PageSourceSearch

https://www.reneesgarden.com/cdn/shop/t/142/assets/cart.js?v=129603510589773006081789661575

js reneesgarden.com collected 2026-10-02 04:46:08 UTC 14,129 bytes, 2 lines download raw bytes

1class CartRemoveButton extends HTMLElement{constructor(){super(),this.addEventListener("click",event=>{event.preventDefault(),(this.closest("cart-items")||this.closest("cart-drawer-items")).updateQuantity(this.dataset.index,0)})}}customElements.define("cart-remove-button",CartRemoveButton);class CartItems extends HTMLElement{static addonDependencyCleanupPromise=null;static marketInventoryAdjustmentPromise=null;constructor(){super(),this.lineItemStatusElement=document.getElementById("shopping-cart-line-item-status")||document.getElementById("CartDrawer-LineItemStatus");const debouncedOnChange=debounce(event=>{this.onChange(event)},ON_CHANGE_DEBOUNCE_TIMER);this.addEventListener("change",debouncedOnChange.bind(this))}cartUpdateUnsubscriber=void 0;connectedCallback(){this.cartUpdateUnsubscriber=subscribe(PUB_SUB_EVENTS.cartUpdate,event=>{event.source!=="cart-items"&&this.onCartUpdate(event)}),window.requestAnimationFrame(()=>this.enforceMarketInventoryCaps())}disconnectedCallback(){this.cartUpdateUnsubscriber&&this.cartUpdateUnsubscriber()}onChange(event){this.updateQuantity(event.target.dataset.index,event.target.value,document.activeElement.getAttribute("name"),event.target.dataset.quantityVariantId)}async onCartUpdate(event){if(event?.shouldCleanupAddonDependencies&&this.hasDependentAddonForProduct(Number(event.changedProductId))&&this.isFullCartState(event?.cartData)){const cleanedCartState=await this.removeOrphanedAddonItems(event.cartData);if(cleanedCartState!==event.cartData){this.renderCartSections(cleanedCartState),publish(PUB_SUB_EVENTS.cartUpdate,{source:"cart-addon-dependencies",cartData:cleanedCartState});return}}this.refreshCartSections()}refreshCartSections(){this.tagName==="CART-DRAWER-ITEMS"?fetch(`${routes.cart_url}?section_id=cart-drawer`).then(response=>response.text()).then(responseText=>{const html=new DOMParser().parseFromString(responseText,"text/html"),selectors=["cart-drawer-items",".cart-drawer__footer"];for(const selector of selectors){const targetElement=document.querySelector(selector),sourceElement=html.querySelector(selector);targetElement&&sourceElement&&targetElement.replaceWith(sourceElement)}}).catch(e=>{console.error(e)}):fetch(`${routes.cart_url}?section_id=main-cart-items`).then(response=>response.text()).then(responseText=>{const sourceQty=new DOMParser().parseFromString(responseText,"text/html").querySelector("cart-items");this.innerHTML=sourceQty.innerHTML}).catch(e=>{console.error(e)})}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"},{id:"main-cart-footer",section:document.getElementById("main-cart-footer").dataset.id,selector:".js-contents"}]}updateQuantity(line,quantity,name,variantId){const previousQuantity=this.getLineQuantity(line),nextQuantity=Number.parseInt(quantity,10),changedProductId=this.getLineProductId(line),shouldCleanupAddonDependencies=Number.isFinite(nextQuantity)&&Number.isFinite(previousQuantity)&&nextQuantity<previousQuantity&&this.hasDependentAddonForProduct(changedProductId);this.enableLoading(line);const body=JSON.stringify({line,quantity,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});fetch(`${routes.cart_change_url}`,{...fetchConfig(),body}).then(response=>response.text()).then(async state=>{let parsedState=JSON.parse(state);const quantityElement=document.getElementById(`Quantity-${line}`)||document.getElementById(`Drawer-quantity-${line}`),items=document.querySelectorAll(".cart-item");if(parsedState.errors){quantityElement.value=quantityElement.getAttribute("value"),this.updateLiveRegions(line,parsedState.errors);return}shouldCleanupAddonDependencies&&(parsedState=await this.removeOrphanedAddonItems(parsedState));const cartDrawerWrapper=document.querySelector("cart-drawer");this.renderCartSections(parsedState);const updatedValue=parsedState.items[line-1]?parsedState.items[line-1].quantity:void 0;let message="";items.length===parsedState.items.length&&updatedValue!==parseInt(quantityElement.value)&&(typeof updatedValue>"u"?message=window.cartStrings.error:message=window.cartStrings.quantityError.replace("[quantity]",updatedValue)),this.updateLiveRegions(line,message);const lineItem=document.getElementById(`CartItem-${line}`)||document.getElementById(`CartDrawer-Item-${line}`);lineItem&&lineItem.querySelector(`[name="${name}"]`)?cartDrawerWrapper?trapFocus(cartDrawerWrapper,lineItem.querySelector(`[name="${name}"]`)):lineItem.querySelector(`[name="${name}"]`).focus():parsedState.item_count===0&&cartDrawerWrapper?trapFocus(cartDrawerWrapper.querySelector(".drawer__inner-empty"),cartDrawerWrapper.querySelector("a")):document.querySelector(".cart-item")&&cartDrawerWrapper&&trapFocus(cartDrawerWrapper,document.querySelector(".cart-item__name")),publish(PUB_SUB_EVENTS.cartUpdate,{source:"cart-items",cartData:parsedState,variantId})}).catch(()=>{this.querySelectorAll(".loading__spinner").forEach(overlay=>overlay.classList.add("hidden"));const errors=document.getElementById("cart-errors")||document.getElementById("CartDrawer-CartErrors");errors.textContent=window.cartStrings.error}).finally(()=>{this.disableLoading(line)})}getLineQuantity(line){const quantityElement=document.getElementById(`Quantity-${line}`)||document.getElementById(`Drawer-quantity-${line}`);if(!quantityElement)return null;const quantity=Number.parseInt(quantityElement.getAttribute("value"),10)||Number.parseInt(quantityElement.dataset.cartQuantity,10)||Number.parseInt(quantityElement.value,10);return Number.isFinite(quantity)?quantity:null}getLineProductId(line){const lineItem=document.getElementById(`CartItem-${line}`)||document.getElementById(`CartDrawer-Item-${line}`),productId=Number(lineItem?.dataset.cartProductId);return Number.isFinite(productId)?productId:null}hasDependentAddonForProduct(productId){return Number.isFinite(Number(productId))?[...this.getRenderedAddonDependencies().values()].some(parentProductIds=>parentProductIds.includes(Number(productId))):!1}renderCartSections(parsedState){this.classList.toggle("is-empty",parsedState.item_count===0);const cartDrawerWrapper=document.querySelector("cart-drawer"),cartFooter=document.getElementById("main-cart-footer");cartFooter&&cartFooter.classList.toggle("is-empty",parsedState.item_count===0),c
1artDrawerWrapper&&cartDrawerWrapper.classList.toggle("is-empty",parsedState.item_count===0),this.getSectionsToRender().forEach(section=>{const sectionHTML=parsedState.sections?.[section.section],sectionElement=document.getElementById(section.id);if(!sectionHTML||!sectionElement)return;const elementToReplace=sectionElement.querySelector(section.selector)||sectionElement;elementToReplace.innerHTML=this.getSectionInnerHTML(sectionHTML,section.selector)})}getMarketInventoryAdjustments(){const variants=new Map;this.querySelectorAll(".quantity__input[data-market-inventory-cap]").forEach(input=>{const row=input.closest("[data-cart-line-key]"),lineKey=row?.dataset.cartLineKey,variantId=Number(input.dataset.quantityVariantId||row?.dataset.cartVariantId),quantity=Number.parseInt(input.value,10),cap=Number.parseInt(input.dataset.marketInventoryCap,10),minimum=Math.max(Number.parseInt(input.min,10)||1,1),increment=Math.max(Number.parseInt(input.step,10)||1,1);if(!lineKey||!Number.isFinite(variantId)||!Number.isFinite(quantity)||!Number.isFinite(cap))return;const group=variants.get(variantId)||{cap:Math.max(cap,0),lines:[]};group.cap=Math.min(group.cap,Math.max(cap,0)),group.lines.push({lineKey,quantity:Math.max(quantity,0),minimum,increment}),variants.set(variantId,group)});const updates={};
1return variants.forEach(({cap,lines})=>{if(lines.reduce((total,line)=>total+line.quantity,0)<=cap)return;let remaining=cap;lines.forEach(({lineKey,quantity,minimum,increment})=>{let allowedQuantity=Math.min(quantity,remaining);allowedQuantity<minimum?allowedQuantity=0:allowedQuantity-=(allowedQuantity-minimum)%increment,remaining=Math.max(remaining-allowedQuantity,0),allowedQuantity!==quantity&&(updates[lineKey]=allowedQuantity)})}),updates}async enforceMarketInventoryCaps(){const updates=this.getMarketInventoryAdjustments();if(Object.keys(updates).length){if(!CartItems.marketInventoryAdjustmentPromise){const checkoutButtons=[...document.querySelectorAll('[name="checkout"]')].map(button=>({button,wasDisabled:button.hasAttribute("disabled")}));checkoutButtons.forEach(({button})=>button.setAttribute("disabled","disabled")),CartItems.marketInventoryAdjustmentPromise=(async()=>{const body=JSON.stringify({updates,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname}),response=await fetch(`${routes.cart_update_url}`,{...fetchConfig(),body});let cartState=await response.json();if(!response.ok||cartState.errors)throw new Error(cartState.description||cartState.message||"Cart update failed");return cartState=await this.removeOrphanedAddonItems(cartState),this.renderCartSections(cartState),document.querySelectorAll("#cart-errors, #CartDrawer-CartErrors").forEach(errorElement=>{errorElement.textContent=window.cartStrings?.marketInventoryAdjusted||"Some quantities were adjusted to match inventory available in your market."}),publish(PUB_SUB_EVENTS.cartUpdate,{source:"market-inventory",cartData:cartState}),cartState})().catch(error=>{console.error(error),checkoutButtons.forEach(({button,wasDisabled})=>{wasDisabled||button.removeAttribute("disabled")}),document.querySelectorAll("#cart-errors, #CartDrawer-CartErrors").forEach(errorElement=>{errorElement.textContent=window.cartStrings?.error||"There was an error while updating your cart."})}).finally(()=>{CartItems.marketInventoryAdjustmentPromise=null})}return CartItems.marketInventoryAdjustmentPromise}}async removeOrphanedAddonItems(cartState){if(!this.isFullCartState(cartState))return cartState;const orphanedLineKeys=this.getOrphanedAddonLineKeys(cartState);return orphanedLineKeys.length?(CartItems.addonDependencyCleanupPromise||(CartItems.addonDependencyCleanupPromise=this.updateAddonDependencyQuantities(orphanedLineKeys).catch(error=>(console.error(error),cartState)).finally(()=>{CartItems.addonDependencyCleanupPromise=null})),CartItems.addonDependencyCleanupPromise):cartState}getOrphanedAddonLineKeys(cartState){const items=Array.isArray(cartState?.items)?cartState.items:[];if(!items.length)return[];const cartProductIds=new Set(items.map(item=>Number(item.product_id)).filter(productId=>Number.isFinite(productId))),renderedDependencies=this.getRenderedAddonDependencies();return items.filter(item=>{const parentProductIds=new Set(renderedDependencies.get(item.key)||[]);return parentProductIds.size>0&&![...parentProductIds].some(productId=>cartProductIds.has(productId))}).map(item=>item.key).filter(Boolean)}isFullCartState(cartState){return Array.isArray(cartState?.items)&&Number.isFinite(Number(cartState.item_count))&&Number.isFinite(Number(cartState.total_price))}getRenderedAddonDependencies(){const dependencies=new Map;return document.querySelectorAll('[data-cart-line-key][data-addon-dependent-line="true"][data-addon-parent-product-ids]').forEach(row=>{const lineKey=row.dataset.cartLineKey,parentProductIds=this.parseIdList(row.dataset.add
1onParentProductIds);!lineKey||!parentProductIds.length||dependencies.set(lineKey,[...dependencies.get(lineKey)||[],...parentProductIds])}),dependencies}parseIdList(value){return`${value||""}`.split(",").map(id=>Number(id.trim())).filter(id=>Number.isFinite(id))}async updateAddonDependencyQuantities(orphanedLineKeys){const updates=orphanedLineKeys.reduce((lineUpdates,lineKey)=>(lineUpdates[lineKey]=0,lineUpdates),{}),body=JSON.stringify({updates,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});return(await fetch(`${routes.cart_update_url}`,{...fetchConfig(),body})).json()}updateLiveRegions(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)}getSectionInnerHTML(html,selector){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}enableLoading(line){(document.getElementById("main-cart-items")||document.getElementById("CartDrawer-CartItems")).classList.add("cart__items--disabled");const cartItemElements=this.querySelectorAll(`#CartItem-${line} .loading__spinner`),cartDrawerItemElements=this.querySelectorAll(`#CartDrawer-Item-${line} .loading__spinner`);
1[...cartItemElements,...cartDrawerItemElements].forEach(overlay=>overlay.classList.remove("hidden")),document.activeElement.blur(),this.lineItemStatusElement.setAttribute("aria-hidden",!1)}disableLoading(line){(document.getElementById("main-cart-items")||document.getElementById("CartDrawer-CartItems")).classList.remove("cart__items--disabled");const cartItemElements=this.querySelectorAll(`#CartItem-${line} .loading__spinner`),cartDrawerItemElements=this.querySelectorAll(`#CartDrawer-Item-${line} .loading__spinner`);cartItemElements.forEach(overlay=>overlay.classList.add("hidden")),cartDrawerItemElements.forEach(overlay=>overlay.classList.add("hidden"))}}customElements.define("cart-items",CartItems),customElements.get("cart-note")||customElements.define("cart-note",class extends HTMLElement{constructor(){super(),this.addEventListener("input",debounce(event=>{const body=JSON.stringify({note:event.target.value});fetch(`${routes.cart_update_url}`,{...fetchConfig(),body})},ON_CHANGE_DEBOUNCE_TIMER))}});
2//# sourceMappingURL=/cdn/shop/t/142/assets/cart.js.map?v=129603510589773006081789661575

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.