1if(!customElements.get("cart-items")){class CartItems extends HTMLElement{constructor(){super();this.lineItemStatusElement=document.getElementById("shopping-cart-line-item-status")||document.getElementById("CartDrawer-LineItemStatus");const debouncedOnChange=debounce(event=>{if(event.target!=document.getElementById("Cart-note")){this.onChange(event)}},300);this.addEventListener("change",debouncedOnChange.bind(this));document.addEventListener("cart-updated",event=>{this.enableLoading();this.renderContents(event.detail);this.disableLoading()})}onChange(event){this.updateQuantity(event.target.dataset.index,event.target.value,document.activeElement.getAttribute("name"),event)}getSectionsToRender(){return[{id:"main-cart-items",section:document.getElementById("main-cart-items").dataset.id,selector:".js-cart-item-contents"},{id:"main-cart-footer",section:document.getElementById("main-cart-footer").dataset.id,selector:".js-cart-footer-contents"},{id:"cart-icon-bubble",section:"cart-icon-bubble",selector:"[data-cart-icon-bubble]"}]}async updateQuantity(line,quantity,name,event){this.enableLoading();const body=JSON.stringify({line,quantity,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});try{const response=await fetch(`${routes.cart_change_url}`,{...fetchConfig(),body});const parsedState=await response.json();const items=document.querySelectorAll(".cart-item");let quantityElement=document.getElementById(`Quantity-${line}`);if(parsedState.errors){quantityElement.value=quantityElement.getAttribute("value");this.updateLiveRegions(line,parsedState.errors);return}if(!parsedState.sections){event.target.value=event.target.defaultValue;throw new Error(window.cartStrings.error)}this.renderContents(parsedState)}catch(error){console.log(error);const errorMessageTarget=document.getElementById("cart-errors");errorMessageTarget.textContent=window.cartStrings.error}finally{this.disableLoading()}}renderContents(parsedState){this.getSectionsToRender().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.toggleEmptyCart()}toggleEmptyCart(){this.currentItemCount=this.querySelectorAll("[data-line-item]").length;this.classList.toggle("cart-is-empty",this.currentItemCount===0)}updateLiveRegions(line,message){const lineItemError=document.getElementById(`Line-item-error-${line}`);if(lineItemError){lineItemError.querySelector(".cart-item__error-text").innerHTML=message}this.lineItemStatusElement.setAttribute("aria-hidden",true);const cartStatus=document.getElementById("cart-live-region-text");cartStatus.setAttribute("aria-hidden",false);setTimeout(()=>{cartStatus.setAttribute("aria-hidden",true)},1e3)}getSectionInnerHTML(html,selector=".shopify-section"){return(new DOMParser).parseFromString(html,"text/html").querySelector(selector).innerHTML}enableLoading(){document.querySelector("cart-items").classList.add("cart-items-is-loading");document.querySelector('[data-cart-loader-active="show"]')?.classList.remove("hidden");document.querySelector('[data-cart-loader-active="hidden"]')?.classList.add("hidden");document.activeElement.blur();this.lineItemStatusElement.setAttribute("aria-hidden",false)}disableLoading(){document.querySelector('[data-cart-loader-active="show"]')?.classList.add("hidden");document.querySelector('[data-cart-loader-active="hidden"]')?.classList.remove("hidden");document.querySelector("cart-items").classList.remove("cart-items-is-loading")}}customElements.define("cart-items",CartItems)}if(!customElements.get("cart-remove-button")){class CartRemoveButton extends HTMLElement{constructor(){super();this.addEventListener("click",event=>{event.preventDefault();this.closest("cart-items").updateQuantity(this.dataset.index,0)})}}customElements.define("cart-remove-button",CartRemoveButton)}if(!customElements.get("cart-note")){class CartNote extends HTMLElement{constructor(){super();this.addEventListener("change",debounce(event=>{const body=JSON.stringify({note:event.target.value});fetch(`${routes.cart_update_url}`,{...fetchConfig(),...{body}})},300))}}customElements.define("cart-note",CartNote)} 2//# sourceMappingURL=cart.js.map
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.