1class TdProductCard{constructor(card){this.card=card,this.container=card.querySelector(".td-product-card__image--secondary[data-video-src]"),this.video=this.container?.querySelector("video"),this.videoLoaded=!1,this.videoEventHandlers=[],!(!this.video||!this.container)&&this.setupEventListeners()}setupEventListeners(){this.card.addEventListener("mouseenter",()=>this.loadVideo()),this.card.addEventListener("mouseleave",()=>this.pauseVideo()),this.card.addEventListener("touchstart",()=>this.loadVideo(),{passive:!0}),this.card.addEventListener("touchend",()=>this.pauseVideo(),{passive:!0}),this.card.addEventListener("touchcancel",()=>this.pauseVideo(),{passive:!0})}pauseVideo(){this.video&&(this.video.pause(),this.video.currentTime=0,this.videoEventHandlers.forEach(({type,handler})=>{this.video.removeEventListener(type,handler)}),this.videoEventHandlers=[]),this.container&&this.container.classList.remove("td-product-card__image--secondary--loading")}loadVideo(){if(!this.video||!this.container)return;this.videoEventHandlers.forEach(({type,handler})=>{this.video.removeEventListener(type,handler)}),this.videoEventHandlers=[];const videoSrc=this.container.dataset.videoSrc;if(!videoSrc)return;this.container.classList.add("td-product-card__image--secondary--loading");const source=this.video.querySelector("source");if(!source)return;const currentSrc=source.getAttribute("src");(!currentSrc||currentSrc!==videoSrc)&&(source.setAttribute("src",videoSrc),this.videoLoaded=!1);const playVideo=async()=>{if(this.video)try{await this.video.play(),this.video.classList.add("td-product-card__video--loaded"),this.video.removeAttribute("poster")}catch(error){console.warn("Video play failed:",error)}};if(this.videoLoaded&&this.video.readyState>=3)playVideo();else if(this.videoLoaded){const handleCanPlay=()=>playVideo();this.video.addEventListener("canplay",handleCanPlay,{once:!0}),this.videoEventHandlers.push({type:"canplay",handler:handleCanPlay});const handleError=()=>{this.videoLoaded=!1,this.video&&this.video.classList.remove("td-product-card__video--loaded"),this.container&&this.container.classList.remove("td-product-card__image--secondary--loading")};this.video.addEventListener("error",handleError,{once:!0}),this.videoEventHandlers.push({type:"error",handler:handleError})}else{this.videoLoaded=!0,this.video.load();const handleCanPlay=()=>playVideo();this.video.readyState>=3?handleCanPlay():(this.video.addEventListener("canplay",handleCanPlay,{once:!0}),this.videoEventHandlers.push({type:"canplay",handler:handleCanPlay}));const handleError=()=>{this.videoLoaded=!1,this.video&&this.video.classList.remove("td-product-card__video--loaded"),this.container&&this.container.classList.remove("td-product-card__image--secondary--loading")};this.video.addEventListener("error",handleError,{once:!0}),this.videoEventHandlers.push({type:"error",handler:handleError})}}}if(!customElements.get("td-product-card-controller")){let initializeController2=function(){if(!document.querySelector("td-product-card-controller")){const controller=document.createElement("td-product-card-controller");document.body.appendChild(controller)}};var initializeController=initializeController2;class TdProductCardController extends HTMLElement{connectedCallback(){this.initializeCards(),this.setupObserver()}disconnectedCallback(){this.observer&&this.observer.disconnect()}initializeCards(){document.querySelectorAll(".td-product-card:not([data-video-initialized])").forEach(card=>{card.querySelector(".td-product-card__image--secondary[data-video-src] video")&&(card.setAttribute("data-video-initialized",""),new TdProductCard(card))})}setupObserver(){this.observer=new MutationObserver(()=>{this.initializeCards()}),this.observer.observe(document.body,{childList:!0,subtree:!0})}}customElements.define("td-product-card-controller",TdProductCardController),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",initializeController2):initializeController2()} 2//# sourceMappingURL=/cdn/shop/t/208/assets/component-td-product-card.js.map?v=110384742813642288881788469941
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.