;(function(){"use strict";class iCarouselNavigation extends HTMLElement{static observedAttributes=["data-autoplay"];connectedCallback(){if(!this.isConnected)return;this.isRTL=document.documentElement.dir==="rtl";this.carousel=document.getElementById(this.getAttribute("data-carousel"));if(!this.carousel)return;this.addEventListener("click",this);this.carouselItems=[...this.carousel.children];this.carouselObserver=new IntersectionObserver((entries)=>{entries.forEach(entry=>{if(entry.target===this.carousel.firstElementChild){this.firstVisible=entry.isIntersecting;}
if(entry.target===this.carousel.lastElementChild){this.lastVisible=entry.isIntersecting;}
entry.target.toggleAttribute("data-carousel-visible",entry.isIntersecting);});requestAnimationFrame(()=>{this.hidden=this.firstVisible&&this.lastVisible;});},{root:this.carousel,threshold:.99});this.carouselItems.forEach(item=>this.carouselObserver.observe(item));this.insideAutoplayWidget=this.closest("[data-widget-interval]");if(this.insideAutoplayWidget){this.setAttribute("data-autoplay",Number(this.insideAutoplayWidget.getAttribute("data-widget-interval"))*1000);}}
disconnectedCallback(){this.stopAutoScroll();this.removeEventListener("click",this);if(this.carouselObserver){this.carouselObserver.disconnect();this.carouselObserver=null;}}
attributeChangedCallback(name,oldValue,newValue){if(!this.isConnected)return;if(name==="data-autoplay"&&newValue!=null){const delay=Number(newValue);if(Number.isNaN(delay)||delay<=0){this.autoplayDuration=null;console.error("[data-autoplay] should be a valid number");return;}
this.autoplayDuration=delay;this.startAutoScroll();}}
startAutoScroll(){this.stopAutoScroll();this.autoTimer=setInterval(()=>{this.scrollCarousel("next");},this.autoplayDuration||3000);}
stopAutoScroll(){if(this.autoTimer){clearInterval(this.autoTimer);this.autoTimer=null;}}
handleEvent(e){return this[`${e.type}Event`]&&this[`${e.type}Event`](e);}
clickEvent(e){const arrowButton=e.target.closest("[data-carousel-arrow]");if(!arrowButton)return;this.stopAutoScroll();const arrowDirection=arrowButton.getAttribute("data-carousel-arrow");this.scrollCarousel(arrowDirection);}
scrollCarousel(arrowDirection="next"){const visibleChildren=this.carousel.querySelectorAll('[data-carousel-visible]');if(!visibleChildren.length)return;const firstVisibleChild=visibleChildren[0];const lastVisibleChild=visibleChildren.length>0?visibleChildren[visibleChildren.length-1]:null;let scrollToItem;if(arrowDirection==="prev"){scrollToItem=firstVisibleChild.previousElementSibling||this.carousel.lastElementChild;}else{scrollToItem=(lastVisibleChild===this.carousel.lastElementChild)?this.carousel.firstElementChild:firstVisibleChild.nextElementSibling;}
const offsetRight=(this.carousel.clientWidth-(scrollToItem.offsetLeft+scrollToItem.offsetWidth))*-1;this.carousel.scrollTo({left:(this.isRTL)?offsetRight:scrollToItem.offsetLeft,behavior:"smooth"});}}
ips.ui.registerWebComponent("carouselNavigation",iCarouselNavigation);Debug.log(`Submitted the web component constructor, iCarouselNavigation, for ${"carouselNavigation"}`);})();;