{"version":3,"file":"filter.js","sources":["../../../../src/assets/scripts/filter.entry.js"],"sourcesContent":["window.arjoFilterModule =\n window.arjoFilterModule ||\n (() => {\n const status = {\n isInitialized: false,\n };\n const init = () => {\n if (status.isInitialized) return;\n const filters = [...document.querySelectorAll('.arjo-m-filter-switcher')];\n if (filters.length === 0) return;\n filters.forEach((filter) => {\n const id = filter.dataset.filterId;\n if (!id) return;\n\n const isFilterHashing = filter.dataset.isFilterHashing;\n\n const prefix = `#${id}-`\n\n const currentHashingRadio = window.location.hash.includes(prefix) ? window.location.hash.replace(prefix, '') : undefined;\n\n const generateHashing = (value) => {\n return `${prefix}${value}`\n }\n\n const changeHandler = (e) => {\n const val = e.target.value;\n if (!val) return;\n const customEvent = new CustomEvent(id, {\n detail: {\n id: val,\n },\n });\n\n if (isFilterHashing) {\n window.location.hash = generateHashing(val);\n }\n\n window.dispatchEvent(customEvent);\n };\n const tabRadios = [...filter.querySelectorAll('.arjo-m-filter-switcher__input')];\n tabRadios.forEach((tabRadio) => {\n tabRadio.addEventListener('change', changeHandler);\n\n if (window.location.hash === generateHashing(tabRadio.value)) {\n tabRadio.checked = true;\n // Filter's display property might equal to none when it is included inside tab container\n // So we need to scroll to the tab container instead of itself.\n const insideTabContainer = filter?.closest('.arjo-o-tab-container__contents');\n if (insideTabContainer) {\n const tabWrapper = filter?.closest('div[data-arjo-tab]');\n const tabStyle = window.getComputedStyle(tabWrapper);\n if (tabStyle.display !== 'none') {\n filter.scrollIntoViewEx();\n } else {\n insideTabContainer.scrollIntoViewEx();\n }\n return;\n }\n\n const style = window.getComputedStyle(filter);\n if (style.display !== 'none') {\n filter.scrollIntoViewEx();\n }\n }\n });\n\n window.addEventListener('hashchange', () => {\n tabRadios.forEach((tabRadio) => {\n if (window.location.hash === generateHashing(tabRadio.value)) {\n tabRadio.checked = true;\n }\n });\n })\n\n const currentRadio = tabRadios[0];\n setTimeout(() => {\n window.dispatchEvent(\n new CustomEvent(id, {\n detail: {\n id: currentHashingRadio ?? currentRadio.value,\n },\n })\n );\n }, 0);\n });\n status.isInitialized = true;\n };\n\n return { init };\n })();\n\nwindow.addEventListener('load', window.arjoFilterModule.init);\n"],"names":["status","filters","filter","id","isFilterHashing","prefix","currentHashingRadio","generateHashing","value","changeHandler","e","val","customEvent","tabRadios","tabRadio","insideTabContainer","tabWrapper","currentRadio"],"mappings":"AAAA,OAAO,iBACL,OAAO,mBACN,IAAM,CACL,MAAMA,EAAS,CACb,cAAe,EACrB,EAmFI,MAAO,CAAE,KAlFI,IAAM,CACjB,GAAIA,EAAO,cAAe,OAC1B,MAAMC,EAAU,CAAC,GAAG,SAAS,iBAAiB,yBAAyB,CAAC,EACpEA,EAAQ,SAAW,IACvBA,EAAQ,QAASC,GAAW,CAC1B,MAAMC,EAAKD,EAAO,QAAQ,SAC1B,GAAI,CAACC,EAAI,OAET,MAAMC,EAAkBF,EAAO,QAAQ,gBAEjCG,EAAS,IAAIF,CAAE,IAEfG,EAAsB,OAAO,SAAS,KAAK,SAASD,CAAM,EAAI,OAAO,SAAS,KAAK,QAAQA,EAAQ,EAAE,EAAI,OAEzGE,EAAmBC,GAChB,GAAGH,CAAM,GAAGG,CAAK,GAGpBC,EAAiBC,GAAM,CAC3B,MAAMC,EAAMD,EAAE,OAAO,MACrB,GAAI,CAACC,EAAK,OACV,MAAMC,EAAc,IAAI,YAAYT,EAAI,CACtC,OAAQ,CACN,GAAIQ,CACL,CACb,CAAW,EAEGP,IACF,OAAO,SAAS,KAAOG,EAAgBI,CAAG,GAG5C,OAAO,cAAcC,CAAW,CAC1C,EACcC,EAAY,CAAC,GAAGX,EAAO,iBAAiB,gCAAgC,CAAC,EAC/EW,EAAU,QAASC,GAAa,CAG9B,GAFAA,EAAS,iBAAiB,SAAUL,CAAa,EAE7C,OAAO,SAAS,OAASF,EAAgBO,EAAS,KAAK,EAAG,CAC5DA,EAAS,QAAU,GAGnB,MAAMC,EAAqBb,GAAA,YAAAA,EAAQ,QAAQ,mCAC3C,GAAIa,E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