(()=>{"use strict";const e=window.wp.interactivity,n=["a[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","[contenteditable]",'[tabindex]:not([tabindex^="-"])'];document.addEventListener("click",(()=>{}));const{state:t,actions:o}=(0,e.store)("core/navigation",{state:{get roleAttribute(){return"overlay"===(0,e.getContext)().type&&t.isMenuOpen?"dialog":null},get ariaModal(){return"overlay"===(0,e.getContext)().type&&t.isMenuOpen?"true":null},get ariaLabel(){const n=(0,e.getContext)();return"overlay"===n.type&&t.isMenuOpen?n.ariaLabel:null},get isMenuOpen(){return Object.values(t.menuOpenedBy).filter(Boolean).length>0},get menuOpenedBy(){const n=(0,e.getContext)();return"overlay"===n.type?n.overlayOpenedBy:n.submenuOpenedBy}},actions:{openMenuOnHover(){const{type:n,overlayOpenedBy:t}=(0,e.getContext)();"submenu"===n&&0===Object.values(t||{}).filter(Boolean).length&&o.openMenu("hover")},closeMenuOnHover(){const{type:n,overlayOpenedBy:t}=(0,e.getContext)();"submenu"===n&&0===Object.values(t||{}).filter(Boolean).length&&o.closeMenu("hover")},openMenuOnClick(){const n=(0,e.getContext)(),{ref:t}=(0,e.getElement)();n.previousFocus=t,o.openMenu("click")},closeMenuOnClick(){o.closeMenu("click"),o.closeMenu("focus")},openMenuOnFocus(){o.openMenu("focus")},toggleMenuOnClick(){const n=(0,e.getContext)(),{ref:l}=(0,e.getElement)();window.document.activeElement!==l&&l.focus();const{menuOpenedBy:c}=t;c.click||c.focus?(o.closeMenu("click"),o.closeMenu("focus")):(n.previousFocus=l,o.openMenu("click"))},handleMenuKeydown(n){const{type:l,firstFocusableElement:c,lastFocusableElement:u}=(0,e.getContext)();if(t.menuOpenedBy.click){if("Escape"===n?.key)return o.closeMenu("click"),void o.closeMenu("focus");"overlay"===l&&"Tab"===n.key&&(n.shiftKey&&window.document.activeElement===c?(n.preventDefault(),u.focus()):n.shiftKey||window.document.activeElement!==u||(n.preventDefault(),c.focus()))}},handleMenuFocusout(n){const{modal:t,type:l}=(0,e.getContext)();(null===n.relatedTarget||!t?.contains(n.relatedTarget)&&n.target!==window.document.activeElement&&"submenu"===l)&&(o.closeMenu("click"),o.closeMenu("focus"))},openMenu(n="click"){const{type:o}=(0,e.getContext)();t.menuOpenedBy[n]=!0,"overlay"===o&&document.documentElement.classList.add("has-modal-open")},closeMenu(n="click"){const o=(0,e.getContext)();t.menuOpenedBy[n]=!1,t.isMenuOpen||(o.modal?.contains(window.document.activeElement)&&o.previousFocus?.focus(),o.modal=null,o.previousFocus=null,"overlay"===o.type&&document.documentElement.classList.remove("has-modal-open"))}},callbacks:{initMenu(){const o=(0,e.getContext)(),{ref:l}=(0,e.getElement)();if(t.isMenuOpen){const e=l.querySelectorAll(n);o.modal=l,o.firstFocusableElement=e[0],o.lastFocusableElement=e[e.length-1]}},focusFirstElement(){const{ref:o}=(0,e.getElement)();if(t.isMenuOpen){const e=o.querySelectorAll(n);e?.[0]?.focus()}}}},{lock:!0})})();
//# sourceMappingURL=view.min.js.map