import"@theme/utilities";class ProductCardLink extends HTMLElement{connectedCallback(){this.addEventListener("click",event=>setTimeout(()=>this.#handleClick(event),0))}disconnectedCallback(){this.removeEventListener("click",this.#handleClick)}get productTransitionEnabled(){return this.getAttribute("data-product-transition")==="true"}get featuredMediaUrl(){return this.getAttribute("data-featured-media-url")}#handleClick=event=>{if(event.defaultPrevented||event.target instanceof HTMLInputElement)return;const gallery=this.querySelector("[data-view-transition-to-main-product]");if(!this.productTransitionEnabled||!(gallery instanceof HTMLElement))return;const activeImage=gallery.querySelector('slideshow-slide[aria-hidden="false"] [transitionToProduct="true"]')||gallery.querySelector('[transitionToProduct="true"]:last-child');activeImage instanceof HTMLImageElement&&this.#setImageSrcset(activeImage),gallery.setAttribute("data-view-transition-type","product-image-transition"),gallery.setAttribute("data-view-transition-triggered","true")};#setImageSrcset(image){if(this.featuredMediaUrl&&!image.srcset.includes(this.featuredMediaUrl)){const imageFade=image.animate([{opacity:.8},{opacity:1}],{duration:125,easing:"ease-in-out"});imageFade.onfinish=()=>{image.srcset=this.featuredMediaUrl??""}}}}customElements.get("product-card-link")||customElements.define("product-card-link",ProductCardLink);
//# sourceMappingURL=/s/files/1/0677/1399/0759/t/1/assets/product-card-link.js.map?v=1783128595
