1if(!customElements.get("color-swatches")){class colorSwatches extends HTMLElement{constructor(){super(),this.list=this.querySelector("ul"),this.url=this.dataset.url,this.id=this.dataset.id,this.collection=this.dataset.collection,this.more=this.nextElementSibling,this.copmareprice=this.closest(".product-item__info").querySelector(".product_compare_price"),this.onlyOneVariant=this.closest(".product-item__info").querySelector(".product-item__swatches"),this.fetchColorSwatches()}fetchColorSwatches(){fetch(this.url).then(response=>response.text()).then(data=>{const htmlDocument=new DOMParser().parseFromString(data,"text/html"),swatches=htmlDocument.querySelectorAll("li"),images=htmlDocument.querySelectorAll("img");let activeId="";swatches.length&&(this.list.innerHTML="",window.matchMedia("(max-width: 749px)").matches&&this.copmareprice&&swatches.length>2&&this.more&&this.more.classList.remove("hidden"),swatches.length==1&&this.onlyOneVariant.classList.add("hidden"),swatches.length>4&&this.more&&this.more.classList.remove("hidden"),swatches.forEach((swatch,index)=>{const swatchInput=swatch.querySelector("input"),swatchLabel=swatch.querySelector("label"),swatchInputId=`group-${this.id}-${this.collection}-${index}`,swatchDataId=`${swatchInput.dataset.id}-${this.collection}`;swatchInput.name=this.id,swatchLabel.setAttribute("for",swatchInputId),swatchInput.id=swatchLabel.getAttribute("for"),swatchDataId===this.id&&(swatchInput.checked=!0,activeId=swatchInput.dataset.image,swatch.classList.add("current-active")),this.list.appendChild(swatch),swatchInput.addEventListener("change",this.handleColorSwatchChange)}),this.moveCurrentSelectedAhead(),images.forEach(image=>{this.images.appendChild(image),activeId===image.dataset.id&&image.classList.add("active")}))}).catch(error=>console.error("Error fetching product swatches:",error))}handleColorSwatchChange(event){if(!event.target.getAttribute("data-url"))return;const productItem=event.target.closest(".product-item"),productMedia=productItem.querySelector(".product-item__media"),productItemUrl=event.target.getAttribute("data-url").toString().split("/products")[1],updateProductUrl=productItem.querySelector(".product-item__title a"),productImagesUrl=productMedia.querySelectorAll(".product-item__media a.product-item__media-link"),finalUrl=productItem.querySelector(".product-item__swatches").getAttribute("data-url").toString().split("/products")[0]+"/products"+productItemUrl;productItem.querySelector(".product-item__plus").setAttribute("href",finalUrl),updateProductUrl.setAttribute("href",finalUrl),productImagesUrl.forEach(function(productImageUrl){productImageUrl.setAttribute("href",finalUrl)});let imageIndex=0;fetch(finalUrl+".js").then(response=>response.json()).then(product=>{for(const image of product.images){const productMediaSwiper=productMedia.querySelectorAll(`.swiper-slide[data-swiper-slide-index="${imageIndex}"]`);for(const swiperImage of productMediaSwiper)swiperImage.querySelectorAll(".product-item__images img").forEach(function(multiImage){multiImage.classList.contains("mobile-image")?(multiImage.setAttribute("src",image+"&width=250"),multiImage.setAttribute("srcset",image+"&width=250")):(multiImage.setAttribute("src",image+"&width=400"),multiImage.setAttribute("srcset",image+"&width=400"))});if(imageIndex++,imageIndex>2)break}})}moveCurrentSelectedAhead(){document.querySelectorAll("ul.color-swatches li.current-active").forEach(swatch=>{if(swatch.classList.contains("current-active")){const swatchInput=swatch.querySelector("input"),activeSwatch=swatch,parentNodeHere=swatch.parentNode;parentNodeHere.removeChild(swatch),parentNodeHere.insertBefore(activeSwatch,parentNodeHere.childNodes[0]),swatchInput.addEventListener("change",this.handleColorSwatchChange)}})}}customElements.define("color-swatches",colorSwatches)} 2//# sourceMappingURL=/cdn/shop/t/1106/assets/color-swatches.js.map?v=5392804746859542611790351820
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.