PageSourceSearch

https://emosnotdead.com/cdn/shop/t/73/assets/cart.js?v=151148477438720192201790263304

js emosnotdead.com collected 2026-10-02 22:02:59 UTC 17,445 bytes, 2 lines download raw bytes

1const withMiniCartScrollRestore=render=>{const main=document.querySelector(".mini-cart__main"),scrollTop=main?main.scrollTop:0;if(render(),scrollTop>0){const newMain=document.querySelector(".mini-cart__main");newMain&&(newMain.scrollTop=scrollTop)}};window.theme=window.theme||{},theme.patchMiniCart=sectionInnerHTML=>{const live=document.getElementById("mini-cart");if(!live||!sectionInnerHTML)return!1;const next=new DOMParser().parseFromString(sectionInnerHTML,"text/html").body;if(!next)return!1;const liveForm=live.querySelector("form.mini-cart"),nextForm=next.querySelector("form.mini-cart");if(!liveForm||!nextForm||liveForm.classList.contains("is-empty")!==nextForm.classList.contains("is-empty"))return!1;const regions=[{selector:"cart-items",mode:"inner"},{selector:".free-shipping",mode:"outer"},{selector:".taxes-discounts",mode:"outer"},{selector:"gift-wrapping",mode:"outer"},{selector:"cart-discount .discounts",mode:"inner"},{selector:'input[type="hidden"][name="discount"]',mode:"outer"},{selector:"#mini-cart-subtotal",mode:"inner"}],jobs=[];for(const region of regions){const liveEls=live.querySelectorAll(region.selector),nextEls=next.querySelectorAll(region.selector);if(liveEls.length!==nextEls.length)return!1;liveEls.forEach((el,i)=>jobs.push({el,nextEl:nextEls[i],mode:region.mode}))}const main=live.querySelector(".mini-cart__main"),scrollTop=main?main.scrollTop:0;jobs.forEach(({el,nextEl,mode})=>{mode==="inner"?el.innerHTML=nextEl.innerHTML:el.outerHTML=nextEl.outerHTML}),liveForm.className=nextForm.className;const liveRecs=live.querySelector("cart-recommendations"),nextRecs=next.querySelector("cart-recommendations");return liveRecs&&nextRecs&&liveRecs.dataset.url!==nextRecs.dataset.url&&(liveRecs.outerHTML=nextRecs.outerHTML),live.querySelectorAll(".is-pending, .cart-item--pending").forEach(el=>{el.classList.remove("is-pending","cart-item--pending")}),main&&scrollTop>0&&(main.scrollTop=scrollTop),!0};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),customElements.get("cart-items")||customElements.define("cart-items",class extends HTMLElement{cartUpdateUnsubscriber=void 0;constructor(){super(),this.lineItemStatusElement=document.getElementById("shopping-cart-line-item-status"),this.cartErrors=document.getElementById("cart-errors"),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.cartUpdateUnsubscriber=subscribe(PUB_SUB_EVENTS.cartUpdate,this.onCartUpdate.bind(this))}disconnectedCallback(){this.cartUpdateUnsubscriber&&this.cartUpdateUnsubscriber()}onCartUpdate(event){const sections=event.sections,parsedState=event.cart;if(event.source==="cart-items"&&event.seq!==void 0&&event.seq!==this.updateSeq)return;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),parsedState.errors&&this.updateErrorLiveRegions(event.line,parsedState.errors);const patched=!!this.closest("#mini-cart")&&parsedState.sections&&parsedState.sections["mini-cart"]&&theme.patchMiniCart&&theme.patchMiniCart(this.getSectionInnerHTML(parsedState.sections["mini-cart"],".shopify-section"));withMiniCartScrollRestore(()=>{this.getSectionsToRender().forEach((section=>{if(patched&&section.id==="mini-cart")return;const element=document.getElementById(section.id);if(element){const elementToReplace=element.querySelector(section.selector)||element;elementToReplace&&parsedState.sections[section.section]&&(elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.section],section.selector))}}))}),this.updateQuantityLiveRegions(event.line,parsedState.item_count);const lineItem=document.getElementById(`CartItem-${event.line}`);lineItem&&event.name&&lineItem.querySelector(`[name="${event.name}"]`).focus(),this.disableLoading(),document.dispatchEvent(new CustomEvent("cart:updated",{detail:{cart:parsedState}}))}optimisticSubtotal(line,quantity){const miniCart=document.getElementById("mini-cart");if(!miniCart||!miniCart.contains(this))return;const rows=Array.from(this.querySelectorAll(".mini-cart__navigation > li")),changedRow=rows[parseInt(line)-1];parseInt(quantity)===0&&changedRow&&changedRow.classList.add("cart-item--removing");const subtotals=miniCart.querySelectorAll("#mini-cart-subtotal");
1if(subtotals.forEach(el=>el.classList.add("is-pending")),!window.theme||!theme.Currency||!theme.shopSettings||parseInt(this.dataset.cartLevelDiscounts||"0")>0||!rows.length||rows.some(row=>!row.dataset.finalPrice))return;let total=0;for(const[i,row]of rows.entries()){let qty;if(i+1===parseInt(line))qty=parseInt(quantity);else{const input=row.querySelector(".quantity__input");qty=parseInt(input?input.value:row.dataset.quantity)}if(Number.isNaN(qty))return;total+=parseInt(row.dataset.finalPrice)*qty}const format=theme.shopSettings.moneyWithCurrencyFormat||theme.shopSettings.moneyFormat;subtotals.forEach(el=>{el.innerHTML=theme.Currency.formatMoney(total,format)})}updateQuantity(line,quantity,name,target){this.updateSeq=(this.updateSeq||0)+1;const seq=this.updateSeq;this.optimisticSubtotal(line,quantity);const sections=this.getSectionsToRender().map(section=>section.section),body=JSON.stringify({line,quantity,sections,sections_url:window.location.pathname});fetch(`${theme.routes.cart_change_url}`,{...fetchConfig(),body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state);publish(PUB_SUB_EVENTS.cartUpdate,{source:"cart-items",cart:parsedState,target,line,name,sections,seq})}).catch(()=>{this.querySelectorAll(".loading-overlay").forEach(overlay=>overlay.classList.add("hidden")),this.disableLoading(),this.cartErrors&&(this.cartErrors.textContent=theme.cartStrings.error),this.resyncMiniCart()})}resyncMiniCart(){const miniCart=document.querySelector("mini-cart[data-url]");!miniCart||!miniCart.contains(this)||fetch(miniCart.dataset.url).then(response=>response.text()).then(html=>{const sectionInnerHTML=new DOMParser().parseFromString(html,"text/html").querySelector(".shopify-section").innerHTML;(!theme.patchMiniCart||!theme.patchMiniCart(sectionInnerHTML))&&withMiniCartScrollRestore(()=>{document.getElementById("mini-cart").innerHTML=sectionInnerHTML})}).catch(e=>console.error(e))}onChange(event){event.target!==null&&this.updateQuantity(event.target.dataset.index,event.target.value,document.activeElement.getAttribute("name"))}getSectionsToRender(){let sections=[{id:"mini-cart",section:document.getElementById("mini-cart")?.id,selector:".shopify-section"},{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:"mobile-cart-icon-bubble",section:"mobile-cart-icon-bubble",selector:".shopify-section"},{id:"cart-live-region-text",section:"cart-live-region-text",selector:".shopify-section"},{id:"main-cart-footer",section:document.getElementById("main-cart-footer")?.dataset.id,selector:".cart__footer"}];return document.querySelector("#main-cart-footer .free-shipping")&&sections.push({id:"main-cart-footer",section:document.getElementById("main-cart-footer")?.dataset.id,selector:".free-shipping"}),sections}updateErrorLiveRegions(line,message){const lineItemError=document.getElementById(`Line-item-error-${line}`)||document.getElementById(`CartDrawer-LineItemError-${line}`);lineItemError&&(lineItemError.querySelector(".cart-item__error-text").innerHTML=message),this.lineItemStatusElement.setAttribute("aria-hidden",!0);const cartStatus=document.getElementById("cart-live-region-text")||document.getElementById("CartDrawer-LiveRegionText");cartStatus.setAttribute("aria-hidden",!1),setTimeout(()=>{cartStatus.setAttribute("aria-hidden",!0)},1e3)}updateQuantityLiveRegions(line,itemCount){if(this.currentItemCount===itemCount){const quantityError=document.getElementById(`Line-item-error-${line}`);quantityError&&(quantityError.querySelector(".cart-item__error-text").innerHTML=theme.cartStrings.quantityError.replace("[quantity]",document.getElementById(`Quantity-${line}`).value))}this.currentItemCount=itemCount,this.lineItemStatusElement&&this.lineItemStatusElement.setAttribute("aria-hidden",!0);const cartStatus=document.getElementById("cart-live-region-text");cartStatus&&(cartStatus.setAttribute("aria-hidden",!1),setTimeout(()=>{cartStatus.setAttribute("aria-hidden",!0)},1e3))}getSectionInnerHTML(html,selector){return new DOMParser().parseFromString(html,"text/html").querySelector(selector)?.innerHTML}enableLoading(line){const cartItems=document.getElementById("main-cart-items");cartItems&&cartItems.classList.add("cart__items--disabled");const loadingOverlay=this.querySelectorAll(".loading-overlay")[line-1];loadingOverlay&&loadingOverlay.classList.remove("hidden"),document.activeElement.blur(),this.lineItemStatusElement&&this.lineItemStatusElement.setAttribute("aria-hidden",!1)}disableLoading(){const cartItems=document.getElementById("main-cart-items");cartItems&&cartItems.classList.remove("cart__items--disabled")}renderContents(parsedState){withMiniCartScrollRestore(()=>
1{this.getSectionsToRender().forEach((section=>{const element=document.getElementById(section.id);element&&(element.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.id],section.selector))}))})}});class CartNote extends HTMLElement{constructor(){super(),this.addEventListener("change",debounce(event=>{const body=JSON.stringify({note:event.target.value});fetch(`${theme.routes.cart_update_url}`,{...fetchConfig(),body})},300))}}customElements.define("cart-note",CartNote),customElements.get("cart-discount")||customElements.define("cart-discount",class extends HTMLElement{constructor(){super(),this.onApplyDiscount=this.applyDiscount.bind(this)}get sectionId(){return this.getAttribute("data-section-id")}connectedCallback(){this.submitButton=this.querySelector("[data-discount-btn]"),this.resultsElement=this.lastElementChild,this.submitButton.addEventListener("click",this.onApplyDiscount)}disconnectedCallback(){this.abortController?.abort(),this.submitButton.removeEventListener("click",this.onApplyDiscount)}getSectionsToRender(){let sections=[{id:"mini-cart",section:document.getElementById("mini-cart")?.id,selector:".shopify-section"},{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:"mobile-cart-icon-bubble",section:"mobile-cart-icon-bubble",selector:".shopify-section"},{id:"cart-live-region-text",section:"cart-live-region-text",selector:".shopify-section"},{id:"main-cart-footer",section:document.getElementById("main-cart-footer")?.dataset.id,selector:".cart__footer"}];return document.querySelector("#main-cart-footer .free-shipping")&&sections.push({id:"main-cart-footer",section:document.getElementById("main-cart-footer")?.dataset.id,selector:".free-shipping"}),sections}applyDiscount(event){event.preventDefault();const discountCode=this.querySelector('[name="discount"]');if(!(discountCode instanceof HTMLInputElement)||typeof this.getAttribute("data-section-id")!="string")return;this.abortController?.abort(),this.abortController=new AbortController;const discountCodeValue=discountCode.value.trim();if(discountCodeValue==="")return;const existingDiscounts=this.existingDiscounts();if(existingDiscounts.includes(discountCodeValue))return;this.setDiscountError(""),this.submitButton.setAttribute("aria-busy","true");const sections=this.getSectionsToRender().map(section=>section.section),body=JSON.stringify({discount:[...existingDiscounts,discountCodeValue].join(","),sections,sections_url:window.location.pathname});fetch(`${theme.routes.cart_update_url}`,{...fetchConfig("json"),body,signal:this.abortController.signal}).then(response=>response.json()).then(parsedState=>{if(parsedState.discount_codes.find(discount=>discount.code===discountCodeValue&&discount.applicable===!1)){discountCode.value="",this.setDiscountError(theme.discountStrings.error);return}const newHtml=parsedState.sections[this.sectionId],section=new DOMParser().parseFromString(newHtml,"text/html").getElementById(`shopify-section-${this.sectionId}`);if(section){const discountCodes=section?.querySelectorAll('button[is="discount-remove"]')||[],codes=Array.from(discountCodes).map(element=>element instanceof HTMLButtonElement?element.getAttribute("data-discount"):null).filter(Boolean);if(codes.length===existingDiscounts.length&&codes.every(code=>existingDiscounts.includes(code))&&parsedState.discount_codes.find(discount=>discount.code===discountCodeValue&&discount.applicable===!0)){discountCode.value="",this.setDiscountError(theme.discountStrings.shippingError);return}}publish(PUB_SUB_EVENTS.cartUpdate,{source:"cart-discount",cart:parsedState})}).catch(error=>{error.name==="AbortError"?console.log("Fetch aborted by user"):console.error(error)}).finally(()=>{this.submitButton.removeAttribute("aria-busy")})}removeDiscount(event){if(event instanceof KeyboardEvent&&event.key!=="Enter"||!(event instanceof MouseEvent))return;const discountCode=event.currentTarget.getAttribute("data-discount");if(!discountCode)return;const existingDiscounts=this.existingDiscounts(),index=existingDiscounts.indexOf(discountCode);
1if(index===-1)return;existingDiscounts.splice(index,1),this.abortController?.abort(),this.abortController=new AbortController,this.setDiscountError(""),event.currentTarget.setAttribute("loading","");const sections=this.getSectionsToRender().map(section=>section.section),body=JSON.stringify({discount:existingDiscounts.join(","),sections,sections_url:window.location.pathname});fetch(theme.routes.cart_update_url,{...fetchConfig(),body,signal:this.abortController.signal}).then(response=>response.json()).then(parsedState=>{publish(PUB_SUB_EVENTS.cartUpdate,{source:"cart-discount",cart:parsedState})}).catch(error=>{error.name==="AbortError"?console.log("Fetch aborted by user"):console.error(error)}).finally(()=>{event.target.removeAttribute("loading")})}existingDiscounts(){const discountCodes=[],discountPills=this.querySelectorAll('button[is="discount-remove"]');for(const pill of discountPills)pill.hasAttribute("data-discount")&&discountCodes.push(pill.getAttribute("data-discount"));return discountCodes}setDiscountError(error){this.resultsElement.lastElementChild.textContent=error,error.length===0?this.resultsElement.classList.add("hidden"):this.resultsElement.classList.remove("hidden")}});class DiscountRemove extends HTMLButtonElement{constructor(){super(),this.addEventListener("click",event=>{const cartDiscount=this.closest("cart-discount")||document.querySelector("cart-discount");cartDiscount&&(event.preventDefault(),cartDiscount.removeDiscount(event))})}}customElements.define("discount-remove",DiscountRemove,{extends:"button"});class ShippingCalculator extends HTMLElement{constructor(){super(),this.setupCountries(),this.errors=this.querySelector("#ShippingCalculatorErrors"),this.success=this.querySelector("#ShippingCalculatorSuccess"),this.zip=this.querySelector("#ShippingCalculatorZip"),this.country=this.querySelector("#ShippingCalculatorCountry"),this.province=this.querySelector("#ShippingCalculatorProvince"),this.button=this.querySelector("button"),this.button.addEventListener("click",this.onSubmitHandler.bind(this))}setupCountries(){Shopify&&Shopify.CountryProvinceSelector&&new Shopify.CountryProvinceSelector("ShippingCalculatorCountry","ShippingCalculatorProvince",{hideElement:"ShippingCalculatorProvinceContainer"})}onSubmitHandler(event){event.preventDefault(),this.errors.classList.add("hidden"),this.success.classList.add("hidden"),this.zip.classList.remove("invalid"),this.country.classList.remove("invalid"),this.province.classList.remove("invalid"),this.button.classList.add("loading"),this.button.setAttribute("disabled",!0);const body=JSON.stringify({shipping_address:{zip:this.zip.value,country:this.country.value,province:this.province.value}});let sectionUrl=`${theme.routes.cart_url}/shipping_rates.json`;sectionUrl=sectionUrl.replace("//","/"),fetch(sectionUrl,{...fetchConfig("javascript"),body}).then(response=>response.json()).then(parsedState=>{if(parsedState.shipping_rates)this.success.classList.remove("hidden"),this.success.innerHTML="",parsedState.shipping_rates.forEac
1h(rate=>{const child=document.createElement("p");child.innerHTML=`${rate.name}: ${rate.price} ${Shopify.currency.active}`,this.success.appendChild(child)});else{let errors=[];Object.entries(parsedState).forEach(([attribute,messages])=>{errors.push(`${attribute.charAt(0).toUpperCase()+attribute.slice(1)} ${messages[0]}`)}),this.errors.classList.remove("hidden"),this.errors.querySelector(".errors").innerHTML=errors.join("; ")}}).catch(e=>{console.error(e)}).finally(()=>{this.button.classList.remove("loading"),this.button.removeAttribute("disabled")})}}customElements.define("shipping-calculator",ShippingCalculator);
2//# sourceMappingURL=/cdn/shop/t/73/assets/cart.js.map?v=151148477438720192201790263304

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.