PageSourceSearch

https://www.melaniatrump.com/cdn/shop/t/4/assets/cart.js?v=68448484942835920921747448274

js melaniatrump.com collected 2026-10-02 04:43:20 UTC 12,134 bytes, 2 lines download raw bytes

1class CartRemoveButton extends HTMLElement{constructor(){super(),this.addEventListener("click",event2=>{event2.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{constructor(){super(),this.lineItemStatusElement=document.getElementById("shopping-cart-line-item-status")||document.getElementById("CartDrawer-LineItemStatus");const debouncedOnChange=debounce(event2=>{this.onChange(event2)},ON_CHANGE_DEBOUNCE_TIMER);this.addEventListener("change",debouncedOnChange.bind(this))}cartUpdateUnsubscriber=void 0;connectedCallback(){this.cartUpdateUnsubscriber=subscribe(PUB_SUB_EVENTS.cartUpdate,event2=>{event2.source!=="cart-items"&&this.onCartUpdate()})}disconnectedCallback(){this.cartUpdateUnsubscriber&&this.cartUpdateUnsubscriber()}resetQuantityInput(id){const input=this.querySelector(`#Quantity-${id}`);input.value=input.getAttribute("value"),this.isEnterPressed=!1}setValidity(event2,index,message){event2.target.setCustomValidity(message),event2.target.reportValidity(),this.resetQuantityInput(index),event2.target.select()}validateQuantity(event2){const inputValue=parseInt(event2.target.value),index=event2.target.dataset.index;let message="";inputValue<event2.target.dataset.min?message=window.quickOrderListStrings.min_error.replace("[min]",event2.target.dataset.min):inputValue>parseInt(event2.target.max)?message=window.quickOrderListStrings.max_error.replace("[max]",event2.target.max):inputValue%parseInt(event2.target.step),message?this.setValidity(event2,index,message):(event2.target.setCustomValidity(""),event2.target.reportValidity(),this.updateQuantity(index,inputValue,document.activeElement.getAttribute("name"),event2.target.dataset.quantityVariantId))}onChange(event2){this.validateQuantity(event2)}onCartUpdate(){if(this.tagName==="CART-DRAWER-ITEMS"&&event&&event.detail&&event.detail.source==="CartDrawer.updateCartDrawer"){console.log("CartItems.onCartUpdate: Skipping redundant update for CART-DRAWER-ITEMS because CartDrawer.updateCartDrawer handled it.");return}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-bottom-buttons"];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"}]}async getCartData(forceRefresh=!1){const now=Date.now(),CACHE_TTL=2e3;if(window.initializingMultiStepCart&&window.cartDrawerOpenCartData)return console.log("Using cart data from drawer open during multi-step cart initialization"),window.cartDrawerOpenCartData;if(window.lastCartDrawerOpenTime&&now-window.lastCartDrawerOpenTime<1e3&&window.cartDrawerOpenCartData)return console.log("Using cart data from recent drawer open"),window.cartDrawerOpenCartData;if(!forceRefresh&&window.latestCartData&&window.latestCartTimestamp&&now-window.latestCartTimestamp<CACHE_TTL||window.cartDataFetchInProgress&&(console.log("Cart data fetch already in progress, waiting for it to complete"),await new Promise(resolve=>setTimeout(resolve,300)),window.latestCartData&&window.latestCartTimestamp&&Date.now()-window.latestCartTimestamp<CACHE_TTL||(window.cartDataFetchInProgress&&await new Promise(resolve=>setTimeout(resolve,500)),window.latestCartData)))return window.latestCartData;try{window.cartDataFetchInProgress=!0;const cartData=await(await fetch("/cart.js")).json();return window.latestCartData=cartData,window.latestCartTimestamp=now,window.cartDataFetchInProgress=!1,cartData}catch(error){return console.error("Error fetching cart data:",error),window.cartDataFetchInProgress=!1,window.latestCartData||{items:[],item_count:0}}}updateQuantity(line,quantity,name,variantId){if(typeof quantity!="number"||isNaN(quantity)){console.error("CartItems.updateQuantity: Invalid quantity detected. Aborting fetch.",{line,quantity,name,variantId}),this.disableLoading(line);return}this.enableLoading(line),window.isQuantityUpdate=!0;const body=JSON.stringify({line,quantity,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});
1fetch(`${routes.cart_change_url}`,{...fetchConfig(),body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state),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}window.latestCartData=parsedState,window.latestCartTimestamp=Date.now(),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),cartDrawerWrapper&&cartDrawerWrapper.classList.toggle("is-empty",parsedState.item_count===0),this.checkMaxCartItems(parsedState.item_count);const protectionPlanSection=document.getElementById("protection-plan-section"),protectionPlanVisible=protectionPlanSection?protectionPlanSection.style.display:"none",protectionPlanHTML=protectionPlanSection?protectionPlanSection.outerHTML:"",protectionCheckboxChecked=document.querySelector("[data-protection-plan]")?.checked||!1;window.lastProtectionCheckboxState=protectionCheckboxChecked;const targetProductId=8128434176195,noProtectionVariant=44321797931203,withProtectionVariant=44321797963971,hasTargetProduct=parsedState.items.some(item=>item.product_id===targetProductId||item.variant_id===noProtectionVariant||item.variant_id===withProtectionVariant);if(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)}),hasTargetProduct&&protectionPlanHTML){const cartDrawerFooter=document.querySelector(".cart-drawer-bottom-buttons");if(cartDrawerFooter){const newProtectionPlanSection=document.getElementById("protection-plan-section");if(!newProtectionPlanSection&&protectionPlanHTML){cartDrawerFooter.insertAdjacentHTML("beforebegin",protectionPlanHTML);const restoredSection=document.getElementById("protection-plan-section");if(restoredSection){restoredSection.style.display=hasTargetProduct?"block":protectionPlanVisible;const checkbox=restoredSection.querySelector("[data-protection-plan]");checkbox&&(checkbox.checked=protectionCheckboxChecked)}}else if(newProtectionPlanSection){newProtectionPlanSection.style.display="block";const checkbox=newProtectionPlanSection.querySelector("[data-protection-plan]");checkbox&&(checkbox.checked=protectionCheckboxChecked)}}}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"));const cartUpdateEvent=new CustomEvent("cart:updated",{detail:{source:"cart-items",cartData:parsedState,variantId,hasProtectionProduct:hasTargetProduct,isQuantityUpdate:!0,protectionPlanChecked:protectionCheckboxChecked}});document.dispatchEvent(cartUpdateEvent),publish(PUB_SUB_EVENTS.cartUpdate,{source:"cart-items",cartData:parsedState,variantId,hasProtectionProduct:hasTargetProduct,isQuantityUpdate:!0,protectionPlanChecked:protectionCheckboxChecked}),typeof window.checkForCollectorsEdition=="function"&&setTimeout(()=>{window.checkForCollectorsEdition(!0,protectionCheckboxChecked)},100)}).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),setTimeout(()=>{window.isQuantityUpdate=!1},500)})}updateLiveRegions(line,message){const lineItemError=document.getElementById(`Line-item-error-${line}`)||document.getElementById(`CartDrawer-LineItemError-${line}`);lineItemError&&(lineItemError.querySelector(".cart-item__error-text").textContent=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"))}checkMaxCartItems(itemCount){const atMaxItems=itemCount>=10;document.querySelectorAll(".quantity__button[name='plus']").forEach(button=>{atMaxItems?(button.setAttribute("disabled","disabled"),button.classList.add("disabled")):(button.removeAttribute("disabled"),button.classList.remove("disabled"))}),window.cartAtMaxItems=atMaxItems}}customElements.define("cart-items",CartItems),customElements.get("cart-note")||customElements.define("cart-note",class extends HTMLElement{constructor(){super(),this.addEventListener("input",debounce(event2=>{const body=JSON.stringify({note:event2.target.value});fetch(`${routes.cart_update_url}`,{...fetchConfig(),body})},ON_CHANGE_DEBOUNCE_TIMER))}});
2//# sourceMappingURL=/cdn/shop/t/4/assets/cart.js.map?v=68448484942835920921747448274

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.