class AgeVerifierPopup extends HTMLElement{constructor(){if(super(),this.cookieName=`Minimog:age-verifier-${this.id}`,this.cookie=getCookie(this.cookieName),this.modal=this.querySelector(".m-modal"),this.modalContent=this.modal.querySelector(".m-modal--content"),this.declineButton=this.querySelector("[data-age-verifier-decline-button]"),this.declineContent=this.querySelector("[data-age-verifier-decline-content]"),this.content=this.querySelector("[data-age-verifier-content]"),this.agreeButton=this.querySelector("[data-age-verifier-agree-button]"),this.returnButton=this.querySelector("[data-age-verifier-return-button]"),""===this.cookie&&"true"===this.dataset.enable){if(Shopify&&Shopify.designMode)return;this.openPopup();if(!sessionStorage.getItem(this.id))return;this.showDeclineContent()}}connectedCallback(){this.declineButton&&this.declineButton.addEventListener("click",(e=>{e.preventDefault(),this.showDeclineContent(),sessionStorage.setItem(this.id,"age-second-view")})),this.returnButton&&this.returnButton.addEventListener("click",(e=>{e.preventDefault(),this.hideDeclineContent();sessionStorage.getItem(this.id)&&sessionStorage.removeItem(this.id)})),this.agreeButton&&this.agreeButton.addEventListener("click",(e=>{e.preventDefault(),this.hideDeclineContent(),"true"===this.dataset.enable&&setCookie(this.cookieName,"agreed",30),this.closePopup()})),Shopify.designMode&&(document.addEventListener("shopify:section:select",this.__shopifySectionSelect.bind(this)),document.addEventListener("shopify:section:load",this.__shopifySectionLoad.bind(this)))}disconnectedCallback(){Shopify.designMode&&(document.removeEventListener("shopify:section:select",this.__shopifySectionSelect.bind(this)),document.removeEventListener("shopify:section:load",this.__shopifySectionLoad.bind(this)))}__shopifySectionLoad(e){if(e.detail.sectionId===this.dataset.sectionId&&"true"===this.dataset.designMode){this.openPopup();if(!sessionStorage.getItem(this.id))return;this.showDeclineContent(e)}}__shopifySectionSelect(e){e.detail.sectionId===this.dataset.sectionId&&"true"===this.dataset.designMode?this.openPopup():this.closePopup()}showDeclineContent(){this.declineContent.classList.remove("m:hidden"),this.content.classList.add("m:hidden")}hideDeclineContent(){this.declineContent.classList.add("m:hidden"),this.content.classList.remove("m:hidden")}openPopup(){this.modal.style.setProperty("--m-opacity","1"),this.modal.classList.add("m-open-modal")}closePopup(){this.modal.classList.remove("m-open-modal"),this.modal.style.setProperty("--m-opacity","0")}}customElements.define("m-age-verifier-popup",AgeVerifierPopup);