1import{ap as w,aq as S}from"./chunk-core-C-8Qoxie.js";class b extends HTMLElement{constructor(){super(...arguments),this._loading=!1,this._handleChange=async t=>{var u;if(this._loading)return;let a;if(t instanceof CustomEvent&&((u=t.detail)==null?void 0:u.value)!=null)a=String(t.detail.value);else if(t.target.tagName==="SELECT")a=t.target.value;else return;const n=parseInt(a,10);if(!n)return;const s=this.getAttribute("key"),d=parseInt(this.getAttribute("item-quantity")||"1",10);if(!s)return;const i=this.querySelector(`option[value="${n}"]`),o=parseInt((i==null?void 0:i.dataset.maxQuantity)??"",10),h=!isNaN(o)&&o>0?Math.min(d,o):d,r=window.Shopify.routes.root,l=Array.from(document.querySelectorAll("cart-sections[section-id]")).map(e=>e.getAttribute("section-id")).filter(e=>!!e),m=Array.from(new Set(l.length?l:["cart-drawer"]));this._loading=!0,this._setLoadingUI(!0);try{w(this.closest("cart-sections")),S(s,String(n));const e=await fetch(`${r}cart/update.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:{[s]:0}})});if(!e.ok)throw new Error(`update.js ${e.status}`);const c=await fetch(`${r}cart/add.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:[{id:n,quantity:h}],sections_url:window.location.pathname})});if(!c.ok)throw new Error(`add.js ${c.status}`);await c.json();const[p,f]=await Promise.all([fetch(`${window.location.pathname}?sections=${m.join(",")}`),fetch(`${r}cart.js`)]),y=await p.json(),g=await f.json();this.dispatchEvent(new CustomEvent("cart:updated-sections",{bubbles:!0,composed:!0,detail:y})),this.dispatchEvent(new CustomEvent("cart:updated",{bubbles:!0,composed:!0,detail:g}))}catch(e){console.error("[cart-variant-selector]",e)}finally{this._loading=!1,this._setLoadingUI(!1)}}}connectedCallback(){this.addEventListener("change",this._handleChange)}disconnectedCallback(){this.removeEventListener("change",this._handleChange)}_setLoadingUI(t){const a=this.closest('[id^="CartDrawer-Item-"]'),n=a==null?void 0:a.querySelector("quantity-input");n&&(n.shopifyCartLoading=t);const s=document.querySelector('button[name="checkout"]');s&&(s.disabled=t)}}customElements.get("cart-variant-selector")||customElements.define("cart-variant-selector",b);
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.