if (typeof ModalBox != "function") { class ModalBox2 extends HTMLElement { constructor() { if (window.inertElems = document.querySelectorAll("[data-js-inert]"), super(), this.o = { show: 10, showOnPageOffset: -1, frequency: "day", enabled: !0, showOnce: !0, closeByKey: !0, disableScroll: !0, enableClose: !1, type: !1, blockTabNavigation: !1, openedModalBodyClass: "modal-opened", ...JSON.parse(this.dataset.options) }, this.o.type == "cookies") { this.o.enabled = !1; const showBanner = () => { this.o.enabled = !0, this.show() }, cookiesAccept = () => { window.Shopify.customerPrivacy.setTrackingConsent({ analytics: !0, marketing: !0, preferences: !0 }, () => { }), localStorage.setItem("krown-cookie-banner", "true") }, cookiesDecline = () => { window.Shopify.customerPrivacy.setTrackingConsent({ analytics: !1, marketing: !1, preferences: !1 }, () => { }), localStorage.setItem("krown-cookie-banner", "true") }, initCookieBanner = () => { localStorage.getItem("krown-cookie-banner") !== "true" && showBanner() }; this.querySelector("[data-js-cookies-accept]").addEventListener("click", cookiesAccept), this.querySelector("[data-js-cookies-decline]").addEventListener("click", cookiesDecline), window.Shopify.loadFeatures([{ name: "consent-tracking-api", version: "0.1" }], error => { if (error) throw error; initCookieBanner() }) } if (this._scrollTriggered = !1, this.o.enabled) { this._modalKey = `modal-${document.location.hostname}-${this.id}`, this._modalStorage = localStorage.getItem(this._modalKey) ? JSON.parse(localStorage.getItem(this._modalKey)) : "empty", this.querySelector("[data-content]") && (this._modalText = this.querySelector("[data-content]").textContent); const timeNow = new Date().getTime(), inBetween = Math.round((timeNow - this._modalStorage.shown) / 1e3); let showModal = !1; if ((this._modalStorage == "empty" || this.o.frequency == "day" && inBetween > 86400 || this.o.frequency == "week" && inBetween > 604800 || this.o.frequency == "month" && inBetween > 2419200 || this._modalStorage.content != this._modalText) && (showModal = !0), showModal) if (this.o.type == "exit_intent_popup") { let lastMouseY = 0, topOffset = 20; document.addEventListener("mousemove", e => { const currentMouseY = e.clientY; currentMouseY < lastMouseY && currentMouseY < topOffset && !Shopify.designMode && this.show(), lastMouseY = currentMouseY }) } else this.o.showOnPageOffset > 0 ? (this._onScroll = () => { window.scrollY / (document.documentElement.scrollHeight - window.innerHeight) * 100 >= this.o.showOnPageOffset && !this._scrollTriggered && (this._scrollTriggered = !0, setTimeout(() => { this.show() }, parseInt(this.o.show * 1e3)), window.removeEventListener("scroll", this._onScroll)) }, window.addEventListener("scroll", this._onScroll, { passive: !0 })) : setTimeout(() => { this.show() }, parseInt(this.o.show * 1e3)); this.querySelectorAll("[data-js-close]").forEach(elm => elm.addEventListener("click", () => { this.hide(this.o.showOnce) })) } else this.querySelectorAll("[data-js-close]").forEach(elm => elm.addEventListener("click", () => { this.hide(this.o.showOnce) })); this.o.enableClose == !0 && this.querySelectorAll("[data-js-close]").forEach(elm => elm.addEventListener("click", () => { this.hide(this.o.showOnce) })), this.o.closeByKey && document.addEventListener("keydown", e => { e.keyCode == 27 && this.classList.contains("active") && this.hide(this.o.showOnce) }) } show(customContent = !1) { if (customContent && document.querySelector(customContent)) { const content = document.querySelector(customContent).innerHTML, modalCommon = document.getElementById("modal-common"); modalCommon.innerHTML = content, this.o.enableClose == !0 && modalCommon.querySelectorAll("[data-js-close]").forEach(elm => elm.addEventListener("click", () => { this.hide(this.o.showOnce) })) } this.setAttribute("style", ""), setTimeout(() => { this.classList.add("active"), this.o.disableScroll && document.body.classList.add(this.o.openedModalBodyClass), this.o.blockTabNavigation && window.inertElems.forEach(elm => elm.setAttribute("inert", "")) }, 10), setTimeout(() => { this.querySelector("[data-js-first-focus]") && this.querySelector("[data-js-first-focus]").focus() }, 250) } hide(remember = !1) { this.classList.remove("active"), document.body.classList.remove(this.o.openedModalBodyClass), setTimeout(() => { this.style.display = "none" }, 500), remember && !Shopify.designMode && localStorage.setItem(this._modalKey, JSON.stringify({ shown: new Date().getTime(), content: this._modalText })), window.inertElems.forEach(elm => elm.removeAttribute("inert")), window.lastFocusedElm && setTimeout(() => { window.lastFocusedElm.focus(), window.lastFocusedElm = null }, 100) } } typeof customElements.get("modal-box") > "u" && (document.querySelectorAll("modal-box").forEach(originalElement => { JSON.parse(originalElement.dataset.options).appendToBody === !0 && document.body.appendChild(originalElement) }), customElements.define("modal-box", ModalBox2)) }
//# sourceMappingURL=/cdn/shop/t/49/assets/component-modal.js.map?v=156099800522851693471760045841
