(()=>{"use strict";var e={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},d:(t,o)=>{for(var s in o)e.o(o,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:o[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=function(e,t,o){let s=`${e}=${t}; path=/`;if(o){const e=new Date;e.setTime(e.getTime()+60*o*60*1e3),s+=`; expires=${e.toUTCString()}`}document.cookie=s},o=window.wp.apiFetch;var s=e.n(o);const n=async(e,o)=>{if(e&&!function(e){const t=`; ${document.cookie}`.split(`; ${e}=`);return 2===t.length?t.pop().split(";").shift():null}(`pbb_conversion_${o}`)&&!window.parent.location.search.includes("preview=true")&&!window.parent.location.search.includes("subpage=templates")){const e=Number(sessionStorage.getItem("pbb_logs"));await s()({path:"/pbb/v1/popup/logs",method:"PUT",data:{id:e,converted:!0,refferer:window.parent.document.referrer}}).then(e=>{"success"===e.status?t(`pbb_conversion_${o}`,"true",8760):console.error("Error updating conversion count:",e.message)})}},r=window.wp.hooks;var i;i="button",window.addEventListener("load",()=>{window[`__POPUPKIT_${i.toUpperCase()}_INIT`]||(window[`__POPUPKIT_${i.toUpperCase()}_INIT`]=!0,(()=>{const e=document.querySelectorAll(".pbb-btn"),o=()=>{const e=document.querySelector(".popup-builder-modal"),o=JSON.parse(e.getAttribute("data-settings"));((e,o)=>{let s=e.getAttribute("id");s=s.replace("popup-builder-","");const{entrAnimation:n,exitAnimation:r,animationDuration:i,type:p}=o||{},c=e.querySelector(".popup-builder-container");c.classList.remove(`${n}`),c.classList.add(`${r}`),c.classList.add("reverse"),setTimeout(()=>{["popup","full-screen"].includes(p)&&o?.preventScroll&&(document.body.style.overflow=""),e.classList.remove("popup-builder-modal--open"),c.classList.remove(`${r}`),c.classList.remove("reverse"),t(`pbb_closed_${s}`,"true",8760),e.remove()},1e3*i)})(e,o)};for(const s of e){const e=JSON.parse(s.getAttribute("data-settings")),{istrackConversion:i,clickEvent:p,closeCampaign:c,step:a,cookies:l}=e||{};(["closeCampaign","openUrl","step","cookieConsent"].includes(p)||i)&&s.addEventListener("click",u=>{u.preventDefault();const d=s.closest(".popup-builder-modal"),b=d?.id.replace("popup-builder-","");if(n(i,b),"closeCampaign"===p&&c)o();else if("openUrl"===p){const e=s.getAttribute("href"),t=s.getAttribute("target");e&&window.top.open(e,t||"_self")}else if("step"===p&&a){const t=(0,r.applyFilters)("popupkit.steps.button",""),o=document.querySelectorAll(".wp-block-popup-builder-block-step");for(const e of o)e.classList.contains("active")&&e.classList.remove("active");const s=t[parseInt(a)];s.classList.add("active"),document.querySelector(".popupkit-steps-inner").insertBefore(s,o[parseInt(e.step)])}else if("cookieConsent"===p&&l){const e=JSON.parse(l);for(const o of e){const{name:e,value:s,expires:n}=o;e&&s&&t(e,s,24*n)}o()}})}})())})})();