{"version":3,"file":"../../javascript/header.js","names":["Header","delayNavItem","delayMobileNav","constructor","this","header","document","querySelector","window","matchMedia","matches","sentinel","headerTop","toggle","switchToggle","headerNav","headerNavItems","querySelectorAll","notice","headerBackground","init","IntersectionObserver","initIntersectionObserver","initFallbackScrollListener","watchNavItems","watchToggle","watchBackgroundClick","entries","position","isIntersecting","setAttribute","observe","addEventListener","scrollY","forEach","item","e","target","classList","contains","dataset","sublinks","preventDefault","toggleNavItem","focus","activateNavItem","el","clearTimeout","deactivateTimeout","add","activateTimeout","setTimeout","Astro","_search","deactivate","deactivateNavItem","navItem","remove","removeAttribute","activate","documentElement","bind","headerInstance","_header"],"sources":["header.js"],"mappings":"AAAA,MAAMA,OACFC,GAAgB,IAChBC,GAAkB,IAElB,WAAAC,GACIC,KAAKC,OAASC,SAASC,cAAc,cAEhCH,KAAKC,SAING,OAAOC,WAAW,uBAAuBC,UACzCN,MAAKH,EAAgB,GAGzBG,KAAKO,SAAWL,SAASC,cAAc,gBACvCH,KAAKQ,UAAYR,KAAKC,OAAOE,cAAc,mBAC3CH,KAAKS,OAAST,KAAKC,OAAOE,cAAc,sBACxCH,KAAKU,aAAeV,KAAKC,OAAOE,cAAc,sBAC9CH,KAAKW,UAAYX,KAAKC,OAAOE,cAAc,kBAC3CH,KAAKY,eAAiBZ,KAAKC,OAAOY,iBAC9B,wBAEJb,KAAKc,OAASZ,SAASC,cAAc,eACrCH,KAAKe,iBAAmBb,SAASC,cAAc,yBACnD,CAEA,IAAAa,GACShB,KAAKC,SAING,OAAOa,qBACPjB,KAAKkB,2BAELlB,KAAKmB,6BAGTnB,KAAKoB,gBACLpB,KAAKqB,cACLrB,KAAKsB,uBACT,CAKAJ,yBAA2B,KACN,IAAID,qBAAsBM,IACvC,MAAMC,EAAWD,EAAQ,GAAGE,eAAiB,SAAW,SACxDzB,KAAKC,OAAOyB,aAAa,gBAAiBF,KAErCG,QAAQ3B,KAAKO,WAM1BY,2BAA6B,KACzBf,OAAOwB,iBA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zBnC,KAAKkD,aACLlD,KAAKuD,YAEnB,CAEA,QAAAA,GACIvD,KAAKC,OAAOiC,UAAUW,IAAI,sBAC1B3C,SAASsD,gBAAgBtB,UAAUW,IAAI,eACvC7C,KAAK8C,gBAAkBC,WAAW,KAC9B/C,KAAKC,OAAOiC,UAAUW,IAAI,mBAC3B7C,MAAKF,GAERkD,MAAMC,QAAQC,YAClB,CAEA,UAAAA,GACIhD,SAASsD,gBAAgBtB,UAAUmB,OAAO,eAC1CrD,KAAKC,OAAOiC,UAAUmB,OAAO,kBAC7BrD,KAAK4C,kBAAoBG,WAAW,KAChC/C,KAAKC,OAAOiC,UAAUmB,OAAO,uBAC9BrD,MAAKF,EACZ,CAEA,oBAAAwB,GACItB,KAAKe,kBAAkBa,iBACnB,QACA5B,KAAKmD,kBAAkBM,KAAKzD,MAEpC,EAGJE,SAAS0B,iBAAiB,mBAAoB,KAC1C,MAAM8B,EAAiB,IAAI9D,OAE3B8D,EAAe1C,OAEfgC,MAAMW,QAAUD","ignoreList":[],"sourceRoot":"../../../../resources/javascript","sourcesContent":["class Header {\n    #delayNavItem = 150;\n    #delayMobileNav = 150;\n\n    constructor() {\n        this.header = document.querySelector('.js-header');\n\n        if (!this.header) {\n            return;\n        }\n\n        if (window.matchMedia('(max-width: 1023px)').matches) {\n            this.#delayNavItem = 0;\n        }\n\n        this.sentinel = document.querySelector('.js-sentinel');\n        this.headerTop = this.header.querySelector('.js-header__top');\n        this.toggle = this.header.querySelector('.js-header__toggle');\n        this.switchToggle = this.header.querySelector('.js-switch__toggle');\n        this.headerNav = this.header.querySelector('.js-header-nav');\n        this.headerNavItems = this.header.querySelectorAll(\n            '.js-header-nav__item'\n        );\n        this.notice = document.querySelector('.notice-bar');\n        this.headerBackground = document.querySelector('.js-header-background');\n    }\n\n    init() {\n        if (!this.header) {\n            return;\n        }\n\n        if (window.IntersectionObserver) {\n            this.initIntersectionObserver();\n        } else {\n            this.initFallbackScrollListener();\n        }\n\n        this.watchNavItems();\n        this.watchToggle();\n        this.watchBackgroundClick();\n    }\n\n    /**\n     * Initializes intersection observer and updates header position.\n     */\n    initIntersectionObserver = () => {\n        const observer = new IntersectionObserver((entries) => {\n            const position = entries[0].isIntersecting ? 'static' : 'sticky';\n            this.header.setAttribute('data-position', position);\n        });\n        observer.observe(this.sentinel);\n    };\n\n    /**\n     * Initializes scroll event listener for browsers without IntersectionObserver support.\n     */\n    initFallbackScrollListener = () => {\n        window.addEventListener('scroll', () => {\n            const position = window.scrollY > 0 ? 'static' : 'sticky';\n            this.header.setAttribute('data-position', position);\n        });\n    };\n\n    watchNavItems() {\n        this.headerNavItems.forEach((item) => {\n            item.addEventListener('click', (e) => {\n                if (\n                    e.target.classList.contains('header-nav__link') &&\n                    item.dataset.sublinks > 0\n                ) {\n                    e.preventDefault();\n                    this.toggleNavItem(item);\n                    item.querySelector('a')?.focus();\n                }\n            });\n        });\n    }\n\n    activateNavItem(el) {\n        if (el.dataset.sublinks == 0) {\n            return;\n        }\n\n        clearTimeout(this.deactivateTimeout); // Clear any pending deactivation timeouts\n\n        el.classList.add('header-nav__item--activating');\n        this.headerBackground?.classList.add('header-background--activating');\n\n        this.activateTimeout = setTimeout(() => {\n            el.classList.add('header-nav__item--active');\n            this.headerBackground?.classList.add('header-background--active');\n        }, this.#delayNavItem);\n\n        Astro._search.deactivate();\n    }\n\n    deactivateNavItem() {\n        clearTimeout(this.activateTimeout); // Clear any pending activation timeouts\n\n        this.headerNavItems.forEach((navItem) =>\n            navItem.classList.remove('header-nav__item--active')\n        );\n        this.headerBackground?.classList.remove('header-background--active');\n\n        this.deactivateTimeout = setTimeout(() => {\n            this.headerNavItems.forEach((navItem) =>\n                navItem.classList.remove('header-nav__item--activating')\n            );\n            this.headerBackground?.classList.remove(\n                'header-background--activating'\n            );\n            this.header.removeAttribute('active-item');\n        }, this.#delayNavItem);\n    }\n\n    toggleNavItem(el) {\n        if (el.classList.contains('header-nav__item--active')) {\n            this.deactivateNavItem();\n        } else {\n            const activeItem = this.header.querySelector(\n                '.header-nav__item--active'\n            );\n            if (activeItem) {\n                this.deactivateNavItem();\n            }\n            // Delay the activation to avoid race condition with deactivation\n            setTimeout(() => {\n                this.activateNavItem(el);\n            }, this.#delayNavItem);\n        }\n    }\n\n    watchToggle() {\n        this.toggle?.addEventListener('click', () => {\n            this.header.classList.contains('header--activating')\n                ? this.deactivate()\n                : this.activate();\n        });\n    }\n\n    activate() {\n        this.header.classList.add('header--activating');\n        document.documentElement.classList.add('lock-scroll');\n        this.activateTimeout = setTimeout(() => {\n            this.header.classList.add('header--active');\n        }, this.#delayMobileNav);\n\n        Astro._search.deactivate();\n    }\n\n    deactivate() {\n        document.documentElement.classList.remove('lock-scroll');\n        this.header.classList.remove('header--active');\n        this.deactivateTimeout = setTimeout(() => {\n            this.header.classList.remove('header--activating');\n        }, this.#delayMobileNav);\n    }\n\n    watchBackgroundClick() {\n        this.headerBackground?.addEventListener(\n            'click',\n            this.deactivateNavItem.bind(this)\n        );\n    }\n}\n\ndocument.addEventListener('DOMContentLoaded', () => {\n    const headerInstance = new Header();\n\n    headerInstance.init();\n\n    Astro._header = headerInstance;\n});\n"]}