"use strict";(function(){this.ajaxCartSuccess=function(e,t,a="add"){window.omegaCallBackAddToCart&&"function"==typeof window.omegaCallBackAddToCart&&window.omegaCallBackAddToCart();let o=`${this.routes.cart_url}?section_id=ecom-ajax-cart${e&&e.key?`&key=${e.key}`:""}`;window.fetch(o,{method:"GET",headers:{"Content-Type":"text/html"}}).then(e=>e.text()).then(t=>{let o=document.querySelector(".ecom-cart-popup"),r=document.createElement("div");r.classList.add("ecom-cart-popup");let i=new DOMParser().parseFromString(t,"text/html").querySelector("#shopify-section-ecom-ajax-cart");if(!i)return window.location.href=this.routes.cart_url,!1;if(r.appendChild(i),document.body.appendChild(r),this.handleCartPopup(r),e&&e.key){let n=r.querySelector(`.ecom-ajax-cart-line-item[data-key="${e.key}"]`);if(n){let s=document.querySelector(".ecom-ajax-cart-body");if(s){let c=s.querySelector(".ecom-ajax-cart-line-item");if(c){let l=s.getBoundingClientRect().top-c.getBoundingClientRect().top;s.scrollTop=l}}}}if(o&&o.remove(),"update"===a){let d=document.querySelector(".ecom-ajax-cart-status span");d&&(d.innerHTML=d.dataset.textUpdate)}this.onAjaxPopupLoaded()}).catch(e=>{console.log(e),alert(e.message)})},this.onAjaxPopupLoaded=()=>{let e=document.querySelector(".ecom-ajax-cart-checkout-button"),t=document.querySelector("#terms"),a=document.querySelector(".terms-error");e&&t&&a&&(e.removeAttribute("name"),e.addEventListener("click",function(e){t.checked?a.classList.add("terms-dn"):(e.preventDefault(),a.classList.remove("terms-dn"))}),t.addEventListener("change",function(){a.classList.add("terms-dn"),t.checked?e.setAttribute("name","checkout"):e.removeAttribute("name")}))},this.handleCartPopup=function(e){let t=this;e.addEventListener("click",function(t){(t.target===e||t.target.closest('[data-ecom-action="close"]'))&&e.remove()});let a=function(){"minus"===this.name?(this.nextElementSibling.stepDown(),this.nextElementSibling.dispatchEvent(new window.Event("change"))):"plus"===this.name&&(this.previousElementSibling.stepUp(),this.previousElementSibling.dispatchEvent(new window.Event("change")))},o=function(){let e=this.value,a=this.dataset.key,o=this.dataset.index,r=this.closest(".ecom-ajax-cart-line-item");r&&r.classList.add("ecom-item-loading"),t.cartItemChange(a,parseInt(e),o).then(e=>{let o=e.items?e.items.find(e=>e.key===a):null;if(o)t.ajaxCartSuccess(o,null,"update");else{if(e.errors){t.showToast(e.errors,"error");let i=r.closest(".ecom-ajax-cart-body");if(i){let n=i.querySelector(".ecom-ajax-cart-line-item");if(n){let s=i.getBoundingClientRect().top-n.getBoundingClientRect().top;setTimeout(()=>{let e=document.querySelector(".ecom-ajax-cart-body");e.scrollTo({top:s,behavior:"smooth"})},450)}}}t.ajaxCartSuccess(null,null,"update")}r&&r.classList.remove("ecom-item-loading")}).catch(e=>{console.error(e),t.ajaxCartError(e)})};e.querySelectorAll(".ecom-ajax-cart-line-item-quantity-button").forEach(e=>{e.addEventListener("click",a)}),e.querySelectorAll(".ecom-ajax-cart-line-item-quantity-input").forEach(e=>{e.addEventListener("change",o)});let r=e.querySelector("#ecom-ajax-cart-note");r&&r.addEventListener("change",function(){t.cartUpdate({note:this.value})}),e.querySelectorAll(".ecom-ajax-cart-line-item-button-remove").forEach(e=>{e.addEventListener("click",function(e){e.preventDefault(),this.value=0,o.bind(this)(e)})})},this.ajaxCartError=function(e){alert("Error"+e.message)},this.beforeAjaxCartSend=function(){},this.checkProperties=function(e){let t=e.querySelectorAll("input[required], .hulkapps_option.required input");return Array.from(t).every(e=>e.value)},this.ajaxCart=function(){let e=this,t=t=>{if(!t.querySelector('[name="id"]'))return window.document.querySelector("#admin-bar-iframe")&&alert('Please drag Variant picker element to this section to allow the "Add to cart" feature working. This message only show for owner\'s store'),!1;let a=t.querySelector(".ecom-product-single__add-to-cart--submit.ecom-clicked");a||(a=t.querySelector(".ecom-product-single__add-to-cart--submit")),a&&(a.style.cursor="not-allowed",a.style.pointerEvents="none",a.classList.add("ecom-ajax-loading","ecom-loading")),this.beforeAjaxCartSend(t);let o=new FormData(t);return o.append("sections","cart-notification-product,cart-notification-button,cart-icon-bubble,cart-drawer"),window.fetch(this.routes.cart_add_url,{method:"POST",headers:{Accept:"application/javascript","X-Requested-With":"XMLHttpRequest"},body:o}).then(e=>e.json()).then(o=>{if(o.errors)throw Error(o.errors);if(o.status>200){e.showToast(o.description,"error"),a&&(a.style.cursor="pointer",a.style.pointerEvents="auto",a.classList.remove("ecom-ajax-loading","ecom-loading"));return}let{action:r,href:i,textAddedCart:n,target:s,messageAddedCart:c}=a.dataset;a&&(a.style.cursor="pointer",a.style.pointerEvents="auto",a.classList.remove("ecom-ajax-loading","ecom-loading"),a.querySelector(".ecom-add-to-cart-text")&&(a.setAttribute("data-added-to-cart",""),n&&""!==n&&(a.querySelector(".ecom-add-to-cart-text").innerHTML=n))),document.dispatchEvent(new CustomEvent("ec-cart-added",{detail:o}));let l=this.routes;switch(r){case"cart":setTimeout(()=>window.location.href=l.cart_url,500);break;case"reload":setTimeout(()=>window.location.reload(),500);break;case"checkout":setTimeout(()=>{window.location.href=l.root_url+("/"===l.root_url?"":"/")+"checkout"},500);break;case"message":this.showToast(c);break;case"link":i&&setTimeout(()=>{"_blank"===s?window.open(i):window.location.href=i},500);break;default:this.ajaxCartSuccess(o,t)}}).catch(e=>{a&&(a.style.cursor="pointer",a.style.pointerEvents="auto",a.classList.remove("ecom-ajax-loading","ecom-loading")),this.ajaxCartError(e,t)}),!1},a=document.querySelectorAll(".ecom-product-single__add-to-cart--submit:not(.ecom-initialized)");a.length&&a.forEach(function(o){o.addEventListener("click",function(r){a.forEach(e=>e.classList.remove("ecom-clicked"));let i=this.closest("form.ecom-product-form");e.checkProperties(i)&&(r.preventDefault(),o.classList.add("ecom-clicked"),i.addEventListener("submit",e=>e.preventDefault()),t.bind(document.body)(i))}),o.classList.add("ecom-initialized")}),this.handleATCList();let o=document.querySelectorAll(".ecom-ajax-cart-simple[data-id]");o.forEach(t=>{t.addEventListener("click",function(t){e.handleClickEvent(this,t)})})},this.handleClickEvent=function(e,t,a=!1){t.preventDefault();let o=e.closest(".ecom-collection__product-form__actions"),r=1;if(o){let i=o.querySelector(".ecom-collection__product-quantity-input");i&&(r=i.value)}let n=e,s=this;n&&(n.style.cursor="pointer",n.style.pointerEvents="auto",n.classList.add("ecom-ajax-loading")),s.beforeAjaxCartSend(t.target),window.fetch(s.routes.cart_add_url,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/javascript","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({id:n.dataset.id,quantity:r,sections:"cart-notification-product,cart-notification-button,cart-icon-bubble,cart-drawer"})}).then(e=>e.json()).then(e=>{if(e.errors)throw Error(e.errors);if(e.status>200){s.showToast(e.description,"error"),n&&(n.style.cursor="pointer",n.style.pointerEvents="auto",n.classList.remove("ecom-ajax-loading","ecom-loading"));return}let{action:o,href:r,textAddedCart:i,target:c,messageAddedCart:l}=n.dataset;if(n&&(n.style.cursor="pointer",n.style.pointerEvents="auto",n.classList.remove("ecom-ajax-loading","ecom-loading"),n.setAttribute("data-added-to-cart",""),i&&""!==i&&(n.querySelector(".ecom-add-to-cart-text").innerHTML=i)),s.onAjaxCartSuccess&&s.onAjaxCartSuccess(e,t.target),a&&!s.configs.ajax_cart.enable){setTimeout(()=>window.location.href=s.routes.cart_url,500);return}switch(document.dispatchEvent(new CustomEvent("ec-cart-added",{detail:e})),o){case"cart":setTimeout(()=>window.location.href=s.routes.cart_url,500);break;case"reload":setTimeout(()=>window.location.reload(),500);break;case"checkout":setTimeout(()=>window.location.href=s.routes.root_url+"checkout",500);break;case"message":s.showToast(l);break;case"link":r&&setTimeout(()=>{"_blank"===c?window.open(r):window.location.href=r},500);break;default:s.ajaxCartSuccess(e,t.target)}}).catch(e=>{window.alert(e.message),console.error(e),n&&(n.style.cursor="pointer",n.style.pointerEvents="auto",n.classList.remove("ecom-ajax-loading","ecom-loading")),s.ajaxCartError(e,t.target)})},this.cartItemChange=function(e,t,a=null){return window.fetch(this.routes.cart_change_url,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({quantity:t,line:a})}).then(e=>e.json())},this.handleATCList=function(){let e=document.querySelectorAll(".ecom-collection__product-item .ecom-product-form"),t=this;e.forEach(e=>{let a=e.querySelector(".ecom-ajax-cart-submit"),o=e.querySelector('[name="variant_id"]');a&&o&&a.addEventListener("click",function(e){e.preventDefault(),this.dataset.id=o.value,t.handleClickEvent(this,e,!0)}),e.classList.add("ecom-ajax-cart")})},this.cartUpdate=function(e){return window.fetch(this.routes.cart_update_url,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)}).then(e=>e.json())},this.showToast=function(e,t){let a=document.querySelector("#ecom-toast-desc"),o=document.querySelector("#ecom-toast"),r=document.querySelector("#ecom-toast-icon");"error"===t?(o.style.cssText="background-color: red;overflow: hidden; z-index: 10000000;",r.style.cssText="background-color: red;",o.classList.add("ecom-toast-error")):(o.classList.remove("ecom-toast-error"),o.style.cssText="background-color: #333;overflow: hidden; z-index: 10000000;",r.style.cssText="background-color: #333; border-radius: 2px;"),o&&a&&r&&(a.innerHTML=e,o.classList.add("ecom-toast-show"),o.style.setProperty("--ecom-max-width",a.clientWidth+50+"px"),setTimeout(()=>o.classList.remove("ecom-toast-show"),5e3))},this.initToastTemplate=function(){let e=document.querySelector("#ecom-template-html");if(e){let t=document.createElement("div");t.innerHTML=e.innerHTML,document.body.appendChild(t)}},this.isAdmin=function(){return document.querySelector("#admin-bar-iframe")||window.Shopify.designMode},this.loadPopupScript=function(){if(window.EComposer&&window.EComposer.popupScriptUrl){let e=document.createElement("script");e.src=window.EComposer.popupScriptUrl,e.async=!0,e.type="text/javascript",e.id="ecom-popup-script",e.onerror=function(){console.error("Failed to load popup script")},document.head.appendChild(e)}},this.init=function(){if(this.initToastTemplate(),window.Shopify&&!this.isAdmin()){let e=window.EComposer.PAGE||window.EComposer.TEMPLATE||window.EComposer.SECTION||window.EComposer.BLOCK||{};if(e){if(e.type&&(e.layout_type=e.type,delete e.type),e.template_id&&(e.layout_id=e.template_id,delete e.template_id),window.Shopify.analytics)Shopify.analytics.publish("ec_page_viewed",e);else{let t=0,a=setInterval(()=>{window.Shopify.analytics&&(Shopify.analytics.publish("ec_page_viewed",e),clearInterval(a)),++t>200&&clearInterval(a)},100)}let o=new Date().getTime(),r=!1;document.addEventListener("click",()=>{r=!0},{once:!0}),window.addEventListener("beforeunload",()=>{if(!r){let t=new Date().getTime();window.Shopify.analytics&&Shopify.analytics.publish("ec_bounce_rate",{...e,elapsed_time:((t-o)/1e3).toFixed(2)})}})}}this.configs&&this.configs.ajax_cart&&this.configs.ajax_cart.enable?this.ajaxCart():(this.handleATCList(),document.body.addEventListener("submit",e=>{e.target.classList.contains("ecom-product-form")&&"FORM"===e.target.nodeName&&window.omegaCallBackAddToCart&&"function"==typeof window.omegaCallBackAddToCart&&window.omegaCallBackAddToCart()})),this.loadPopupScript()},this.init()}).bind(window.EComposer||{})(),function(){let e,t=e=>{let{top:t,bottom:a}=e.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight;return(t>0||a>0)&&t{let e=document.querySelectorAll(".ecom-sections .ecom-video-background");e.forEach(e=>{"true"===e.dataset.playPauseInview&&(t(e)?e.play():e.pause())})};window.addEventListener("scroll",()=>{clearTimeout(e),e=setTimeout(a,500)});let o=()=>{document.body.hasAttribute("ecom-loaded")||(clearTimeout(window.stretchedTimmer),window.stretchedTimmer=setTimeout(()=>{let e=document.querySelectorAll(".ecom-core.ecom-section"),t=document.querySelectorAll(".ecom-swiper-container"),a=document.querySelectorAll(".ecom-sections"),o=window.innerWidth;if(e.length>0){a.forEach(e=>e.style.width="");let r=(o-a[0].offsetWidth)/2;e.forEach(e=>{e.classList.contains("ecom-section__stretched")?(e.style.width=o+"px",e.style.marginLeft=-r+"px"):(e.style.width="",e.style.marginLeft="")})}t.length>0&&t.forEach(e=>{e.EComSwiper&&e.EComSwiper.update()})},50))};o(),window.addEventListener("resize",o),window.addEventListener("load",o),document.addEventListener("DOMContentLoaded",()=>{"function"==typeof window.EComposer.initQuickview&&window.EComposer.initQuickview()});let r=(e,t)=>{let a=new IntersectionObserver((a,o)=>{a.forEach(a=>{if(a.isIntersecting){if(t.cb)t.cb(e);else{let r=a.target.getAttribute("data-animation-delay"),i=parseInt(r)||10,n=()=>{setTimeout(()=>{a.target.classList.add("ecom-animated","animated"),a.target.addEventListener("animationend",()=>{a.target.classList.add("ecom-animated-end")},{once:!0})},i)},s=a.target.closest(".ecom-animation");s&&s!==a.target?s.classList.contains("ecom-animated-end")?n():s.addEventListener("animationend",n,{once:!0}):n()}o.unobserve(a.target)}})},t);a.observe(e)};((e,t={})=>{let a=Array.from(document.querySelectorAll(e));a.forEach(e=>r(e,t))})(".ecom-animation");let i=function(){let e=this;this.defaultValue=[],this.init=function(){let t=document.querySelectorAll("[ecom-scrolling-animation]");t.length&&window.addEventListener("scroll",()=>{e.handleScrollAnimation(t)})},this.handleScrollAnimation=function(t){t.forEach((t,a)=>{e.animation(t,a)})},this.animation=function(e,t){let a=e.getAttribute("ecom-scrolling-animation")?JSON.parse(e.getAttribute("ecom-scrolling-animation")):null;if(!a)return;let o=this.getViewPercentage(e),r=this.getOptions(a,o,e,t);if(o>0&&o<100){let i="",n="",s="";if(Object.keys(r).forEach(e=>{["translateX","translateY"].includes(e)?(i+=`${e}(${r[e]})`,delete r[e]):["blur"].includes(e)?(s+=`${e}(${r[e]})`,delete r[e]):["rotate"].includes(e)&&(n=`${e}(${r[e]})`,delete r[e])}),Object.keys(r).length&&Object.assign(e.style,r),i&&(e.style.transform=i,e.ecomCSSTransform=!0),s&&(e.style.filter=s,e.ecomCSSFilter=!0),n){let c=e.querySelector(":first-child");c&&(c.style.transform=n),e.ecomCSSRotate=!0}}else if(e.ecomCSSTransform&&(e.style.transform="",e.ecomCSSTransform=!1),e.ecomCSSFilter&&(e.style.filter="",e.ecomCSSFilter=!1),e.ecomCSSRotate){let l=e.firstElementChild;l&&(l.style.transform=""),e.ecomCSSRotate=!1}},this.getStyleValue=function(e,t){if(!t)return"";let a=RegExp(`${e}\\(([\\d\\-.a-z]+)\\)`),o=t.match(a);return o?o[1]:""},this.getOptions=function(t,a,o,r){let i={};return t.forEach(t=>{let n=t.value;if(!n)return;let s;if(e.defaultValue[r]){if(void 0===e.defaultValue[r][t.css]){let c=o.style[t.css];["translateX","translateY"].includes(t.css)&&(c=e.getStyleValue(t.css,o.style.transform)||0),["blur"].includes(t.css)&&(c=e.getStyleValue(t.css,o.style.filter)||0),e.defaultValue[r][t.css]=c}}else e.defaultValue[r]={},e.defaultValue[r][t.css]=o.style[t.css];if(0d&&([l,d]=[d,l]);let u;if(l>a)u=0;else if(d{if(!e)return;let t=e.closest(".ecom-use-parallax"),a=t.getBoundingClientRect().top+window.scrollY,o=window.scrollY,r=window.innerHeight,i=t.clientHeight,n=o+r;if(n>a&&o{n.forEach(e=>s(e))};n.length>0&&(document.addEventListener("scroll",c),window.addEventListener("load",c)),document.addEventListener("shopify:section:load",e=>{let t=JSON.parse(unescape(e.target.dataset.shopifyEditorSection)),a=null;if(t.type&&t.type.includes("ecom-")&&(a=e.target),!a)return;let o=a.querySelectorAll("script");o.forEach(e=>{if(e.src){a.removeChild(e);let t=document.createElement("script");t.src=e.src,a.prepend(t)}})})}();