import*as e from"@wordpress/interactivity";var t={d:(e,o)=>{for(var s in o)t.o(o,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:o[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const o=(s={getContext:()=>e.getContext,getElement:()=>e.getElement,store:()=>e.store},c={},t.d(c,s),c);var s,c;let n=new Set;const a="spectra-modal-active";function i(){const e=document.body;n.size>0?e.classList.add(a):e.classList.remove(a)}const{actions:r}=(0,o.store)("spectra/modal",{actions:{open(){const{blockId:e}=(0,o.getContext)(),t=document.getElementById(e);if(t){t.classList.add("active"),n.add(e),i();const o=t.querySelector(".spectra-modal-popup");o&&(o.setAttribute("aria-hidden","false"),o.setAttribute("aria-modal","true"),o.setAttribute("role","dialog"));const s=new CustomEvent("spectra:modal:opened",{detail:{blockId:e},bubbles:!0});document.dispatchEvent(s)}},close(){const{blockId:e}=(0,o.getContext)(),t=document.getElementById(e);if(t){t.classList.remove("active"),n.delete(e),i();const o=t.querySelector(".spectra-modal-popup");o&&(o.setAttribute("aria-hidden","true"),o.removeAttribute("aria-modal"));const s=new CustomEvent("spectra:modal:closed",{detail:{blockId:e},bubbles:!0});document.dispatchEvent(s)}},toggle(){const{blockId:e}=(0,o.getContext)(),t=document.getElementById(e);t&&(t.classList.contains("active")?r.close():r.open())}},callbacks:{initialize(){const e=(0,o.getContext)(),{ref:t}=(0,o.getElement)(),{blockId:s,modalTrigger:c,cssClass:n,cssId:a,exitIntent:i,showAfterSeconds:r,noOfSecondsToShow:d,enableCookies:l,setCookiesOn:m,hideForDays:u,overlayClick:b,escPress:p}=e;setTimeout((()=>{const e=t.querySelector(".spectra-modal-popup");e&&(e.setAttribute("aria-hidden","true"),e.setAttribute("role","dialog"))}),0);const g=new CustomEvent("spectra:modal:initialized",{detail:{blockId:s,modalTrigger:c,cssClass:n,cssId:a,exitIntent:i,showAfterSeconds:r,noOfSecondsToShow:d,enableCookies:l,setCookiesOn:m,hideForDays:u,overlayClick:b,escPress:p},bubbles:!0});t.dispatchEvent(g)}}});export{r as actions};