1class CartRemoveButton extends HTMLElement{constructor(){super(),this.addEventListener("click",event=>{event.preventDefault(),this.closest("cart-items").updateQuantity({id:this.dataset.id,quantity:0})})}}customElements.define("cart-remove-button",CartRemoveButton);class CartDrawer{constructor(){this.cartButton=document.getElementById("cart-icon-bubble"),this.cartDrawer=document.getElementById("cart-drawer-wrapper"),this.cartCheckoutButton=document.getElementById("cart-checkout-button"),this.cartDrawerCloseButton=document.getElementById("close-cart-icon"),this.defaultCartTitle=document.getElementById("cart__item-title").innerHTML,this.cartButton.addEventListener("click",function(e){e.preventDefault(),document.body.classList.add("drawer-open"),this.cartDrawer.classList.remove("closed")}.bind(this)),this.cartDrawerCloseButton.addEventListener("click",function(){this.cartDrawer.classList.add("closed"),document.body.classList.remove("drawer-open")}.bind(this)),this.cartDrawer.addEventListener("click",function(e){e.target===this.cartDrawer&&(this.cartDrawer.classList.add("closed"),this.updateCartTitle(),document.body.classList.remove("drawer-open"))}.bind(this))}updateCartPrices(parsedState){const cartSubTotal=document.getElementById("cart-sub-total"),cartTotal=document.getElementById("cart-total");cartSubTotal&&(cartSubTotal.setAttribute("data-total",parsedState.total_price),cartSubTotal.innerHTML=`\xA3${(parsedState.total_price/100).toFixed(2)}`),cartTotal&&(cartTotal.innerHTML=` \xA3${(parsedState.total_price/100).toFixed(2)}`)}updateCartTitle(text){text===void 0&&(text=this.defaultCartTitle),document.getElementById("cart__item-title").innerHTML=text}updateCartItemCount(itemCount){document.getElementById("cart__item-count").innerHTML=itemCount}updateCartPromo(parsedState){parsedState.total_price===void 0&&(parsedState.total_price=Number($("#cart-sub-total").data("total")));const $cart_promo=$("#cart__promo");parsedState.total_price<=window.cart_promo.price_show_at?$cart_promo.hide():parsedState.total_price>=window.cart_promo.price_show_at&&parsedState.total_price<=window.cart_promo.price_needed?$cart_promo.show().html(window.cart_promo.content_invalid):parsedState.total_price>window.cart_promo.price_needed&&$cart_promo.show().html(window.cart_promo.content_valid)}}window.addEventListener("load",function(){document.getElementById("cart-drawer-wrapper")!==null&&(window.cartDrawer=new CartDrawer)});class CartItems extends HTMLElement{constructor(){super(),this.lineItemStatusElement=document.getElementById("shopping-cart-line-item-status"),this.currentItemCount=Array.from(this.querySelectorAll('[name="updates[]"]')).reduce((total,quantityInput)=>total+parseInt(quantityInput.value),0),this.debouncedOnChange=debounce(event=>{this.onChange(event)},300),this.addEventListener("change",this.debouncedOnChange.bind(this)),this.addEventListener("input",this.debouncedOnChange.bind(this))}onChange(event){if(!event||!event.target||event.target.name!=="updates[]")return;const activeElementName=document.activeElement&&typeof document.activeElement.getAttribute=="function"?document.activeElement.getAttribute("name"):null;this.updateQuantity({line:event.target.dataset.index,quantity:event.target.value,name:activeElementName||event.target.getAttribute("name"),id:event.target.dataset.id})}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:"cart-live-region-text",section:"cart-live-region-text",selector:".shopify-section"}]}renderContents(parsedState){this.classList.toggle("is-empty",parsedState.item_count===0),this.get
1SectionsToRender().forEach(section=>{document.getElementById(section.id).innerHTML=this.getSectionInnerHTML(parsedState.sections[section.id],section.selector)}),document.getElementById("cart-icon-bubble").click()}updateCartPromo(parsedState){parsedState.total_price===void 0&&(parsedState.total_price=Number($("#cart-sub-total").data("total")));const $cart_promo=$("#cart__promo");parsedState.total_price<=window.cart_promo.price_show_at?$cart_promo.hide():parsedState.total_price>=window.cart_promo.price_show_at&&parsedState.total_price<=window.cart_promo.price_needed?$cart_promo.show().html(window.cart_promo.content_invalid):parsedState.total_price>window.cart_promo.price_needed&&$cart_promo.show().html(window.cart_promo.content_valid)}updateCartPagePrices(parsedState){const cartSubTotal=document.getElementById("cart-sub-total"),cartTotal=document.getElementById("cart-total");cartSubTotal&&(cartSubTotal.innerHTML=`\xA3${(parsedState.total_price/100).toFixed(2)}`,cartSubTotal.setAttribute("data-total",parsedState.total_price)),cartTotal&&(cartTotal.innerHTML=` \xA3${(parsedState.total_price/100).toFixed(2)}`)}updateQuantity(data){const line=data.line,name=data.name,id=data.id,requestedQuantity=Math.max(0,parseInt(data.quantity,10)||0);this.enableLoading(line);const body=JSON.stringify({id,quantity:requestedQuantity,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});fetch(`${routes.cart_change_url}`,{...fetchConfig(),body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state);this.classList.toggle("is-empty",parsedState.item_count===0);const cartFooter=document.getElementById("main-cart-footer");cartFooter&&cartFooter.classList.toggle("is-empty",parsedState.item_count===0),this.get
1SectionsToRender().forEach(section=>{const elementToReplace=document.getElementById(section.id).querySelector(section.selector)||document.getElementById(section.id);elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.section],section.selector)}),this.updateLiveRegions(line,parsedState,requestedQuantity,id);const lineItem=document.getElementById(`CartItem-${line}`);lineItem&&lineItem.querySelector(`[name="${name}"]`)&&lineItem.querySelector(`[name="${name}"]`).focus(),document.getElementById("cart-drawer-wrapper")!==null&&window.cartDrawer.updateCartPrices(parsedState),document.getElementById("cart__item-count")!==null&&(document.getElementById("cart__item-count").innerHTML=parsedState.item_count),this.updateCartPagePrices(parsedState),this.updateCartPromo(parsedState),this.disableLoading()}).catch(async state=>{try{if(state?.json){const quantityMatch=(await state.json())?.description?.match(/(\d+)/),maxQuantity=quantityMatch?parseInt(quantityMatch[1],10):null;if(Number.isFinite(maxQuantity)){const quantityInput=document.getElementById(`Quantity-${line}`);quantityInput&&(quantityInput.value=maxQuantity),this.updateQuantity({line,quantity:maxQuantity,name,id});return}}}catch{}this.querySelectorAll(".loading-overlay").forEach(overlay=>overlay.classList.add("hidden")),document.getElementById("cart-errors").textContent=window.cartStrings.error,this.disableLoading()})}updateLiveRegions(line,parsedState,requestedQuantity,lineItemId){const itemCount=parsedState.item_count,lineItemError=document.getElementById(`Line-item-error-${line}`)?.querySelector(".cart-item__error-text"),updatedInput=document.getElementById(`Quantity-${line}`),updatedLineItem=parsedState.items?.find(item=>String(item.id)===String(lineItemId))||parsedState.items?.[line-1];if(lineItemError){lineItemError.innerHTML="";const requested=parseInt(requestedQuantity,10);updatedLineItem&&Number.isFinite(requested)&&requested>0&&updatedLineItem.quantity<requested&&(lineItemError.innerHTML=window.cartStrings.quantityError.replace("[quantity]",updatedLineItem.quantity))}updatedLineItem&&(updatedInput&&(updatedInput.value=updatedLineItem.quantity),this.querySelectorAll(`[name="updates[]"][data-id="${updatedLineItem.id}"]`).forEach(input=>{input.value=updatedLineItem.quantity}));const cartStatus=document.getElementById("cart-live-region-text"),statusText=cartStatus?.textContent.trim()||`Cart updated. ${itemCount} ${itemCount===1?"item":"items"} in cart.`;this.currentItemCount=itemCount,this.lineItemStatusElement&&(this.lineItemStatusElement.textContent=""),cartStatus&&(cartStatus.textContent=statusText)}getSectionInnerHTML(html,selector){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}enableLoading(line){document.getElementById("main-cart-items").classList.add("cart__items--disabled"),this.querySelectorAll(`#CartItem-${line} .loading-overlay`).forEach(overlay=>overlay.classList.remove("hidden")),document.activeElement.blur(),this.lineItemStatusElement&&(this.lineItemStatusElement.textContent=window.cartStrings.loading)}disableLoading(){document.getElementById("main-cart-items").classList.remove("cart__items--disabled")}}customElements.define("cart-items",CartItems); 2//# sourceMappingURL=/cdn/shop/t/548/assets/cart.js.map?v=13682877002612509421786351897
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.