class LiquidCarouselDotsBehavior extends LiquidBehavior{static behaviorName="liquidCarouselDots";static viewEvents={"carousel:activate":"onCarouselActivate","carousel:select":"updateSelectedDots","carousel:itemChange":"updateDots","carousel:resize":"updateDots"};dotClassname="lqd-carousel-dot inline-block flex-shrink-0 flex-grow-0 basis-auto overflow-hidden -indent-full";activeClassname=["lqd-is-active","lqd-carousel-dot-active"];dotTextContent="View slide";dots=[];get ui(){return{dotsHolder:".lqd-carousel-dots",dots:".lqd-carousel-dot"}}get bindToThis(){return["onDotsClick"]}onCarouselActivate(){this.dotTemplate=this.getUI("dots")[0],this.dots=[],this.activateDots()}setDots(){let t=this.view.carouselSlides.length-this.dots.length;t>0?this.addDots(t):t<0&&this.removeDots(-t)}addDots(t){const e=this.getUI("dotsHolder")[0];let i=new Array(t).fill().map((l,o)=>{let s;return this.dotTemplate?(s=this.dotTemplate.cloneNode(!0),s?.classList?.remove(...this.activeClassname,"hidden")):(s=document.createElement("button"),s.setAttribute("type","button"),s.className=this.dotClassname),s.textContent=`${this.dotTextContent} ${o+1+this.dots.length}`,s});e.append(...i),this.dots=this.dots.concat(i),e.classList.remove("lqd-carousel-dots-empty")}removeDots(t){this.dots.splice(this.dots.length-t,t).forEach(i=>i.remove())}updateSelectedDot(t){this.selectedDot&&(this.selectedDot.classList.remove(...this.activeClassname),this.selectedDot.removeAttribute("aria-current")),this.dots.length&&(this.selectedDot=this.dots[t]||this.dots[0],this.selectedDot.classList.add(...this.activeClassname),this.selectedDot.setAttribute("aria-current","step"))}activateDots(){this.setDots(),this.view.focusableElems.push(...this.dots),this.getUI("dotsHolder")[0].addEventListener("click",this.onDotsClick)}onDotsClick(t){let e=this.dots.indexOf(t.target);e!==-1&&(this.view.trigger("carousel:uiChange"),this.view.trigger("carousel:select",e))}updateSelectedDots(){this.updateSelectedDot(this.view.selectedIndex)}updateDots(){this.dots.forEach(t=>{this.view.focusableElems=this.view.focusableElems.filter(e=>e!==t)}),this.setDots(),this.view.focusableElems.push(...this.dots)}destroy(){this.removeDots(this.dots.length),this.getUI("dotsHolder")[0].removeEventListener("click",this.onDotsClick),super.destroy()}}typeof window<"u"&&(window.liquid?.app?window.liquid?.app?.model?.set("loadedBehaviors",[...window.liquid.app.model.get("loadedBehaviors"),LiquidCarouselDotsBehavior]):window.liquid?.loadedBehaviors?.push(LiquidCarouselDotsBehavior));
