1import{Component}from"@theme/component";class CartUpsellComponent extends Component{connectedCallback(){super.connectedCallback(),this.initCarousel(),this.initAddToCart()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this.#handleClick)}initCarousel(){const track=this.querySelector("#cart-upsell-track"),prevBtn=this.querySelector(".cart-upsell__arrow--prev"),nextBtn=this.querySelector(".cart-upsell__arrow--next"),slides=this.querySelectorAll(".cart-upsell__slide");if(!track||!prevBtn||!nextBtn||slides.length===0)return;const getSlideWidth=()=>{const slide=slides[0],style=getComputedStyle(track),gap=parseInt(style.gap)||16;return slide.offsetWidth+gap},scroll=direction=>{const slideWidth=getSlideWidth(),scrollAmount=direction==="next"?slideWidth:-slideWidth;track.scrollBy({left:scrollAmount,behavior:"smooth"})};prevBtn.addEventListener("click",()=>scroll("prev")),nextBtn.addEventListener("click",()=>scroll("next"))}initAddToCart(){this.addEventListener("click",this.#handleClick)}#handleClick=async e=>{const btn=e.target.closest(".cart-upsell__card-atc");if(!btn||btn.disabled)return;const variantId=btn.dataset.variantId;if(variantId){e.preventDefault(),btn.classList.add("loading"),btn.disabled=!0;try{if(!(await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:parseInt(variantId),quantity:1})})).ok)throw new Error("Failed to add to cart");const fullCart=await(await fetch("/cart.js")).json();document.dispatchEvent(new CustomEvent("cart:add",{bubbles:!0})),document.dispatchEvent(new CustomEvent("cart:update",{bubbles:!0,detail:{resource:fullCart,sourceId:"cart-upsell",data:{itemCount:fullCart.item_count,source:"cart-upsell",variantId:parseInt(variantId)}}}))}catch(error){console.error("Error adding to cart:",error)}finally{btn.classList.remove("loading"),btn.disabled=!1}}}}customElements.get("cart-upsell-component")||customElements.define("cart-upsell-component",CartUpsellComponent); 2//# sourceMappingURL=/cdn/shop/t/7/assets/gobeautex-cart-upsell.js.map?v=59808753679994031481778157356
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.