const generateSrcset=(image,widths=[])=>{const imageUrl=new URL(image.src);return widths.filter(width=>width<=image.width).map(width=>(imageUrl.searchParams.set("width",width.toString()),`${imageUrl.href} ${width}w`)).join(", ")},createImageElement=(image,classes,sizes,productTitle)=>{const previewImage=image.preview_image,newImage=new Image(previewImage.width,previewImage.height);return newImage.className=classes,newImage.alt=image.alt||productTitle,newImage.sizes=sizes,newImage.src=previewImage.src,newImage.srcset=generateSrcset(previewImage,[165,360,533,720,940,1066]),newImage.loading="lazy",newImage},checkSwatches=()=>{document.querySelectorAll(".js-color-swatches-wrapper").forEach(wrapper=>{wrapper.querySelectorAll(".js-color-swatches input").forEach(input=>{input.addEventListener("click",event=>{const primaryImage=wrapper.querySelector(".media--first"),secondaryImage=wrapper.querySelector(".media--second"),handleProduct=wrapper.dataset.product;if(event.currentTarget.checked&&primaryImage){wrapper.querySelector(".js-color-swatches-link").setAttribute("href",event.currentTarget.dataset.variantLink);const currentColor=event.currentTarget.value;jQuery.getJSON(window.Shopify.routes.root+`products/${handleProduct}.js`,function(product){const variant=product.variants.filter(item=>item.featured_media!=null&&item.options.includes(currentColor))[0];if(variant){const newPrimaryImage=createImageElement(variant.featured_media,primaryImage.className,primaryImage.sizes,product.title);if(newPrimaryImage.src!==primaryImage.src){let flag=!1;if(secondaryImage){const secondaryImagePathname=new URL(secondaryImage.src).pathname,newPrimaryImagePathname=new URL(newPrimaryImage.src).pathname;secondaryImagePathname==newPrimaryImagePathname&&(primaryImage.remove(),secondaryImage.classList.remove("media--second"),secondaryImage.classList.add("media--first"),flag=!0)}flag==!1&&(primaryImage.animate({opacity:[1,0]},{duration:200,easing:"ease-in",fill:"forwards"}).finished,setTimeout(function(){primaryImage.replaceWith(newPrimaryImage),newPrimaryImage.animate({opacity:[0,1]},{duration:200,easing:"ease-in"}),secondaryImage&&secondaryImage.remove()},200))}}})}})})})};function colorSwatches(){checkSwatches(),document.addEventListener("shopify:section:load",function(){checkSwatches()})}(function(){colorSwatches()})(); //# sourceMappingURL=/cdn/shop/t/5/assets/product-card.js.map?v=24727378675940765051707847414