@twistedandy/better-carousel 1.1.2 → 1.1.3

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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  <p>A small, fast and accessible JavaScript carousel.<br />The CSS sets the layout, and the motion runs on the compositor, also on slow phones.</p>
6
6
 
7
- [![Gzip size](https://flat.badgen.net/static/gzip/12.6%20KB/green)](dist/better-carousel.min.js)
7
+ [![Gzip size](https://flat.badgen.net/static/gzip/12.7%20KB/green)](dist/better-carousel.min.js)
8
8
  [![MIT license](https://flat.badgen.net/static/license/MIT/purple)](LICENSE)
9
9
  [![No dependencies](https://flat.badgen.net/static/dependencies/0/blue)](package.json)
10
10
 
@@ -16,7 +16,7 @@
16
16
 
17
17
  - **Layout from CSS** - Your CSS sets the sizes of the slides, the space between them, the axis and the alignment. One carousel can show 1 slide on a phone and 4 slides on a desktop.
18
18
  - **Smooth** - Each motion is a Web Animations API animation of `translate`. No script runs on each frame, also during the auto scroll.
19
- - **Small** - <!-- generated:gzip -->12.6 KB<!-- /generated --> gzip with loop, autoplay, auto scroll, auto height, sync and the mouse wheel.
19
+ - **Small** - <!-- generated:gzip -->12.7 KB<!-- /generated --> gzip with loop, autoplay, auto scroll, auto height, sync and the mouse wheel.
20
20
  - **Loop** - The loop moves the original slides. It adds clones only if the slides are too few.
21
21
  - **Vertical and grid** - A column layout makes a vertical carousel. A CSS grid with more rows also works.
22
22
  - **Accessible** - WCAG 2.1 AA: names for the carousel, the slides and the buttons, the keyboard focus, a live region and reduced motion.
@@ -29,13 +29,13 @@ Load the minified script and the stylesheet from jsDelivr. The script adds the g
29
29
  ```html
30
30
  <link
31
31
  rel="stylesheet"
32
- href="https://cdn.jsdelivr.net/gh/TwistedAndy/better-carousel@v1.1.2/dist/better-carousel.css"
32
+ href="https://cdn.jsdelivr.net/gh/TwistedAndy/better-carousel@v1.1.3/dist/better-carousel.css"
33
33
  integrity="sha384-WH4VE2eTsNlsGXmOFkXZ+1tAsP2NEOB318/Byze8PAwaRtrgx+ZBmXaRIMLL9Cdq"
34
34
  crossorigin="anonymous"
35
35
  />
36
36
  <script
37
- src="https://cdn.jsdelivr.net/gh/TwistedAndy/better-carousel@v1.1.2/dist/better-carousel.min.js"
38
- integrity="sha384-h0ZLTfuVtmQW35SwAzeU1mNp4DQqHyJDBrmuKXU7953wMh0AKZj1vCFv3XcJg+Dw"
37
+ src="https://cdn.jsdelivr.net/gh/TwistedAndy/better-carousel@v1.1.3/dist/better-carousel.min.js"
38
+ integrity="sha384-+DZKd1P/J+A1azLGDffP2BQIpVf4r1y6mKO9Fe8wP4N7hCRR2QpAKclrz1AlGHlq"
39
39
  crossorigin="anonymous"
40
40
  ></script>
41
41
  ```
@@ -356,7 +356,7 @@ BetterCarousel(element, {
356
356
  | `duration` | `number` | `400` | The duration of a motion by one snap, in ms. A longer motion takes more time, to a maximum of 2 times this value. ([example](https://twistedandy.github.io/better-carousel/#options-usage)) |
357
357
  | `startSnap` | `number` | `0` | The index of the snap at the start. ([example](https://twistedandy.github.io/better-carousel/#options-usage)) |
358
358
  | `lazy` | `boolean`, `number` | `false` | `true`: start when the carousel comes within one screen of the view. A number: the distance in px. ([example](https://twistedandy.github.io/better-carousel/#lazy)) |
359
- | `drag` | `boolean` | `true` | Drag with the mouse, the pen and the finger. A press on a form field does not start a drag. To keep the drag off another element, such as a map in a slide, stop the propagation of its `pointerdown` event. |
359
+ | `drag` | `boolean` | `true` | Drag with the mouse, the pen and the finger. A press during a motion stops the motion. A press on a form field does not start a drag. To keep the drag off another element, such as a map in a slide, stop the propagation of its `pointerdown` event. |
360
360
  | `wheel` | `boolean`, `'axis'`, `'both'` | `true` | The mouse wheel moves a vertical carousel. `'axis'`: also a horizontal carousel, but only with a horizontal wheel motion, such as a trackpad swipe. A vertical wheel scrolls the page. `'both'`: also a horizontal carousel, with all wheel motions. `false`: the wheel does not move the carousel. ([example](https://twistedandy.github.io/better-carousel/#vertical)) |
361
361
  | `keys` | `boolean` | `true` | The arrow keys move the carousel while the keyboard focus is in it: left and right in a horizontal carousel, up and down in a vertical carousel. A key in a form field does not move the carousel. |
362
362
  | `resize` | `boolean` | `true` | Measure again when a size changes. ([example](https://twistedandy.github.io/better-carousel/#options-usage)) |
@@ -602,7 +602,7 @@ Add a handler with `on(name, handler)`, and remove it with `off(name, handler)`.
602
602
  | `settle` | A motion stopped. |
603
603
  | `dragstart`, `dragend` | A drag started or stopped. |
604
604
  | `slidesinview` | The slides in view changed. |
605
- | `slideschanged` | The page added or removed a slide. |
605
+ | `slideschanged` | The page added, removed or replaced a slide. |
606
606
  | `slidefocus` | A slide got the keyboard focus. |
607
607
  | `autoplay:play`, `autoplay:stop` | The autoplay started or stopped. |
608
608
  | `autoscroll:play`, `autoscroll:stop` | The auto scroll started or stopped. |
@@ -695,7 +695,7 @@ The carousel follows the carousel pattern of the WAI-ARIA Authoring Practices an
695
695
  - While the focus is in the carousel, the arrow keys go to the previous and the next slide. To turn them off, set `keys: false`.
696
696
  - Clones are `inert` and hidden from screen readers. A click on a link or a button in a clone goes to the same element in its slide. The form fields in clones have no name, so the form sends only the fields of the slides.
697
697
  - The autoplay and the auto scroll have a play and pause button (WCAG 2.2.2). The keyboard focus pauses them. If the user prefers reduced motion, they do not start.
698
- - A drag across the axis scrolls the page. A link opens on a click, but not after a drag.
698
+ - A drag across the axis scrolls the page. A link opens on a click, but not after a drag or after a press that stopped a motion.
699
699
 
700
700
  To translate the labels, set `labels`. In the texts, `%d` is the slide number, and `%n` is the number of slides:
701
701
 
@@ -720,9 +720,9 @@ The library is made for slow phones. A motion runs on the compositor, and a caro
720
720
  <!-- generated:sizes -->
721
721
  | File | Minified | Gzip | Brotli |
722
722
  | --- | --- | --- | --- |
723
- | `better-carousel.min.js` | 30.6 KB | 12.6 KB | 11.5 KB |
723
+ | `better-carousel.min.js` | 30.8 KB | 12.7 KB | 11.6 KB |
724
724
  | `better-carousel.css` | 4.8 KB | 1.4 KB | 1.2 KB |
725
- | Total | 35.3 KB | 13.9 KB | 12.7 KB |
725
+ | Total | 35.6 KB | 14.0 KB | 12.8 KB |
726
726
  <!-- /generated -->
727
727
 
728
728
  The [Comparison](#comparison) section gives the sizes and the runtime costs of other carousel libraries.
@@ -1943,6 +1943,8 @@ function carousel(element, userOptions, defaults, features) {
1943
1943
  geo: () => geo,
1944
1944
  selected: () => selected,
1945
1945
  dragging: () => dragging,
1946
+ // true while a motion to a location runs, such as a goToSnap() motion or a glide. The auto scroll is not such a motion.
1947
+ moving: () => !free && motion.current() !== null,
1946
1948
  // The location at rest or at the end of the motion. During a free motion, the location now.
1947
1949
  location: () => free ? current() : location,
1948
1950
  current,
@@ -2066,13 +2068,7 @@ function carousel(element, userOptions, defaults, features) {
2066
2068
  viewport.removeEventListener('input', onInput);
2067
2069
  removeEventListener('resize', onWindow);
2068
2070
 
2069
- for (const node of nodes) {
2070
- setStyle(node, 'translate', '');
2071
- setStyle(node, '--better-offset', '');
2072
- setClass(node, cls.selected, false);
2073
- setClass(node, cls.inView, false);
2074
- cleanStyle(node);
2075
- }
2071
+ nodes.forEach(clean);
2076
2072
 
2077
2073
  setStyle(container, 'translate', '');
2078
2074
  setStyle(container, 'will-change', '');
@@ -2191,17 +2187,37 @@ function carousel(element, userOptions, defaults, features) {
2191
2187
  return same && options.autoHeight && geo?.axis === 'x';
2192
2188
  }
2193
2189
 
2190
+ /**
2191
+ * Remove the styles and the classes that the carousel wrote on a slide or a clone.
2192
+ *
2193
+ * @param {HTMLElement} node
2194
+ */
2195
+ function clean(node) {
2196
+ setStyle(node, 'translate', '');
2197
+ setStyle(node, '--better-offset', '');
2198
+ setClass(node, cls.selected, false);
2199
+ setClass(node, cls.inView, false);
2200
+ cleanStyle(node);
2201
+ }
2202
+
2194
2203
  // Keep the selected slide. If the page removed it, select the slide that is now at its index, or the last slide.
2204
+ // The loop shift of a slide stays with the slide at its new index, because the measure pass subtracts it from the slide box.
2205
+ // A new slide can have the same size as the slide that it replaced, so the measure pass must not skip.
2195
2206
  function onMutation() {
2196
2207
  const old = ready ? selectedSlide() : -1,
2197
- node = slides[old];
2208
+ node = slides[old],
2209
+ shifts = new Map(slides.map((item, index) => [item, written.slides[index]]));
2198
2210
  slides = readSlides(container, options.slides);
2199
2211
  if (old > -1) {
2200
2212
  const index = slides.indexOf(node);
2201
2213
  requested = index > -1 ? index : Math.min(old, slides.length - 1);
2202
2214
  }
2215
+ // A removed slide can come back later, for example after a sort. It must not keep a loop shift.
2216
+ shifts.forEach((shift, item) => slides.includes(item) || clean(item));
2203
2217
  setClones(0);
2204
2218
  nodes = slides;
2219
+ written.slides = slides.map((item) => shifts.get(item) || 0);
2220
+ signature = [];
2205
2221
  changed = true;
2206
2222
  observe(true);
2207
2223
  }
@@ -2839,6 +2855,8 @@ function drag(context) {
2839
2855
  base,
2840
2856
  axis,
2841
2857
  block = false,
2858
+ // true if the press stopped a motion
2859
+ stopped = false,
2842
2860
  samples = [],
2843
2861
  // The selected snap at the drag start
2844
2862
  snap = 0;
@@ -2867,6 +2885,16 @@ function drag(context) {
2867
2885
  axis = { x: geo.axis === 'x', sign: geo.sign, scale: geo.scale };
2868
2886
  start = [event.clientX, event.clientY];
2869
2887
  samples = [];
2888
+
2889
+ // A press stops a motion where it is. The release goes to a snap, and the click after it does not count.
2890
+ // The auto scroll does not stop here: its feature stops it during the press and starts it again after the release.
2891
+ stopped = context.moving();
2892
+ if (stopped) {
2893
+ base = context.halt();
2894
+ snap = context.selected();
2895
+ context.emit('interact');
2896
+ }
2897
+
2870
2898
  listen(true);
2871
2899
  }
2872
2900
 
@@ -2926,28 +2954,35 @@ function drag(context) {
2926
2954
  listen();
2927
2955
  pointer = null;
2928
2956
 
2929
- if (!context.dragging()) {
2957
+ const dragged = context.dragging();
2958
+
2959
+ if (!dragged && !stopped) {
2930
2960
  return;
2931
2961
  }
2932
2962
 
2933
2963
  const geo = context.geo(),
2934
2964
  location = context.location(),
2935
- speed = up ? velocity(samples) : 0,
2965
+ // A press that only stopped a motion has no samples
2966
+ speed = up && samples.length ? velocity(samples) : 0,
2936
2967
  // The snaps and the limits come from the geometry, and skipSnaps, dragFree and dragFriction from the options
2937
2968
  target = releaseTarget({ ...geo, ...options, location, from: base, velocity: speed, current: snap }),
2938
2969
  curve = options.dragFree === true ? GLIDE : EASE;
2939
2970
 
2940
2971
  block = true;
2941
- context.drag(false);
2972
+ if (dragged) {
2973
+ context.drag(false);
2974
+ }
2942
2975
  context.move(target.snap, target.location, releaseDuration(target.location - location, speed, curve, options.duration), curve);
2943
2976
  }
2944
2977
 
2978
+ // Cancel the click after a drag. A touch drag sends no click, so the next click can come from the keyboard or a script.
2979
+ // Such a click has no detail (the click count), and it is not cancelled.
2945
2980
  function click(event) {
2946
- if (block) {
2947
- block = false;
2981
+ if (block && event.detail) {
2948
2982
  event.preventDefault();
2949
2983
  event.stopPropagation();
2950
2984
  }
2985
+ block = false;
2951
2986
  }
2952
2987
 
2953
2988
  const prevent = (event) => event.preventDefault();
@@ -1 +1 @@
1
- var BetterCarousel=(()=>{"use strict";function t(t,e,n){e&&t.classList.contains(e)!==!!n&&t.classList.toggle(e,!!n)}function e(t,e,n){t.getAttribute(e)!==(n||null)&&(n?t.setAttribute(e,n):t.removeAttribute(e))}function n(t,e,n){t.style.getPropertyValue(e)!==n+""&&t.style.setProperty(e,n)}function o(t){""===t.getAttribute("style")&&t.removeAttribute("style")}function r(t,e){return n=>e.forEach(([e,o,r])=>t[n?"addEventListener":"removeEventListener"](e,o,r))}function i(t,e){const n=document.createElement(t);return e&&(n.className=e),n}function s(t,n,o,r){const s=i("button",t);return s.type="button",e(s,"aria-label",o),s.setAttribute("aria-controls",n.id),s.addEventListener("click",r),s}function a(t,e){if("string"==typeof t){for(let n=e;n;n=n.parentElement){const e=n.querySelector(t);if(e)return e}return null}return!0===t?e:t||null}const l=new WeakMap,c=new WeakMap;function d(t,n,o){const r=l.get(t)||new Set;!r.has(n)&&t.hasAttribute(n)||(r.add(n),l.set(t,r),e(t,n,o))}function u(t,e){if(e&&!t.classList.contains(e)){const n=c.get(t)||new Set;t.classList.add(e),n.add(e),c.set(t,n)}}const p=new WeakSet;let f=0;const g=new Set(["template","script","style"]);function h(t,e){return[...e?t.querySelectorAll(e):t.children].filter(t=>!p.has(t)&&!g.has(t.localName))}function m(t){const e=t.cloneNode(!0),n=t.querySelectorAll("select");for(const t of[e,...e.querySelectorAll("[id],[name],[required]")])["id","name","required"].forEach(e=>t.removeAttribute(e));return e.querySelectorAll("select").forEach((t,e)=>t.selectedIndex=n[e].selectedIndex),e}function v(t,e){t.replaceChildren(...m(e).childNodes)}const x={delay:4e3,stopOnInteraction:!0,pauseOnHover:!1,pauseOnFocus:!0,stopOnLastSnap:!1,playOnInit:!0,instant:!1,timer:null},y={speed:120,direction:"next",startDelay:1e3,stopOnInteraction:!0,pauseOnHover:!1,pauseOnFocus:!0,playOnInit:!0};function w(t,e,n){return{...t,..."number"==typeof n?{[e]:n}:n}}function b(n,o,r,i){const{api:a,root:l,container:c,cls:u,emit:p}=n,f=n.options.labels,g=s(u.button+" "+u.playButton,c,"",()=>h?y.stop():y.play());let h=!1,m=null,v=!0;function x(){e(g,"aria-label",h?f.pause:f.play),t(l,u.playing,h),d(c,"aria-live",h?"off":"polite")}const y={play(){h||(h=!0,m=((t,e)=>{const n=new Set,o=(t,e)=>{const o=n.size;n[e?"add":"delete"](t),!o!=!n.size&&i.pause(m.paused())},r=new IntersectionObserver(([t])=>o("view",!t.isIntersecting)),s=[[document,"visibilitychange",()=>o("tab",document.hidden)],[t,"pointerenter",t=>o("mouse",e.pauseOnHover&&"mouse"===t.pointerType)],[t,"pointerleave",()=>o("mouse",!1)],[t,"focusin",t=>o("focus",e.pauseOnFocus&&t.target.matches(":focus-visible"))],[t,"focusout",e=>o("focus",t.contains(e.relatedTarget)&&n.has("focus"))]];return r.observe(t),s.forEach(([t,e,n])=>t.addEventListener(e,n)),{paused:()=>n.size>0,remove(){r.disconnect(),s.forEach(([t,e,n])=>t.removeEventListener(e,n))}}})(l,r),x(),i.play(),p(o.toLowerCase()+":play"))},stop(){h&&(h=!1,m.remove(),x(),i.stop(),p(o.toLowerCase()+":stop"))},isPlaying(){return h},paused(){return!h||m.paused()},remove(){n.playing&&(n.playing[o]=h),y.stop(),g.remove(),delete a[o]}};return[["init reinit resize",()=>{a.isFit()?g.remove():g.isConnected||l.append(g),v&&(v=!1,h?i.play():(n.playing?.[o]??(r.playOnInit&&!matchMedia("(prefers-reduced-motion: reduce)").matches))&&y.play())}],...i.events].forEach(([t,e])=>n.on(t,e)),x(),a[o]=y,y}function S(t,e,n,o,r,i=0){return t.map(t=>{const s=(i+n/2-e-(t.start+t.end)/2)/o,a=Math.round(s);return{k:a,offset:r>0?a+.5-s:s-a+.5}})}function E(t,e){return t-Math.ceil(t/e)*e}const{abs:M,floor:T,round:z}=Math;function k(t,e,n){return Math.min(n,Math.max(e,t))}function A(t,e,n){return n?(t%e+e)%e:k(t,0,e-1)}function L(t,e,n,o){return"function"==typeof t?t(e,n,o):"center"===t?(e-n)/2:"end"===t?e-n:0}function O(t){let e=1/0,n=-1/0,o=0;for(const r of t)r.hidden||(e=Math.min(e,r.start),n=Math.max(n,r.end),o=Math.max(o,r.end-r.start));return{start:e,end:n,size:n-e,max:o}}function F(t,e,n=0){let o=-1,r=1/0;return t.forEach((t,i)=>{const s=e(t,i);r-n>s&&(r=s,o=i)}),o}function I(t,e,n){const o=t-e;return n?o-z(o/n)*n:o}function P(t,e,n,o,r,i=0,s=t.length){return F(t,(t,a)=>i>a||a>=s||t.hidden?1/0:M(I(t.start+e,L(o,n,t.end-t.start,a),r)),.5)}function C(t,e,n){return Math.max(0,F(t,t=>M(I(t.location,e,n))))}function N(t,e,n,o=0){return n?o>0?t+(Math.ceil((e-.5-t)/n)-1)*n:0>o?t+(T((e+.5-t)/n)+1)*n:e+I(t,e,n):t}function _(t,{min:e,max:n,period:o}){if(o){const e=(n-t)/o;return e-T(e)}return n>e?k((n-t)/(n-e),0,1):0}function W({slides:t,view:e,period:n},o,r){const i=[];return t.forEach((t,s)=>{const a=t.end-t.start,l=n?I(t.start+o+a/2,e/2,n)+e/2-a/2:t.start+o,c=Math.min(l+a,e)-Math.max(l,0);t.hidden||0>=c||r*a-.5>c||i.push(s)}),i}function H(t){return"x"===t?document.documentElement.clientWidth:innerHeight}const q=new WeakMap,B=new WeakMap,D=new WeakMap;let j;function R(t,e){j||=new ResizeObserver(t=>{const e=[...new Set(t.filter(t=>{const{inlineSize:e,blockSize:n}=t.borderBoxSize[0],o=e+","+n,r=D.get(t.target)===o;return D.set(t.target,o),!r&&!q.get(t.target)?.skip(t)}).map(t=>q.get(t.target)))].filter(t=>t?.read());e.forEach(t=>t.write()),e.length&&(e.forEach(t=>B.get(t)?.forEach(t=>j.unobserve(t))),requestAnimationFrame(()=>e.forEach(t=>B.get(t)?.forEach(e=>q.get(e)===t&&j.observe(e)))))}),e&&B.set(e,t);for(const n of t)D.delete(n),e?(q.set(n,e),j.observe(n)):(q.delete(n),j.unobserve(n))}const G=new Map,V=new WeakMap;let X=[];function Y(){const t=X,e=t.map(([t])=>t.getBoundingClientRect());X=[],t.forEach(([t,n,o],r)=>{const i=!0===n?innerHeight:n,s=e[r],a=V.get(t);if(!a)return;if(s.height&&s.bottom>=-i&&s.top<=innerHeight+i)return void a();let l=G.get(o);l||(l=new IntersectionObserver(t=>t.forEach(t=>t.isIntersecting&&V.get(t.target)?.()),{rootMargin:o}),G.set(o,l)),l.observe(t)})}const K=[.25,1,.5,1],J=[.2,.6,.35,1];function U([t,e,n,o]){const r=(t,e,n)=>((1+3*t-3*e)*n+3*e-6*t)*n*n+3*t*n;return i=>{if(0>=i||i>=1)return i>0?1:0;let s=i;for(let a=0;6>a;a++){const a=r(t,n,s)-i,l=3*(1+3*t-3*n)*s*s+2*(3*n-6*t)*s+3*t;if(1e-5>M(a))return r(e,o,s);if(1e-6>M(l))break;s-=a/l}let a=0,l=1;for(s=i;l-a>1e-5;)r(t,n,s)<i?a=s:l=s,s=(a+l)/2;return r(e,o,s)}}const Q={axis:"auto",align:"auto",dir:"auto",loop:!1,dragFree:!1,dragFriction:1,containScroll:"trimSnaps",slidesPerSnap:1,skipSnaps:!0,dragThreshold:10,duration:400,startSnap:0,lazy:!1,drag:!0,wheel:!0,keys:!0,resize:!0,slideChanges:!0,focus:!0,inViewThreshold:0,active:!0,breakpoints:{},container:null,slides:null,wrapper:!0,arrows:!0,dots:!0,dotsStyle:"zoom",labels:{carousel:"Carousel",slide:"%d of %n",prev:"Previous slide",next:"Next slide",dot:"Go to slide %d",play:"Start the slide show",pause:"Stop the slide show"},classes:null,state:"",sync:null,clones:"auto",autoplay:!1,autoScroll:!1,autoHeight:!1,progress:!1,offset:!1},Z=t=>({root:t,viewport:t+"_viewport",container:t+"_container",fit:t+"_fit",horizontal:t+"_horizontal",vertical:t+"_vertical",autoHeight:t+"_auto_height",button:t+"_button",prevButton:t+"_prev",nextButton:t+"_next",dots:t+"_dots",dotsTrack:t+"_dots_track",dotsMarker:t+"_dots_marker",dotsAll:t+"_dots_all",dot:t+"_dot",playButton:t+"_play",clone:"clone",selected:"selected",inView:"",dragging:"dragging",playing:"playing",first:"first",prev:"prev",current:"current",next:"next",last:"last"}),$=["selected","inView","dragging","playing","first","prev","current","next","last"];function tt(...t){const e={};for(const n of t)for(const t in n){const o=n[t],r=e[t];e[t]=o&&r&&"object"==typeof o&&"object"==typeof r&&o.constructor===Object&&r.constructor===Object?{...r,...o}:o}return e}function et(t,...e){let n={};try{n=JSON.parse(t.dataset.carousel||"{}")}catch{}return tt(Q,...e,n)}const nt=new WeakMap;let ot;const rt=t=>nt.get(t),it="input,textarea,select,[contenteditable]",st=new WeakSet,at=[t=>{const{viewport:e,options:n}=t;if(!n.drag)return;let o,i,s,a=null,l=!1,c=[],d=0;const u=r(window,[["pointermove",p],["pointerup",p],["pointercancel",p]]);function p(r){if(r.pointerId!==a)return;if("pointermove"!==r.type)return c.length&&c.push([c[c.length-1][0],r.timeStamp]),f("pointerup"===r.type);const l=(r.clientX-o[0])/s.scale,u=(r.clientY-o[1])/s.scale,p=s.x?l*s.sign:u,g=s.x?u:l;if(!t.dragging()){if("mouse"!==r.pointerType&&M(g)>M(p))return f();if(M(p)<n.dragThreshold)return;i=t.halt(),d=t.selected(),t.drag(!0),e.setPointerCapture(a)}const h=t.geo(),m=i+p,v=k(m,h.min,h.max);t.hold(h.period?m:v+(m-v)/4,!0),c.push([p,r.timeStamp]),c.length>10&&c.shift()}function f(e){if(u(),a=null,!t.dragging())return;const o=t.geo(),r=t.location(),s=e?(t=>{const e=t[t.length-1],n=t.find(t=>100>=e[1]-t[1]),o=e[1]-n[1];return o>0?(e[0]-n[0])/o:0})(c):0,p=(({location:t,from:e,velocity:n,current:o,snaps:r,min:i,max:s,period:a,skipSnaps:l,dragFree:c,dragFriction:d=1})=>{const u=r.length;let p=t+325*n/d;if(a||(p=k(p,i,s)),"number"==typeof l&&l>0&&u-1+!a>l){const t=t=>N(r[A(o+t*l,u,a)].location,e,a,t);p=k(p,t(1),t(-1))}if(!0===c)return{location:p,snap:C(r,p,a)};if(c||l){const t=C(r,p,a);return{location:N(r[t].location,p,a),snap:t}}const f=t-e;let g=0;M(n)>.3?g=0>n?1:-1:M(f)>20&&(g=0>f?1:-1);const h=A(o+g,u,a),m=r[h].location;return{location:a?N(m,g?e:t,a,h===o?0:g):m,snap:h}})({...o,...n,location:r,from:i,velocity:s,current:d}),f=!0===n.dragFree?J:K;l=!0,t.drag(!1),t.move(p.snap,p.location,((t,e,n,o)=>Math.sign(t)!==Math.sign(e)||.05>M(e)?o:k(M(t)*n[1]/n[0]/M(e),200,1200))(p.location-r,s,f,n.duration),f)}const g=r(e,[["pointerdown",e=>{l=!1;const n=t.geo();null!==a||e.button||!n||n.fit||st.has(e)||e.target.closest(it)||(st.add(e),"mouse"===e.pointerType&&e.preventDefault(),a=e.pointerId,s={x:"x"===n.axis,sign:n.sign,scale:n.scale},o=[e.clientX,e.clientY],c=[],u(!0))}],["click",t=>{l&&(l=!1,t.preventDefault(),t.stopPropagation())},!0],["dragstart",t=>t.preventDefault()],["selectstart",e=>t.dragging()&&e.preventDefault()]]);return g(!0),{remove(){u(),g()}}},t=>{const{viewport:e,options:n}=t,o=!0===n.dragFree;if(!n.wheel)return;let i=0,s=0,a=!1,l=!1,c=0,d=0,u=0;function p(){c=0;const e=t.geo(),n=t.current(),o=C(e.snaps,n,e.period),r=M(N(e.snaps[o].location,n,e.period)-n)>10;t.step(o,o===d&&r?u:0)}const f=r(e,[["wheel",r=>{const f=t.geo(),g="x"===f.axis&&M(r.deltaX)>M(r.deltaY),h=g?r.deltaX*f.sign:r.deltaY;if(r.ctrlKey||!h||t.dragging()||"axis"===n.wheel&&"x"===f.axis&&!g)return;const m=r.timeStamp,v=200>m-i,x=M(h),y=v&&s>=x;if(i=m,s=x,a&&=v,l=v&&l||((t,e,n,o)=>{const[r,i,s,a]="x"===n?["scrollWidth","clientWidth","scrollLeft","overflowX"]:["scrollHeight","clientHeight","scrollTop","overflowY"];for(;t&&t!==e;t=t.parentElement)if(t[r]>t[i]&&/auto|scroll/.test(getComputedStyle(t)[a])){const e=M(t[s]);if(o>0?t[r]-1>e+t[i]:e>0)return!0}return!1})(r.target,e,g?"x":"y",g?r.deltaX:h),l)return;const w=t.location(),b=h*(1===r.deltaMode?40:r.deltaMode?f.view:1);let S=w-b;f.period||(S=k(S,f.min,f.max)),.5>M(S-w)?a&&y&&r.preventDefault():(r.preventDefault(),t.emit("interact"),c||(d=t.selected()),a=!0,u=b>0?1:-1,t.move(C(f.snaps,S,f.period),S,180,K),clearTimeout(c),o||(c=setTimeout(p,150)))},{passive:!1}]]);return t.on("init reinit resize",()=>{const e=t.geo();f(!e.fit&&("y"===e.axis||!0!==n.wheel))}),{remove(){f(),clearTimeout(c)}}},t=>{const{api:e,root:n,options:o}=t;if(!o.keys)return;const i=r(n,[["keydown",n=>{const o=t.geo(),{key:r,target:i}=n,s=o&&!o.fit&&("y"===o.axis?{ArrowUp:-1,ArrowDown:1}:{ArrowLeft:-o.sign,ArrowRight:o.sign})[r],a=s>0?"Next":"Prev";s&&!(n.altKey||n.ctrlKey||n.metaKey||n.shiftKey||i.closest(it))&&e["canGoTo"+a]()&&(n.preventDefault(),e["goTo"+a]())}]]);return i(!0),{remove:i}},t=>{const{api:e,container:n,options:o}=t;let i=-1e4;const s=r(n,[["pointerdown",t=>{t.target.closest(it)||(i=t.timeStamp)}],["focusin",n=>{const r=t.geo(),s=e.slideNodes().findIndex(t=>t.contains(n.target));!r||0>s||600>n.timeStamp-i||(o.focus&&!W(r,t.location(),1).map(t=>t%r.count).includes(s)&&e.goToSlide(s),t.emit("slidefocus"))}]]);return s(!0),{remove:s}},o=>{const{api:r,root:l,cls:c,options:d}=o,u=d.labels,p=a(d.arrows,l),f=a(d.dots,l),g=[],h=[],m="all"!==d.dotsStyle,v=f&&i("div",m?c.dots:c.dots+" "+c.dotsAll),x=v&&i("div",c.dotsTrack);let y=new Map;if(p||f)return v&&(x.append(i("span",c.dotsMarker)),v.append(x),f.append(v)),p&&g.push(s(c.button+" "+c.prevButton,o.container,u.prev,()=>r.goToPrev()),s(c.button+" "+c.nextButton,o.container,u.next,()=>r.goToNext())),o.on("init reinit resize select slideschanged",()=>{const i=r.isFit(),a=i?0:o.geo().logical.length,l=r.selectedSnap();if(g.forEach((t,e)=>{if(i)t.remove();else{t.isConnected||(v?.parentNode===p?v.before(t):p.append(t));const n=!(e?r.canGoToNext():r.canGoToPrev());t.disabled!==n&&(t.disabled=n)}}),!v)return;if(2>a)return void v.remove();for(;h.length>a;)h.pop().remove(),y.delete(h.length);for(;a>h.length;){const t=h.length,e=s(c.dot,o.container,u.dot.replace("%d",t+1),()=>r.goToSnap(t));m&&(e.tabIndex=-1),h.push(e),x.append(e)}v.isConnected||f.append(v);const d=new Map;["first","prev","current","next","last"].forEach((t,e)=>{h[l+e-2]&&d.set(l+e-2,c[t])}),y.forEach((n,o)=>{d.get(o)!==n&&(t(h[o],n,!1),e(h[o],"aria-current",!1),h[o].tabIndex=m?-1:0)}),d.forEach((n,o)=>{t(h[o],n,!0),e(h[o],"aria-current",o===l&&"true"),h[o].tabIndex=0}),y=d,m&&n(v,"--better-shift",2-(Math.max(0,l-2)+Math.min(a-1,l+2))/2),n(v,"--better-dot",l)}),{remove(){g.forEach(t=>t.remove()),v?.remove()}}},t=>{if(!t.options.autoplay)return;const e=t.api,n=w(x,"delay",t.options.autoplay);let o=0,r=null,i=!1;function s(){clearTimeout(o),r?.(),r=null}function a(){if(s(),!c.paused()&&!e.isFit()){const t=e.slideNodes()[e.selectedSlide()]?.dataset.delay||n.delay,i=+(Array.isArray(t)?t[e.selectedSnap()]:t);o=setTimeout(l,i),r=n.timer?.(i,e)}}function l(){s(),i=!0,e.canGoToNext()?e.goToNext(n.instant):n.stopOnLastSnap?c.stop():e.goToSnap(0,n.instant),i=!1}const c=b(t,"autoplay",n,{play:a,stop:s,pause:a,events:[["settle",a],["interact",()=>{i||(s(),n.stopOnInteraction&&c.stop())}]]});return c.reset=a,c},t=>{if(!t.options.autoScroll)return;const e=w(y,"speed",t.options.autoScroll);let n=0,o=!1;const i=b(t,"autoScroll",e,{play(){c(!0),s()},stop(){c(),l(),o=!1,s(-1),t.halt()},pause(e){e?t.halt():n||a()},events:[["settle",()=>i.isPlaying()&&s()],["resize",()=>i.isPlaying()&&!n&&a()],["interact",()=>{i.isPlaying()&&(s(-1),e.stopOnInteraction&&i.stop())}]]});function s(t){clearTimeout(n),n=t?0:setTimeout(a,e.startDelay)}function a(){n=0;const r=t.geo();!r||r.fit||o||t.dragging()||i.paused()||t.scroll("prev"===e.direction?-1:1,e.speed/1e3)}const l=r(window,[["pointerup",d],["pointercancel",d]]),c=r(t.viewport,[["pointerdown",e=>{e.button||o||(o=!0,s(-1),t.halt(),l(!0))}]]);function d(){o=!1,l(),t.dragging()||s()}return i},t=>{const{api:e,container:n}=t,o=t.options.sync;let i=null;if(!o)return;function s(n){const o=i.selectedSlide();t.follow(o),e.goToSlide(o,!0===n)}t.on("init reinit",()=>{i||(i=o.goToSnap?o:t.find("string"==typeof o?a(o,t.root):o),i&&(i.on("select",s),s(!0)))});const l=r(n,[["click",t=>{const n=e.slideNodes().findIndex(e=>e.contains(t.target));i&&n>-1&&i.goToSlide(n)}]]);return l(!0),{remove(){i?.off("select",s),l()}}}];function lt(e,r={}){return((e,r,s,a)=>{const g=nt.get(e);if(g)return g;let x,y,w,b,q,B,D,j,J=[],Q=[],it=[],st=[],at=[],lt=null,ct=!1,dt=!1,ut=!1,pt=[],ft=0,gt=-1,ht=0,mt=null,vt=0,xt=0,yt=0,wt=-1,bt=-1,St=[],Et={axis:"",container:0,slides:[]},Mt=!1,Tt=!1;const zt={goToSnap:(t,e)=>se(Gt(t),e),goToNext:t=>re(1,t),goToPrev:t=>re(-1,t),goToSlide:(t,e)=>se(Gt(zt.snapOfSlide(t)),e,t),canGoToNext:()=>oe(1),canGoToPrev:()=>oe(-1),selectedSnap:()=>Rt(xt),previousSnap:()=>Rt(yt),selectedSlide:Vt,snapOfSlide:t=>mt?Rt((({snaps:t,slides:e,view:n,align:o,period:r},i)=>{const s=t.findIndex(t=>t.slide===i),a=e[i];return s>-1||!a?Math.max(s,0):C(t,L(o,n,a.end-a.start,i)-a.start,r)})(mt,t)):t,snapProgress:()=>mt?mt.logical.map(t=>_(mt.snaps[t].location,mt)):[],progress:()=>mt?_(Xt(),mt):0,slideNodes:()=>J.slice(),slidesInView:()=>St.slice(),rootNode:()=>w,viewportNode:()=>b,containerNode:()=>q,isFit:()=>!mt||mt.fit,options:()=>x,reinit:_t,destroy(){Nt(!1),kt.emit("destroy")}},kt=(t=>{const e={},n={},o=(t,e,n)=>(t[e]||=new Set).add(n);return{on:(n,r)=>(o(e,n,r),t),off:(n,o)=>(e[n]?.delete(o),t),listen(t,e){return t.split(" ").forEach(t=>o(n,t,e))},clear(){return Object.values(n).forEach(t=>t.clear())},emit(o){n[o]?.forEach(e=>e(t,o)),e[o]?.forEach(e=>e(t,o))},has(t){return!!e[t]?.size}}})(zt),At={read:Yt,write:Jt,skip({target:t,contentRect:{width:e}}){if(t!==b)return!1;const n=e===ft;return ft=e,n&&x.autoHeight&&"x"===mt?.axis}},Lt={progress:0,snap:0},Ot={node:null,index:0,offset:0,distance:0,size:0,visible:0},Ft={api:zt,emit:kt.emit,on:kt.listen,find:rt,geo:()=>mt,selected:()=>xt,dragging:()=>Mt,location:()=>Tt?Xt():vt,current:Xt,hold(t,e){vt=t,(e?de:$t)(t),ce()},halt:pe,step:ie,scroll(t,e){const n=pe(),o=t>0?mt.min:mt.max;mt.period?(Tt=!0,vt=E(n,mt.period),j.loop(vt,t,mt.period/e,mt,it)):M(o-n)>1&&(Tt=!0,vt=o,j.run(n,o,M(o-n)/e,[0,0,1,1],kt.has("scroll")))},move(t,e,n,o){wt=-1,ae(t,e,n,o)},drag(e){Mt=e,t(w,y.dragging,e),e?(kt.emit("interact"),kt.emit("dragstart")):kt.emit("dragend")},follow(t){bt=t}};zt.on=kt.on,zt.off=kt.off;let It=et(e,s,r),Pt=It.lazy?((t,e,n)=>{const o=!0===e?"100%":e+"px";return X.length||queueMicrotask(Y),X.push([t,e,o]),V.set(t,n),()=>{G.get(o)?.unobserve(t),V.delete(t)}})(e,It.lazy,_t):null;return Pt?nt.set(e,zt):Ct(),zt;function Ct(){if(lt=((t,e)=>{const n=Object.entries(t.breakpoints||{}).map(([t,e])=>[matchMedia(t),e]);return n.forEach(([t])=>t.addEventListener("change",e)),{options:tt(t,...n.filter(([t])=>t.matches).map(([,t])=>t)),remove(){return n.forEach(([t])=>t.removeEventListener("change",e))}}})(It||et(e,s,r),()=>_t()),It=null,x=lt.options,x.active){y=((t,e)=>{const n="string"==typeof t?Z(t):{...Z(t?.prefix||"better"),...t};for(const t of $)n[t]&&(n[t]=e+n[t]);return n})(x.classes,x.state),({root:w,viewport:b,container:q}=((t,e,n)=>{let o=e.container?t.querySelector(e.container):t;o.classList.contains(n.viewport)&&(o=o.firstElementChild);let r=o.parentElement,s=r.parentElement;return p.has(r)||r.classList.contains(n.viewport)||!e.wrapper||(s=i("div"),r=i("div"),p.add(s).add(r),o.before(s),s.append(r),r.append(o)),u(s,n.root),u(r,n.viewport),u(o,n.container),d(s,"role","region"),d(s,"aria-roledescription","carousel"),s.hasAttribute("aria-labelledby")||d(s,"aria-label",e.labels.carousel),d(o,"id",o.id||"carousel-"+ ++f),d(o,"aria-live","polite"),{root:s,viewport:r,container:o}})(e,x,y));for(const t of[w,b,q])nt.set(t,zt);J=h(q,x.slides),it=J,xt=x.startSnap,Bt(!0),Object.assign(Ft,{root:w,viewport:b,container:q,cls:y,options:x}),st=a.map(t=>t(Ft)).filter(Boolean),j=((t,e,n,o,r)=>{let i=null;const s=()=>i.animations?i.animations[0].currentTime||0:performance.now()-i.start,a=()=>i&&i.from+(i.to-i.from)*i.ease(s()/i.duration);function l(){if(!i.animations&&s()>=i.duration)return c();i.raf=requestAnimationFrame(l),(i.animations?r:n)(a())}function c(){const t=i.to;d(),n(t),o()}function d(){const t=a();return i&&(i.animations?.forEach(t=>t.cancel()),cancelAnimationFrame(i.raf),i=null),t}function u(n){const o=t.animate([{translate:e(i.from)},{translate:e(i.to)}],{duration:i.duration,easing:"cubic-bezier("+i.curve+")",fill:"forwards"});o.currentTime=n,o.onfinish=c,i.animations=[o]}function p(n,o){if(d(),i=n,n.list){const r={duration:n.duration,iterations:1/0},i=document.timeline.currentTime,{from:s,to:a,length:l,direction:c}=n;n.animations=[t.animate([{translate:e(s)},{translate:e(a)}],r),...o.map((t,o)=>{const{k:i,offset:s}=n.list[o],a=e(i*l),d=e((i+c)*l);return t.animate([{translate:a},{translate:a,offset:s},{translate:d,offset:s},{translate:d}],r)})],n.animations.forEach(t=>t.startTime=i)}else n.script?n.start=performance.now():u(0);(n.script||r)&&(n.raf=requestAnimationFrame(l))}return{run(t,e,n,o,r){return p({from:t,to:e,duration:n,curve:o,script:r,ease:U(o)})},loop(t,e,n,o,r){return p({from:t,to:t-e*o.period,duration:n,direction:e,length:o.period,list:S(o.slides,t,o.area.size,o.period,e,o.area.start),ease(t){return t%1}},r)},retarget(t){if(!i||i.list)return!1;if(t!==i.to&&(i.to=t,i.animations)){const t=s();i.animations[0].cancel(),u(t)}return!0},stop:d,current:a,shifts(t){if(!i?.list)return null;const e=s()/i.duration%1;return i.list.map(({k:n,offset:o})=>t*(o>e?n:n+i.direction)*i.length)}}})(q,ne,de,ue,(x.progress||x.offset)&&(t=>te(t,j.shifts(mt.sign)||Et.slides))),x.autoHeight&&u(w,y.autoHeight),b.addEventListener("scroll",fe),b.addEventListener("click",ge),b.addEventListener("input",qt),x.loop&&"fill"===x.clones&&addEventListener("resize",Kt),x.slideChanges&&(B=new MutationObserver(Dt),B.observe(q,{childList:!0}))}}function Nt(r){if(Pt?.(),Pt=null,nt.delete(e),Bt(!1),B?.disconnect(),lt?.remove(),lt=null,y){j.stop(),st.forEach(t=>t.remove()),kt.clear(),st=[],bt=-1,Mt=Tt=!1,Wt(0),b.removeEventListener("scroll",fe),b.removeEventListener("click",ge),b.removeEventListener("input",qt),removeEventListener("resize",Kt);for(const e of it)n(e,"translate",""),n(e,"--better-offset",""),t(e,y.selected,!1),t(e,y.inView,!1),o(e);n(q,"translate",""),n(q,"will-change",""),n(b,"touch-action",""),n(b,"height",""),n(w,"--better-progress","");for(const e of["horizontal","vertical","fit","dragging"])t(w,y[e],!1);for(const t of[w,b,q])o(t),nt.delete(t);((t,e,n,o,r)=>{for(const r of[t,e,n,...o])l.get(r)?.forEach(t=>r.removeAttribute(t)),c.get(r)?.forEach(t=>r.classList.remove(t)),l.delete(r),c.delete(r),""===r.getAttribute("class")&&r.removeAttribute("class");!r&&p.has(t)&&(t.before(n),t.remove())})(w,b,q,J,r),y=mt=null,ct=!1,vt=0,St=[],pt=[],ft=0,Et={axis:"",container:0,slides:[]}}}function _t(t){t&&(r=tt(r,t),It=null);const e=mt?Vt():wt;Ft.playing=t?null:{},Nt(!0),Ct(),wt=e}function Wt(e){Q.length!==e*J.length&&(Q.forEach(t=>t.remove()),Q=((e,n,r)=>{const i=[];for(let s=0;n>s;s++)for(const n of e){const e=m(n);e.setAttribute("aria-hidden","true"),e.inert=!0,e.style.translate="",t(e,r,!0),o(e),p.add(e),i.push(e)}return i})(J,e,y.clone),q.append(...Q),it=J.concat(Q),Et.slides.length=J.length,B?.takeRecords(),D?.disconnect(),Q.length&&(D||=new MutationObserver(Ht),J.forEach(t=>D.observe(t,{childList:!0,characterData:!0,subtree:!0,attributeFilter:["class","src","srcset","href","value"]}))))}function Ht(t){J.forEach((e,n)=>{if(!t||t.some(({type:t,target:n})=>e.contains(n)&&("attributes"!==t||n!==e)))for(let t=n;Q.length>t;t+=J.length)v(Q[t],e)})}function qt(){Ht()}function Bt(t){R(at),at=t?[b,q,...it]:[],R(at,At)}function Dt(){const t=ct?Vt():-1,e=J[t];if(J=h(q,x.slides),t>-1){const n=J.indexOf(e);wt=n>-1?n:Math.min(t,J.length-1)}Wt(0),it=J,ut=!0,Bt(!0)}function jt(t){return t%J.length}function Rt(t){return mt?mt.map[t]??0:t}function Gt(t){return mt?((t,e,n)=>{const o=F(t.snaps,(o,r)=>t.map[r]===e?M(I(o.location,n,t.period)):1/0);return 0>o?k(e,0,t.snaps.length-1):o})(mt,t,Xt()):t}function Vt(){return bt>-1?bt:mt?0>wt||zt.snapOfSlide(wt)!==Rt(xt)?jt(mt.snaps[xt].slide):wt:Math.max(wt,0)}function Xt(){return j.current()??vt}function Yt(){const t=mt?.sign||1,e=j.current(),n=((t,e)=>{const n=getComputedStyle(t),o=n.display,r=n.justifyContent;let i=e.axis;"auto"===i&&(i="x",o.includes("grid")?i=n.gridAutoFlow.startsWith("column")?"x":"y":o.includes("flex")&&n.flexDirection.startsWith("column")&&"nowrap"===n.flexWrap&&(i="y"));let s=e.align;"auto"===s&&(s="center"===r?"center":"flex-end"===r||"end"===r||"x"===i&&"right"===r?"end":"start");const a="x"===i&&("auto"===e.dir?"rtl"===n.direction:"rtl"===e.dir);return{axis:i,align:s,rtl:a,sign:a?-1:1,gap:parseFloat("x"===i?n.columnGap:n.rowGap)||0}})(q,x);ht=x.loop&&"fill"===x.clones?H(n.axis):0;const o=((t,e,n,o,r)=>{const i=t.getBoundingClientRect(),s="x"===n.axis,a=n.sign,l=o.axis===n.axis,c=l?o.container:0,d=t.offsetWidth,u=t.offsetHeight,p=!d||!u||1>M(i.width-d)&&1>M(i.height-u)?1:s?i.width/d:i.height/u,f=(s?i.width:i.height)/p,g=getComputedStyle(t),h=s?n.rtl?["Right","Left"]:["Left","Right"]:["Top","Bottom"],m={start:parseFloat(g["padding"+h[0]])||0,end:parseFloat(g["padding"+h[1]])||0},v=e.map((t,e)=>{const r=t.getBoundingClientRect(),d=(s?n.rtl?i.right-r.right:r.left-i.left:r.top-i.top)/p-m.start-a*(c+(l&&o.slides[e]||0));return{start:d,end:d+(s?r.width:r.height)/p,cross:(s?r.height:r.width)/p,hidden:!r.width&&!r.height}});let x=v.find(t=>!t.hidden)?.start||0,y=-1,w=-1,b=n.gap;v.forEach((t,e)=>{t.hidden?t.start=t.end=x:(x=t.end,(0>y||v[y].start>t.start)&&(y=e),(0>w||t.end>v[w].end)&&(w=e))}),y>-1&&(b+=(parseFloat(getComputedStyle(e[y])["margin"+h[0]])||0)+(parseFloat(getComputedStyle(e[w])["margin"+h[1]])||0));const S=f-m.start-m.end;let E=m.start,T=S+m.end;return r&&(E+=Math.max(0,z(s?n.rtl?r-i.right:i.left:i.top)),T=Math.max(T,z(r-E))),{view:S,slides:v,gap:b,scale:p,area:{start:-E,size:E+T}}})(b,it,n,null===e?Et:{axis:Et.axis,container:t*e,slides:j.shifts(t)||Et.slides},ht),r=[n.axis,n.rtl,"string"==typeof n.align&&n.align,o.view,o.gap,o.area.start,o.area.size,...o.slides.flatMap(t=>[t.start,t.end,t.cross])];if(ct&&r.length===pt.length&&r.every((t,e)=>t===pt[e]||.5>M(t-pt[e])))return!1;pt=r;const i=ct&&!ut?Vt():wt,s=function(t,e,n,o){const r=O(e.slides.slice(0,n)),i=!(r.size>e.view+1||o.autoScroll&&o.loop&&r.max),s=o.loop&&!i&&n,a=s?O(e.slides).size+e.gap:0,l=s&&o.clones&&(c=r.size+e.gap)>0?Math.max(0,Math.ceil((e.area.size+r.max)/c)-1):0;var c;if(l*n!==e.slides.length-n)return{copies:l};const d={...t,...e,fit:i,count:n,period:a,min:0,max:0};i?d.snaps=[{location:0,slide:Math.max(0,P(e.slides,0,e.view,t.align))}]:Object.assign(d,(({slides:t,view:e,align:n,slidesPerSnap:o,containScroll:r,period:i=0})=>{const s=O(t);let a=-s.start||0,l=e-s.end,c=((t,e,n)=>{const o=[];let r,i=0;for(const s of t)r&&("auto"===n?r&&e+1>=s.end-r.start:n>i)?(r.end=Math.max(r.end,s.end),i++):(r={start:s.start,end:s.end},o.push(r),i=1);return o})((t=>{const e=t.map((t,e)=>e).filter(e=>!t[e].hidden).sort((e,n)=>t[e].start-t[n].start||e-n),n=[];let o;for(const r of e){const e=t[r];o&&1>=e.start-o.start?o.end=Math.max(o.end,e.end):(o={start:e.start,end:e.end},n.push(o))}return n})(t),e,o).map((t,o)=>L(n,e,t.end-t.start,o)-t.start);i||(r?c=c.map(t=>k(t,l,a)):(a=Math.max(...c),l=Math.min(...c))),(i||"keepSnaps"!==r)&&(c=c.filter((t,e)=>!e||M(I(t,c[e-1],i))>1),i&&c.length>1&&1>=M(I(c[0],c[c.length-1],i))&&c.pop());const d=c.map(o=>({location:o,slide:P(t,o,e,n,i)})),u=(o,r,i)=>{const s=P(t,o.location,e,n,0,r,i);o.slide=s>-1?s:o.slide};if(!i&&d.length>1){const e=d[0],n=d[d.length-1];d[1].slide>e.slide||u(e,0,d[1].slide),n.slide>d[d.length-2].slide||u(n,d[d.length-2].slide+1,t.length)}return{snaps:d,min:l,max:i?c[0]:a}})({...e,align:t.align,slidesPerSnap:o.slidesPerSnap,containScroll:o.containScroll,period:a}));const u=d.snaps.map((t,e)=>e).filter(t=>!l||n>d.snaps[t].slide);return d.logical=u,d.map=d.snaps.map((t,e)=>l?Math.max(0,u.findIndex(e=>d.snaps[e].slide%n===t.slide%n)):e),d}(n,o,J.length,x);if(!s.snaps)return gt=s.copies,!0;mt=s;const a=mt.snaps.length;return xt=0>i?Math.min(a-1,ct?xt:Gt(A(xt,mt.logical.length,mt.period))):Gt(zt.snapOfSlide(i)),yt=Math.min(yt,a-1),wt=i,Mt||(vt=N(mt.snaps[xt].location,vt,mt.period)),!0}function Kt(){mt&&H(mt.axis)!==ht&&Yt()&&Jt()}function Jt(){if(gt>=0)return Wt(gt),gt=-1,pt=[],void Bt(!0);Tt&&pe();const t=j.current();null!==t&&Et.axis===mt.axis&&!mt.fit&&j.retarget(vt)?(ee(t,vt),Ut(!0)):(j.stop(),Ut(Mt)),((t,e)=>{t.forEach((n,o)=>{n.matches("a[href],button,input,select,textarea,[tabindex],[role]")&&!l.get(n)?.has("role")||(n.matches("div,span,section")&&d(n,"role","group"),d(n,"aria-roledescription","slide"),d(n,"aria-label",e.replace("%d",o+1).replace("%n",t.length)))})})(J,x.labels.slide),x.resize||Bt(!1),ct?kt.emit("resize"):(ct=!0,kt.emit(dt?"reinit":"init"),dt=!0),ut&&(ut=!1,kt.emit("slideschanged"))}function Ut(e){const o="x"===mt.axis;t(w,y.horizontal,o),t(w,y.vertical,!o),t(w,y.fit,mt.fit);const r=!oe(-1),i=!oe(1),s=!o&&(r||i)&&(ot??=CSS.supports("touch-action","pan-up"))?r&&i?"pan-y ":r?"pan-up ":"pan-down ":"";n(b,"touch-action",mt.fit?"":o?"pan-y pinch-zoom":"pan-x "+s+"pinch-zoom"),n(q,"will-change",mt.fit?"":"translate"),e||$t(mt.fit?0:vt),x.autoHeight&&n(b,"height",o?Math.max(...W(mt,vt,0).map(t=>mt.slides[t].cross))+"px":"");const a=Vt(),l=[...new Set(W(mt,vt,x.inViewThreshold).map(jt))].sort((t,e)=>t-e);it.forEach((e,n)=>t(e,y.selected,jt(n)===a)),l.join()!==St.join()&&(St=l,it.forEach((e,n)=>t(e,y.inView,l.includes(jt(n)))),kt.emit("slidesinview"))}function Qt(t){const e=devicePixelRatio||1;return z(t*e)/e*mt.sign}function Zt(t){return t?"x"===mt.axis?t+"px":"0 "+t+"px":""}function $t(t){Et.axis!==mt.axis&&(it.forEach(t=>n(t,"translate","")),Et={axis:mt.axis,container:0,slides:[]}),Et.container=Qt(t),n(q,"translate",Zt(Et.container)),ee(t,t),te(t,Et.slides)}function te(t,e){if(!0===x.progress)w.style.setProperty("--better-progress",_(t,mt));else if(x.progress){const e=((t,e,n)=>{const o=t.length-1,r=t[0].location,i=n?r-((r-e)%n+n)%n:k(e,t[o].location,r);let s=0;for(;o>s&&t[s+1].location>=i;)s++;const a=t[s].location,l=o>s?t[s+1].location:r-n;return s+(a>l?(a-i)/(a-l):0)})(mt.snaps,t,mt.period),n=T(e);Lt.progress=_(t,mt),Lt.snap=Rt(n)+e-n,x.progress(Lt,zt)}x.offset&&it.forEach((n,o)=>{const r=mt.slides[o],i=r.end-r.start,s=r.start+mt.sign*(e[o]||0)+t,a=s-L(mt.align,mt.view,i,o),l=a/(i+mt.gap);!0===x.offset?n.style.setProperty("--better-offset",l):(Ot.node=n,Ot.index=jt(o),Ot.offset=l,Ot.distance=mt.sign*a,Ot.size=i,Ot.visible=k((Math.min(s+i,mt.view)-Math.max(s,0))/i,0,1)||0,x.offset(Ot,zt))})}function ee(t,e){const o=mt.period?((t,e,n,o,r,i=0)=>{const s=i+(o-e-n)/2;return t.map(t=>Math.round((s-(t.start+t.end)/2)/r)||0)})(mt.slides,t,e,mt.area.size,mt.period,mt.area.start):[];it.forEach((t,e)=>{const r=o.length?Qt(o[e]*mt.period):0;(Et.slides[e]||0)!==r&&(Et.slides[e]=r,n(t,"translate",Zt(r)))})}function ne(t){return Zt(Qt(t))||"0px"}function oe(t){return!(!mt||mt.fit||!mt.period&&!(t>0?mt.snaps.length-1>xt:xt>0))}function re(t,e){mt?oe(t)&&ie(xt,t,e):se(xt+t,e)}function ie(t,e,n){se(A(t+e,mt.snaps.length,mt.period),n,-1,e)}function se(t,e,n=-1,o=0){if(Pt&&_t(),kt.emit("interact"),wt=n,!mt)return void(xt=t);const r=N(mt.snaps[t].location,Xt(),mt.period,o),i=M(t-xt);var s,a;ae(t,r,e?0:(s=x.duration,(a=mt.period?Math.min(i,mt.snaps.length-i):i)>1?Math.min(2*s,s*(1+Math.log2(a))):s),K)}function ae(t,e,n,o){const r=pe(),i=le(t),s=!n||mt.fit||.5>M(e-r);if(vt=e,s)Ut();else{const t=kt.has("scroll")||!!mt.period&&!((t,e,n,o,r)=>{const i=o+Math.abs(n-e);return t.every(t=>r>=i+t.end-t.start)})(mt.slides,r,e,mt.area.size,mt.period);Ut(!0),t||ee(r,e),j.run(r,e,n,o,t)}i&&kt.emit("select"),s&&ue()}function le(t){return t!==xt&&(yt=xt,xt=t,!0)}function ce(){le(C(mt.snaps,vt,mt.period))&&(Ut(!0),kt.emit("select"))}function de(t){$t(t),kt.emit("scroll")}function ue(){Tt&&(Tt=!1,ce()),mt.period&&(vt=E(vt,mt.period)),Ut(),kt.emit("settle")}function pe(){const t=j.stop();return null!==t&&(vt=t,$t(t),Tt&&ce()),Tt=!1,vt}function fe(){b.scrollLeft=b.scrollTop=0}function ge(t){if(t.defaultPrevented||!Q.length||t.target!==b&&t.target!==q)return;Q.forEach(t=>t.inert=!1);const e=document.elementFromPoint(t.clientX,t.clientY),n=Q.findIndex(t=>t.contains(e)),o=t=>t?[t,...t.querySelectorAll("*")]:[];Q.forEach(t=>t.inert=!0),o(J[n%J.length])[o(Q[n]).indexOf(e)]?.dispatchEvent(new MouseEvent("click",t))}})(e,r,lt.defaults,at)}return lt.defaults={},lt.get=rt,lt.initAll=(t,e)=>[...document.querySelectorAll(t)].map(t=>lt(t,e)),lt})();
1
+ var BetterCarousel=(()=>{"use strict";function t(t,e,n){e&&t.classList.contains(e)!==!!n&&t.classList.toggle(e,!!n)}function e(t,e,n){t.getAttribute(e)!==(n||null)&&(n?t.setAttribute(e,n):t.removeAttribute(e))}function n(t,e,n){t.style.getPropertyValue(e)!==n+""&&t.style.setProperty(e,n)}function o(t){""===t.getAttribute("style")&&t.removeAttribute("style")}function r(t,e){return n=>e.forEach(([e,o,r])=>t[n?"addEventListener":"removeEventListener"](e,o,r))}function i(t,e){const n=document.createElement(t);return e&&(n.className=e),n}function s(t,n,o,r){const s=i("button",t);return s.type="button",e(s,"aria-label",o),s.setAttribute("aria-controls",n.id),s.addEventListener("click",r),s}function a(t,e){if("string"==typeof t){for(let n=e;n;n=n.parentElement){const e=n.querySelector(t);if(e)return e}return null}return!0===t?e:t||null}const l=new WeakMap,c=new WeakMap;function d(t,n,o){const r=l.get(t)||new Set;!r.has(n)&&t.hasAttribute(n)||(r.add(n),l.set(t,r),e(t,n,o))}function u(t,e){if(e&&!t.classList.contains(e)){const n=c.get(t)||new Set;t.classList.add(e),n.add(e),c.set(t,n)}}const p=new WeakSet;let f=0;const g=new Set(["template","script","style"]);function h(t,e){return[...e?t.querySelectorAll(e):t.children].filter(t=>!p.has(t)&&!g.has(t.localName))}function m(t){const e=t.cloneNode(!0),n=t.querySelectorAll("select");for(const t of[e,...e.querySelectorAll("[id],[name],[required]")])["id","name","required"].forEach(e=>t.removeAttribute(e));return e.querySelectorAll("select").forEach((t,e)=>t.selectedIndex=n[e].selectedIndex),e}function v(t,e){t.replaceChildren(...m(e).childNodes)}const x={delay:4e3,stopOnInteraction:!0,pauseOnHover:!1,pauseOnFocus:!0,stopOnLastSnap:!1,playOnInit:!0,instant:!1,timer:null},y={speed:120,direction:"next",startDelay:1e3,stopOnInteraction:!0,pauseOnHover:!1,pauseOnFocus:!0,playOnInit:!0};function w(t,e,n){return{...t,..."number"==typeof n?{[e]:n}:n}}function b(n,o,r,i){const{api:a,root:l,container:c,cls:u,emit:p}=n,f=n.options.labels,g=s(u.button+" "+u.playButton,c,"",()=>h?y.stop():y.play());let h=!1,m=null,v=!0;function x(){e(g,"aria-label",h?f.pause:f.play),t(l,u.playing,h),d(c,"aria-live",h?"off":"polite")}const y={play(){h||(h=!0,m=((t,e)=>{const n=new Set,o=(t,e)=>{const o=n.size;n[e?"add":"delete"](t),!o!=!n.size&&i.pause(m.paused())},r=new IntersectionObserver(([t])=>o("view",!t.isIntersecting)),s=[[document,"visibilitychange",()=>o("tab",document.hidden)],[t,"pointerenter",t=>o("mouse",e.pauseOnHover&&"mouse"===t.pointerType)],[t,"pointerleave",()=>o("mouse",!1)],[t,"focusin",t=>o("focus",e.pauseOnFocus&&t.target.matches(":focus-visible"))],[t,"focusout",e=>o("focus",t.contains(e.relatedTarget)&&n.has("focus"))]];return r.observe(t),s.forEach(([t,e,n])=>t.addEventListener(e,n)),{paused:()=>n.size>0,remove(){r.disconnect(),s.forEach(([t,e,n])=>t.removeEventListener(e,n))}}})(l,r),x(),i.play(),p(o.toLowerCase()+":play"))},stop(){h&&(h=!1,m.remove(),x(),i.stop(),p(o.toLowerCase()+":stop"))},isPlaying(){return h},paused(){return!h||m.paused()},remove(){n.playing&&(n.playing[o]=h),y.stop(),g.remove(),delete a[o]}};return[["init reinit resize",()=>{a.isFit()?g.remove():g.isConnected||l.append(g),v&&(v=!1,h?i.play():(n.playing?.[o]??(r.playOnInit&&!matchMedia("(prefers-reduced-motion: reduce)").matches))&&y.play())}],...i.events].forEach(([t,e])=>n.on(t,e)),x(),a[o]=y,y}function S(t,e,n,o,r,i=0){return t.map(t=>{const s=(i+n/2-e-(t.start+t.end)/2)/o,a=Math.round(s);return{k:a,offset:r>0?a+.5-s:s-a+.5}})}function E(t,e){return t-Math.ceil(t/e)*e}const{abs:M,floor:T,round:z}=Math;function k(t,e,n){return Math.min(n,Math.max(e,t))}function A(t,e,n){return n?(t%e+e)%e:k(t,0,e-1)}function L(t,e,n,o){return"function"==typeof t?t(e,n,o):"center"===t?(e-n)/2:"end"===t?e-n:0}function O(t){let e=1/0,n=-1/0,o=0;for(const r of t)r.hidden||(e=Math.min(e,r.start),n=Math.max(n,r.end),o=Math.max(o,r.end-r.start));return{start:e,end:n,size:n-e,max:o}}function F(t,e,n=0){let o=-1,r=1/0;return t.forEach((t,i)=>{const s=e(t,i);r-n>s&&(r=s,o=i)}),o}function I(t,e,n){const o=t-e;return n?o-z(o/n)*n:o}function P(t,e,n,o,r,i=0,s=t.length){return F(t,(t,a)=>i>a||a>=s||t.hidden?1/0:M(I(t.start+e,L(o,n,t.end-t.start,a),r)),.5)}function C(t,e,n){return Math.max(0,F(t,t=>M(I(t.location,e,n))))}function N(t,e,n,o=0){return n?o>0?t+(Math.ceil((e-.5-t)/n)-1)*n:0>o?t+(T((e+.5-t)/n)+1)*n:e+I(t,e,n):t}function _(t,{min:e,max:n,period:o}){if(o){const e=(n-t)/o;return e-T(e)}return n>e?k((n-t)/(n-e),0,1):0}function W({slides:t,view:e,period:n},o,r){const i=[];return t.forEach((t,s)=>{const a=t.end-t.start,l=n?I(t.start+o+a/2,e/2,n)+e/2-a/2:t.start+o,c=Math.min(l+a,e)-Math.max(l,0);t.hidden||0>=c||r*a-.5>c||i.push(s)}),i}function H(t){return"x"===t?document.documentElement.clientWidth:innerHeight}const q=new WeakMap,B=new WeakMap,D=new WeakMap;let j;function R(t,e){j||=new ResizeObserver(t=>{const e=[...new Set(t.filter(t=>{const{inlineSize:e,blockSize:n}=t.borderBoxSize[0],o=e+","+n,r=D.get(t.target)===o;return D.set(t.target,o),!r&&!q.get(t.target)?.skip(t)}).map(t=>q.get(t.target)))].filter(t=>t?.read());e.forEach(t=>t.write()),e.length&&(e.forEach(t=>B.get(t)?.forEach(t=>j.unobserve(t))),requestAnimationFrame(()=>e.forEach(t=>B.get(t)?.forEach(e=>q.get(e)===t&&j.observe(e)))))}),e&&B.set(e,t);for(const n of t)D.delete(n),e?(q.set(n,e),j.observe(n)):(q.delete(n),j.unobserve(n))}const G=new Map,V=new WeakMap;let X=[];function Y(){const t=X,e=t.map(([t])=>t.getBoundingClientRect());X=[],t.forEach(([t,n,o],r)=>{const i=!0===n?innerHeight:n,s=e[r],a=V.get(t);if(!a)return;if(s.height&&s.bottom>=-i&&s.top<=innerHeight+i)return void a();let l=G.get(o);l||(l=new IntersectionObserver(t=>t.forEach(t=>t.isIntersecting&&V.get(t.target)?.()),{rootMargin:o}),G.set(o,l)),l.observe(t)})}const K=[.25,1,.5,1],J=[.2,.6,.35,1];function U([t,e,n,o]){const r=(t,e,n)=>((1+3*t-3*e)*n+3*e-6*t)*n*n+3*t*n;return i=>{if(0>=i||i>=1)return i>0?1:0;let s=i;for(let a=0;6>a;a++){const a=r(t,n,s)-i,l=3*(1+3*t-3*n)*s*s+2*(3*n-6*t)*s+3*t;if(1e-5>M(a))return r(e,o,s);if(1e-6>M(l))break;s-=a/l}let a=0,l=1;for(s=i;l-a>1e-5;)r(t,n,s)<i?a=s:l=s,s=(a+l)/2;return r(e,o,s)}}const Q={axis:"auto",align:"auto",dir:"auto",loop:!1,dragFree:!1,dragFriction:1,containScroll:"trimSnaps",slidesPerSnap:1,skipSnaps:!0,dragThreshold:10,duration:400,startSnap:0,lazy:!1,drag:!0,wheel:!0,keys:!0,resize:!0,slideChanges:!0,focus:!0,inViewThreshold:0,active:!0,breakpoints:{},container:null,slides:null,wrapper:!0,arrows:!0,dots:!0,dotsStyle:"zoom",labels:{carousel:"Carousel",slide:"%d of %n",prev:"Previous slide",next:"Next slide",dot:"Go to slide %d",play:"Start the slide show",pause:"Stop the slide show"},classes:null,state:"",sync:null,clones:"auto",autoplay:!1,autoScroll:!1,autoHeight:!1,progress:!1,offset:!1},Z=t=>({root:t,viewport:t+"_viewport",container:t+"_container",fit:t+"_fit",horizontal:t+"_horizontal",vertical:t+"_vertical",autoHeight:t+"_auto_height",button:t+"_button",prevButton:t+"_prev",nextButton:t+"_next",dots:t+"_dots",dotsTrack:t+"_dots_track",dotsMarker:t+"_dots_marker",dotsAll:t+"_dots_all",dot:t+"_dot",playButton:t+"_play",clone:"clone",selected:"selected",inView:"",dragging:"dragging",playing:"playing",first:"first",prev:"prev",current:"current",next:"next",last:"last"}),$=["selected","inView","dragging","playing","first","prev","current","next","last"];function tt(...t){const e={};for(const n of t)for(const t in n){const o=n[t],r=e[t];e[t]=o&&r&&"object"==typeof o&&"object"==typeof r&&o.constructor===Object&&r.constructor===Object?{...r,...o}:o}return e}function et(t,...e){let n={};try{n=JSON.parse(t.dataset.carousel||"{}")}catch{}return tt(Q,...e,n)}const nt=new WeakMap;let ot;const rt=t=>nt.get(t),it="input,textarea,select,[contenteditable]",st=new WeakSet,at=[t=>{const{viewport:e,options:n}=t;if(!n.drag)return;let o,i,s,a=null,l=!1,c=!1,d=[],u=0;const p=r(window,[["pointermove",f],["pointerup",f],["pointercancel",f]]);function f(r){if(r.pointerId!==a)return;if("pointermove"!==r.type)return d.length&&d.push([d[d.length-1][0],r.timeStamp]),g("pointerup"===r.type);const l=(r.clientX-o[0])/s.scale,c=(r.clientY-o[1])/s.scale,p=s.x?l*s.sign:c,f=s.x?c:l;if(!t.dragging()){if("mouse"!==r.pointerType&&M(f)>M(p))return g();if(M(p)<n.dragThreshold)return;i=t.halt(),u=t.selected(),t.drag(!0),e.setPointerCapture(a)}const h=t.geo(),m=i+p,v=k(m,h.min,h.max);t.hold(h.period?m:v+(m-v)/4,!0),d.push([p,r.timeStamp]),d.length>10&&d.shift()}function g(e){p(),a=null;const o=t.dragging();if(!o&&!c)return;const r=t.geo(),s=t.location(),f=e&&d.length?(t=>{const e=t[t.length-1],n=t.find(t=>100>=e[1]-t[1]),o=e[1]-n[1];return o>0?(e[0]-n[0])/o:0})(d):0,g=(({location:t,from:e,velocity:n,current:o,snaps:r,min:i,max:s,period:a,skipSnaps:l,dragFree:c,dragFriction:d=1})=>{const u=r.length;let p=t+325*n/d;if(a||(p=k(p,i,s)),"number"==typeof l&&l>0&&u-1+!a>l){const t=t=>N(r[A(o+t*l,u,a)].location,e,a,t);p=k(p,t(1),t(-1))}if(!0===c)return{location:p,snap:C(r,p,a)};if(c||l){const t=C(r,p,a);return{location:N(r[t].location,p,a),snap:t}}const f=t-e;let g=0;M(n)>.3?g=0>n?1:-1:M(f)>20&&(g=0>f?1:-1);const h=A(o+g,u,a),m=r[h].location;return{location:a?N(m,g?e:t,a,h===o?0:g):m,snap:h}})({...r,...n,location:s,from:i,velocity:f,current:u}),h=!0===n.dragFree?J:K;l=!0,o&&t.drag(!1),t.move(g.snap,g.location,((t,e,n,o)=>Math.sign(t)!==Math.sign(e)||.05>M(e)?o:k(M(t)*n[1]/n[0]/M(e),200,1200))(g.location-s,f,h,n.duration),h)}const h=r(e,[["pointerdown",e=>{l=!1;const n=t.geo();null!==a||e.button||!n||n.fit||st.has(e)||e.target.closest(it)||(st.add(e),"mouse"===e.pointerType&&e.preventDefault(),a=e.pointerId,s={x:"x"===n.axis,sign:n.sign,scale:n.scale},o=[e.clientX,e.clientY],d=[],c=t.moving(),c&&(i=t.halt(),u=t.selected(),t.emit("interact")),p(!0))}],["click",t=>{l&&t.detail&&(t.preventDefault(),t.stopPropagation()),l=!1},!0],["dragstart",t=>t.preventDefault()],["selectstart",e=>t.dragging()&&e.preventDefault()]]);return h(!0),{remove(){p(),h()}}},t=>{const{viewport:e,options:n}=t,o=!0===n.dragFree;if(!n.wheel)return;let i=0,s=0,a=!1,l=!1,c=0,d=0,u=0;function p(){c=0;const e=t.geo(),n=t.current(),o=C(e.snaps,n,e.period),r=M(N(e.snaps[o].location,n,e.period)-n)>10;t.step(o,o===d&&r?u:0)}const f=r(e,[["wheel",r=>{const f=t.geo(),g="x"===f.axis&&M(r.deltaX)>M(r.deltaY),h=g?r.deltaX*f.sign:r.deltaY;if(r.ctrlKey||!h||t.dragging()||"axis"===n.wheel&&"x"===f.axis&&!g)return;const m=r.timeStamp,v=200>m-i,x=M(h),y=v&&s>=x;if(i=m,s=x,a&&=v,l=v&&l||((t,e,n,o)=>{const[r,i,s,a]="x"===n?["scrollWidth","clientWidth","scrollLeft","overflowX"]:["scrollHeight","clientHeight","scrollTop","overflowY"];for(;t&&t!==e;t=t.parentElement)if(t[r]>t[i]&&/auto|scroll/.test(getComputedStyle(t)[a])){const e=M(t[s]);if(o>0?t[r]-1>e+t[i]:e>0)return!0}return!1})(r.target,e,g?"x":"y",g?r.deltaX:h),l)return;const w=t.location(),b=h*(1===r.deltaMode?40:r.deltaMode?f.view:1);let S=w-b;f.period||(S=k(S,f.min,f.max)),.5>M(S-w)?a&&y&&r.preventDefault():(r.preventDefault(),t.emit("interact"),c||(d=t.selected()),a=!0,u=b>0?1:-1,t.move(C(f.snaps,S,f.period),S,180,K),clearTimeout(c),o||(c=setTimeout(p,150)))},{passive:!1}]]);return t.on("init reinit resize",()=>{const e=t.geo();f(!e.fit&&("y"===e.axis||!0!==n.wheel))}),{remove(){f(),clearTimeout(c)}}},t=>{const{api:e,root:n,options:o}=t;if(!o.keys)return;const i=r(n,[["keydown",n=>{const o=t.geo(),{key:r,target:i}=n,s=o&&!o.fit&&("y"===o.axis?{ArrowUp:-1,ArrowDown:1}:{ArrowLeft:-o.sign,ArrowRight:o.sign})[r],a=s>0?"Next":"Prev";s&&!(n.altKey||n.ctrlKey||n.metaKey||n.shiftKey||i.closest(it))&&e["canGoTo"+a]()&&(n.preventDefault(),e["goTo"+a]())}]]);return i(!0),{remove:i}},t=>{const{api:e,container:n,options:o}=t;let i=-1e4;const s=r(n,[["pointerdown",t=>{t.target.closest(it)||(i=t.timeStamp)}],["focusin",n=>{const r=t.geo(),s=e.slideNodes().findIndex(t=>t.contains(n.target));!r||0>s||600>n.timeStamp-i||(o.focus&&!W(r,t.location(),1).map(t=>t%r.count).includes(s)&&e.goToSlide(s),t.emit("slidefocus"))}]]);return s(!0),{remove:s}},o=>{const{api:r,root:l,cls:c,options:d}=o,u=d.labels,p=a(d.arrows,l),f=a(d.dots,l),g=[],h=[],m="all"!==d.dotsStyle,v=f&&i("div",m?c.dots:c.dots+" "+c.dotsAll),x=v&&i("div",c.dotsTrack);let y=new Map;if(p||f)return v&&(x.append(i("span",c.dotsMarker)),v.append(x),f.append(v)),p&&g.push(s(c.button+" "+c.prevButton,o.container,u.prev,()=>r.goToPrev()),s(c.button+" "+c.nextButton,o.container,u.next,()=>r.goToNext())),o.on("init reinit resize select slideschanged",()=>{const i=r.isFit(),a=i?0:o.geo().logical.length,l=r.selectedSnap();if(g.forEach((t,e)=>{if(i)t.remove();else{t.isConnected||(v?.parentNode===p?v.before(t):p.append(t));const n=!(e?r.canGoToNext():r.canGoToPrev());t.disabled!==n&&(t.disabled=n)}}),!v)return;if(2>a)return void v.remove();for(;h.length>a;)h.pop().remove(),y.delete(h.length);for(;a>h.length;){const t=h.length,e=s(c.dot,o.container,u.dot.replace("%d",t+1),()=>r.goToSnap(t));m&&(e.tabIndex=-1),h.push(e),x.append(e)}v.isConnected||f.append(v);const d=new Map;["first","prev","current","next","last"].forEach((t,e)=>{h[l+e-2]&&d.set(l+e-2,c[t])}),y.forEach((n,o)=>{d.get(o)!==n&&(t(h[o],n,!1),e(h[o],"aria-current",!1),h[o].tabIndex=m?-1:0)}),d.forEach((n,o)=>{t(h[o],n,!0),e(h[o],"aria-current",o===l&&"true"),h[o].tabIndex=0}),y=d,m&&n(v,"--better-shift",2-(Math.max(0,l-2)+Math.min(a-1,l+2))/2),n(v,"--better-dot",l)}),{remove(){g.forEach(t=>t.remove()),v?.remove()}}},t=>{if(!t.options.autoplay)return;const e=t.api,n=w(x,"delay",t.options.autoplay);let o=0,r=null,i=!1;function s(){clearTimeout(o),r?.(),r=null}function a(){if(s(),!c.paused()&&!e.isFit()){const t=e.slideNodes()[e.selectedSlide()]?.dataset.delay||n.delay,i=+(Array.isArray(t)?t[e.selectedSnap()]:t);o=setTimeout(l,i),r=n.timer?.(i,e)}}function l(){s(),i=!0,e.canGoToNext()?e.goToNext(n.instant):n.stopOnLastSnap?c.stop():e.goToSnap(0,n.instant),i=!1}const c=b(t,"autoplay",n,{play:a,stop:s,pause:a,events:[["settle",a],["interact",()=>{i||(s(),n.stopOnInteraction&&c.stop())}]]});return c.reset=a,c},t=>{if(!t.options.autoScroll)return;const e=w(y,"speed",t.options.autoScroll);let n=0,o=!1;const i=b(t,"autoScroll",e,{play(){c(!0),s()},stop(){c(),l(),o=!1,s(-1),t.halt()},pause(e){e?t.halt():n||a()},events:[["settle",()=>i.isPlaying()&&s()],["resize",()=>i.isPlaying()&&!n&&a()],["interact",()=>{i.isPlaying()&&(s(-1),e.stopOnInteraction&&i.stop())}]]});function s(t){clearTimeout(n),n=t?0:setTimeout(a,e.startDelay)}function a(){n=0;const r=t.geo();!r||r.fit||o||t.dragging()||i.paused()||t.scroll("prev"===e.direction?-1:1,e.speed/1e3)}const l=r(window,[["pointerup",d],["pointercancel",d]]),c=r(t.viewport,[["pointerdown",e=>{e.button||o||(o=!0,s(-1),t.halt(),l(!0))}]]);function d(){o=!1,l(),t.dragging()||s()}return i},t=>{const{api:e,container:n}=t,o=t.options.sync;let i=null;if(!o)return;function s(n){const o=i.selectedSlide();t.follow(o),e.goToSlide(o,!0===n)}t.on("init reinit",()=>{i||(i=o.goToSnap?o:t.find("string"==typeof o?a(o,t.root):o),i&&(i.on("select",s),s(!0)))});const l=r(n,[["click",t=>{const n=e.slideNodes().findIndex(e=>e.contains(t.target));i&&n>-1&&i.goToSlide(n)}]]);return l(!0),{remove(){i?.off("select",s),l()}}}];function lt(e,r={}){return((e,r,s,a)=>{const g=nt.get(e);if(g)return g;let x,y,w,b,q,B,D,j,J=[],Q=[],it=[],st=[],at=[],lt=null,ct=!1,dt=!1,ut=!1,pt=[],ft=0,gt=-1,ht=0,mt=null,vt=0,xt=0,yt=0,wt=-1,bt=-1,St=[],Et={axis:"",container:0,slides:[]},Mt=!1,Tt=!1;const zt={goToSnap:(t,e)=>ae(Vt(t),e),goToNext:t=>ie(1,t),goToPrev:t=>ie(-1,t),goToSlide:(t,e)=>ae(Vt(zt.snapOfSlide(t)),e,t),canGoToNext:()=>re(1),canGoToPrev:()=>re(-1),selectedSnap:()=>Gt(xt),previousSnap:()=>Gt(yt),selectedSlide:Xt,snapOfSlide:t=>mt?Gt((({snaps:t,slides:e,view:n,align:o,period:r},i)=>{const s=t.findIndex(t=>t.slide===i),a=e[i];return s>-1||!a?Math.max(s,0):C(t,L(o,n,a.end-a.start,i)-a.start,r)})(mt,t)):t,snapProgress:()=>mt?mt.logical.map(t=>_(mt.snaps[t].location,mt)):[],progress:()=>mt?_(Yt(),mt):0,slideNodes:()=>J.slice(),slidesInView:()=>St.slice(),rootNode:()=>w,viewportNode:()=>b,containerNode:()=>q,isFit:()=>!mt||mt.fit,options:()=>x,reinit:_t,destroy(){Nt(!1),kt.emit("destroy")}},kt=(t=>{const e={},n={},o=(t,e,n)=>(t[e]||=new Set).add(n);return{on:(n,r)=>(o(e,n,r),t),off:(n,o)=>(e[n]?.delete(o),t),listen(t,e){return t.split(" ").forEach(t=>o(n,t,e))},clear(){return Object.values(n).forEach(t=>t.clear())},emit(o){n[o]?.forEach(e=>e(t,o)),e[o]?.forEach(e=>e(t,o))},has(t){return!!e[t]?.size}}})(zt),At={read:Kt,write:Ut,skip({target:t,contentRect:{width:e}}){if(t!==b)return!1;const n=e===ft;return ft=e,n&&x.autoHeight&&"x"===mt?.axis}},Lt={progress:0,snap:0},Ot={node:null,index:0,offset:0,distance:0,size:0,visible:0},Ft={api:zt,emit:kt.emit,on:kt.listen,find:rt,geo:()=>mt,selected:()=>xt,dragging:()=>Mt,moving:()=>!Tt&&null!==j.current(),location:()=>Tt?Yt():vt,current:Yt,hold(t,e){vt=t,(e?ue:te)(t),de()},halt:fe,step:se,scroll(t,e){const n=fe(),o=t>0?mt.min:mt.max;mt.period?(Tt=!0,vt=E(n,mt.period),j.loop(vt,t,mt.period/e,mt,it)):M(o-n)>1&&(Tt=!0,vt=o,j.run(n,o,M(o-n)/e,[0,0,1,1],kt.has("scroll")))},move(t,e,n,o){wt=-1,le(t,e,n,o)},drag(e){Mt=e,t(w,y.dragging,e),e?(kt.emit("interact"),kt.emit("dragstart")):kt.emit("dragend")},follow(t){bt=t}};zt.on=kt.on,zt.off=kt.off;let It=et(e,s,r),Pt=It.lazy?((t,e,n)=>{const o=!0===e?"100%":e+"px";return X.length||queueMicrotask(Y),X.push([t,e,o]),V.set(t,n),()=>{G.get(o)?.unobserve(t),V.delete(t)}})(e,It.lazy,_t):null;return Pt?nt.set(e,zt):Ct(),zt;function Ct(){if(lt=((t,e)=>{const n=Object.entries(t.breakpoints||{}).map(([t,e])=>[matchMedia(t),e]);return n.forEach(([t])=>t.addEventListener("change",e)),{options:tt(t,...n.filter(([t])=>t.matches).map(([,t])=>t)),remove(){return n.forEach(([t])=>t.removeEventListener("change",e))}}})(It||et(e,s,r),()=>_t()),It=null,x=lt.options,x.active){y=((t,e)=>{const n="string"==typeof t?Z(t):{...Z(t?.prefix||"better"),...t};for(const t of $)n[t]&&(n[t]=e+n[t]);return n})(x.classes,x.state),({root:w,viewport:b,container:q}=((t,e,n)=>{let o=e.container?t.querySelector(e.container):t;o.classList.contains(n.viewport)&&(o=o.firstElementChild);let r=o.parentElement,s=r.parentElement;return p.has(r)||r.classList.contains(n.viewport)||!e.wrapper||(s=i("div"),r=i("div"),p.add(s).add(r),o.before(s),s.append(r),r.append(o)),u(s,n.root),u(r,n.viewport),u(o,n.container),d(s,"role","region"),d(s,"aria-roledescription","carousel"),s.hasAttribute("aria-labelledby")||d(s,"aria-label",e.labels.carousel),d(o,"id",o.id||"carousel-"+ ++f),d(o,"aria-live","polite"),{root:s,viewport:r,container:o}})(e,x,y));for(const t of[w,b,q])nt.set(t,zt);J=h(q,x.slides),it=J,xt=x.startSnap,Bt(!0),Object.assign(Ft,{root:w,viewport:b,container:q,cls:y,options:x}),st=a.map(t=>t(Ft)).filter(Boolean),j=((t,e,n,o,r)=>{let i=null;const s=()=>i.animations?i.animations[0].currentTime||0:performance.now()-i.start,a=()=>i&&i.from+(i.to-i.from)*i.ease(s()/i.duration);function l(){if(!i.animations&&s()>=i.duration)return c();i.raf=requestAnimationFrame(l),(i.animations?r:n)(a())}function c(){const t=i.to;d(),n(t),o()}function d(){const t=a();return i&&(i.animations?.forEach(t=>t.cancel()),cancelAnimationFrame(i.raf),i=null),t}function u(n){const o=t.animate([{translate:e(i.from)},{translate:e(i.to)}],{duration:i.duration,easing:"cubic-bezier("+i.curve+")",fill:"forwards"});o.currentTime=n,o.onfinish=c,i.animations=[o]}function p(n,o){if(d(),i=n,n.list){const r={duration:n.duration,iterations:1/0},i=document.timeline.currentTime,{from:s,to:a,length:l,direction:c}=n;n.animations=[t.animate([{translate:e(s)},{translate:e(a)}],r),...o.map((t,o)=>{const{k:i,offset:s}=n.list[o],a=e(i*l),d=e((i+c)*l);return t.animate([{translate:a},{translate:a,offset:s},{translate:d,offset:s},{translate:d}],r)})],n.animations.forEach(t=>t.startTime=i)}else n.script?n.start=performance.now():u(0);(n.script||r)&&(n.raf=requestAnimationFrame(l))}return{run(t,e,n,o,r){return p({from:t,to:e,duration:n,curve:o,script:r,ease:U(o)})},loop(t,e,n,o,r){return p({from:t,to:t-e*o.period,duration:n,direction:e,length:o.period,list:S(o.slides,t,o.area.size,o.period,e,o.area.start),ease(t){return t%1}},r)},retarget(t){if(!i||i.list)return!1;if(t!==i.to&&(i.to=t,i.animations)){const t=s();i.animations[0].cancel(),u(t)}return!0},stop:d,current:a,shifts(t){if(!i?.list)return null;const e=s()/i.duration%1;return i.list.map(({k:n,offset:o})=>t*(o>e?n:n+i.direction)*i.length)}}})(q,oe,ue,pe,(x.progress||x.offset)&&(t=>ee(t,j.shifts(mt.sign)||Et.slides))),x.autoHeight&&u(w,y.autoHeight),b.addEventListener("scroll",ge),b.addEventListener("click",he),b.addEventListener("input",qt),x.loop&&"fill"===x.clones&&addEventListener("resize",Jt),x.slideChanges&&(B=new MutationObserver(jt),B.observe(q,{childList:!0}))}}function Nt(r){if(Pt?.(),Pt=null,nt.delete(e),Bt(!1),B?.disconnect(),lt?.remove(),lt=null,y){j.stop(),st.forEach(t=>t.remove()),kt.clear(),st=[],bt=-1,Mt=Tt=!1,Wt(0),b.removeEventListener("scroll",ge),b.removeEventListener("click",he),b.removeEventListener("input",qt),removeEventListener("resize",Jt),it.forEach(Dt),n(q,"translate",""),n(q,"will-change",""),n(b,"touch-action",""),n(b,"height",""),n(w,"--better-progress","");for(const e of["horizontal","vertical","fit","dragging"])t(w,y[e],!1);for(const t of[w,b,q])o(t),nt.delete(t);((t,e,n,o,r)=>{for(const r of[t,e,n,...o])l.get(r)?.forEach(t=>r.removeAttribute(t)),c.get(r)?.forEach(t=>r.classList.remove(t)),l.delete(r),c.delete(r),""===r.getAttribute("class")&&r.removeAttribute("class");!r&&p.has(t)&&(t.before(n),t.remove())})(w,b,q,J,r),y=mt=null,ct=!1,vt=0,St=[],pt=[],ft=0,Et={axis:"",container:0,slides:[]}}}function _t(t){t&&(r=tt(r,t),It=null);const e=mt?Xt():wt;Ft.playing=t?null:{},Nt(!0),Ct(),wt=e}function Wt(e){Q.length!==e*J.length&&(Q.forEach(t=>t.remove()),Q=((e,n,r)=>{const i=[];for(let s=0;n>s;s++)for(const n of e){const e=m(n);e.setAttribute("aria-hidden","true"),e.inert=!0,e.style.translate="",t(e,r,!0),o(e),p.add(e),i.push(e)}return i})(J,e,y.clone),q.append(...Q),it=J.concat(Q),Et.slides.length=J.length,B?.takeRecords(),D?.disconnect(),Q.length&&(D||=new MutationObserver(Ht),J.forEach(t=>D.observe(t,{childList:!0,characterData:!0,subtree:!0,attributeFilter:["class","src","srcset","href","value"]}))))}function Ht(t){J.forEach((e,n)=>{if(!t||t.some(({type:t,target:n})=>e.contains(n)&&("attributes"!==t||n!==e)))for(let t=n;Q.length>t;t+=J.length)v(Q[t],e)})}function qt(){Ht()}function Bt(t){R(at),at=t?[b,q,...it]:[],R(at,At)}function Dt(e){n(e,"translate",""),n(e,"--better-offset",""),t(e,y.selected,!1),t(e,y.inView,!1),o(e)}function jt(){const t=ct?Xt():-1,e=J[t],n=new Map(J.map((t,e)=>[t,Et.slides[e]]));if(J=h(q,x.slides),t>-1){const n=J.indexOf(e);wt=n>-1?n:Math.min(t,J.length-1)}n.forEach((t,e)=>J.includes(e)||Dt(e)),Wt(0),it=J,Et.slides=J.map(t=>n.get(t)||0),pt=[],ut=!0,Bt(!0)}function Rt(t){return t%J.length}function Gt(t){return mt?mt.map[t]??0:t}function Vt(t){return mt?((t,e,n)=>{const o=F(t.snaps,(o,r)=>t.map[r]===e?M(I(o.location,n,t.period)):1/0);return 0>o?k(e,0,t.snaps.length-1):o})(mt,t,Yt()):t}function Xt(){return bt>-1?bt:mt?0>wt||zt.snapOfSlide(wt)!==Gt(xt)?Rt(mt.snaps[xt].slide):wt:Math.max(wt,0)}function Yt(){return j.current()??vt}function Kt(){const t=mt?.sign||1,e=j.current(),n=((t,e)=>{const n=getComputedStyle(t),o=n.display,r=n.justifyContent;let i=e.axis;"auto"===i&&(i="x",o.includes("grid")?i=n.gridAutoFlow.startsWith("column")?"x":"y":o.includes("flex")&&n.flexDirection.startsWith("column")&&"nowrap"===n.flexWrap&&(i="y"));let s=e.align;"auto"===s&&(s="center"===r?"center":"flex-end"===r||"end"===r||"x"===i&&"right"===r?"end":"start");const a="x"===i&&("auto"===e.dir?"rtl"===n.direction:"rtl"===e.dir);return{axis:i,align:s,rtl:a,sign:a?-1:1,gap:parseFloat("x"===i?n.columnGap:n.rowGap)||0}})(q,x);ht=x.loop&&"fill"===x.clones?H(n.axis):0;const o=((t,e,n,o,r)=>{const i=t.getBoundingClientRect(),s="x"===n.axis,a=n.sign,l=o.axis===n.axis,c=l?o.container:0,d=t.offsetWidth,u=t.offsetHeight,p=!d||!u||1>M(i.width-d)&&1>M(i.height-u)?1:s?i.width/d:i.height/u,f=(s?i.width:i.height)/p,g=getComputedStyle(t),h=s?n.rtl?["Right","Left"]:["Left","Right"]:["Top","Bottom"],m={start:parseFloat(g["padding"+h[0]])||0,end:parseFloat(g["padding"+h[1]])||0},v=e.map((t,e)=>{const r=t.getBoundingClientRect(),d=(s?n.rtl?i.right-r.right:r.left-i.left:r.top-i.top)/p-m.start-a*(c+(l&&o.slides[e]||0));return{start:d,end:d+(s?r.width:r.height)/p,cross:(s?r.height:r.width)/p,hidden:!r.width&&!r.height}});let x=v.find(t=>!t.hidden)?.start||0,y=-1,w=-1,b=n.gap;v.forEach((t,e)=>{t.hidden?t.start=t.end=x:(x=t.end,(0>y||v[y].start>t.start)&&(y=e),(0>w||t.end>v[w].end)&&(w=e))}),y>-1&&(b+=(parseFloat(getComputedStyle(e[y])["margin"+h[0]])||0)+(parseFloat(getComputedStyle(e[w])["margin"+h[1]])||0));const S=f-m.start-m.end;let E=m.start,T=S+m.end;return r&&(E+=Math.max(0,z(s?n.rtl?r-i.right:i.left:i.top)),T=Math.max(T,z(r-E))),{view:S,slides:v,gap:b,scale:p,area:{start:-E,size:E+T}}})(b,it,n,null===e?Et:{axis:Et.axis,container:t*e,slides:j.shifts(t)||Et.slides},ht),r=[n.axis,n.rtl,"string"==typeof n.align&&n.align,o.view,o.gap,o.area.start,o.area.size,...o.slides.flatMap(t=>[t.start,t.end,t.cross])];if(ct&&r.length===pt.length&&r.every((t,e)=>t===pt[e]||.5>M(t-pt[e])))return!1;pt=r;const i=ct&&!ut?Xt():wt,s=function(t,e,n,o){const r=O(e.slides.slice(0,n)),i=!(r.size>e.view+1||o.autoScroll&&o.loop&&r.max),s=o.loop&&!i&&n,a=s?O(e.slides).size+e.gap:0,l=s&&o.clones&&(c=r.size+e.gap)>0?Math.max(0,Math.ceil((e.area.size+r.max)/c)-1):0;var c;if(l*n!==e.slides.length-n)return{copies:l};const d={...t,...e,fit:i,count:n,period:a,min:0,max:0};i?d.snaps=[{location:0,slide:Math.max(0,P(e.slides,0,e.view,t.align))}]:Object.assign(d,(({slides:t,view:e,align:n,slidesPerSnap:o,containScroll:r,period:i=0})=>{const s=O(t);let a=-s.start||0,l=e-s.end,c=((t,e,n)=>{const o=[];let r,i=0;for(const s of t)r&&("auto"===n?r&&e+1>=s.end-r.start:n>i)?(r.end=Math.max(r.end,s.end),i++):(r={start:s.start,end:s.end},o.push(r),i=1);return o})((t=>{const e=t.map((t,e)=>e).filter(e=>!t[e].hidden).sort((e,n)=>t[e].start-t[n].start||e-n),n=[];let o;for(const r of e){const e=t[r];o&&1>=e.start-o.start?o.end=Math.max(o.end,e.end):(o={start:e.start,end:e.end},n.push(o))}return n})(t),e,o).map((t,o)=>L(n,e,t.end-t.start,o)-t.start);i||(r?c=c.map(t=>k(t,l,a)):(a=Math.max(...c),l=Math.min(...c))),(i||"keepSnaps"!==r)&&(c=c.filter((t,e)=>!e||M(I(t,c[e-1],i))>1),i&&c.length>1&&1>=M(I(c[0],c[c.length-1],i))&&c.pop());const d=c.map(o=>({location:o,slide:P(t,o,e,n,i)})),u=(o,r,i)=>{const s=P(t,o.location,e,n,0,r,i);o.slide=s>-1?s:o.slide};if(!i&&d.length>1){const e=d[0],n=d[d.length-1];d[1].slide>e.slide||u(e,0,d[1].slide),n.slide>d[d.length-2].slide||u(n,d[d.length-2].slide+1,t.length)}return{snaps:d,min:l,max:i?c[0]:a}})({...e,align:t.align,slidesPerSnap:o.slidesPerSnap,containScroll:o.containScroll,period:a}));const u=d.snaps.map((t,e)=>e).filter(t=>!l||n>d.snaps[t].slide);return d.logical=u,d.map=d.snaps.map((t,e)=>l?Math.max(0,u.findIndex(e=>d.snaps[e].slide%n===t.slide%n)):e),d}(n,o,J.length,x);if(!s.snaps)return gt=s.copies,!0;mt=s;const a=mt.snaps.length;return xt=0>i?Math.min(a-1,ct?xt:Vt(A(xt,mt.logical.length,mt.period))):Vt(zt.snapOfSlide(i)),yt=Math.min(yt,a-1),wt=i,Mt||(vt=N(mt.snaps[xt].location,vt,mt.period)),!0}function Jt(){mt&&H(mt.axis)!==ht&&Kt()&&Ut()}function Ut(){if(gt>=0)return Wt(gt),gt=-1,pt=[],void Bt(!0);Tt&&fe();const t=j.current();null!==t&&Et.axis===mt.axis&&!mt.fit&&j.retarget(vt)?(ne(t,vt),Qt(!0)):(j.stop(),Qt(Mt)),((t,e)=>{t.forEach((n,o)=>{n.matches("a[href],button,input,select,textarea,[tabindex],[role]")&&!l.get(n)?.has("role")||(n.matches("div,span,section")&&d(n,"role","group"),d(n,"aria-roledescription","slide"),d(n,"aria-label",e.replace("%d",o+1).replace("%n",t.length)))})})(J,x.labels.slide),x.resize||Bt(!1),ct?kt.emit("resize"):(ct=!0,kt.emit(dt?"reinit":"init"),dt=!0),ut&&(ut=!1,kt.emit("slideschanged"))}function Qt(e){const o="x"===mt.axis;t(w,y.horizontal,o),t(w,y.vertical,!o),t(w,y.fit,mt.fit);const r=!re(-1),i=!re(1),s=!o&&(r||i)&&(ot??=CSS.supports("touch-action","pan-up"))?r&&i?"pan-y ":r?"pan-up ":"pan-down ":"";n(b,"touch-action",mt.fit?"":o?"pan-y pinch-zoom":"pan-x "+s+"pinch-zoom"),n(q,"will-change",mt.fit?"":"translate"),e||te(mt.fit?0:vt),x.autoHeight&&n(b,"height",o?Math.max(...W(mt,vt,0).map(t=>mt.slides[t].cross))+"px":"");const a=Xt(),l=[...new Set(W(mt,vt,x.inViewThreshold).map(Rt))].sort((t,e)=>t-e);it.forEach((e,n)=>t(e,y.selected,Rt(n)===a)),l.join()!==St.join()&&(St=l,it.forEach((e,n)=>t(e,y.inView,l.includes(Rt(n)))),kt.emit("slidesinview"))}function Zt(t){const e=devicePixelRatio||1;return z(t*e)/e*mt.sign}function $t(t){return t?"x"===mt.axis?t+"px":"0 "+t+"px":""}function te(t){Et.axis!==mt.axis&&(it.forEach(t=>n(t,"translate","")),Et={axis:mt.axis,container:0,slides:[]}),Et.container=Zt(t),n(q,"translate",$t(Et.container)),ne(t,t),ee(t,Et.slides)}function ee(t,e){if(!0===x.progress)w.style.setProperty("--better-progress",_(t,mt));else if(x.progress){const e=((t,e,n)=>{const o=t.length-1,r=t[0].location,i=n?r-((r-e)%n+n)%n:k(e,t[o].location,r);let s=0;for(;o>s&&t[s+1].location>=i;)s++;const a=t[s].location,l=o>s?t[s+1].location:r-n;return s+(a>l?(a-i)/(a-l):0)})(mt.snaps,t,mt.period),n=T(e);Lt.progress=_(t,mt),Lt.snap=Gt(n)+e-n,x.progress(Lt,zt)}x.offset&&it.forEach((n,o)=>{const r=mt.slides[o],i=r.end-r.start,s=r.start+mt.sign*(e[o]||0)+t,a=s-L(mt.align,mt.view,i,o),l=a/(i+mt.gap);!0===x.offset?n.style.setProperty("--better-offset",l):(Ot.node=n,Ot.index=Rt(o),Ot.offset=l,Ot.distance=mt.sign*a,Ot.size=i,Ot.visible=k((Math.min(s+i,mt.view)-Math.max(s,0))/i,0,1)||0,x.offset(Ot,zt))})}function ne(t,e){const o=mt.period?((t,e,n,o,r,i=0)=>{const s=i+(o-e-n)/2;return t.map(t=>Math.round((s-(t.start+t.end)/2)/r)||0)})(mt.slides,t,e,mt.area.size,mt.period,mt.area.start):[];it.forEach((t,e)=>{const r=o.length?Zt(o[e]*mt.period):0;(Et.slides[e]||0)!==r&&(Et.slides[e]=r,n(t,"translate",$t(r)))})}function oe(t){return $t(Zt(t))||"0px"}function re(t){return!(!mt||mt.fit||!mt.period&&!(t>0?mt.snaps.length-1>xt:xt>0))}function ie(t,e){mt?re(t)&&se(xt,t,e):ae(xt+t,e)}function se(t,e,n){ae(A(t+e,mt.snaps.length,mt.period),n,-1,e)}function ae(t,e,n=-1,o=0){if(Pt&&_t(),kt.emit("interact"),wt=n,!mt)return void(xt=t);const r=N(mt.snaps[t].location,Yt(),mt.period,o),i=M(t-xt);var s,a;le(t,r,e?0:(s=x.duration,(a=mt.period?Math.min(i,mt.snaps.length-i):i)>1?Math.min(2*s,s*(1+Math.log2(a))):s),K)}function le(t,e,n,o){const r=fe(),i=ce(t),s=!n||mt.fit||.5>M(e-r);if(vt=e,s)Qt();else{const t=kt.has("scroll")||!!mt.period&&!((t,e,n,o,r)=>{const i=o+Math.abs(n-e);return t.every(t=>r>=i+t.end-t.start)})(mt.slides,r,e,mt.area.size,mt.period);Qt(!0),t||ne(r,e),j.run(r,e,n,o,t)}i&&kt.emit("select"),s&&pe()}function ce(t){return t!==xt&&(yt=xt,xt=t,!0)}function de(){ce(C(mt.snaps,vt,mt.period))&&(Qt(!0),kt.emit("select"))}function ue(t){te(t),kt.emit("scroll")}function pe(){Tt&&(Tt=!1,de()),mt.period&&(vt=E(vt,mt.period)),Qt(),kt.emit("settle")}function fe(){const t=j.stop();return null!==t&&(vt=t,te(t),Tt&&de()),Tt=!1,vt}function ge(){b.scrollLeft=b.scrollTop=0}function he(t){if(t.defaultPrevented||!Q.length||t.target!==b&&t.target!==q)return;Q.forEach(t=>t.inert=!1);const e=document.elementFromPoint(t.clientX,t.clientY),n=Q.findIndex(t=>t.contains(e)),o=t=>t?[t,...t.querySelectorAll("*")]:[];Q.forEach(t=>t.inert=!0),o(J[n%J.length])[o(Q[n]).indexOf(e)]?.dispatchEvent(new MouseEvent("click",t))}})(e,r,lt.defaults,at)}return lt.defaults={},lt.get=rt,lt.initAll=(t,e)=>[...document.querySelectorAll(t)].map(t=>lt(t,e)),lt})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twistedandy/better-carousel",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "A small and fast carousel that takes all sizes, gaps and the layout from CSS.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -163,6 +163,8 @@ export default function carousel(element, userOptions, defaults, features) {
163
163
  geo: () => geo,
164
164
  selected: () => selected,
165
165
  dragging: () => dragging,
166
+ // true while a motion to a location runs, such as a goToSnap() motion or a glide. The auto scroll is not such a motion.
167
+ moving: () => !free && motion.current() !== null,
166
168
  // The location at rest or at the end of the motion. During a free motion, the location now.
167
169
  location: () => free ? current() : location,
168
170
  current,
@@ -286,13 +288,7 @@ export default function carousel(element, userOptions, defaults, features) {
286
288
  viewport.removeEventListener('input', onInput);
287
289
  removeEventListener('resize', onWindow);
288
290
 
289
- for (const node of nodes) {
290
- setStyle(node, 'translate', '');
291
- setStyle(node, '--better-offset', '');
292
- setClass(node, cls.selected, false);
293
- setClass(node, cls.inView, false);
294
- cleanStyle(node);
295
- }
291
+ nodes.forEach(clean);
296
292
 
297
293
  setStyle(container, 'translate', '');
298
294
  setStyle(container, 'will-change', '');
@@ -411,17 +407,37 @@ export default function carousel(element, userOptions, defaults, features) {
411
407
  return same && options.autoHeight && geo?.axis === 'x';
412
408
  }
413
409
 
410
+ /**
411
+ * Remove the styles and the classes that the carousel wrote on a slide or a clone.
412
+ *
413
+ * @param {HTMLElement} node
414
+ */
415
+ function clean(node) {
416
+ setStyle(node, 'translate', '');
417
+ setStyle(node, '--better-offset', '');
418
+ setClass(node, cls.selected, false);
419
+ setClass(node, cls.inView, false);
420
+ cleanStyle(node);
421
+ }
422
+
414
423
  // Keep the selected slide. If the page removed it, select the slide that is now at its index, or the last slide.
424
+ // The loop shift of a slide stays with the slide at its new index, because the measure pass subtracts it from the slide box.
425
+ // A new slide can have the same size as the slide that it replaced, so the measure pass must not skip.
415
426
  function onMutation() {
416
427
  const old = ready ? selectedSlide() : -1,
417
- node = slides[old];
428
+ node = slides[old],
429
+ shifts = new Map(slides.map((item, index) => [item, written.slides[index]]));
418
430
  slides = readSlides(container, options.slides);
419
431
  if (old > -1) {
420
432
  const index = slides.indexOf(node);
421
433
  requested = index > -1 ? index : Math.min(old, slides.length - 1);
422
434
  }
435
+ // A removed slide can come back later, for example after a sort. It must not keep a loop shift.
436
+ shifts.forEach((shift, item) => slides.includes(item) || clean(item));
423
437
  setClones(0);
424
438
  nodes = slides;
439
+ written.slides = slides.map((item) => shifts.get(item) || 0);
440
+ signature = [];
425
441
  changed = true;
426
442
  observe(true);
427
443
  }
@@ -131,6 +131,8 @@ export function drag(context) {
131
131
  base,
132
132
  axis,
133
133
  block = false,
134
+ // true if the press stopped a motion
135
+ stopped = false,
134
136
  samples = [],
135
137
  // The selected snap at the drag start
136
138
  snap = 0;
@@ -159,6 +161,16 @@ export function drag(context) {
159
161
  axis = { x: geo.axis === 'x', sign: geo.sign, scale: geo.scale };
160
162
  start = [event.clientX, event.clientY];
161
163
  samples = [];
164
+
165
+ // A press stops a motion where it is. The release goes to a snap, and the click after it does not count.
166
+ // The auto scroll does not stop here: its feature stops it during the press and starts it again after the release.
167
+ stopped = context.moving();
168
+ if (stopped) {
169
+ base = context.halt();
170
+ snap = context.selected();
171
+ context.emit('interact');
172
+ }
173
+
162
174
  listen(true);
163
175
  }
164
176
 
@@ -218,28 +230,35 @@ export function drag(context) {
218
230
  listen();
219
231
  pointer = null;
220
232
 
221
- if (!context.dragging()) {
233
+ const dragged = context.dragging();
234
+
235
+ if (!dragged && !stopped) {
222
236
  return;
223
237
  }
224
238
 
225
239
  const geo = context.geo(),
226
240
  location = context.location(),
227
- speed = up ? velocity(samples) : 0,
241
+ // A press that only stopped a motion has no samples
242
+ speed = up && samples.length ? velocity(samples) : 0,
228
243
  // The snaps and the limits come from the geometry, and skipSnaps, dragFree and dragFriction from the options
229
244
  target = releaseTarget({ ...geo, ...options, location, from: base, velocity: speed, current: snap }),
230
245
  curve = options.dragFree === true ? GLIDE : EASE;
231
246
 
232
247
  block = true;
233
- context.drag(false);
248
+ if (dragged) {
249
+ context.drag(false);
250
+ }
234
251
  context.move(target.snap, target.location, releaseDuration(target.location - location, speed, curve, options.duration), curve);
235
252
  }
236
253
 
254
+ // Cancel the click after a drag. A touch drag sends no click, so the next click can come from the keyboard or a script.
255
+ // Such a click has no detail (the click count), and it is not cancelled.
237
256
  function click(event) {
238
- if (block) {
239
- block = false;
257
+ if (block && event.detail) {
240
258
  event.preventDefault();
241
259
  event.stopPropagation();
242
260
  }
261
+ block = false;
243
262
  }
244
263
 
245
264
  const prevent = (event) => event.preventDefault();
@@ -163,7 +163,7 @@ export interface Options {
163
163
  startSnap?: number;
164
164
  /** `true`: start when the carousel comes within one screen of the view. A number: the distance in px. @default false @see {@link https://twistedandy.github.io/better-carousel/#lazy | example} */
165
165
  lazy?: boolean | number;
166
- /** Drag with the mouse, the pen and the finger. A press on a form field does not start a drag. To keep the drag off another element, such as a map in a slide, stop the propagation of its `pointerdown` event. @default true */
166
+ /** Drag with the mouse, the pen and the finger. A press during a motion stops the motion. A press on a form field does not start a drag. To keep the drag off another element, such as a map in a slide, stop the propagation of its `pointerdown` event. @default true */
167
167
  drag?: boolean;
168
168
  /** The mouse wheel moves a vertical carousel. `'axis'`: also a horizontal carousel, but only with a horizontal wheel motion, such as a trackpad swipe. A vertical wheel scrolls the page. `'both'`: also a horizontal carousel, with all wheel motions. `false`: the wheel does not move the carousel. @default true @see {@link https://twistedandy.github.io/better-carousel/#vertical | example} */
169
169
  wheel?: boolean | 'axis' | 'both';