1class CartItems extends HTMLElement{constructor(){super(),this.cartCountDown=document.getElementById(`CartCountdown-${this.dataset.section}`),this.giftCardElement=document.getElementById("is-a-gift"),this.giftCardButton=document.getElementById("cart-gift-wrapping"),this.removeButtons=document.querySelectorAll("[data-cart-remove]"),this.toCheckoutButton=document.getElementById("cart-checkout"),this.couponCodeInput=document.getElementById("cart-coupon-code"),this.cartNoteInput=document.getElementById("cart-note"),this.checkTerms=document.getElementById("cart_conditions"),this.toCheckoutButton?.addEventListener("click",this.handleToCheckoutPage.bind(this)),this.initToCheckoutButtonDisabling(),this.initCartCountdown(),this.giftCardElement&&this.initGiftCardElement(),this.initGiftCardManipulation()}initGiftCardElement(){let t=this.giftCardButton?.dataset.isChecked;if("true"===t){let e=this.giftCardButton?.dataset.giftId,i=document.querySelector(`[data-cart-remove-id="${e}"]`),n=document.querySelector(`[data-cart-quantity-id="${e}"]`);this.giftCardElement.style.display="none",i?.addEventListener("click",()=>{this.giftCardButton.dataset.isChecked="false"}),n?.addEventListener("change",t=>{let e=Number(t.target.value);e<=0&&(this.giftCardButton.dataset.isChecked="false")})}else this.giftCardElement.style.display="flex"}initGiftCardManipulation(){this.giftCardButton&&(this.giftCardButton.removeEventListener("click",this.onAddGiftCardClick.bind(this)),this.giftCardButton.addEventListener("click",this.onAddGiftCardClick.bind(this)))}onAddGiftCardClick(t){t.preventDefault(),t.stopPropagation(),this.giftCardButton.dataset.isChecked="true"}initToCheckoutButtonDisabling(){this.checkTerms&&window.addEventListener("load",()=>{this.toCheckoutButton.disabled=!this.checkTerms.checked})}async handleToCheckoutPage(t){t.preventDefault();try{let e=this.couponCodeInput?.value;if(e){localStorage.setItem("storedDiscount",e);let i=await fetch(`/discount/${e}`);await i.text()}let n=this.cartNoteInput?.value;if(n){let a=JSON.stringify({note:n}),o=await fetch(`${routes.cart_update_url}`,{...fetchConfig(),body:a});await o.text()}}catch(s){console.error(`Error: ${s.message}`)}let r=this.toCheckoutButton.dataset.href;null==r&&(r=`${window.routes?.root?window.routes.root:""}/checkout`),window.location=r}initCartCountdown(){if(this.cartCountDown&&!this.cartCountDown.classList.contains("is-running")){let t=60*this.cartCountDown.getAttribute("data-cart-countdown"),e=this.cartCountDown.querySelector(".time");this.cartCountDown.classList.add("is-running"),this.startTimerCartCountdown(t,e)}}startTimerCartCountdown(t,e){var i,n,a,o=t,s=setInterval(()=>
1{i=parseInt(o/60,10),n=parseInt(o%60,10),i=i<10?"0"+i:i,n=n<10?"0"+n:n,a=i+":"+n,e.innerText=a,--o<0&&(clearInterval(s),this.cartCountDown.remove())},1e3)}}customElements.define("cart-items",CartItems);
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.