if(typeof CSSSlider!="function"){class CSSSlider2 extends HTMLElement{constructor(){super(),this._touchScreen=document.body.classList.contains("touchevents"),this._rtl=document.documentElement.getAttribute("dir")=="rtl",this.o={selector:".css-slide",snapping:!0,groupCells:!1,forceOneSlidePerPage:!1,autoHeight:!1,navigation:!0,navigationDOM:`<span class="css-slider-button css-slider-prev" style="display:none">\u2190</span>
            <span class="css-slider-button css-slider-next" style="display:none">\u2192</span>`,thumbnails:!0,thumbnailsDOM:'<div class="css-slider-dot-navigation" style="display:none"></div>',thumbnailsNoInteraction:!1,indexNav:!1,indexNavDOM:'<div class="css-slider-index-navigation"><span class="css-slider-current">1</span> / <span class="css-slider-total">1</span></div>',watchCSS:!1,undisplay:!1,disableSwipe:!1,listenScroll:!1,observer:!0,disableMouseDownEvent:!0,disableTabNavigation:!1,autoplay:0,...JSON.parse(this.dataset.options)},this.o.watchCSS?(this.RESIZE_WATCHER=debounce(()=>{const afterContent=window.getComputedStyle(this,":after").content;afterContent.includes("css-slide")&&!this.sliderEnabled?this.initSlider():!afterContent.includes("css-slide")&&this.sliderEnabled&&this.destroySlider()},100),window.addEventListener("resize",this.RESIZE_WATCHER),this.RESIZE_WATCHER()):this.initSlider()}destroySlider(){this.innerHTML=`${this.originalHTML}`,this.classList.remove("enabled"),this.sliderEnabled=!1,window.removeEventListener("resize",this.RESIZE_EVENT),window.removeEventListener("scroll",this.SCROLL_EVENT),window.removeEventListener("scroll",this.SCROLL_EVENT_ANIMATION)}initSlider(){if(this._readyEvent=new CustomEvent("ready"),this._changeEvent=new CustomEvent("change"),this._scrollEvent=new CustomEvent("scroll"),this._navEvent=new CustomEvent("navigation"),this._resetEvent=new CustomEvent("reset"),this._pointerDownEvent=new CustomEvent("pointerDown"),this._pointerUpEvent=new CustomEvent("pointerUp"),this.classList.add("css-slider"),this.originalHTML=this.innerHTML,this.innerHTML=`<div class="css-slider-viewport">
        <div class="css-slider-holder" ${this.o.disableTabNavigation?'tabindex="-1"':""}>
          <div class="css-slider-container">
            ${this.originalHTML}
          </div>
        </div>
      </div>`,this.o.undisplay&&this.querySelectorAll(`${this.o.selector}`).forEach(elm=>{elm.style.display="block"}),this.o.selector!=".css-slide"&&this.querySelectorAll(`${this.o.selector}`).forEach(elm=>{elm.classList.add("css-slide")}),this.element=this.querySelector(".css-slider-holder"),this.o.groupCells&&(this.element.scrollLeft=0),this.items=this.querySelectorAll(`${this.o.selector}`),this.indexedItems=[],this.index=0,this.length=this.items.length,this.windowWidth=window.innerWidth,this.o.disableMouseDownEvent&&this.querySelector(".css-slider-container").addEventListener("mousedown",e=>{e.target.tagName!=="SELECT"&&e.preventDefault()}),this.viewport=this.querySelector(".css-slider-viewport"),this.o.autoHeight&&this.viewport.classList.add("auto-height"),this.o.navigation||this.o.thumbnails||this.indexNav){const navigationElements=new DOMParser().parseFromString(this.o.navigationDOM,"text/html");let container=document.createElement("div");if(container.classList.add("css-slider-navigation-container"),container.innerHTML=`
          ${this.o.navigation?navigationElements.querySelector(".css-slider-prev").outerHTML:""}
          ${this.o.thumbnails?this.o.thumbnailsDOM:""}
          ${this.o.navigation?navigationElements.querySelector(".css-slider-next").outerHTML:""}
          ${this.o.indexNav?this.o.indexNavDOM:""}`,this.o.navigation){this.prevEl=container.querySelector(".css-slider-prev"),this.prevEl.setAttribute("tabindex",0),this.prevEl.setAttribute("role","button"),this.prevEl.addEventListener("click",e=>{e.preventDefault(),this.changeSlide("prev"),this.dispatchEvent(this._navEvent)}),this.prevEl.addEventListener("keydown",e=>{e.keyCode==window.KEYCODES.RETURN&&this.prevEl.click()}),this.prevEl.querySelector("svg").setAttribute("aria-hidden","true");const prevElA11y=document.createElement("span");prevElA11y.textContent=window.KROWN.settings.locales.slider_prev_button_label,prevElA11y.classList.add("visually-hidden"),this.prevEl.appendChild(prevElA11y),this.nextEl=container.querySelector(".css-slider-next"),this.nextEl.setAttribute("tabindex",0),this.nextEl.setAttribute("role","button"),this.nextEl.addEventListener("click",e=>{e.preventDefault(),this.changeSlide("next"),this.dispatchEvent(this._navEvent)}),this.nextEl.addEventListener("keydown",e=>{e.keyCode==window.KEYCODES.RETURN&&this.nextEl.click()}),this.nextEl.querySelector("svg").setAttribute("aria-hidden","true");const nextElA11y=document.createElement("span");nextElA11y.textContent=window.KROWN.settings.locales.slider_next_button_label,nextElA11y.classList.add("visually-hidden"),this.nextEl.appendChild(nextElA11y)}this.o.thumbnails&&(this.thumbnailsEl=container.querySelector(".css-slider-dot-navigation")),this.o.indexNav&&(this.indexEl=container.querySelector(".css-slider-current"),this.lengthEl=container.querySelector(".css-slider-total")),this.append(container)}this.length>1&&(this.o.observer?this.OBSERVER=new IntersectionObserver(entries=>{this._sliderBlockScroll||entries.forEach(entry=>{entry.intersectionRatio>=.5&&(this.index=parseInt(entry.target.getAttribute("data-index")),this.checkSlide(),this.dispatchEvent(this._changeEvent))})},{threshold:[0,.5]}):(this.SCROLL_EVENT=debounce(()=>{if(!this._sliderBlockScroll){const scrollItems=this.indexedItems.entries(),scrollArray=Array.from(scrollItems,elm=>Math.abs(elm[1].offsetLeft-this.element.scrollLeft)),scrollDistance=Math.min(...scrollArray),scrollIndex=scrollArray.indexOf(scrollDistance);scrollIndex!=this.index&&(this.index=scrollIndex,this.checkSlide(),this.dispatchEvent(this._changeEvent))}},10),this.element.addEventListener("scroll",this.SCROLL_EVENT,{passive:!0})),this.RESIZE_EVENT=debounce(()=>{this.windowWidth!=window.innerWidth&&this.o.groupCells&&this.resetSlider(),this.o.groupCells||this.checkSlide(),this.windowWidth=window.innerWidth},100),window.addEventListener("resize",this.RESIZE_EVENT),this.resetSlider(!0),this.o.listenScroll&&(this.SCROLL_EVENT_ANIMATIONS=()=>{let slidesWidth=-this.querySelector(".css-slider-container").offsetWidth;this.items.forEach(elm=>{slidesWidth+=elm.offsetWidth}),this.progress=this.element.scrollLeft/slidesWidth,this.dispatchEvent(this._scrollEvent)},this.element.addEventListener("scroll",this.SCROLL_EVENT_ANIMATIONS,{passive:!0})),!this.o.disableSwipe&&!this._touchScreen&&!this.element.classList.contains("css-slider--singular")&&(this.element.addEventListener("mousedown",e=>{this.element.classList.contains("css-slider--disable-dragging")||(this.mouseX=e.screenX,this.element.classList.add("can-drag"),this.element.classList.add("mouse-down"))}),this.element.addEventListener("mouseup",e=>{this.element.classList.remove("mouse-down"),this.element.classList.remove("can-drag"),this.element.classList.remove("pointer-events-off"),this._pot&&clearTimeout(this._pot)}),this.element.addEventListener("mouseleave",e=>{this.element.classList.remove("mouse-down"),this.element.classList.remove("can-drag"),this.element.classList.remove("pointer-events-off"),this._pot&&clearTimeout(this._pot)}),this.element.addEventListener("mousemove",e=>{if(this.element.classList.contains("can-drag")){let directionX=this.mouseX-e.screenX;Math.abs(directionX)>1&&(this.element.classList.contains("css-slider--no-drag")||this.element.classList.add("pointer-events-off"),!this._rtl&&directionX>0||this._rtl&&directionX<0?(this.changeSlide("next"),this.element.classList.remove("can-drag")):(!this._rtl&&directionX<0||this._rtl&&directionX>0)&&(this.changeSlide("prev"),this.element.classList.remove("can-drag")))}})),!("scrollBehavior"in document.documentElement.style)&&!this._touchScreen&&this.element.classList.add("force-disable-snapping"),this._touchScreen||(this.element.ondragstart=e=>{e.preventDefault()})),this.classList.add("enabled"),this.sliderEnabled=!0,this.dispatchEvent(this._readyEvent),parseInt(this.o.autoplay)>0&&this._initAutoplay()}changeSlide(direction,behavior="smooth"){direction=="next"?this.index+1<this.length&&this.index++:direction=="prev"?this.index-1>=0&&this.index--:parseInt(direction)>=0&&(this.index=parseInt(direction)),this._sliderBlockScroll=!0,setTimeout(()=>{this._sliderBlockScroll=!1},500),this.checkSlide(),this.element.scrollTo({top:0,left:this._rtl&&this.slidesPerPage>1?(this.querySelector(".css-slider-container").offsetWidth-(this.indexedItems[this.index].offsetLeft-parseInt(getComputedStyle(this.indexedItems[0]).marginLeft)))*-1:this.indexedItems[this.index].offsetLeft-parseInt(getComputedStyle(this.indexedItems[0]).marginLeft),behavior}),this.dispatchEvent(this._changeEvent)}checkSlide(){if(this.o.navigation&&(this.prevEl.classList.remove("disabled"),this.nextEl.classList.remove("disabled"),this.index==0&&this.prevEl.classList.add("disabled"),this.index==this.length-1&&this.nextEl.classList.add("disabled")),this.o.thumbnails&&this.thumbnails&&(this.thumbnails.forEach(elm=>{elm.classList.remove("active")}),this.thumbnails[this.index].classList.add("active")),this.o.indexNav&&(this.indexEl.textContent=this.index+1),this.o.autoHeight&&(this.viewport.style.height=this.indexedItems[this.index].offsetHeight+"px"),this.indexedItems.forEach((elm,i)=>{i==this.index?elm.classList.add("css-slide-active"):elm.classList.remove("css-slide-active")}),!this.o.disableTabNavigation){const maxStart=Math.max(0,this.items.length-this.slidesPerPage),start=this.index*this.slidesPerPage,adjustedStart=Math.min(start,maxStart),end=adjustedStart+this.slidesPerPage;this.items.forEach(elm=>{elm.setAttribute("inert","")});for(let i=adjustedStart;i<end&&i<this.items.length;i++)this.items[i].removeAttribute("inert")}parseInt(this.o.autoplay)>0&&this._initAutoplay()}afterAppend(){this.items=this.querySelectorAll(`${this.o.selector}`)}_initAutoplay(){this._autoplayInterval&&clearInterval(this._autoplayInterval),this._autoplayInterval=setInterval(()=>{this.index+1==this.length?this.changeSlide(0):this.changeSlide("next")},parseInt(this.o.autoplay))}resetSlider(nojump=!1,resetIndex=!0){let slidesWidth=0,page=0,pages=0,totalWidth=this.querySelector(".css-slider-container").offsetWidth,hideNavigation=!1;this.slidesPerPage=0,this.indexedItems=[],this.element.classList.add("disable-snapping"),this.OBSERVER&&this.OBSERVER.disconnect(),this.items.forEach((elm,i)=>{elm.classList.remove("css-slide--snap"),slidesWidth+=elm.getBoundingClientRect().width,slidesWidth>totalWidth&&this.slidesPerPage==0&&(this.slidesPerPage=i)}),this.slidesPerPage==0&&(this.slidesPerPage=this.items.length,hideNavigation=!0),this.o.forceOneSlidePerPage&&(this.slidesPerPage=1);const sliderDifference=totalWidth-slidesWidth;if(sliderDifference<60?this.setAttribute("data-slides-per-page-difference","small"):sliderDifference>=60&&this.setAttribute("data-slides-per-page-difference","large"),this.items.forEach((elm,i)=>{i%this.slidesPerPage==0&&(elm.classList.add("css-slide--snap"),elm.setAttribute("data-index",page++),this.OBSERVER&&this.OBSERVER.observe(elm))}),this.indexedItems=this.querySelectorAll(`${this.o.selector}.css-slide--snap`),resetIndex&&(this.index=0),this.length=Math.ceil(this.items.length/this.slidesPerPage),this.o.thumbnails){this.thumbnailsEl.innerHTML="";for(let i=0;i<this.length;i++){let dot=document.createElement("span");dot.classList.add("css-slider-dot"),dot.dataset.index=i,this.thumbnailsEl.appendChild(dot),this.o.thumbnailsNoInteraction||(dot.addEventListener("click",e=>{this.changeSlide(e.target.dataset.index)}),dot.setAttribute("aria-label",window.KROWN.settings.locales.slider_thumbnail_label.replace("{{ count }}",i+1)),dot.setAttribute("role","button"),dot.setAttribute("tabindex",0),dot.addEventListener("keydown",e=>{e.keyCode==window.KEYCODES.RETURN&&dot.click()}))}this.thumbnailsEl.style.setProperty("--size",this.length),this.thumbnails=this.thumbnailsEl.querySelectorAll(".css-slider-dot")}this.o.indexNav&&(this.indexEl.textContent=this.index+1,this.lengthEl.textContent=this.length),hideNavigation?(this.element.classList.add("css-slider--no-drag"),this.o.navigation&&(this.prevEl.style.display="none",this.nextEl.style.display="none"),this.o.thumbnails&&(this.thumbnailsEl.style.display="none")):(this.element.classList.remove("css-slider--no-drag"),this.o.navigation&&(this.prevEl.style.display="block",this.nextEl.style.display="block"),this.o.thumbnails&&(this.thumbnailsEl.style.display="block")),this.checkSlide(),nojump||this.element.scrollTo({top:0,left:0,behavior:"auto"}),this.element.classList.remove("disable-snapping"),this.setAttribute("data-slider-length",this.length),this.dispatchEvent(this._resetEvent)}}typeof customElements.get("css-slider")>"u"&&customElements.define("css-slider",CSSSlider2)}
//# sourceMappingURL=/cdn/shop/t/49/assets/component-slider.js.map?v=30874678805472068791760045849
