react-spring-carousel 3.0.0-beta-2.0.3 → 3.0.0-beta-2.0.32

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.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import { jsxs as At, jsx as X } from "react/jsx-runtime";
2
- import { useSpring as $t } from "@react-spring/web";
1
+ import { jsxs as $t, jsx as X } from "react/jsx-runtime";
2
+ import { useSpring as At } from "@react-spring/web";
3
3
  import q, { useRef as k, useEffect as Z, useState as Pt } from "react";
4
4
  function Nt(r, t, e) {
5
5
  return Math.max(t, Math.min(r, e));
@@ -261,13 +261,13 @@ class Jt {
261
261
  } else
262
262
  m[0] = c[0] !== !1 ? a - c[0] : 0, m[1] = c[1] !== !1 ? u - c[1] : 0;
263
263
  this.restrictToAxis && !e._blocked && this.restrictToAxis(m);
264
- const $ = e.offset, D = e._active && !e._blocked || e.active;
264
+ const A = e.offset, D = e._active && !e._blocked || e.active;
265
265
  D && (e.first = e._active && !e.active, e.last = !e._active && e.active, e.active = s[this.ingKey] = e._active, t && (e.first && ("bounds" in n && (e._bounds = z(n.bounds, e)), this.setup && this.setup()), e.movement = m, this.computeOffset()));
266
- const [S, A] = e.offset, [[P, x], [C, O]] = e._bounds;
267
- e.overflow = [S < P ? -1 : S > x ? 1 : 0, A < C ? -1 : A > O ? 1 : 0], e._movementBound[0] = e.overflow[0] ? e._movementBound[0] === !1 ? e._movement[0] : e._movementBound[0] : !1, e._movementBound[1] = e.overflow[1] ? e._movementBound[1] === !1 ? e._movement[1] : e._movementBound[1] : !1;
266
+ const [S, $] = e.offset, [[P, x], [C, O]] = e._bounds;
267
+ e.overflow = [S < P ? -1 : S > x ? 1 : 0, $ < C ? -1 : $ > O ? 1 : 0], e._movementBound[0] = e.overflow[0] ? e._movementBound[0] === !1 ? e._movement[0] : e._movementBound[0] : !1, e._movementBound[1] = e.overflow[1] ? e._movementBound[1] === !1 ? e._movement[1] : e._movementBound[1] : !1;
268
268
  const R = e._active ? n.rubberband || [0, 0] : [0, 0];
269
- if (e.offset = Mt(e._bounds, e.offset, R), e.delta = y.sub(e.offset, $), this.computeMovement(), D && (!e.last || o > qt)) {
270
- e.delta = y.sub(e.offset, $);
269
+ if (e.offset = Mt(e._bounds, e.offset, R), e.delta = y.sub(e.offset, A), this.computeMovement(), D && (!e.last || o > qt)) {
270
+ e.delta = y.sub(e.offset, A);
271
271
  const l = e.delta.map(Math.abs);
272
272
  y.addTo(e.distance, l), e.direction = e.delta.map(Math.sign), e._direction = e._delta.map(Math.sign), !e.first && o > 0 && (e.velocity = [l[0] / o, l[1] / o], e.timeDelta = o);
273
273
  }
@@ -498,10 +498,10 @@ class ee extends Zt {
498
498
  if (e.tap = o <= n.tapsThreshold && a <= n.tapsThreshold, e.tap && n.filterTaps)
499
499
  e._force = !0;
500
500
  else {
501
- const [u, h] = e._delta, [p, c] = e._movement, [b, m] = n.swipe.velocity, [$, D] = n.swipe.distance, S = n.swipe.duration;
501
+ const [u, h] = e._delta, [p, c] = e._movement, [b, m] = n.swipe.velocity, [A, D] = n.swipe.distance, S = n.swipe.duration;
502
502
  if (e.elapsedTime < S) {
503
- const A = Math.abs(u / e.timeDelta), P = Math.abs(h / e.timeDelta);
504
- A > b && Math.abs(p) > $ && (e.swipe[0] = Math.sign(u)), P > m && Math.abs(c) > D && (e.swipe[1] = Math.sign(h));
503
+ const $ = Math.abs(u / e.timeDelta), P = Math.abs(h / e.timeDelta);
504
+ $ > b && Math.abs(p) > A && (e.swipe[0] = Math.sign(u)), P > m && Math.abs(c) > D && (e.swipe[1] = Math.sign(h));
505
505
  }
506
506
  }
507
507
  this.emit();
@@ -999,7 +999,7 @@ function Oe({
999
999
  onInit: c,
1000
1000
  initialActiveItem: b = 0
1001
1001
  }) {
1002
- const [m, $] = Pt(!1), D = k(r), S = k(null), A = k(null), P = k(0), x = k(0), C = k(!e), O = k(!1), R = k(0), l = k(0), [L, G] = $t(
1002
+ const [m, A] = Pt(!1), D = k(r), S = k(null), $ = k(null), P = k(0), x = k(0), C = k(!e), O = k(!1), R = k(0), l = k(0), [L, G] = At(
1003
1003
  () => ({
1004
1004
  value: 0,
1005
1005
  onChange({ value: i }) {
@@ -1102,12 +1102,12 @@ function Oe({
1102
1102
  });
1103
1103
  }
1104
1104
  function Dt() {
1105
- const i = A.current.children[0];
1105
+ const i = $.current.children[0];
1106
1106
  let f = 0;
1107
1107
  return f = i.getBoundingClientRect()[a === "x" ? "width" : "height"] + kt(), f;
1108
1108
  }
1109
1109
  function H(i) {
1110
- const f = A.current;
1110
+ const f = $.current;
1111
1111
  return f[a === "x" ? "scrollWidth" : "scrollHeight"] - f.getBoundingClientRect()[a === "x" ? "width" : "height"] - i;
1112
1112
  }
1113
1113
  function nt() {
@@ -1149,7 +1149,7 @@ function Oe({
1149
1149
  e && (E = x.current * t.length), E -= x.current * i(u, s), E -= _ / 2, S.current.style.setProperty(
1150
1150
  `--${n}-offset-modifier`,
1151
1151
  `${-E}px`
1152
- ), $(!0), g && g();
1152
+ ), A(!0), g && g();
1153
1153
  }
1154
1154
  }
1155
1155
  function v() {
@@ -1220,7 +1220,7 @@ function Oe({
1220
1220
  return typeof i == "number" ? l.current === i : ((f = t.find((g) => g.id === i)) == null ? void 0 : f.id) === ((v = t[l.current]) == null ? void 0 : v.id);
1221
1221
  }
1222
1222
  return {
1223
- carouselFragment: /* @__PURE__ */ At(
1223
+ carouselFragment: /* @__PURE__ */ $t(
1224
1224
  "div",
1225
1225
  {
1226
1226
  ref: S,
@@ -1244,6 +1244,8 @@ function Oe({
1244
1244
  --${n}-offset-modifier: 0px;
1245
1245
  --${n}-scroll-x-value: ${a === "x" ? `calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))` : "0px"};
1246
1246
  --${n}-scroll-y-value: ${a === "y" ? `calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))` : "0px"};
1247
+ --${n}-gutter: 0px;
1248
+ --${n}-start-end-gutter: 0px;
1247
1249
  touch-action: ${st ? a === "x" ? "pan-y" : "pan-x" : "auto"};
1248
1250
  }
1249
1251
  [data-part-internal="${n}-Track"] {
@@ -1279,7 +1281,7 @@ function Oe({
1279
1281
  /* @__PURE__ */ X(
1280
1282
  "div",
1281
1283
  {
1282
- ref: A,
1284
+ ref: $,
1283
1285
  className: "ReactSpringCarouselTrack",
1284
1286
  "data-part": "Track",
1285
1287
  "data-part-internal": `${n}-Track`,
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(D,$){typeof exports=="object"&&typeof module<"u"?$(exports,require("react/jsx-runtime"),require("@react-spring/web"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@react-spring/web","react"],$):(D=typeof globalThis<"u"?globalThis:D||self,$(D["react-spring-carousel"]={},D["react/jsx-runtime"],D["@react-spring/web"],D.React))})(this,function(D,$,Se,g){"use strict";function Ie(r,e,t){return Math.max(e,Math.min(r,t))}const v={toVector(r,e){return r===void 0&&(r=e),Array.isArray(r)?r:[r,r]},add(r,e){return[r[0]+e[0],r[1]+e[1]]},sub(r,e){return[r[0]-e[0],r[1]-e[1]]},addTo(r,e){r[0]+=e[0],r[1]+=e[1]},subTo(r,e){r[0]-=e[0],r[1]-=e[1]}};function te(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function re(r,e,t,n=.15){return n===0?Ie(r,e,t):r<e?-te(e-r,t-e,n)+e:r>t?+te(r-t,t-e,n)+t:r}function ke(r,[e,t],[n,s]){const[[o,a],[u,h]]=r;return[re(e,o,a,n),re(t,u,h,s)]}function De(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Ce(r){var e=De(r,"string");return typeof e=="symbol"?e:String(e)}function w(r,e,t){return e=Ce(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function ne(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,n)}return t}function d(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ne(Object(t),!0).forEach(function(n){w(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ne(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const se={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function ie(r){return r?r[0].toUpperCase()+r.slice(1):""}const Oe=["enter","leave"];function Ae(r=!1,e){return r&&!Oe.includes(e)}function $e(r,e="",t=!1){const n=se[r],s=n&&n[e]||e;return"on"+ie(r)+ie(s)+(Ae(t,s)?"Capture":"")}const Pe=["gotpointercapture","lostpointercapture"];function Ne(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=Pe.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:t}}function Me(r,e=""){const t=se[r],n=t&&t[e]||e;return r+n}function B(r){return"touches"in r}function oe(r){return B(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function Le(r){return Array.from(r.touches).filter(e=>{var t,n;return e.target===r.currentTarget||((t=r.currentTarget)===null||t===void 0||(n=t.contains)===null||n===void 0?void 0:n.call(t,e.target))})}function Ve(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function ae(r){return B(r)?Ve(r)[0]:r}function Re(r){return Le(r).map(e=>e.identifier)}function W(r){const e=ae(r);return B(r)?e.identifier:e.pointerId}function ce(r){const e=ae(r);return[e.clientX,e.clientY]}function je(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:s,ctrlKey:o}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:s,ctrlKey:o})}return e}function z(r,...e){return typeof r=="function"?r(...e):r}function Ue(){}function Ke(...r){return r.length===0?Ue:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function ue(r,e){return Object.assign({},e,r||{})}const Be=32;class ze{constructor(e,t,n){this.ctrl=e,this.args=t,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:n,args:s}=this;t[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=s,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,n=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=n.from?z(n.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:n,shared:s}=this;t.args=this.args;let o=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,je(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,o=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const f=t._delta.map(Math.abs);v.addTo(t._distance,f)}this.axisIntent&&this.axisIntent(e);const[a,u]=t._movement,[h,p]=n.threshold,{_step:c,values:E}=t;if(n.hasCustomTransform?(c[0]===!1&&(c[0]=Math.abs(a)>=h&&E[0]),c[1]===!1&&(c[1]=Math.abs(u)>=p&&E[1])):(c[0]===!1&&(c[0]=Math.abs(a)>=h&&Math.sign(a)*h),c[1]===!1&&(c[1]=Math.abs(u)>=p&&Math.sign(u)*p)),t.intentional=c[0]!==!1||c[1]!==!1,!t.intentional)return;const y=[0,0];if(n.hasCustomTransform){const[f,K]=E;y[0]=c[0]!==!1?f-c[0]:0,y[1]=c[1]!==!1?K-c[1]:0}else y[0]=c[0]!==!1?a-c[0]:0,y[1]=c[1]!==!1?u-c[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(y);const M=t.offset,C=t._active&&!t._blocked||t.active;C&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=s[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=z(n.bounds,t)),this.setup&&this.setup()),t.movement=y,this.computeOffset()));const[k,P]=t.offset,[[L,I],[O,A]]=t._bounds;t.overflow=[k<L?-1:k>I?1:0,P<O?-1:P>A?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const U=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=ke(t._bounds,t.offset,U),t.delta=v.sub(t.offset,M),this.computeMovement(),C&&(!t.last||o>Be)){t.delta=v.sub(t.offset,M);const f=t.delta.map(Math.abs);v.addTo(t.distance,f),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&o>0&&(t.velocity=[f[0]/o,f[1]/o],t.timeDelta=o)}}emit(){const e=this.state,t=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const s=this.handler(d(d(d({},t),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Ye([r,e],t){const n=Math.abs(r),s=Math.abs(e);if(n>s&&n>t)return"x";if(s>n&&s>t)return"y"}class Ge extends ze{constructor(...e){super(...e),w(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=v.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=v.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const s=typeof n.axisThreshold=="object"?n.axisThreshold[oe(e)]:n.axisThreshold;t.axis=Ye(t._movement,s)}t._blocked=(n.lockDirection||!!n.axis)&&!t.axis||!!n.axis&&n.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const fe=r=>r,le=.15,H={enabled(r=!0){return r},eventOptions(r,e,t){return d(d({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[le,le];case!1:return[0,0];default:return v.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return v.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||fe;return o=>{const a=s(o);return(!isFinite(a[0])||!isFinite(a[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${a[0]},${[1]}]`),a}}return n||fe},threshold(r){return v.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(H,{domTarget(r){if(r!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(r){if(r!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(r){if(r!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const Fe=0,R=d(d({},H),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=Fe){return r},bounds(r={}){if(typeof r=="function")return o=>R.bounds(r(o));if("current"in r)return()=>r.current;if(typeof HTMLElement=="function"&&r instanceof HTMLElement)return r;const{left:e=-1/0,right:t=1/0,top:n=-1/0,bottom:s=1/0}=r;return[[e,t],[n,s]]}}),de={ArrowRight:(r,e=1)=>[r*e,0],ArrowLeft:(r,e=1)=>[-1*r*e,0],ArrowUp:(r,e=1)=>[0,-1*r*e],ArrowDown:(r,e=1)=>[0,r*e]};class We extends Ge{constructor(...e){super(...e),w(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),s={left:t.left-n.left+e.offset[0],right:t.right-n.right+e.offset[0],top:t.top-n.top+e.offset[1],bottom:t.bottom-n.bottom+e.offset[1]};e._bounds=R.bounds(s)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=W(e),n._pointerActive=!0,this.computeValues(ce(e)),this.computeInitial(),t.preventScrollAxis&&oe(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,n=this.config;if(!t._pointerActive)return;const s=W(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;const o=ce(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=v.sub(o,t._values),this.computeValues(o)),v.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{process.env.NODE_ENV==="development"&&console.warn("[@use-gesture]: If you see this message, it's likely that you're using an outdated version of `@react-three/fiber`. \n\nPlease upgrade to the latest version.")}const t=this.state,n=this.config;if(!t._active||!t._pointerActive)return;const s=W(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[o,a]=t._distance;if(t.tap=o<=n.tapsThreshold&&a<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[u,h]=t._delta,[p,c]=t._movement,[E,y]=n.swipe.velocity,[M,C]=n.swipe.distance,k=n.swipe.duration;if(t.elapsedTime<k){const P=Math.abs(u/t.timeDelta),L=Math.abs(h/t.timeDelta);P>E&&Math.abs(p)>M&&(t.swipe[0]=Math.sign(u)),L>y&&Math.abs(c)>C&&(t.swipe[1]=Math.sign(h))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,n=t.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&t.preventScrollDelay===void 0){const s="uv"in e?e.sourceEvent.currentTarget:e.currentTarget;window.getComputedStyle(s).touchAction==="auto"&&console.warn("[@use-gesture]: The drag target has its `touch-action` style property set to `auto`. It is recommended to add `touch-action: 'none'` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.\n\nThis message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.",s)}}catch{}t.pointerLock&&e.currentTarget.requestPointerLock(),t.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,He(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=de[e.key];if(t){const n=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=t(this.config.keyboardDisplacement,s),n._keyboardActive=!0,v.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in de&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function He(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const j=typeof window<"u"&&window.document&&window.document.createElement;function he(){return j&&"ontouchstart"in window}function Xe(){return he()||j&&window.navigator.maxTouchPoints>1}function qe(){return j&&"onpointerdown"in window}function Je(){return j&&"exitPointerLock"in window.document}function Qe(){try{return"constructor"in GestureEvent}catch{return!1}}const S={isBrowser:j,gesture:Qe(),touch:he(),touchscreen:Xe(),pointer:qe(),pointerLock:Je()},Ze=250,et=180,tt=.5,rt=50,nt=250,st=10,pe={mouse:0,touch:0,pen:8},ge=d(d({},R),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&S.pointerLock,S.touch&&t?"touch":this.pointerLock?"mouse":S.pointer&&!s?"pointer":S.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?Ze:void 0,!(!S.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:s=!0}={}}){return this.pointerButtons=n,this.keys=s,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:s=void 0}){const o=v.toVector(r,t?n:s?1:0);return this.filterTaps=t,this.tapsThreshold=n,o},swipe({velocity:r=tt,distance:e=rt,duration:t=nt}={}){return{velocity:this.transform(v.toVector(r)),distance:this.transform(v.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return et;case!1:return 0;default:return r}},axisThreshold(r){return r?d(d({},pe),r):pe},keyboardDisplacement(r=st){return r}});process.env.NODE_ENV==="development"&&Object.assign(ge,{useTouch(r){if(r!==void 0)throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");return NaN},experimental_preventWindowScrollY(r){if(r!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");return NaN},swipeDistance(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),d(d({},H),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!S.touch&&S.gesture)return"gesture";if(S.touch&&n)return"touch";if(S.touchscreen){if(S.pointer)return"pointer";if(S.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const s=a=>{const u=ue(z(t,a),{min:-1/0,max:1/0});return[u.min,u.max]},o=a=>{const u=ue(z(n,a),{min:-1/0,max:1/0});return[u.min,u.max]};return typeof t!="function"&&typeof n!="function"?[s(),o()]:a=>[s(a),o(a)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",v.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}}),d(d({},R),{},{mouseOnly:(r=!0)=>r}),d(d({},R),{},{mouseOnly:(r=!0)=>r});const me=new Map,X=new Map;function it(r){me.set(r.key,r.engine),X.set(r.key,r.resolver)}const ot={key:"drag",engine:We,resolver:ge};function at(r,e){if(r==null)return{};var t={},n=Object.keys(r),s,o;for(o=0;o<n.length;o++)s=n[o],!(e.indexOf(s)>=0)&&(t[s]=r[s]);return t}function ct(r,e){if(r==null)return{};var t=at(r,e),n,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);for(s=0;s<o.length;s++)n=o[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const ut={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=S.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},ft=["target","eventOptions","window","enabled","transform"];function Y(r={},e){const t={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const o=s.call(t,r[n],n,r);Number.isNaN(o)||(t[n]=o)}else t[n]=s.call(t,r[n],n,r);break;case"object":t[n]=Y(r[n],s);break;case"boolean":s&&(t[n]=r[n]);break}return t}function lt(r,e,t={}){const n=r,{target:s,eventOptions:o,window:a,enabled:u,transform:h}=n,p=ct(n,ft);if(t.shared=Y({target:s,eventOptions:o,window:a,enabled:u,transform:h},ut),e){const c=X.get(e);t[e]=Y(d({shared:t.shared},p),c)}else for(const c in p){const E=X.get(c);if(E)t[c]=Y(d({shared:t.shared},p[c]),E);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(c)){if(c==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${c}\` was used. Please read the documentation for further information.`)}}return t}class ve{constructor(e,t){w(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,s,o){const a=this._listeners,u=Me(t,n),h=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},p=d(d({},h),o);e.addEventListener(u,s,p);const c=()=>{e.removeEventListener(u,s,p),a.delete(c)};return a.add(c),c}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class dt{constructor(){w(this,"_timeouts",new Map)}add(e,t,n=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...s))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class ht{constructor(e){w(this,"gestures",new Set),w(this,"_targetEventStore",new ve(this)),w(this,"gestureEventStores",{}),w(this,"gestureTimeoutStores",{}),w(this,"handlers",{}),w(this,"config",{}),w(this,"pointerIds",new Set),w(this,"touchIds",new Set),w(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),pt(this,e)}setEventIds(e){if(B(e))return this.touchIds=new Set(Re(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=lt(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,n={};let s;if(!(t.target&&(s=t.target(),!s))){if(t.enabled){for(const a of this.gestures){const u=this.config[a],h=ye(n,u.eventOptions,!!s);if(u.enabled){const p=me.get(a);new p(this,e,a).bind(h)}}const o=ye(n,t.eventOptions,!!s);for(const a in this.nativeHandlers)o(a,"",u=>this.nativeHandlers[a](d(d({},this.state.shared),{},{event:u,args:e})),void 0,!0)}for(const o in n)n[o]=Ke(...n[o]);if(!s)return n;for(const o in n){const{device:a,capture:u,passive:h}=Ne(o);this._targetEventStore.add(s,a,"",n[o],{capture:u,passive:h})}}}}function N(r,e){r.gestures.add(e),r.gestureEventStores[e]=new ve(r,e),r.gestureTimeoutStores[e]=new dt}function pt(r,e){e.drag&&N(r,"drag"),e.wheel&&N(r,"wheel"),e.scroll&&N(r,"scroll"),e.move&&N(r,"move"),e.pinch&&N(r,"pinch"),e.hover&&N(r,"hover")}const ye=(r,e,t)=>(n,s,o,a={},u=!1)=>{var h,p;const c=(h=a.capture)!==null&&h!==void 0?h:e.capture,E=(p=a.passive)!==null&&p!==void 0?p:e.passive;let y=u?n:$e(n,s,c);t&&E&&(y+="Passive"),r[y]=r[y]||[],r[y].push(o)};function gt(r,e={},t,n){const s=g.useMemo(()=>new ht(r),[]);if(s.applyHandlers(r,n),s.applyConfig(e,t),g.useEffect(s.effect.bind(s)),g.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function mt(r,e){return it(ot),gt({drag:r},e||{},"drag")}const q="RSC::Event";function vt(){const r=g.useRef(null);function e(n){g.useEffect(()=>{r.current||(r.current=document.createElement("div"));function s(o){n(o.detail)}if(r.current)return r.current.addEventListener(q,s,!1),()=>{var o;(o=r.current)==null||o.removeEventListener(q,s,!1)}},[n])}function t(n){if(r.current){const s=new CustomEvent(q,{detail:n});r.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:t}}function yt({init:r=!0,items:e,withLoop:t=!1,id:n,itemsPerSlide:s=1,responsiveGutter:o=[{breakpoint:0,gutter:0,startEndGutter:0}],carouselAxis:a="x",startingPosition:u="start",enableGestures:h=!0,slideWhenDragThresholdIsReached:p=!0,onInit:c,initialActiveItem:E=0}){const[y,M]=g.useState(!1),C=g.useRef(r),k=g.useRef(null),P=g.useRef(null),L=g.useRef(0),I=g.useRef(0),O=g.useRef(!t),A=g.useRef(!1),U=g.useRef(0),f=g.useRef(0),[K,J]=Se.useSpring(()=>({value:0,onChange({value:i}){k.current.style.setProperty(`--${n}-offset-position`,`${i.value}px`)}}),[a]),_t=t?[...e.map(i=>({...i,id:`prev-repeated-item-${i.id}`,isClonedItem:!0})),...e,...e.map(i=>({...i,id:`next-repeated-item-${i.id}`,isClonedItem:!0}))]:e,{useListenToCustomEvent:_e,emitEvent:G}=vt();function bt(){const{totalGutterCssVar:i}=be();return i}function Q(i){C.current&&(A.current||V({type:"next",toIndex:i,actionType:"click"}))}function Z(i){C.current&&(O.current||V({type:"prev",toIndex:i,actionType:"click"}))}function V({type:i,shouldAnimate:l=!0,toIndex:_,actionType:m}){var Ee,Te;const b=!l;O.current=!1,A.current=!1;let T=K.value.get(),x=0;if(i==="next"&&(f.current+=1),i==="prev"&&(f.current===0?f.current=e.length-1:f.current-=1),_!==void 0&&(f.current=_),i==="next"){const F=ee(t?I.current*(e.length*2):0);x=-(f.current*I.current),t&&f.current===e.length&&(f.current=0,T=T+I.current*e.length,x=0),!t&&Math.abs(x)>=F&&(A.current=!0,x=-F)}i==="prev"&&(x=-(f.current*I.current),f.current===e.length-1&&(T=T-e.length*I.current),!t&&x>=0&&(O.current=!0,x=0)),L.current=x,m==="resize"?(x=-(f.current*I.current),G({eventName:"onResize",sliceActionType:m,slideDirection:i,currentItem:{index:f.current,id:((Ee=e.at(f.current))==null?void 0:Ee.id)??"",startReached:O.current,endReached:A.current}})):G({eventName:"onSlideStartChange",sliceActionType:m,slideDirection:i,nextItem:{index:f.current,id:((Te=e.at(f.current))==null?void 0:Te.id)??"",startReached:O.current,endReached:A.current}}),J.start({immediate:b,from:{value:T},to:{value:x},onRest({finished:F}){var xe;F&&G({eventName:"onSlideChangeComplete",sliceActionType:m,slideDirection:i,currentItem:{index:f.current,id:((xe=e.at(f.current))==null?void 0:xe.id)??"",startReached:O.current,endReached:A.current}})}})}function wt(){const i=P.current.children[0];let l=0;return l=i.getBoundingClientRect()[a==="x"?"width":"height"]+bt(),l}function ee(i){const l=P.current;return l[a==="x"?"scrollWidth":"scrollHeight"]-l.getBoundingClientRect()[a==="x"?"width":"height"]-i}function be(){let i=0,l=0;if(k.current){const _=window.getComputedStyle(k.current),m=_.getPropertyValue(`--${n}-start-end-gutter`).trim();m.includes("px")&&(i=Number(m.replace("px","")));const b=_.getPropertyValue(`--${n}-gutter`).trim();b.includes("px")&&(l=Number(b.replace("px","")))}return{totalStartEndGutterCssVar:i,totalGutterCssVar:l}}g.useEffect(()=>{function i(m,b){switch(m){case"start":return 0;case"middle-start":return Math.floor((b-1)*.25);case"center":return Math.floor((b-1)*.5);case"middle-end":return Math.floor((b-1)*.75);case"end":return b-1;default:return 0}}function l(m){if(I.current=wt(),U.current=I.current/4,k.current){const{totalStartEndGutterCssVar:b}=be();console.log({totalStartEndGutterCssVar:b});let T=0;t&&(T=I.current*e.length),T-=I.current*i(u,s),T-=b/2,k.current.style.setProperty(`--${n}-offset-modifier`,`${-T}px`),M(!0),m&&m()}}function _(){l(),V({type:"resize",toIndex:f.current,shouldAnimate:!1,actionType:"resize"})}if(r)return C.current=!0,l(c),window.addEventListener("resize",_),()=>{window.removeEventListener("resize",_)}},[r,t,n,a,o,u]),g.useEffect(()=>{r&&E!==f.current&&V({type:"next",toIndex:E,actionType:"resize",shouldAnimate:!1})},[r,E]);const we=h,Et=mt(i=>{if(!C.current)return;const l=i.dragging,_=i.offset[a==="x"?0:1],m=i.movement[a==="x"?0:1],b=m>U.current,T=m<-U.current,x=i.velocity;l&&(G({...i,eventName:"onDrag",slideActionType:"drag"}),J.start({value:_,immediate:!0,config:{velocity:x}}),p&&(b||T)&&i.cancel()),i.last&&(b?(V({actionType:"drag",type:"prev"}),i.cancel()):T?(V({actionType:"drag",type:"next"}),i.cancel()):(J.start({value:L.current,config:{velocity:x}}),i.cancel()))},{enabled:we,axis:a,rubberband:!t,...t?{}:{bounds:()=>({right:0,left:-ee(0),top:-ee(0),bottom:0})},from:()=>[K.value.get(),K.value.get()]});function Tt(i){var l,_;return typeof i=="number"?f.current===i:((l=e.find(m=>m.id===i))==null?void 0:l.id)===((_=e[f.current])==null?void 0:_.id)}return{carouselFragment:$.jsxs("div",{ref:k,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,...Et(),children:[$.jsx("style",{dangerouslySetInnerHTML:{__html:`
1
+ (function(D,A){typeof exports=="object"&&typeof module<"u"?A(exports,require("react/jsx-runtime"),require("@react-spring/web"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@react-spring/web","react"],A):(D=typeof globalThis<"u"?globalThis:D||self,A(D["react-spring-carousel"]={},D["react/jsx-runtime"],D["@react-spring/web"],D.React))})(this,function(D,A,Se,g){"use strict";function Ie(r,e,t){return Math.max(e,Math.min(r,t))}const v={toVector(r,e){return r===void 0&&(r=e),Array.isArray(r)?r:[r,r]},add(r,e){return[r[0]+e[0],r[1]+e[1]]},sub(r,e){return[r[0]-e[0],r[1]-e[1]]},addTo(r,e){r[0]+=e[0],r[1]+=e[1]},subTo(r,e){r[0]-=e[0],r[1]-=e[1]}};function te(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function re(r,e,t,n=.15){return n===0?Ie(r,e,t):r<e?-te(e-r,t-e,n)+e:r>t?+te(r-t,t-e,n)+t:r}function ke(r,[e,t],[n,s]){const[[o,a],[u,h]]=r;return[re(e,o,a,n),re(t,u,h,s)]}function De(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Ce(r){var e=De(r,"string");return typeof e=="symbol"?e:String(e)}function w(r,e,t){return e=Ce(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function ne(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,n)}return t}function d(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ne(Object(t),!0).forEach(function(n){w(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ne(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const se={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function ie(r){return r?r[0].toUpperCase()+r.slice(1):""}const Oe=["enter","leave"];function $e(r=!1,e){return r&&!Oe.includes(e)}function Ae(r,e="",t=!1){const n=se[r],s=n&&n[e]||e;return"on"+ie(r)+ie(s)+($e(t,s)?"Capture":"")}const Pe=["gotpointercapture","lostpointercapture"];function Ne(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=Pe.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:t}}function Me(r,e=""){const t=se[r],n=t&&t[e]||e;return r+n}function B(r){return"touches"in r}function oe(r){return B(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function Le(r){return Array.from(r.touches).filter(e=>{var t,n;return e.target===r.currentTarget||((t=r.currentTarget)===null||t===void 0||(n=t.contains)===null||n===void 0?void 0:n.call(t,e.target))})}function Ve(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function ae(r){return B(r)?Ve(r)[0]:r}function Re(r){return Le(r).map(e=>e.identifier)}function W(r){const e=ae(r);return B(r)?e.identifier:e.pointerId}function ce(r){const e=ae(r);return[e.clientX,e.clientY]}function je(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:s,ctrlKey:o}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:s,ctrlKey:o})}return e}function z(r,...e){return typeof r=="function"?r(...e):r}function Ue(){}function Ke(...r){return r.length===0?Ue:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function ue(r,e){return Object.assign({},e,r||{})}const Be=32;class ze{constructor(e,t,n){this.ctrl=e,this.args=t,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:n,args:s}=this;t[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=s,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,n=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=n.from?z(n.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:n,shared:s}=this;t.args=this.args;let o=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,je(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,o=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const f=t._delta.map(Math.abs);v.addTo(t._distance,f)}this.axisIntent&&this.axisIntent(e);const[a,u]=t._movement,[h,p]=n.threshold,{_step:c,values:E}=t;if(n.hasCustomTransform?(c[0]===!1&&(c[0]=Math.abs(a)>=h&&E[0]),c[1]===!1&&(c[1]=Math.abs(u)>=p&&E[1])):(c[0]===!1&&(c[0]=Math.abs(a)>=h&&Math.sign(a)*h),c[1]===!1&&(c[1]=Math.abs(u)>=p&&Math.sign(u)*p)),t.intentional=c[0]!==!1||c[1]!==!1,!t.intentional)return;const y=[0,0];if(n.hasCustomTransform){const[f,K]=E;y[0]=c[0]!==!1?f-c[0]:0,y[1]=c[1]!==!1?K-c[1]:0}else y[0]=c[0]!==!1?a-c[0]:0,y[1]=c[1]!==!1?u-c[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(y);const M=t.offset,C=t._active&&!t._blocked||t.active;C&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=s[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=z(n.bounds,t)),this.setup&&this.setup()),t.movement=y,this.computeOffset()));const[k,P]=t.offset,[[L,I],[O,$]]=t._bounds;t.overflow=[k<L?-1:k>I?1:0,P<O?-1:P>$?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const U=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=ke(t._bounds,t.offset,U),t.delta=v.sub(t.offset,M),this.computeMovement(),C&&(!t.last||o>Be)){t.delta=v.sub(t.offset,M);const f=t.delta.map(Math.abs);v.addTo(t.distance,f),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&o>0&&(t.velocity=[f[0]/o,f[1]/o],t.timeDelta=o)}}emit(){const e=this.state,t=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const s=this.handler(d(d(d({},t),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Ye([r,e],t){const n=Math.abs(r),s=Math.abs(e);if(n>s&&n>t)return"x";if(s>n&&s>t)return"y"}class Ge extends ze{constructor(...e){super(...e),w(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=v.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=v.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const s=typeof n.axisThreshold=="object"?n.axisThreshold[oe(e)]:n.axisThreshold;t.axis=Ye(t._movement,s)}t._blocked=(n.lockDirection||!!n.axis)&&!t.axis||!!n.axis&&n.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const fe=r=>r,le=.15,H={enabled(r=!0){return r},eventOptions(r,e,t){return d(d({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[le,le];case!1:return[0,0];default:return v.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return v.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||fe;return o=>{const a=s(o);return(!isFinite(a[0])||!isFinite(a[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${a[0]},${[1]}]`),a}}return n||fe},threshold(r){return v.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(H,{domTarget(r){if(r!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(r){if(r!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(r){if(r!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const Fe=0,R=d(d({},H),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=Fe){return r},bounds(r={}){if(typeof r=="function")return o=>R.bounds(r(o));if("current"in r)return()=>r.current;if(typeof HTMLElement=="function"&&r instanceof HTMLElement)return r;const{left:e=-1/0,right:t=1/0,top:n=-1/0,bottom:s=1/0}=r;return[[e,t],[n,s]]}}),de={ArrowRight:(r,e=1)=>[r*e,0],ArrowLeft:(r,e=1)=>[-1*r*e,0],ArrowUp:(r,e=1)=>[0,-1*r*e],ArrowDown:(r,e=1)=>[0,r*e]};class We extends Ge{constructor(...e){super(...e),w(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),s={left:t.left-n.left+e.offset[0],right:t.right-n.right+e.offset[0],top:t.top-n.top+e.offset[1],bottom:t.bottom-n.bottom+e.offset[1]};e._bounds=R.bounds(s)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=W(e),n._pointerActive=!0,this.computeValues(ce(e)),this.computeInitial(),t.preventScrollAxis&&oe(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,n=this.config;if(!t._pointerActive)return;const s=W(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;const o=ce(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=v.sub(o,t._values),this.computeValues(o)),v.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{process.env.NODE_ENV==="development"&&console.warn("[@use-gesture]: If you see this message, it's likely that you're using an outdated version of `@react-three/fiber`. \n\nPlease upgrade to the latest version.")}const t=this.state,n=this.config;if(!t._active||!t._pointerActive)return;const s=W(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[o,a]=t._distance;if(t.tap=o<=n.tapsThreshold&&a<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[u,h]=t._delta,[p,c]=t._movement,[E,y]=n.swipe.velocity,[M,C]=n.swipe.distance,k=n.swipe.duration;if(t.elapsedTime<k){const P=Math.abs(u/t.timeDelta),L=Math.abs(h/t.timeDelta);P>E&&Math.abs(p)>M&&(t.swipe[0]=Math.sign(u)),L>y&&Math.abs(c)>C&&(t.swipe[1]=Math.sign(h))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,n=t.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&t.preventScrollDelay===void 0){const s="uv"in e?e.sourceEvent.currentTarget:e.currentTarget;window.getComputedStyle(s).touchAction==="auto"&&console.warn("[@use-gesture]: The drag target has its `touch-action` style property set to `auto`. It is recommended to add `touch-action: 'none'` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.\n\nThis message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.",s)}}catch{}t.pointerLock&&e.currentTarget.requestPointerLock(),t.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,He(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=de[e.key];if(t){const n=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=t(this.config.keyboardDisplacement,s),n._keyboardActive=!0,v.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in de&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function He(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const j=typeof window<"u"&&window.document&&window.document.createElement;function he(){return j&&"ontouchstart"in window}function Xe(){return he()||j&&window.navigator.maxTouchPoints>1}function qe(){return j&&"onpointerdown"in window}function Je(){return j&&"exitPointerLock"in window.document}function Qe(){try{return"constructor"in GestureEvent}catch{return!1}}const S={isBrowser:j,gesture:Qe(),touch:he(),touchscreen:Xe(),pointer:qe(),pointerLock:Je()},Ze=250,et=180,tt=.5,rt=50,nt=250,st=10,pe={mouse:0,touch:0,pen:8},ge=d(d({},R),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&S.pointerLock,S.touch&&t?"touch":this.pointerLock?"mouse":S.pointer&&!s?"pointer":S.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?Ze:void 0,!(!S.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:s=!0}={}}){return this.pointerButtons=n,this.keys=s,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:s=void 0}){const o=v.toVector(r,t?n:s?1:0);return this.filterTaps=t,this.tapsThreshold=n,o},swipe({velocity:r=tt,distance:e=rt,duration:t=nt}={}){return{velocity:this.transform(v.toVector(r)),distance:this.transform(v.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return et;case!1:return 0;default:return r}},axisThreshold(r){return r?d(d({},pe),r):pe},keyboardDisplacement(r=st){return r}});process.env.NODE_ENV==="development"&&Object.assign(ge,{useTouch(r){if(r!==void 0)throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");return NaN},experimental_preventWindowScrollY(r){if(r!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");return NaN},swipeDistance(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),d(d({},H),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!S.touch&&S.gesture)return"gesture";if(S.touch&&n)return"touch";if(S.touchscreen){if(S.pointer)return"pointer";if(S.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const s=a=>{const u=ue(z(t,a),{min:-1/0,max:1/0});return[u.min,u.max]},o=a=>{const u=ue(z(n,a),{min:-1/0,max:1/0});return[u.min,u.max]};return typeof t!="function"&&typeof n!="function"?[s(),o()]:a=>[s(a),o(a)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",v.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}}),d(d({},R),{},{mouseOnly:(r=!0)=>r}),d(d({},R),{},{mouseOnly:(r=!0)=>r});const me=new Map,X=new Map;function it(r){me.set(r.key,r.engine),X.set(r.key,r.resolver)}const ot={key:"drag",engine:We,resolver:ge};function at(r,e){if(r==null)return{};var t={},n=Object.keys(r),s,o;for(o=0;o<n.length;o++)s=n[o],!(e.indexOf(s)>=0)&&(t[s]=r[s]);return t}function ct(r,e){if(r==null)return{};var t=at(r,e),n,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);for(s=0;s<o.length;s++)n=o[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const ut={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=S.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},ft=["target","eventOptions","window","enabled","transform"];function Y(r={},e){const t={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const o=s.call(t,r[n],n,r);Number.isNaN(o)||(t[n]=o)}else t[n]=s.call(t,r[n],n,r);break;case"object":t[n]=Y(r[n],s);break;case"boolean":s&&(t[n]=r[n]);break}return t}function lt(r,e,t={}){const n=r,{target:s,eventOptions:o,window:a,enabled:u,transform:h}=n,p=ct(n,ft);if(t.shared=Y({target:s,eventOptions:o,window:a,enabled:u,transform:h},ut),e){const c=X.get(e);t[e]=Y(d({shared:t.shared},p),c)}else for(const c in p){const E=X.get(c);if(E)t[c]=Y(d({shared:t.shared},p[c]),E);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(c)){if(c==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${c}\` was used. Please read the documentation for further information.`)}}return t}class ve{constructor(e,t){w(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,s,o){const a=this._listeners,u=Me(t,n),h=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},p=d(d({},h),o);e.addEventListener(u,s,p);const c=()=>{e.removeEventListener(u,s,p),a.delete(c)};return a.add(c),c}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class dt{constructor(){w(this,"_timeouts",new Map)}add(e,t,n=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...s))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class ht{constructor(e){w(this,"gestures",new Set),w(this,"_targetEventStore",new ve(this)),w(this,"gestureEventStores",{}),w(this,"gestureTimeoutStores",{}),w(this,"handlers",{}),w(this,"config",{}),w(this,"pointerIds",new Set),w(this,"touchIds",new Set),w(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),pt(this,e)}setEventIds(e){if(B(e))return this.touchIds=new Set(Re(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=lt(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,n={};let s;if(!(t.target&&(s=t.target(),!s))){if(t.enabled){for(const a of this.gestures){const u=this.config[a],h=ye(n,u.eventOptions,!!s);if(u.enabled){const p=me.get(a);new p(this,e,a).bind(h)}}const o=ye(n,t.eventOptions,!!s);for(const a in this.nativeHandlers)o(a,"",u=>this.nativeHandlers[a](d(d({},this.state.shared),{},{event:u,args:e})),void 0,!0)}for(const o in n)n[o]=Ke(...n[o]);if(!s)return n;for(const o in n){const{device:a,capture:u,passive:h}=Ne(o);this._targetEventStore.add(s,a,"",n[o],{capture:u,passive:h})}}}}function N(r,e){r.gestures.add(e),r.gestureEventStores[e]=new ve(r,e),r.gestureTimeoutStores[e]=new dt}function pt(r,e){e.drag&&N(r,"drag"),e.wheel&&N(r,"wheel"),e.scroll&&N(r,"scroll"),e.move&&N(r,"move"),e.pinch&&N(r,"pinch"),e.hover&&N(r,"hover")}const ye=(r,e,t)=>(n,s,o,a={},u=!1)=>{var h,p;const c=(h=a.capture)!==null&&h!==void 0?h:e.capture,E=(p=a.passive)!==null&&p!==void 0?p:e.passive;let y=u?n:Ae(n,s,c);t&&E&&(y+="Passive"),r[y]=r[y]||[],r[y].push(o)};function gt(r,e={},t,n){const s=g.useMemo(()=>new ht(r),[]);if(s.applyHandlers(r,n),s.applyConfig(e,t),g.useEffect(s.effect.bind(s)),g.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function mt(r,e){return it(ot),gt({drag:r},e||{},"drag")}const q="RSC::Event";function vt(){const r=g.useRef(null);function e(n){g.useEffect(()=>{r.current||(r.current=document.createElement("div"));function s(o){n(o.detail)}if(r.current)return r.current.addEventListener(q,s,!1),()=>{var o;(o=r.current)==null||o.removeEventListener(q,s,!1)}},[n])}function t(n){if(r.current){const s=new CustomEvent(q,{detail:n});r.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:t}}function yt({init:r=!0,items:e,withLoop:t=!1,id:n,itemsPerSlide:s=1,responsiveGutter:o=[{breakpoint:0,gutter:0,startEndGutter:0}],carouselAxis:a="x",startingPosition:u="start",enableGestures:h=!0,slideWhenDragThresholdIsReached:p=!0,onInit:c,initialActiveItem:E=0}){const[y,M]=g.useState(!1),C=g.useRef(r),k=g.useRef(null),P=g.useRef(null),L=g.useRef(0),I=g.useRef(0),O=g.useRef(!t),$=g.useRef(!1),U=g.useRef(0),f=g.useRef(0),[K,J]=Se.useSpring(()=>({value:0,onChange({value:i}){k.current.style.setProperty(`--${n}-offset-position`,`${i.value}px`)}}),[a]),_t=t?[...e.map(i=>({...i,id:`prev-repeated-item-${i.id}`,isClonedItem:!0})),...e,...e.map(i=>({...i,id:`next-repeated-item-${i.id}`,isClonedItem:!0}))]:e,{useListenToCustomEvent:_e,emitEvent:G}=vt();function bt(){const{totalGutterCssVar:i}=be();return i}function Q(i){C.current&&($.current||V({type:"next",toIndex:i,actionType:"click"}))}function Z(i){C.current&&(O.current||V({type:"prev",toIndex:i,actionType:"click"}))}function V({type:i,shouldAnimate:l=!0,toIndex:_,actionType:m}){var Ee,Te;const b=!l;O.current=!1,$.current=!1;let T=K.value.get(),x=0;if(i==="next"&&(f.current+=1),i==="prev"&&(f.current===0?f.current=e.length-1:f.current-=1),_!==void 0&&(f.current=_),i==="next"){const F=ee(t?I.current*(e.length*2):0);x=-(f.current*I.current),t&&f.current===e.length&&(f.current=0,T=T+I.current*e.length,x=0),!t&&Math.abs(x)>=F&&($.current=!0,x=-F)}i==="prev"&&(x=-(f.current*I.current),f.current===e.length-1&&(T=T-e.length*I.current),!t&&x>=0&&(O.current=!0,x=0)),L.current=x,m==="resize"?(x=-(f.current*I.current),G({eventName:"onResize",sliceActionType:m,slideDirection:i,currentItem:{index:f.current,id:((Ee=e.at(f.current))==null?void 0:Ee.id)??"",startReached:O.current,endReached:$.current}})):G({eventName:"onSlideStartChange",sliceActionType:m,slideDirection:i,nextItem:{index:f.current,id:((Te=e.at(f.current))==null?void 0:Te.id)??"",startReached:O.current,endReached:$.current}}),J.start({immediate:b,from:{value:T},to:{value:x},onRest({finished:F}){var xe;F&&G({eventName:"onSlideChangeComplete",sliceActionType:m,slideDirection:i,currentItem:{index:f.current,id:((xe=e.at(f.current))==null?void 0:xe.id)??"",startReached:O.current,endReached:$.current}})}})}function wt(){const i=P.current.children[0];let l=0;return l=i.getBoundingClientRect()[a==="x"?"width":"height"]+bt(),l}function ee(i){const l=P.current;return l[a==="x"?"scrollWidth":"scrollHeight"]-l.getBoundingClientRect()[a==="x"?"width":"height"]-i}function be(){let i=0,l=0;if(k.current){const _=window.getComputedStyle(k.current),m=_.getPropertyValue(`--${n}-start-end-gutter`).trim();m.includes("px")&&(i=Number(m.replace("px","")));const b=_.getPropertyValue(`--${n}-gutter`).trim();b.includes("px")&&(l=Number(b.replace("px","")))}return{totalStartEndGutterCssVar:i,totalGutterCssVar:l}}g.useEffect(()=>{function i(m,b){switch(m){case"start":return 0;case"middle-start":return Math.floor((b-1)*.25);case"center":return Math.floor((b-1)*.5);case"middle-end":return Math.floor((b-1)*.75);case"end":return b-1;default:return 0}}function l(m){if(I.current=wt(),U.current=I.current/4,k.current){const{totalStartEndGutterCssVar:b}=be();console.log({totalStartEndGutterCssVar:b});let T=0;t&&(T=I.current*e.length),T-=I.current*i(u,s),T-=b/2,k.current.style.setProperty(`--${n}-offset-modifier`,`${-T}px`),M(!0),m&&m()}}function _(){l(),V({type:"resize",toIndex:f.current,shouldAnimate:!1,actionType:"resize"})}if(r)return C.current=!0,l(c),window.addEventListener("resize",_),()=>{window.removeEventListener("resize",_)}},[r,t,n,a,o,u]),g.useEffect(()=>{r&&E!==f.current&&V({type:"next",toIndex:E,actionType:"resize",shouldAnimate:!1})},[r,E]);const we=h,Et=mt(i=>{if(!C.current)return;const l=i.dragging,_=i.offset[a==="x"?0:1],m=i.movement[a==="x"?0:1],b=m>U.current,T=m<-U.current,x=i.velocity;l&&(G({...i,eventName:"onDrag",slideActionType:"drag"}),J.start({value:_,immediate:!0,config:{velocity:x}}),p&&(b||T)&&i.cancel()),i.last&&(b?(V({actionType:"drag",type:"prev"}),i.cancel()):T?(V({actionType:"drag",type:"next"}),i.cancel()):(J.start({value:L.current,config:{velocity:x}}),i.cancel()))},{enabled:we,axis:a,rubberband:!t,...t?{}:{bounds:()=>({right:0,left:-ee(0),top:-ee(0),bottom:0})},from:()=>[K.value.get(),K.value.get()]});function Tt(i){var l,_;return typeof i=="number"?f.current===i:((l=e.find(m=>m.id===i))==null?void 0:l.id)===((_=e[f.current])==null?void 0:_.id)}return{carouselFragment:A.jsxs("div",{ref:k,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,...Et(),children:[A.jsx("style",{dangerouslySetInnerHTML:{__html:`
2
2
  [data-part-internal="${n}-Container"] {
3
3
  display: flex;
4
4
  width: 100%;
@@ -9,6 +9,8 @@
9
9
  --${n}-offset-modifier: 0px;
10
10
  --${n}-scroll-x-value: ${a==="x"?`calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))`:"0px"};
11
11
  --${n}-scroll-y-value: ${a==="y"?`calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))`:"0px"};
12
+ --${n}-gutter: 0px;
13
+ --${n}-start-end-gutter: 0px;
12
14
  touch-action: ${we?a==="x"?"pan-y":"pan-x":"auto"};
13
15
  }
14
16
  [data-part-internal="${n}-Track"] {
@@ -35,4 +37,4 @@
35
37
  }
36
38
  }
37
39
  `).join(""):""}
38
- `}}),$.jsx("div",{ref:P,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track`,onScroll:()=>{O.current=!1,A.current=!1},children:_t.map((i,l)=>$.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,"data-id":i.id,children:typeof i.renderItem=="function"?i.renderItem({useListenToCustomEvent:_e,index:l,isClonedItem:!!i.isClonedItem,isActiveItem:Tt}):i.renderItem},`${i.id}-${l}`))})]}),useListenToCustomEvent:_e,slideToNextItem:()=>Q(),slideToPrevItem:()=>Z(),slideToItem:i=>{if(typeof i=="number"){if(!e[i]){console.warn(`The item you're trying to slide doesn't exist. index: ${i}`);return}i>f.current?Q(i):Z(i)}if(typeof i=="string"){const l=e.findIndex(_=>_.id===i);if(l<0){console.warn(`The item you're trying to slide doesn't exist. id: ${i}`);return}l>f.current?Q(l):Z(l)}}}}D.useSpringCarousel=yt,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
40
+ `}}),A.jsx("div",{ref:P,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track`,onScroll:()=>{O.current=!1,$.current=!1},children:_t.map((i,l)=>A.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,"data-id":i.id,children:typeof i.renderItem=="function"?i.renderItem({useListenToCustomEvent:_e,index:l,isClonedItem:!!i.isClonedItem,isActiveItem:Tt}):i.renderItem},`${i.id}-${l}`))})]}),useListenToCustomEvent:_e,slideToNextItem:()=>Q(),slideToPrevItem:()=>Z(),slideToItem:i=>{if(typeof i=="number"){if(!e[i]){console.warn(`The item you're trying to slide doesn't exist. index: ${i}`);return}i>f.current?Q(i):Z(i)}if(typeof i=="string"){const l=e.findIndex(_=>_.id===i);if(l<0){console.warn(`The item you're trying to slide doesn't exist. id: ${i}`);return}l>f.current?Q(l):Z(l)}}}}D.useSpringCarousel=yt,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-spring-carousel",
3
- "version": "3.0.0-beta-2.0.3",
3
+ "version": "3.0.0-beta-2.0.32",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.umd.js",