1document.addEventListener("DOMContentLoaded",()=>{if(window.innerWidth>=768)return;const drawer=document.getElementById("offerDrawer");if(!drawer)return;const addToCartBtn=document.querySelector('[id^="ProductSubmitButton-"]'),closeDrawer=drawer.querySelector(".drawer-close"),overlay=drawer.querySelector(".drawer-overlay"),drawerAddBtn=document.getElementById("drawerAddToCart"),offerCheckboxes=drawer.querySelectorAll(".select-offer"),offerText=document.querySelector(".offer-text"),copyIcon=document.querySelector(".offer-text-wrap .copy"),offerTextwrap=document.querySelector(".offer-text-wrap");drawer.querySelectorAll(".upsell-prd").forEach(prd=>{prd.addEventListener("click",e=>{if(e.target.matches(".select-offer"))return;const checkbox=prd.querySelector(".select-offer");checkbox&&(checkbox.checked=!checkbox.checked,checkbox.dispatchEvent(new Event("change",{bubbles:!0})))})});function updateOfferText(){const selected=[...offerCheckboxes].filter(cb=>cb.checked).length;let coupon="",offer="";switch(selected){case 1:coupon=window.offerData?.coupan_code_1||"",offer=window.offerData?.offer_text_1||"";break;case 2:coupon=window.offerData?.coupan_code_2||"",offer=window.offerData?.offer_text_2||"";break;case 3:coupon=window.offerData?.coupan_code_3||"",offer=window.offerData?.offer_text_3||"";break;default:offerText.textContent="",offerText.classList.remove("active"),copyIcon.style.display="none",offerTextwrap.style.display="none",drawerAddBtn.textContent="GO TO CART";return}offerText.textContent=offer,offerText.classList.add("active"),offerTextwrap.style.display="flex",drawerAddBtn.textContent="ADD TO CART",coupon&&coupon.trim()!==""?(copyIcon.setAttribute("data-coupans",coupon),copyIcon.style.display="inline-flex"):copyIcon.style.display="none";const selectedNames=[...offerCheckboxes].filter(cb=>cb.checked).map(cb=>cb.closest(".drawer-product")?.querySelector(".details p")?.textContent?.trim()||"").filter(Boolean).join(", ");closeDrawer.setAttribute("data-upsellproducts",selectedNames||""),drawerAddBtn.setAttribute("data-upsellproducts",selectedNames||"")}offerCheckboxes.forEach(cb=>cb.addEventListener("change",updateOfferText)),copyIcon.addEventListener("click",()=>{const coupon=copyIcon.getAttribute("data-coupans");coupon&&navigator.clipboard.writeText(coupon).then(()=>{const originalHTML=copyIcon.innerHTML;copyIcon.innerHTML="Copied!",setTimeout(()=>{copyIcon.innerHTML=originalHTML},1e3)}).catch(err=>console.error("Clipboard copy failed:",err))}),drawerAddBtn.addEventListener("click",()=>{const selectedIds=[...offerCheckboxes].filter(cb=>cb.checked).map(cb=>cb.closest(".drawer-product").dataset.productId),cart=document.querySelector("cart-drawer")||document.querySelector("cart-notification");if(!cart)return;if(selectedIds.length===0){drawer.classList.remove("active"),cart.classList.add("active");return}const items=selectedIds.map(id=>({id,quantity:1}));fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({items,sections:cart.getSectionsToRender?.().map(s=>s.id),sections_url:window.location.pathname})}).then(res=>res.json()).then(data=>{drawer.classList.remove("active"),cart.renderContents?(cart.renderContents(data),cart.classList.remove("is-empty"),cart.classList.add("active")):window.location.href="/cart"}).catch(err=>console.error("Error adding upsell:",err))}),closeDrawer.addEventListener("click",()=>drawer.classList.remove("active")),overlay.addEventListener("click",()=>drawer.classList.remove("active"))}); 2//# sourceMappingURL=/cdn/shop/t/2242/assets/atc-upsell-drawer.js.map?v=19472185433010485171762170430
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.