1import"./chunk-6KHOHYTW.js";var l=class{constructor(e){this.element=e,this._init()}_init(){let e=(window.lclClientConfig||{}).language,s=({index:t,total:n})=>e.carousel_sr_item.replace("%{index}",t).replace("%{total}",n);this._visibleItemsLabel=({from:t,to:n,total:r})=>e&&e[n?"carousel_sr_visible_items_multiple":"carousel_sr_visible_items_single"].replace("%{from}",t).replace("%{to}",n).replace("%{total}",r),this._viewport=this.element.querySelector(".carousel__viewport"),this._previousButton=this.element.querySelector(".carousel__navigation--previous"),this._nextButton=this.element.querySelector(".carousel__navigation--next"),this._currentItemSrText=this.element.querySelector(".carousel__sr-current-item"),this._pagination=this.element.parentNode.querySelector(".carousel__pagination"),this._paginationItems=this.element.parentNode.querySelectorAll(".carousel__pagination-item");let i=(t,n)=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),t())};this._previousButton.addEventListener("keydown",i.bind(this,this._showPrevious.bind(this))),this._nextButton.addEventListener("keydown",i.bind(this,this._showNext.bind(this))),this._previousButton.addEventListener("click",this._showPrevious.bind(this)),this._nextButton.addEventListener("click",this._showNext.bind(this)),this._preferredScrollBehaviour=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth",this._itemsContainer=this.element.querySelector(".carousel__items"),this._items=[...this.element.querySelectorAll(".carousel__items > *")],this._itemsInView=[],"IntersectionObserver"in window&&(this._observer=new IntersectionObserver(this._handleIntersection.bind(this),{root:this._viewport,rootMargin:"1px",threshold:1}),this._items.forEach((t,n)=>{this._observer.observe(t),t.ariaLabel=e&&s({index:n+1,total:this._items.length})})),this._items.length===1&&this.element.classList.add("carousel--single-item")}_handleIntersection(e){e.forEach(({target:t,isIntersecting:n})=>{if(t.parentNode!==this._itemsContainer)return;let r=t.querySelectorAll(this.element.dataset.linkSelector)||[],a=this._items.indexOf(t);n?(this._itemsInView=new Int8Array([...this._itemsInView,a]).sort(),t.ariaHidden=!1,r.forEach(o=>{o.tabIndex=0})):(this._itemsInView=this._itemsInView.filter(o=>o!==a),t.ariaHidden=!0,r.forEach(o=>{o.tabIndex=-1}))});let s=this._previousButton,i=this._nextButton;if(this._itemsInView.length===this._items.length){s.classList.add("carousel__navigation--hidden"),i.classList.add("carousel__navigation--hidden");return}s.classList.remove("carousel__navigation--hidden"),i.classList.remove("carousel__navigation--hidden"),this._itemsInView.length>0&&(this._itemsInView[0]===0?s.setAttribute("aria-disabled","true"):[...this._itemsInView].at(-1)===this._items.length-1?i.setAttribute("aria-disabled","true"):(s.setAttribute("aria-disabled","false"),i.setAttribute("aria-disabled","false")),this._updateSrItemsInView(),this._updatePaginationBar())}_showPrevious(){let[e]=this._itemsInView;if(e===0)return;let s=this._items[e-1].getBoundingClientRect().right,i=Math.min(this._viewport.getBoundingClientRect().right,window.innerWidth-10);this._viewport.scrollBy({left:s-i,behavior:this._preferredScrollBehaviour})}_showNext(){let e=[...this._itemsInView].at(-1);if(e===this._items.length-1)return;let s=this._items[e+1].getBoundingClientRect().left,i=Math.max(this._viewport.getBoundingClientRect().left,10);this._viewport.scrollBy({left:s-i,behavior:this._preferredScrollBehaviour})}_updateSrItemsInView(){let e=this._itemsInView,s=e[0]+1,i=e.length>1&&[...e].at(-1)+1,t=this._visibleItemsLabel({from:s,to:i,total:this._items.length});this._currentItemSrText.textContent=t}
1_getItemsPerViewAndCurrentPage(){let e=0,s=0;for(let n of this._items){let r=getComputedStyle(n),a=n.offsetWidth+Number.parseFloat(r.marginLeft)+Number.parseFloat(r.marginRight);if(s+a<=this._viewport.offsetWidth)s+=a,e++;else break}e<=0&&(e=1);let i=this._itemsInView.length?[...this._itemsInView].at(-1):0,t=Math.floor(i/e);return{itemsPerView:e,currentPage:t}}_setPaginationBarDottes(e){let s=Math.ceil(this._items.length/e);this._pagination.innerHTML="";for(let i=0;i<s;i++){let t=document.createElement("span");t.className="carousel__pagination-item",this._pagination.appendChild(t)}this._paginationItems=this.element.parentNode.querySelectorAll(".carousel__pagination-item")}_updatePaginationBar(){if(!this._paginationItems||!this._paginationItems.length)return;let{itemsPerView:e,currentPage:s}=this._getItemsPerViewAndCurrentPage();this._setPaginationBarDottes(e),this._paginationItems.forEach((i,t)=>{i.classList.remove("active","nearby-active"),t===s?i.classList.add("active"):(t===s-1||t===s+1)&&i.classList.add("nearby-active")})}};export{l as default}; 2//# sourceMappingURL=carousel-module-GO44M2CZ.js.map
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.