function getFocusableElements(e){return Array.from(e.querySelectorAll("summary, a[href], button:enabled, [tabindex]:not([tabindex^='-']), [draggable], area, input:not([type=hidden]):enabled, select:enabled, textarea:enabled, object, iframe"))}class QuantityInput extends HTMLElement{constructor(){super(),this.input=this.querySelector("input"),this.changeEvent=new Event("change",{bubbles:!0}),this.querySelectorAll(".qtyBtn").forEach((e=>e.addEventListener("click",this.onButtonClick.bind(this))))}onButtonClick(e){e.preventDefault();const t=this.input.value;"plus"===e.target.name?this.input.stepUp():this.input.stepDown(),t!==this.input.value&&this.input.dispatchEvent(this.changeEvent)}}function debounce(e,t){let r;return(...n)=>{clearTimeout(r),r=setTimeout((()=>e.apply(this,n)),t)}}function fetchConfig(e="json"){return{method:"POST",headers:{"Content-Type":"application/json",Accept:`application/${e}`}}}function removeTrapFocus(e=null){document.removeEventListener("focusin",trapFocusHandlers.focusin),document.removeEventListener("focusout",trapFocusHandlers.focusout),document.removeEventListener("keydown",trapFocusHandlers.keydown),e&&e.focus()}customElements.define("quantity-input",QuantityInput);const trapFocusHandlers={};function trapFocus(e,t=e){var r=getFocusableElements(e),n=r[0],s=r[r.length-1];removeTrapFocus(),trapFocusHandlers.focusin=t=>{t.target!==e&&t.target!==s&&t.target!==n||document.addEventListener("keydown",trapFocusHandlers.keydown)},trapFocusHandlers.focusout=function(){document.removeEventListener("keydown",trapFocusHandlers.keydown)},trapFocusHandlers.keydown=function(t){"TAB"===t.code.toUpperCase()&&(t.target!==s||t.shiftKey||(t.preventDefault(),n.focus()),t.target!==e&&t.target!==n||!t.shiftKey||(t.preventDefault(),s.focus()))},document.addEventListener("focusout",trapFocusHandlers.focusout),document.addEventListener("focusin",trapFocusHandlers.focusin),t.focus()}class CartRemoveButton extends HTMLElement{constructor(){super(),this.addEventListener("click",(e=>{e.preventDefault();(this.closest("cart-items")||this.closest("cart-drawer-items")).updateQuantity(this.dataset.index,0)}))}}customElements.define("cart-remove-button",CartRemoveButton);class CartItems extends HTMLElement{constructor(){super(),this.lineItemStatusElement=document.getElementById("shopping-cart-line-item-status")||document.getElementById("CartDrawer-LineItemStatus"),this.currentItemCount=Array.from(this.querySelectorAll('[name="updates[]"]')).reduce(((e,t)=>e+parseInt(t.value)),0),this.debouncedOnChange=debounce((e=>{this.onChange(e)}),300),this.addEventListener("change",this.debouncedOnChange.bind(this))}onChange(e){e.target.classList.contains("stopEv")||this.updateQuantity(e.target.dataset.index,e.target.value,document.activeElement.getAttribute("name"))}getSectionsToRender(){return[{id:"main-cart-items",section:document.getElementById("main-cart-items").dataset.id,selector:".js-contents"},{id:"cart-icon-bubble",section:"cart-icon-bubble",selector:".shopify-section"},{id:"main-cart-footer",section:document.getElementById("main-cart-footer").dataset.id,selector:".cartTotal"}]}updateQuantity(e,t,r){this.enableLoading(e);const n=JSON.stringify({line:e,quantity:t,sections:this.getSectionsToRender().map((e=>e.section)),sections_url:window.location.pathname});fetch(`${routes.cart_change_url}`,{...fetchConfig(),body:n}).then((e=>e.text())).then((t=>{const n=JSON.parse(t),s=document.getElementById(`Quantity-${e}`)||document.getElementById(`Drawer-quantity-${e}`);this.classList.toggle("is-empty",0===n.item_count);const i=document.querySelector("cart-drawer"),o=document.getElementById("main-cart-footer");n.errors&&(s.value=s.getAttribute("value"),this.updateLiveRegions(e,"none")),o&&o.classList.toggle("is-empty",0===n.item_count),i&&i.classList.toggle("is-empty",0===n.item_count),this.getSectionsToRender().forEach((e=>{(document.getElementById(e.id).querySelector(e.selector)||document.getElementById(e.id)).innerHTML=this.getSectionInnerHTML(n.sections[e.section],e.selector)})),this.updateLiveRegions(e,n.item_count);const a=document.getElementById(`CartItem-${e}`)||document.getElementById(`CartDrawer-Item-${e}`);a&&a.querySelector(`[name="${r}"]`)?i?trapFocus(i,a.querySelector(`[name="${r}"]`)):a.querySelector(`[name="${r}"]`).focus():0===n.item_count&&i?trapFocus(i.querySelector(".drawer__inner-empty"),i.querySelector("a")):document.querySelector(".cart-item")&&i&&trapFocus(i,document.querySelector(".cart-item__name")),this.disableLoading()})).catch((()=>{this.querySelectorAll(".loading-overlay").forEach((e=>e.classList.add("hidden")));(document.getElementById("cart-errors")||document.getElementById("CartDrawer-CartErrors")).textContent=window.cartStrings.error,this.disableLoading()}))}updateLiveRegions(e,t){if(this.currentItemCount===t||"none"==t){const t=document.getElementById(`Line-item-error-${e}`)||document.getElementById(`CartDrawer-LineItemError-${e}`),r=document.getElementById(`Quantity-${e}`)||document.getElementById(`Drawer-quantity-${e}`);t.classList.add("error-alert"),t.querySelector(".ctItem-error").innerHTML=window.cartStrings.quantityError.replace("[quantity]",r.value)}this.currentItemCount=t,this.lineItemStatusElement.setAttribute("aria-hidden",!0);const r=document.getElementById("cart-live-region-text")||document.getElementById("CartDrawer-LiveRegionText");r.setAttribute("aria-hidden",!1),freeShippMsg(),setTimeout((()=>{r.setAttribute("aria-hidden",!0)}),1e3)}getSectionInnerHTML(e,t){return(new DOMParser).parseFromString(e,"text/html").querySelector(t).innerHTML}enableLoading(e){(document.getElementById("main-cart-items")||document.getElementById("CartDrawer-CartItems")).classList.add("cart__items--disabled");[...this.querySelectorAll(`#CartItem-${e} .loading-overlay`),...this.querySelectorAll(`#CartDrawer-Item-${e} .loading-overlay`)].forEach((e=>e.classList.remove("hidden"))),document.activeElement.blur(),this.lineItemStatusElement.setAttribute("aria-hidden",!1)}disableLoading(){(document.getElementById("main-cart-items")||document.getElementById("CartDrawer-CartItems")).classList.remove("cart__items--disabled")}}customElements.define("cart-items",CartItems),customElements.get("cart-note")||customElements.define("cart-note",class extends HTMLElement{constructor(){super(),this.addEventListener("change",debounce((e=>{const t=JSON.stringify({note:e.target.value});fetch(`${routes.cart_update_url}`,{...fetchConfig(),body:t})}),300))}});class CartDrawer extends HTMLElement{constructor(){super(),this.addEventListener("keyup",(e=>"Escape"===e.code&&this.close())),this.querySelector("#CartDrawer-Overlay").addEventListener("click",this.close.bind(this)),this.setHeaderCartIconAccessibility()}setHeaderCartIconAccessibility(){const e=document.querySelector("#cartLink");e.setAttribute("role","button"),e.setAttribute("aria-haspopup","dialog"),e.addEventListener("click",(t=>{t.preventDefault(),this.open(e)})),e.addEventListener("keydown",(t=>{"SPACE"===t.code.toUpperCase()&&(t.preventDefault(),this.open(e))}))}open(e){e&&this.setActiveElement(e);const t=this.querySelector('[id^="Details-"] summary');t&&!t.hasAttribute("role")&&this.setSummaryAccessibility(t),setTimeout((()=>{this.classList.add("animate","active")})),this.addEventListener("transitionend",(()=>{trapFocus(this.classList.contains("is-empty")?this.querySelector(".drawer-empty"):document.getElementById("CartDrawer"),this.querySelector(".drawer__inner")||this.querySelector(".drawer__close"))}),{once:!0}),$("html").addClass("overflow-hidden"),document.body.classList.remove("loading")}close(){this.classList.remove("active"),removeTrapFocus(this.activeElement),$("html").removeClass("overflow-hidden")}setSummaryAccessibility(e){e.setAttribute("role","button"),e.setAttribute("aria-expanded","false"),e.nextElementSibling.getAttribute("id")&&e.setAttribute("aria-controls",e.nextElementSibling.id),e.addEventListener("click",(e=>{e.currentTarget.setAttribute("aria-expanded",!e.currentTarget.closest("details").hasAttribute("open"))}))}renderContents(e){this.querySelector(".drawer__inner").classList.contains("is-empty")&&this.querySelector(".drawer__inner").classList.remove("is-empty"),this.productId=e.id,this.getSectionsToRender().forEach((t=>{(t.selector?document.querySelector(t.selector):document.getElementById(t.id)).innerHTML=this.getSectionInnerHTML(e.sections[t.id],t.selector)})),setTimeout((()=>{this.querySelector("#CartDrawer-Overlay").addEventListener("click",this.close.bind(this)),this.open()}))}getSectionInnerHTML(e,t=".shopify-section"){return(new DOMParser).parseFromString(e,"text/html").querySelector(t).innerHTML}getSectionsToRender(){return[{id:"cart-drawer",selector:"#CartDrawer"},{id:"cart-icon-bubble"}]}getSectionDOM(e,t=".shopify-section"){return(new DOMParser).parseFromString(e,"text/html").querySelector(t)}setActiveElement(e){this.activeElement=e}}customElements.define("cart-drawer",CartDrawer);class CartDrawerItems extends CartItems{getSectionsToRender(){return[{id:"CartDrawer",section:"cart-drawer",selector:".drawer__inner"},{id:"cart-icon-bubble",section:"cart-icon-bubble",selector:".shopify-section"}]}}customElements.define("cart-drawer-items",CartDrawerItems);class CouponCode extends HTMLElement{constructor(){super(),localStorage.getItem("storedDiscount")&&(this.querySelector('input[name="discount"]').value=localStorage.getItem("storedDiscount")),this.querySelector('input[name="discount"]').addEventListener("change",(e=>{this.val=this.querySelector('input[name="discount"]').value,localStorage.setItem("storedDiscount",this.val),fetch(`/discount/${this.val}`).then((e=>e.text())).then((e=>{})),document.querySelector("#cartCoupon").classList.remove("active")}))}}customElements.define("coupon-code",CouponCode);class CartOption extends HTMLElement{constructor(){super(),this.querySelectorAll(".cftBtn").forEach((e=>e.addEventListener("click",(function(e){e.preventDefault();var t=this.hash.substr(1);document.getElementById(t).classList.add("active")}))))}}function startTimer(e,t){var r,n,s=e;setInterval((function(){r=parseInt(s/60,10),n=parseInt(s%60,10),r=r<10?"0"+r:r,n=n<10?"0"+n:n,t.textContent=r+":"+n,--s<0&&(clearInterval(startTimer),document.querySelector(".cartCountdown").remove())}),1e3)}customElements.define("cart-option",CartOption),$(document).on("click",".saveBtn",(function(e){e.preventDefault(),$(".cftDraw").removeClass("active")})),window.onload=function(){document.querySelector(".cartCountdown")&&startTimer(document.querySelector(".cartCountdown").getAttribute("data-countdown"),document.querySelector("#cartTime"))},customElements.get("product-form")||customElements.define("product-form",class extends HTMLElement{constructor(){super(),this.form=this.querySelector("form"),this.form.querySelector("[name=id]").disabled=!1,this.form.addEventListener("submit",this.onSubmitHandler.bind(this)),this.cart=document.querySelector("cart-drawer"),this.submitButton=this.querySelector('[type="submit"]'),document.querySelector("cart-drawer")&&this.submitButton.setAttribute("aria-haspopup","dialog")}onSubmitHandler(e){if(e.preventDefault(),"true"===this.submitButton.getAttribute("aria-disabled"))return;this.handleErrorMessage(),this.submitButton.setAttribute("aria-disabled",!0),this.submitButton.classList.add("loading"),this.querySelector(".loading-overlay__spinner").classList.remove("hidden");const t=fetchConfig("javascript");t.headers["X-Requested-With"]="XMLHttpRequest",delete t.headers["Content-Type"];const r=new FormData(this.form);this.cart&&(r.append("sections",this.cart.getSectionsToRender().map((e=>e.id))),r.append("sections_url",window.location.pathname),this.cart.setActiveElement(document.activeElement)),t.body=r,fetch(`${routes.cart_add_url}`,t).then((e=>e.json())).then((e=>{if(e.status){this.handleErrorMessage(e.description);const t=this.submitButton.querySelector(".sold-out-message");if(!t)return;return this.submitButton.setAttribute("aria-disabled",!0),this.submitButton.querySelector("span").classList.add("hidden"),t.classList.remove("hidden"),void(this.error=!0)}if(!this.cart)return void(window.location=window.routes.cart_url);this.error=!1;const t=this.closest("quick-add-modal");t?(document.body.addEventListener("modalClosed",(()=>{setTimeout((()=>{this.cart.renderContents(e)}))}),{once:!0}),t.hide(!0)):this.cart.renderContents(e)})).catch((e=>{console.error(e)})).finally((()=>{this.submitButton.classList.remove("loading"),this.cart&&this.cart.classList.contains("is-empty")&&this.cart.classList.remove("is-empty"),this.error||this.submitButton.removeAttribute("aria-disabled"),this.querySelector(".loading-overlay__spinner").classList.add("hidden"),freeShippMsg()}))}handleErrorMessage(e=!1){this.errorMessageWrapper=this.errorMessageWrapper||this.querySelector(".pform-error-wrap"),this.errorMessageWrapper&&(this.errorMessage=this.errorMessage||this.errorMessageWrapper.querySelector(".pform-error-msg"),this.errorMessageWrapper.toggleAttribute("hidden",!e),e&&(this.errorMessage.textContent=e))}});