1if(!customElements.get("product-form")){let removeElementsByScreenSize2=function(container=document){window.matchMedia("(max-width: 990px)").matches?(document.querySelectorAll(".hide-mobile").forEach(el=>{removedElements.desktop.push({parent:el.parentNode,element:el,nextSibling:el.nextSibling}),el.remove()}),removedElements.mobile.forEach(({parent,element,nextSibling})=>{nextSibling&&nextSibling.parentNode===parent?parent.insertBefore(element,nextSibling):parent.appendChild(element)}),removedElements.mobile=[]):(document.querySelectorAll(".hide-desktop").forEach(el=>{removedElements.mobile.push({parent:el.parentNode,element:el,nextSibling:el.nextSibling}),el.remove()}),removedElements.desktop.forEach(({parent,element,nextSibling})=>{nextSibling&&nextSibling.parentNode===parent?parent.insertBefore(element,nextSibling):parent.appendChild(element)}),removedElements.desktop=[])};var removeElementsByScreenSize=removeElementsByScreenSize2;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-notification")||document.querySelector("cart-drawer"),this.submitButton=this.querySelector('[type="submit"]'),document.querySelector("cart-drawer")&&this.submitButton.setAttribute("aria-haspopup","dialog")}onSubmitHandler(evt){if(evt.preventDefault(),this.submitButton.getAttribute("aria-disabled")==="true")return;this.handleErrorMessage(),this.submitButton.setAttribute("aria-disabled",!0);const config=fetchConfig("javascript");config.headers["X-Requested-With"]="XMLHttpRequest",delete config.headers["Content-Type"];const formData=new FormData(this.form);this.cart&&(formData.append("sections",this.cart.getSectionsToRender().map(section=>section.id)),formData.append("sections_url",window.location.pathname),this.cart.setActiveElement(document.activeElement)),config.body=formData,fetch(`${routes.cart_add_url}`,config).then(response=>response.json()).then(response=>{if(response.status){this.handleErrorMessage(response.description);const soldOutMessage=this.submitButton.querySelector(".sold-out-message");if(!soldOutMessage)return;this.submitButton.setAttribute("aria-disabled",!0),this.submitButton.querySelector("span").classList.add("hidden"),soldOutMessage.classList.remove("hidden"),this.error=!0;return}else if(!this.cart){window.location=window.routes.cart_url;return}this.error||publish(PUB_SUB_EVENTS.cartUpdate,{source:"product-form"}),this.error=!1;const quickAddModal=this.closest("quick-add-modal");quickAddModal?(document.body.addEventListener("modalClosed",()=>{setTimeout(()=>{this.cart.renderContents(response)})},{once:!0}),quickAddModal.hide(!0),typeof AOS<"u"&&AOS.init()):(this.cart.renderContents(response),typeof AOS<"u"&&AOS.init())}).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"),typeof AOS<"u"&&AOS.init()})}handleErrorMessage(errorMessage=!1){if(!this.hideErrors&&(this.errorMessageWrapper=this.errorMessageWrapper||this.querySelector(".product-form__error-message-wrapper"),!!this.errorMessageWrapper&&(this.errorMessage=this.errorMessage||this.errorMessageWrapper.querySelector(".product-form__error-message"),this.errorMessageWrapper.toggleAttribute("hidden",!errorMessage),errorMessage)))if(typeof errorMessage=="object"){const formattedMessage=Object.entries(errorMessage).map(([field,messages])=>`${field}: ${messages.join(", ")}`).join(" | ");this.errorMessage.textContent=formattedMessage}else this.errorMessage.textContent=errorMessage}});let removedElements={mobile:[],desktop:[]};removeElementsByScreenSize2(),window.addEventListener("resize",removeElementsByScreenSize2),window.addEventListener("shopify:section:select",removeElementsByScreenSize2)}class StickyAddToCart extends HTMLElement{constructor(){super(),this._handleResize=this._debounce(this.initStickyAddToCart.bind(this),200)}connectedCallback(){this.initStickyAddToCart(),window.addEventListener("resize",this._handleResize)}disconnectedCallback(){window.removeEventListener("resize",this._handleResize)}initStickyAddToCart(){const img=this.querySelector(".product-content img"),selectField=this.querySelector('select[name="id"]'),addButton=this.querySelector('button[name="add"]'),productForm=d
1ocument.querySelector(".product-form");if(!selectField||!addButton||!productForm)return;const addToCartText=addButton.getAttribute("data-add-to-cart"),soldOutText=addButton.getAttribute("data-sold-out"),checkVisibility=()=>{const formRect=productForm.getBoundingClientRect(),footerRect=document.querySelector("footer")?.getBoundingClientRect(),isOutOfView=formRect.bottom<=0,isFooterVisible=footerRect&&footerRect.top<window.innerHeight;isOutOfView&&!isFooterVisible?(this.classList.add("show"),document.documentElement.style.paddingBottom=`${this.clientHeight}px`):(this.classList.remove("show"),document.documentElement.style.paddingBottom="0")};checkVisibility(),window.addEventListener("scroll",checkVisibility),selectField.addEventListener("change",()=>{const selectedOption=selectField.options[selectField.selectedIndex];selectedOption.dataset.img&&img.setAttribute("src",selectedOption.dataset.img),selectedOption.getAttribute("data-available")==="false"?(addButton.setAttribute("disabled","true"),addButton.querySelector("span").textContent=soldOutText):(addButton.removeAttribute("disabled"),addButton.querySelector("span").textContent=addToCartText)}),document.querySelector('.product-form [name="id"]')?.addEventListener("change",e=>{const value=Number(e.target.value);value&&(selectField.value=value)})}_debounce(func,wait){let timeout;return(...args)=>{clearTimeout(timeout),timeout=setTimeout(()=>func.apply(this,args),wait)}}}customElements.define("sticky-add-to-cart",StickyAddToCart); 2//# sourceMappingURL=/cdn/shop/t/35/assets/product-form.js.map?v=166818781659367200261777903797
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.