lazer-slider 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var H={MIN_DURATION:400,MAX_DURATION:1e3,SPEED_FACTOR:1.5,SCROLL_END_DELAY:50,THUMB_UPDATE_DELAY:500},ve="(min-width: 64rem)",N=()=>window.matchMedia(ve).matches;var k=e=>e===1?1:1-Math.pow(2,-10*e),w=e=>1-Math.pow(1-e,3),Ee=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Le=e=>1-(1-e)*(1-e),Ae=e=>e;var ye=()=>`slider-${Math.random().toString(36).substring(2,9)}`,le=e=>{let{feed:t,prevSlideButton:l,nextSlideButton:i,thumbs:o,slides:c}=e;t.id||(t.id=ye()),t.setAttribute("role","region"),t.setAttribute("aria-label","Carousel"),t.setAttribute("aria-roledescription","carousel"),t.removeAttribute("tabindex"),c.forEach((r,a)=>{r.setAttribute("role","group"),r.setAttribute("aria-roledescription","slide"),r.setAttribute("aria-label",`Slide ${a+1} of ${c.length}`);}),l&&(l.setAttribute("aria-label","Previous slide"),l.setAttribute("aria-controls",t.id),l.setAttribute("tabindex","0"),l.tagName!=="BUTTON"&&l.setAttribute("role","button")),i&&(i.setAttribute("aria-label","Next slide"),i.setAttribute("aria-controls",t.id),i.setAttribute("tabindex","0"),i.tagName!=="BUTTON"&&i.setAttribute("role","button")),o?.length&&o.forEach((r,a)=>{r.tagName!=="BUTTON"&&r.setAttribute("role","button"),r.setAttribute("aria-label",`Go to slide ${a+1}`),r.setAttribute("tabindex","0"),r.setAttribute("aria-controls",t.id);});},W=(e,t,l)=>{if(!e)return;!t&&e===document.activeElement&&l&&l.focus();let i="opacity 0.3s ease",o=t?"1":"0";Object.assign(e.style,{opacity:o,transition:i,pointerEvents:t?"auto":"none"}),t?(e.removeAttribute("aria-hidden"),e.setAttribute("tabindex","0")):(e.setAttribute("aria-hidden","true"),e.setAttribute("tabindex","-1")),t?e.style.visibility="visible":setTimeout(()=>{e.style.opacity==="0"&&(e.style.visibility="hidden");},300);},F=(e,t,l="active")=>{e?.length&&e.forEach((i,o)=>{let c=o===t;i.classList.toggle(l,c),i.setAttribute("aria-selected",c.toString());});},re=(e,t,l,i,o="horizontal")=>{let c=o==="vertical",r=c?"ArrowUp":"ArrowLeft",a=c?"ArrowDown":"ArrowRight";e.addEventListener("keydown",u=>{switch(u.key){case r:u.preventDefault(),t();break;case a:u.preventDefault(),l();break}},{signal:i}),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");};var D={FRICTION:.94,MIN_VELOCITY:.3,MOMENTUM_RATIO:.8,VELOCITY_SMOOTHING:.4,EDGE_RESISTANCE:.3,MAX_EDGE_OVERSCROLL:100,SHORT_SWIPE_VELOCITY:.5,BOUNCE_DURATION:400},ge=()=>({isDragging:false,startX:0,startY:0,startScrollLeft:0,startScrollTop:0,velocity:0,lastX:0,lastY:0,lastTime:0,momentumId:null}),xe=()=>({...ge(),velocityHistory:[],dragDistance:0,dragStartTime:0}),$=(e,t,l="horizontal")=>{let i=e.getBoundingClientRect(),o=l==="vertical",c=o?i.top:i.left,r=null,a=1/0;for(let u of t){if(u.offsetParent===null)continue;let f=u.getBoundingClientRect(),p=o?f.top:f.left,E=Math.abs(c-p);E<a&&(a=E,r=u);}return r},Ie=(e,t,l,i="horizontal")=>{let o=e.getBoundingClientRect(),c=i==="vertical",r=c?o.top:o.left,a=t.filter(n=>n.offsetParent!==null);if(a.length===0)return null;let u=0,f=1/0;a.forEach((n,S)=>{let L=n.getBoundingClientRect(),v=c?L.top:L.left,O=Math.abs(r-v);O<f&&(f=O,u=S);});let p=2,E=u;return Math.abs(l)>p&&(l>0?E=Math.min(u+1,a.length-1):E=Math.max(u-1,0)),a[E]??null},Me=e=>{if(e.length===0)return 0;let t=0,l=0;return e.forEach((i,o)=>{let c=o+1;t+=i*c,l+=c;}),t/l},De=(e,t,l,i,o,c="horizontal",r=false)=>{let a=c==="vertical",u=e.velocity*D.MOMENTUM_RATIO,f=()=>{if(Math.abs(u)<D.MIN_VELOCITY){e.momentumId=null;let S=$(t,l,c);if(S){let L=a?S.offsetTop:S.offsetLeft;i(L,w);}o?.(S);return}let p=a?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,n=(a?t.scrollTop:t.scrollLeft)+u;r||(n<0||n>p)&&(u*=.5),a?t.scrollTop=Math.max(0,Math.min(p,n)):t.scrollLeft=Math.max(0,Math.min(p,n)),u*=D.FRICTION,e.momentumId=requestAnimationFrame(f);};e.momentumId=requestAnimationFrame(f);},ie=e=>"touches"in e?e.touches[0]?.clientX??0:e.clientX,ne=e=>"touches"in e?e.touches[0]?.clientY??0:e.clientY,Ce=(e,t)=>t==="vertical"?ne(e):ie(e),ae=e=>{let {feed:t,slides:l,abortSignal:i,smoothScrollTo:o,onDragStart:c,onDragEnd:r,direction:a="horizontal",loop:u=false,touchRatio:f=1,shortSwipeThreshold:p=300,swipeDistanceThreshold:E=10}=e,n=xe(),S=a==="vertical",L=()=>{if(!u)return l;let A=[],M=t.children;for(let C=0;C<M.length;C++){let x=M[C];(l.includes(x)||x.hasAttribute("data-lazer-clone"))&&A.push(x);}return A.length>0?A:l},v=0,U=()=>{v=S?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,S?t.clientHeight:t.clientWidth;},B=A=>{n.momentumId!==null&&(cancelAnimationFrame(n.momentumId),n.momentumId=null),U(),c?.(),n.isDragging=true,n.startX=ie(A),n.startY=ne(A),n.startScrollLeft=t.scrollLeft,n.startScrollTop=t.scrollTop,n.velocity=0,n.lastX=n.startX,n.lastY=n.startY,n.lastTime=performance.now(),n.velocityHistory=[],n.dragDistance=0,n.dragStartTime=performance.now(),t.style.userSelect="none",t.style.cursor="grabbing",t.classList.add("is-dragging"),A.type==="mousedown"&&A.preventDefault();},X=A=>{if(!n.isDragging)return;let M=Ce(A,a),C=S?n.startY:n.startX,x=S?n.lastY:n.lastX,s=S?n.startScrollTop:n.startScrollLeft,d=performance.now(),b=d-n.lastTime,h=(C-M)*f,m=s+h;if(n.dragDistance=Math.abs(h),!u){if(m<0){let T=Math.abs(m),y=1-Math.min(T/D.MAX_EDGE_OVERSCROLL,1)*(1-D.EDGE_RESISTANCE);m=-T*y;}else if(m>v){let T=m-v,y=1-Math.min(T/D.MAX_EDGE_OVERSCROLL,1)*(1-D.EDGE_RESISTANCE);m=v+T*y;}}if(S?t.scrollTop=m:t.scrollLeft=m,b>0){let T=(x-M)/b*16;if(n.velocityHistory.length>0){let y=n.velocity;n.velocity=y*(1-D.VELOCITY_SMOOTHING)+T*D.VELOCITY_SMOOTHING;}else n.velocity=T;n.velocityHistory.push(T),n.velocityHistory.length>5&&n.velocityHistory.shift();}S?n.lastY=M:n.lastX=M,n.lastTime=d,A.type==="touchmove"&&A.preventDefault();},P=()=>{if(!n.isDragging)return;n.isDragging=false,t.style.userSelect="",t.style.cursor="",t.classList.remove("is-dragging");let M=performance.now()-n.dragStartTime<p&&n.dragDistance>E,C=Me(n.velocityHistory),x=L();if(!u){let s=S?t.scrollTop:t.scrollLeft;if(s<0||s>v){let d=s<0?0:v,b=s,h=performance.now(),m=()=>{let T=performance.now()-h,y=Math.min(T/D.BOUNCE_DURATION,1),R=w(y),g=b+(d-b)*R;if(S?t.scrollTop=g:t.scrollLeft=g,y<1)requestAnimationFrame(m);else {let I=$(t,x,a);if(I){let Te=S?I.offsetTop:I.offsetLeft;o(Te,w);}r?.(I);}};requestAnimationFrame(m);return}}if(M||Math.abs(C)>D.SHORT_SWIPE_VELOCITY){let s=Ie(t,x,C,a);if(s){let d=S?s.offsetTop:s.offsetLeft;o(d,w),r?.(s);}else r?.(null);}else if(Math.abs(n.velocity)>1&&!n.isLoopDragHandled)De(n,t,x,o,r,a,u);else {let s=$(t,x,a);if(!n.isLoopDragHandled){if(s){let d=S?s.offsetTop:s.offsetLeft;o(d,w);}r?.(s);}}};return t.addEventListener("mousedown",B,{signal:i}),document.addEventListener("mousemove",X,{signal:i}),document.addEventListener("mouseup",P,{signal:i}),t.addEventListener("touchstart",B,{passive:true,signal:i}),t.addEventListener("touchmove",X,{passive:false,signal:i}),t.addEventListener("touchend",P,{signal:i}),t.addEventListener("touchcancel",P,{signal:i}),document.addEventListener("mouseleave",P,{signal:i}),t.style.cursor="grab",n},ce=e=>{e.momentumId!==null&&(cancelAnimationFrame(e.momentumId),e.momentumId=null);};var q=({bulletsContainer:e,slides:t,bulletClass:l,bulletActiveClass:i,feedId:o})=>{if(!e||!(e instanceof HTMLElement))throw new Error("Invalid bulletsContainer: must be a valid HTMLElement");if(!Array.isArray(t)||t.length===0)throw new Error("Invalid slides: must be a non-empty array");if(!o||typeof o!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!l||typeof l!="string")throw new Error("Invalid bulletClass: must be a non-empty string");e.innerHTML="",e.setAttribute("role","tablist"),e.setAttribute("aria-label","Slide navigation");let c=t.map((a,u)=>({slide:a,originalIndex:u})).filter(({slide:a})=>a.offsetParent!==null);return c.length===0?(console.warn("No visible slides found"),[]):c.map(({slide:a,originalIndex:u},f)=>{let p=document.createElement("button");return p.type="button",p.classList.add(l),f===0&&p.classList.add(i),p.setAttribute("role","tab"),p.setAttribute("aria-selected",f===0?"true":"false"),p.setAttribute("aria-controls",o),p.setAttribute("aria-label",`Go to slide ${f+1}`),p.setAttribute("data-slide-index",String(f)),e.appendChild(p),p})};var j=({thumbsContainer:e,slides:t,thumbClass:l,thumbActiveClass:i,feedId:o,thumbImageSelector:c="img",thumbSize:r})=>{if(!e||!(e instanceof HTMLElement))throw new Error("Invalid thumbsContainer: must be a valid HTMLElement");if(!Array.isArray(t)||t.length===0)throw new Error("Invalid slides: must be a non-empty array");if(!o||typeof o!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!l||typeof l!="string")throw new Error("Invalid thumbClass: must be a non-empty string");e.innerHTML="",e.setAttribute("role","tablist"),e.setAttribute("aria-label","Slide thumbnails");let a=t.map((f,p)=>({slide:f,originalIndex:p})).filter(({slide:f})=>f.offsetParent!==null);return a.length===0?(console.warn("No visible slides found"),[]):a.map(({slide:f,originalIndex:p},E)=>{let n=document.createElement("button");n.type="button",n.classList.add(l),E===0&&n.classList.add(i);let S=f.querySelector(c);if(S?.src){let L=document.createElement("img");L.src=S.src,L.alt=S.alt||`Slide ${E+1} thumbnail`,L.draggable=false,r&&(L.style.width=`${r.width}px`,L.style.height=`${r.height}px`,L.style.objectFit="cover"),n.appendChild(L);}return n.setAttribute("role","tab"),n.setAttribute("aria-selected",E===0?"true":"false"),n.setAttribute("aria-controls",o),n.setAttribute("aria-label",`Go to slide ${E+1}`),n.setAttribute("data-slide-index",String(E)),e.appendChild(n),n})};var _=(e,t,l,i)=>{if(t.autoScrollAnimationId!==null)return;t.autoScrollPaused=false,t.autoScrollStopped=false,t.autoScrollLastTimestamp=performance.now();let o=e.autoScrollSpeed??50,c=e.autoScrollDirection??"forward",r=a=>{if(t.autoScrollPaused||t.autoScrollStopped){t.autoScrollAnimationId=null;return}let u=a-t.autoScrollLastTimestamp;t.autoScrollLastTimestamp=a,u>100&&(u=100);let f=o*(u/1e3);c==="backward"&&(f=-f),i?e.feed.scrollTop+=f:e.feed.scrollLeft+=f,Re(e,l,i,c),t.autoScrollAnimationId=requestAnimationFrame(r);};t.autoScrollAnimationId=requestAnimationFrame(r);},Re=(e,t,l,i)=>{if(!t.initialized||t.realSlides.length===0)return;let o=e.feed;if(i==="forward"){let c=l?o.scrollHeight-o.clientHeight:o.scrollWidth-o.clientWidth;if((l?o.scrollTop:o.scrollLeft)>=c-1){let a=t.realSlides[0];a&&(l?o.scrollTop=a.offsetTop:o.scrollLeft=a.offsetLeft);}}else if((l?o.scrollTop:o.scrollLeft)<=1){let r=t.realSlides[t.realSlides.length-1];r&&(l?o.scrollTop=r.offsetTop:o.scrollLeft=r.offsetLeft);}},K=e=>{e.autoScrollAnimationId!==null&&(cancelAnimationFrame(e.autoScrollAnimationId),e.autoScrollAnimationId=null),e.autoScrollResumeTimeout!==null&&(clearTimeout(e.autoScrollResumeTimeout),e.autoScrollResumeTimeout=null);},z=e=>{e.autoScrollPaused=true,e.autoScrollAnimationId!==null&&(cancelAnimationFrame(e.autoScrollAnimationId),e.autoScrollAnimationId=null);},G=(e,t,l,i)=>{t.autoScrollStopped||(t.autoScrollLastTimestamp=performance.now(),t.autoScrollPaused=false,t.autoScrollAnimationId===null&&_(e,t,l,i));},Y=(e,t,l,i)=>{if(t.autoScrollStopped)return;t.autoScrollResumeTimeout!==null&&clearTimeout(t.autoScrollResumeTimeout);let o=e.autoScrollStartDelay??0;o>0?t.autoScrollResumeTimeout=setTimeout(()=>{t.autoScrollResumeTimeout=null,G(e,t,l,i);},o):G(e,t,l,i);},se=(e,t,l,i,o)=>{if(!e.autoScroll)return;let c=e.stopOnMouseEnter!==false,r=e.stopOnFocusIn!==false;c&&(e.feed.addEventListener("mouseenter",()=>z(t),{signal:o}),e.feed.addEventListener("mouseleave",()=>Y(e,t,l,i),{signal:o})),r&&(e.feed.addEventListener("focusin",()=>z(t),{signal:o}),e.feed.addEventListener("focusout",()=>Y(e,t,l,i),{signal:o})),e.feed.addEventListener("touchstart",()=>z(t),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>Y(e,t,l,i),{signal:o});};var de=e=>({initialized:false,clonedSlides:[],realSlides:[...e],clonesPerSide:0}),He=e=>{let t=N()?e.desktopSlidesPerView:e.mobileSlidesPerView;if(e.autoScroll){let l=!t||t==="auto"?3:Math.ceil(t)+1;return Math.min(l,e.slides.length)}return !t||t==="auto"?1:Math.ceil(t)},Q=(e,t,l)=>{if(!e.loop||t.initialized)return;let i=t.realSlides,o=He(e);t.clonesPerSide=o;for(let c=i.length-o;c<i.length;c++){let r=i[c];if(!r)continue;let a=r.cloneNode(true);a.setAttribute("data-lazer-clone","prepend"),a.setAttribute("aria-hidden","true"),e.feed.insertBefore(a,e.feed.firstChild),t.clonedSlides.push(a);}for(let c=0;c<o;c++){let r=i[c];if(!r)continue;let a=r.cloneNode(true);a.setAttribute("data-lazer-clone","append"),a.setAttribute("aria-hidden","true"),e.feed.appendChild(a),t.clonedSlides.push(a);}requestAnimationFrame(()=>{let c=i[0];c&&(l?e.feed.scrollTop=c.offsetTop:e.feed.scrollLeft=c.offsetLeft);}),t.initialized=true;},ue=(e,t,l,i,o,c,r)=>{if(!t.loop||!l.initialized)return;c(true);let a=l.realSlides,u=a.length;if(e==="next"){let f=a[0];f&&(i?t.feed.scrollTop=f.offsetTop:t.feed.scrollLeft=f.offsetLeft),o(0);}else {let f=a[u-1];f&&(i?t.feed.scrollTop=f.offsetTop:t.feed.scrollLeft=f.offsetLeft),o(u-1);}requestAnimationFrame(()=>{requestAnimationFrame(()=>{c(false),r();});});},fe=e=>{e.initialized&&(e.clonedSlides.forEach(t=>{t.remove();}),e.clonedSlides=[],e.initialized=false,e.clonesPerSide=0);};var J=(e,t,l)=>{if(t.autoplayIntervalId)return;let i=e.autoplayInterval??3e3;t.autoplayIntervalId=setInterval(()=>{t.autoplayPaused||l("next");},i);},Z=e=>{e.autoplayIntervalId&&(clearInterval(e.autoplayIntervalId),e.autoplayIntervalId=null);},me=e=>{e.autoplayPaused=true;},pe=e=>{e.autoplayPaused=false;},Se=(e,t,l)=>{!e.autoplay||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>me(t),{signal:l}),e.feed.addEventListener("mouseleave",()=>pe(t),{signal:l}),e.feed.addEventListener("touchstart",()=>me(t),{passive:true,signal:l}),e.feed.addEventListener("touchend",()=>pe(t),{signal:l}));};var ee=(e,t,l)=>{if(e.scrollbarThumb)if(l){let i=t.height/e.feed.scrollHeight*100;e.scrollbarThumb.style.height=`${i}%`,e.scrollbarThumb.style.width="";}else {let i=t.width/e.feed.scrollWidth*100;e.scrollbarThumb.style.width=`${i}%`,e.scrollbarThumb.style.height="";}},he=(e,t)=>{if(!(!e.scrollbarThumb||!e.scrollbarTrack))if(t){let l=e.scrollbarTrack.getBoundingClientRect().height,i=e.scrollbarThumb.getBoundingClientRect().height,o=l-i,c=e.feed.scrollHeight-e.feed.clientHeight,r=c>0?e.feed.scrollTop/c:0;e.scrollbarThumb.style.transform=`translateY(${o*r}px)`;}else {let l=e.scrollbarTrack.getBoundingClientRect().width,i=e.scrollbarThumb.getBoundingClientRect().width,o=l-i,c=e.feed.scrollWidth-e.feed.clientWidth,r=c>0?e.feed.scrollLeft/c:0;e.scrollbarThumb.style.transform=`translateX(${o*r}px)`;}};var te=(e,t,l,i=k,o,c)=>{let r=l?e.scrollTop:e.scrollLeft,a=Math.abs(t-r),u=Math.min(H.MAX_DURATION,Math.max(H.MIN_DURATION,a/H.SPEED_FACTOR)),f=performance.now(),p=E=>{if(c?.cancelled)return;let n=(E-f)/u,S=Math.min(n,1),L=i(S),v=r+(t-r)*L;l?e.scrollTop=v:e.scrollLeft=v,S<1?requestAnimationFrame(p):(l?e.scrollTop=t:e.scrollLeft=t,o?.());};requestAnimationFrame(p);},V=e=>e.filter(t=>t.offsetParent!==null),oe=(e,t,l)=>{let i=l?e.desktopSlidesPerView:e.mobileSlidesPerView,o=e.slideGap??0;if(o>0&&(e.feed.style.gap=`${o}px`),!i||i==="auto"){e.slides.forEach(a=>{a.style.flex="",a.style.minWidth="",a.style.minHeight="";});return}let r=`calc((100% - ${o*(i-1)}px) / ${i})`;t?e.slides.forEach(a=>{a.style.flex=`0 0 ${r}`,a.style.minHeight=r,a.style.minWidth="";}):e.slides.forEach(a=>{a.style.flex=`0 0 ${r}`,a.style.minWidth=r,a.style.minHeight="";});},be=(e,t,l,i)=>{let o=i?e.clientHeight:e.clientWidth;return !t||l!==o?{rect:e.getBoundingClientRect(),size:o}:{rect:t,size:l}};var we=e=>{if(!e.feed)throw new Error("lazer-slider: feed element is required");if(!e.slides?.length)throw new Error("lazer-slider: slides array is required and must not be empty");if(e.feed.id||(e.feed.id=`lazer-slider-feed-${Math.random().toString(36).substr(2,9)}`),e.bulletsContainer&&!e.thumbs){let s=q({bulletsContainer:e.bulletsContainer,slides:e.slides,bulletClass:e.bulletsClass??"slider-bullet",bulletActiveClass:e.bulletsActiveClass??"active",feedId:e.feed.id});e.thumbs=s;}if(e.thumbsContainer&&!e.thumbs){let s=j({thumbsContainer:e.thumbsContainer,slides:e.slides,thumbClass:e.thumbsClass??"slider-thumb",thumbActiveClass:e.thumbsActiveClass??"active",feedId:e.feed.id,thumbImageSelector:e.thumbImageSelector??"img",thumbSize:e.thumbSize});e.thumbs=s;}let t=e.direction??"horizontal",l=t==="vertical",i=e.easing??k,o={currentSlideIndex:0,isScrolling:false,ticking:false,cachedFeedRect:null,lastWidth:0,updateThumbTimeout:null,scrollEndTimeout:null,abortController:new AbortController,autoplayIntervalId:null,autoplayPaused:false,autoScrollAnimationId:null,autoScrollPaused:false,autoScrollLastTimestamp:0,autoScrollStopped:false,autoScrollResumeTimeout:null,isLoopRepositioning:false},c=null,r=de(e.slides),a={cancelled:false},u=null,f=()=>{let s=be(e.feed,o.cachedFeedRect,o.lastWidth,l);return o.cachedFeedRect=s.rect,o.lastWidth=s.size,s.rect},p=(s,d)=>{te(e.feed,s,l,i,d);},E=(s,d)=>{a.cancelled=true,a={cancelled:false},te(e.feed,s,l,d??i,void 0,a);},n=()=>{if(o.isLoopRepositioning)return;let s=f(),d,b,h;if(l?(d=e.feed.scrollTop<=1,b=e.feed.scrollTop+s.height>=e.feed.scrollHeight-1,h=e.feed.scrollHeight<=s.height):(d=e.feed.scrollLeft<=1,b=e.feed.scrollLeft+s.width>=e.feed.scrollWidth-1,h=e.feed.scrollWidth<=s.width),e.scrollbarTrack&&(e.scrollbarTrack.style.display=h?"none":"block"),e.loop){W(e.prevSlideButton,!h,e.feed),W(e.nextSlideButton,!h,e.feed);return}W(e.prevSlideButton,!d&&!h,e.feed),W(e.nextSlideButton,!b&&!h,e.feed);},S=()=>{let s=f(),d=r.initialized?r.realSlides:V(e.slides),b=d.filter(h=>{let m=h.getBoundingClientRect(),T=20;return l?m.bottom>s.top+T&&m.top<s.bottom-T:m.right>s.left+T&&m.left<s.right-T});if(b.length&&b[0]){let h=d.indexOf(b[0]);if(h!==-1){o.currentSlideIndex=h;let m=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScroll?.({currentScroll:m,currentSlideIndex:o.currentSlideIndex});}}},L=s=>{if(!e.thumbs)return;let d=e.thumbs.indexOf(s);if(d===-1||!e.slides[d])return;o.currentSlideIndex=d,F(e.thumbs,d),o.isScrolling=true,o.updateThumbTimeout&&clearTimeout(o.updateThumbTimeout),o.updateThumbTimeout=setTimeout(()=>{o.isScrolling=false;},H.THUMB_UPDATE_DELAY);let b=l?e.slides[d].offsetTop:e.slides[d].offsetLeft;p(b);},v=s=>{let d=r.initialized?r.realSlides:V(e.slides),b=N()?e.desktopSlidesPerScroll??1:e.mobileSlidesPerScroll??1,h=d.length;S();let m,T=false;if(s==="prev")if(e.loop&&r.initialized&&o.currentSlideIndex===0){let g=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="prepend");m=g[g.length-1],T=true;}else o.currentSlideIndex=Math.max(0,o.currentSlideIndex-b),m=d[o.currentSlideIndex];else e.loop&&r.initialized&&o.currentSlideIndex>=h-1?(m=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="append")[0],T=true):(o.currentSlideIndex=Math.min(h-1,o.currentSlideIndex+b),m=d[o.currentSlideIndex]);if(!m)return;let y=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollStart?.({currentScroll:y,target:m,direction:s});let R=l?m.offsetTop:m.offsetLeft;T?p(R,()=>{ue(s,e,r,l,g=>{o.currentSlideIndex=g;},g=>{o.isLoopRepositioning=g;},n);}):p(R);},O=()=>{he(e,l),n(),S(),o.isScrolling||F(e.thumbs,o.currentSlideIndex),o.scrollEndTimeout&&clearTimeout(o.scrollEndTimeout),o.scrollEndTimeout=setTimeout(()=>{o.isScrolling=false;let s=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollEnd?.({currentScroll:s,currentSlideIndex:o.currentSlideIndex});},H.SCROLL_END_DELAY);},U=()=>{o.ticking||(requestAnimationFrame(()=>{O(),o.ticking=false;}),o.ticking=true);},B=()=>{let s=o.currentSlideIndex;o.cachedFeedRect=null;let d=()=>{let h=(r.initialized?r.realSlides:V(e.slides))[s];if(h){let m=l?h.offsetTop:h.offsetLeft;l?e.feed.scrollTop=m:e.feed.scrollLeft=m;}};d(),u&&clearTimeout(u),u=setTimeout(()=>{A(),d();},150);},X=()=>{let{signal:s}=o.abortController;window.addEventListener("resize",B),e.feed.addEventListener("scroll",U,{passive:true,signal:s}),e.prevSlideButton&&e.prevSlideButton.addEventListener("click",()=>v("prev"),{signal:s}),e.nextSlideButton&&e.nextSlideButton.addEventListener("click",()=>v("next"),{signal:s}),e.thumbs?.length&&(e.thumbs[0]?.classList.add("active"),e.thumbs.forEach(d=>{d.addEventListener("click",()=>L(d),{signal:s});})),re(e.feed,()=>v("prev"),()=>v("next"),s,t),e.enableDragToScroll!==false&&(c=ae({feed:e.feed,slides:e.slides,abortSignal:s,smoothScrollTo:E,onDragStart:()=>{e.autoScroll&&z(o);},onDragEnd:d=>{let b=d?.getAttribute("data-lazer-clone");if(!!(b&&e.loop&&r.initialized)&&d){let m=r.realSlides,T=0,y;if(b==="prepend"){let g=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="prepend").indexOf(d);T=m.length-r.clonesPerSide+g,y=m[T];}else if(b==="append"){let g=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="append").indexOf(d);T=g,y=m[g];}if(y){o.currentSlideIndex=T;let R=l?y.offsetTop:y.offsetLeft;setTimeout(()=>{a.cancelled=true,l?e.feed.scrollTop=R:e.feed.scrollLeft=R;},H.MIN_DURATION),F(e.thumbs,o.currentSlideIndex);}}else S(),F(e.thumbs,o.currentSlideIndex);e.autoScroll&&!o.autoScrollStopped&&(e.stopOnInteraction?o.autoScrollStopped=true:Y(e,o,r,l));},direction:t,loop:e.loop})),Se(e,o,s),se(e,o,r,l,s);},P=s=>{let d=r.initialized?r.realSlides:V(e.slides),b=Math.max(0,Math.min(s,d.length-1)),h=d[b];if(!h)return;o.currentSlideIndex=b,F(e.thumbs,b);let m=l?h.offsetTop:h.offsetLeft;p(m);},A=()=>{o.cachedFeedRect=null,oe(e,l,N()),ee(e,f(),l),n(),e.autoScroll&&!o.autoScrollPaused&&!o.autoScrollStopped&&(K(o),_(e,o,r,l));},M=()=>{Z(o),K(o),o.abortController.abort(),window.removeEventListener("resize",B),o.updateThumbTimeout&&clearTimeout(o.updateThumbTimeout),o.scrollEndTimeout&&clearTimeout(o.scrollEndTimeout),u&&clearTimeout(u),c&&ce(c),fe(r),o.cachedFeedRect=null;},C=()=>{e.autoScroll?(o.autoScrollStopped=false,o.autoScrollPaused?G(e,o,r,l):_(e,o,r,l)):e.autoplay&&J(e,o,v);},x=()=>{e.autoScroll?z(o):Z(o);};if(le(e),oe(e,l,N()),e.autoScroll){e.loop=true,Q(e,r,l);let s=e.autoScrollStartDelay??0;s>0?o.autoScrollResumeTimeout=setTimeout(()=>{o.autoScrollResumeTimeout=null,_(e,o,r,l);},s):requestAnimationFrame(()=>{requestAnimationFrame(()=>{_(e,o,r,l);});});}else Q(e,r,l),e.autoplay&&J(e,o,v);return n(),X(),ee(e,f(),l),{goToIndex:P,refresh:A,unload:M,play:C,pause:x,next:()=>v("next"),prev:()=>v("prev")}};exports.createSlider=we;exports.easeInOutCubic=Ee;exports.easeOutCubic=w;exports.easeOutExpo=k;exports.easeOutQuad=Le;exports.generateBullets=q;exports.generateThumbs=j;exports.linear=Ae;
1
+ 'use strict';var w={MIN_DURATION:400,MAX_DURATION:1e3,SPEED_FACTOR:1.5,SCROLL_END_DELAY:50,THUMB_UPDATE_DELAY:500},Ee="(min-width: 64rem)",P=()=>window.matchMedia(Ee).matches;var k=e=>e===1?1:1-Math.pow(2,-10*e),H=e=>1-Math.pow(1-e,3),Le=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Ae=e=>1-(1-e)*(1-e),ye=e=>e;var ge=()=>`slider-${Math.random().toString(36).substring(2,9)}`,le=e=>{let{feed:t,prevSlideButton:l,nextSlideButton:i,thumbs:o,slides:c}=e;t.id||(t.id=ge()),t.setAttribute("role","region"),t.setAttribute("aria-label","Carousel"),t.setAttribute("aria-roledescription","carousel"),t.removeAttribute("tabindex"),c.forEach((r,n)=>{r.setAttribute("role","group"),r.setAttribute("aria-roledescription","slide"),r.setAttribute("aria-label",`Slide ${n+1} of ${c.length}`);}),l&&(l.setAttribute("aria-label","Previous slide"),l.setAttribute("aria-controls",t.id),l.setAttribute("tabindex","0"),l.tagName!=="BUTTON"&&l.setAttribute("role","button")),i&&(i.setAttribute("aria-label","Next slide"),i.setAttribute("aria-controls",t.id),i.setAttribute("tabindex","0"),i.tagName!=="BUTTON"&&i.setAttribute("role","button")),o?.length&&o.forEach((r,n)=>{r.tagName!=="BUTTON"&&r.setAttribute("role","button"),r.setAttribute("aria-label",`Go to slide ${n+1}`),r.setAttribute("tabindex","0"),r.setAttribute("aria-controls",t.id);});},B=(e,t,l)=>{if(!e)return;!t&&e===document.activeElement&&l&&l.focus();let i="opacity 0.3s ease",o=t?"1":"0";Object.assign(e.style,{opacity:o,transition:i,pointerEvents:t?"auto":"none"}),t?(e.removeAttribute("aria-hidden"),e.setAttribute("tabindex","0")):(e.setAttribute("aria-hidden","true"),e.setAttribute("tabindex","-1")),t?e.style.visibility="visible":setTimeout(()=>{e.style.opacity==="0"&&(e.style.visibility="hidden");},300);},N=(e,t,l="active")=>{e?.length&&e.forEach((i,o)=>{let c=o===t;i.classList.toggle(l,c),i.setAttribute("aria-selected",c.toString());});},re=(e,t,l,i,o="horizontal")=>{let c=o==="vertical",r=c?"ArrowUp":"ArrowLeft",n=c?"ArrowDown":"ArrowRight";e.addEventListener("keydown",d=>{switch(d.key){case r:d.preventDefault(),t();break;case n:d.preventDefault(),l();break}},{signal:i}),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");};var M={FRICTION:.94,MIN_VELOCITY:.3,MOMENTUM_RATIO:.8,VELOCITY_SMOOTHING:.4,EDGE_RESISTANCE:.3,MAX_EDGE_OVERSCROLL:100,SHORT_SWIPE_VELOCITY:.5,BOUNCE_DURATION:400},xe=()=>({isDragging:false,startX:0,startY:0,startScrollLeft:0,startScrollTop:0,velocity:0,lastX:0,lastY:0,lastTime:0,momentumId:null}),Ie=()=>({...xe(),velocityHistory:[],dragDistance:0,dragStartTime:0}),q=(e,t,l="horizontal")=>{let i=e.getBoundingClientRect(),o=l==="vertical",c=o?i.top:i.left,r=null,n=1/0;for(let d of t){if(d.offsetParent===null)continue;let u=d.getBoundingClientRect(),m=o?u.top:u.left,b=Math.abs(c-m);b<n&&(n=b,r=d);}return r},Me=(e,t,l,i="horizontal")=>{let o=e.getBoundingClientRect(),c=i==="vertical",r=c?o.top:o.left,n=t.filter(a=>a.offsetParent!==null);if(n.length===0)return null;let d=0,u=1/0;n.forEach((a,p)=>{let L=a.getBoundingClientRect(),E=c?L.top:L.left,C=Math.abs(r-E);C<u&&(u=C,d=p);});let m=2,b=d;return Math.abs(l)>m&&(l>0?b=Math.min(d+1,n.length-1):b=Math.max(d-1,0)),n[b]??null},Re=e=>{if(e.length===0)return 0;let t=0,l=0;return e.forEach((i,o)=>{let c=o+1;t+=i*c,l+=c;}),t/l},De=(e,t,l,i,o,c="horizontal",r=false)=>{let n=c==="vertical",d=e.velocity*M.MOMENTUM_RATIO,u=()=>{if(Math.abs(d)<M.MIN_VELOCITY){e.momentumId=null;let p=q(t,l,c);if(p){let L=n?p.offsetTop:p.offsetLeft;i(L,H);}o?.(p);return}let m=n?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,a=(n?t.scrollTop:t.scrollLeft)+d;r||(a<0||a>m)&&(d*=.5),n?t.scrollTop=Math.max(0,Math.min(m,a)):t.scrollLeft=Math.max(0,Math.min(m,a)),d*=M.FRICTION,e.momentumId=requestAnimationFrame(u);};e.momentumId=requestAnimationFrame(u);},ie=e=>"touches"in e?e.touches[0]?.clientX??0:e.clientX,ne=e=>"touches"in e?e.touches[0]?.clientY??0:e.clientY,we=(e,t)=>t==="vertical"?ne(e):ie(e),ae=e=>{let {feed:t,slides:l,abortSignal:i,smoothScrollTo:o,onDragStart:c,onDragEnd:r,direction:n="horizontal",loop:d=false,touchRatio:u=1,shortSwipeThreshold:m=300,swipeDistanceThreshold:b=10}=e,a=Ie(),p=n==="vertical",L=()=>{if(!d)return l;let A=[],x=t.children;for(let R=0;R<x.length;R++){let g=x[R];(l.includes(g)||g.hasAttribute("data-lazer-clone"))&&A.push(g);}return A.length>0?A:l},E=0,$=()=>{E=p?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,p?t.clientHeight:t.clientWidth;},_=A=>{a.momentumId!==null&&(cancelAnimationFrame(a.momentumId),a.momentumId=null),$(),c?.(),a.isDragging=true,a.startX=ie(A),a.startY=ne(A),a.startScrollLeft=t.scrollLeft,a.startScrollTop=t.scrollTop,a.velocity=0,a.lastX=a.startX,a.lastY=a.startY,a.lastTime=performance.now(),a.velocityHistory=[],a.dragDistance=0,a.dragStartTime=performance.now(),t.style.userSelect="none",t.style.cursor="grabbing",t.classList.add("is-dragging"),A.type==="mousedown"&&A.preventDefault();},G=A=>{if(!a.isDragging)return;let x=we(A,n),R=p?a.startY:a.startX,g=p?a.lastY:a.lastX,s=p?a.startScrollTop:a.startScrollLeft,f=performance.now(),T=f-a.lastTime,h=(R-x)*u,S=s+h;if(a.dragDistance=Math.abs(h),!d){if(S<0){let v=Math.abs(S),y=1-Math.min(v/M.MAX_EDGE_OVERSCROLL,1)*(1-M.EDGE_RESISTANCE);S=-v*y;}else if(S>E){let v=S-E,y=1-Math.min(v/M.MAX_EDGE_OVERSCROLL,1)*(1-M.EDGE_RESISTANCE);S=E+v*y;}}if(p?t.scrollTop=S:t.scrollLeft=S,T>0){let v=(g-x)/T*16;if(a.velocityHistory.length>0){let y=a.velocity;a.velocity=y*(1-M.VELOCITY_SMOOTHING)+v*M.VELOCITY_SMOOTHING;}else a.velocity=v;a.velocityHistory.push(v),a.velocityHistory.length>5&&a.velocityHistory.shift();}p?a.lastY=x:a.lastX=x,a.lastTime=f,A.type==="touchmove"&&A.preventDefault();},O=()=>{if(!a.isDragging)return;a.isDragging=false,t.style.userSelect="",t.style.cursor="",t.classList.remove("is-dragging");let x=performance.now()-a.dragStartTime<m&&a.dragDistance>b,R=Re(a.velocityHistory),g=L();if(!d){let s=p?t.scrollTop:t.scrollLeft;if(s<0||s>E){let f=s<0?0:E,T=s,h=performance.now(),S=()=>{let v=performance.now()-h,y=Math.min(v/M.BOUNCE_DURATION,1),D=H(y),I=T+(f-T)*D;if(p?t.scrollTop=I:t.scrollLeft=I,y<1)requestAnimationFrame(S);else {let X=q(t,g,n);if(X){let ve=p?X.offsetTop:X.offsetLeft;o(ve,H);}r?.(X);}};requestAnimationFrame(S);return}}if(x||Math.abs(R)>M.SHORT_SWIPE_VELOCITY){let s=Me(t,g,R,n);if(s){let f=p?s.offsetTop:s.offsetLeft;o(f,H),r?.(s);}else r?.(null);}else if(Math.abs(a.velocity)>1&&!a.isLoopDragHandled)De(a,t,g,o,r,n,d);else {let s=q(t,g,n);if(!a.isLoopDragHandled){if(s){let f=p?s.offsetTop:s.offsetLeft;o(f,H);}r?.(s);}}};return t.addEventListener("mousedown",_,{signal:i}),document.addEventListener("mousemove",G,{signal:i}),document.addEventListener("mouseup",O,{signal:i}),t.addEventListener("touchstart",_,{passive:true,signal:i}),t.addEventListener("touchmove",G,{passive:false,signal:i}),t.addEventListener("touchend",O,{signal:i}),t.addEventListener("touchcancel",O,{signal:i}),document.addEventListener("mouseleave",O,{signal:i}),t.style.cursor="grab",a},se=e=>{e.momentumId!==null&&(cancelAnimationFrame(e.momentumId),e.momentumId=null);};var V=({bulletsContainer:e,slides:t,bulletClass:l,bulletActiveClass:i,feedId:o})=>{if(!e||!(e instanceof HTMLElement))throw new Error("Invalid bulletsContainer: must be a valid HTMLElement");if(!Array.isArray(t)||t.length===0)throw new Error("Invalid slides: must be a non-empty array");if(!o||typeof o!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!l||typeof l!="string")throw new Error("Invalid bulletClass: must be a non-empty string");e.innerHTML="",e.setAttribute("role","tablist"),e.setAttribute("aria-label","Slide navigation");let c=t.map((n,d)=>({slide:n,originalIndex:d})).filter(({slide:n})=>n.offsetParent!==null);return c.length===0?(console.warn("No visible slides found"),[]):c.map(({slide:n,originalIndex:d},u)=>{let m=document.createElement("button");return m.type="button",m.classList.add(l),u===0&&m.classList.add(i),m.setAttribute("role","tab"),m.setAttribute("aria-selected",u===0?"true":"false"),m.setAttribute("aria-controls",o),m.setAttribute("aria-label",`Go to slide ${u+1}`),m.setAttribute("data-slide-index",String(u)),e.appendChild(m),m})};var j=({thumbsContainer:e,slides:t,thumbClass:l,thumbActiveClass:i,feedId:o,thumbImageSelector:c="img",thumbSize:r})=>{if(!e||!(e instanceof HTMLElement))throw new Error("Invalid thumbsContainer: must be a valid HTMLElement");if(!Array.isArray(t)||t.length===0)throw new Error("Invalid slides: must be a non-empty array");if(!o||typeof o!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!l||typeof l!="string")throw new Error("Invalid thumbClass: must be a non-empty string");e.innerHTML="",e.setAttribute("role","tablist"),e.setAttribute("aria-label","Slide thumbnails");let n=t.map((u,m)=>({slide:u,originalIndex:m})).filter(({slide:u})=>u.offsetParent!==null);return n.length===0?(console.warn("No visible slides found"),[]):n.map(({slide:u,originalIndex:m},b)=>{let a=document.createElement("button");a.type="button",a.classList.add(l),b===0&&a.classList.add(i);let p=u.querySelector(c);if(p?.src){let L=document.createElement("img");L.src=p.src,L.alt=p.alt||`Slide ${b+1} thumbnail`,L.draggable=false,r&&(L.style.width=`${r.width}px`,L.style.height=`${r.height}px`,L.style.objectFit="cover"),a.appendChild(L);}return a.setAttribute("role","tab"),a.setAttribute("aria-selected",b===0?"true":"false"),a.setAttribute("aria-controls",o),a.setAttribute("aria-label",`Go to slide ${b+1}`),a.setAttribute("data-slide-index",String(b)),e.appendChild(a),a})};var F=(e,t,l,i)=>{if(t.autoScrollAnimationId!==null)return;t.autoScrollPaused=false,t.autoScrollStopped=false,t.autoScrollLastTimestamp=performance.now();let o=e.autoScrollSpeed??50,c=e.autoScrollDirection??"forward",r=n=>{if(t.autoScrollPaused||t.autoScrollStopped){t.autoScrollAnimationId=null;return}let d=n-t.autoScrollLastTimestamp;t.autoScrollLastTimestamp=n,d>100&&(d=100);let u=o*(d/1e3);c==="backward"&&(u=-u),i?e.feed.scrollTop+=u:e.feed.scrollLeft+=u,He(e,l,i,c),t.autoScrollAnimationId=requestAnimationFrame(r);};t.autoScrollAnimationId=requestAnimationFrame(r);},He=(e,t,l,i)=>{if(!t.initialized||t.realSlides.length===0)return;let o=e.feed,c=l?o.scrollTop:o.scrollLeft,r=t.realSlides[0],n=t.realSlides[t.realSlides.length-1];if(!(!r||!n))if(i==="forward"){let d=t.forwardResetThreshold;if(c>=d){let u=c-d,m=l?r.offsetTop:r.offsetLeft;l?o.scrollTop=m+u:o.scrollLeft=m+u;}}else {let d=t.backwardResetThreshold;if(c<d){let u=l?n.offsetTop:n.offsetLeft,m;if(c<=0)m=u;else {let b=c-d;m=u+b,m<d&&(m=d);}l?o.scrollTop=m:o.scrollLeft=m;}}},K=e=>{e.autoScrollAnimationId!==null&&(cancelAnimationFrame(e.autoScrollAnimationId),e.autoScrollAnimationId=null),e.autoScrollResumeTimeout!==null&&(clearTimeout(e.autoScrollResumeTimeout),e.autoScrollResumeTimeout=null);},z=e=>{e.autoScrollPaused=true,e.autoScrollAnimationId!==null&&(cancelAnimationFrame(e.autoScrollAnimationId),e.autoScrollAnimationId=null);},U=(e,t,l,i)=>{t.autoScrollStopped||(t.autoScrollLastTimestamp=performance.now(),t.autoScrollPaused=false,t.autoScrollAnimationId===null&&F(e,t,l,i));},W=(e,t,l,i)=>{if(t.autoScrollStopped)return;t.autoScrollResumeTimeout!==null&&clearTimeout(t.autoScrollResumeTimeout);let o=e.autoScrollStartDelay??0;o>0?t.autoScrollResumeTimeout=setTimeout(()=>{t.autoScrollResumeTimeout=null,U(e,t,l,i);},o):U(e,t,l,i);},ce=(e,t,l,i,o)=>{if(!e.autoScroll)return;let c=e.stopOnMouseEnter!==false,r=e.stopOnFocusIn!==false;c&&(e.feed.addEventListener("mouseenter",()=>z(t),{signal:o}),e.feed.addEventListener("mouseleave",()=>W(e,t,l,i),{signal:o})),r&&(e.feed.addEventListener("focusin",()=>z(t),{signal:o}),e.feed.addEventListener("focusout",()=>W(e,t,l,i),{signal:o})),e.feed.addEventListener("touchstart",()=>z(t),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>W(e,t,l,i),{signal:o});};var de=e=>({initialized:false,clonedSlides:[],realSlides:[...e],clonesPerSide:0,forwardResetThreshold:0,backwardResetThreshold:0}),Ce=(e,t)=>{let l=P()?e.desktopSlidesPerView:e.mobileSlidesPerView;if(e.autoScroll){let i=e.slides,o=e.feed,c=e.slideGap??0,r=t?o.clientHeight:o.clientWidth,n=0;for(let b of i)n+=t?b.offsetHeight:b.offsetWidth;let d=i.length>0?(n+c*(i.length-1))/i.length:0,u=d>0?Math.ceil(r/d)+1:i.length,m=Math.max(u,i.length*2);return Math.max(m,1)}return !l||l==="auto"?1:Math.ceil(l)},Q=(e,t,l)=>{if(!e.loop||t.initialized)return;let i=t.realSlides,o=Ce(e,l);t.clonesPerSide=o;let c=e.slideGap??0;for(let r=o-1;r>=0;r--){let n=r%i.length,d=i[n];if(!d)continue;let u=d.cloneNode(true);u.setAttribute("data-lazer-clone","prepend"),u.setAttribute("data-lazer-clone-source",String(n)),u.setAttribute("aria-hidden","true"),e.feed.insertBefore(u,e.feed.firstChild),t.clonedSlides.push(u);}for(let r=0;r<o;r++){let n=r%i.length,d=i[n];if(!d)continue;let u=d.cloneNode(true);u.setAttribute("data-lazer-clone","append"),u.setAttribute("data-lazer-clone-source",String(n)),u.setAttribute("aria-hidden","true"),e.feed.appendChild(u),t.clonedSlides.push(u);}requestAnimationFrame(()=>{let r=i[0],n=i[i.length-1];if(r&&n){let d=l?n.offsetHeight:n.offsetWidth;l?(e.feed.scrollTop=r.offsetTop,t.forwardResetThreshold=n.offsetTop+d+c,t.backwardResetThreshold=r.offsetTop):(e.feed.scrollLeft=r.offsetLeft,t.forwardResetThreshold=n.offsetLeft+d+c,t.backwardResetThreshold=r.offsetLeft);}}),t.initialized=true;},ue=(e,t,l)=>{if(!t.initialized||t.realSlides.length===0)return;let i=t.realSlides[0],o=t.realSlides[t.realSlides.length-1],c=e.slideGap??0;if(i&&o){let r=l?o.offsetHeight:o.offsetWidth;l?(t.forwardResetThreshold=o.offsetTop+r+c,t.backwardResetThreshold=i.offsetTop):(t.forwardResetThreshold=o.offsetLeft+r+c,t.backwardResetThreshold=i.offsetLeft);}},fe=(e,t,l,i,o,c,r)=>{if(!t.loop||!l.initialized)return;c(true);let n=l.realSlides,d=n.length;if(e==="next"){let u=n[0];u&&(i?t.feed.scrollTop=u.offsetTop:t.feed.scrollLeft=u.offsetLeft),o(0);}else {let u=n[d-1];u&&(i?t.feed.scrollTop=u.offsetTop:t.feed.scrollLeft=u.offsetLeft),o(d-1);}requestAnimationFrame(()=>{requestAnimationFrame(()=>{c(false),r();});});},me=e=>{e.initialized&&(e.clonedSlides.forEach(t=>{t.remove();}),e.clonedSlides=[],e.initialized=false,e.clonesPerSide=0,e.forwardResetThreshold=0,e.backwardResetThreshold=0);};var J=(e,t,l)=>{if(t.autoplayIntervalId)return;let i=e.autoplayInterval??3e3;t.autoplayIntervalId=setInterval(()=>{t.autoplayPaused||l("next");},i);},Z=e=>{e.autoplayIntervalId&&(clearInterval(e.autoplayIntervalId),e.autoplayIntervalId=null);},Se=e=>{e.autoplayPaused=true;},pe=e=>{e.autoplayPaused=false;},he=(e,t,l)=>{!e.autoplay||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>Se(t),{signal:l}),e.feed.addEventListener("mouseleave",()=>pe(t),{signal:l}),e.feed.addEventListener("touchstart",()=>Se(t),{passive:true,signal:l}),e.feed.addEventListener("touchend",()=>pe(t),{signal:l}));};var ee=(e,t,l)=>{if(e.scrollbarThumb)if(l){let i=t.height/e.feed.scrollHeight*100;e.scrollbarThumb.style.height=`${i}%`,e.scrollbarThumb.style.width="";}else {let i=t.width/e.feed.scrollWidth*100;e.scrollbarThumb.style.width=`${i}%`,e.scrollbarThumb.style.height="";}},be=(e,t)=>{if(!(!e.scrollbarThumb||!e.scrollbarTrack))if(t){let l=e.scrollbarTrack.getBoundingClientRect().height,i=e.scrollbarThumb.getBoundingClientRect().height,o=l-i,c=e.feed.scrollHeight-e.feed.clientHeight,r=c>0?e.feed.scrollTop/c:0;e.scrollbarThumb.style.transform=`translateY(${o*r}px)`;}else {let l=e.scrollbarTrack.getBoundingClientRect().width,i=e.scrollbarThumb.getBoundingClientRect().width,o=l-i,c=e.feed.scrollWidth-e.feed.clientWidth,r=c>0?e.feed.scrollLeft/c:0;e.scrollbarThumb.style.transform=`translateX(${o*r}px)`;}};var te=(e,t,l,i=k,o,c)=>{let r=l?e.scrollTop:e.scrollLeft,n=Math.abs(t-r),d=Math.min(w.MAX_DURATION,Math.max(w.MIN_DURATION,n/w.SPEED_FACTOR)),u=performance.now(),m=b=>{if(c?.cancelled)return;let a=(b-u)/d,p=Math.min(a,1),L=i(p),E=r+(t-r)*L;l?e.scrollTop=E:e.scrollLeft=E,p<1?requestAnimationFrame(m):(l?e.scrollTop=t:e.scrollLeft=t,o?.());};requestAnimationFrame(m);},Y=e=>e.filter(t=>t.offsetParent!==null),oe=(e,t,l)=>{let i=l?e.desktopSlidesPerView:e.mobileSlidesPerView,o=e.slideGap??0;if(o>0&&(e.feed.style.gap=`${o}px`),!i||i==="auto"){e.slides.forEach(n=>{n.style.flex="0 0 auto",n.style.minWidth="",n.style.minHeight="";});return}let r=`calc((100% - ${o*(i-1)}px) / ${i})`;t?e.slides.forEach(n=>{n.style.flex=`0 0 ${r}`,n.style.minHeight=r,n.style.minWidth="";}):e.slides.forEach(n=>{n.style.flex=`0 0 ${r}`,n.style.minWidth=r,n.style.minHeight="";});},Te=(e,t,l,i)=>{let o=i?e.clientHeight:e.clientWidth;return !t||l!==o?{rect:e.getBoundingClientRect(),size:o}:{rect:t,size:l}};var Oe=e=>{if(!e.feed)throw new Error("lazer-slider: feed element is required");if(!e.slides?.length)throw new Error("lazer-slider: slides array is required and must not be empty");if(e.feed.id||(e.feed.id=`lazer-slider-feed-${Math.random().toString(36).substr(2,9)}`),e.bulletsContainer&&!e.thumbs){let s=V({bulletsContainer:e.bulletsContainer,slides:e.slides,bulletClass:e.bulletsClass??"slider-bullet",bulletActiveClass:e.bulletsActiveClass??"active",feedId:e.feed.id});e.thumbs=s;}if(e.thumbsContainer&&!e.thumbs){let s=j({thumbsContainer:e.thumbsContainer,slides:e.slides,thumbClass:e.thumbsClass??"slider-thumb",thumbActiveClass:e.thumbsActiveClass??"active",feedId:e.feed.id,thumbImageSelector:e.thumbImageSelector??"img",thumbSize:e.thumbSize});e.thumbs=s;}let t=e.direction??"horizontal",l=t==="vertical",i=e.easing??k,o={currentSlideIndex:0,isScrolling:false,ticking:false,cachedFeedRect:null,lastWidth:0,updateThumbTimeout:null,scrollEndTimeout:null,abortController:new AbortController,autoplayIntervalId:null,autoplayPaused:false,autoScrollAnimationId:null,autoScrollPaused:false,autoScrollLastTimestamp:0,autoScrollStopped:false,autoScrollResumeTimeout:null,isLoopRepositioning:false},c=null,r=de(e.slides),n={cancelled:false},d=null,u=()=>{let s=Te(e.feed,o.cachedFeedRect,o.lastWidth,l);return o.cachedFeedRect=s.rect,o.lastWidth=s.size,s.rect},m=(s,f)=>{te(e.feed,s,l,i,f);},b=(s,f)=>{n.cancelled=true,n={cancelled:false},te(e.feed,s,l,f??i,void 0,n);},a=()=>{if(o.isLoopRepositioning)return;let s=u(),f,T,h;if(l?(f=e.feed.scrollTop<=1,T=e.feed.scrollTop+s.height>=e.feed.scrollHeight-1,h=e.feed.scrollHeight<=s.height):(f=e.feed.scrollLeft<=1,T=e.feed.scrollLeft+s.width>=e.feed.scrollWidth-1,h=e.feed.scrollWidth<=s.width),e.scrollbarTrack&&(e.scrollbarTrack.style.display=h?"none":"block"),e.loop){B(e.prevSlideButton,!h,e.feed),B(e.nextSlideButton,!h,e.feed);return}B(e.prevSlideButton,!f&&!h,e.feed),B(e.nextSlideButton,!T&&!h,e.feed);},p=()=>{let s=u(),f=r.initialized?r.realSlides:Y(e.slides),T=f.filter(h=>{let S=h.getBoundingClientRect(),v=20;return l?S.bottom>s.top+v&&S.top<s.bottom-v:S.right>s.left+v&&S.left<s.right-v});if(T.length&&T[0]){let h=f.indexOf(T[0]);if(h!==-1){o.currentSlideIndex=h;let S=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScroll?.({currentScroll:S,currentSlideIndex:o.currentSlideIndex});}}},L=s=>{if(!e.thumbs)return;let f=e.thumbs.indexOf(s);if(f===-1||!e.slides[f])return;o.currentSlideIndex=f,N(e.thumbs,f),o.isScrolling=true,o.updateThumbTimeout&&clearTimeout(o.updateThumbTimeout),o.updateThumbTimeout=setTimeout(()=>{o.isScrolling=false;},w.THUMB_UPDATE_DELAY);let T=l?e.slides[f].offsetTop:e.slides[f].offsetLeft;m(T);},E=s=>{let f=r.initialized?r.realSlides:Y(e.slides),T=P()?e.desktopSlidesPerScroll??1:e.mobileSlidesPerScroll??1,h=f.length;p();let S,v=false;if(s==="prev"?e.loop&&r.initialized&&o.currentSlideIndex===0?(S=f[0]?.previousElementSibling,v=!!S?.hasAttribute("data-lazer-clone")):(o.currentSlideIndex=Math.max(0,o.currentSlideIndex-T),S=f[o.currentSlideIndex]):e.loop&&r.initialized&&o.currentSlideIndex>=h-1?(S=f[h-1]?.nextElementSibling,v=!!S?.hasAttribute("data-lazer-clone")):(o.currentSlideIndex=Math.min(h-1,o.currentSlideIndex+T),S=f[o.currentSlideIndex]),!S)return;let y=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollStart?.({currentScroll:y,target:S,direction:s});let D=l?S.offsetTop:S.offsetLeft;v?m(D,()=>{fe(s,e,r,l,I=>{o.currentSlideIndex=I;},I=>{o.isLoopRepositioning=I;},a);}):m(D);},C=()=>{be(e,l),a(),p(),o.isScrolling||N(e.thumbs,o.currentSlideIndex),o.scrollEndTimeout&&clearTimeout(o.scrollEndTimeout),o.scrollEndTimeout=setTimeout(()=>{o.isScrolling=false;let s=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollEnd?.({currentScroll:s,currentSlideIndex:o.currentSlideIndex});},w.SCROLL_END_DELAY);},$=()=>{o.ticking||(requestAnimationFrame(()=>{C(),o.ticking=false;}),o.ticking=true);},_=()=>{let s=o.currentSlideIndex;o.cachedFeedRect=null;let f=()=>{let h=(r.initialized?r.realSlides:Y(e.slides))[s];if(h){let S=l?h.offsetTop:h.offsetLeft;l?e.feed.scrollTop=S:e.feed.scrollLeft=S;}};f(),d&&clearTimeout(d),d=setTimeout(()=>{A(),f();},150);},G=()=>{let{signal:s}=o.abortController;window.addEventListener("resize",_),e.feed.addEventListener("scroll",$,{passive:true,signal:s}),e.prevSlideButton&&e.prevSlideButton.addEventListener("click",()=>E("prev"),{signal:s}),e.nextSlideButton&&e.nextSlideButton.addEventListener("click",()=>E("next"),{signal:s}),e.thumbs?.length&&(e.thumbs[0]?.classList.add("active"),e.thumbs.forEach(f=>{f.addEventListener("click",()=>L(f),{signal:s});})),re(e.feed,()=>E("prev"),()=>E("next"),s,t),e.enableDragToScroll!==false&&(c=ae({feed:e.feed,slides:e.slides,abortSignal:s,smoothScrollTo:b,onDragStart:()=>{e.autoScroll&&z(o);},onDragEnd:f=>{if(!!(f?.getAttribute("data-lazer-clone")&&e.loop&&r.initialized)&&f){let S=r.realSlides,v=f.getAttribute("data-lazer-clone-source"),y=v!==null?Math.max(0,Math.min(parseInt(v,10),S.length-1)):0,D=S[y];if(D){o.currentSlideIndex=y;let I=l?D.offsetTop:D.offsetLeft;setTimeout(()=>{n.cancelled=true,l?e.feed.scrollTop=I:e.feed.scrollLeft=I;},w.MIN_DURATION),N(e.thumbs,o.currentSlideIndex);}}else p(),N(e.thumbs,o.currentSlideIndex);e.autoScroll&&!o.autoScrollStopped&&(e.stopOnInteraction?o.autoScrollStopped=true:W(e,o,r,l));},direction:t,loop:e.loop})),he(e,o,s),ce(e,o,r,l,s);},O=s=>{let f=r.initialized?r.realSlides:Y(e.slides),T=Math.max(0,Math.min(s,f.length-1)),h=f[T];if(!h)return;o.currentSlideIndex=T,N(e.thumbs,T);let S=l?h.offsetTop:h.offsetLeft;m(S);},A=()=>{o.cachedFeedRect=null,oe(e,l,P()),ee(e,u(),l),a(),e.autoScroll&&r.initialized&&(ue(e,r,l),!o.autoScrollPaused&&!o.autoScrollStopped&&(K(o),F(e,o,r,l)));},x=()=>{Z(o),K(o),o.abortController.abort(),window.removeEventListener("resize",_),o.updateThumbTimeout&&clearTimeout(o.updateThumbTimeout),o.scrollEndTimeout&&clearTimeout(o.scrollEndTimeout),d&&clearTimeout(d),c&&se(c),me(r),e.feed.style.scrollBehavior="",e.feed.style.scrollSnapType="",e.feed.removeAttribute("data-lazer-autoscroll"),o.cachedFeedRect=null;},R=()=>{e.autoScroll?(o.autoScrollStopped=false,o.autoScrollPaused?U(e,o,r,l):F(e,o,r,l)):e.autoplay&&J(e,o,E);},g=()=>{e.autoScroll?z(o):Z(o);};if(le(e),oe(e,l,P()),e.autoScroll){e.loop=true,Q(e,r,l),e.feed.style.scrollBehavior="auto",e.feed.style.scrollSnapType="none",e.feed.setAttribute("data-lazer-autoscroll",""),r.clonedSlides.forEach(f=>{f.style.flex="0 0 auto";});let s=e.autoScrollStartDelay??0;s>0?o.autoScrollResumeTimeout=setTimeout(()=>{o.autoScrollResumeTimeout=null,F(e,o,r,l);},s):requestAnimationFrame(()=>{requestAnimationFrame(()=>{F(e,o,r,l);});});}else Q(e,r,l),e.autoplay&&J(e,o,E);return a(),G(),ee(e,u(),l),{goToIndex:O,refresh:A,unload:x,play:R,pause:g,next:()=>E("next"),prev:()=>E("prev")}};exports.createSlider=Oe;exports.easeInOutCubic=Le;exports.easeOutCubic=H;exports.easeOutExpo=k;exports.easeOutQuad=Ae;exports.generateBullets=V;exports.generateThumbs=j;exports.linear=ye;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var H={MIN_DURATION:400,MAX_DURATION:1e3,SPEED_FACTOR:1.5,SCROLL_END_DELAY:50,THUMB_UPDATE_DELAY:500},ve="(min-width: 64rem)",N=()=>window.matchMedia(ve).matches;var k=e=>e===1?1:1-Math.pow(2,-10*e),w=e=>1-Math.pow(1-e,3),Ee=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Le=e=>1-(1-e)*(1-e),Ae=e=>e;var ye=()=>`slider-${Math.random().toString(36).substring(2,9)}`,le=e=>{let{feed:t,prevSlideButton:l,nextSlideButton:i,thumbs:o,slides:c}=e;t.id||(t.id=ye()),t.setAttribute("role","region"),t.setAttribute("aria-label","Carousel"),t.setAttribute("aria-roledescription","carousel"),t.removeAttribute("tabindex"),c.forEach((r,a)=>{r.setAttribute("role","group"),r.setAttribute("aria-roledescription","slide"),r.setAttribute("aria-label",`Slide ${a+1} of ${c.length}`);}),l&&(l.setAttribute("aria-label","Previous slide"),l.setAttribute("aria-controls",t.id),l.setAttribute("tabindex","0"),l.tagName!=="BUTTON"&&l.setAttribute("role","button")),i&&(i.setAttribute("aria-label","Next slide"),i.setAttribute("aria-controls",t.id),i.setAttribute("tabindex","0"),i.tagName!=="BUTTON"&&i.setAttribute("role","button")),o?.length&&o.forEach((r,a)=>{r.tagName!=="BUTTON"&&r.setAttribute("role","button"),r.setAttribute("aria-label",`Go to slide ${a+1}`),r.setAttribute("tabindex","0"),r.setAttribute("aria-controls",t.id);});},W=(e,t,l)=>{if(!e)return;!t&&e===document.activeElement&&l&&l.focus();let i="opacity 0.3s ease",o=t?"1":"0";Object.assign(e.style,{opacity:o,transition:i,pointerEvents:t?"auto":"none"}),t?(e.removeAttribute("aria-hidden"),e.setAttribute("tabindex","0")):(e.setAttribute("aria-hidden","true"),e.setAttribute("tabindex","-1")),t?e.style.visibility="visible":setTimeout(()=>{e.style.opacity==="0"&&(e.style.visibility="hidden");},300);},F=(e,t,l="active")=>{e?.length&&e.forEach((i,o)=>{let c=o===t;i.classList.toggle(l,c),i.setAttribute("aria-selected",c.toString());});},re=(e,t,l,i,o="horizontal")=>{let c=o==="vertical",r=c?"ArrowUp":"ArrowLeft",a=c?"ArrowDown":"ArrowRight";e.addEventListener("keydown",u=>{switch(u.key){case r:u.preventDefault(),t();break;case a:u.preventDefault(),l();break}},{signal:i}),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");};var D={FRICTION:.94,MIN_VELOCITY:.3,MOMENTUM_RATIO:.8,VELOCITY_SMOOTHING:.4,EDGE_RESISTANCE:.3,MAX_EDGE_OVERSCROLL:100,SHORT_SWIPE_VELOCITY:.5,BOUNCE_DURATION:400},ge=()=>({isDragging:false,startX:0,startY:0,startScrollLeft:0,startScrollTop:0,velocity:0,lastX:0,lastY:0,lastTime:0,momentumId:null}),xe=()=>({...ge(),velocityHistory:[],dragDistance:0,dragStartTime:0}),$=(e,t,l="horizontal")=>{let i=e.getBoundingClientRect(),o=l==="vertical",c=o?i.top:i.left,r=null,a=1/0;for(let u of t){if(u.offsetParent===null)continue;let f=u.getBoundingClientRect(),p=o?f.top:f.left,E=Math.abs(c-p);E<a&&(a=E,r=u);}return r},Ie=(e,t,l,i="horizontal")=>{let o=e.getBoundingClientRect(),c=i==="vertical",r=c?o.top:o.left,a=t.filter(n=>n.offsetParent!==null);if(a.length===0)return null;let u=0,f=1/0;a.forEach((n,S)=>{let L=n.getBoundingClientRect(),v=c?L.top:L.left,O=Math.abs(r-v);O<f&&(f=O,u=S);});let p=2,E=u;return Math.abs(l)>p&&(l>0?E=Math.min(u+1,a.length-1):E=Math.max(u-1,0)),a[E]??null},Me=e=>{if(e.length===0)return 0;let t=0,l=0;return e.forEach((i,o)=>{let c=o+1;t+=i*c,l+=c;}),t/l},De=(e,t,l,i,o,c="horizontal",r=false)=>{let a=c==="vertical",u=e.velocity*D.MOMENTUM_RATIO,f=()=>{if(Math.abs(u)<D.MIN_VELOCITY){e.momentumId=null;let S=$(t,l,c);if(S){let L=a?S.offsetTop:S.offsetLeft;i(L,w);}o?.(S);return}let p=a?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,n=(a?t.scrollTop:t.scrollLeft)+u;r||(n<0||n>p)&&(u*=.5),a?t.scrollTop=Math.max(0,Math.min(p,n)):t.scrollLeft=Math.max(0,Math.min(p,n)),u*=D.FRICTION,e.momentumId=requestAnimationFrame(f);};e.momentumId=requestAnimationFrame(f);},ie=e=>"touches"in e?e.touches[0]?.clientX??0:e.clientX,ne=e=>"touches"in e?e.touches[0]?.clientY??0:e.clientY,Ce=(e,t)=>t==="vertical"?ne(e):ie(e),ae=e=>{let {feed:t,slides:l,abortSignal:i,smoothScrollTo:o,onDragStart:c,onDragEnd:r,direction:a="horizontal",loop:u=false,touchRatio:f=1,shortSwipeThreshold:p=300,swipeDistanceThreshold:E=10}=e,n=xe(),S=a==="vertical",L=()=>{if(!u)return l;let A=[],M=t.children;for(let C=0;C<M.length;C++){let x=M[C];(l.includes(x)||x.hasAttribute("data-lazer-clone"))&&A.push(x);}return A.length>0?A:l},v=0,U=()=>{v=S?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,S?t.clientHeight:t.clientWidth;},B=A=>{n.momentumId!==null&&(cancelAnimationFrame(n.momentumId),n.momentumId=null),U(),c?.(),n.isDragging=true,n.startX=ie(A),n.startY=ne(A),n.startScrollLeft=t.scrollLeft,n.startScrollTop=t.scrollTop,n.velocity=0,n.lastX=n.startX,n.lastY=n.startY,n.lastTime=performance.now(),n.velocityHistory=[],n.dragDistance=0,n.dragStartTime=performance.now(),t.style.userSelect="none",t.style.cursor="grabbing",t.classList.add("is-dragging"),A.type==="mousedown"&&A.preventDefault();},X=A=>{if(!n.isDragging)return;let M=Ce(A,a),C=S?n.startY:n.startX,x=S?n.lastY:n.lastX,s=S?n.startScrollTop:n.startScrollLeft,d=performance.now(),b=d-n.lastTime,h=(C-M)*f,m=s+h;if(n.dragDistance=Math.abs(h),!u){if(m<0){let T=Math.abs(m),y=1-Math.min(T/D.MAX_EDGE_OVERSCROLL,1)*(1-D.EDGE_RESISTANCE);m=-T*y;}else if(m>v){let T=m-v,y=1-Math.min(T/D.MAX_EDGE_OVERSCROLL,1)*(1-D.EDGE_RESISTANCE);m=v+T*y;}}if(S?t.scrollTop=m:t.scrollLeft=m,b>0){let T=(x-M)/b*16;if(n.velocityHistory.length>0){let y=n.velocity;n.velocity=y*(1-D.VELOCITY_SMOOTHING)+T*D.VELOCITY_SMOOTHING;}else n.velocity=T;n.velocityHistory.push(T),n.velocityHistory.length>5&&n.velocityHistory.shift();}S?n.lastY=M:n.lastX=M,n.lastTime=d,A.type==="touchmove"&&A.preventDefault();},P=()=>{if(!n.isDragging)return;n.isDragging=false,t.style.userSelect="",t.style.cursor="",t.classList.remove("is-dragging");let M=performance.now()-n.dragStartTime<p&&n.dragDistance>E,C=Me(n.velocityHistory),x=L();if(!u){let s=S?t.scrollTop:t.scrollLeft;if(s<0||s>v){let d=s<0?0:v,b=s,h=performance.now(),m=()=>{let T=performance.now()-h,y=Math.min(T/D.BOUNCE_DURATION,1),R=w(y),g=b+(d-b)*R;if(S?t.scrollTop=g:t.scrollLeft=g,y<1)requestAnimationFrame(m);else {let I=$(t,x,a);if(I){let Te=S?I.offsetTop:I.offsetLeft;o(Te,w);}r?.(I);}};requestAnimationFrame(m);return}}if(M||Math.abs(C)>D.SHORT_SWIPE_VELOCITY){let s=Ie(t,x,C,a);if(s){let d=S?s.offsetTop:s.offsetLeft;o(d,w),r?.(s);}else r?.(null);}else if(Math.abs(n.velocity)>1&&!n.isLoopDragHandled)De(n,t,x,o,r,a,u);else {let s=$(t,x,a);if(!n.isLoopDragHandled){if(s){let d=S?s.offsetTop:s.offsetLeft;o(d,w);}r?.(s);}}};return t.addEventListener("mousedown",B,{signal:i}),document.addEventListener("mousemove",X,{signal:i}),document.addEventListener("mouseup",P,{signal:i}),t.addEventListener("touchstart",B,{passive:true,signal:i}),t.addEventListener("touchmove",X,{passive:false,signal:i}),t.addEventListener("touchend",P,{signal:i}),t.addEventListener("touchcancel",P,{signal:i}),document.addEventListener("mouseleave",P,{signal:i}),t.style.cursor="grab",n},ce=e=>{e.momentumId!==null&&(cancelAnimationFrame(e.momentumId),e.momentumId=null);};var q=({bulletsContainer:e,slides:t,bulletClass:l,bulletActiveClass:i,feedId:o})=>{if(!e||!(e instanceof HTMLElement))throw new Error("Invalid bulletsContainer: must be a valid HTMLElement");if(!Array.isArray(t)||t.length===0)throw new Error("Invalid slides: must be a non-empty array");if(!o||typeof o!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!l||typeof l!="string")throw new Error("Invalid bulletClass: must be a non-empty string");e.innerHTML="",e.setAttribute("role","tablist"),e.setAttribute("aria-label","Slide navigation");let c=t.map((a,u)=>({slide:a,originalIndex:u})).filter(({slide:a})=>a.offsetParent!==null);return c.length===0?(console.warn("No visible slides found"),[]):c.map(({slide:a,originalIndex:u},f)=>{let p=document.createElement("button");return p.type="button",p.classList.add(l),f===0&&p.classList.add(i),p.setAttribute("role","tab"),p.setAttribute("aria-selected",f===0?"true":"false"),p.setAttribute("aria-controls",o),p.setAttribute("aria-label",`Go to slide ${f+1}`),p.setAttribute("data-slide-index",String(f)),e.appendChild(p),p})};var j=({thumbsContainer:e,slides:t,thumbClass:l,thumbActiveClass:i,feedId:o,thumbImageSelector:c="img",thumbSize:r})=>{if(!e||!(e instanceof HTMLElement))throw new Error("Invalid thumbsContainer: must be a valid HTMLElement");if(!Array.isArray(t)||t.length===0)throw new Error("Invalid slides: must be a non-empty array");if(!o||typeof o!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!l||typeof l!="string")throw new Error("Invalid thumbClass: must be a non-empty string");e.innerHTML="",e.setAttribute("role","tablist"),e.setAttribute("aria-label","Slide thumbnails");let a=t.map((f,p)=>({slide:f,originalIndex:p})).filter(({slide:f})=>f.offsetParent!==null);return a.length===0?(console.warn("No visible slides found"),[]):a.map(({slide:f,originalIndex:p},E)=>{let n=document.createElement("button");n.type="button",n.classList.add(l),E===0&&n.classList.add(i);let S=f.querySelector(c);if(S?.src){let L=document.createElement("img");L.src=S.src,L.alt=S.alt||`Slide ${E+1} thumbnail`,L.draggable=false,r&&(L.style.width=`${r.width}px`,L.style.height=`${r.height}px`,L.style.objectFit="cover"),n.appendChild(L);}return n.setAttribute("role","tab"),n.setAttribute("aria-selected",E===0?"true":"false"),n.setAttribute("aria-controls",o),n.setAttribute("aria-label",`Go to slide ${E+1}`),n.setAttribute("data-slide-index",String(E)),e.appendChild(n),n})};var _=(e,t,l,i)=>{if(t.autoScrollAnimationId!==null)return;t.autoScrollPaused=false,t.autoScrollStopped=false,t.autoScrollLastTimestamp=performance.now();let o=e.autoScrollSpeed??50,c=e.autoScrollDirection??"forward",r=a=>{if(t.autoScrollPaused||t.autoScrollStopped){t.autoScrollAnimationId=null;return}let u=a-t.autoScrollLastTimestamp;t.autoScrollLastTimestamp=a,u>100&&(u=100);let f=o*(u/1e3);c==="backward"&&(f=-f),i?e.feed.scrollTop+=f:e.feed.scrollLeft+=f,Re(e,l,i,c),t.autoScrollAnimationId=requestAnimationFrame(r);};t.autoScrollAnimationId=requestAnimationFrame(r);},Re=(e,t,l,i)=>{if(!t.initialized||t.realSlides.length===0)return;let o=e.feed;if(i==="forward"){let c=l?o.scrollHeight-o.clientHeight:o.scrollWidth-o.clientWidth;if((l?o.scrollTop:o.scrollLeft)>=c-1){let a=t.realSlides[0];a&&(l?o.scrollTop=a.offsetTop:o.scrollLeft=a.offsetLeft);}}else if((l?o.scrollTop:o.scrollLeft)<=1){let r=t.realSlides[t.realSlides.length-1];r&&(l?o.scrollTop=r.offsetTop:o.scrollLeft=r.offsetLeft);}},K=e=>{e.autoScrollAnimationId!==null&&(cancelAnimationFrame(e.autoScrollAnimationId),e.autoScrollAnimationId=null),e.autoScrollResumeTimeout!==null&&(clearTimeout(e.autoScrollResumeTimeout),e.autoScrollResumeTimeout=null);},z=e=>{e.autoScrollPaused=true,e.autoScrollAnimationId!==null&&(cancelAnimationFrame(e.autoScrollAnimationId),e.autoScrollAnimationId=null);},G=(e,t,l,i)=>{t.autoScrollStopped||(t.autoScrollLastTimestamp=performance.now(),t.autoScrollPaused=false,t.autoScrollAnimationId===null&&_(e,t,l,i));},Y=(e,t,l,i)=>{if(t.autoScrollStopped)return;t.autoScrollResumeTimeout!==null&&clearTimeout(t.autoScrollResumeTimeout);let o=e.autoScrollStartDelay??0;o>0?t.autoScrollResumeTimeout=setTimeout(()=>{t.autoScrollResumeTimeout=null,G(e,t,l,i);},o):G(e,t,l,i);},se=(e,t,l,i,o)=>{if(!e.autoScroll)return;let c=e.stopOnMouseEnter!==false,r=e.stopOnFocusIn!==false;c&&(e.feed.addEventListener("mouseenter",()=>z(t),{signal:o}),e.feed.addEventListener("mouseleave",()=>Y(e,t,l,i),{signal:o})),r&&(e.feed.addEventListener("focusin",()=>z(t),{signal:o}),e.feed.addEventListener("focusout",()=>Y(e,t,l,i),{signal:o})),e.feed.addEventListener("touchstart",()=>z(t),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>Y(e,t,l,i),{signal:o});};var de=e=>({initialized:false,clonedSlides:[],realSlides:[...e],clonesPerSide:0}),He=e=>{let t=N()?e.desktopSlidesPerView:e.mobileSlidesPerView;if(e.autoScroll){let l=!t||t==="auto"?3:Math.ceil(t)+1;return Math.min(l,e.slides.length)}return !t||t==="auto"?1:Math.ceil(t)},Q=(e,t,l)=>{if(!e.loop||t.initialized)return;let i=t.realSlides,o=He(e);t.clonesPerSide=o;for(let c=i.length-o;c<i.length;c++){let r=i[c];if(!r)continue;let a=r.cloneNode(true);a.setAttribute("data-lazer-clone","prepend"),a.setAttribute("aria-hidden","true"),e.feed.insertBefore(a,e.feed.firstChild),t.clonedSlides.push(a);}for(let c=0;c<o;c++){let r=i[c];if(!r)continue;let a=r.cloneNode(true);a.setAttribute("data-lazer-clone","append"),a.setAttribute("aria-hidden","true"),e.feed.appendChild(a),t.clonedSlides.push(a);}requestAnimationFrame(()=>{let c=i[0];c&&(l?e.feed.scrollTop=c.offsetTop:e.feed.scrollLeft=c.offsetLeft);}),t.initialized=true;},ue=(e,t,l,i,o,c,r)=>{if(!t.loop||!l.initialized)return;c(true);let a=l.realSlides,u=a.length;if(e==="next"){let f=a[0];f&&(i?t.feed.scrollTop=f.offsetTop:t.feed.scrollLeft=f.offsetLeft),o(0);}else {let f=a[u-1];f&&(i?t.feed.scrollTop=f.offsetTop:t.feed.scrollLeft=f.offsetLeft),o(u-1);}requestAnimationFrame(()=>{requestAnimationFrame(()=>{c(false),r();});});},fe=e=>{e.initialized&&(e.clonedSlides.forEach(t=>{t.remove();}),e.clonedSlides=[],e.initialized=false,e.clonesPerSide=0);};var J=(e,t,l)=>{if(t.autoplayIntervalId)return;let i=e.autoplayInterval??3e3;t.autoplayIntervalId=setInterval(()=>{t.autoplayPaused||l("next");},i);},Z=e=>{e.autoplayIntervalId&&(clearInterval(e.autoplayIntervalId),e.autoplayIntervalId=null);},me=e=>{e.autoplayPaused=true;},pe=e=>{e.autoplayPaused=false;},Se=(e,t,l)=>{!e.autoplay||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>me(t),{signal:l}),e.feed.addEventListener("mouseleave",()=>pe(t),{signal:l}),e.feed.addEventListener("touchstart",()=>me(t),{passive:true,signal:l}),e.feed.addEventListener("touchend",()=>pe(t),{signal:l}));};var ee=(e,t,l)=>{if(e.scrollbarThumb)if(l){let i=t.height/e.feed.scrollHeight*100;e.scrollbarThumb.style.height=`${i}%`,e.scrollbarThumb.style.width="";}else {let i=t.width/e.feed.scrollWidth*100;e.scrollbarThumb.style.width=`${i}%`,e.scrollbarThumb.style.height="";}},he=(e,t)=>{if(!(!e.scrollbarThumb||!e.scrollbarTrack))if(t){let l=e.scrollbarTrack.getBoundingClientRect().height,i=e.scrollbarThumb.getBoundingClientRect().height,o=l-i,c=e.feed.scrollHeight-e.feed.clientHeight,r=c>0?e.feed.scrollTop/c:0;e.scrollbarThumb.style.transform=`translateY(${o*r}px)`;}else {let l=e.scrollbarTrack.getBoundingClientRect().width,i=e.scrollbarThumb.getBoundingClientRect().width,o=l-i,c=e.feed.scrollWidth-e.feed.clientWidth,r=c>0?e.feed.scrollLeft/c:0;e.scrollbarThumb.style.transform=`translateX(${o*r}px)`;}};var te=(e,t,l,i=k,o,c)=>{let r=l?e.scrollTop:e.scrollLeft,a=Math.abs(t-r),u=Math.min(H.MAX_DURATION,Math.max(H.MIN_DURATION,a/H.SPEED_FACTOR)),f=performance.now(),p=E=>{if(c?.cancelled)return;let n=(E-f)/u,S=Math.min(n,1),L=i(S),v=r+(t-r)*L;l?e.scrollTop=v:e.scrollLeft=v,S<1?requestAnimationFrame(p):(l?e.scrollTop=t:e.scrollLeft=t,o?.());};requestAnimationFrame(p);},V=e=>e.filter(t=>t.offsetParent!==null),oe=(e,t,l)=>{let i=l?e.desktopSlidesPerView:e.mobileSlidesPerView,o=e.slideGap??0;if(o>0&&(e.feed.style.gap=`${o}px`),!i||i==="auto"){e.slides.forEach(a=>{a.style.flex="",a.style.minWidth="",a.style.minHeight="";});return}let r=`calc((100% - ${o*(i-1)}px) / ${i})`;t?e.slides.forEach(a=>{a.style.flex=`0 0 ${r}`,a.style.minHeight=r,a.style.minWidth="";}):e.slides.forEach(a=>{a.style.flex=`0 0 ${r}`,a.style.minWidth=r,a.style.minHeight="";});},be=(e,t,l,i)=>{let o=i?e.clientHeight:e.clientWidth;return !t||l!==o?{rect:e.getBoundingClientRect(),size:o}:{rect:t,size:l}};var we=e=>{if(!e.feed)throw new Error("lazer-slider: feed element is required");if(!e.slides?.length)throw new Error("lazer-slider: slides array is required and must not be empty");if(e.feed.id||(e.feed.id=`lazer-slider-feed-${Math.random().toString(36).substr(2,9)}`),e.bulletsContainer&&!e.thumbs){let s=q({bulletsContainer:e.bulletsContainer,slides:e.slides,bulletClass:e.bulletsClass??"slider-bullet",bulletActiveClass:e.bulletsActiveClass??"active",feedId:e.feed.id});e.thumbs=s;}if(e.thumbsContainer&&!e.thumbs){let s=j({thumbsContainer:e.thumbsContainer,slides:e.slides,thumbClass:e.thumbsClass??"slider-thumb",thumbActiveClass:e.thumbsActiveClass??"active",feedId:e.feed.id,thumbImageSelector:e.thumbImageSelector??"img",thumbSize:e.thumbSize});e.thumbs=s;}let t=e.direction??"horizontal",l=t==="vertical",i=e.easing??k,o={currentSlideIndex:0,isScrolling:false,ticking:false,cachedFeedRect:null,lastWidth:0,updateThumbTimeout:null,scrollEndTimeout:null,abortController:new AbortController,autoplayIntervalId:null,autoplayPaused:false,autoScrollAnimationId:null,autoScrollPaused:false,autoScrollLastTimestamp:0,autoScrollStopped:false,autoScrollResumeTimeout:null,isLoopRepositioning:false},c=null,r=de(e.slides),a={cancelled:false},u=null,f=()=>{let s=be(e.feed,o.cachedFeedRect,o.lastWidth,l);return o.cachedFeedRect=s.rect,o.lastWidth=s.size,s.rect},p=(s,d)=>{te(e.feed,s,l,i,d);},E=(s,d)=>{a.cancelled=true,a={cancelled:false},te(e.feed,s,l,d??i,void 0,a);},n=()=>{if(o.isLoopRepositioning)return;let s=f(),d,b,h;if(l?(d=e.feed.scrollTop<=1,b=e.feed.scrollTop+s.height>=e.feed.scrollHeight-1,h=e.feed.scrollHeight<=s.height):(d=e.feed.scrollLeft<=1,b=e.feed.scrollLeft+s.width>=e.feed.scrollWidth-1,h=e.feed.scrollWidth<=s.width),e.scrollbarTrack&&(e.scrollbarTrack.style.display=h?"none":"block"),e.loop){W(e.prevSlideButton,!h,e.feed),W(e.nextSlideButton,!h,e.feed);return}W(e.prevSlideButton,!d&&!h,e.feed),W(e.nextSlideButton,!b&&!h,e.feed);},S=()=>{let s=f(),d=r.initialized?r.realSlides:V(e.slides),b=d.filter(h=>{let m=h.getBoundingClientRect(),T=20;return l?m.bottom>s.top+T&&m.top<s.bottom-T:m.right>s.left+T&&m.left<s.right-T});if(b.length&&b[0]){let h=d.indexOf(b[0]);if(h!==-1){o.currentSlideIndex=h;let m=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScroll?.({currentScroll:m,currentSlideIndex:o.currentSlideIndex});}}},L=s=>{if(!e.thumbs)return;let d=e.thumbs.indexOf(s);if(d===-1||!e.slides[d])return;o.currentSlideIndex=d,F(e.thumbs,d),o.isScrolling=true,o.updateThumbTimeout&&clearTimeout(o.updateThumbTimeout),o.updateThumbTimeout=setTimeout(()=>{o.isScrolling=false;},H.THUMB_UPDATE_DELAY);let b=l?e.slides[d].offsetTop:e.slides[d].offsetLeft;p(b);},v=s=>{let d=r.initialized?r.realSlides:V(e.slides),b=N()?e.desktopSlidesPerScroll??1:e.mobileSlidesPerScroll??1,h=d.length;S();let m,T=false;if(s==="prev")if(e.loop&&r.initialized&&o.currentSlideIndex===0){let g=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="prepend");m=g[g.length-1],T=true;}else o.currentSlideIndex=Math.max(0,o.currentSlideIndex-b),m=d[o.currentSlideIndex];else e.loop&&r.initialized&&o.currentSlideIndex>=h-1?(m=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="append")[0],T=true):(o.currentSlideIndex=Math.min(h-1,o.currentSlideIndex+b),m=d[o.currentSlideIndex]);if(!m)return;let y=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollStart?.({currentScroll:y,target:m,direction:s});let R=l?m.offsetTop:m.offsetLeft;T?p(R,()=>{ue(s,e,r,l,g=>{o.currentSlideIndex=g;},g=>{o.isLoopRepositioning=g;},n);}):p(R);},O=()=>{he(e,l),n(),S(),o.isScrolling||F(e.thumbs,o.currentSlideIndex),o.scrollEndTimeout&&clearTimeout(o.scrollEndTimeout),o.scrollEndTimeout=setTimeout(()=>{o.isScrolling=false;let s=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollEnd?.({currentScroll:s,currentSlideIndex:o.currentSlideIndex});},H.SCROLL_END_DELAY);},U=()=>{o.ticking||(requestAnimationFrame(()=>{O(),o.ticking=false;}),o.ticking=true);},B=()=>{let s=o.currentSlideIndex;o.cachedFeedRect=null;let d=()=>{let h=(r.initialized?r.realSlides:V(e.slides))[s];if(h){let m=l?h.offsetTop:h.offsetLeft;l?e.feed.scrollTop=m:e.feed.scrollLeft=m;}};d(),u&&clearTimeout(u),u=setTimeout(()=>{A(),d();},150);},X=()=>{let{signal:s}=o.abortController;window.addEventListener("resize",B),e.feed.addEventListener("scroll",U,{passive:true,signal:s}),e.prevSlideButton&&e.prevSlideButton.addEventListener("click",()=>v("prev"),{signal:s}),e.nextSlideButton&&e.nextSlideButton.addEventListener("click",()=>v("next"),{signal:s}),e.thumbs?.length&&(e.thumbs[0]?.classList.add("active"),e.thumbs.forEach(d=>{d.addEventListener("click",()=>L(d),{signal:s});})),re(e.feed,()=>v("prev"),()=>v("next"),s,t),e.enableDragToScroll!==false&&(c=ae({feed:e.feed,slides:e.slides,abortSignal:s,smoothScrollTo:E,onDragStart:()=>{e.autoScroll&&z(o);},onDragEnd:d=>{let b=d?.getAttribute("data-lazer-clone");if(!!(b&&e.loop&&r.initialized)&&d){let m=r.realSlides,T=0,y;if(b==="prepend"){let g=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="prepend").indexOf(d);T=m.length-r.clonesPerSide+g,y=m[T];}else if(b==="append"){let g=r.clonedSlides.filter(I=>I.getAttribute("data-lazer-clone")==="append").indexOf(d);T=g,y=m[g];}if(y){o.currentSlideIndex=T;let R=l?y.offsetTop:y.offsetLeft;setTimeout(()=>{a.cancelled=true,l?e.feed.scrollTop=R:e.feed.scrollLeft=R;},H.MIN_DURATION),F(e.thumbs,o.currentSlideIndex);}}else S(),F(e.thumbs,o.currentSlideIndex);e.autoScroll&&!o.autoScrollStopped&&(e.stopOnInteraction?o.autoScrollStopped=true:Y(e,o,r,l));},direction:t,loop:e.loop})),Se(e,o,s),se(e,o,r,l,s);},P=s=>{let d=r.initialized?r.realSlides:V(e.slides),b=Math.max(0,Math.min(s,d.length-1)),h=d[b];if(!h)return;o.currentSlideIndex=b,F(e.thumbs,b);let m=l?h.offsetTop:h.offsetLeft;p(m);},A=()=>{o.cachedFeedRect=null,oe(e,l,N()),ee(e,f(),l),n(),e.autoScroll&&!o.autoScrollPaused&&!o.autoScrollStopped&&(K(o),_(e,o,r,l));},M=()=>{Z(o),K(o),o.abortController.abort(),window.removeEventListener("resize",B),o.updateThumbTimeout&&clearTimeout(o.updateThumbTimeout),o.scrollEndTimeout&&clearTimeout(o.scrollEndTimeout),u&&clearTimeout(u),c&&ce(c),fe(r),o.cachedFeedRect=null;},C=()=>{e.autoScroll?(o.autoScrollStopped=false,o.autoScrollPaused?G(e,o,r,l):_(e,o,r,l)):e.autoplay&&J(e,o,v);},x=()=>{e.autoScroll?z(o):Z(o);};if(le(e),oe(e,l,N()),e.autoScroll){e.loop=true,Q(e,r,l);let s=e.autoScrollStartDelay??0;s>0?o.autoScrollResumeTimeout=setTimeout(()=>{o.autoScrollResumeTimeout=null,_(e,o,r,l);},s):requestAnimationFrame(()=>{requestAnimationFrame(()=>{_(e,o,r,l);});});}else Q(e,r,l),e.autoplay&&J(e,o,v);return n(),X(),ee(e,f(),l),{goToIndex:P,refresh:A,unload:M,play:C,pause:x,next:()=>v("next"),prev:()=>v("prev")}};export{we as createSlider,Ee as easeInOutCubic,w as easeOutCubic,k as easeOutExpo,Le as easeOutQuad,q as generateBullets,j as generateThumbs,Ae as linear};
1
+ var w={MIN_DURATION:400,MAX_DURATION:1e3,SPEED_FACTOR:1.5,SCROLL_END_DELAY:50,THUMB_UPDATE_DELAY:500},Ee="(min-width: 64rem)",P=()=>window.matchMedia(Ee).matches;var k=e=>e===1?1:1-Math.pow(2,-10*e),H=e=>1-Math.pow(1-e,3),Le=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Ae=e=>1-(1-e)*(1-e),ye=e=>e;var ge=()=>`slider-${Math.random().toString(36).substring(2,9)}`,le=e=>{let{feed:t,prevSlideButton:l,nextSlideButton:i,thumbs:o,slides:c}=e;t.id||(t.id=ge()),t.setAttribute("role","region"),t.setAttribute("aria-label","Carousel"),t.setAttribute("aria-roledescription","carousel"),t.removeAttribute("tabindex"),c.forEach((r,n)=>{r.setAttribute("role","group"),r.setAttribute("aria-roledescription","slide"),r.setAttribute("aria-label",`Slide ${n+1} of ${c.length}`);}),l&&(l.setAttribute("aria-label","Previous slide"),l.setAttribute("aria-controls",t.id),l.setAttribute("tabindex","0"),l.tagName!=="BUTTON"&&l.setAttribute("role","button")),i&&(i.setAttribute("aria-label","Next slide"),i.setAttribute("aria-controls",t.id),i.setAttribute("tabindex","0"),i.tagName!=="BUTTON"&&i.setAttribute("role","button")),o?.length&&o.forEach((r,n)=>{r.tagName!=="BUTTON"&&r.setAttribute("role","button"),r.setAttribute("aria-label",`Go to slide ${n+1}`),r.setAttribute("tabindex","0"),r.setAttribute("aria-controls",t.id);});},B=(e,t,l)=>{if(!e)return;!t&&e===document.activeElement&&l&&l.focus();let i="opacity 0.3s ease",o=t?"1":"0";Object.assign(e.style,{opacity:o,transition:i,pointerEvents:t?"auto":"none"}),t?(e.removeAttribute("aria-hidden"),e.setAttribute("tabindex","0")):(e.setAttribute("aria-hidden","true"),e.setAttribute("tabindex","-1")),t?e.style.visibility="visible":setTimeout(()=>{e.style.opacity==="0"&&(e.style.visibility="hidden");},300);},N=(e,t,l="active")=>{e?.length&&e.forEach((i,o)=>{let c=o===t;i.classList.toggle(l,c),i.setAttribute("aria-selected",c.toString());});},re=(e,t,l,i,o="horizontal")=>{let c=o==="vertical",r=c?"ArrowUp":"ArrowLeft",n=c?"ArrowDown":"ArrowRight";e.addEventListener("keydown",d=>{switch(d.key){case r:d.preventDefault(),t();break;case n:d.preventDefault(),l();break}},{signal:i}),e.hasAttribute("tabindex")||e.setAttribute("tabindex","0");};var M={FRICTION:.94,MIN_VELOCITY:.3,MOMENTUM_RATIO:.8,VELOCITY_SMOOTHING:.4,EDGE_RESISTANCE:.3,MAX_EDGE_OVERSCROLL:100,SHORT_SWIPE_VELOCITY:.5,BOUNCE_DURATION:400},xe=()=>({isDragging:false,startX:0,startY:0,startScrollLeft:0,startScrollTop:0,velocity:0,lastX:0,lastY:0,lastTime:0,momentumId:null}),Ie=()=>({...xe(),velocityHistory:[],dragDistance:0,dragStartTime:0}),q=(e,t,l="horizontal")=>{let i=e.getBoundingClientRect(),o=l==="vertical",c=o?i.top:i.left,r=null,n=1/0;for(let d of t){if(d.offsetParent===null)continue;let u=d.getBoundingClientRect(),m=o?u.top:u.left,b=Math.abs(c-m);b<n&&(n=b,r=d);}return r},Me=(e,t,l,i="horizontal")=>{let o=e.getBoundingClientRect(),c=i==="vertical",r=c?o.top:o.left,n=t.filter(a=>a.offsetParent!==null);if(n.length===0)return null;let d=0,u=1/0;n.forEach((a,p)=>{let L=a.getBoundingClientRect(),E=c?L.top:L.left,C=Math.abs(r-E);C<u&&(u=C,d=p);});let m=2,b=d;return Math.abs(l)>m&&(l>0?b=Math.min(d+1,n.length-1):b=Math.max(d-1,0)),n[b]??null},Re=e=>{if(e.length===0)return 0;let t=0,l=0;return e.forEach((i,o)=>{let c=o+1;t+=i*c,l+=c;}),t/l},De=(e,t,l,i,o,c="horizontal",r=false)=>{let n=c==="vertical",d=e.velocity*M.MOMENTUM_RATIO,u=()=>{if(Math.abs(d)<M.MIN_VELOCITY){e.momentumId=null;let p=q(t,l,c);if(p){let L=n?p.offsetTop:p.offsetLeft;i(L,H);}o?.(p);return}let m=n?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,a=(n?t.scrollTop:t.scrollLeft)+d;r||(a<0||a>m)&&(d*=.5),n?t.scrollTop=Math.max(0,Math.min(m,a)):t.scrollLeft=Math.max(0,Math.min(m,a)),d*=M.FRICTION,e.momentumId=requestAnimationFrame(u);};e.momentumId=requestAnimationFrame(u);},ie=e=>"touches"in e?e.touches[0]?.clientX??0:e.clientX,ne=e=>"touches"in e?e.touches[0]?.clientY??0:e.clientY,we=(e,t)=>t==="vertical"?ne(e):ie(e),ae=e=>{let {feed:t,slides:l,abortSignal:i,smoothScrollTo:o,onDragStart:c,onDragEnd:r,direction:n="horizontal",loop:d=false,touchRatio:u=1,shortSwipeThreshold:m=300,swipeDistanceThreshold:b=10}=e,a=Ie(),p=n==="vertical",L=()=>{if(!d)return l;let A=[],x=t.children;for(let R=0;R<x.length;R++){let g=x[R];(l.includes(g)||g.hasAttribute("data-lazer-clone"))&&A.push(g);}return A.length>0?A:l},E=0,$=()=>{E=p?t.scrollHeight-t.clientHeight:t.scrollWidth-t.clientWidth,p?t.clientHeight:t.clientWidth;},_=A=>{a.momentumId!==null&&(cancelAnimationFrame(a.momentumId),a.momentumId=null),$(),c?.(),a.isDragging=true,a.startX=ie(A),a.startY=ne(A),a.startScrollLeft=t.scrollLeft,a.startScrollTop=t.scrollTop,a.velocity=0,a.lastX=a.startX,a.lastY=a.startY,a.lastTime=performance.now(),a.velocityHistory=[],a.dragDistance=0,a.dragStartTime=performance.now(),t.style.userSelect="none",t.style.cursor="grabbing",t.classList.add("is-dragging"),A.type==="mousedown"&&A.preventDefault();},G=A=>{if(!a.isDragging)return;let x=we(A,n),R=p?a.startY:a.startX,g=p?a.lastY:a.lastX,s=p?a.startScrollTop:a.startScrollLeft,f=performance.now(),T=f-a.lastTime,h=(R-x)*u,S=s+h;if(a.dragDistance=Math.abs(h),!d){if(S<0){let v=Math.abs(S),y=1-Math.min(v/M.MAX_EDGE_OVERSCROLL,1)*(1-M.EDGE_RESISTANCE);S=-v*y;}else if(S>E){let v=S-E,y=1-Math.min(v/M.MAX_EDGE_OVERSCROLL,1)*(1-M.EDGE_RESISTANCE);S=E+v*y;}}if(p?t.scrollTop=S:t.scrollLeft=S,T>0){let v=(g-x)/T*16;if(a.velocityHistory.length>0){let y=a.velocity;a.velocity=y*(1-M.VELOCITY_SMOOTHING)+v*M.VELOCITY_SMOOTHING;}else a.velocity=v;a.velocityHistory.push(v),a.velocityHistory.length>5&&a.velocityHistory.shift();}p?a.lastY=x:a.lastX=x,a.lastTime=f,A.type==="touchmove"&&A.preventDefault();},O=()=>{if(!a.isDragging)return;a.isDragging=false,t.style.userSelect="",t.style.cursor="",t.classList.remove("is-dragging");let x=performance.now()-a.dragStartTime<m&&a.dragDistance>b,R=Re(a.velocityHistory),g=L();if(!d){let s=p?t.scrollTop:t.scrollLeft;if(s<0||s>E){let f=s<0?0:E,T=s,h=performance.now(),S=()=>{let v=performance.now()-h,y=Math.min(v/M.BOUNCE_DURATION,1),D=H(y),I=T+(f-T)*D;if(p?t.scrollTop=I:t.scrollLeft=I,y<1)requestAnimationFrame(S);else {let X=q(t,g,n);if(X){let ve=p?X.offsetTop:X.offsetLeft;o(ve,H);}r?.(X);}};requestAnimationFrame(S);return}}if(x||Math.abs(R)>M.SHORT_SWIPE_VELOCITY){let s=Me(t,g,R,n);if(s){let f=p?s.offsetTop:s.offsetLeft;o(f,H),r?.(s);}else r?.(null);}else if(Math.abs(a.velocity)>1&&!a.isLoopDragHandled)De(a,t,g,o,r,n,d);else {let s=q(t,g,n);if(!a.isLoopDragHandled){if(s){let f=p?s.offsetTop:s.offsetLeft;o(f,H);}r?.(s);}}};return t.addEventListener("mousedown",_,{signal:i}),document.addEventListener("mousemove",G,{signal:i}),document.addEventListener("mouseup",O,{signal:i}),t.addEventListener("touchstart",_,{passive:true,signal:i}),t.addEventListener("touchmove",G,{passive:false,signal:i}),t.addEventListener("touchend",O,{signal:i}),t.addEventListener("touchcancel",O,{signal:i}),document.addEventListener("mouseleave",O,{signal:i}),t.style.cursor="grab",a},se=e=>{e.momentumId!==null&&(cancelAnimationFrame(e.momentumId),e.momentumId=null);};var V=({bulletsContainer:e,slides:t,bulletClass:l,bulletActiveClass:i,feedId:o})=>{if(!e||!(e instanceof HTMLElement))throw new Error("Invalid bulletsContainer: must be a valid HTMLElement");if(!Array.isArray(t)||t.length===0)throw new Error("Invalid slides: must be a non-empty array");if(!o||typeof o!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!l||typeof l!="string")throw new Error("Invalid bulletClass: must be a non-empty string");e.innerHTML="",e.setAttribute("role","tablist"),e.setAttribute("aria-label","Slide navigation");let c=t.map((n,d)=>({slide:n,originalIndex:d})).filter(({slide:n})=>n.offsetParent!==null);return c.length===0?(console.warn("No visible slides found"),[]):c.map(({slide:n,originalIndex:d},u)=>{let m=document.createElement("button");return m.type="button",m.classList.add(l),u===0&&m.classList.add(i),m.setAttribute("role","tab"),m.setAttribute("aria-selected",u===0?"true":"false"),m.setAttribute("aria-controls",o),m.setAttribute("aria-label",`Go to slide ${u+1}`),m.setAttribute("data-slide-index",String(u)),e.appendChild(m),m})};var j=({thumbsContainer:e,slides:t,thumbClass:l,thumbActiveClass:i,feedId:o,thumbImageSelector:c="img",thumbSize:r})=>{if(!e||!(e instanceof HTMLElement))throw new Error("Invalid thumbsContainer: must be a valid HTMLElement");if(!Array.isArray(t)||t.length===0)throw new Error("Invalid slides: must be a non-empty array");if(!o||typeof o!="string")throw new Error("Invalid feedId: must be a non-empty string");if(!l||typeof l!="string")throw new Error("Invalid thumbClass: must be a non-empty string");e.innerHTML="",e.setAttribute("role","tablist"),e.setAttribute("aria-label","Slide thumbnails");let n=t.map((u,m)=>({slide:u,originalIndex:m})).filter(({slide:u})=>u.offsetParent!==null);return n.length===0?(console.warn("No visible slides found"),[]):n.map(({slide:u,originalIndex:m},b)=>{let a=document.createElement("button");a.type="button",a.classList.add(l),b===0&&a.classList.add(i);let p=u.querySelector(c);if(p?.src){let L=document.createElement("img");L.src=p.src,L.alt=p.alt||`Slide ${b+1} thumbnail`,L.draggable=false,r&&(L.style.width=`${r.width}px`,L.style.height=`${r.height}px`,L.style.objectFit="cover"),a.appendChild(L);}return a.setAttribute("role","tab"),a.setAttribute("aria-selected",b===0?"true":"false"),a.setAttribute("aria-controls",o),a.setAttribute("aria-label",`Go to slide ${b+1}`),a.setAttribute("data-slide-index",String(b)),e.appendChild(a),a})};var F=(e,t,l,i)=>{if(t.autoScrollAnimationId!==null)return;t.autoScrollPaused=false,t.autoScrollStopped=false,t.autoScrollLastTimestamp=performance.now();let o=e.autoScrollSpeed??50,c=e.autoScrollDirection??"forward",r=n=>{if(t.autoScrollPaused||t.autoScrollStopped){t.autoScrollAnimationId=null;return}let d=n-t.autoScrollLastTimestamp;t.autoScrollLastTimestamp=n,d>100&&(d=100);let u=o*(d/1e3);c==="backward"&&(u=-u),i?e.feed.scrollTop+=u:e.feed.scrollLeft+=u,He(e,l,i,c),t.autoScrollAnimationId=requestAnimationFrame(r);};t.autoScrollAnimationId=requestAnimationFrame(r);},He=(e,t,l,i)=>{if(!t.initialized||t.realSlides.length===0)return;let o=e.feed,c=l?o.scrollTop:o.scrollLeft,r=t.realSlides[0],n=t.realSlides[t.realSlides.length-1];if(!(!r||!n))if(i==="forward"){let d=t.forwardResetThreshold;if(c>=d){let u=c-d,m=l?r.offsetTop:r.offsetLeft;l?o.scrollTop=m+u:o.scrollLeft=m+u;}}else {let d=t.backwardResetThreshold;if(c<d){let u=l?n.offsetTop:n.offsetLeft,m;if(c<=0)m=u;else {let b=c-d;m=u+b,m<d&&(m=d);}l?o.scrollTop=m:o.scrollLeft=m;}}},K=e=>{e.autoScrollAnimationId!==null&&(cancelAnimationFrame(e.autoScrollAnimationId),e.autoScrollAnimationId=null),e.autoScrollResumeTimeout!==null&&(clearTimeout(e.autoScrollResumeTimeout),e.autoScrollResumeTimeout=null);},z=e=>{e.autoScrollPaused=true,e.autoScrollAnimationId!==null&&(cancelAnimationFrame(e.autoScrollAnimationId),e.autoScrollAnimationId=null);},U=(e,t,l,i)=>{t.autoScrollStopped||(t.autoScrollLastTimestamp=performance.now(),t.autoScrollPaused=false,t.autoScrollAnimationId===null&&F(e,t,l,i));},W=(e,t,l,i)=>{if(t.autoScrollStopped)return;t.autoScrollResumeTimeout!==null&&clearTimeout(t.autoScrollResumeTimeout);let o=e.autoScrollStartDelay??0;o>0?t.autoScrollResumeTimeout=setTimeout(()=>{t.autoScrollResumeTimeout=null,U(e,t,l,i);},o):U(e,t,l,i);},ce=(e,t,l,i,o)=>{if(!e.autoScroll)return;let c=e.stopOnMouseEnter!==false,r=e.stopOnFocusIn!==false;c&&(e.feed.addEventListener("mouseenter",()=>z(t),{signal:o}),e.feed.addEventListener("mouseleave",()=>W(e,t,l,i),{signal:o})),r&&(e.feed.addEventListener("focusin",()=>z(t),{signal:o}),e.feed.addEventListener("focusout",()=>W(e,t,l,i),{signal:o})),e.feed.addEventListener("touchstart",()=>z(t),{passive:true,signal:o}),e.feed.addEventListener("touchend",()=>W(e,t,l,i),{signal:o});};var de=e=>({initialized:false,clonedSlides:[],realSlides:[...e],clonesPerSide:0,forwardResetThreshold:0,backwardResetThreshold:0}),Ce=(e,t)=>{let l=P()?e.desktopSlidesPerView:e.mobileSlidesPerView;if(e.autoScroll){let i=e.slides,o=e.feed,c=e.slideGap??0,r=t?o.clientHeight:o.clientWidth,n=0;for(let b of i)n+=t?b.offsetHeight:b.offsetWidth;let d=i.length>0?(n+c*(i.length-1))/i.length:0,u=d>0?Math.ceil(r/d)+1:i.length,m=Math.max(u,i.length*2);return Math.max(m,1)}return !l||l==="auto"?1:Math.ceil(l)},Q=(e,t,l)=>{if(!e.loop||t.initialized)return;let i=t.realSlides,o=Ce(e,l);t.clonesPerSide=o;let c=e.slideGap??0;for(let r=o-1;r>=0;r--){let n=r%i.length,d=i[n];if(!d)continue;let u=d.cloneNode(true);u.setAttribute("data-lazer-clone","prepend"),u.setAttribute("data-lazer-clone-source",String(n)),u.setAttribute("aria-hidden","true"),e.feed.insertBefore(u,e.feed.firstChild),t.clonedSlides.push(u);}for(let r=0;r<o;r++){let n=r%i.length,d=i[n];if(!d)continue;let u=d.cloneNode(true);u.setAttribute("data-lazer-clone","append"),u.setAttribute("data-lazer-clone-source",String(n)),u.setAttribute("aria-hidden","true"),e.feed.appendChild(u),t.clonedSlides.push(u);}requestAnimationFrame(()=>{let r=i[0],n=i[i.length-1];if(r&&n){let d=l?n.offsetHeight:n.offsetWidth;l?(e.feed.scrollTop=r.offsetTop,t.forwardResetThreshold=n.offsetTop+d+c,t.backwardResetThreshold=r.offsetTop):(e.feed.scrollLeft=r.offsetLeft,t.forwardResetThreshold=n.offsetLeft+d+c,t.backwardResetThreshold=r.offsetLeft);}}),t.initialized=true;},ue=(e,t,l)=>{if(!t.initialized||t.realSlides.length===0)return;let i=t.realSlides[0],o=t.realSlides[t.realSlides.length-1],c=e.slideGap??0;if(i&&o){let r=l?o.offsetHeight:o.offsetWidth;l?(t.forwardResetThreshold=o.offsetTop+r+c,t.backwardResetThreshold=i.offsetTop):(t.forwardResetThreshold=o.offsetLeft+r+c,t.backwardResetThreshold=i.offsetLeft);}},fe=(e,t,l,i,o,c,r)=>{if(!t.loop||!l.initialized)return;c(true);let n=l.realSlides,d=n.length;if(e==="next"){let u=n[0];u&&(i?t.feed.scrollTop=u.offsetTop:t.feed.scrollLeft=u.offsetLeft),o(0);}else {let u=n[d-1];u&&(i?t.feed.scrollTop=u.offsetTop:t.feed.scrollLeft=u.offsetLeft),o(d-1);}requestAnimationFrame(()=>{requestAnimationFrame(()=>{c(false),r();});});},me=e=>{e.initialized&&(e.clonedSlides.forEach(t=>{t.remove();}),e.clonedSlides=[],e.initialized=false,e.clonesPerSide=0,e.forwardResetThreshold=0,e.backwardResetThreshold=0);};var J=(e,t,l)=>{if(t.autoplayIntervalId)return;let i=e.autoplayInterval??3e3;t.autoplayIntervalId=setInterval(()=>{t.autoplayPaused||l("next");},i);},Z=e=>{e.autoplayIntervalId&&(clearInterval(e.autoplayIntervalId),e.autoplayIntervalId=null);},Se=e=>{e.autoplayPaused=true;},pe=e=>{e.autoplayPaused=false;},he=(e,t,l)=>{!e.autoplay||e.pauseOnHover===false||(e.feed.addEventListener("mouseenter",()=>Se(t),{signal:l}),e.feed.addEventListener("mouseleave",()=>pe(t),{signal:l}),e.feed.addEventListener("touchstart",()=>Se(t),{passive:true,signal:l}),e.feed.addEventListener("touchend",()=>pe(t),{signal:l}));};var ee=(e,t,l)=>{if(e.scrollbarThumb)if(l){let i=t.height/e.feed.scrollHeight*100;e.scrollbarThumb.style.height=`${i}%`,e.scrollbarThumb.style.width="";}else {let i=t.width/e.feed.scrollWidth*100;e.scrollbarThumb.style.width=`${i}%`,e.scrollbarThumb.style.height="";}},be=(e,t)=>{if(!(!e.scrollbarThumb||!e.scrollbarTrack))if(t){let l=e.scrollbarTrack.getBoundingClientRect().height,i=e.scrollbarThumb.getBoundingClientRect().height,o=l-i,c=e.feed.scrollHeight-e.feed.clientHeight,r=c>0?e.feed.scrollTop/c:0;e.scrollbarThumb.style.transform=`translateY(${o*r}px)`;}else {let l=e.scrollbarTrack.getBoundingClientRect().width,i=e.scrollbarThumb.getBoundingClientRect().width,o=l-i,c=e.feed.scrollWidth-e.feed.clientWidth,r=c>0?e.feed.scrollLeft/c:0;e.scrollbarThumb.style.transform=`translateX(${o*r}px)`;}};var te=(e,t,l,i=k,o,c)=>{let r=l?e.scrollTop:e.scrollLeft,n=Math.abs(t-r),d=Math.min(w.MAX_DURATION,Math.max(w.MIN_DURATION,n/w.SPEED_FACTOR)),u=performance.now(),m=b=>{if(c?.cancelled)return;let a=(b-u)/d,p=Math.min(a,1),L=i(p),E=r+(t-r)*L;l?e.scrollTop=E:e.scrollLeft=E,p<1?requestAnimationFrame(m):(l?e.scrollTop=t:e.scrollLeft=t,o?.());};requestAnimationFrame(m);},Y=e=>e.filter(t=>t.offsetParent!==null),oe=(e,t,l)=>{let i=l?e.desktopSlidesPerView:e.mobileSlidesPerView,o=e.slideGap??0;if(o>0&&(e.feed.style.gap=`${o}px`),!i||i==="auto"){e.slides.forEach(n=>{n.style.flex="0 0 auto",n.style.minWidth="",n.style.minHeight="";});return}let r=`calc((100% - ${o*(i-1)}px) / ${i})`;t?e.slides.forEach(n=>{n.style.flex=`0 0 ${r}`,n.style.minHeight=r,n.style.minWidth="";}):e.slides.forEach(n=>{n.style.flex=`0 0 ${r}`,n.style.minWidth=r,n.style.minHeight="";});},Te=(e,t,l,i)=>{let o=i?e.clientHeight:e.clientWidth;return !t||l!==o?{rect:e.getBoundingClientRect(),size:o}:{rect:t,size:l}};var Oe=e=>{if(!e.feed)throw new Error("lazer-slider: feed element is required");if(!e.slides?.length)throw new Error("lazer-slider: slides array is required and must not be empty");if(e.feed.id||(e.feed.id=`lazer-slider-feed-${Math.random().toString(36).substr(2,9)}`),e.bulletsContainer&&!e.thumbs){let s=V({bulletsContainer:e.bulletsContainer,slides:e.slides,bulletClass:e.bulletsClass??"slider-bullet",bulletActiveClass:e.bulletsActiveClass??"active",feedId:e.feed.id});e.thumbs=s;}if(e.thumbsContainer&&!e.thumbs){let s=j({thumbsContainer:e.thumbsContainer,slides:e.slides,thumbClass:e.thumbsClass??"slider-thumb",thumbActiveClass:e.thumbsActiveClass??"active",feedId:e.feed.id,thumbImageSelector:e.thumbImageSelector??"img",thumbSize:e.thumbSize});e.thumbs=s;}let t=e.direction??"horizontal",l=t==="vertical",i=e.easing??k,o={currentSlideIndex:0,isScrolling:false,ticking:false,cachedFeedRect:null,lastWidth:0,updateThumbTimeout:null,scrollEndTimeout:null,abortController:new AbortController,autoplayIntervalId:null,autoplayPaused:false,autoScrollAnimationId:null,autoScrollPaused:false,autoScrollLastTimestamp:0,autoScrollStopped:false,autoScrollResumeTimeout:null,isLoopRepositioning:false},c=null,r=de(e.slides),n={cancelled:false},d=null,u=()=>{let s=Te(e.feed,o.cachedFeedRect,o.lastWidth,l);return o.cachedFeedRect=s.rect,o.lastWidth=s.size,s.rect},m=(s,f)=>{te(e.feed,s,l,i,f);},b=(s,f)=>{n.cancelled=true,n={cancelled:false},te(e.feed,s,l,f??i,void 0,n);},a=()=>{if(o.isLoopRepositioning)return;let s=u(),f,T,h;if(l?(f=e.feed.scrollTop<=1,T=e.feed.scrollTop+s.height>=e.feed.scrollHeight-1,h=e.feed.scrollHeight<=s.height):(f=e.feed.scrollLeft<=1,T=e.feed.scrollLeft+s.width>=e.feed.scrollWidth-1,h=e.feed.scrollWidth<=s.width),e.scrollbarTrack&&(e.scrollbarTrack.style.display=h?"none":"block"),e.loop){B(e.prevSlideButton,!h,e.feed),B(e.nextSlideButton,!h,e.feed);return}B(e.prevSlideButton,!f&&!h,e.feed),B(e.nextSlideButton,!T&&!h,e.feed);},p=()=>{let s=u(),f=r.initialized?r.realSlides:Y(e.slides),T=f.filter(h=>{let S=h.getBoundingClientRect(),v=20;return l?S.bottom>s.top+v&&S.top<s.bottom-v:S.right>s.left+v&&S.left<s.right-v});if(T.length&&T[0]){let h=f.indexOf(T[0]);if(h!==-1){o.currentSlideIndex=h;let S=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScroll?.({currentScroll:S,currentSlideIndex:o.currentSlideIndex});}}},L=s=>{if(!e.thumbs)return;let f=e.thumbs.indexOf(s);if(f===-1||!e.slides[f])return;o.currentSlideIndex=f,N(e.thumbs,f),o.isScrolling=true,o.updateThumbTimeout&&clearTimeout(o.updateThumbTimeout),o.updateThumbTimeout=setTimeout(()=>{o.isScrolling=false;},w.THUMB_UPDATE_DELAY);let T=l?e.slides[f].offsetTop:e.slides[f].offsetLeft;m(T);},E=s=>{let f=r.initialized?r.realSlides:Y(e.slides),T=P()?e.desktopSlidesPerScroll??1:e.mobileSlidesPerScroll??1,h=f.length;p();let S,v=false;if(s==="prev"?e.loop&&r.initialized&&o.currentSlideIndex===0?(S=f[0]?.previousElementSibling,v=!!S?.hasAttribute("data-lazer-clone")):(o.currentSlideIndex=Math.max(0,o.currentSlideIndex-T),S=f[o.currentSlideIndex]):e.loop&&r.initialized&&o.currentSlideIndex>=h-1?(S=f[h-1]?.nextElementSibling,v=!!S?.hasAttribute("data-lazer-clone")):(o.currentSlideIndex=Math.min(h-1,o.currentSlideIndex+T),S=f[o.currentSlideIndex]),!S)return;let y=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollStart?.({currentScroll:y,target:S,direction:s});let D=l?S.offsetTop:S.offsetLeft;v?m(D,()=>{fe(s,e,r,l,I=>{o.currentSlideIndex=I;},I=>{o.isLoopRepositioning=I;},a);}):m(D);},C=()=>{be(e,l),a(),p(),o.isScrolling||N(e.thumbs,o.currentSlideIndex),o.scrollEndTimeout&&clearTimeout(o.scrollEndTimeout),o.scrollEndTimeout=setTimeout(()=>{o.isScrolling=false;let s=l?e.feed.scrollTop:e.feed.scrollLeft;e.onScrollEnd?.({currentScroll:s,currentSlideIndex:o.currentSlideIndex});},w.SCROLL_END_DELAY);},$=()=>{o.ticking||(requestAnimationFrame(()=>{C(),o.ticking=false;}),o.ticking=true);},_=()=>{let s=o.currentSlideIndex;o.cachedFeedRect=null;let f=()=>{let h=(r.initialized?r.realSlides:Y(e.slides))[s];if(h){let S=l?h.offsetTop:h.offsetLeft;l?e.feed.scrollTop=S:e.feed.scrollLeft=S;}};f(),d&&clearTimeout(d),d=setTimeout(()=>{A(),f();},150);},G=()=>{let{signal:s}=o.abortController;window.addEventListener("resize",_),e.feed.addEventListener("scroll",$,{passive:true,signal:s}),e.prevSlideButton&&e.prevSlideButton.addEventListener("click",()=>E("prev"),{signal:s}),e.nextSlideButton&&e.nextSlideButton.addEventListener("click",()=>E("next"),{signal:s}),e.thumbs?.length&&(e.thumbs[0]?.classList.add("active"),e.thumbs.forEach(f=>{f.addEventListener("click",()=>L(f),{signal:s});})),re(e.feed,()=>E("prev"),()=>E("next"),s,t),e.enableDragToScroll!==false&&(c=ae({feed:e.feed,slides:e.slides,abortSignal:s,smoothScrollTo:b,onDragStart:()=>{e.autoScroll&&z(o);},onDragEnd:f=>{if(!!(f?.getAttribute("data-lazer-clone")&&e.loop&&r.initialized)&&f){let S=r.realSlides,v=f.getAttribute("data-lazer-clone-source"),y=v!==null?Math.max(0,Math.min(parseInt(v,10),S.length-1)):0,D=S[y];if(D){o.currentSlideIndex=y;let I=l?D.offsetTop:D.offsetLeft;setTimeout(()=>{n.cancelled=true,l?e.feed.scrollTop=I:e.feed.scrollLeft=I;},w.MIN_DURATION),N(e.thumbs,o.currentSlideIndex);}}else p(),N(e.thumbs,o.currentSlideIndex);e.autoScroll&&!o.autoScrollStopped&&(e.stopOnInteraction?o.autoScrollStopped=true:W(e,o,r,l));},direction:t,loop:e.loop})),he(e,o,s),ce(e,o,r,l,s);},O=s=>{let f=r.initialized?r.realSlides:Y(e.slides),T=Math.max(0,Math.min(s,f.length-1)),h=f[T];if(!h)return;o.currentSlideIndex=T,N(e.thumbs,T);let S=l?h.offsetTop:h.offsetLeft;m(S);},A=()=>{o.cachedFeedRect=null,oe(e,l,P()),ee(e,u(),l),a(),e.autoScroll&&r.initialized&&(ue(e,r,l),!o.autoScrollPaused&&!o.autoScrollStopped&&(K(o),F(e,o,r,l)));},x=()=>{Z(o),K(o),o.abortController.abort(),window.removeEventListener("resize",_),o.updateThumbTimeout&&clearTimeout(o.updateThumbTimeout),o.scrollEndTimeout&&clearTimeout(o.scrollEndTimeout),d&&clearTimeout(d),c&&se(c),me(r),e.feed.style.scrollBehavior="",e.feed.style.scrollSnapType="",e.feed.removeAttribute("data-lazer-autoscroll"),o.cachedFeedRect=null;},R=()=>{e.autoScroll?(o.autoScrollStopped=false,o.autoScrollPaused?U(e,o,r,l):F(e,o,r,l)):e.autoplay&&J(e,o,E);},g=()=>{e.autoScroll?z(o):Z(o);};if(le(e),oe(e,l,P()),e.autoScroll){e.loop=true,Q(e,r,l),e.feed.style.scrollBehavior="auto",e.feed.style.scrollSnapType="none",e.feed.setAttribute("data-lazer-autoscroll",""),r.clonedSlides.forEach(f=>{f.style.flex="0 0 auto";});let s=e.autoScrollStartDelay??0;s>0?o.autoScrollResumeTimeout=setTimeout(()=>{o.autoScrollResumeTimeout=null,F(e,o,r,l);},s):requestAnimationFrame(()=>{requestAnimationFrame(()=>{F(e,o,r,l);});});}else Q(e,r,l),e.autoplay&&J(e,o,E);return a(),G(),ee(e,u(),l),{goToIndex:O,refresh:A,unload:x,play:R,pause:g,next:()=>E("next"),prev:()=>E("prev")}};export{Oe as createSlider,Le as easeInOutCubic,H as easeOutCubic,k as easeOutExpo,Ae as easeOutQuad,V as generateBullets,j as generateThumbs,ye as linear};
@@ -286,8 +286,13 @@
286
286
  }
287
287
 
288
288
  /* ============================================
289
- Marquee Specific
289
+ Marquee / Auto-scroll
290
290
  ============================================ */
291
+ .lazer-feed[data-lazer-autoscroll] {
292
+ scroll-snap-type: none;
293
+ scroll-behavior: auto;
294
+ }
295
+
291
296
  .lazer-feed.lazer-marquee {
292
297
  scroll-snap-type: none;
293
298
  cursor: default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lazer-slider",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "A lightweight, accessible slider with smooth scroll-to-snap animations and drag-to-scroll support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -43,7 +43,7 @@
43
43
  "jsdom": "^25.0.0",
44
44
  "tsup": "^8.0.0",
45
45
  "typescript": "^5.0.0",
46
- "vitest": "^3.0.0"
46
+ "vitest": "3.0.0"
47
47
  },
48
48
  "repository": {
49
49
  "type": "git",