const TEMPLATE_LIBRARY = TemplateCatalog.all;
const TEMPLATE_CATEGORIES = TemplateCatalog.categories;
function templateCategoryIds(tpl) {
    return Array.isArray(tpl?.categories) && tpl.categories.length ? tpl.categories : ["shaadi"];
}
function templateMatchesCategory(tpl, categoryId) {
    if (!categoryId || categoryId === "all")
        return true;
    return templateCategoryIds(tpl).includes(categoryId);
}
function getTemplateCategory(categoryId) {
    return TEMPLATE_CATEGORIES.find((cat) => cat.id === categoryId) || TEMPLATE_CATEGORIES[0];
}
function TemplateCategoryTabs({ active = "all", onChange, templates = TEMPLATE_LIBRARY }) {
    const available = TEMPLATE_CATEGORIES.filter(cat => cat.id === 'all' || templates.some(tpl => templateMatchesCategory(tpl, cat.id)));
    const shortLabels = { all: 'All designs', shaadi: 'Weddings', 'fight-girlfriend': 'For her', 'fight-boyfriend': 'For him' };
    return (React.createElement("div", { className: "template-category-wrap", "aria-label": "Template categories" },
        React.createElement("div", { className: "template-category-scroll", role: "group", "aria-label": "Filter template designs" }, available.map((cat) => {
            const selected = active === cat.id;
            return (React.createElement("button", { key: cat.id, type: "button", className: "template-category-pill" + (selected ? " is-active" : ""), "aria-pressed": selected, onClick: () => onChange && onChange(cat.id) }, shortLabels[cat.id] || cat.label.replace(/ Templates?$/i, '')));
        })),
        React.createElement("div", { className: "template-category-note" },
            "Make it yours with ",
            React.createElement("span", null, "Your words"),
            React.createElement("span", null, "Photographs"),
            React.createElement("span", null, "A shareable link"),
            React.createElement("span", null, "Dashboard"))));
}
function TemplateCategoryEmpty({ category }) {
    const cat = category || TEMPLATE_CATEGORIES[0];
    return (React.createElement("div", { className: "template-category-empty" },
        React.createElement("h3", null, cat.label),
        React.createElement("p", null, "No designs are available in this category. Choose All designs to explore the collection.")));
}
Object.assign(window, {
    TEMPLATE_LIBRARY,
    TEMPLATE_CATEGORIES,
    templateMatchesCategory,
    getTemplateCategory,
    TemplateCategoryTabs,
    TemplateCategoryEmpty,
});
