1class CartDrawer extends HTMLElement{constructor(){super(),this.addEventListener("keyup",evt=>evt.code==="Escape"&&this.close()),this.querySelector("#CartDrawer-Overlay").addEventListener("click",this.close.bind(this)),this.setHeaderCartIconAccessibility()}setHeaderCartIconAccessibility(){const cartLink=document.querySelector("#cart-icon-bubble");cartLink.setAttribute("role","button"),cartLink.setAttribute("aria-haspopup","dialog"),cartLink.addEventListener("click",event=>{event.preventDefault(),this.open(cartLink)}),cartLink.addEventListener("keydown",event=>{event.code.toUpperCase()==="SPACE"&&(event.preventDefault(),this.open(cartLink))})}open(triggeredBy){triggeredBy&&this.setActiveElement(triggeredBy);const cartDrawerNote=this.querySelector('[id^="Details-"] summary');cartDrawerNote&&!cartDrawerNote.hasAttribute("role")&&this.setSummaryAccessibility(cartDrawerNote),setTimeout(()=>{this.classList.add("animate","active")}),this.addEventListener("transitionend",()=>{const containerToTrapFocusOn=this.classList.contains("is-empty")?this.querySelector(".drawer__inner-empty"):document.getElementById("CartDrawer"),focusElement=this.querySelector(".drawer__inner")||this.querySelector(".drawer__close");trapFocus(containerToTrapFocusOn,focusElement)},{once:!0}),document.body.classList.add("overflow-hidden")}close(){this.classList.remove("active"),removeTrapFocus(this.activeElement),document.body.classList.remove("overflow-hidden")}setSummaryAccessibility(cartDrawerNote){cartDrawerNote.setAttribute("role","button"),cartDrawerNote.setAttribute("aria-expanded","false"),cartDrawerNote.nextElementSibling.getAttribute("id")&&cartDrawerNote.setAttribute("aria-controls",cartDrawerNote.nextElementSibling.id),cartDrawerNote.addEventListener("click",event=>{event.currentTarget.setAttribute("aria-expanded",!event.currentTarget.closest("details").hasAttribute("open"))}),cartDrawerNote.parentElement.addEventListener("keyup",onKeyUpEscape)}renderContents(parsedState){this.querySelector(".drawer__inner").classList.contains("is-empty")&&this.querySelector(".drawer__inner").classList.remove("is-empty"),this.productId=parsedState.id,this.getSectionsToRender().forEach(section=>{const sectionElement=section.selector?document.querySelector(section.selector):document.getElementById(section.id);sectionElement.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.id],section.selector)}),checkCartForUpsell(),setTimeout(()=>{this.querySelector("#CartDrawer-Overlay").addEventListener("click",this.close.bind(this)),this.open()})}getSectionInnerHTML(html,selector=".shopify-section"){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}getSectionsToRender(){return[{id:"cart-drawer",selector:"#CartDrawer"},{id:"cart-icon-bubble"}]}getSectionDOM(html,selector=".shopify-section"){return new DOMParser().parseFromString(html,"text/html").querySelector(selector)}setActiveElement(element){this.activeElement=element}}customElements.define("cart-drawer",CartDrawer);class CartDrawerItems extends CartItems{getSectionsToRender(){return[{id:"CartDrawer",section:"cart-drawer",selector:".drawer__inner"},{id:"cart-icon-bubble",section:"cart-icon-bubble",selector:".shopify-section"}]}}customElements.define("cart-drawer-items",CartDrawerItems);function renderUpsellForm(product,isSubscription,cartSellingPlanName){const variants=product?.variants?.filter(v=>v.available)||[],firstAvailable=variants[0];if(!firstAvailable)return;const upsellContainer=document.getElementById("upsell-offer");if(!upsellContainer||!variants.length)return;const hasMultipleVariants=product.variants.length>1,planDataScript=document.getElementById("upsell-selling-plans-json");let upsellPlans=[];if(planDataScript)try{upsellPlans=JSON.parse(planDataScript.textContent)}catch{}let sellingPlanId=null;if(isSubscription&&cartSellingPlanName&&upsellPlans.length){const normalizedCartName=cartSellingPlanName.trim().toLowerCase();for(const plan of upsellPlans){const planName=plan.selling_plan_name?.trim().toLowerCase();if(planName===normalizedCartName||planName.includes(normalizedCartName)||normalizedCartName.includes(planName)||planName.includes("60 day")&&normalizedCartName.includes("60")||planName.includes("30 day")&&normalizedCartName.includes("30")){sellingPlanId=plan.selling_plan_id;break}}}const originalPrice=firstAvailable.price/100,discountedPrice=sellingPlanId?(originalPrice*.85).toFixed(2):originalPrice.toFixed(2),getVariantImage=variant=>variant.featured_media?.preview_image?.src||variant.featured_image?.src||product.featured_image?.src||product.images?.[0],variantOptionsHTML=hasMultipleVariants?` 2 <div class="upsell-select-wrapper"> 3 <select class="upsell-variant-id upsell-variant-selector"> 4 ${product.variants.map(v=>` 5 <option 6 value="${v.id}" 7 ${v.available?"":"disabled"} 8 ${v.id===firstAvailable.id?"selected":""} 9 data-price="${(v.price/100).toFixed(2)}" 10 data-image="${getVariantImage(v)}" 11 > 12 ${v.title}${v.available?"":" (Sold out)"} 13 </option>`).join("")} 14 </select> 15 </div> 16 `:` 17 <input type="hidden" class="upsell-variant-id" 18 value="${firstAvailable.id}" 19 data-price="${originalPrice.toFixed(2)}" /> 20 `;upsellContainer.innerHTML=` 21 <div class="upsell-box"> 22 <p class="upsell-message">PAIR WITH</p> 23 <div class="upsell-content"> 24 <div class="upsell-text"> 25 <h4 class="upsell-title">${product.title}</h4> 26 <div class="upsell-price-wrap">
27 <span class="upsell-price">$${discountedPrice}</span> 28 ${sellingPlanId?`<span class="upsell-compare-price line-through ml-2 opacity-70">$${originalPrice.toFixed(2)}</span>`:""} 29 </div> 30 ${variantOptionsHTML} 31 <button class="btn btn-primary upsell-add-btn">Add to Cart</button> 32 </div> 33 <img 34 src="${getVariantImage(firstAvailable)}" 35 alt="${product.title}" 36 class="upsell-image" 37 /> 38 </div> 39 </div> 40 `;const accordion=document.querySelector(".cart_products-accrodion");accordion&&(accordion.style.display="none");const select=upsellContainer.querySelector(".upsell-variant-selector"),img=upsellContainer.querySelector(".upsell-image");select&&select.addEventListener("change",e=>{const selectedOption=e.target.selectedOptions[0],newImg=selectedOption.getAttribute("data-image"),basePrice=parseFloat(selectedOption.getAttribute("data-price"));if(img&&newImg&&(img.src=newImg),!isNaN(basePrice)){const newDiscountedPrice=sellingPlanId?(basePrice*.85).toFixed(2):basePrice.toFixed(2),priceEl=upsellContainer.querySelector(".upsell-price"),compareEl=upsellContainer.querySelector(".upsell-compare-price");priceEl&&(priceEl.textContent=`$${newDiscountedPrice}`),compareEl&&(sellingPlanId?(compareEl.textContent=`$${basePrice.toFixed(2)}`,compareEl.style.display=""):(compareEl.textContent="",compareEl.style.display="none"))}}),upsellContainer.querySelector(".upsell-add-btn")?.addEventListener("click",()=>{const variantInput=upsellContainer.querySelector(".upsell-variant-id, .upsell-variant-selector"),variantId=parseInt(variantInput.value);fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:[{id:variantId,quantity:1,...sellingPlanId&&{selling_plan:sellingPlanId}}]})}).then(()=>{fetch(`${routes.cart_url}?section_id=cart-drawer`).then(res=>res.text()).then(htmlText=>{const html=new DOMParser().parseFromString(htmlText,"text/html");["cart-drawer-items",".cart-drawer__footer"].forEach(selector=>{const target=document.querySelector(selector),source=html.querySelector(selector);target&&source&&target.replaceWith(source)});const cartDrawer2=document.querySelector("cart-drawer");cartDrawer2&&(cartDrawer2.classList.add("is-open"),document.body.classList.add("overflow-hidden")),setTimeout(checkCartForUpsell,50)})})}),upsellContainer.style.display="block"}function checkCartForUpsell(){const upsellDataScript=document.getElementById("upsell-metafields-json");if(!upsellDataScript)return;const upsellHandle=JSON.parse(upsellDataScript.textContent||"{}").upsell_handle;upsellHandle&&fetch("/cart.js").then(res=>res.json()).then(cart=>{if(!cart.items.length)return;const firstItem=cart.items[0],isSubscription=!!firstItem.selling_plan_allocation?.selling_plan,cartSellingPlanName=firstItem.selling_plan_allocation?.selling_plan?.name?.trim()||null,existingVariantIds=cart.items.map(item=>item.variant_id);fetch(`/products/${upsellHandle}.js`).then(res=>res.json()).then(product=>{if(product.variants.some(variant=>existingVariantIds.includes(variant.id))){document.getElementById("upsell-offer").style.display="none";return}renderUpsellForm(product,isSubscription,cartSellingPlanName)})})}document.addEventListener("DOMContentLoaded",()=>{checkCartForUpsell(),subscribe(PUB_SUB_EVENTS.cartUpdate,event=>{["cart-items","product-form"].includes(event.source)&&setTimeout(checkCartForUpsell,50)})});const cartDrawer=document.querySelector("cart-drawer");cartDrawer&&cartDrawer.addEventListener("transitionend",()=>{checkCartForUpsell()},{once:!0}); 41//# sourceMappingURL=/cdn/shop/t/19/assets/cart-drawer.js.map?v=62185694800285124551762623882
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.