import*as e from"@wordpress/interactivity";var t,r,n={d:function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},o=(t={getElement:function(){return e.getElement},store:function(){return e.store},withSyncEvent:function(){return e.withSyncEvent}},r={},n.d(r,t),r);let a=[];function i(e){return e.classList.contains("a11y-speak-region")||e.classList.contains("a11y-speak-intro-text")||e.querySelector("#a11y-speak-assertive, #a11y-speak-polite, #a11y-speak-intro-text")}const{__}=wp.i18n,{state:s,actions:c}=(0,o.store)("surecart/sidebar",{state:{mobileOpen:!1,get dialog(){let e=document?.querySelector(".sc-sidebar-drawer")||null;if(!e){const{ref:t}=(0,o.getElement)();e=t.parentElement.querySelector(".sc-sidebar-drawer")||t.closest(".sc-sidebar-drawer")||null}return e},get ariaLabelDesktop(){return __(s?.open?"Hide filters":"Show filters","surecart")},ariaLabelMobile:__("Show filters","surecart")},actions:{open:function*(){s.mobileOpen=!0,function(e){a=[];let t=e;for(;t&&t!==document.body;){const e=t.parentElement;if(!e)break;Array.from(e.children).forEach((e=>{e===t||e.hasAttribute("inert")||i(e)||(e.setAttribute("inert",""),a.push(e))})),t=e}}(document.querySelector(".sc-sidebar-drawer")),s.ariaLabelMobile=__("Close sidebar","surecart")},close:()=>{s.mobileOpen=!1,a.forEach((e=>{e.removeAttribute("inert")})),a=[],s.ariaLabelMobile=__("Open sidebar","surecart")},closeDesktop:()=>{s.open=!1},openDesktop:()=>{s.open=!0},toggleDesktop:(0,o.withSyncEvent)((e=>{e?.key&&" "!==e?.key&&"Enter"!==e?.key||(e?.preventDefault(),s.open=!s.open)})),toggleMobile:(0,o.withSyncEvent)((e=>{e?.key&&" "!==e?.key&&"Enter"!==e?.key||(e?.preventDefault(),s?.mobileOpen?c.close():c.open())})),closeOverlay:(0,o.withSyncEvent)((e=>{e.target===e.currentTarget&&c.close()})),handleKeydown:(0,o.withSyncEvent)((e=>{s.mobileOpen&&"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),c.close())}))}});