if(!customElements.get("recently-viewed-products")){class RecentlyViewed extends customElements.get("card-product-slider"){constructor(){super(),this.section=this.closest(".js-section"),this.sliderWrapper=this.querySelector(".swiper-wrapper"),this.productHandle=this.dataset.productHandle,this.fetchRecentProducts()}fetchRecentProducts(){const productHandles=localStorage.getItem("recently-viewed");if(!productHandles)return;const productHandlesArray=productHandles.split(",").filter(productHandle=>productHandle!==this.productHandle);productHandlesArray.length!==0&&productHandlesArray.forEach((productHandle,i)=>{(async()=>{try{const productCardResponse=await fetch(`${window.Shopify.routes.root}products/${productHandle}?view=card`);if(!productCardResponse.ok){const updatedProductHandles=localStorage.getItem("recently-viewed").replace(`${productHandle},`,"").replace(productHandle,"");localStorage.setItem("recently-viewed",updatedProductHandles);return}const productCardHTML=await productCardResponse.text(),productSlide=document.createElement("DIV");if(productSlide.classList.add("swiper-slide","card-product-slider__slide"),productSlide.insertAdjacentHTML("beforeend",productCardHTML),!productSlide.querySelector("card-product")||!productSlide.querySelector(".card-product"))return;this.sliderWrapper.append(productSlide)}catch{}finally{if(!(i===productHandlesArray.length-1))return;this.initSlider(),this.section.classList.remove("hidden")}})()})}}customElements.define("recently-viewed-products",RecentlyViewed)}
//# sourceMappingURL=/cdn/shop/t/12/assets/recently-viewed-products.js.map?v=149017490890723888951684249907
