1document.addEventListener("alpine:init",()=>{Alpine.data("CartItems",()=>({itemsRoot:null,loading:null,init(){this.itemsRoot=this.$root,window.addEventListener("baseline:cart:afteradditem",this.onCartQuantityChange.bind(this)),window.addEventListener("baseline:cart:cartqtychange",this.onCartQuantityChange.bind(this)),window.addEventListener("baseline:cart:update",this.onCartQuantityChange.bind(this)),document.addEventListener("baseline:cart:lock",()=>{this.loading=!0}),document.addEventListener("baseline:cart:unlock",()=>{this.loading=!1})},onCartQuantityChange(e){Alpine.morph(this.itemsRoot,querySelectorInHTMLString("[data-cart-items]",e.detail.response.sections["cart-items"]).outerHTML),this.$nextTick(()=>{this.itemsRoot.querySelectorAll("input").forEach(inputEl=>{inputEl.value=inputEl.getAttribute("value"),inputEl.dispatchEvent(new Event("input"))})}),this.updateLiveRegion(parseDOMFromString(e.detail.response.sections["cart-live-region"]).firstElementChild.textContent),e.detail.originalTarget&&this.$nextTick(()=>{if(!this.itemsRoot.contains(e.detail.originalTarget)){let focusRoot;this.itemsRoot.closest('[role="dialog"]')?focusRoot=this.itemsRoot.closest('[role="dialog"]').parentNode:focusRoot=this.itemsRoot,this.$focus.within(focusRoot).first()}});const itemsRootEl=this.itemsRoot;switch(e.type){case"baseline:cart:afteradditem":document.dispatchEvent(new CustomEvent("theme:product:add",{detail:{cartItemCount:window.theme.cartItemCount,itemsRootEl,lineItemEl:document.querySelector(`[data-line-item-key="${e.detail.response.key}"]`)||null,variantId:e.detail.response.variant_id,key:e.detail.response.key,formEl:document.getElementById(e.detail.sourceId),get cartPromise(){return fetch(window.theme.routes.cart_url,fetchConfigDefaults()).then(res=>res.json()).then(cart=>cart).catch(error=>console.error("Error fetching cart in `theme:product:add`",error))}}}));break;case"baseline:cart:cartqtychange":document.dispatchEvent(new CustomEvent("theme:line-item:change",{detail:{cartItemCount:e.detail.response.item_count,itemsRootEl,lineItemEl:document.querySelector(`[data-line-item-key="${e.detail.key}
1"]`)||null,variantId:e.detail.variantId,key:e.detail.key,quantity:e.detail.quantity,previousQuantity:e.detail.previousQuantity,cart:e.detail.response}}));break;case"baseline:cart:update":document.dispatchEvent(new CustomEvent("theme:cart:update",{detail:{cartItemCount:window.theme.cartItemCount,itemsRootEl,get cartPromise(){return fetch(window.theme.routes.cart_url,fetchConfigDefaults()).then(res=>res.json()).then(cart=>cart).catch(error=>console.error("Error fetching cart in `theme:cart:update`",error))}}}));break}},updateLiveRegion(liveRegionText){if(!liveRegionText)return;const cartStatus=document.getElementById("cart-live-region-text");cartStatus.textContent=liveRegionText,cartStatus.setAttribute("aria-hidden",!1),setTimeout(()=>{cartStatus.setAttribute("aria-hidden",!0)},1e3)}})),Alpine.data("CartItem",key=>({quantity:null,previousQuantity:null,key,locked:!1,errorMessage:null,init(){document.addEventListener("baseline:cart:lock",()=>{this.locked=!0}),document.addEventListener("baseline:cart:unlock",()=>{this.locked=!1})},async itemQuantityChange(){if(this.locked||this.loading||this.$refs.quantityInput.hasAttribute("data-last-value")&&this.quantity===Number(this.$refs.quantityInput.dataset.lastValue))return;this.locked=!0,this.loading=!0;const request={...fetchConfigDefaults("application/javascript"),body:JSON.stringify({id:this.key,quantity:this.quantity,sections:"cart-items,cart-footer,cart-item-count,cart-live-region",sections_url:window.location.pathname})};try{const data=await(await fetch(theme.routes.cart_change_url,request)).json();data.status===422?(this.errorMessage=data.message,this.quantity=this.previousQuantity,document.dispatchEvent(new CustomEvent("theme:line-item:error",{detail:{message:this.errorMessage,itemsRootEl:this.itemsRoot,lineItemEl:document.querySelector(`[data-line-item-key="${this.key}"]`)||null,variantId:Number(this.$refs.quantityInput.dataset.variantId),key:this.key,quantity:this.quantity}}))):(this.errorMessage=null,document.body.dispatchEvent(new CustomEvent("baseline:cart:cartqtychange",{bubbles:!0,detail:{response:data,key:this.key,quantity:this.quantity,previousQuantity:this.previousQuantity,variantId:Number(this.$refs.quantityInput.dataset.variantId),originalTarget:this.$refs.quantityControl}})))}catch(e){console.error(e),document.getElementById("cart-errors").textContent=theme.strings.cartError,document.dispatchEvent(new CustomEvent("theme:cart:error:other",{detail:{message:theme.strings.cartError,error:e}}))}finally{this.locked=!1,this.loading=!1}},removeItem(){Array.from(this.$root.querySelectorAll('[x-data="CartItemQuantity"]')).filter(el=>el.offsetParent)[0].dispatchEvent(new CustomEvent("remove"))}})),Alpine.data("CartItemQuantity",()=>({init(){this.$root.addEventListener("remove",()=>{this.remove()})},remove(){this.adjustQuantity(()=>{this.$refs.quantityInput.value=0})},...coreQuantity}))}); 2//# sourceMappingURL=/cdn/shop/t/95/assets/cart-items.js.map?v=43431675167093328721763134146
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.