react-spring-carousel 3.0.0-beta-2.1.0 → 3.0.0-beta-2.1.1

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,10 +1,10 @@
1
- import { jsxs as Yt, jsx as et } from "react/jsx-runtime";
2
- import { useSpringRef as Ht, useSpring as $t } from "@react-spring/web";
3
- import rt, { useRef as w, useEffect as U, useState as Xt, useCallback as qt, useMemo as nt } from "react";
4
- function Jt(r, t, e) {
1
+ import { jsxs as Qt, jsx as H } from "react/jsx-runtime";
2
+ import { useSpringRef as Zt, useSpring as Ot } from "@react-spring/web";
3
+ import st, { useRef as _, useEffect as z, useState as _t, useCallback as te, useMemo as it } from "react";
4
+ function ee(r, t, e) {
5
5
  return Math.max(t, Math.min(r, e));
6
6
  }
7
- const E = {
7
+ const x = {
8
8
  toVector(r, t) {
9
9
  return r === void 0 && (r = t), Array.isArray(r) ? r : [r, r];
10
10
  },
@@ -21,17 +21,17 @@ const E = {
21
21
  r[0] -= t[0], r[1] -= t[1];
22
22
  }
23
23
  };
24
- function yt(r, t, e) {
24
+ function wt(r, t, e) {
25
25
  return t === 0 || Math.abs(t) === 1 / 0 ? Math.pow(r, e * 5) : r * t * e / (t + e * r);
26
26
  }
27
- function bt(r, t, e, n = 0.15) {
28
- return n === 0 ? Jt(r, t, e) : r < t ? -yt(t - r, e - t, n) + t : r > e ? +yt(r - e, e - t, n) + e : r;
27
+ function xt(r, t, e, n = 0.15) {
28
+ return n === 0 ? ee(r, t, e) : r < t ? -wt(t - r, e - t, n) + t : r > e ? +wt(r - e, e - t, n) + e : r;
29
29
  }
30
- function Qt(r, [t, e], [n, s]) {
31
- const [[a, o], [u, d]] = r;
32
- return [bt(t, a, o, n), bt(e, u, d, s)];
30
+ function re(r, [t, e], [n, s]) {
31
+ const [[a, o], [l, c]] = r;
32
+ return [xt(t, a, o, n), xt(e, l, c, s)];
33
33
  }
34
- function Zt(r, t) {
34
+ function ne(r, t) {
35
35
  if (typeof r != "object" || r === null) return r;
36
36
  var e = r[Symbol.toPrimitive];
37
37
  if (e !== void 0) {
@@ -41,19 +41,19 @@ function Zt(r, t) {
41
41
  }
42
42
  return (t === "string" ? String : Number)(r);
43
43
  }
44
- function te(r) {
45
- var t = Zt(r, "string");
44
+ function se(r) {
45
+ var t = ne(r, "string");
46
46
  return typeof t == "symbol" ? t : String(t);
47
47
  }
48
- function C(r, t, e) {
49
- return t = te(t), t in r ? Object.defineProperty(r, t, {
48
+ function S(r, t, e) {
49
+ return t = se(t), t in r ? Object.defineProperty(r, t, {
50
50
  value: e,
51
51
  enumerable: !0,
52
52
  configurable: !0,
53
53
  writable: !0
54
54
  }) : r[t] = e, r;
55
55
  }
56
- function _t(r, t) {
56
+ function Tt(r, t) {
57
57
  var e = Object.keys(r);
58
58
  if (Object.getOwnPropertySymbols) {
59
59
  var n = Object.getOwnPropertySymbols(r);
@@ -63,18 +63,18 @@ function _t(r, t) {
63
63
  }
64
64
  return e;
65
65
  }
66
- function m(r) {
66
+ function v(r) {
67
67
  for (var t = 1; t < arguments.length; t++) {
68
68
  var e = arguments[t] != null ? arguments[t] : {};
69
- t % 2 ? _t(Object(e), !0).forEach(function(n) {
70
- C(r, n, e[n]);
71
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) : _t(Object(e)).forEach(function(n) {
69
+ t % 2 ? Tt(Object(e), !0).forEach(function(n) {
70
+ S(r, n, e[n]);
71
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) : Tt(Object(e)).forEach(function(n) {
72
72
  Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(e, n));
73
73
  });
74
74
  }
75
75
  return r;
76
76
  }
77
- const Pt = {
77
+ const Nt = {
78
78
  pointer: {
79
79
  start: "down",
80
80
  change: "move",
@@ -96,63 +96,63 @@ const Pt = {
96
96
  end: "end"
97
97
  }
98
98
  };
99
- function xt(r) {
99
+ function It(r) {
100
100
  return r ? r[0].toUpperCase() + r.slice(1) : "";
101
101
  }
102
- const ee = ["enter", "leave"];
103
- function re(r = !1, t) {
104
- return r && !ee.includes(t);
102
+ const ie = ["enter", "leave"];
103
+ function oe(r = !1, t) {
104
+ return r && !ie.includes(t);
105
105
  }
106
- function ne(r, t = "", e = !1) {
107
- const n = Pt[r], s = n && n[t] || t;
108
- return "on" + xt(r) + xt(s) + (re(e, s) ? "Capture" : "");
106
+ function ae(r, t = "", e = !1) {
107
+ const n = Nt[r], s = n && n[t] || t;
108
+ return "on" + It(r) + It(s) + (oe(e, s) ? "Capture" : "");
109
109
  }
110
- const se = ["gotpointercapture", "lostpointercapture"];
111
- function ie(r) {
110
+ const ce = ["gotpointercapture", "lostpointercapture"];
111
+ function ue(r) {
112
112
  let t = r.substring(2).toLowerCase();
113
113
  const e = !!~t.indexOf("passive");
114
114
  e && (t = t.replace("passive", ""));
115
- const n = se.includes(t) ? "capturecapture" : "capture", s = !!~t.indexOf(n);
115
+ const n = ce.includes(t) ? "capturecapture" : "capture", s = !!~t.indexOf(n);
116
116
  return s && (t = t.replace("capture", "")), {
117
117
  device: t,
118
118
  capture: s,
119
119
  passive: e
120
120
  };
121
121
  }
122
- function oe(r, t = "") {
123
- const e = Pt[r], n = e && e[t] || t;
122
+ function le(r, t = "") {
123
+ const e = Nt[r], n = e && e[t] || t;
124
124
  return r + n;
125
125
  }
126
- function X(r) {
126
+ function Q(r) {
127
127
  return "touches" in r;
128
128
  }
129
- function Ot(r) {
130
- return X(r) ? "touch" : "pointerType" in r ? r.pointerType : "mouse";
129
+ function Rt(r) {
130
+ return Q(r) ? "touch" : "pointerType" in r ? r.pointerType : "mouse";
131
131
  }
132
- function ae(r) {
132
+ function fe(r) {
133
133
  return Array.from(r.touches).filter((t) => {
134
134
  var e, n;
135
135
  return t.target === r.currentTarget || ((e = r.currentTarget) === null || e === void 0 || (n = e.contains) === null || n === void 0 ? void 0 : n.call(e, t.target));
136
136
  });
137
137
  }
138
- function ce(r) {
138
+ function de(r) {
139
139
  return r.type === "touchend" || r.type === "touchcancel" ? r.changedTouches : r.targetTouches;
140
140
  }
141
- function At(r) {
142
- return X(r) ? ce(r)[0] : r;
141
+ function Mt(r) {
142
+ return Q(r) ? de(r)[0] : r;
143
143
  }
144
- function ue(r) {
145
- return ae(r).map((t) => t.identifier);
144
+ function he(r) {
145
+ return fe(r).map((t) => t.identifier);
146
146
  }
147
- function st(r) {
148
- const t = At(r);
149
- return X(r) ? t.identifier : t.pointerId;
147
+ function ot(r) {
148
+ const t = Mt(r);
149
+ return Q(r) ? t.identifier : t.pointerId;
150
150
  }
151
- function wt(r) {
152
- const t = At(r);
151
+ function Et(r) {
152
+ const t = Mt(r);
153
153
  return [t.clientX, t.clientY];
154
154
  }
155
- function le(r) {
155
+ function pe(r) {
156
156
  const t = {};
157
157
  if ("buttons" in r && (t.buttons = r.buttons), "shiftKey" in r) {
158
158
  const {
@@ -170,24 +170,24 @@ function le(r) {
170
170
  }
171
171
  return t;
172
172
  }
173
- function H(r, ...t) {
173
+ function J(r, ...t) {
174
174
  return typeof r == "function" ? r(...t) : r;
175
175
  }
176
- function fe() {
176
+ function ge() {
177
177
  }
178
- function de(...r) {
179
- return r.length === 0 ? fe : r.length === 1 ? r[0] : function() {
178
+ function me(...r) {
179
+ return r.length === 0 ? ge : r.length === 1 ? r[0] : function() {
180
180
  let t;
181
181
  for (const e of r)
182
182
  t = e.apply(this, arguments) || t;
183
183
  return t;
184
184
  };
185
185
  }
186
- function Et(r, t) {
186
+ function St(r, t) {
187
187
  return Object.assign({}, t, r || {});
188
188
  }
189
- const he = 32;
190
- class pe {
189
+ const ve = 32;
190
+ class ye {
191
191
  constructor(t, e, n) {
192
192
  this.ctrl = t, this.args = e, this.key = n, this.state || (this.state = {}, this.computeValues([0, 0]), this.computeInitial(), this.init && this.init(), this.reset());
193
193
  }
@@ -226,7 +226,7 @@ class pe {
226
226
  }
227
227
  start(t) {
228
228
  const e = this.state, n = this.config;
229
- e._active || (this.reset(), this.computeInitial(), e._active = !0, e.target = t.target, e.currentTarget = t.currentTarget, e.lastOffset = n.from ? H(n.from, e) : e.offset, e.offset = e.lastOffset, e.startTime = e.timeStamp = t.timeStamp);
229
+ e._active || (this.reset(), this.computeInitial(), e._active = !0, e.target = t.target, e.currentTarget = t.currentTarget, e.lastOffset = n.from ? J(n.from, e) : e.offset, e.offset = e.lastOffset, e.startTime = e.timeStamp = t.timeStamp);
230
230
  }
231
231
  computeValues(t) {
232
232
  const e = this.state;
@@ -244,38 +244,38 @@ class pe {
244
244
  } = this;
245
245
  e.args = this.args;
246
246
  let a = 0;
247
- if (t && (e.event = t, n.preventDefault && t.cancelable && e.event.preventDefault(), e.type = t.type, s.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, s.locked = !!document.pointerLockElement, Object.assign(s, le(t)), s.down = s.pressed = s.buttons % 2 === 1 || s.touches > 0, a = t.timeStamp - e.timeStamp, e.timeStamp = t.timeStamp, e.elapsedTime = e.timeStamp - e.startTime), e._active) {
248
- const f = e._delta.map(Math.abs);
249
- E.addTo(e._distance, f);
247
+ if (t && (e.event = t, n.preventDefault && t.cancelable && e.event.preventDefault(), e.type = t.type, s.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, s.locked = !!document.pointerLockElement, Object.assign(s, pe(t)), s.down = s.pressed = s.buttons % 2 === 1 || s.touches > 0, a = t.timeStamp - e.timeStamp, e.timeStamp = t.timeStamp, e.elapsedTime = e.timeStamp - e.startTime), e._active) {
248
+ const T = e._delta.map(Math.abs);
249
+ x.addTo(e._distance, T);
250
250
  }
251
251
  this.axisIntent && this.axisIntent(t);
252
- const [o, u] = e._movement, [d, g] = n.threshold, {
253
- _step: l,
254
- values: b
252
+ const [o, l] = e._movement, [c, h] = n.threshold, {
253
+ _step: f,
254
+ values: y
255
255
  } = e;
256
- if (n.hasCustomTransform ? (l[0] === !1 && (l[0] = Math.abs(o) >= d && b[0]), l[1] === !1 && (l[1] = Math.abs(u) >= g && b[1])) : (l[0] === !1 && (l[0] = Math.abs(o) >= d && Math.sign(o) * d), l[1] === !1 && (l[1] = Math.abs(u) >= g && Math.sign(u) * g)), e.intentional = l[0] !== !1 || l[1] !== !1, !e.intentional) return;
257
- const y = [0, 0];
256
+ if (n.hasCustomTransform ? (f[0] === !1 && (f[0] = Math.abs(o) >= c && y[0]), f[1] === !1 && (f[1] = Math.abs(l) >= h && y[1])) : (f[0] === !1 && (f[0] = Math.abs(o) >= c && Math.sign(o) * c), f[1] === !1 && (f[1] = Math.abs(l) >= h && Math.sign(l) * h)), e.intentional = f[0] !== !1 || f[1] !== !1, !e.intentional) return;
257
+ const p = [0, 0];
258
258
  if (n.hasCustomTransform) {
259
- const [f, z] = b;
260
- y[0] = l[0] !== !1 ? f - l[0] : 0, y[1] = l[1] !== !1 ? z - l[1] : 0;
259
+ const [T, G] = y;
260
+ p[0] = f[0] !== !1 ? T - f[0] : 0, p[1] = f[1] !== !1 ? G - f[1] : 0;
261
261
  } else
262
- y[0] = l[0] !== !1 ? o - l[0] : 0, y[1] = l[1] !== !1 ? u - l[1] : 0;
263
- this.restrictToAxis && !e._blocked && this.restrictToAxis(y);
264
- const P = e.offset, T = e._active && !e._blocked || e.active;
265
- T && (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 = H(n.bounds, e)), this.setup && this.setup()), e.movement = y, this.computeOffset()));
266
- const [k, S] = e.offset, [[A, I], [D, $]] = e._bounds;
267
- e.overflow = [k < A ? -1 : k > I ? 1 : 0, S < D ? -1 : S > $ ? 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
- const j = e._active ? n.rubberband || [0, 0] : [0, 0];
269
- if (e.offset = Qt(e._bounds, e.offset, j), e.delta = E.sub(e.offset, P), this.computeMovement(), T && (!e.last || a > he)) {
270
- e.delta = E.sub(e.offset, P);
271
- const f = e.delta.map(Math.abs);
272
- E.addTo(e.distance, f), e.direction = e.delta.map(Math.sign), e._direction = e._delta.map(Math.sign), !e.first && a > 0 && (e.velocity = [f[0] / a, f[1] / a], e.timeDelta = a);
262
+ p[0] = f[0] !== !1 ? o - f[0] : 0, p[1] = f[1] !== !1 ? l - f[1] : 0;
263
+ this.restrictToAxis && !e._blocked && this.restrictToAxis(p);
264
+ const w = e.offset, E = e._active && !e._blocked || e.active;
265
+ E && (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 = J(n.bounds, e)), this.setup && this.setup()), e.movement = p, this.computeOffset()));
266
+ const [R, k] = e.offset, [[$, D], [M, C]] = e._bounds;
267
+ e.overflow = [R < $ ? -1 : R > D ? 1 : 0, k < M ? -1 : k > C ? 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
+ const P = e._active ? n.rubberband || [0, 0] : [0, 0];
269
+ if (e.offset = re(e._bounds, e.offset, P), e.delta = x.sub(e.offset, w), this.computeMovement(), E && (!e.last || a > ve)) {
270
+ e.delta = x.sub(e.offset, w);
271
+ const T = e.delta.map(Math.abs);
272
+ x.addTo(e.distance, T), e.direction = e.delta.map(Math.sign), e._direction = e._delta.map(Math.sign), !e.first && a > 0 && (e.velocity = [T[0] / a, T[1] / a], e.timeDelta = a);
273
273
  }
274
274
  }
275
275
  emit() {
276
276
  const t = this.state, e = this.shared, n = this.config;
277
277
  if (t._active || this.clean(), (t._blocked || !t.intentional) && !t._force && !n.triggerAllEvents) return;
278
- const s = this.handler(m(m(m({}, e), t), {}, {
278
+ const s = this.handler(v(v(v({}, e), t), {}, {
279
279
  [this.aliasKey]: t.values
280
280
  }));
281
281
  s !== void 0 && (t.memo = s);
@@ -284,16 +284,16 @@ class pe {
284
284
  this.eventStore.clean(), this.timeoutStore.clean();
285
285
  }
286
286
  }
287
- function ge([r, t], e) {
287
+ function be([r, t], e) {
288
288
  const n = Math.abs(r), s = Math.abs(t);
289
289
  if (n > s && n > e)
290
290
  return "x";
291
291
  if (s > n && s > e)
292
292
  return "y";
293
293
  }
294
- class me extends pe {
294
+ class _e extends ye {
295
295
  constructor(...t) {
296
- super(...t), C(this, "aliasKey", "xy");
296
+ super(...t), S(this, "aliasKey", "xy");
297
297
  }
298
298
  reset() {
299
299
  super.reset(), this.state.axis = void 0;
@@ -302,16 +302,16 @@ class me extends pe {
302
302
  this.state.offset = [0, 0], this.state.lastOffset = [0, 0];
303
303
  }
304
304
  computeOffset() {
305
- this.state.offset = E.add(this.state.lastOffset, this.state.movement);
305
+ this.state.offset = x.add(this.state.lastOffset, this.state.movement);
306
306
  }
307
307
  computeMovement() {
308
- this.state.movement = E.sub(this.state.offset, this.state.lastOffset);
308
+ this.state.movement = x.sub(this.state.offset, this.state.lastOffset);
309
309
  }
310
310
  axisIntent(t) {
311
311
  const e = this.state, n = this.config;
312
312
  if (!e.axis && t) {
313
- const s = typeof n.axisThreshold == "object" ? n.axisThreshold[Ot(t)] : n.axisThreshold;
314
- e.axis = ge(e._movement, s);
313
+ const s = typeof n.axisThreshold == "object" ? n.axisThreshold[Rt(t)] : n.axisThreshold;
314
+ e.axis = be(e._movement, s);
315
315
  }
316
316
  e._blocked = (n.lockDirection || !!n.axis) && !e.axis || !!n.axis && n.axis !== e.axis;
317
317
  }
@@ -327,12 +327,12 @@ class me extends pe {
327
327
  }
328
328
  }
329
329
  }
330
- const Tt = (r) => r, St = 0.15, ct = {
330
+ const kt = (r) => r, Dt = 0.15, ut = {
331
331
  enabled(r = !0) {
332
332
  return r;
333
333
  },
334
334
  eventOptions(r, t, e) {
335
- return m(m({}, e.shared.eventOptions), r);
335
+ return v(v({}, e.shared.eventOptions), r);
336
336
  },
337
337
  preventDefault(r = !1) {
338
338
  return r;
@@ -343,33 +343,33 @@ const Tt = (r) => r, St = 0.15, ct = {
343
343
  rubberband(r = 0) {
344
344
  switch (r) {
345
345
  case !0:
346
- return [St, St];
346
+ return [Dt, Dt];
347
347
  case !1:
348
348
  return [0, 0];
349
349
  default:
350
- return E.toVector(r);
350
+ return x.toVector(r);
351
351
  }
352
352
  },
353
353
  from(r) {
354
354
  if (typeof r == "function") return r;
355
- if (r != null) return E.toVector(r);
355
+ if (r != null) return x.toVector(r);
356
356
  },
357
357
  transform(r, t, e) {
358
358
  const n = r || e.shared.transform;
359
359
  if (this.hasCustomTransform = !!n, process.env.NODE_ENV === "development") {
360
- const s = n || Tt;
360
+ const s = n || kt;
361
361
  return (a) => {
362
362
  const o = s(a);
363
363
  return (!isFinite(o[0]) || !isFinite(o[1])) && console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${o[0]},${[1]}]`), o;
364
364
  };
365
365
  }
366
- return n || Tt;
366
+ return n || kt;
367
367
  },
368
368
  threshold(r) {
369
- return E.toVector(r, 0);
369
+ return x.toVector(r, 0);
370
370
  }
371
371
  };
372
- process.env.NODE_ENV === "development" && Object.assign(ct, {
372
+ process.env.NODE_ENV === "development" && Object.assign(ut, {
373
373
  domTarget(r) {
374
374
  if (r !== void 0)
375
375
  throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
@@ -386,18 +386,18 @@ process.env.NODE_ENV === "development" && Object.assign(ct, {
386
386
  return NaN;
387
387
  }
388
388
  });
389
- const ve = 0, K = m(m({}, ct), {}, {
389
+ const we = 0, F = v(v({}, ut), {}, {
390
390
  axis(r, t, {
391
391
  axis: e
392
392
  }) {
393
393
  if (this.lockDirection = e === "lock", !this.lockDirection) return e;
394
394
  },
395
- axisThreshold(r = ve) {
395
+ axisThreshold(r = we) {
396
396
  return r;
397
397
  },
398
398
  bounds(r = {}) {
399
399
  if (typeof r == "function")
400
- return (a) => K.bounds(r(a));
400
+ return (a) => F.bounds(r(a));
401
401
  if ("current" in r)
402
402
  return () => r.current;
403
403
  if (typeof HTMLElement == "function" && r instanceof HTMLElement)
@@ -410,15 +410,15 @@ const ve = 0, K = m(m({}, ct), {}, {
410
410
  } = r;
411
411
  return [[t, e], [n, s]];
412
412
  }
413
- }), It = {
413
+ }), Ct = {
414
414
  ArrowRight: (r, t = 1) => [r * t, 0],
415
415
  ArrowLeft: (r, t = 1) => [-1 * r * t, 0],
416
416
  ArrowUp: (r, t = 1) => [0, -1 * r * t],
417
417
  ArrowDown: (r, t = 1) => [0, r * t]
418
418
  };
419
- class ye extends me {
419
+ class xe extends _e {
420
420
  constructor(...t) {
421
- super(...t), C(this, "ingKey", "dragging");
421
+ super(...t), S(this, "ingKey", "dragging");
422
422
  }
423
423
  reset() {
424
424
  super.reset();
@@ -434,7 +434,7 @@ class ye extends me {
434
434
  top: e.top - n.top + t.offset[1],
435
435
  bottom: e.bottom - n.bottom + t.offset[1]
436
436
  };
437
- t._bounds = K.bounds(s);
437
+ t._bounds = F.bounds(s);
438
438
  }
439
439
  }
440
440
  cancel() {
@@ -453,7 +453,7 @@ class ye extends me {
453
453
  const e = this.config, n = this.state;
454
454
  if (t.buttons != null && (Array.isArray(e.pointerButtons) ? !e.pointerButtons.includes(t.buttons) : e.pointerButtons !== -1 && e.pointerButtons !== t.buttons)) return;
455
455
  const s = this.ctrl.setEventIds(t);
456
- e.pointerCapture && t.target.setPointerCapture(t.pointerId), !(s && s.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId = st(t), n._pointerActive = !0, this.computeValues(wt(t)), this.computeInitial(), e.preventScrollAxis && Ot(t) !== "mouse" ? (n._active = !1, this.setupScrollPrevention(t)) : e.delay > 0 ? (this.setupDelayTrigger(t), e.triggerAllEvents && (this.compute(t), this.emit())) : this.startPointerDrag(t));
456
+ e.pointerCapture && t.target.setPointerCapture(t.pointerId), !(s && s.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId = ot(t), n._pointerActive = !0, this.computeValues(Et(t)), this.computeInitial(), e.preventScrollAxis && Rt(t) !== "mouse" ? (n._active = !1, this.setupScrollPrevention(t)) : e.delay > 0 ? (this.setupDelayTrigger(t), e.triggerAllEvents && (this.compute(t), this.emit())) : this.startPointerDrag(t));
457
457
  }
458
458
  startPointerDrag(t) {
459
459
  const e = this.state;
@@ -462,10 +462,10 @@ class ye extends me {
462
462
  pointerMove(t) {
463
463
  const e = this.state, n = this.config;
464
464
  if (!e._pointerActive) return;
465
- const s = st(t);
465
+ const s = ot(t);
466
466
  if (e._pointerId !== void 0 && s !== e._pointerId) return;
467
- const a = wt(t);
468
- if (document.pointerLockElement === t.target ? e._delta = [t.movementX, t.movementY] : (e._delta = E.sub(a, e._values), this.computeValues(a)), E.addTo(e._movement, e._delta), this.compute(t), e._delayed && e.intentional) {
467
+ const a = Et(t);
468
+ if (document.pointerLockElement === t.target ? e._delta = [t.movementX, t.movementY] : (e._delta = x.sub(a, e._values), this.computeValues(a)), x.addTo(e._movement, e._delta), this.compute(t), e._delayed && e.intentional) {
469
469
  this.timeoutStore.remove("dragDelay"), e.active = !1, this.startPointerDrag(t);
470
470
  return;
471
471
  }
@@ -491,17 +491,17 @@ class ye extends me {
491
491
  }
492
492
  const e = this.state, n = this.config;
493
493
  if (!e._active || !e._pointerActive) return;
494
- const s = st(t);
494
+ const s = ot(t);
495
495
  if (e._pointerId !== void 0 && s !== e._pointerId) return;
496
496
  this.state._pointerActive = !1, this.setActive(), this.compute(t);
497
497
  const [a, o] = e._distance;
498
498
  if (e.tap = a <= n.tapsThreshold && o <= n.tapsThreshold, e.tap && n.filterTaps)
499
499
  e._force = !0;
500
500
  else {
501
- const [u, d] = e._delta, [g, l] = e._movement, [b, y] = n.swipe.velocity, [P, T] = n.swipe.distance, k = n.swipe.duration;
502
- if (e.elapsedTime < k) {
503
- const S = Math.abs(u / e.timeDelta), A = Math.abs(d / e.timeDelta);
504
- S > b && Math.abs(g) > P && (e.swipe[0] = Math.sign(u)), A > y && Math.abs(l) > T && (e.swipe[1] = Math.sign(d));
501
+ const [l, c] = e._delta, [h, f] = e._movement, [y, p] = n.swipe.velocity, [w, E] = n.swipe.distance, R = n.swipe.duration;
502
+ if (e.elapsedTime < R) {
503
+ const k = Math.abs(l / e.timeDelta), $ = Math.abs(c / e.timeDelta);
504
+ k > y && Math.abs(h) > w && (e.swipe[0] = Math.sign(l)), $ > p && Math.abs(f) > E && (e.swipe[1] = Math.sign(c));
505
505
  }
506
506
  }
507
507
  this.emit();
@@ -528,7 +528,7 @@ class ye extends me {
528
528
  this.state._preventScroll && t.cancelable && t.preventDefault();
529
529
  }
530
530
  setupScrollPrevention(t) {
531
- this.state._preventScroll = !1, be(t);
531
+ this.state._preventScroll = !1, Te(t);
532
532
  const e = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), {
533
533
  passive: !1
534
534
  });
@@ -540,14 +540,14 @@ class ye extends me {
540
540
  }, this.config.delay);
541
541
  }
542
542
  keyDown(t) {
543
- const e = It[t.key];
543
+ const e = Ct[t.key];
544
544
  if (e) {
545
545
  const n = this.state, s = t.shiftKey ? 10 : t.altKey ? 0.1 : 1;
546
- this.start(t), n._delta = e(this.config.keyboardDisplacement, s), n._keyboardActive = !0, E.addTo(n._movement, n._delta), this.compute(t), this.emit();
546
+ this.start(t), n._delta = e(this.config.keyboardDisplacement, s), n._keyboardActive = !0, x.addTo(n._movement, n._delta), this.compute(t), this.emit();
547
547
  }
548
548
  }
549
549
  keyUp(t) {
550
- t.key in It && (this.state._keyboardActive = !1, this.setActive(), this.compute(t), this.emit());
550
+ t.key in Ct && (this.state._keyboardActive = !1, this.setActive(), this.compute(t), this.emit());
551
551
  }
552
552
  bind(t) {
553
553
  const e = this.config.device;
@@ -557,41 +557,41 @@ class ye extends me {
557
557
  });
558
558
  }
559
559
  }
560
- function be(r) {
560
+ function Te(r) {
561
561
  "persist" in r && typeof r.persist == "function" && r.persist();
562
562
  }
563
- const G = typeof window < "u" && window.document && window.document.createElement;
564
- function Nt() {
565
- return G && "ontouchstart" in window;
563
+ const W = typeof window < "u" && window.document && window.document.createElement;
564
+ function Lt() {
565
+ return W && "ontouchstart" in window;
566
566
  }
567
- function _e() {
568
- return Nt() || G && window.navigator.maxTouchPoints > 1;
567
+ function Ie() {
568
+ return Lt() || W && window.navigator.maxTouchPoints > 1;
569
569
  }
570
- function xe() {
571
- return G && "onpointerdown" in window;
570
+ function Ee() {
571
+ return W && "onpointerdown" in window;
572
572
  }
573
- function we() {
574
- return G && "exitPointerLock" in window.document;
573
+ function Se() {
574
+ return W && "exitPointerLock" in window.document;
575
575
  }
576
- function Ee() {
576
+ function ke() {
577
577
  try {
578
578
  return "constructor" in GestureEvent;
579
579
  } catch {
580
580
  return !1;
581
581
  }
582
582
  }
583
- const O = {
584
- isBrowser: G,
585
- gesture: Ee(),
586
- touch: Nt(),
587
- touchscreen: _e(),
588
- pointer: xe(),
589
- pointerLock: we()
590
- }, Te = 250, Se = 180, Ie = 0.5, ke = 50, Ce = 250, De = 10, kt = {
583
+ const A = {
584
+ isBrowser: W,
585
+ gesture: ke(),
586
+ touch: Lt(),
587
+ touchscreen: Ie(),
588
+ pointer: Ee(),
589
+ pointerLock: Se()
590
+ }, De = 250, Ce = 180, Ae = 0.5, $e = 50, Pe = 250, Oe = 10, At = {
591
591
  mouse: 0,
592
592
  touch: 0,
593
593
  pen: 8
594
- }, Mt = m(m({}, K), {}, {
594
+ }, Vt = v(v({}, F), {}, {
595
595
  device(r, t, {
596
596
  pointer: {
597
597
  touch: e = !1,
@@ -599,12 +599,12 @@ const O = {
599
599
  mouse: s = !1
600
600
  } = {}
601
601
  }) {
602
- return this.pointerLock = n && O.pointerLock, O.touch && e ? "touch" : this.pointerLock ? "mouse" : O.pointer && !s ? "pointer" : O.touch ? "touch" : "mouse";
602
+ return this.pointerLock = n && A.pointerLock, A.touch && e ? "touch" : this.pointerLock ? "mouse" : A.pointer && !s ? "pointer" : A.touch ? "touch" : "mouse";
603
603
  },
604
604
  preventScrollAxis(r, t, {
605
605
  preventScroll: e
606
606
  }) {
607
- if (this.preventScrollDelay = typeof e == "number" ? e : e || e === void 0 && r ? Te : void 0, !(!O.touchscreen || e === !1))
607
+ if (this.preventScrollDelay = typeof e == "number" ? e : e || e === void 0 && r ? De : void 0, !(!A.touchscreen || e === !1))
608
608
  return r || (e !== void 0 ? "y" : void 0);
609
609
  },
610
610
  pointerCapture(r, t, {
@@ -621,24 +621,24 @@ const O = {
621
621
  tapsThreshold: n = 3,
622
622
  axis: s = void 0
623
623
  }) {
624
- const a = E.toVector(r, e ? n : s ? 1 : 0);
624
+ const a = x.toVector(r, e ? n : s ? 1 : 0);
625
625
  return this.filterTaps = e, this.tapsThreshold = n, a;
626
626
  },
627
627
  swipe({
628
- velocity: r = Ie,
629
- distance: t = ke,
630
- duration: e = Ce
628
+ velocity: r = Ae,
629
+ distance: t = $e,
630
+ duration: e = Pe
631
631
  } = {}) {
632
632
  return {
633
- velocity: this.transform(E.toVector(r)),
634
- distance: this.transform(E.toVector(t)),
633
+ velocity: this.transform(x.toVector(r)),
634
+ distance: this.transform(x.toVector(t)),
635
635
  duration: e
636
636
  };
637
637
  },
638
638
  delay(r = 0) {
639
639
  switch (r) {
640
640
  case !0:
641
- return Se;
641
+ return Ce;
642
642
  case !1:
643
643
  return 0;
644
644
  default:
@@ -646,13 +646,13 @@ const O = {
646
646
  }
647
647
  },
648
648
  axisThreshold(r) {
649
- return r ? m(m({}, kt), r) : kt;
649
+ return r ? v(v({}, At), r) : At;
650
650
  },
651
- keyboardDisplacement(r = De) {
651
+ keyboardDisplacement(r = Oe) {
652
652
  return r;
653
653
  }
654
654
  });
655
- process.env.NODE_ENV === "development" && Object.assign(Mt, {
655
+ process.env.NODE_ENV === "development" && Object.assign(Vt, {
656
656
  useTouch(r) {
657
657
  if (r !== void 0)
658
658
  throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");
@@ -679,18 +679,18 @@ process.env.NODE_ENV === "development" && Object.assign(Mt, {
679
679
  return NaN;
680
680
  }
681
681
  });
682
- m(m({}, ct), {}, {
682
+ v(v({}, ut), {}, {
683
683
  device(r, t, {
684
684
  shared: e,
685
685
  pointer: {
686
686
  touch: n = !1
687
687
  } = {}
688
688
  }) {
689
- if (e.target && !O.touch && O.gesture) return "gesture";
690
- if (O.touch && n) return "touch";
691
- if (O.touchscreen) {
692
- if (O.pointer) return "pointer";
693
- if (O.touch) return "touch";
689
+ if (e.target && !A.touch && A.gesture) return "gesture";
690
+ if (A.touch && n) return "touch";
691
+ if (A.touchscreen) {
692
+ if (A.pointer) return "pointer";
693
+ if (A.touch) return "touch";
694
694
  }
695
695
  },
696
696
  bounds(r, t, {
@@ -698,22 +698,22 @@ m(m({}, ct), {}, {
698
698
  angleBounds: n = {}
699
699
  }) {
700
700
  const s = (o) => {
701
- const u = Et(H(e, o), {
701
+ const l = St(J(e, o), {
702
702
  min: -1 / 0,
703
703
  max: 1 / 0
704
704
  });
705
- return [u.min, u.max];
705
+ return [l.min, l.max];
706
706
  }, a = (o) => {
707
- const u = Et(H(n, o), {
707
+ const l = St(J(n, o), {
708
708
  min: -1 / 0,
709
709
  max: 1 / 0
710
710
  });
711
- return [u.min, u.max];
711
+ return [l.min, l.max];
712
712
  };
713
713
  return typeof e != "function" && typeof n != "function" ? [s(), a()] : (o) => [s(o), a(o)];
714
714
  },
715
715
  threshold(r, t, e) {
716
- return this.lockDirection = e.axis === "lock", E.toVector(r, this.lockDirection ? [0.1, 3] : 0);
716
+ return this.lockDirection = e.axis === "lock", x.toVector(r, this.lockDirection ? [0.1, 3] : 0);
717
717
  },
718
718
  modifierKey(r) {
719
719
  return r === void 0 ? "ctrlKey" : r;
@@ -722,31 +722,31 @@ m(m({}, ct), {}, {
722
722
  return r;
723
723
  }
724
724
  });
725
- m(m({}, K), {}, {
725
+ v(v({}, F), {}, {
726
726
  mouseOnly: (r = !0) => r
727
727
  });
728
- m(m({}, K), {}, {
728
+ v(v({}, F), {}, {
729
729
  mouseOnly: (r = !0) => r
730
730
  });
731
- const Rt = /* @__PURE__ */ new Map(), at = /* @__PURE__ */ new Map();
732
- function $e(r) {
733
- Rt.set(r.key, r.engine), at.set(r.key, r.resolver);
731
+ const jt = /* @__PURE__ */ new Map(), ct = /* @__PURE__ */ new Map();
732
+ function Ne(r) {
733
+ jt.set(r.key, r.engine), ct.set(r.key, r.resolver);
734
734
  }
735
- const Pe = {
735
+ const Re = {
736
736
  key: "drag",
737
- engine: ye,
738
- resolver: Mt
737
+ engine: xe,
738
+ resolver: Vt
739
739
  };
740
- function Oe(r, t) {
740
+ function Me(r, t) {
741
741
  if (r == null) return {};
742
742
  var e = {}, n = Object.keys(r), s, a;
743
743
  for (a = 0; a < n.length; a++)
744
744
  s = n[a], !(t.indexOf(s) >= 0) && (e[s] = r[s]);
745
745
  return e;
746
746
  }
747
- function Ae(r, t) {
747
+ function Le(r, t) {
748
748
  if (r == null) return {};
749
- var e = Oe(r, t), n, s;
749
+ var e = Me(r, t), n, s;
750
750
  if (Object.getOwnPropertySymbols) {
751
751
  var a = Object.getOwnPropertySymbols(r);
752
752
  for (s = 0; s < a.length; s++)
@@ -754,7 +754,7 @@ function Ae(r, t) {
754
754
  }
755
755
  return e;
756
756
  }
757
- const Ne = {
757
+ const Ve = {
758
758
  target(r) {
759
759
  if (r)
760
760
  return () => "current" in r ? r.current : r;
@@ -762,7 +762,7 @@ const Ne = {
762
762
  enabled(r = !0) {
763
763
  return r;
764
764
  },
765
- window(r = O.isBrowser ? window : void 0) {
765
+ window(r = A.isBrowser ? window : void 0) {
766
766
  return r;
767
767
  },
768
768
  eventOptions({
@@ -777,8 +777,8 @@ const Ne = {
777
777
  transform(r) {
778
778
  return r;
779
779
  }
780
- }, Me = ["target", "eventOptions", "window", "enabled", "transform"];
781
- function Y(r = {}, t) {
780
+ }, je = ["target", "eventOptions", "window", "enabled", "transform"];
781
+ function q(r = {}, t) {
782
782
  const e = {};
783
783
  for (const [n, s] of Object.entries(t))
784
784
  switch (typeof s) {
@@ -790,7 +790,7 @@ function Y(r = {}, t) {
790
790
  e[n] = s.call(e, r[n], n, r);
791
791
  break;
792
792
  case "object":
793
- e[n] = Y(r[n], s);
793
+ e[n] = q(r[n], s);
794
794
  break;
795
795
  case "boolean":
796
796
  s && (e[n] = r[n]);
@@ -798,59 +798,59 @@ function Y(r = {}, t) {
798
798
  }
799
799
  return e;
800
800
  }
801
- function Re(r, t, e = {}) {
801
+ function Be(r, t, e = {}) {
802
802
  const n = r, {
803
803
  target: s,
804
804
  eventOptions: a,
805
805
  window: o,
806
- enabled: u,
807
- transform: d
808
- } = n, g = Ae(n, Me);
809
- if (e.shared = Y({
806
+ enabled: l,
807
+ transform: c
808
+ } = n, h = Le(n, je);
809
+ if (e.shared = q({
810
810
  target: s,
811
811
  eventOptions: a,
812
812
  window: o,
813
- enabled: u,
814
- transform: d
815
- }, Ne), t) {
816
- const l = at.get(t);
817
- e[t] = Y(m({
813
+ enabled: l,
814
+ transform: c
815
+ }, Ve), t) {
816
+ const f = ct.get(t);
817
+ e[t] = q(v({
818
818
  shared: e.shared
819
- }, g), l);
819
+ }, h), f);
820
820
  } else
821
- for (const l in g) {
822
- const b = at.get(l);
823
- if (b)
824
- e[l] = Y(m({
821
+ for (const f in h) {
822
+ const y = ct.get(f);
823
+ if (y)
824
+ e[f] = q(v({
825
825
  shared: e.shared
826
- }, g[l]), b);
827
- else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(l)) {
828
- if (l === "domTarget")
826
+ }, h[f]), y);
827
+ else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(f)) {
828
+ if (f === "domTarget")
829
829
  throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
830
- console.warn(`[@use-gesture]: Unknown config key \`${l}\` was used. Please read the documentation for further information.`);
830
+ console.warn(`[@use-gesture]: Unknown config key \`${f}\` was used. Please read the documentation for further information.`);
831
831
  }
832
832
  }
833
833
  return e;
834
834
  }
835
- class Vt {
835
+ class Bt {
836
836
  constructor(t, e) {
837
- C(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = t, this._gestureKey = e;
837
+ S(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = t, this._gestureKey = e;
838
838
  }
839
839
  add(t, e, n, s, a) {
840
- const o = this._listeners, u = oe(e, n), d = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, g = m(m({}, d), a);
841
- t.addEventListener(u, s, g);
842
- const l = () => {
843
- t.removeEventListener(u, s, g), o.delete(l);
840
+ const o = this._listeners, l = le(e, n), c = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, h = v(v({}, c), a);
841
+ t.addEventListener(l, s, h);
842
+ const f = () => {
843
+ t.removeEventListener(l, s, h), o.delete(f);
844
844
  };
845
- return o.add(l), l;
845
+ return o.add(f), f;
846
846
  }
847
847
  clean() {
848
848
  this._listeners.forEach((t) => t()), this._listeners.clear();
849
849
  }
850
850
  }
851
- class Ve {
851
+ class Ue {
852
852
  constructor() {
853
- C(this, "_timeouts", /* @__PURE__ */ new Map());
853
+ S(this, "_timeouts", /* @__PURE__ */ new Map());
854
854
  }
855
855
  add(t, e, n = 140, ...s) {
856
856
  this.remove(t), this._timeouts.set(t, window.setTimeout(e, n, ...s));
@@ -863,20 +863,20 @@ class Ve {
863
863
  this._timeouts.forEach((t) => void window.clearTimeout(t)), this._timeouts.clear();
864
864
  }
865
865
  }
866
- class Le {
866
+ class Ke {
867
867
  constructor(t) {
868
- C(this, "gestures", /* @__PURE__ */ new Set()), C(this, "_targetEventStore", new Vt(this)), C(this, "gestureEventStores", {}), C(this, "gestureTimeoutStores", {}), C(this, "handlers", {}), C(this, "config", {}), C(this, "pointerIds", /* @__PURE__ */ new Set()), C(this, "touchIds", /* @__PURE__ */ new Set()), C(this, "state", {
868
+ S(this, "gestures", /* @__PURE__ */ new Set()), S(this, "_targetEventStore", new Bt(this)), S(this, "gestureEventStores", {}), S(this, "gestureTimeoutStores", {}), S(this, "handlers", {}), S(this, "config", {}), S(this, "pointerIds", /* @__PURE__ */ new Set()), S(this, "touchIds", /* @__PURE__ */ new Set()), S(this, "state", {
869
869
  shared: {
870
870
  shiftKey: !1,
871
871
  metaKey: !1,
872
872
  ctrlKey: !1,
873
873
  altKey: !1
874
874
  }
875
- }), je(this, t);
875
+ }), ze(this, t);
876
876
  }
877
877
  setEventIds(t) {
878
- if (X(t))
879
- return this.touchIds = new Set(ue(t)), this.touchIds;
878
+ if (Q(t))
879
+ return this.touchIds = new Set(he(t)), this.touchIds;
880
880
  if ("pointerId" in t)
881
881
  return t.type === "pointerup" || t.type === "pointercancel" ? this.pointerIds.delete(t.pointerId) : t.type === "pointerdown" && this.pointerIds.add(t.pointerId), this.pointerIds;
882
882
  }
@@ -884,7 +884,7 @@ class Le {
884
884
  this.handlers = t, this.nativeHandlers = e;
885
885
  }
886
886
  applyConfig(t, e) {
887
- this.config = Re(t, e, this.config);
887
+ this.config = Be(t, e, this.config);
888
888
  }
889
889
  clean() {
890
890
  this._targetEventStore.clean();
@@ -900,93 +900,112 @@ class Le {
900
900
  if (!(e.target && (s = e.target(), !s))) {
901
901
  if (e.enabled) {
902
902
  for (const o of this.gestures) {
903
- const u = this.config[o], d = Ct(n, u.eventOptions, !!s);
904
- if (u.enabled) {
905
- const g = Rt.get(o);
906
- new g(this, t, o).bind(d);
903
+ const l = this.config[o], c = $t(n, l.eventOptions, !!s);
904
+ if (l.enabled) {
905
+ const h = jt.get(o);
906
+ new h(this, t, o).bind(c);
907
907
  }
908
908
  }
909
- const a = Ct(n, e.eventOptions, !!s);
909
+ const a = $t(n, e.eventOptions, !!s);
910
910
  for (const o in this.nativeHandlers)
911
- a(o, "", (u) => this.nativeHandlers[o](m(m({}, this.state.shared), {}, {
912
- event: u,
911
+ a(o, "", (l) => this.nativeHandlers[o](v(v({}, this.state.shared), {}, {
912
+ event: l,
913
913
  args: t
914
914
  })), void 0, !0);
915
915
  }
916
916
  for (const a in n)
917
- n[a] = de(...n[a]);
917
+ n[a] = me(...n[a]);
918
918
  if (!s) return n;
919
919
  for (const a in n) {
920
920
  const {
921
921
  device: o,
922
- capture: u,
923
- passive: d
924
- } = ie(a);
922
+ capture: l,
923
+ passive: c
924
+ } = ue(a);
925
925
  this._targetEventStore.add(s, o, "", n[a], {
926
- capture: u,
927
- passive: d
926
+ capture: l,
927
+ passive: c
928
928
  });
929
929
  }
930
930
  }
931
931
  }
932
932
  }
933
- function L(r, t) {
934
- r.gestures.add(t), r.gestureEventStores[t] = new Vt(r, t), r.gestureTimeoutStores[t] = new Ve();
933
+ function K(r, t) {
934
+ r.gestures.add(t), r.gestureEventStores[t] = new Bt(r, t), r.gestureTimeoutStores[t] = new Ue();
935
935
  }
936
- function je(r, t) {
937
- t.drag && L(r, "drag"), t.wheel && L(r, "wheel"), t.scroll && L(r, "scroll"), t.move && L(r, "move"), t.pinch && L(r, "pinch"), t.hover && L(r, "hover");
936
+ function ze(r, t) {
937
+ t.drag && K(r, "drag"), t.wheel && K(r, "wheel"), t.scroll && K(r, "scroll"), t.move && K(r, "move"), t.pinch && K(r, "pinch"), t.hover && K(r, "hover");
938
938
  }
939
- const Ct = (r, t, e) => (n, s, a, o = {}, u = !1) => {
940
- var d, g;
941
- const l = (d = o.capture) !== null && d !== void 0 ? d : t.capture, b = (g = o.passive) !== null && g !== void 0 ? g : t.passive;
942
- let y = u ? n : ne(n, s, l);
943
- e && b && (y += "Passive"), r[y] = r[y] || [], r[y].push(a);
939
+ const $t = (r, t, e) => (n, s, a, o = {}, l = !1) => {
940
+ var c, h;
941
+ const f = (c = o.capture) !== null && c !== void 0 ? c : t.capture, y = (h = o.passive) !== null && h !== void 0 ? h : t.passive;
942
+ let p = l ? n : ae(n, s, f);
943
+ e && y && (p += "Passive"), r[p] = r[p] || [], r[p].push(a);
944
944
  };
945
- function Be(r, t = {}, e, n) {
946
- const s = rt.useMemo(() => new Le(r), []);
947
- if (s.applyHandlers(r, n), s.applyConfig(t, e), rt.useEffect(s.effect.bind(s)), rt.useEffect(() => s.clean.bind(s), []), t.target === void 0)
945
+ function Ge(r, t = {}, e, n) {
946
+ const s = st.useMemo(() => new Ke(r), []);
947
+ if (s.applyHandlers(r, n), s.applyConfig(t, e), st.useEffect(s.effect.bind(s)), st.useEffect(() => s.clean.bind(s), []), t.target === void 0)
948
948
  return s.bind.bind(s);
949
949
  }
950
- function Ue(r, t) {
951
- return $e(Pe), Be({
950
+ function Fe(r, t) {
951
+ return Ne(Re), Ge({
952
952
  drag: r
953
953
  }, t || {}, "drag");
954
954
  }
955
- const it = "RSC::Event";
956
- function Ke() {
957
- const r = w(null), t = w(null);
955
+ function We(r) {
956
+ const {
957
+ type: t,
958
+ actionType: e,
959
+ toIndex: n,
960
+ itemsLength: s,
961
+ withLoop: a,
962
+ scrollAmount: o,
963
+ totalAvailable: l
964
+ } = r;
965
+ let c = r.currentActive, h = r.fromValueRaw, f = !1, y = !1;
966
+ t === "next" && (c += 1), t === "prev" && (c = c === 0 ? s - 1 : c - 1), n !== void 0 && (c = n);
967
+ let p = 0;
968
+ t === "next" && (p = -(c * o), a && c === s && (c = 0, h = h + o * s, p = 0), !a && (Math.abs(p) >= l || c === s - 1) && (y = !0, p = -l)), t === "prev" && (p = -(c * o), c === s - 1 && (h = h - s * o), !a && p >= 0 && (f = !0, p = 0)), e === "resize" && (p = -(c * o));
969
+ const w = a ? c % s : c, E = a ? s + c % s : c;
970
+ return {
971
+ newActive: c,
972
+ fromValue: h,
973
+ toValue: p,
974
+ startReached: f,
975
+ endReached: y,
976
+ logicalIndex: w,
977
+ realTrackIndex: E
978
+ };
979
+ }
980
+ function X(r, t, e) {
981
+ return t === "x" ? `translate3d(calc(${r}px + var(--${e}-offset-modifier)), 0px, 0px)` : `translate3d(0px, calc(${r}px + var(--${e}-offset-modifier)), 0px)`;
982
+ }
983
+ function Ye() {
984
+ const r = _(
985
+ null
986
+ );
987
+ r.current === null && (r.current = /* @__PURE__ */ new Set());
988
+ const t = _(null);
958
989
  return t.current === null && (t.current = {
959
990
  useListenToCustomEvent(e) {
960
- U(() => {
961
- r.current || (r.current = document.createElement("div"));
962
- function n(s) {
963
- e(s.detail);
964
- }
965
- return r.current.addEventListener(it, n, !1), () => {
966
- var s;
967
- (s = r.current) == null || s.removeEventListener(
968
- it,
969
- n,
970
- !1
971
- );
991
+ z(() => {
992
+ const n = r.current;
993
+ return n.add(e), () => {
994
+ n.delete(e);
972
995
  };
973
996
  }, [e]);
974
997
  },
975
998
  emitEvent(e) {
976
- if (r.current) {
977
- const n = new CustomEvent(it, {
978
- detail: e
979
- });
980
- r.current.dispatchEvent(n);
981
- }
999
+ const n = r.current;
1000
+ !n || n.size === 0 || n.forEach((s) => s(e));
982
1001
  }
983
1002
  }), t.current;
984
1003
  }
985
- function Ge(r) {
1004
+ function He(r) {
986
1005
  let t = r.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm, "");
987
1006
  return t = t.replace(/[\n\t]+/g, " "), t = t.replace(/\s*([{}:;,])\s*/g, "$1"), t = t.replace(/\s+}/g, "}"), t = t.replace(/{\s+/g, "{"), t = t.replace(/\s+/g, " "), t.trim();
988
1007
  }
989
- function Xe({
1008
+ function tr({
990
1009
  init: r = !0,
991
1010
  items: t,
992
1011
  withLoop: e = !1,
@@ -994,280 +1013,308 @@ function Xe({
994
1013
  gutter: s = [{ breakpoint: 0, gutter: 0, startEndGutter: 0 }],
995
1014
  itemsPerSlide: a = [{ breakpoint: 0, itemsPerSlide: 1 }],
996
1015
  carouselAxis: o = "x",
997
- startingPosition: u = "start",
998
- enableGestures: d = !0,
999
- slideWhenDragThresholdIsReached: g = !0,
1000
- slideType: l = "item",
1001
- initialActiveItem: b = 0
1016
+ startingPosition: l = "start",
1017
+ enableGestures: c = !0,
1018
+ slideWhenDragThresholdIsReached: h = !0,
1019
+ slideType: f = "item",
1020
+ initialActiveItem: y = 0,
1021
+ renderWindow: p
1002
1022
  }) {
1003
- const [y, P] = Xt(!1), T = w(r), k = w(null), S = w(null), A = w(0), I = w(0), D = w(!e), $ = w(!1), j = w(0), f = w(0), z = w(t);
1004
- z.current = t;
1005
- const ut = w(e);
1006
- ut.current = e;
1007
- const lt = w(!1);
1008
- function ft(i) {
1023
+ const [w, E] = _t(!1), [, R] = _t(0), k = _(r), $ = _(null), D = _(null), M = _(0), C = _(0), P = _(!e), T = _(!1), G = _(0), b = _(0), lt = _(t);
1024
+ lt.current = t;
1025
+ const ft = _(e);
1026
+ ft.current = e;
1027
+ const dt = _(!1), V = _(null), O = _(null);
1028
+ function ht(i) {
1009
1029
  if (i === void 0) return 0;
1010
1030
  if (typeof i == "number")
1011
1031
  return t[i] ? i : (console.warn(
1012
1032
  `initialActiveItem: item at index ${i} doesn't exist.`
1013
1033
  ), 0);
1014
- const c = t.findIndex((h) => h.id === i);
1015
- return c < 0 ? (console.warn(`initialActiveItem: item with id "${i}" doesn't exist.`), 0) : c;
1034
+ const u = t.findIndex((m) => m.id === i);
1035
+ return u < 0 ? (console.warn(`initialActiveItem: item with id "${i}" doesn't exist.`), 0) : u;
1016
1036
  }
1017
- const W = Ht(), q = $t({
1037
+ const Y = Zt(), Z = Ot({
1018
1038
  value: 0,
1019
- ref: W,
1039
+ ref: Y,
1020
1040
  onChange({ value: i }) {
1021
- const c = o === "x" ? `translate3d(calc(${i.value}px + var(--${n}-offset-modifier)), 0px, 0px)` : `translate3d(0px, calc(${i.value}px + var(--${n}-offset-modifier)), 0px)`;
1022
- S.current.style.transform = c;
1041
+ D.current.style.transform = X(
1042
+ i.value,
1043
+ o,
1044
+ n
1045
+ );
1023
1046
  }
1024
- }), Lt = e ? t.length * 3 : t.length, { useListenToCustomEvent: dt, emitEvent: B } = Ke();
1025
- function ht() {
1026
- const { totalGutterCssVar: i } = pt();
1047
+ }), Ut = e ? t.length * 3 : t.length, { useListenToCustomEvent: pt, emitEvent: j } = Ye();
1048
+ function gt(i) {
1049
+ if (!i || i.length === 0) return null;
1050
+ let u = null, m = -1 / 0;
1051
+ for (const g of i)
1052
+ (g.media ? window.matchMedia(g.media).matches : window.innerWidth >= g.breakpoint) && g.breakpoint >= m && (u = g, m = g.breakpoint);
1053
+ return u;
1054
+ }
1055
+ function mt() {
1056
+ const { totalGutterCssVar: i } = vt();
1027
1057
  return i;
1028
1058
  }
1029
- function jt() {
1030
- if (k.current) {
1031
- const c = window.getComputedStyle(
1032
- k.current
1033
- ).getPropertyValue(`--${n}-items-per-slide`).trim();
1034
- return Number(c) || 1;
1035
- }
1036
- return 1;
1059
+ function Kt() {
1060
+ const i = gt(a);
1061
+ return (i == null ? void 0 : i.itemsPerSlide) || 1;
1037
1062
  }
1038
- function J(i) {
1039
- T.current && ($.current || R({
1063
+ function tt(i) {
1064
+ k.current && (T.current || B({
1040
1065
  type: "next",
1041
1066
  toIndex: i,
1042
1067
  actionType: "click"
1043
1068
  }));
1044
1069
  }
1045
- function Q(i) {
1046
- T.current && (D.current || R({
1070
+ function et(i) {
1071
+ k.current && (P.current || B({
1047
1072
  type: "prev",
1048
1073
  toIndex: i,
1049
1074
  actionType: "click"
1050
1075
  }));
1051
1076
  }
1052
- function R({
1077
+ function B({
1053
1078
  type: i,
1054
- shouldAnimate: c = !0,
1055
- toIndex: h,
1056
- actionType: v
1079
+ shouldAnimate: u = !0,
1080
+ toIndex: m,
1081
+ actionType: g
1057
1082
  }) {
1058
- var gt, mt;
1059
- const _ = !c;
1060
- D.current = !1, $.current = !1;
1061
- let p = q.value.get(), x = 0;
1062
- if (i === "next" && (f.current += 1), i === "prev" && (f.current === 0 ? f.current = t.length - 1 : f.current -= 1), h !== void 0 && (f.current = h), i === "next") {
1063
- const M = Z(
1064
- e ? I.current * (t.length * 2) : 0
1065
- );
1066
- x = -(f.current * I.current), e && f.current === t.length && (f.current = 0, p = p + I.current * t.length, x = 0), !e && (Math.abs(x) >= M || f.current === t.length - 1) && ($.current = !0, x = -M);
1067
- }
1068
- i === "prev" && (x = -(f.current * I.current), f.current === t.length - 1 && (p = p - t.length * I.current), !e && x >= 0 && (D.current = !0, x = 0)), A.current = x;
1069
- const N = e ? f.current % t.length : f.current, V = e ? t.length + f.current % t.length : f.current;
1070
- v === "resize" ? (x = -(f.current * I.current), B({
1083
+ var N, L;
1084
+ const I = !u;
1085
+ P.current = !1, T.current = !1;
1086
+ const d = We({
1087
+ type: i,
1088
+ actionType: g,
1089
+ toIndex: m,
1090
+ currentActive: b.current,
1091
+ itemsLength: t.length,
1092
+ withLoop: e,
1093
+ scrollAmount: C.current,
1094
+ totalAvailable: i === "next" ? rt(
1095
+ e ? C.current * (t.length * 2) : 0
1096
+ ) : 0,
1097
+ fromValueRaw: Z.value.get()
1098
+ });
1099
+ b.current = d.newActive, P.current = d.startReached, T.current = d.endReached, M.current = d.toValue, p !== void 0 && R((U) => U + 1), j(g === "resize" ? {
1071
1100
  eventName: "onResize",
1072
- sliceActionType: v,
1101
+ sliceActionType: g,
1073
1102
  slideDirection: i,
1074
1103
  currentItem: {
1075
- id: ((gt = t.at(N)) == null ? void 0 : gt.id) ?? "",
1076
- index: N,
1077
- trackIndex: V,
1078
- startReached: D.current,
1079
- endReached: $.current
1104
+ id: ((N = t.at(d.logicalIndex)) == null ? void 0 : N.id) ?? "",
1105
+ index: d.logicalIndex,
1106
+ trackIndex: d.realTrackIndex,
1107
+ startReached: P.current,
1108
+ endReached: T.current
1080
1109
  }
1081
- })) : B({
1110
+ } : {
1082
1111
  eventName: "onSlideStartChange",
1083
- sliceActionType: v,
1112
+ sliceActionType: g,
1084
1113
  slideDirection: i,
1085
1114
  nextItem: {
1086
- index: N,
1087
- id: ((mt = t.at(N)) == null ? void 0 : mt.id) ?? "",
1088
- trackIndex: V,
1089
- startReached: D.current,
1090
- endReached: $.current
1115
+ index: d.logicalIndex,
1116
+ id: ((L = t.at(d.logicalIndex)) == null ? void 0 : L.id) ?? "",
1117
+ trackIndex: d.realTrackIndex,
1118
+ startReached: P.current,
1119
+ endReached: T.current
1091
1120
  }
1092
- }), W.start({
1093
- immediate: _,
1094
- from: {
1095
- value: p
1096
- },
1097
- to: {
1098
- value: x
1121
+ }), Y.start({
1122
+ immediate: I,
1123
+ from: { value: d.fromValue },
1124
+ to: { value: d.toValue },
1125
+ onChange({ value: U }) {
1126
+ D.current.style.transform = X(
1127
+ U.value,
1128
+ o,
1129
+ n
1130
+ );
1099
1131
  },
1100
- onChange({ value: M }) {
1101
- const F = o === "x" ? `translate3d(calc(${M.value}px + var(--${n}-offset-modifier)), 0px, 0px)` : `translate3d(0px, calc(${M.value}px + var(--${n}-offset-modifier)), 0px)`;
1102
- S.current.style.transform = F;
1103
- },
1104
- onRest({ finished: M }) {
1105
- var F;
1106
- if (M) {
1107
- const vt = e ? f.current % t.length : f.current, Ft = e ? t.length + f.current % t.length : f.current;
1108
- B({
1132
+ onRest({ finished: U }) {
1133
+ var yt;
1134
+ if (U) {
1135
+ const bt = e ? b.current % t.length : b.current, Jt = e ? t.length + b.current % t.length : b.current;
1136
+ j({
1109
1137
  eventName: "onSlideChangeComplete",
1110
- sliceActionType: v,
1138
+ sliceActionType: g,
1111
1139
  slideDirection: i,
1112
1140
  currentItem: {
1113
- index: vt,
1114
- id: ((F = t.at(vt)) == null ? void 0 : F.id) ?? "",
1115
- trackIndex: Ft,
1116
- startReached: D.current,
1117
- endReached: $.current
1141
+ index: bt,
1142
+ id: ((yt = t.at(bt)) == null ? void 0 : yt.id) ?? "",
1143
+ trackIndex: Jt,
1144
+ startReached: P.current,
1145
+ endReached: T.current
1118
1146
  }
1119
1147
  });
1120
1148
  }
1121
1149
  }
1122
1150
  });
1123
1151
  }
1124
- function Bt() {
1125
- const i = S.current;
1126
- let c = 0;
1127
- return l === "item" ? c = i.children[0].getBoundingClientRect()[o === "x" ? "width" : "height"] + ht() : c = i.getBoundingClientRect()[o === "x" ? "width" : "height"] + ht(), c;
1128
- }
1129
- function Z(i) {
1130
- const c = S.current;
1131
- return c[o === "x" ? "scrollWidth" : "scrollHeight"] - c.getBoundingClientRect()[o === "x" ? "width" : "height"] - i;
1132
- }
1133
- function pt() {
1134
- let i = 0, c = 0;
1135
- if (k.current) {
1136
- const h = window.getComputedStyle(
1137
- k.current
1138
- ), v = h.getPropertyValue(`--${n}-start-end-gutter`).trim();
1139
- v.includes("px") && (i = Number(
1140
- v.replace("px", "")
1141
- ));
1142
- const _ = h.getPropertyValue(`--${n}-gutter`).trim();
1143
- _.includes("px") && (c = Number(_.replace("px", "")));
1144
- }
1145
- return { totalStartEndGutterCssVar: i, totalGutterCssVar: c };
1152
+ function zt() {
1153
+ const i = D.current;
1154
+ let u = 0;
1155
+ return f === "item" ? u = i.children[0].getBoundingClientRect()[o === "x" ? "width" : "height"] + mt() : u = i.getBoundingClientRect()[o === "x" ? "width" : "height"] + mt(), u;
1146
1156
  }
1147
- U(() => {
1148
- function i(_) {
1149
- const p = jt();
1150
- switch (_) {
1157
+ function rt(i) {
1158
+ const u = D.current;
1159
+ return u[o === "x" ? "scrollWidth" : "scrollHeight"] - u.getBoundingClientRect()[o === "x" ? "width" : "height"] - i;
1160
+ }
1161
+ function vt() {
1162
+ const i = gt(s);
1163
+ return {
1164
+ totalGutterCssVar: (i == null ? void 0 : i.gutter) || 0,
1165
+ totalStartEndGutterCssVar: ((i == null ? void 0 : i.startEndGutter) || 0) * 2
1166
+ };
1167
+ }
1168
+ z(() => {
1169
+ function i(I) {
1170
+ const d = Kt();
1171
+ switch (I) {
1151
1172
  case "start":
1152
1173
  return 0;
1153
1174
  case "middle-start":
1154
- return Math.floor((p - 1) * 0.25);
1175
+ return Math.floor((d - 1) * 0.25);
1155
1176
  case "center":
1156
- return Math.floor((p - 1) * 0.5);
1177
+ return Math.floor((d - 1) * 0.5);
1157
1178
  case "middle-end":
1158
- return Math.floor((p - 1) * 0.75);
1179
+ return Math.floor((d - 1) * 0.75);
1159
1180
  case "end":
1160
- return p - 1;
1181
+ return d - 1;
1161
1182
  default:
1162
1183
  return 0;
1163
1184
  }
1164
1185
  }
1165
- function c() {
1166
- I.current = Bt(), j.current = I.current / 4;
1167
- const { totalStartEndGutterCssVar: _ } = pt();
1168
- let p = 0;
1169
- e && (p = I.current * t.length), p -= I.current * i(u), p -= _ / 2, k.current.style.setProperty(
1186
+ function u() {
1187
+ C.current = zt(), G.current = C.current / 4;
1188
+ const { totalStartEndGutterCssVar: I } = vt();
1189
+ let d = 0;
1190
+ e && (d = C.current * t.length), d -= C.current * i(l), d -= I / 2, $.current.style.setProperty(
1170
1191
  `--${n}-offset-modifier`,
1171
- `${-p}px`
1192
+ `${-d}px`
1172
1193
  );
1173
1194
  }
1174
- function h(_) {
1175
- if (k.current && (c(), P(!0), _)) {
1176
- const p = ft(b), x = e ? t.length + p % t.length : p;
1177
- B({ eventName: "onInit", index: p, trackIndex: x });
1195
+ function m(I) {
1196
+ if ($.current && (u(), E(!0), I)) {
1197
+ const d = ht(y), N = e ? t.length + d % t.length : d;
1198
+ j({ eventName: "onInit", index: d, trackIndex: N });
1178
1199
  }
1179
1200
  }
1180
- function v() {
1181
- h(), R({
1201
+ function g() {
1202
+ m(), B({
1182
1203
  type: "resize",
1183
- toIndex: f.current,
1204
+ toIndex: b.current,
1184
1205
  shouldAnimate: !1,
1185
1206
  actionType: "resize"
1186
1207
  });
1187
1208
  }
1188
1209
  if (r)
1189
- return T.current = !0, lt.current ? v() : (h(!0), lt.current = !0), window.addEventListener("resize", v), () => {
1190
- window.removeEventListener("resize", v);
1210
+ return k.current = !0, dt.current ? g() : (m(!0), dt.current = !0), window.addEventListener("resize", g), () => {
1211
+ window.removeEventListener("resize", g);
1191
1212
  };
1192
- }, [r, n, o]), U(() => {
1193
- const i = ft(b);
1194
- r && i !== f.current && R({
1213
+ }, [r, n, o, e]), z(() => {
1214
+ const i = ht(y);
1215
+ r && i !== b.current && B({
1195
1216
  type: "next",
1196
1217
  toIndex: i,
1197
1218
  actionType: "resize",
1198
1219
  shouldAnimate: !1
1199
1220
  });
1200
- }, [r, b]);
1201
- const tt = d, Ut = Ue(
1221
+ }, [r, y]);
1222
+ const nt = c;
1223
+ function Gt() {
1224
+ if (O.current !== null && (cancelAnimationFrame(O.current), O.current = null), V.current) {
1225
+ const i = V.current;
1226
+ V.current = null, j(i);
1227
+ }
1228
+ }
1229
+ function Ft(i) {
1230
+ V.current = i, O.current === null && (O.current = requestAnimationFrame(() => {
1231
+ O.current = null;
1232
+ const u = V.current;
1233
+ V.current = null, u && j(u);
1234
+ }));
1235
+ }
1236
+ z(
1237
+ () => () => {
1238
+ O.current !== null && (cancelAnimationFrame(O.current), O.current = null), V.current = null;
1239
+ },
1240
+ []
1241
+ );
1242
+ const Wt = Fe(
1202
1243
  (i) => {
1203
- if (!T.current)
1244
+ if (!k.current)
1204
1245
  return;
1205
- const c = i.dragging, h = i.offset[o === "x" ? 0 : 1], v = i.movement[o === "x" ? 0 : 1], _ = v > j.current, p = v < -j.current, x = i.velocity;
1206
- c && (B({
1246
+ const u = i.dragging, m = i.offset[o === "x" ? 0 : 1], g = i.movement[o === "x" ? 0 : 1], I = g > G.current, d = g < -G.current, N = i.velocity;
1247
+ u && (Ft({
1207
1248
  ...i,
1208
1249
  eventName: "onDrag",
1209
1250
  slideActionType: "drag"
1210
- }), W.start({
1211
- value: h,
1251
+ }), Y.start({
1252
+ value: m,
1212
1253
  immediate: !0,
1213
1254
  config: {
1214
- velocity: x
1255
+ velocity: N
1215
1256
  },
1216
- onChange({ value: N }) {
1217
- const V = o === "x" ? `translate3d(calc(${N.value}px + var(--${n}-offset-modifier)), 0px, 0px)` : `translate3d(0px, calc(${N.value}px + var(--${n}-offset-modifier)), 0px)`;
1218
- S.current.style.transform = V;
1257
+ onChange({ value: L }) {
1258
+ D.current.style.transform = X(
1259
+ L.value,
1260
+ o,
1261
+ n
1262
+ );
1219
1263
  }
1220
- }), g && (_ || p) && i.cancel()), i.last && (_ ? (R({
1264
+ }), h && (I || d) && i.cancel()), i.last && (Gt(), I ? (B({
1221
1265
  actionType: "drag",
1222
1266
  type: "prev"
1223
- }), i.cancel()) : p ? (R({
1267
+ }), i.cancel()) : d ? (B({
1224
1268
  actionType: "drag",
1225
1269
  type: "next"
1226
- }), i.cancel()) : (W.start({
1227
- value: A.current,
1270
+ }), i.cancel()) : (Y.start({
1271
+ value: M.current,
1228
1272
  config: {
1229
- velocity: x
1273
+ velocity: N
1230
1274
  },
1231
- onChange({ value: N }) {
1232
- const V = o === "x" ? `translate3d(calc(${N.value}px + var(--${n}-offset-modifier)), 0px, 0px)` : `translate3d(0px, calc(${N.value}px + var(--${n}-offset-modifier)), 0px)`;
1233
- S.current.style.transform = V;
1275
+ onChange({ value: L }) {
1276
+ D.current.style.transform = X(
1277
+ L.value,
1278
+ o,
1279
+ n
1280
+ );
1234
1281
  }
1235
1282
  }), i.cancel()));
1236
1283
  },
1237
1284
  {
1238
- enabled: tt,
1285
+ enabled: nt,
1239
1286
  axis: o,
1240
1287
  rubberband: !e,
1241
1288
  ...e ? {} : {
1242
1289
  bounds: () => ({
1243
1290
  right: 0,
1244
- left: -Z(0),
1245
- top: -Z(0),
1291
+ left: -rt(0),
1292
+ top: -rt(0),
1246
1293
  bottom: 0
1247
1294
  })
1248
1295
  },
1249
- from: () => [q.value.get(), q.value.get()]
1296
+ from: () => [Z.value.get(), Z.value.get()]
1250
1297
  }
1251
- ), Kt = qt((i) => {
1252
- var p;
1253
- const c = z.current, v = ut.current ? c.length + f.current % c.length : f.current;
1254
- if (typeof i == "number") return v === i;
1255
- const _ = f.current % c.length;
1256
- return i === ((p = c[_]) == null ? void 0 : p.id);
1257
- }, []), Gt = nt(
1258
- () => Array.from({ length: t.length }, (i, c) => () => {
1259
- const h = e ? f.current % t.length : f.current;
1260
- return e ? c === (h + 1) % t.length : h + 1 >= t.length ? !1 : c === h + 1;
1298
+ ), Yt = te((i) => {
1299
+ var d;
1300
+ const u = lt.current, g = ft.current ? u.length + b.current % u.length : b.current;
1301
+ if (typeof i == "number") return g === i;
1302
+ const I = b.current % u.length;
1303
+ return i === ((d = u[I]) == null ? void 0 : d.id);
1304
+ }, []), Ht = it(
1305
+ () => Array.from({ length: t.length }, (i, u) => () => {
1306
+ const m = e ? b.current % t.length : b.current;
1307
+ return e ? u === (m + 1) % t.length : m + 1 >= t.length ? !1 : u === m + 1;
1261
1308
  }),
1262
1309
  [t.length, e]
1263
- ), zt = nt(
1264
- () => Array.from({ length: t.length }, (i, c) => () => {
1265
- const h = e ? f.current % t.length : f.current;
1266
- return e ? c === (h - 1 + t.length) % t.length : h - 1 < 0 ? !1 : c === h - 1;
1310
+ ), Xt = it(
1311
+ () => Array.from({ length: t.length }, (i, u) => () => {
1312
+ const m = e ? b.current % t.length : b.current;
1313
+ return e ? u === (m - 1 + t.length) % t.length : m - 1 < 0 ? !1 : u === m - 1;
1267
1314
  }),
1268
1315
  [t.length, e]
1269
- ), Wt = nt(
1270
- () => Ge(`
1316
+ ), qt = it(
1317
+ () => He(`
1271
1318
  [data-part-internal="${n}-Container"] {
1272
1319
  display: flex;
1273
1320
  width: 100%;
@@ -1280,14 +1327,14 @@ function Xe({
1280
1327
  --${n}-scroll-y-value: ${o === "y" ? `calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))` : "0px"};
1281
1328
  --${n}-gutter: 0px;
1282
1329
  --${n}-start-end-gutter: 0px;
1283
- touch-action: ${tt ? o === "x" ? "pan-y" : "pan-x" : "auto"};
1330
+ touch-action: ${nt ? o === "x" ? "pan-y" : "pan-x" : "auto"};
1284
1331
  }
1285
1332
  [data-part-internal="${n}-Track"] {
1286
1333
  display: flex;
1287
1334
  position: relative;
1288
1335
  --initial-offset-modifier: calc(calc(-100% - var(--${n}-gutter) + calc(var(--${n}-start-end-gutter) / 2 / ${t.length} * var(--${n}-items-per-slide)) + var(--${n}-start-end-gutter)) * ${t.length} / var(--${n}-items-per-slide));
1289
- left: ${e && o === "x" && !y ? "var(--initial-offset-modifier)" : "0px"};
1290
- top: ${e && o === "y" && !y ? "var(--initial-offset-modifier)" : "0px"};
1336
+ left: ${e && o === "x" && !w ? "var(--initial-offset-modifier)" : "0px"};
1337
+ top: ${e && o === "y" && !w ? "var(--initial-offset-modifier)" : "0px"};
1291
1338
  flex-direction: ${o === "x" ? "row" : "column"};
1292
1339
  width: 100%;
1293
1340
  height: 100%;
@@ -1298,7 +1345,7 @@ function Xe({
1298
1345
  display: flex;
1299
1346
  flex: 1 0 calc(100% / var(--${n}-items-per-slide) - calc(var(--${n}-gutter) * (var(--${n}-items-per-slide) - 1)) / var(--${n}-items-per-slide) - calc(var(--${n}-start-end-gutter) / var(--${n}-items-per-slide)));
1300
1347
  }
1301
- ${s && s.length > 0 ? s.slice().sort((i, c) => i.breakpoint - c.breakpoint).map(
1348
+ ${s && s.length > 0 ? s.slice().sort((i, u) => i.breakpoint - u.breakpoint).map(
1302
1349
  (i) => `
1303
1350
  @media ${i.media || `(min-width: ${i.breakpoint}px)`} {
1304
1351
  [data-part-internal="${n}-Container"] {
@@ -1308,7 +1355,7 @@ function Xe({
1308
1355
  }
1309
1356
  `
1310
1357
  ).join("") : ""}
1311
- ${a && a.length > 0 ? a.slice().sort((i, c) => i.breakpoint - c.breakpoint).map(
1358
+ ${a && a.length > 0 ? a.slice().sort((i, u) => i.breakpoint - u.breakpoint).map(
1312
1359
  (i) => `
1313
1360
  @media ${i.media || `(min-width: ${i.breakpoint}px)`} {
1314
1361
  [data-part-internal="${n}-Container"] {
@@ -1321,54 +1368,70 @@ function Xe({
1321
1368
  [
1322
1369
  n,
1323
1370
  o,
1324
- tt,
1371
+ nt,
1325
1372
  t.length,
1326
1373
  e,
1327
- y,
1374
+ w,
1328
1375
  s,
1329
1376
  a
1330
1377
  ]
1331
1378
  );
1332
1379
  return {
1333
- carouselFragment: /* @__PURE__ */ Yt(
1380
+ carouselFragment: /* @__PURE__ */ Qt(
1334
1381
  "div",
1335
1382
  {
1336
- ref: k,
1383
+ ref: $,
1337
1384
  className: "ReactSpringCarouselContainer",
1338
1385
  "data-part": "Container",
1339
1386
  "data-part-internal": `${n}-Container`,
1340
- ...Ut(),
1387
+ ...Wt(),
1341
1388
  children: [
1342
- /* @__PURE__ */ et("style", { dangerouslySetInnerHTML: { __html: Wt } }),
1343
- /* @__PURE__ */ et(
1389
+ /* @__PURE__ */ H("style", { dangerouslySetInnerHTML: { __html: qt } }),
1390
+ /* @__PURE__ */ H(
1344
1391
  "div",
1345
1392
  {
1346
- ref: S,
1393
+ ref: D,
1347
1394
  className: "ReactSpringCarouselTrack",
1348
1395
  "data-part": "Track",
1349
1396
  "data-part-internal": `${n}-Track`,
1350
1397
  onScroll: () => {
1351
- D.current = !1, $.current = !1;
1398
+ P.current = !1, T.current = !1;
1352
1399
  },
1353
- children: Array.from({ length: Lt }, (i, c) => {
1354
- const h = e ? c % t.length : c, v = t[h], _ = e && (c < t.length || c >= t.length * 2), p = Gt[h], x = zt[h];
1355
- return /* @__PURE__ */ et(
1400
+ children: Array.from({ length: Ut }, (i, u) => {
1401
+ const m = e ? u % t.length : u, g = t[m], I = e && (u < t.length || u >= t.length * 2);
1402
+ if (p !== void 0) {
1403
+ const L = e ? t.length + b.current % t.length : b.current;
1404
+ if (Math.abs(u - L) > p)
1405
+ return /* @__PURE__ */ H(
1406
+ "div",
1407
+ {
1408
+ className: "ReactSpringCarouselItem",
1409
+ "data-part": "Item",
1410
+ "data-part-internal": `${n}-Item`,
1411
+ "data-id": g.id,
1412
+ "aria-hidden": "true"
1413
+ },
1414
+ `${g.id}-${u}`
1415
+ );
1416
+ }
1417
+ const d = Ht[m], N = Xt[m];
1418
+ return /* @__PURE__ */ H(
1356
1419
  "div",
1357
1420
  {
1358
1421
  className: "ReactSpringCarouselItem",
1359
1422
  "data-part": "Item",
1360
1423
  "data-part-internal": `${n}-Item`,
1361
- "data-id": v.id,
1362
- children: typeof v.renderItem == "function" ? v.renderItem({
1363
- useListenToCustomEvent: dt,
1364
- index: c,
1365
- isClonedItem: _,
1366
- isActiveItem: Kt,
1367
- isNextItem: p,
1368
- isPrevItem: x
1369
- }) : v.renderItem
1424
+ "data-id": g.id,
1425
+ children: typeof g.renderItem == "function" ? g.renderItem({
1426
+ useListenToCustomEvent: pt,
1427
+ index: u,
1428
+ isClonedItem: I,
1429
+ isActiveItem: Yt,
1430
+ isNextItem: d,
1431
+ isPrevItem: N
1432
+ }) : g.renderItem
1370
1433
  },
1371
- `${v.id}-${c}`
1434
+ `${g.id}-${u}`
1372
1435
  );
1373
1436
  })
1374
1437
  }
@@ -1376,9 +1439,9 @@ function Xe({
1376
1439
  ]
1377
1440
  }
1378
1441
  ),
1379
- useListenToCustomEvent: dt,
1380
- slideToNextItem: () => J(),
1381
- slideToPrevItem: () => Q(),
1442
+ useListenToCustomEvent: pt,
1443
+ slideToNextItem: () => tt(),
1444
+ slideToPrevItem: () => et(),
1382
1445
  slideToItem: (i) => {
1383
1446
  if (typeof i == "number") {
1384
1447
  if (!t[i]) {
@@ -1387,98 +1450,98 @@ function Xe({
1387
1450
  );
1388
1451
  return;
1389
1452
  }
1390
- i > f.current ? J(i) : Q(i);
1453
+ i > b.current ? tt(i) : et(i);
1391
1454
  }
1392
1455
  if (typeof i == "string") {
1393
- const c = t.findIndex((h) => h.id === i);
1394
- if (c < 0) {
1456
+ const u = t.findIndex((m) => m.id === i);
1457
+ if (u < 0) {
1395
1458
  console.warn(
1396
1459
  `The item you're trying to slide doesn't exist. id: ${i}`
1397
1460
  );
1398
1461
  return;
1399
1462
  }
1400
- c > f.current ? J(c) : Q(c);
1463
+ u > b.current ? tt(u) : et(u);
1401
1464
  }
1402
1465
  }
1403
1466
  };
1404
1467
  }
1405
- function ze(r) {
1468
+ function Xe(r) {
1406
1469
  let t = 0;
1407
1470
  const e = getComputedStyle(r).getPropertyValue("gap");
1408
1471
  return e.includes("px") && (t = Number(e.replace("px", ""))), t;
1409
1472
  }
1410
- function Dt(r) {
1473
+ function Pt(r) {
1411
1474
  return r.scrollWidth - r.clientWidth;
1412
1475
  }
1413
- function ot(r) {
1414
- const t = r.children[0], e = ze(r);
1476
+ function at(r) {
1477
+ const t = r.children[0], e = Xe(r);
1415
1478
  return t.getBoundingClientRect().width + e;
1416
1479
  }
1417
- function qe({ container: r, onReach: t }) {
1418
- const e = w("start"), n = w(0), [, s] = $t(() => ({
1480
+ function er({ container: r, onReach: t }) {
1481
+ const e = _("start"), n = _(0), [, s] = Ot(() => ({
1419
1482
  x: 0
1420
1483
  }));
1421
- function a(u) {
1484
+ function a(l) {
1422
1485
  s.start({
1423
1486
  from: {
1424
1487
  x: r.current.scrollLeft
1425
1488
  },
1426
1489
  to: {
1427
- x: u
1490
+ x: l
1428
1491
  },
1429
- onChange({ value: d }) {
1430
- r.current && (r.current.scrollLeft = d.x);
1492
+ onChange({ value: c }) {
1493
+ r.current && (r.current.scrollLeft = c.x);
1431
1494
  }
1432
1495
  });
1433
1496
  }
1434
- function o(u) {
1435
- if (!r.current || u === "next" && e.current === "end" || u === "prev" && e.current === "start")
1497
+ function o(l) {
1498
+ if (!r.current || l === "next" && e.current === "end" || l === "prev" && e.current === "start")
1436
1499
  return;
1437
- let d = 0;
1438
- if (u === "next" && (n.current += 1), u === "prev" && (n.current -= 1), d = n.current * ot(r.current), u === "next") {
1439
- const g = Dt(r.current);
1440
- d > g && (e.current = "end", d = g, t && t("end"));
1500
+ let c = 0;
1501
+ if (l === "next" && (n.current += 1), l === "prev" && (n.current -= 1), c = n.current * at(r.current), l === "next") {
1502
+ const h = Pt(r.current);
1503
+ c > h && (e.current = "end", c = h, t && t("end"));
1441
1504
  }
1442
- u === "prev" && d <= 0 && (e.current = "start", n.current = 0, d = 0, t && t("start")), a(d);
1443
- }
1444
- return U(() => {
1445
- function u() {
1446
- var I;
1447
- const P = ot(r.current), T = ((I = [...r.current.children].at(0)) == null ? void 0 : I.getBoundingClientRect().width) || 0, k = Array(r.current.childElementCount).fill(0).map((D, $) => ({
1448
- index: $,
1449
- start: P * $,
1450
- end: P * ($ + 1)
1451
- })), S = r.current.scrollLeft + T, A = k.find(
1452
- (D) => S >= D.start && S < D.end
1505
+ l === "prev" && c <= 0 && (e.current = "start", n.current = 0, c = 0, t && t("start")), a(c);
1506
+ }
1507
+ return z(() => {
1508
+ function l() {
1509
+ var D;
1510
+ const w = at(r.current), E = ((D = [...r.current.children].at(0)) == null ? void 0 : D.getBoundingClientRect().width) || 0, R = Array(r.current.childElementCount).fill(0).map((M, C) => ({
1511
+ index: C,
1512
+ start: w * C,
1513
+ end: w * (C + 1)
1514
+ })), k = r.current.scrollLeft + E, $ = R.find(
1515
+ (M) => k >= M.start && k < M.end
1453
1516
  );
1454
- n.current = (A == null ? void 0 : A.index) || 0;
1517
+ n.current = ($ == null ? void 0 : $.index) || 0;
1455
1518
  }
1456
- function d() {
1519
+ function c() {
1457
1520
  s.stop();
1458
1521
  }
1459
- function g(P) {
1460
- const T = P.target;
1461
- T.scrollLeft === 0 ? (n.current = 0, e.current = "start", t && t("start")) : T.scrollLeft >= Dt(T) ? (e.current = "end", t && t("end")) : e.current !== "idle" && (e.current = "idle", t && t("idle"));
1522
+ function h(w) {
1523
+ const E = w.target;
1524
+ E.scrollLeft === 0 ? (n.current = 0, e.current = "start", t && t("start")) : E.scrollLeft >= Pt(E) ? (e.current = "end", t && t("end")) : e.current !== "idle" && (e.current = "idle", t && t("idle"));
1462
1525
  }
1463
- let l, b = 0;
1464
- function y() {
1465
- b = r.current.scrollLeft, clearTimeout(l), l = setTimeout(function() {
1466
- r.current.scrollLeft === b && u();
1526
+ let f, y = 0;
1527
+ function p() {
1528
+ y = r.current.scrollLeft, clearTimeout(f), f = setTimeout(function() {
1529
+ r.current.scrollLeft === y && l();
1467
1530
  }, 200);
1468
1531
  }
1469
1532
  if (r.current)
1470
- return r.current.addEventListener("wheel", d, {
1533
+ return r.current.addEventListener("wheel", c, {
1471
1534
  passive: !0
1472
- }), r.current.addEventListener("scroll", g), r.current.addEventListener("scroll", y), () => {
1473
- r.current && (r.current.removeEventListener("scroll", y), r.current.removeEventListener("scroll", g), r.current.removeEventListener("wheel", d));
1535
+ }), r.current.addEventListener("scroll", h), r.current.addEventListener("scroll", p), () => {
1536
+ r.current && (r.current.removeEventListener("scroll", p), r.current.removeEventListener("scroll", h), r.current.removeEventListener("wheel", c));
1474
1537
  };
1475
- }, [r, t]), U(() => {
1538
+ }, [r, t]), z(() => {
1476
1539
  if (r.current) {
1477
- const u = new ResizeObserver(() => {
1478
- a(n.current * ot(r.current));
1540
+ const l = new ResizeObserver(() => {
1541
+ a(n.current * at(r.current));
1479
1542
  });
1480
- return u.observe(r.current), () => {
1481
- u.disconnect();
1543
+ return l.observe(r.current), () => {
1544
+ l.disconnect();
1482
1545
  };
1483
1546
  }
1484
1547
  }, []), {
@@ -1491,6 +1554,6 @@ function qe({ container: r, onReach: t }) {
1491
1554
  };
1492
1555
  }
1493
1556
  export {
1494
- Xe as useSpringCarousel,
1495
- qe as useSpringScroll
1557
+ tr as useSpringCarousel,
1558
+ er as useSpringScroll
1496
1559
  };