{"version":3,"file":"tab-Bzwdp__d.js","sources":["../../src/js/components/tab.ts"],"sourcesContent":["export function initTabs() {\n const allTabsOnPage =\n document.querySelectorAll('[data-tab-frame]');\n\n allTabsOnPage.forEach((tabFrame) => {\n const tabTriggers =\n tabFrame.querySelectorAll('[data-tab-trigger]');\n const tabContentContainer =\n tabFrame.querySelector('[data-tab-active]');\n const tabTriggerContainer =\n tabFrame.querySelector('[data-tabs-list]');\n const firstTrigger =\n tabFrame.querySelector('[data-tab-trigger]');\n const firstContent =\n tabContentContainer?.querySelector('[data-tab-content]');\n\n // Check if tab has different layouts for mobile and desktop\n const usesDifferentLayouts =\n tabFrame.dataset.tabDifferentLayouts === 'True';\n\n // Set first mobile content\n if (usesDifferentLayouts) {\n // Set first mobile and desktop content to be shown depending on screen width\n const firstMobileContent =\n tabTriggerContainer?.querySelector('[data-tab-content]');\n\n if (firstMobileContent) {\n firstMobileContent.dataset.state = 'active';\n }\n }\n\n if (firstContent) {\n firstContent.dataset.state = 'active';\n }\n if (firstTrigger) {\n firstTrigger.dataset.state = 'active';\n }\n\n tabTriggers.forEach((trigger) => {\n const selectContent = () => {\n const triggerID = trigger.getAttribute('data-tab-trigger');\n\n const contentToShow = tabFrame.querySelectorAll(\n `[data-tab-content=\"${triggerID}\"]`,\n );\n\n // Hide all content, deactivate all triggers\n const triggersInTab = tabFrame.querySelectorAll('[data-tab-trigger]');\n const contentInTab = tabFrame.querySelectorAll('[data-tab-content]');\n triggersInTab.forEach((t) => {\n const tr = t as HTMLElement;\n tr.dataset.state = 'inactive';\n });\n contentInTab.forEach((c) => {\n const co = c as HTMLElement;\n co.dataset.state = 'inactive';\n });\n\n // Show active content and highlight active trigger\n if (trigger) {\n trigger.dataset.state = 'active';\n }\n\n if (contentToShow[0]) {\n contentToShow.forEach((content) => {\n content.dataset.state = 'active';\n });\n\n if (tabContentContainer) {\n switch (trigger) {\n case trigger.parentNode?.firstElementChild:\n tabContentContainer.dataset.tabActive = 'first';\n break;\n case trigger.parentNode?.lastElementChild:\n tabContentContainer.dataset.tabActive = 'last';\n break;\n default:\n tabContentContainer.dataset.tabActive = 'other';\n break;\n }\n }\n }\n };\n\n trigger.addEventListener('click', selectContent);\n });\n });\n}\n"],"names":["initTabs","tabFrame","tabTriggers","tabContentContainer","tabTriggerContainer","firstTrigger","firstContent","firstMobileContent","trigger","selectContent","_a","_b","triggerID","contentToShow","triggersInTab","contentInTab","t","tr","c","co","content"],"mappings":"AAAO,SAASA,GAAW,CAEvB,SAAS,iBAA8B,kBAAkB,EAE7C,QAASC,GAAa,CAC5B,MAAAC,EACJD,EAAS,iBAA8B,oBAAoB,EACvDE,EACJF,EAAS,cAA2B,mBAAmB,EACnDG,EACJH,EAAS,cAA2B,kBAAkB,EAClDI,EACJJ,EAAS,cAA2B,oBAAoB,EACpDK,EACJH,GAAA,YAAAA,EAAqB,cAA2B,sBAOlD,GAHEF,EAAS,QAAQ,sBAAwB,OAGjB,CAElB,MAAAM,EACJH,GAAA,YAAAA,EAAqB,cAA2B,sBAE9CG,IACFA,EAAmB,QAAQ,MAAQ,SACrC,CAGED,IACFA,EAAa,QAAQ,MAAQ,UAE3BD,IACFA,EAAa,QAAQ,MAAQ,UAGnBH,EAAA,QAASM,GAAY,CAC/B,MAAMC,EAAgB,IAAM,CAvC3B,IAAAC,EAAAC,EAwCO,MAAAC,EAAYJ,EAAQ,aAAa,kBAAkB,EAEnDK,EAAgBZ,EAAS,iBAC7B,sBAAsBW,CAAS,IACjC,EAGME,EAAgBb,EAAS,iBAAiB,oBAAoB,EAC9Dc,EAAed,EAAS,iBAAiB,oBAAoB,EAe/D,GAdUa,EAAA,QAASE,GAAM,CAC3B,MAAMC,EAAKD,EACXC,EAAG,QAAQ,MAAQ,UAAA,CACpB,EACYF,EAAA,QAASG,GAAM,CAC1B,MAAMC,EAAKD,EACXC,EAAG,QAAQ,MAAQ,UAAA,CACpB,EAGGX,IACFA,EAAQ,QAAQ,MAAQ,UAGtBK,EAAc,CAAC,IACHA,E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