import{Segment}from"@dna/analytics";import{getSectionPosition}from"@dna/utils";if(!customElements.get("dna-editorial-product-carousel")){class DNAEditorialProductCarousel extends HTMLElement{constructor(){super(),this.epcDirection=!1,this.epcPosition=1,this.experimentationTrackingKey=this.getAttribute("experimentation-tracking-key"),this.trackingKey=this.getAttribute("tracking-key")}connectedCallback(){if(this.$section=this.closest(".shopify-section"),this.sectionPosition=getSectionPosition(this.$section),this.$epcBanner=this.querySelector(".js-epc-banner"),this.$epcSectionTitle=this.querySelector(".js-epc-headline"),this.$epcItemCarousel=this.querySelector(".js-epc-content sl-carousel"),this.$epcNavButtons=this.querySelectorAll(".js-epc-nav-button"),this.$epcCta=this.querySelector(".js-epc-cta"),this.$epcProducts=this.querySelectorAll(".js-epc-product"),this.experimentationTrackingKey?.length&&this.$section.setAttribute("data-experiment-selector",this.experimentationTrackingKey),customElements.whenDefined("sl-carousel").then(()=>{this.$epcItemCarousel?.goToSlide(0),this.$empcCarousel?.addEventListener("sl-slide-change",event=>{this.handleSlideChange(event,this.epcDirection)})}),this.$epcNavButtons.length){for(const button of this.$epcNavButtons)button.addEventListener("click",event=>{this.handleSlideChangeClick(event)});this.$epcItemCarousel.addEventListener("sl-slide-change",event=>{this.handleSlideChange(event,this.epcDirection)})}if(this.$epcCta?.addEventListener("click",event=>{this.trackEPCLinkClick(event)}),this.$epcProducts.length)for(const product of this.$epcProducts)product.addEventListener("click",event=>{this.trackEPCProductClick(event)});window.innerWidth>768&&this.$epcBanner.hasAttribute("data-animation")&&this.$epcBanner.setAttribute("data-animation","wipeInDown")}handleSlideChangeClick(clickEvent){clickEvent.target.closest("button")?.classList.contains("js-arrow-next")?(this.epcDirection="next",this.$epcItemCarousel.next()):(this.epcDirection="previous",this.$epcItemCarousel.previous())}handleSlideChange(slideEvent,slideDirection){this.epcPosition=slideEvent.detail.index+1;const $epcBannerImages=this.$epcBanner?.querySelectorAll(".epc-banner__image-container");if($epcBannerImages.length)for(const image of $epcBannerImages)Number(image.getAttribute("data-slide"))===slideEvent.detail.index?image.classList.add("active"):image.classList.remove("active");this.trackEPCScroll()}trackEPCScroll(){Segment.protect(()=>{Segment.track(Segment.CONSTANTS.EVENTS.EPC_SCROLLED,{epc_section_title:this.$epcSectionTitle?.textContent?.trim(),epc_scroll_direction:this.epcDirection,epc_product_position:this.epcPosition,section_page_position:this.sectionPosition,section_tracking_key:this.trackingKey})})}trackEPCLinkClick(event){Segment.protect(()=>{const $clickedLink=event.target.closest(".epc-item__cta");Segment.track(Segment.CONSTANTS.EVENTS.EPC_LINK_CLICKED,{epc_section_title:this.$epcSectionTitle?.textContent?.trim(),epc_cta_text:$clickedLink?.textContent.trim(),epc_cta_link:$clickedLink?.getAttribute("href"),epc_product_position:this.epcPosition,section_page_position:this.sectionPosition,section_tracking_key:this.trackingKey})})}trackEPCProductClick(event){Segment.protect(()=>{const $clickedItem=event.target.closest(".js-epc-product-link");Segment.track(Segment.CONSTANTS.EVENTS.EPC_PRODUCT_CLICKED,{epc_section_title:this.$epcSectionTitle?.textContent?.trim(),epc_clicked_product:$clickedItem?.getAttribute("data-product"),epc_product_position:this.epcPosition,section_page_position:this.sectionPosition,section_tracking_key:this.trackingKey})})}}customElements.define("dna-editorial-product-carousel",DNAEditorialProductCarousel)} //# sourceMappingURL=/cdn/shop/t/1170/assets/component-editorial-product-carousel.js.map?v=92822633391396202271761851316