react-spring-carousel 3.0.0-beta-2.0.16 → 3.0.0-beta-2.0.18
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 +220 -203
- package/dist/index.umd.js +7 -4
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useSpring as
|
|
3
|
-
import J, { useRef as
|
|
4
|
-
function
|
|
1
|
+
import { jsxs as St, jsx as q } from "react/jsx-runtime";
|
|
2
|
+
import { useSpring as Tt } from "@react-spring/web";
|
|
3
|
+
import J, { useRef as P, useEffect as pt } from "react";
|
|
4
|
+
function It(r, t, e) {
|
|
5
5
|
return Math.max(t, Math.min(r, e));
|
|
6
6
|
}
|
|
7
7
|
const g = {
|
|
@@ -25,13 +25,13 @@ function nt(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
27
|
function st(r, t, e, n = 0.15) {
|
|
28
|
-
return n === 0 ?
|
|
28
|
+
return n === 0 ? It(r, t, e) : r < t ? -nt(t - r, e - t, n) + t : r > e ? +nt(r - e, e - t, n) + e : r;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function Dt(r, [t, e], [n, s]) {
|
|
31
31
|
const [[i, c], [a, u]] = r;
|
|
32
32
|
return [st(t, i, c, n), st(e, a, u, s)];
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function kt(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,12 +41,12 @@ function Dt(r, t) {
|
|
|
41
41
|
}
|
|
42
42
|
return (t === "string" ? String : Number)(r);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
var t =
|
|
44
|
+
function Ct(r) {
|
|
45
|
+
var t = kt(r, "string");
|
|
46
46
|
return typeof t == "symbol" ? t : String(t);
|
|
47
47
|
}
|
|
48
48
|
function y(r, t, e) {
|
|
49
|
-
return t =
|
|
49
|
+
return t = Ct(t), t in r ? Object.defineProperty(r, t, {
|
|
50
50
|
value: e,
|
|
51
51
|
enumerable: !0,
|
|
52
52
|
configurable: !0,
|
|
@@ -63,7 +63,7 @@ function it(r, t) {
|
|
|
63
63
|
}
|
|
64
64
|
return e;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function d(r) {
|
|
67
67
|
for (var t = 1; t < arguments.length; t++) {
|
|
68
68
|
var e = arguments[t] != null ? arguments[t] : {};
|
|
69
69
|
t % 2 ? it(Object(e), !0).forEach(function(n) {
|
|
@@ -99,27 +99,27 @@ const mt = {
|
|
|
99
99
|
function ot(r) {
|
|
100
100
|
return r ? r[0].toUpperCase() + r.slice(1) : "";
|
|
101
101
|
}
|
|
102
|
-
const
|
|
103
|
-
function
|
|
104
|
-
return r && !
|
|
102
|
+
const Ot = ["enter", "leave"];
|
|
103
|
+
function At(r = !1, t) {
|
|
104
|
+
return r && !Ot.includes(t);
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function Pt(r, t = "", e = !1) {
|
|
107
107
|
const n = mt[r], s = n && n[t] || t;
|
|
108
|
-
return "on" + ot(r) + ot(s) + (
|
|
108
|
+
return "on" + ot(r) + ot(s) + (At(e, s) ? "Capture" : "");
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
function
|
|
110
|
+
const $t = ["gotpointercapture", "lostpointercapture"];
|
|
111
|
+
function Nt(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 =
|
|
115
|
+
const n = $t.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
|
|
122
|
+
function Mt(r, t = "") {
|
|
123
123
|
const e = mt[r], n = e && e[t] || t;
|
|
124
124
|
return r + n;
|
|
125
125
|
}
|
|
@@ -129,20 +129,20 @@ function W(r) {
|
|
|
129
129
|
function gt(r) {
|
|
130
130
|
return W(r) ? "touch" : "pointerType" in r ? r.pointerType : "mouse";
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function Rt(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
|
|
138
|
+
function Lt(r) {
|
|
139
139
|
return r.type === "touchend" || r.type === "touchcancel" ? r.changedTouches : r.targetTouches;
|
|
140
140
|
}
|
|
141
141
|
function vt(r) {
|
|
142
|
-
return W(r) ?
|
|
142
|
+
return W(r) ? Lt(r)[0] : r;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
return
|
|
144
|
+
function Vt(r) {
|
|
145
|
+
return Rt(r).map((t) => t.identifier);
|
|
146
146
|
}
|
|
147
147
|
function Q(r) {
|
|
148
148
|
const t = vt(r);
|
|
@@ -152,7 +152,7 @@ function at(r) {
|
|
|
152
152
|
const t = vt(r);
|
|
153
153
|
return [t.clientX, t.clientY];
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function jt(r) {
|
|
156
156
|
const t = {};
|
|
157
157
|
if ("buttons" in r && (t.buttons = r.buttons), "shiftKey" in r) {
|
|
158
158
|
const {
|
|
@@ -173,10 +173,10 @@ function Vt(r) {
|
|
|
173
173
|
function Y(r, ...t) {
|
|
174
174
|
return typeof r == "function" ? r(...t) : r;
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function Ut() {
|
|
177
177
|
}
|
|
178
|
-
function
|
|
179
|
-
return r.length === 0 ?
|
|
178
|
+
function Kt(...r) {
|
|
179
|
+
return r.length === 0 ? Ut : 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;
|
|
@@ -186,8 +186,8 @@ function Ut(...r) {
|
|
|
186
186
|
function ct(r, t) {
|
|
187
187
|
return Object.assign({}, t, r || {});
|
|
188
188
|
}
|
|
189
|
-
const
|
|
190
|
-
class
|
|
189
|
+
const Bt = 32;
|
|
190
|
+
class zt {
|
|
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
|
}
|
|
@@ -244,16 +244,16 @@ class Bt {
|
|
|
244
244
|
} = this;
|
|
245
245
|
e.args = this.args;
|
|
246
246
|
let i = 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,
|
|
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, jt(t)), s.down = s.pressed = s.buttons % 2 === 1 || s.touches > 0, i = t.timeStamp - e.timeStamp, e.timeStamp = t.timeStamp, e.elapsedTime = e.timeStamp - e.startTime), e._active) {
|
|
248
248
|
const I = e._delta.map(Math.abs);
|
|
249
249
|
g.addTo(e._distance, I);
|
|
250
250
|
}
|
|
251
251
|
this.axisIntent && this.axisIntent(t);
|
|
252
|
-
const [c, a] = e._movement, [u,
|
|
252
|
+
const [c, a] = e._movement, [u, h] = n.threshold, {
|
|
253
253
|
_step: f,
|
|
254
254
|
values: E
|
|
255
255
|
} = e;
|
|
256
|
-
if (n.hasCustomTransform ? (f[0] === !1 && (f[0] = Math.abs(c) >= u && E[0]), f[1] === !1 && (f[1] = Math.abs(a) >=
|
|
256
|
+
if (n.hasCustomTransform ? (f[0] === !1 && (f[0] = Math.abs(c) >= u && E[0]), f[1] === !1 && (f[1] = Math.abs(a) >= h && E[1])) : (f[0] === !1 && (f[0] = Math.abs(c) >= u && Math.sign(c) * u), f[1] === !1 && (f[1] = Math.abs(a) >= h && Math.sign(a) * h)), e.intentional = f[0] !== !1 || f[1] !== !1, !e.intentional) return;
|
|
257
257
|
const v = [0, 0];
|
|
258
258
|
if (n.hasCustomTransform) {
|
|
259
259
|
const [I, F] = E;
|
|
@@ -261,13 +261,13 @@ class Bt {
|
|
|
261
261
|
} else
|
|
262
262
|
v[0] = f[0] !== !1 ? c - f[0] : 0, v[1] = f[1] !== !1 ? a - f[1] : 0;
|
|
263
263
|
this.restrictToAxis && !e._blocked && this.restrictToAxis(v);
|
|
264
|
-
const
|
|
264
|
+
const $ = e.offset, C = e._active && !e._blocked || e.active;
|
|
265
265
|
C && (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 = Y(n.bounds, e)), this.setup && this.setup()), e.movement = v, this.computeOffset()));
|
|
266
|
-
const [
|
|
267
|
-
e.overflow = [
|
|
268
|
-
const
|
|
269
|
-
if (e.offset =
|
|
270
|
-
e.delta = g.sub(e.offset,
|
|
266
|
+
const [S, N] = e.offset, [[T, O], [L, p]] = e._bounds;
|
|
267
|
+
e.overflow = [S < T ? -1 : S > O ? 1 : 0, N < L ? -1 : N > p ? 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 M = e._active ? n.rubberband || [0, 0] : [0, 0];
|
|
269
|
+
if (e.offset = Dt(e._bounds, e.offset, M), e.delta = g.sub(e.offset, $), this.computeMovement(), C && (!e.last || i > Bt)) {
|
|
270
|
+
e.delta = g.sub(e.offset, $);
|
|
271
271
|
const I = e.delta.map(Math.abs);
|
|
272
272
|
g.addTo(e.distance, I), e.direction = e.delta.map(Math.sign), e._direction = e._delta.map(Math.sign), !e.first && i > 0 && (e.velocity = [I[0] / i, I[1] / i], e.timeDelta = i);
|
|
273
273
|
}
|
|
@@ -275,7 +275,7 @@ class Bt {
|
|
|
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(
|
|
278
|
+
const s = this.handler(d(d(d({}, e), t), {}, {
|
|
279
279
|
[this.aliasKey]: t.values
|
|
280
280
|
}));
|
|
281
281
|
s !== void 0 && (t.memo = s);
|
|
@@ -284,14 +284,14 @@ class Bt {
|
|
|
284
284
|
this.eventStore.clean(), this.timeoutStore.clean();
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function Yt([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
|
|
294
|
+
class Wt extends zt {
|
|
295
295
|
constructor(...t) {
|
|
296
296
|
super(...t), y(this, "aliasKey", "xy");
|
|
297
297
|
}
|
|
@@ -311,7 +311,7 @@ class Yt extends Bt {
|
|
|
311
311
|
const e = this.state, n = this.config;
|
|
312
312
|
if (!e.axis && t) {
|
|
313
313
|
const s = typeof n.axisThreshold == "object" ? n.axisThreshold[gt(t)] : n.axisThreshold;
|
|
314
|
-
e.axis =
|
|
314
|
+
e.axis = Yt(e._movement, s);
|
|
315
315
|
}
|
|
316
316
|
e._blocked = (n.lockDirection || !!n.axis) && !e.axis || !!n.axis && n.axis !== e.axis;
|
|
317
317
|
}
|
|
@@ -332,7 +332,7 @@ const ut = (r) => r, ft = 0.15, et = {
|
|
|
332
332
|
return r;
|
|
333
333
|
},
|
|
334
334
|
eventOptions(r, t, e) {
|
|
335
|
-
return
|
|
335
|
+
return d(d({}, e.shared.eventOptions), r);
|
|
336
336
|
},
|
|
337
337
|
preventDefault(r = !1) {
|
|
338
338
|
return r;
|
|
@@ -386,18 +386,18 @@ process.env.NODE_ENV === "development" && Object.assign(et, {
|
|
|
386
386
|
return NaN;
|
|
387
387
|
}
|
|
388
388
|
});
|
|
389
|
-
const
|
|
389
|
+
const Ft = 0, U = d(d({}, et), {}, {
|
|
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 =
|
|
395
|
+
axisThreshold(r = Ft) {
|
|
396
396
|
return r;
|
|
397
397
|
},
|
|
398
398
|
bounds(r = {}) {
|
|
399
399
|
if (typeof r == "function")
|
|
400
|
-
return (i) =>
|
|
400
|
+
return (i) => U.bounds(r(i));
|
|
401
401
|
if ("current" in r)
|
|
402
402
|
return () => r.current;
|
|
403
403
|
if (typeof HTMLElement == "function" && r instanceof HTMLElement)
|
|
@@ -416,7 +416,7 @@ const Wt = 0, j = l(l({}, et), {}, {
|
|
|
416
416
|
ArrowUp: (r, t = 1) => [0, -1 * r * t],
|
|
417
417
|
ArrowDown: (r, t = 1) => [0, r * t]
|
|
418
418
|
};
|
|
419
|
-
class
|
|
419
|
+
class Ht extends Wt {
|
|
420
420
|
constructor(...t) {
|
|
421
421
|
super(...t), y(this, "ingKey", "dragging");
|
|
422
422
|
}
|
|
@@ -434,7 +434,7 @@ class Ft extends Yt {
|
|
|
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 =
|
|
437
|
+
t._bounds = U.bounds(s);
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
440
|
cancel() {
|
|
@@ -498,10 +498,10 @@ class Ft extends Yt {
|
|
|
498
498
|
if (e.tap = i <= n.tapsThreshold && c <= n.tapsThreshold, e.tap && n.filterTaps)
|
|
499
499
|
e._force = !0;
|
|
500
500
|
else {
|
|
501
|
-
const [a, u] = e._delta, [
|
|
502
|
-
if (e.elapsedTime <
|
|
503
|
-
const
|
|
504
|
-
|
|
501
|
+
const [a, u] = e._delta, [h, f] = e._movement, [E, v] = n.swipe.velocity, [$, C] = n.swipe.distance, S = n.swipe.duration;
|
|
502
|
+
if (e.elapsedTime < S) {
|
|
503
|
+
const N = Math.abs(a / e.timeDelta), T = Math.abs(u / e.timeDelta);
|
|
504
|
+
N > E && Math.abs(h) > $ && (e.swipe[0] = Math.sign(a)), T > v && Math.abs(f) > C && (e.swipe[1] = Math.sign(u));
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
this.emit();
|
|
@@ -528,7 +528,7 @@ class Ft extends Yt {
|
|
|
528
528
|
this.state._preventScroll && t.cancelable && t.preventDefault();
|
|
529
529
|
}
|
|
530
530
|
setupScrollPrevention(t) {
|
|
531
|
-
this.state._preventScroll = !1,
|
|
531
|
+
this.state._preventScroll = !1, Gt(t);
|
|
532
532
|
const e = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), {
|
|
533
533
|
passive: !1
|
|
534
534
|
});
|
|
@@ -557,41 +557,41 @@ class Ft extends Yt {
|
|
|
557
557
|
});
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function Gt(r) {
|
|
561
561
|
"persist" in r && typeof r.persist == "function" && r.persist();
|
|
562
562
|
}
|
|
563
|
-
const
|
|
563
|
+
const K = typeof window < "u" && window.document && window.document.createElement;
|
|
564
564
|
function yt() {
|
|
565
|
-
return
|
|
565
|
+
return K && "ontouchstart" in window;
|
|
566
566
|
}
|
|
567
567
|
function Xt() {
|
|
568
|
-
return yt() ||
|
|
569
|
-
}
|
|
570
|
-
function Gt() {
|
|
571
|
-
return U && "onpointerdown" in window;
|
|
568
|
+
return yt() || K && window.navigator.maxTouchPoints > 1;
|
|
572
569
|
}
|
|
573
570
|
function qt() {
|
|
574
|
-
return
|
|
571
|
+
return K && "onpointerdown" in window;
|
|
575
572
|
}
|
|
576
573
|
function Jt() {
|
|
574
|
+
return K && "exitPointerLock" in window.document;
|
|
575
|
+
}
|
|
576
|
+
function Qt() {
|
|
577
577
|
try {
|
|
578
578
|
return "constructor" in GestureEvent;
|
|
579
579
|
} catch {
|
|
580
580
|
return !1;
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
|
-
const
|
|
584
|
-
isBrowser:
|
|
585
|
-
gesture:
|
|
583
|
+
const x = {
|
|
584
|
+
isBrowser: K,
|
|
585
|
+
gesture: Qt(),
|
|
586
586
|
touch: yt(),
|
|
587
587
|
touchscreen: Xt(),
|
|
588
|
-
pointer:
|
|
589
|
-
pointerLock:
|
|
590
|
-
},
|
|
588
|
+
pointer: qt(),
|
|
589
|
+
pointerLock: Jt()
|
|
590
|
+
}, Zt = 250, te = 180, ee = 0.5, re = 50, ne = 250, se = 10, dt = {
|
|
591
591
|
mouse: 0,
|
|
592
592
|
touch: 0,
|
|
593
593
|
pen: 8
|
|
594
|
-
}, _t =
|
|
594
|
+
}, _t = d(d({}, U), {}, {
|
|
595
595
|
device(r, t, {
|
|
596
596
|
pointer: {
|
|
597
597
|
touch: e = !1,
|
|
@@ -599,12 +599,12 @@ const T = {
|
|
|
599
599
|
mouse: s = !1
|
|
600
600
|
} = {}
|
|
601
601
|
}) {
|
|
602
|
-
return this.pointerLock = n &&
|
|
602
|
+
return this.pointerLock = n && x.pointerLock, x.touch && e ? "touch" : this.pointerLock ? "mouse" : x.pointer && !s ? "pointer" : x.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 ?
|
|
607
|
+
if (this.preventScrollDelay = typeof e == "number" ? e : e || e === void 0 && r ? Zt : void 0, !(!x.touchscreen || e === !1))
|
|
608
608
|
return r || (e !== void 0 ? "y" : void 0);
|
|
609
609
|
},
|
|
610
610
|
pointerCapture(r, t, {
|
|
@@ -625,9 +625,9 @@ const T = {
|
|
|
625
625
|
return this.filterTaps = e, this.tapsThreshold = n, i;
|
|
626
626
|
},
|
|
627
627
|
swipe({
|
|
628
|
-
velocity: r =
|
|
629
|
-
distance: t =
|
|
630
|
-
duration: e =
|
|
628
|
+
velocity: r = ee,
|
|
629
|
+
distance: t = re,
|
|
630
|
+
duration: e = ne
|
|
631
631
|
} = {}) {
|
|
632
632
|
return {
|
|
633
633
|
velocity: this.transform(g.toVector(r)),
|
|
@@ -638,7 +638,7 @@ const T = {
|
|
|
638
638
|
delay(r = 0) {
|
|
639
639
|
switch (r) {
|
|
640
640
|
case !0:
|
|
641
|
-
return
|
|
641
|
+
return te;
|
|
642
642
|
case !1:
|
|
643
643
|
return 0;
|
|
644
644
|
default:
|
|
@@ -646,9 +646,9 @@ const T = {
|
|
|
646
646
|
}
|
|
647
647
|
},
|
|
648
648
|
axisThreshold(r) {
|
|
649
|
-
return r ?
|
|
649
|
+
return r ? d(d({}, dt), r) : dt;
|
|
650
650
|
},
|
|
651
|
-
keyboardDisplacement(r =
|
|
651
|
+
keyboardDisplacement(r = se) {
|
|
652
652
|
return r;
|
|
653
653
|
}
|
|
654
654
|
});
|
|
@@ -679,18 +679,18 @@ process.env.NODE_ENV === "development" && Object.assign(_t, {
|
|
|
679
679
|
return NaN;
|
|
680
680
|
}
|
|
681
681
|
});
|
|
682
|
-
|
|
682
|
+
d(d({}, et), {}, {
|
|
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 && !
|
|
690
|
-
if (
|
|
691
|
-
if (
|
|
692
|
-
if (
|
|
693
|
-
if (
|
|
689
|
+
if (e.target && !x.touch && x.gesture) return "gesture";
|
|
690
|
+
if (x.touch && n) return "touch";
|
|
691
|
+
if (x.touchscreen) {
|
|
692
|
+
if (x.pointer) return "pointer";
|
|
693
|
+
if (x.touch) return "touch";
|
|
694
694
|
}
|
|
695
695
|
},
|
|
696
696
|
bounds(r, t, {
|
|
@@ -722,31 +722,31 @@ l(l({}, et), {}, {
|
|
|
722
722
|
return r;
|
|
723
723
|
}
|
|
724
724
|
});
|
|
725
|
-
|
|
725
|
+
d(d({}, U), {}, {
|
|
726
726
|
mouseOnly: (r = !0) => r
|
|
727
727
|
});
|
|
728
|
-
|
|
728
|
+
d(d({}, U), {}, {
|
|
729
729
|
mouseOnly: (r = !0) => r
|
|
730
730
|
});
|
|
731
731
|
const bt = /* @__PURE__ */ new Map(), tt = /* @__PURE__ */ new Map();
|
|
732
|
-
function
|
|
732
|
+
function ie(r) {
|
|
733
733
|
bt.set(r.key, r.engine), tt.set(r.key, r.resolver);
|
|
734
734
|
}
|
|
735
|
-
const
|
|
735
|
+
const oe = {
|
|
736
736
|
key: "drag",
|
|
737
|
-
engine:
|
|
737
|
+
engine: Ht,
|
|
738
738
|
resolver: _t
|
|
739
739
|
};
|
|
740
|
-
function
|
|
740
|
+
function ae(r, t) {
|
|
741
741
|
if (r == null) return {};
|
|
742
742
|
var e = {}, n = Object.keys(r), s, i;
|
|
743
743
|
for (i = 0; i < n.length; i++)
|
|
744
744
|
s = n[i], !(t.indexOf(s) >= 0) && (e[s] = r[s]);
|
|
745
745
|
return e;
|
|
746
746
|
}
|
|
747
|
-
function
|
|
747
|
+
function ce(r, t) {
|
|
748
748
|
if (r == null) return {};
|
|
749
|
-
var e =
|
|
749
|
+
var e = ae(r, t), n, s;
|
|
750
750
|
if (Object.getOwnPropertySymbols) {
|
|
751
751
|
var i = Object.getOwnPropertySymbols(r);
|
|
752
752
|
for (s = 0; s < i.length; s++)
|
|
@@ -754,7 +754,7 @@ function ae(r, t) {
|
|
|
754
754
|
}
|
|
755
755
|
return e;
|
|
756
756
|
}
|
|
757
|
-
const
|
|
757
|
+
const ue = {
|
|
758
758
|
target(r) {
|
|
759
759
|
if (r)
|
|
760
760
|
return () => "current" in r ? r.current : r;
|
|
@@ -762,7 +762,7 @@ const ce = {
|
|
|
762
762
|
enabled(r = !0) {
|
|
763
763
|
return r;
|
|
764
764
|
},
|
|
765
|
-
window(r =
|
|
765
|
+
window(r = x.isBrowser ? window : void 0) {
|
|
766
766
|
return r;
|
|
767
767
|
},
|
|
768
768
|
eventOptions({
|
|
@@ -777,7 +777,7 @@ const ce = {
|
|
|
777
777
|
transform(r) {
|
|
778
778
|
return r;
|
|
779
779
|
}
|
|
780
|
-
},
|
|
780
|
+
}, fe = ["target", "eventOptions", "window", "enabled", "transform"];
|
|
781
781
|
function z(r = {}, t) {
|
|
782
782
|
const e = {};
|
|
783
783
|
for (const [n, s] of Object.entries(t))
|
|
@@ -798,32 +798,32 @@ function z(r = {}, t) {
|
|
|
798
798
|
}
|
|
799
799
|
return e;
|
|
800
800
|
}
|
|
801
|
-
function
|
|
801
|
+
function le(r, t, e = {}) {
|
|
802
802
|
const n = r, {
|
|
803
803
|
target: s,
|
|
804
804
|
eventOptions: i,
|
|
805
805
|
window: c,
|
|
806
806
|
enabled: a,
|
|
807
807
|
transform: u
|
|
808
|
-
} = n,
|
|
808
|
+
} = n, h = ce(n, fe);
|
|
809
809
|
if (e.shared = z({
|
|
810
810
|
target: s,
|
|
811
811
|
eventOptions: i,
|
|
812
812
|
window: c,
|
|
813
813
|
enabled: a,
|
|
814
814
|
transform: u
|
|
815
|
-
},
|
|
815
|
+
}, ue), t) {
|
|
816
816
|
const f = tt.get(t);
|
|
817
|
-
e[t] = z(
|
|
817
|
+
e[t] = z(d({
|
|
818
818
|
shared: e.shared
|
|
819
|
-
},
|
|
819
|
+
}, h), f);
|
|
820
820
|
} else
|
|
821
|
-
for (const f in
|
|
821
|
+
for (const f in h) {
|
|
822
822
|
const E = tt.get(f);
|
|
823
823
|
if (E)
|
|
824
|
-
e[f] = z(
|
|
824
|
+
e[f] = z(d({
|
|
825
825
|
shared: e.shared
|
|
826
|
-
},
|
|
826
|
+
}, h[f]), E);
|
|
827
827
|
else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(f)) {
|
|
828
828
|
if (f === "domTarget")
|
|
829
829
|
throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
|
|
@@ -837,10 +837,10 @@ class wt {
|
|
|
837
837
|
y(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = t, this._gestureKey = e;
|
|
838
838
|
}
|
|
839
839
|
add(t, e, n, s, i) {
|
|
840
|
-
const c = this._listeners, a =
|
|
841
|
-
t.addEventListener(a, s,
|
|
840
|
+
const c = this._listeners, a = Mt(e, n), u = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, h = d(d({}, u), i);
|
|
841
|
+
t.addEventListener(a, s, h);
|
|
842
842
|
const f = () => {
|
|
843
|
-
t.removeEventListener(a, s,
|
|
843
|
+
t.removeEventListener(a, s, h), c.delete(f);
|
|
844
844
|
};
|
|
845
845
|
return c.add(f), f;
|
|
846
846
|
}
|
|
@@ -848,7 +848,7 @@ class wt {
|
|
|
848
848
|
this._listeners.forEach((t) => t()), this._listeners.clear();
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
|
-
class
|
|
851
|
+
class de {
|
|
852
852
|
constructor() {
|
|
853
853
|
y(this, "_timeouts", /* @__PURE__ */ new Map());
|
|
854
854
|
}
|
|
@@ -863,7 +863,7 @@ class le {
|
|
|
863
863
|
this._timeouts.forEach((t) => void window.clearTimeout(t)), this._timeouts.clear();
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
|
-
class
|
|
866
|
+
class he {
|
|
867
867
|
constructor(t) {
|
|
868
868
|
y(this, "gestures", /* @__PURE__ */ new Set()), y(this, "_targetEventStore", new wt(this)), y(this, "gestureEventStores", {}), y(this, "gestureTimeoutStores", {}), y(this, "handlers", {}), y(this, "config", {}), y(this, "pointerIds", /* @__PURE__ */ new Set()), y(this, "touchIds", /* @__PURE__ */ new Set()), y(this, "state", {
|
|
869
869
|
shared: {
|
|
@@ -872,11 +872,11 @@ class de {
|
|
|
872
872
|
ctrlKey: !1,
|
|
873
873
|
altKey: !1
|
|
874
874
|
}
|
|
875
|
-
}),
|
|
875
|
+
}), pe(this, t);
|
|
876
876
|
}
|
|
877
877
|
setEventIds(t) {
|
|
878
878
|
if (W(t))
|
|
879
|
-
return this.touchIds = new Set(
|
|
879
|
+
return this.touchIds = new Set(Vt(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 de {
|
|
|
884
884
|
this.handlers = t, this.nativeHandlers = e;
|
|
885
885
|
}
|
|
886
886
|
applyConfig(t, e) {
|
|
887
|
-
this.config =
|
|
887
|
+
this.config = le(t, e, this.config);
|
|
888
888
|
}
|
|
889
889
|
clean() {
|
|
890
890
|
this._targetEventStore.clean();
|
|
@@ -902,26 +902,26 @@ class de {
|
|
|
902
902
|
for (const c of this.gestures) {
|
|
903
903
|
const a = this.config[c], u = ht(n, a.eventOptions, !!s);
|
|
904
904
|
if (a.enabled) {
|
|
905
|
-
const
|
|
906
|
-
new
|
|
905
|
+
const h = bt.get(c);
|
|
906
|
+
new h(this, t, c).bind(u);
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
909
|
const i = ht(n, e.eventOptions, !!s);
|
|
910
910
|
for (const c in this.nativeHandlers)
|
|
911
|
-
i(c, "", (a) => this.nativeHandlers[c](
|
|
911
|
+
i(c, "", (a) => this.nativeHandlers[c](d(d({}, this.state.shared), {}, {
|
|
912
912
|
event: a,
|
|
913
913
|
args: t
|
|
914
914
|
})), void 0, !0);
|
|
915
915
|
}
|
|
916
916
|
for (const i in n)
|
|
917
|
-
n[i] =
|
|
917
|
+
n[i] = Kt(...n[i]);
|
|
918
918
|
if (!s) return n;
|
|
919
919
|
for (const i in n) {
|
|
920
920
|
const {
|
|
921
921
|
device: c,
|
|
922
922
|
capture: a,
|
|
923
923
|
passive: u
|
|
924
|
-
} =
|
|
924
|
+
} = Nt(i);
|
|
925
925
|
this._targetEventStore.add(s, c, "", n[i], {
|
|
926
926
|
capture: a,
|
|
927
927
|
passive: u
|
|
@@ -930,31 +930,31 @@ class de {
|
|
|
930
930
|
}
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
|
-
function
|
|
934
|
-
r.gestures.add(t), r.gestureEventStores[t] = new wt(r, t), r.gestureTimeoutStores[t] = new
|
|
933
|
+
function R(r, t) {
|
|
934
|
+
r.gestures.add(t), r.gestureEventStores[t] = new wt(r, t), r.gestureTimeoutStores[t] = new de();
|
|
935
935
|
}
|
|
936
|
-
function
|
|
937
|
-
t.drag &&
|
|
936
|
+
function pe(r, t) {
|
|
937
|
+
t.drag && R(r, "drag"), t.wheel && R(r, "wheel"), t.scroll && R(r, "scroll"), t.move && R(r, "move"), t.pinch && R(r, "pinch"), t.hover && R(r, "hover");
|
|
938
938
|
}
|
|
939
939
|
const ht = (r, t, e) => (n, s, i, c = {}, a = !1) => {
|
|
940
|
-
var u,
|
|
941
|
-
const f = (u = c.capture) !== null && u !== void 0 ? u : t.capture, E = (
|
|
942
|
-
let v = a ? n :
|
|
940
|
+
var u, h;
|
|
941
|
+
const f = (u = c.capture) !== null && u !== void 0 ? u : t.capture, E = (h = c.passive) !== null && h !== void 0 ? h : t.passive;
|
|
942
|
+
let v = a ? n : Pt(n, s, f);
|
|
943
943
|
e && E && (v += "Passive"), r[v] = r[v] || [], r[v].push(i);
|
|
944
944
|
};
|
|
945
|
-
function
|
|
946
|
-
const s = J.useMemo(() => new
|
|
945
|
+
function me(r, t = {}, e, n) {
|
|
946
|
+
const s = J.useMemo(() => new he(r), []);
|
|
947
947
|
if (s.applyHandlers(r, n), s.applyConfig(t, e), J.useEffect(s.effect.bind(s)), J.useEffect(() => s.clean.bind(s), []), t.target === void 0)
|
|
948
948
|
return s.bind.bind(s);
|
|
949
949
|
}
|
|
950
|
-
function
|
|
951
|
-
return
|
|
950
|
+
function ge(r, t) {
|
|
951
|
+
return ie(oe), me({
|
|
952
952
|
drag: r
|
|
953
953
|
}, t || {}, "drag");
|
|
954
954
|
}
|
|
955
955
|
const Z = "RSC::Event";
|
|
956
|
-
function
|
|
957
|
-
const r =
|
|
956
|
+
function ve() {
|
|
957
|
+
const r = P(null);
|
|
958
958
|
function t(n) {
|
|
959
959
|
pt(() => {
|
|
960
960
|
r.current || (r.current = document.createElement("div"));
|
|
@@ -985,7 +985,7 @@ function ge() {
|
|
|
985
985
|
emitEvent: e
|
|
986
986
|
};
|
|
987
987
|
}
|
|
988
|
-
function
|
|
988
|
+
function Ee({
|
|
989
989
|
init: r = !0,
|
|
990
990
|
items: t,
|
|
991
991
|
withLoop: e = !1,
|
|
@@ -995,19 +995,19 @@ function we({
|
|
|
995
995
|
startEndGutter: c = 0,
|
|
996
996
|
carouselAxis: a = "x",
|
|
997
997
|
slideType: u = "fixed",
|
|
998
|
-
startingPosition:
|
|
998
|
+
startingPosition: h = "start",
|
|
999
999
|
enableGestures: f = !0,
|
|
1000
1000
|
slideWhenDragThresholdIsReached: E = !0,
|
|
1001
1001
|
onInit: v
|
|
1002
1002
|
}) {
|
|
1003
|
-
const
|
|
1003
|
+
const $ = P(r), C = P(null), S = P(null), N = P(0), T = P(!e), O = P(!1), L = P(0), p = P(0), [M, I] = Tt(
|
|
1004
1004
|
() => ({
|
|
1005
1005
|
value: 0,
|
|
1006
1006
|
onChange({ value: o }) {
|
|
1007
1007
|
(u === "fixed" || u === "fluid") && C.current.style.setProperty(
|
|
1008
1008
|
`--${n}-offset-position`,
|
|
1009
1009
|
`${o.value}px`
|
|
1010
|
-
), u === "freeScroll" && (
|
|
1010
|
+
), u === "freeScroll" && (S.current[a === "x" ? "scrollLeft" : "scrollTop"] = Math.abs(o.value));
|
|
1011
1011
|
}
|
|
1012
1012
|
}),
|
|
1013
1013
|
[a]
|
|
@@ -1023,52 +1023,52 @@ function we({
|
|
|
1023
1023
|
id: `next-repeated-item-${o.id}`,
|
|
1024
1024
|
isClonedItem: !0
|
|
1025
1025
|
}))
|
|
1026
|
-
] : t, { useListenToCustomEvent: rt, emitEvent:
|
|
1026
|
+
] : t, { useListenToCustomEvent: rt, emitEvent: V } = ve();
|
|
1027
1027
|
function H(o) {
|
|
1028
|
-
|
|
1028
|
+
$.current && (O.current || j({
|
|
1029
1029
|
type: "next",
|
|
1030
1030
|
toIndex: o,
|
|
1031
1031
|
actionType: "click"
|
|
1032
1032
|
}));
|
|
1033
1033
|
}
|
|
1034
|
-
function
|
|
1035
|
-
|
|
1034
|
+
function G(o) {
|
|
1035
|
+
$.current && (T.current || j({
|
|
1036
1036
|
type: "prev",
|
|
1037
1037
|
toIndex: o,
|
|
1038
1038
|
actionType: "click"
|
|
1039
1039
|
}));
|
|
1040
1040
|
}
|
|
1041
|
-
function
|
|
1041
|
+
function j({
|
|
1042
1042
|
type: o,
|
|
1043
|
-
shouldAnimate:
|
|
1043
|
+
shouldAnimate: l = !0,
|
|
1044
1044
|
toIndex: D,
|
|
1045
1045
|
actionType: _
|
|
1046
1046
|
}) {
|
|
1047
|
-
const m =
|
|
1048
|
-
|
|
1049
|
-
let k =
|
|
1050
|
-
if (o === "next" && (
|
|
1051
|
-
const w =
|
|
1047
|
+
const m = B(), A = !l;
|
|
1048
|
+
T.current = !1, O.current = !1;
|
|
1049
|
+
let k = M.value.get(), b = 0;
|
|
1050
|
+
if (o === "next" && (p.current += 1), o === "prev" && (p.current === 0 ? p.current = t.length - 1 : p.current -= 1), D !== void 0 && (p.current = D), u !== "freeScroll" && o === "next") {
|
|
1051
|
+
const w = X(
|
|
1052
1052
|
e ? m * (t.length * 2) : 0
|
|
1053
1053
|
);
|
|
1054
|
-
b = -(
|
|
1054
|
+
b = -(p.current * m), w - Math.abs(b) < m / 1.2 && u === "fluid" && !e && (b = -w), !e && Math.abs(b) >= w && (O.current = !0, b = -w), e && p.current === t.length && (p.current = 0, k = k + m * t.length, b = 0);
|
|
1055
1055
|
}
|
|
1056
|
-
if (u !== "freeScroll" && o === "prev" && (b = -(
|
|
1057
|
-
const w =
|
|
1056
|
+
if (u !== "freeScroll" && o === "prev" && (b = -(p.current * m), p.current === t.length - 1 && (k = k - t.length * m), !e && b >= 0 && (T.current = !0, b = 0)), u === "freeScroll" && o === "next") {
|
|
1057
|
+
const w = S.current[a === "x" ? "scrollLeft" : "scrollTop"];
|
|
1058
1058
|
k = w, b = w + m;
|
|
1059
1059
|
}
|
|
1060
1060
|
if (u === "freeScroll" && o === "prev") {
|
|
1061
|
-
const w =
|
|
1061
|
+
const w = S.current[a === "x" ? "scrollLeft" : "scrollTop"];
|
|
1062
1062
|
k = w, b = w - m;
|
|
1063
1063
|
}
|
|
1064
|
-
|
|
1064
|
+
N.current = b, V(_ === "resize" ? {
|
|
1065
1065
|
eventName: "onResize",
|
|
1066
1066
|
sliceActionType: _,
|
|
1067
1067
|
slideDirection: o,
|
|
1068
1068
|
currentItem: {
|
|
1069
|
-
index:
|
|
1070
|
-
id: t.at(
|
|
1071
|
-
startReached:
|
|
1069
|
+
index: p.current,
|
|
1070
|
+
id: t.at(p.current).id,
|
|
1071
|
+
startReached: T.current,
|
|
1072
1072
|
endReached: O.current
|
|
1073
1073
|
}
|
|
1074
1074
|
} : {
|
|
@@ -1076,13 +1076,13 @@ function we({
|
|
|
1076
1076
|
sliceActionType: _,
|
|
1077
1077
|
slideDirection: o,
|
|
1078
1078
|
nextItem: {
|
|
1079
|
-
index:
|
|
1080
|
-
id: t.at(
|
|
1081
|
-
startReached:
|
|
1079
|
+
index: p.current,
|
|
1080
|
+
id: t.at(p.current).id,
|
|
1081
|
+
startReached: T.current,
|
|
1082
1082
|
endReached: O.current
|
|
1083
1083
|
}
|
|
1084
1084
|
}), I.start({
|
|
1085
|
-
immediate:
|
|
1085
|
+
immediate: A,
|
|
1086
1086
|
from: {
|
|
1087
1087
|
value: k
|
|
1088
1088
|
},
|
|
@@ -1090,38 +1090,47 @@ function we({
|
|
|
1090
1090
|
value: b
|
|
1091
1091
|
},
|
|
1092
1092
|
onRest({ finished: w }) {
|
|
1093
|
-
w && u === "fixed" &&
|
|
1093
|
+
w && u === "fixed" && V({
|
|
1094
1094
|
eventName: "onSlideChangeComplete",
|
|
1095
1095
|
sliceActionType: _,
|
|
1096
1096
|
slideDirection: o,
|
|
1097
1097
|
currentItem: {
|
|
1098
|
-
index:
|
|
1099
|
-
id: t.at(
|
|
1100
|
-
startReached:
|
|
1098
|
+
index: p.current,
|
|
1099
|
+
id: t.at(p.current).id,
|
|
1100
|
+
startReached: T.current,
|
|
1101
1101
|
endReached: O.current
|
|
1102
1102
|
}
|
|
1103
|
-
}), w && u === "fluid" &&
|
|
1103
|
+
}), w && u === "fluid" && V({
|
|
1104
1104
|
eventName: "onSlideChangeComplete",
|
|
1105
1105
|
sliceActionType: _,
|
|
1106
1106
|
slideDirection: o,
|
|
1107
1107
|
currentItem: {
|
|
1108
1108
|
index: 0,
|
|
1109
1109
|
id: "",
|
|
1110
|
-
startReached:
|
|
1110
|
+
startReached: T.current,
|
|
1111
1111
|
endReached: O.current
|
|
1112
1112
|
}
|
|
1113
1113
|
});
|
|
1114
1114
|
}
|
|
1115
1115
|
});
|
|
1116
1116
|
}
|
|
1117
|
-
function
|
|
1118
|
-
const o =
|
|
1119
|
-
let
|
|
1120
|
-
return
|
|
1117
|
+
function B() {
|
|
1118
|
+
const o = S.current.children[0];
|
|
1119
|
+
let l = 0;
|
|
1120
|
+
return l = o.getBoundingClientRect()[a === "x" ? "width" : "height"] + i, l;
|
|
1121
1121
|
}
|
|
1122
|
-
function
|
|
1123
|
-
const
|
|
1124
|
-
return
|
|
1122
|
+
function X(o) {
|
|
1123
|
+
const l = S.current;
|
|
1124
|
+
return l[a === "x" ? "scrollWidth" : "scrollHeight"] - l.getBoundingClientRect()[a === "x" ? "width" : "height"] - o;
|
|
1125
|
+
}
|
|
1126
|
+
function Et() {
|
|
1127
|
+
let o = 0;
|
|
1128
|
+
const l = getComputedStyle(
|
|
1129
|
+
document.documentElement
|
|
1130
|
+
).getPropertyValue(`--${n}-start-end-gutter`);
|
|
1131
|
+
return l.includes("px") && (o = Number(
|
|
1132
|
+
l.replace("px", "")
|
|
1133
|
+
)), { totalStartEndGutterCssVar: o };
|
|
1125
1134
|
}
|
|
1126
1135
|
pt(() => {
|
|
1127
1136
|
function o(_, m) {
|
|
@@ -1140,34 +1149,39 @@ function we({
|
|
|
1140
1149
|
return 0;
|
|
1141
1150
|
}
|
|
1142
1151
|
}
|
|
1143
|
-
function
|
|
1152
|
+
function l(_) {
|
|
1144
1153
|
if (C.current) {
|
|
1145
|
-
|
|
1146
|
-
|
|
1154
|
+
const { totalStartEndGutterCssVar: m } = Et();
|
|
1155
|
+
document.documentElement.style.setProperty(
|
|
1156
|
+
`--${n}-start-end-gutter`,
|
|
1157
|
+
`${m}px`
|
|
1158
|
+
);
|
|
1159
|
+
let A = 0;
|
|
1160
|
+
e && (A = B() * t.length), A -= B() * o(h, s), A -= m, C.current.style.setProperty(
|
|
1147
1161
|
`--${n}-offset-modifier`,
|
|
1148
|
-
`${-
|
|
1162
|
+
`${-A}px`
|
|
1149
1163
|
), _ && _();
|
|
1150
1164
|
}
|
|
1151
1165
|
}
|
|
1152
1166
|
function D() {
|
|
1153
|
-
|
|
1167
|
+
l(), j({
|
|
1154
1168
|
type: "next",
|
|
1155
|
-
toIndex:
|
|
1169
|
+
toIndex: p.current,
|
|
1156
1170
|
shouldAnimate: !1,
|
|
1157
1171
|
actionType: "resize"
|
|
1158
1172
|
});
|
|
1159
1173
|
}
|
|
1160
|
-
if (r && (
|
|
1161
|
-
return
|
|
1174
|
+
if (r && (L.current = B() / 4), r && u === "fixed")
|
|
1175
|
+
return l(v), window.addEventListener("resize", D), () => {
|
|
1162
1176
|
window.removeEventListener("resize", D);
|
|
1163
1177
|
};
|
|
1164
|
-
}, [r, e, n, a, i,
|
|
1165
|
-
const
|
|
1178
|
+
}, [r, e, n, a, i, h, u]);
|
|
1179
|
+
const xt = ge(
|
|
1166
1180
|
(o) => {
|
|
1167
|
-
if (
|
|
1181
|
+
if (!$.current)
|
|
1168
1182
|
return;
|
|
1169
|
-
const
|
|
1170
|
-
|
|
1183
|
+
const l = o.dragging, D = o.offset[a === "x" ? 0 : 1], _ = o.movement[a === "x" ? 0 : 1], m = _ > L.current, A = _ < -L.current, k = o.velocity;
|
|
1184
|
+
l && (V({
|
|
1171
1185
|
...o,
|
|
1172
1186
|
eventName: "onDrag",
|
|
1173
1187
|
slideActionType: "drag"
|
|
@@ -1177,14 +1191,14 @@ function we({
|
|
|
1177
1191
|
config: {
|
|
1178
1192
|
velocity: k
|
|
1179
1193
|
}
|
|
1180
|
-
}), E && (m ||
|
|
1194
|
+
}), E && (m || A) && o.cancel()), o.last && (m ? j({
|
|
1181
1195
|
actionType: "drag",
|
|
1182
1196
|
type: "prev"
|
|
1183
|
-
}) :
|
|
1197
|
+
}) : A ? j({
|
|
1184
1198
|
actionType: "drag",
|
|
1185
1199
|
type: "next"
|
|
1186
1200
|
}) : I.start({
|
|
1187
|
-
value:
|
|
1201
|
+
value: N.current,
|
|
1188
1202
|
config: {
|
|
1189
1203
|
velocity: k
|
|
1190
1204
|
}
|
|
@@ -1197,16 +1211,16 @@ function we({
|
|
|
1197
1211
|
...e ? {} : {
|
|
1198
1212
|
bounds: () => ({
|
|
1199
1213
|
right: 0,
|
|
1200
|
-
left: -
|
|
1201
|
-
top: -
|
|
1214
|
+
left: -X(0),
|
|
1215
|
+
top: -X(0),
|
|
1202
1216
|
bottom: 0
|
|
1203
1217
|
})
|
|
1204
1218
|
},
|
|
1205
|
-
from: () => [
|
|
1219
|
+
from: () => [M.value.get(), M.value.get()]
|
|
1206
1220
|
}
|
|
1207
1221
|
);
|
|
1208
1222
|
return {
|
|
1209
|
-
carouselFragment: /* @__PURE__ */
|
|
1223
|
+
carouselFragment: /* @__PURE__ */ St(
|
|
1210
1224
|
"div",
|
|
1211
1225
|
{
|
|
1212
1226
|
ref: C,
|
|
@@ -1219,18 +1233,21 @@ function we({
|
|
|
1219
1233
|
{
|
|
1220
1234
|
dangerouslySetInnerHTML: {
|
|
1221
1235
|
__html: `
|
|
1236
|
+
:root {
|
|
1237
|
+
--${n}-start-end-gutter: ${c * 2}px;
|
|
1238
|
+
--${n}-gutter: ${i}px;
|
|
1239
|
+
}
|
|
1222
1240
|
[data-part-internal="${n}-Container"] {
|
|
1223
1241
|
display: flex;
|
|
1224
1242
|
width: 100%;
|
|
1225
1243
|
height: 100%;
|
|
1226
1244
|
overflow: hidden;
|
|
1227
|
-
--${n}-gutter: ${i}px;
|
|
1228
1245
|
--${n}-items-per-slide: ${s};
|
|
1229
1246
|
--${n}-offset-position: 0px;
|
|
1230
1247
|
--${n}-offset-modifier: 0px;
|
|
1231
1248
|
--${n}-scroll-x-value: ${u !== "freeScroll" && a === "x" ? `calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))` : "0px"};
|
|
1232
1249
|
--${n}-scroll-y-value: ${u !== "freeScroll" && a === "y" ? `calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))` : "0px"};
|
|
1233
|
-
|
|
1250
|
+
|
|
1234
1251
|
}
|
|
1235
1252
|
[data-part-internal="${n}-Track"] {
|
|
1236
1253
|
display: flex;
|
|
@@ -1253,17 +1270,17 @@ function we({
|
|
|
1253
1270
|
/* @__PURE__ */ q(
|
|
1254
1271
|
"div",
|
|
1255
1272
|
{
|
|
1256
|
-
ref:
|
|
1273
|
+
ref: S,
|
|
1257
1274
|
className: "ReactSpringCarouselTrack",
|
|
1258
1275
|
"data-part": "Track",
|
|
1259
1276
|
"data-part-internal": `${n}-Track`,
|
|
1260
|
-
...
|
|
1277
|
+
...xt(),
|
|
1261
1278
|
...u === "freeScroll" ? {
|
|
1262
1279
|
onWheel() {
|
|
1263
|
-
|
|
1280
|
+
M.value.stop();
|
|
1264
1281
|
}
|
|
1265
1282
|
} : {},
|
|
1266
|
-
children: F.map((o,
|
|
1283
|
+
children: F.map((o, l) => /* @__PURE__ */ q(
|
|
1267
1284
|
"div",
|
|
1268
1285
|
{
|
|
1269
1286
|
className: "ReactSpringCarouselItem",
|
|
@@ -1272,11 +1289,11 @@ function we({
|
|
|
1272
1289
|
"data-id": o.id,
|
|
1273
1290
|
children: typeof o.renderItem == "function" ? o.renderItem({
|
|
1274
1291
|
useListenToCustomEvent: rt,
|
|
1275
|
-
index:
|
|
1292
|
+
index: l,
|
|
1276
1293
|
isClonedItem: !!o.isClonedItem
|
|
1277
1294
|
}) : o.renderItem
|
|
1278
1295
|
},
|
|
1279
|
-
`${o.id}-${
|
|
1296
|
+
`${o.id}-${l}`
|
|
1280
1297
|
))
|
|
1281
1298
|
}
|
|
1282
1299
|
)
|
|
@@ -1285,7 +1302,7 @@ function we({
|
|
|
1285
1302
|
),
|
|
1286
1303
|
useListenToCustomEvent: rt,
|
|
1287
1304
|
slideToNextItem: () => H(),
|
|
1288
|
-
slideToPrevItem: () =>
|
|
1305
|
+
slideToPrevItem: () => G(),
|
|
1289
1306
|
slideToItem: (o) => {
|
|
1290
1307
|
if (typeof o == "number") {
|
|
1291
1308
|
if (!t[o]) {
|
|
@@ -1294,21 +1311,21 @@ function we({
|
|
|
1294
1311
|
);
|
|
1295
1312
|
return;
|
|
1296
1313
|
}
|
|
1297
|
-
o >
|
|
1314
|
+
o > p.current ? H(o) : G(o);
|
|
1298
1315
|
}
|
|
1299
1316
|
if (typeof o == "string") {
|
|
1300
|
-
const
|
|
1301
|
-
if (
|
|
1317
|
+
const l = t.findIndex((D) => D.id === o);
|
|
1318
|
+
if (l < 0) {
|
|
1302
1319
|
console.warn(
|
|
1303
1320
|
`The item you're trying to slide doesn't exist. id: ${o}`
|
|
1304
1321
|
);
|
|
1305
1322
|
return;
|
|
1306
1323
|
}
|
|
1307
|
-
|
|
1324
|
+
l > p.current ? H(l) : G(l);
|
|
1308
1325
|
}
|
|
1309
1326
|
}
|
|
1310
1327
|
};
|
|
1311
1328
|
}
|
|
1312
1329
|
export {
|
|
1313
|
-
|
|
1330
|
+
Ee as useSpringCarousel
|
|
1314
1331
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
(function(O,$){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"],$):(O=typeof globalThis<"u"?globalThis:O||self,$(O["react-spring-carousel"]={},O["react/jsx-runtime"],O["@react-spring/web"],O.React))})(this,function(O,$,we,y){"use strict";function Ee(r,e,t){return Math.max(e,Math.min(r,t))}const g={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 re(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function ne(r,e,t,n=.15){return n===0?Ee(r,e,t):r<e?-re(e-r,t-e,n)+e:r>t?+re(r-t,t-e,n)+t:r}function Te(r,[e,t],[n,s]){const[[i,c],[a,u]]=r;return[ne(e,i,c,n),ne(t,a,u,s)]}function xe(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 Se(r){var e=xe(r,"string");return typeof e=="symbol"?e:String(e)}function _(r,e,t){return e=Se(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function se(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 l(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?se(Object(t),!0).forEach(function(n){_(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):se(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const ie={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 oe(r){return r?r[0].toUpperCase()+r.slice(1):""}const Ie=["enter","leave"];function De(r=!1,e){return r&&!Ie.includes(e)}function ke(r,e="",t=!1){const n=ie[r],s=n&&n[e]||e;return"on"+oe(r)+oe(s)+(De(t,s)?"Capture":"")}const Ce=["gotpointercapture","lostpointercapture"];function Oe(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=Ce.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:t}}function Ae(r,e=""){const t=ie[r],n=t&&t[e]||e;return r+n}function z(r){return"touches"in r}function ae(r){return z(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function Pe(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 $e(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function ce(r){return z(r)?$e(r)[0]:r}function Me(r){return Pe(r).map(e=>e.identifier)}function X(r){const e=ce(r);return z(r)?e.identifier:e.pointerId}function ue(r){const e=ce(r);return[e.clientX,e.clientY]}function Ne(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:s,ctrlKey:i}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:s,ctrlKey:i})}return e}function Y(r,...e){return typeof r=="function"?r(...e):r}function Le(){}function Re(...r){return r.length===0?Le:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function fe(r,e){return Object.assign({},e,r||{})}const Ve=32;class je{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?Y(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 i=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,Ne(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,i=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const D=t._delta.map(Math.abs);g.addTo(t._distance,D)}this.axisIntent&&this.axisIntent(e);const[c,a]=t._movement,[u,d]=n.threshold,{_step:f,values:x}=t;if(n.hasCustomTransform?(f[0]===!1&&(f[0]=Math.abs(c)>=u&&x[0]),f[1]===!1&&(f[1]=Math.abs(a)>=d&&x[1])):(f[0]===!1&&(f[0]=Math.abs(c)>=u&&Math.sign(c)*u),f[1]===!1&&(f[1]=Math.abs(a)>=d&&Math.sign(a)*d)),t.intentional=f[0]!==!1||f[1]!==!1,!t.intentional)return;const v=[0,0];if(n.hasCustomTransform){const[D,Q]=x;v[0]=f[0]!==!1?D-f[0]:0,v[1]=f[1]!==!1?Q-f[1]:0}else v[0]=f[0]!==!1?c-f[0]:0,v[1]=f[1]!==!1?a-f[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(v);const M=t.offset,A=t._active&&!t._blocked||t.active;A&&(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=Y(n.bounds,t)),this.setup&&this.setup()),t.movement=v,this.computeOffset()));const[S,N]=t.offset,[[I,P],[U,h]]=t._bounds;t.overflow=[S<I?-1:S>P?1:0,N<U?-1:N>h?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 R=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=Te(t._bounds,t.offset,R),t.delta=g.sub(t.offset,M),this.computeMovement(),A&&(!t.last||i>Ve)){t.delta=g.sub(t.offset,M);const D=t.delta.map(Math.abs);g.addTo(t.distance,D),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&i>0&&(t.velocity=[D[0]/i,D[1]/i],t.timeDelta=i)}}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(l(l(l({},t),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Ue([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 Ke extends je{constructor(...e){super(...e),_(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=g.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=g.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[ae(e)]:n.axisThreshold;t.axis=Ue(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 le=r=>r,de=.15,q={enabled(r=!0){return r},eventOptions(r,e,t){return l(l({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[de,de];case!1:return[0,0];default:return g.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return g.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||le;return i=>{const c=s(i);return(!isFinite(c[0])||!isFinite(c[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${c[0]},${[1]}]`),c}}return n||le},threshold(r){return g.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(q,{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 Be=0,V=l(l({},q),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=Be){return r},bounds(r={}){if(typeof r=="function")return i=>V.bounds(r(i));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]]}}),he={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 ze extends Ke{constructor(...e){super(...e),_(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=V.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=X(e),n._pointerActive=!0,this.computeValues(ue(e)),this.computeInitial(),t.preventScrollAxis&&ae(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=X(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;const i=ue(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=g.sub(i,t._values),this.computeValues(i)),g.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=X(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[i,c]=t._distance;if(t.tap=i<=n.tapsThreshold&&c<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[a,u]=t._delta,[d,f]=t._movement,[x,v]=n.swipe.velocity,[M,A]=n.swipe.distance,S=n.swipe.duration;if(t.elapsedTime<S){const N=Math.abs(a/t.timeDelta),I=Math.abs(u/t.timeDelta);N>x&&Math.abs(d)>M&&(t.swipe[0]=Math.sign(a)),I>v&&Math.abs(f)>A&&(t.swipe[1]=Math.sign(u))}}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,Ye(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=he[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,g.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in he&&(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 Ye(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const j=typeof window<"u"&&window.document&&window.document.createElement;function pe(){return j&&"ontouchstart"in window}function We(){return pe()||j&&window.navigator.maxTouchPoints>1}function Fe(){return j&&"onpointerdown"in window}function He(){return j&&"exitPointerLock"in window.document}function Xe(){try{return"constructor"in GestureEvent}catch{return!1}}const T={isBrowser:j,gesture:Xe(),touch:pe(),touchscreen:We(),pointer:Fe(),pointerLock:He()},qe=250,Ge=180,Je=.5,Qe=50,Ze=250,et=10,me={mouse:0,touch:0,pen:8},ge=l(l({},V),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&T.pointerLock,T.touch&&t?"touch":this.pointerLock?"mouse":T.pointer&&!s?"pointer":T.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?qe:void 0,!(!T.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 i=g.toVector(r,t?n:s?1:0);return this.filterTaps=t,this.tapsThreshold=n,i},swipe({velocity:r=Je,distance:e=Qe,duration:t=Ze}={}){return{velocity:this.transform(g.toVector(r)),distance:this.transform(g.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return Ge;case!1:return 0;default:return r}},axisThreshold(r){return r?l(l({},me),r):me},keyboardDisplacement(r=et){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}}),l(l({},q),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!T.touch&&T.gesture)return"gesture";if(T.touch&&n)return"touch";if(T.touchscreen){if(T.pointer)return"pointer";if(T.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const s=c=>{const a=fe(Y(t,c),{min:-1/0,max:1/0});return[a.min,a.max]},i=c=>{const a=fe(Y(n,c),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof n!="function"?[s(),i()]:c=>[s(c),i(c)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",g.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}}),l(l({},V),{},{mouseOnly:(r=!0)=>r}),l(l({},V),{},{mouseOnly:(r=!0)=>r});const ve=new Map,G=new Map;function tt(r){ve.set(r.key,r.engine),G.set(r.key,r.resolver)}const rt={key:"drag",engine:ze,resolver:ge};function nt(r,e){if(r==null)return{};var t={},n=Object.keys(r),s,i;for(i=0;i<n.length;i++)s=n[i],!(e.indexOf(s)>=0)&&(t[s]=r[s]);return t}function st(r,e){if(r==null)return{};var t=nt(r,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const it={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=T.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},ot=["target","eventOptions","window","enabled","transform"];function W(r={},e){const t={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const i=s.call(t,r[n],n,r);Number.isNaN(i)||(t[n]=i)}else t[n]=s.call(t,r[n],n,r);break;case"object":t[n]=W(r[n],s);break;case"boolean":s&&(t[n]=r[n]);break}return t}function at(r,e,t={}){const n=r,{target:s,eventOptions:i,window:c,enabled:a,transform:u}=n,d=st(n,ot);if(t.shared=W({target:s,eventOptions:i,window:c,enabled:a,transform:u},it),e){const f=G.get(e);t[e]=W(l({shared:t.shared},d),f)}else for(const f in d){const x=G.get(f);if(x)t[f]=W(l({shared:t.shared},d[f]),x);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(f)){if(f==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${f}\` was used. Please read the documentation for further information.`)}}return t}class ye{constructor(e,t){_(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,s,i){const c=this._listeners,a=Ae(t,n),u=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},d=l(l({},u),i);e.addEventListener(a,s,d);const f=()=>{e.removeEventListener(a,s,d),c.delete(f)};return c.add(f),f}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class ct{constructor(){_(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 ut{constructor(e){_(this,"gestures",new Set),_(this,"_targetEventStore",new ye(this)),_(this,"gestureEventStores",{}),_(this,"gestureTimeoutStores",{}),_(this,"handlers",{}),_(this,"config",{}),_(this,"pointerIds",new Set),_(this,"touchIds",new Set),_(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),ft(this,e)}setEventIds(e){if(z(e))return this.touchIds=new Set(Me(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=at(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 c of this.gestures){const a=this.config[c],u=_e(n,a.eventOptions,!!s);if(a.enabled){const d=ve.get(c);new d(this,e,c).bind(u)}}const i=_e(n,t.eventOptions,!!s);for(const c in this.nativeHandlers)i(c,"",a=>this.nativeHandlers[c](l(l({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const i in n)n[i]=Re(...n[i]);if(!s)return n;for(const i in n){const{device:c,capture:a,passive:u}=Oe(i);this._targetEventStore.add(s,c,"",n[i],{capture:a,passive:u})}}}}function L(r,e){r.gestures.add(e),r.gestureEventStores[e]=new ye(r,e),r.gestureTimeoutStores[e]=new ct}function ft(r,e){e.drag&&L(r,"drag"),e.wheel&&L(r,"wheel"),e.scroll&&L(r,"scroll"),e.move&&L(r,"move"),e.pinch&&L(r,"pinch"),e.hover&&L(r,"hover")}const _e=(r,e,t)=>(n,s,i,c={},a=!1)=>{var u,d;const f=(u=c.capture)!==null&&u!==void 0?u:e.capture,x=(d=c.passive)!==null&&d!==void 0?d:e.passive;let v=a?n:ke(n,s,f);t&&x&&(v+="Passive"),r[v]=r[v]||[],r[v].push(i)};function lt(r,e={},t,n){const s=y.useMemo(()=>new ut(r),[]);if(s.applyHandlers(r,n),s.applyConfig(e,t),y.useEffect(s.effect.bind(s)),y.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function dt(r,e){return tt(rt),lt({drag:r},e||{},"drag")}const J="RSC::Event";function ht(){const r=y.useRef(null);function e(n){y.useEffect(()=>{r.current||(r.current=document.createElement("div"));function s(i){n(i.detail)}if(r.current)return r.current.addEventListener(J,s,!1),()=>{var i;(i=r.current)==null||i.removeEventListener(J,s,!1)}},[n])}function t(n){if(r.current){const s=new CustomEvent(J,{detail:n});r.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:t}}function pt({init:r=!0,items:e,withLoop:t=!1,id:n,itemsPerSlide:s=1,gutter:i=0,startEndGutter:c=0,carouselAxis:a="x",slideType:u="fixed",startingPosition:d="start",enableGestures:f=!0,slideWhenDragThresholdIsReached:x=!0,onInit:v}){const M=y.useRef(r),A=y.useRef(null),S=y.useRef(null),N=y.useRef(0),I=y.useRef(!t),P=y.useRef(!1),U=y.useRef(0),h=y.useRef(0),[R,D]=we.useSpring(()=>({value:0,onChange({value:o}){(u==="fixed"||u==="fluid")&&A.current.style.setProperty(`--${n}-offset-position`,`${o.value}px`),u==="freeScroll"&&(S.current[a==="x"?"scrollLeft":"scrollTop"]=Math.abs(o.value))}}),[a]),Q=u!=="freeScroll"&&t?[...e.map(o=>({...o,id:`prev-repeated-item-${o.id}`,isClonedItem:!0})),...e,...e.map(o=>({...o,id:`next-repeated-item-${o.id}`,isClonedItem:!0}))]:e,{useListenToCustomEvent:be,emitEvent:K}=ht();function Z(o){M.current&&(P.current||B({type:"next",toIndex:o,actionType:"click"}))}function ee(o){M.current&&(I.current||B({type:"prev",toIndex:o,actionType:"click"}))}function B({type:o,shouldAnimate:p=!0,toIndex:k,actionType:b}){const m=F(),H=!p;I.current=!1,P.current=!1;let C=R.value.get(),w=0;if(o==="next"&&(h.current+=1),o==="prev"&&(h.current===0?h.current=e.length-1:h.current-=1),k!==void 0&&(h.current=k),u!=="freeScroll"&&o==="next"){const E=te(t?m*(e.length*2):0);w=-(h.current*m),E-Math.abs(w)<m/1.2&&u==="fluid"&&!t&&(w=-E),!t&&Math.abs(w)>=E&&(P.current=!0,w=-E),t&&h.current===e.length&&(h.current=0,C=C+m*e.length,w=0)}if(u!=="freeScroll"&&o==="prev"&&(w=-(h.current*m),h.current===e.length-1&&(C=C-e.length*m),!t&&w>=0&&(I.current=!0,w=0)),u==="freeScroll"&&o==="next"){const E=S.current[a==="x"?"scrollLeft":"scrollTop"];C=E,w=E+m}if(u==="freeScroll"&&o==="prev"){const E=S.current[a==="x"?"scrollLeft":"scrollTop"];C=E,w=E-m}N.current=w,K(b==="resize"?{eventName:"onResize",sliceActionType:b,slideDirection:o,currentItem:{index:h.current,id:e.at(h.current).id,startReached:I.current,endReached:P.current}}:{eventName:"onSlideStartChange",sliceActionType:b,slideDirection:o,nextItem:{index:h.current,id:e.at(h.current).id,startReached:I.current,endReached:P.current}}),D.start({immediate:H,from:{value:C},to:{value:w},onRest({finished:E}){E&&u==="fixed"&&K({eventName:"onSlideChangeComplete",sliceActionType:b,slideDirection:o,currentItem:{index:h.current,id:e.at(h.current).id,startReached:I.current,endReached:P.current}}),E&&u==="fluid"&&K({eventName:"onSlideChangeComplete",sliceActionType:b,slideDirection:o,currentItem:{index:0,id:"",startReached:I.current,endReached:P.current}})}})}function F(){const o=S.current.children[0];let p=0;return p=o.getBoundingClientRect()[a==="x"?"width":"height"]+i,p}function te(o){const p=S.current;return p[a==="x"?"scrollWidth":"scrollHeight"]-p.getBoundingClientRect()[a==="x"?"width":"height"]-o}y.useEffect(()=>{function o(b,m){switch(b){case"start":return 0;case"middle-start":return Math.floor((m-1)*.25);case"center":return Math.floor((m-1)*.5);case"middle-end":return Math.floor((m-1)*.75);case"end":return m-1;default:return 0}}function p(b){if(A.current){let m=0;t&&(m=F()*e.length),m-=F()*o(d,s),m-=c,A.current.style.setProperty(`--${n}-offset-modifier`,`${-m}px`),b&&b()}}function k(){p(),B({type:"next",toIndex:h.current,shouldAnimate:!1,actionType:"resize"})}if(r&&(U.current=F()/4),r&&u==="fixed")return p(v),window.addEventListener("resize",k),()=>{window.removeEventListener("resize",k)}},[r,t,n,a,i,d,u]);const mt=dt(o=>{if(!M.current)return;const p=o.dragging,k=o.offset[a==="x"?0:1],b=o.movement[a==="x"?0:1],m=b>U.current,H=b<-U.current,C=o.velocity;p&&(K({...o,eventName:"onDrag",slideActionType:"drag"}),D.start({value:k,immediate:!0,config:{velocity:C}}),x&&(m||H)&&o.cancel()),o.last&&(m?B({actionType:"drag",type:"prev"}):H?B({actionType:"drag",type:"next"}):D.start({value:N.current,config:{velocity:C}}))},{enabled:f&&u!=="freeScroll",axis:a,rubberband:!t,...t?{}:{bounds:()=>({right:0,left:-te(0),top:-te(0),bottom:0})},from:()=>[R.value.get(),R.value.get()]});return{carouselFragment:$.jsxs("div",{ref:A,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,children:[$.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
1
|
+
(function(O,N){typeof exports=="object"&&typeof module<"u"?N(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"],N):(O=typeof globalThis<"u"?globalThis:O||self,N(O["react-spring-carousel"]={},O["react/jsx-runtime"],O["@react-spring/web"],O.React))})(this,function(O,N,we,y){"use strict";function Ee(r,e,t){return Math.max(e,Math.min(r,t))}const g={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 re(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function ne(r,e,t,n=.15){return n===0?Ee(r,e,t):r<e?-re(e-r,t-e,n)+e:r>t?+re(r-t,t-e,n)+t:r}function xe(r,[e,t],[n,s]){const[[i,c],[a,u]]=r;return[ne(e,i,c,n),ne(t,a,u,s)]}function Se(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 Te(r){var e=Se(r,"string");return typeof e=="symbol"?e:String(e)}function _(r,e,t){return e=Te(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function se(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?se(Object(t),!0).forEach(function(n){_(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):se(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const ie={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 oe(r){return r?r[0].toUpperCase()+r.slice(1):""}const Ie=["enter","leave"];function De(r=!1,e){return r&&!Ie.includes(e)}function ke(r,e="",t=!1){const n=ie[r],s=n&&n[e]||e;return"on"+oe(r)+oe(s)+(De(t,s)?"Capture":"")}const Ce=["gotpointercapture","lostpointercapture"];function Oe(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=Ce.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:t}}function Ae(r,e=""){const t=ie[r],n=t&&t[e]||e;return r+n}function Y(r){return"touches"in r}function ae(r){return Y(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function Pe(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 $e(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function ce(r){return Y(r)?$e(r)[0]:r}function Ne(r){return Pe(r).map(e=>e.identifier)}function G(r){const e=ce(r);return Y(r)?e.identifier:e.pointerId}function ue(r){const e=ce(r);return[e.clientX,e.clientY]}function Me(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:s,ctrlKey:i}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:s,ctrlKey:i})}return e}function W(r,...e){return typeof r=="function"?r(...e):r}function Le(){}function Re(...r){return r.length===0?Le:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function fe(r,e){return Object.assign({},e,r||{})}const Ve=32;class je{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?W(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 i=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,Me(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,i=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const D=t._delta.map(Math.abs);g.addTo(t._distance,D)}this.axisIntent&&this.axisIntent(e);const[c,a]=t._movement,[u,h]=n.threshold,{_step:f,values:S}=t;if(n.hasCustomTransform?(f[0]===!1&&(f[0]=Math.abs(c)>=u&&S[0]),f[1]===!1&&(f[1]=Math.abs(a)>=h&&S[1])):(f[0]===!1&&(f[0]=Math.abs(c)>=u&&Math.sign(c)*u),f[1]===!1&&(f[1]=Math.abs(a)>=h&&Math.sign(a)*h)),t.intentional=f[0]!==!1||f[1]!==!1,!t.intentional)return;const v=[0,0];if(n.hasCustomTransform){const[D,Q]=S;v[0]=f[0]!==!1?D-f[0]:0,v[1]=f[1]!==!1?Q-f[1]:0}else v[0]=f[0]!==!1?c-f[0]:0,v[1]=f[1]!==!1?a-f[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(v);const M=t.offset,A=t._active&&!t._blocked||t.active;A&&(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=W(n.bounds,t)),this.setup&&this.setup()),t.movement=v,this.computeOffset()));const[T,L]=t.offset,[[I,P],[K,p]]=t._bounds;t.overflow=[T<I?-1:T>P?1:0,L<K?-1:L>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 V=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=xe(t._bounds,t.offset,V),t.delta=g.sub(t.offset,M),this.computeMovement(),A&&(!t.last||i>Ve)){t.delta=g.sub(t.offset,M);const D=t.delta.map(Math.abs);g.addTo(t.distance,D),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&i>0&&(t.velocity=[D[0]/i,D[1]/i],t.timeDelta=i)}}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 Ue([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 Ke extends je{constructor(...e){super(...e),_(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=g.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=g.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[ae(e)]:n.axisThreshold;t.axis=Ue(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 le=r=>r,de=.15,X={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[de,de];case!1:return[0,0];default:return g.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return g.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||le;return i=>{const c=s(i);return(!isFinite(c[0])||!isFinite(c[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${c[0]},${[1]}]`),c}}return n||le},threshold(r){return g.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(X,{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 Be=0,j=d(d({},X),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=Be){return r},bounds(r={}){if(typeof r=="function")return i=>j.bounds(r(i));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]]}}),he={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 ze extends Ke{constructor(...e){super(...e),_(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=j.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=G(e),n._pointerActive=!0,this.computeValues(ue(e)),this.computeInitial(),t.preventScrollAxis&&ae(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=G(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;const i=ue(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=g.sub(i,t._values),this.computeValues(i)),g.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=G(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[i,c]=t._distance;if(t.tap=i<=n.tapsThreshold&&c<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[a,u]=t._delta,[h,f]=t._movement,[S,v]=n.swipe.velocity,[M,A]=n.swipe.distance,T=n.swipe.duration;if(t.elapsedTime<T){const L=Math.abs(a/t.timeDelta),I=Math.abs(u/t.timeDelta);L>S&&Math.abs(h)>M&&(t.swipe[0]=Math.sign(a)),I>v&&Math.abs(f)>A&&(t.swipe[1]=Math.sign(u))}}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,Ye(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=he[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,g.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in he&&(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 Ye(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const U=typeof window<"u"&&window.document&&window.document.createElement;function pe(){return U&&"ontouchstart"in window}function We(){return pe()||U&&window.navigator.maxTouchPoints>1}function Fe(){return U&&"onpointerdown"in window}function He(){return U&&"exitPointerLock"in window.document}function Ge(){try{return"constructor"in GestureEvent}catch{return!1}}const x={isBrowser:U,gesture:Ge(),touch:pe(),touchscreen:We(),pointer:Fe(),pointerLock:He()},Xe=250,qe=180,Je=.5,Qe=50,Ze=250,et=10,me={mouse:0,touch:0,pen:8},ge=d(d({},j),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&x.pointerLock,x.touch&&t?"touch":this.pointerLock?"mouse":x.pointer&&!s?"pointer":x.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?Xe:void 0,!(!x.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 i=g.toVector(r,t?n:s?1:0);return this.filterTaps=t,this.tapsThreshold=n,i},swipe({velocity:r=Je,distance:e=Qe,duration:t=Ze}={}){return{velocity:this.transform(g.toVector(r)),distance:this.transform(g.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return qe;case!1:return 0;default:return r}},axisThreshold(r){return r?d(d({},me),r):me},keyboardDisplacement(r=et){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({},X),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!x.touch&&x.gesture)return"gesture";if(x.touch&&n)return"touch";if(x.touchscreen){if(x.pointer)return"pointer";if(x.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const s=c=>{const a=fe(W(t,c),{min:-1/0,max:1/0});return[a.min,a.max]},i=c=>{const a=fe(W(n,c),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof n!="function"?[s(),i()]:c=>[s(c),i(c)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",g.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}}),d(d({},j),{},{mouseOnly:(r=!0)=>r}),d(d({},j),{},{mouseOnly:(r=!0)=>r});const ve=new Map,q=new Map;function tt(r){ve.set(r.key,r.engine),q.set(r.key,r.resolver)}const rt={key:"drag",engine:ze,resolver:ge};function nt(r,e){if(r==null)return{};var t={},n=Object.keys(r),s,i;for(i=0;i<n.length;i++)s=n[i],!(e.indexOf(s)>=0)&&(t[s]=r[s]);return t}function st(r,e){if(r==null)return{};var t=nt(r,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const it={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=x.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},ot=["target","eventOptions","window","enabled","transform"];function F(r={},e){const t={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const i=s.call(t,r[n],n,r);Number.isNaN(i)||(t[n]=i)}else t[n]=s.call(t,r[n],n,r);break;case"object":t[n]=F(r[n],s);break;case"boolean":s&&(t[n]=r[n]);break}return t}function at(r,e,t={}){const n=r,{target:s,eventOptions:i,window:c,enabled:a,transform:u}=n,h=st(n,ot);if(t.shared=F({target:s,eventOptions:i,window:c,enabled:a,transform:u},it),e){const f=q.get(e);t[e]=F(d({shared:t.shared},h),f)}else for(const f in h){const S=q.get(f);if(S)t[f]=F(d({shared:t.shared},h[f]),S);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(f)){if(f==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${f}\` was used. Please read the documentation for further information.`)}}return t}class ye{constructor(e,t){_(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,s,i){const c=this._listeners,a=Ae(t,n),u=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},h=d(d({},u),i);e.addEventListener(a,s,h);const f=()=>{e.removeEventListener(a,s,h),c.delete(f)};return c.add(f),f}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class ct{constructor(){_(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 ut{constructor(e){_(this,"gestures",new Set),_(this,"_targetEventStore",new ye(this)),_(this,"gestureEventStores",{}),_(this,"gestureTimeoutStores",{}),_(this,"handlers",{}),_(this,"config",{}),_(this,"pointerIds",new Set),_(this,"touchIds",new Set),_(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),ft(this,e)}setEventIds(e){if(Y(e))return this.touchIds=new Set(Ne(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=at(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 c of this.gestures){const a=this.config[c],u=_e(n,a.eventOptions,!!s);if(a.enabled){const h=ve.get(c);new h(this,e,c).bind(u)}}const i=_e(n,t.eventOptions,!!s);for(const c in this.nativeHandlers)i(c,"",a=>this.nativeHandlers[c](d(d({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const i in n)n[i]=Re(...n[i]);if(!s)return n;for(const i in n){const{device:c,capture:a,passive:u}=Oe(i);this._targetEventStore.add(s,c,"",n[i],{capture:a,passive:u})}}}}function R(r,e){r.gestures.add(e),r.gestureEventStores[e]=new ye(r,e),r.gestureTimeoutStores[e]=new ct}function ft(r,e){e.drag&&R(r,"drag"),e.wheel&&R(r,"wheel"),e.scroll&&R(r,"scroll"),e.move&&R(r,"move"),e.pinch&&R(r,"pinch"),e.hover&&R(r,"hover")}const _e=(r,e,t)=>(n,s,i,c={},a=!1)=>{var u,h;const f=(u=c.capture)!==null&&u!==void 0?u:e.capture,S=(h=c.passive)!==null&&h!==void 0?h:e.passive;let v=a?n:ke(n,s,f);t&&S&&(v+="Passive"),r[v]=r[v]||[],r[v].push(i)};function lt(r,e={},t,n){const s=y.useMemo(()=>new ut(r),[]);if(s.applyHandlers(r,n),s.applyConfig(e,t),y.useEffect(s.effect.bind(s)),y.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function dt(r,e){return tt(rt),lt({drag:r},e||{},"drag")}const J="RSC::Event";function ht(){const r=y.useRef(null);function e(n){y.useEffect(()=>{r.current||(r.current=document.createElement("div"));function s(i){n(i.detail)}if(r.current)return r.current.addEventListener(J,s,!1),()=>{var i;(i=r.current)==null||i.removeEventListener(J,s,!1)}},[n])}function t(n){if(r.current){const s=new CustomEvent(J,{detail:n});r.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:t}}function pt({init:r=!0,items:e,withLoop:t=!1,id:n,itemsPerSlide:s=1,gutter:i=0,startEndGutter:c=0,carouselAxis:a="x",slideType:u="fixed",startingPosition:h="start",enableGestures:f=!0,slideWhenDragThresholdIsReached:S=!0,onInit:v}){const M=y.useRef(r),A=y.useRef(null),T=y.useRef(null),L=y.useRef(0),I=y.useRef(!t),P=y.useRef(!1),K=y.useRef(0),p=y.useRef(0),[V,D]=we.useSpring(()=>({value:0,onChange({value:o}){(u==="fixed"||u==="fluid")&&A.current.style.setProperty(`--${n}-offset-position`,`${o.value}px`),u==="freeScroll"&&(T.current[a==="x"?"scrollLeft":"scrollTop"]=Math.abs(o.value))}}),[a]),Q=u!=="freeScroll"&&t?[...e.map(o=>({...o,id:`prev-repeated-item-${o.id}`,isClonedItem:!0})),...e,...e.map(o=>({...o,id:`next-repeated-item-${o.id}`,isClonedItem:!0}))]:e,{useListenToCustomEvent:be,emitEvent:B}=ht();function Z(o){M.current&&(P.current||z({type:"next",toIndex:o,actionType:"click"}))}function ee(o){M.current&&(I.current||z({type:"prev",toIndex:o,actionType:"click"}))}function z({type:o,shouldAnimate:l=!0,toIndex:k,actionType:b}){const m=H(),$=!l;I.current=!1,P.current=!1;let C=V.value.get(),w=0;if(o==="next"&&(p.current+=1),o==="prev"&&(p.current===0?p.current=e.length-1:p.current-=1),k!==void 0&&(p.current=k),u!=="freeScroll"&&o==="next"){const E=te(t?m*(e.length*2):0);w=-(p.current*m),E-Math.abs(w)<m/1.2&&u==="fluid"&&!t&&(w=-E),!t&&Math.abs(w)>=E&&(P.current=!0,w=-E),t&&p.current===e.length&&(p.current=0,C=C+m*e.length,w=0)}if(u!=="freeScroll"&&o==="prev"&&(w=-(p.current*m),p.current===e.length-1&&(C=C-e.length*m),!t&&w>=0&&(I.current=!0,w=0)),u==="freeScroll"&&o==="next"){const E=T.current[a==="x"?"scrollLeft":"scrollTop"];C=E,w=E+m}if(u==="freeScroll"&&o==="prev"){const E=T.current[a==="x"?"scrollLeft":"scrollTop"];C=E,w=E-m}L.current=w,B(b==="resize"?{eventName:"onResize",sliceActionType:b,slideDirection:o,currentItem:{index:p.current,id:e.at(p.current).id,startReached:I.current,endReached:P.current}}:{eventName:"onSlideStartChange",sliceActionType:b,slideDirection:o,nextItem:{index:p.current,id:e.at(p.current).id,startReached:I.current,endReached:P.current}}),D.start({immediate:$,from:{value:C},to:{value:w},onRest({finished:E}){E&&u==="fixed"&&B({eventName:"onSlideChangeComplete",sliceActionType:b,slideDirection:o,currentItem:{index:p.current,id:e.at(p.current).id,startReached:I.current,endReached:P.current}}),E&&u==="fluid"&&B({eventName:"onSlideChangeComplete",sliceActionType:b,slideDirection:o,currentItem:{index:0,id:"",startReached:I.current,endReached:P.current}})}})}function H(){const o=T.current.children[0];let l=0;return l=o.getBoundingClientRect()[a==="x"?"width":"height"]+i,l}function te(o){const l=T.current;return l[a==="x"?"scrollWidth":"scrollHeight"]-l.getBoundingClientRect()[a==="x"?"width":"height"]-o}function mt(){let o=0;const l=getComputedStyle(document.documentElement).getPropertyValue(`--${n}-start-end-gutter`);return l.includes("px")&&(o=Number(l.replace("px",""))),{totalStartEndGutterCssVar:o}}y.useEffect(()=>{function o(b,m){switch(b){case"start":return 0;case"middle-start":return Math.floor((m-1)*.25);case"center":return Math.floor((m-1)*.5);case"middle-end":return Math.floor((m-1)*.75);case"end":return m-1;default:return 0}}function l(b){if(A.current){const{totalStartEndGutterCssVar:m}=mt();document.documentElement.style.setProperty(`--${n}-start-end-gutter`,`${m}px`);let $=0;t&&($=H()*e.length),$-=H()*o(h,s),$-=m,A.current.style.setProperty(`--${n}-offset-modifier`,`${-$}px`),b&&b()}}function k(){l(),z({type:"next",toIndex:p.current,shouldAnimate:!1,actionType:"resize"})}if(r&&(K.current=H()/4),r&&u==="fixed")return l(v),window.addEventListener("resize",k),()=>{window.removeEventListener("resize",k)}},[r,t,n,a,i,h,u]);const gt=dt(o=>{if(!M.current)return;const l=o.dragging,k=o.offset[a==="x"?0:1],b=o.movement[a==="x"?0:1],m=b>K.current,$=b<-K.current,C=o.velocity;l&&(B({...o,eventName:"onDrag",slideActionType:"drag"}),D.start({value:k,immediate:!0,config:{velocity:C}}),S&&(m||$)&&o.cancel()),o.last&&(m?z({actionType:"drag",type:"prev"}):$?z({actionType:"drag",type:"next"}):D.start({value:L.current,config:{velocity:C}}))},{enabled:f&&u!=="freeScroll",axis:a,rubberband:!t,...t?{}:{bounds:()=>({right:0,left:-te(0),top:-te(0),bottom:0})},from:()=>[V.value.get(),V.value.get()]});return{carouselFragment:N.jsxs("div",{ref:A,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,children:[N.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
2
|
+
:root {
|
|
3
|
+
--${n}-start-end-gutter: ${c*2}px;
|
|
4
|
+
--${n}-gutter: ${i}px;
|
|
5
|
+
}
|
|
2
6
|
[data-part-internal="${n}-Container"] {
|
|
3
7
|
display: flex;
|
|
4
8
|
width: 100%;
|
|
5
9
|
height: 100%;
|
|
6
10
|
overflow: hidden;
|
|
7
|
-
--${n}-gutter: ${i}px;
|
|
8
11
|
--${n}-items-per-slide: ${s};
|
|
9
12
|
--${n}-offset-position: 0px;
|
|
10
13
|
--${n}-offset-modifier: 0px;
|
|
11
14
|
--${n}-scroll-x-value: ${u!=="freeScroll"&&a==="x"?`calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))`:"0px"};
|
|
12
15
|
--${n}-scroll-y-value: ${u!=="freeScroll"&&a==="y"?`calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))`:"0px"};
|
|
13
|
-
|
|
16
|
+
|
|
14
17
|
}
|
|
15
18
|
[data-part-internal="${n}-Track"] {
|
|
16
19
|
display: flex;
|
|
@@ -26,4 +29,4 @@
|
|
|
26
29
|
display: flex;
|
|
27
30
|
flex: ${u==="fixed"?`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)))`:"1"};
|
|
28
31
|
}
|
|
29
|
-
`}})
|
|
32
|
+
`}}),N.jsx("div",{ref:T,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track`,...gt(),...u==="freeScroll"?{onWheel(){V.value.stop()}}:{},children:Q.map((o,l)=>N.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,"data-id":o.id,children:typeof o.renderItem=="function"?o.renderItem({useListenToCustomEvent:be,index:l,isClonedItem:!!o.isClonedItem}):o.renderItem},`${o.id}-${l}`))})]}),useListenToCustomEvent:be,slideToNextItem:()=>Z(),slideToPrevItem:()=>ee(),slideToItem:o=>{if(typeof o=="number"){if(!e[o]){console.warn(`The item you're trying to slide doesn't exist. index: ${o}`);return}o>p.current?Z(o):ee(o)}if(typeof o=="string"){const l=e.findIndex(k=>k.id===o);if(l<0){console.warn(`The item you're trying to slide doesn't exist. id: ${o}`);return}l>p.current?Z(l):ee(l)}}}}O.useSpringCarousel=pt,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
|