1if(!customElements.get("product-form")){class ProductForm extends HTMLElement{constructor(){super(),this.hasChildNodes()&&this.init()}init(){this.form=this.querySelector(".js-product-form"),this.form&&(this.form.querySelector('[name="id"]').disabled=!1,this.cartDrawer=document.querySelector("cart-drawer"),this.submitBtn=this.querySelector('[name="add"]'),theme.settings.afterAtc!=="no-js"&&this.form.addEventListener("submit",this.handleSubmit.bind(this)))}async handleSubmit(evt){if(evt.target.id==="product-signup_form"||(evt.preventDefault(),this.submitBtn.getAttribute("aria-disabled")==="true"))return;theme.settings.vibrateOnATC&&window.navigator.vibrate&&window.navigator.vibrate(100),this.errorMsg=null,this.setErrorMsgState(),this.submitBtn.setAttribute("aria-disabled","true"),this.submitBtn.classList.add("is-loading");const formData=new FormData(this.form);let sections="cart-icon-bubble";this.cartDrawer&&(sections+=`,${this.cartDrawer.closest(".shopify-section").id.replace("shopify-section-","")}`),formData.append("sections_url",window.location.pathname),formData.append("sections",sections);const fetchRequestOpts={method:"POST",headers:{Accept:"application/javascript","X-Requested-With":"XMLHttpRequest"},body:formData};try{const oldCartResponse=await fetch(`${theme.routes.cart}.js`);if(!oldCartResponse.ok)throw new Error(oldCartResponse.status);const oldCartData=await oldCartResponse.json(),response=await fetch(theme.routes.cartAdd,fetchRequestOpts),data=await response.json();let error=typeof data.description=="string"?data.description:data.message;if(data.errors&&typeof data.errors=="object"&&(error=Object.entries(data.errors).map(item=>item[1].join(", "))),data.status&&this.setErrorMsgState(error),!response.ok)throw new Error(response.status);if(theme.settings.afterAtc==="page")setTimeout(()=>{window.location.href=theme.routes.cart},300);else{ProductForm.updateCartIcon(data);const quickAddDrawer=this.closest("quick-add-drawer");quickAddDrawer&&quickAddDrawer.addedToCart(),setTimeout(()=>{if(this.cartDrawer)this.cartDrawer.renderContents(data,!quickAddDrawer&&theme.settings.afterAtc==="drawer");else if(window.location.pathname===theme.routes.cart){const cartItems=document.querySelector("cart-items");cartItems&&(cartItems.dataset.empty==="true"?window.location.reload():cartItems.refresh())}},700)}const newCartResponse=await fetch(`${theme.routes.cart}.js`);if(!newCartResponse.ok)throw new Error(newCartResponse.status);const newCartData=await newCartResponse.json(),itemInOldCart=oldCartData.items.filter(item=>item.variant_id===data.variant_id)[0];itemInOldCart?this.dispatchEvent(new CustomEvent("on:line-item:change",{bubbles:!0,detail:{cart:newCartData,variantId:data.variant_id,oldQuantity:itemInOldCart.quantity,newQuantity:itemInOldCart.quantity===data.quantity?itemInOldCart.quantity:data.quantity}})):this.dispatchEvent(new CustomEvent("on:cart:add",{bubbles:!0,detail:{cart:newCartData,variantId:data.variant_id}}))}catch(error){console.log(error),this.dispatchEvent(new CustomEvent("on:cart:error",{bubbles:!0,detail:{error:this.errorMsg.textContent}}))}finally{this.submitBtn.classList.add("is-success"),this.submitBtn.removeAttribute("aria-disabled"),setTimeout(()=>{this.submitBtn.classList.remove("is-loading"),this.submitBtn.classList.remove("is-success")},1400)}}static updateCartIcon(response){const cartIconBubble=document.getElementById("cart-icon-bubble");cartIconBubble&&(cartIconBubble.innerHTML=response.sections["cart-icon-bubble"])}setErrorMsgState(error=!1){this.errorMsg=this.errorMsg||this.querySelector(".js-form-error"),this.errorMsg&&(this.errorMsg.hidden=!error,error&&(this.errorMsg.innerHTML="",(Array.isArray(error)?error:[error]).forEac
1h((err,index)=>{index>0&&this.errorMsg.insertAdjacentHTML("beforeend","<br>"),this.errorMsg.insertAdjacentText("beforeend",err)})))}}customElements.define("product-form",ProductForm)}document.addEventListener("DOMContentLoaded",function(){function updateDeliveryTime(){const variantSelect2=document.querySelector('select[name="id"]')||document.querySelector('input[name="id"]:checked'),selectedVariantId=variantSelect2?variantSelect2.value:null,deliveryTimeElement=document.querySelector(".delivery-time");if(console.log("Selected Variant ID:",selectedVariantId),console.log("Delivery Time Element:",deliveryTimeElement),!selectedVariantId||!deliveryTimeElement)return;document.querySelectorAll(".variant-delivery-time").forEach(element=>{if(console.log("Checking Variant ID:",element.getAttribute("data-variant-id")),element.getAttribute("data-variant-id")===selectedVariantId){const deliveryTime=element.getAttribute("data-delivery-time");deliveryTimeElement.textContent=deliveryTime,console.log("Updated Delivery Time:",deliveryTime)}})}updateDeliveryTime();const variantSelect=document.querySelector('select[name="id"]'),variantRadios=document.querySelectorAll('input[name="id"]');variantSelect&&variantSelect.addEventListener("change",updateDeliveryTime),variantRadios.length>0&&variantRadios.forEach(radio=>{radio.addEventListener("change",updateDeliveryTime)})}); 2//# sourceMappingURL=/cdn/shop/t/6/assets/product-form.js.map?v=120900837495949118791716909250
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.