(()=>{"use strict";function e(e){if("1"===e.dataset.mvReady)return;e.dataset.mvReady="1";const t=parseInt(e.dataset.mvOpenDelay,10)||0,n=parseInt(e.dataset.mvCloseDelay,10)||0,a=parseInt(e.dataset.mvBreakpoint,10)||782,o="hover"===e.dataset.mvTrigger,r=window.matchMedia(`(min-width: ${a+1}px)`),i=window.matchMedia("(hover: hover) and (pointer: fine)");let s=null,d=null,c=null;const u=()=>o&&r.matches&&i.matches;function l(){window.clearTimeout(s),window.clearTimeout(d)}function m(t){const n=t.querySelector(":scope > [data-mv-toggle]"),a=n&&n.getAttribute("aria-controls");return a?e.querySelector(`#${CSS.escape(a)}`):null}function v(e){if(c===e)return;w();const t=m(e),n=e.querySelector(":scope > [data-mv-toggle]");t&&n&&(t.hidden=!1,t.offsetHeight,e.classList.add("is-open"),n.setAttribute("aria-expanded","true"),c=e,g(t))}function g(t){if(t.classList.contains("menuverse-mega__panel--full"))return void e.style.setProperty("--menuverse-mega-top",`${Math.round(e.getBoundingClientRect().bottom)}px`);t.style.marginInlineStart="";const n=t.getBoundingClientRect().right-(window.innerWidth-16);n>0&&(t.style.marginInlineStart=`-${Math.round(n)}px`)}function p(){if(!c)return;const e=m(c);e&&g(e)}function w(){if(!c)return;const e=m(c),t=c.querySelector(":scope > [data-mv-toggle]");c.classList.remove("is-open"),t&&t.setAttribute("aria-expanded","false"),e&&(e.hidden=!0,e.style.marginInlineStart=""),c=null}window.addEventListener("scroll",p,{passive:!0}),window.addEventListener("resize",p,{passive:!0}),e.querySelectorAll(".menuverse-mega__item").forEach(e=>{const a=e.querySelector(":scope > [data-mv-toggle]");a&&(a.addEventListener("click",()=>{l(),c===e?w():v(e)}),e.addEventListener("mouseenter",()=>{u()&&(l(),s=window.setTimeout(()=>v(e),t))}),e.addEventListener("mouseleave",()=>{u()&&(l(),d=window.setTimeout(w,n))}))}),e.addEventListener("keydown",e=>{if("Escape"!==e.key||!c)return;const t=c.querySelector(":scope > [data-mv-toggle]");e.preventDefault(),w(),t&&t.focus()}),e.addEventListener("focusout",t=>{c&&!e.contains(t.relatedTarget)&&w()}),document.addEventListener("click",t=>{c&&!e.contains(t.target)&&w()}),r.addEventListener("change",()=>{l(),w()})}function t(){document.querySelectorAll("[data-menuverse-mega]").forEach(e)}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t(),window.menuverse=window.menuverse||{},window.menuverse.initMegaMenu=t})();