/** © Read the LICENSE file located at the theme folder. */!function(){"use strict";class e{static load(s){const t=new e;t.ready=t.ready.bind(t),t.callback=s,t.listen()}listen(){"loading"!==document.readyState?this.ready():(document.addEventListener("DOMContentLoaded",this.ready),window.addEventListener("load",this.ready))}ready(){document.removeEventListener("DOMContentLoaded",this.ready),window.removeEventListener("load",this.ready),this.callback()}}class s{constructor(){this.subheaderIsOpened=!1,this.body=document.querySelector("body"),this.overlayMask=document.querySelector("#js-overlay-mask"),this.subheader=document.querySelector("#js-subheader"),this.subheaderSearchForm=this.subheader?this.subheader.querySelector("form"):null,this.subheaderLinks=document.querySelectorAll("a"),this.openSubheaderButton=document.querySelector("#js-subheader-menu-opener"),this.searchButton=document.querySelector("#js-subheader-search-opener"),this.headerSearchForm=document.querySelector(".js-search form"),this.toggleSubheaderMenu=this.toggleSubheaderMenu.bind(this),this.toggleSubheaderSearch=this.toggleSubheaderSearch.bind(this),this.closeSubheader=this.closeSubheader.bind(this)}init(){this.addEventListeners()}addEventListeners(){this.openSubheaderButton&&this.openSubheaderButton.addEventListener("click",this.toggleSubheaderMenu),this.searchButton&&this.searchButton.addEventListener("click",this.toggleSubheaderSearch),this.overlayMask&&this.overlayMask.addEventListener("click",this.closeSubheader),this.subheaderLinks.forEach((e=>{e.addEventListener("click",this.closeSubheader)}))}toggleSubheaderMenu(){this.subheader&&!this.isVisible(this.subheader)&&this.body.classList.add("subheader-menu"),this.toggleSubheader()}toggleSubheaderSearch(){if(this.headerSearchForm&&this.isVisible(this.headerSearchForm))return this.headerSearchForm.submit();this.toggleSubheader(),this.subheaderSearchForm&&this.isVisible(this.subheaderSearchForm)&&(this.body.classList.add("subheader-search"),this.subheaderSearchForm.querySelector('input[type="search"]').focus())}toggleSubheader(){this.subheader&&this.isVisible(this.subheader)?this.closeSubheader():this.openSubheader()}openSubheader(){this.subheaderIsOpened||(this.body.classList.add("subheader-opened"),this.subheaderIsOpened=!0)}closeSubheader(){this.subheaderIsOpened&&(this.body.classList.remove("subheader-opened"),this.body.classList.remove("subheader-search"),this.body.classList.remove("subheader-menu"),this.subheaderIsOpened=!1)}isVisible(e){return e.offsetWidth>0&&e.offsetHeight>0}}e.load((()=>{window.wasabi_menu=new s,window.wasabi_menu.init()}))}();