react-spring-carousel 3.0.0-beta-2.0.41 → 3.0.0-beta-2.0.43
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 +149 -154
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as Lt, jsx as q } from "react/jsx-runtime";
|
|
2
2
|
import { useSpring as wt } from "@react-spring/web";
|
|
3
|
-
import J, { useRef as
|
|
3
|
+
import J, { useRef as $, useEffect as R, useState as Mt } from "react";
|
|
4
4
|
function Vt(e, t, r) {
|
|
5
5
|
return Math.max(t, Math.min(e, r));
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const b = {
|
|
8
8
|
toVector(e, t) {
|
|
9
9
|
return e === void 0 && (e = t), Array.isArray(e) ? e : [e, e];
|
|
10
10
|
},
|
|
@@ -41,12 +41,12 @@ function jt(e, t) {
|
|
|
41
41
|
}
|
|
42
42
|
return (t === "string" ? String : Number)(e);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function Bt(e) {
|
|
45
45
|
var t = jt(e, "string");
|
|
46
46
|
return typeof t == "symbol" ? t : String(t);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
return t =
|
|
48
|
+
function S(e, t, r) {
|
|
49
|
+
return t = Bt(t), t in e ? Object.defineProperty(e, t, {
|
|
50
50
|
value: r,
|
|
51
51
|
enumerable: !0,
|
|
52
52
|
configurable: !0,
|
|
@@ -67,7 +67,7 @@ function p(e) {
|
|
|
67
67
|
for (var t = 1; t < arguments.length; t++) {
|
|
68
68
|
var r = arguments[t] != null ? arguments[t] : {};
|
|
69
69
|
t % 2 ? ft(Object(r), !0).forEach(function(n) {
|
|
70
|
-
|
|
70
|
+
S(e, n, r[n]);
|
|
71
71
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : ft(Object(r)).forEach(function(n) {
|
|
72
72
|
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
|
|
73
73
|
});
|
|
@@ -99,9 +99,9 @@ const Et = {
|
|
|
99
99
|
function dt(e) {
|
|
100
100
|
return e ? e[0].toUpperCase() + e.slice(1) : "";
|
|
101
101
|
}
|
|
102
|
-
const
|
|
102
|
+
const Ut = ["enter", "leave"];
|
|
103
103
|
function Kt(e = !1, t) {
|
|
104
|
-
return e && !
|
|
104
|
+
return e && !Ut.includes(t);
|
|
105
105
|
}
|
|
106
106
|
function Gt(e, t = "", r = !1) {
|
|
107
107
|
const n = Et[e], s = n && n[t] || t;
|
|
@@ -246,7 +246,7 @@ class te {
|
|
|
246
246
|
let o = 0;
|
|
247
247
|
if (t && (r.event = t, n.preventDefault && t.cancelable && r.event.preventDefault(), r.type = t.type, s.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, s.locked = !!document.pointerLockElement, Object.assign(s, qt(t)), s.down = s.pressed = s.buttons % 2 === 1 || s.touches > 0, o = t.timeStamp - r.timeStamp, r.timeStamp = t.timeStamp, r.elapsedTime = r.timeStamp - r.startTime), r._active) {
|
|
248
248
|
const d = r._delta.map(Math.abs);
|
|
249
|
-
|
|
249
|
+
b.addTo(r._distance, d);
|
|
250
250
|
}
|
|
251
251
|
this.axisIntent && this.axisIntent(t);
|
|
252
252
|
const [a, c] = r._movement, [l, h] = n.threshold, {
|
|
@@ -261,15 +261,15 @@ class te {
|
|
|
261
261
|
} else
|
|
262
262
|
m[0] = u[0] !== !1 ? a - u[0] : 0, m[1] = u[1] !== !1 ? c - u[1] : 0;
|
|
263
263
|
this.restrictToAxis && !r._blocked && this.restrictToAxis(m);
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
const [
|
|
267
|
-
r.overflow = [
|
|
264
|
+
const D = r.offset, _ = r._active && !r._blocked || r.active;
|
|
265
|
+
_ && (r.first = r._active && !r.active, r.last = !r._active && r.active, r.active = s[this.ingKey] = r._active, t && (r.first && ("bounds" in n && (r._bounds = z(n.bounds, r)), this.setup && this.setup()), r.movement = m, this.computeOffset()));
|
|
266
|
+
const [E, P] = r.offset, [[A, w], [x, I]] = r._bounds;
|
|
267
|
+
r.overflow = [E < A ? -1 : E > w ? 1 : 0, P < x ? -1 : P > I ? 1 : 0], r._movementBound[0] = r.overflow[0] ? r._movementBound[0] === !1 ? r._movement[0] : r._movementBound[0] : !1, r._movementBound[1] = r.overflow[1] ? r._movementBound[1] === !1 ? r._movement[1] : r._movementBound[1] : !1;
|
|
268
268
|
const M = r._active ? n.rubberband || [0, 0] : [0, 0];
|
|
269
|
-
if (r.offset = Rt(r._bounds, r.offset, M), r.delta =
|
|
270
|
-
r.delta =
|
|
269
|
+
if (r.offset = Rt(r._bounds, r.offset, M), r.delta = b.sub(r.offset, D), this.computeMovement(), _ && (!r.last || o > Zt)) {
|
|
270
|
+
r.delta = b.sub(r.offset, D);
|
|
271
271
|
const d = r.delta.map(Math.abs);
|
|
272
|
-
|
|
272
|
+
b.addTo(r.distance, d), r.direction = r.delta.map(Math.sign), r._direction = r._delta.map(Math.sign), !r.first && o > 0 && (r.velocity = [d[0] / o, d[1] / o], r.timeDelta = o);
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
emit() {
|
|
@@ -293,7 +293,7 @@ function ee([e, t], r) {
|
|
|
293
293
|
}
|
|
294
294
|
class re extends te {
|
|
295
295
|
constructor(...t) {
|
|
296
|
-
super(...t),
|
|
296
|
+
super(...t), S(this, "aliasKey", "xy");
|
|
297
297
|
}
|
|
298
298
|
reset() {
|
|
299
299
|
super.reset(), this.state.axis = void 0;
|
|
@@ -302,10 +302,10 @@ class re extends te {
|
|
|
302
302
|
this.state.offset = [0, 0], this.state.lastOffset = [0, 0];
|
|
303
303
|
}
|
|
304
304
|
computeOffset() {
|
|
305
|
-
this.state.offset =
|
|
305
|
+
this.state.offset = b.add(this.state.lastOffset, this.state.movement);
|
|
306
306
|
}
|
|
307
307
|
computeMovement() {
|
|
308
|
-
this.state.movement =
|
|
308
|
+
this.state.movement = b.sub(this.state.offset, this.state.lastOffset);
|
|
309
309
|
}
|
|
310
310
|
axisIntent(t) {
|
|
311
311
|
const r = this.state, n = this.config;
|
|
@@ -347,12 +347,12 @@ const mt = (e) => e, gt = 0.15, rt = {
|
|
|
347
347
|
case !1:
|
|
348
348
|
return [0, 0];
|
|
349
349
|
default:
|
|
350
|
-
return
|
|
350
|
+
return b.toVector(e);
|
|
351
351
|
}
|
|
352
352
|
},
|
|
353
353
|
from(e) {
|
|
354
354
|
if (typeof e == "function") return e;
|
|
355
|
-
if (e != null) return
|
|
355
|
+
if (e != null) return b.toVector(e);
|
|
356
356
|
},
|
|
357
357
|
transform(e, t, r) {
|
|
358
358
|
const n = e || r.shared.transform;
|
|
@@ -366,7 +366,7 @@ const mt = (e) => e, gt = 0.15, rt = {
|
|
|
366
366
|
return n || mt;
|
|
367
367
|
},
|
|
368
368
|
threshold(e) {
|
|
369
|
-
return
|
|
369
|
+
return b.toVector(e, 0);
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
372
|
process.env.NODE_ENV === "development" && Object.assign(rt, {
|
|
@@ -418,7 +418,7 @@ const ne = 0, j = p(p({}, rt), {}, {
|
|
|
418
418
|
};
|
|
419
419
|
class se extends re {
|
|
420
420
|
constructor(...t) {
|
|
421
|
-
super(...t),
|
|
421
|
+
super(...t), S(this, "ingKey", "dragging");
|
|
422
422
|
}
|
|
423
423
|
reset() {
|
|
424
424
|
super.reset();
|
|
@@ -465,7 +465,7 @@ class se extends re {
|
|
|
465
465
|
const s = Q(t);
|
|
466
466
|
if (r._pointerId !== void 0 && s !== r._pointerId) return;
|
|
467
467
|
const o = ht(t);
|
|
468
|
-
if (document.pointerLockElement === t.target ? r._delta = [t.movementX, t.movementY] : (r._delta =
|
|
468
|
+
if (document.pointerLockElement === t.target ? r._delta = [t.movementX, t.movementY] : (r._delta = b.sub(o, r._values), this.computeValues(o)), b.addTo(r._movement, r._delta), this.compute(t), r._delayed && r.intentional) {
|
|
469
469
|
this.timeoutStore.remove("dragDelay"), r.active = !1, this.startPointerDrag(t);
|
|
470
470
|
return;
|
|
471
471
|
}
|
|
@@ -498,10 +498,10 @@ class se extends re {
|
|
|
498
498
|
if (r.tap = o <= n.tapsThreshold && a <= n.tapsThreshold, r.tap && n.filterTaps)
|
|
499
499
|
r._force = !0;
|
|
500
500
|
else {
|
|
501
|
-
const [c, l] = r._delta, [h, u] = r._movement, [g, m] = n.swipe.velocity, [
|
|
502
|
-
if (r.elapsedTime <
|
|
503
|
-
const
|
|
504
|
-
|
|
501
|
+
const [c, l] = r._delta, [h, u] = r._movement, [g, m] = n.swipe.velocity, [D, _] = n.swipe.distance, E = n.swipe.duration;
|
|
502
|
+
if (r.elapsedTime < E) {
|
|
503
|
+
const P = Math.abs(c / r.timeDelta), A = Math.abs(l / r.timeDelta);
|
|
504
|
+
P > g && Math.abs(h) > D && (r.swipe[0] = Math.sign(c)), A > m && Math.abs(u) > _ && (r.swipe[1] = Math.sign(l));
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
this.emit();
|
|
@@ -543,7 +543,7 @@ class se extends re {
|
|
|
543
543
|
const r = vt[t.key];
|
|
544
544
|
if (r) {
|
|
545
545
|
const n = this.state, s = t.shiftKey ? 10 : t.altKey ? 0.1 : 1;
|
|
546
|
-
this.start(t), n._delta = r(this.config.keyboardDisplacement, s), n._keyboardActive = !0,
|
|
546
|
+
this.start(t), n._delta = r(this.config.keyboardDisplacement, s), n._keyboardActive = !0, b.addTo(n._movement, n._delta), this.compute(t), this.emit();
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
549
|
keyUp(t) {
|
|
@@ -560,18 +560,18 @@ class se extends re {
|
|
|
560
560
|
function ie(e) {
|
|
561
561
|
"persist" in e && typeof e.persist == "function" && e.persist();
|
|
562
562
|
}
|
|
563
|
-
const
|
|
563
|
+
const B = typeof window < "u" && window.document && window.document.createElement;
|
|
564
564
|
function xt() {
|
|
565
|
-
return
|
|
565
|
+
return B && "ontouchstart" in window;
|
|
566
566
|
}
|
|
567
567
|
function oe() {
|
|
568
|
-
return xt() ||
|
|
568
|
+
return xt() || B && window.navigator.maxTouchPoints > 1;
|
|
569
569
|
}
|
|
570
570
|
function ae() {
|
|
571
|
-
return
|
|
571
|
+
return B && "onpointerdown" in window;
|
|
572
572
|
}
|
|
573
573
|
function ce() {
|
|
574
|
-
return
|
|
574
|
+
return B && "exitPointerLock" in window.document;
|
|
575
575
|
}
|
|
576
576
|
function ue() {
|
|
577
577
|
try {
|
|
@@ -580,8 +580,8 @@ function ue() {
|
|
|
580
580
|
return !1;
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
|
-
const
|
|
584
|
-
isBrowser:
|
|
583
|
+
const O = {
|
|
584
|
+
isBrowser: B,
|
|
585
585
|
gesture: ue(),
|
|
586
586
|
touch: xt(),
|
|
587
587
|
touchscreen: oe(),
|
|
@@ -599,12 +599,12 @@ const P = {
|
|
|
599
599
|
mouse: s = !1
|
|
600
600
|
} = {}
|
|
601
601
|
}) {
|
|
602
|
-
return this.pointerLock = n &&
|
|
602
|
+
return this.pointerLock = n && O.pointerLock, O.touch && r ? "touch" : this.pointerLock ? "mouse" : O.pointer && !s ? "pointer" : O.touch ? "touch" : "mouse";
|
|
603
603
|
},
|
|
604
604
|
preventScrollAxis(e, t, {
|
|
605
605
|
preventScroll: r
|
|
606
606
|
}) {
|
|
607
|
-
if (this.preventScrollDelay = typeof r == "number" ? r : r || r === void 0 && e ? le : void 0, !(!
|
|
607
|
+
if (this.preventScrollDelay = typeof r == "number" ? r : r || r === void 0 && e ? le : void 0, !(!O.touchscreen || r === !1))
|
|
608
608
|
return e || (r !== void 0 ? "y" : void 0);
|
|
609
609
|
},
|
|
610
610
|
pointerCapture(e, t, {
|
|
@@ -621,7 +621,7 @@ const P = {
|
|
|
621
621
|
tapsThreshold: n = 3,
|
|
622
622
|
axis: s = void 0
|
|
623
623
|
}) {
|
|
624
|
-
const o =
|
|
624
|
+
const o = b.toVector(e, r ? n : s ? 1 : 0);
|
|
625
625
|
return this.filterTaps = r, this.tapsThreshold = n, o;
|
|
626
626
|
},
|
|
627
627
|
swipe({
|
|
@@ -630,8 +630,8 @@ const P = {
|
|
|
630
630
|
duration: r = pe
|
|
631
631
|
} = {}) {
|
|
632
632
|
return {
|
|
633
|
-
velocity: this.transform(
|
|
634
|
-
distance: this.transform(
|
|
633
|
+
velocity: this.transform(b.toVector(e)),
|
|
634
|
+
distance: this.transform(b.toVector(t)),
|
|
635
635
|
duration: r
|
|
636
636
|
};
|
|
637
637
|
},
|
|
@@ -686,11 +686,11 @@ p(p({}, rt), {}, {
|
|
|
686
686
|
touch: n = !1
|
|
687
687
|
} = {}
|
|
688
688
|
}) {
|
|
689
|
-
if (r.target && !
|
|
690
|
-
if (
|
|
691
|
-
if (
|
|
692
|
-
if (
|
|
693
|
-
if (
|
|
689
|
+
if (r.target && !O.touch && O.gesture) return "gesture";
|
|
690
|
+
if (O.touch && n) return "touch";
|
|
691
|
+
if (O.touchscreen) {
|
|
692
|
+
if (O.pointer) return "pointer";
|
|
693
|
+
if (O.touch) return "touch";
|
|
694
694
|
}
|
|
695
695
|
},
|
|
696
696
|
bounds(e, t, {
|
|
@@ -713,7 +713,7 @@ p(p({}, rt), {}, {
|
|
|
713
713
|
return typeof r != "function" && typeof n != "function" ? [s(), o()] : (a) => [s(a), o(a)];
|
|
714
714
|
},
|
|
715
715
|
threshold(e, t, r) {
|
|
716
|
-
return this.lockDirection = r.axis === "lock",
|
|
716
|
+
return this.lockDirection = r.axis === "lock", b.toVector(e, this.lockDirection ? [0.1, 3] : 0);
|
|
717
717
|
},
|
|
718
718
|
modifierKey(e) {
|
|
719
719
|
return e === void 0 ? "ctrlKey" : e;
|
|
@@ -762,7 +762,7 @@ const _e = {
|
|
|
762
762
|
enabled(e = !0) {
|
|
763
763
|
return e;
|
|
764
764
|
},
|
|
765
|
-
window(e =
|
|
765
|
+
window(e = O.isBrowser ? window : void 0) {
|
|
766
766
|
return e;
|
|
767
767
|
},
|
|
768
768
|
eventOptions({
|
|
@@ -834,7 +834,7 @@ function Ee(e, t, r = {}) {
|
|
|
834
834
|
}
|
|
835
835
|
class Ct {
|
|
836
836
|
constructor(t, r) {
|
|
837
|
-
|
|
837
|
+
S(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = t, this._gestureKey = r;
|
|
838
838
|
}
|
|
839
839
|
add(t, r, n, s, o) {
|
|
840
840
|
const a = this._listeners, c = Yt(r, n), l = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, h = p(p({}, l), o);
|
|
@@ -850,7 +850,7 @@ class Ct {
|
|
|
850
850
|
}
|
|
851
851
|
class Te {
|
|
852
852
|
constructor() {
|
|
853
|
-
|
|
853
|
+
S(this, "_timeouts", /* @__PURE__ */ new Map());
|
|
854
854
|
}
|
|
855
855
|
add(t, r, n = 140, ...s) {
|
|
856
856
|
this.remove(t), this._timeouts.set(t, window.setTimeout(r, n, ...s));
|
|
@@ -865,7 +865,7 @@ class Te {
|
|
|
865
865
|
}
|
|
866
866
|
class Se {
|
|
867
867
|
constructor(t) {
|
|
868
|
-
|
|
868
|
+
S(this, "gestures", /* @__PURE__ */ new Set()), S(this, "_targetEventStore", new Ct(this)), S(this, "gestureEventStores", {}), S(this, "gestureTimeoutStores", {}), S(this, "handlers", {}), S(this, "config", {}), S(this, "pointerIds", /* @__PURE__ */ new Set()), S(this, "touchIds", /* @__PURE__ */ new Set()), S(this, "state", {
|
|
869
869
|
shared: {
|
|
870
870
|
shiftKey: !1,
|
|
871
871
|
metaKey: !1,
|
|
@@ -930,11 +930,11 @@ class Se {
|
|
|
930
930
|
}
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
|
-
function
|
|
933
|
+
function L(e, t) {
|
|
934
934
|
e.gestures.add(t), e.gestureEventStores[t] = new Ct(e, t), e.gestureTimeoutStores[t] = new Te();
|
|
935
935
|
}
|
|
936
936
|
function xe(e, t) {
|
|
937
|
-
t.drag &&
|
|
937
|
+
t.drag && L(e, "drag"), t.wheel && L(e, "wheel"), t.scroll && L(e, "scroll"), t.move && L(e, "move"), t.pinch && L(e, "pinch"), t.hover && L(e, "hover");
|
|
938
938
|
}
|
|
939
939
|
const bt = (e, t, r) => (n, s, o, a = {}, c = !1) => {
|
|
940
940
|
var l, h;
|
|
@@ -954,7 +954,7 @@ function ke(e, t) {
|
|
|
954
954
|
}
|
|
955
955
|
const Z = "RSC::Event";
|
|
956
956
|
function Ce() {
|
|
957
|
-
const e =
|
|
957
|
+
const e = $(null);
|
|
958
958
|
function t(n) {
|
|
959
959
|
R(() => {
|
|
960
960
|
e.current || (e.current = document.createElement("div"));
|
|
@@ -989,7 +989,7 @@ function De(e) {
|
|
|
989
989
|
let t = e.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm, "");
|
|
990
990
|
return t = t.replace(/[\n\t]+/g, " "), t = t.replace(/\s*([{}:;,])\s*/g, "$1"), t = t.replace(/\s+}/g, "}"), t = t.replace(/{\s+/g, "{"), t = t.replace(/\s+/g, " "), t.trim();
|
|
991
991
|
}
|
|
992
|
-
function
|
|
992
|
+
function Le({
|
|
993
993
|
init: e = !0,
|
|
994
994
|
items: t,
|
|
995
995
|
withLoop: r = !1,
|
|
@@ -1003,14 +1003,11 @@ function Ne({
|
|
|
1003
1003
|
onInit: u,
|
|
1004
1004
|
initialActiveItem: g = 0
|
|
1005
1005
|
}) {
|
|
1006
|
-
const [m,
|
|
1006
|
+
const [m, D] = Mt(!1), _ = $(e), E = $(null), P = $(null), A = $(0), w = $(0), x = $(!r), I = $(!1), M = $(0), d = $(0), [V, Y] = wt(
|
|
1007
1007
|
() => ({
|
|
1008
1008
|
value: 0,
|
|
1009
1009
|
onChange({ value: i }) {
|
|
1010
|
-
|
|
1011
|
-
`--${n}-offset-position`,
|
|
1012
|
-
`${i.value}px`
|
|
1013
|
-
);
|
|
1010
|
+
P.current.style.transform = `translate3d(${i.value}px, 0px, 0px)`;
|
|
1014
1011
|
}
|
|
1015
1012
|
}),
|
|
1016
1013
|
[a]
|
|
@@ -1026,147 +1023,147 @@ function Ne({
|
|
|
1026
1023
|
id: `next-repeated-item-${i.id}`,
|
|
1027
1024
|
isClonedItem: !0
|
|
1028
1025
|
}))
|
|
1029
|
-
] : t, { useListenToCustomEvent: nt, emitEvent:
|
|
1026
|
+
] : t, { useListenToCustomEvent: nt, emitEvent: U } = Ce();
|
|
1030
1027
|
function Pt() {
|
|
1031
1028
|
const { totalGutterCssVar: i } = st();
|
|
1032
1029
|
return i;
|
|
1033
1030
|
}
|
|
1034
1031
|
function $t() {
|
|
1035
|
-
if (
|
|
1032
|
+
if (E.current) {
|
|
1036
1033
|
const f = window.getComputedStyle(
|
|
1037
|
-
|
|
1034
|
+
E.current
|
|
1038
1035
|
).getPropertyValue(`--${n}-items-per-slide`).trim();
|
|
1039
1036
|
return Number(f) || 1;
|
|
1040
1037
|
}
|
|
1041
1038
|
return 1;
|
|
1042
1039
|
}
|
|
1043
1040
|
function F(i) {
|
|
1044
|
-
|
|
1041
|
+
_.current && (I.current || N({
|
|
1045
1042
|
type: "next",
|
|
1046
1043
|
toIndex: i,
|
|
1047
1044
|
actionType: "click"
|
|
1048
1045
|
}));
|
|
1049
1046
|
}
|
|
1050
1047
|
function H(i) {
|
|
1051
|
-
|
|
1048
|
+
_.current && (x.current || N({
|
|
1052
1049
|
type: "prev",
|
|
1053
1050
|
toIndex: i,
|
|
1054
1051
|
actionType: "click"
|
|
1055
1052
|
}));
|
|
1056
1053
|
}
|
|
1057
|
-
function
|
|
1054
|
+
function N({
|
|
1058
1055
|
type: i,
|
|
1059
1056
|
shouldAnimate: f = !0,
|
|
1060
|
-
toIndex:
|
|
1061
|
-
actionType:
|
|
1057
|
+
toIndex: y,
|
|
1058
|
+
actionType: v
|
|
1062
1059
|
}) {
|
|
1063
1060
|
var ot, at;
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1066
|
-
let
|
|
1067
|
-
if (i === "next" && (d.current += 1), i === "prev" && (d.current === 0 ? d.current = t.length - 1 : d.current -= 1),
|
|
1061
|
+
const T = !f;
|
|
1062
|
+
x.current = !1, I.current = !1;
|
|
1063
|
+
let k = V.value.get(), C = 0;
|
|
1064
|
+
if (i === "next" && (d.current += 1), i === "prev" && (d.current === 0 ? d.current = t.length - 1 : d.current -= 1), y !== void 0 && (d.current = y), i === "next") {
|
|
1068
1065
|
const K = X(
|
|
1069
|
-
r ?
|
|
1066
|
+
r ? w.current * (t.length * 2) : 0
|
|
1070
1067
|
);
|
|
1071
|
-
|
|
1068
|
+
C = -(d.current * w.current), r && d.current === t.length && (d.current = 0, k = k + w.current * t.length, C = 0), !r && Math.abs(C) >= K && (I.current = !0, C = -K);
|
|
1072
1069
|
}
|
|
1073
|
-
i === "prev" && (
|
|
1070
|
+
i === "prev" && (C = -(d.current * w.current), d.current === t.length - 1 && (k = k - t.length * w.current), !r && C >= 0 && (x.current = !0, C = 0)), A.current = C, v === "resize" ? (C = -(d.current * w.current), U({
|
|
1074
1071
|
eventName: "onResize",
|
|
1075
|
-
sliceActionType:
|
|
1072
|
+
sliceActionType: v,
|
|
1076
1073
|
slideDirection: i,
|
|
1077
1074
|
currentItem: {
|
|
1078
1075
|
index: d.current,
|
|
1079
1076
|
id: ((ot = t.at(d.current)) == null ? void 0 : ot.id) ?? "",
|
|
1080
|
-
startReached:
|
|
1081
|
-
endReached:
|
|
1077
|
+
startReached: x.current,
|
|
1078
|
+
endReached: I.current
|
|
1082
1079
|
}
|
|
1083
|
-
})) :
|
|
1080
|
+
})) : U({
|
|
1084
1081
|
eventName: "onSlideStartChange",
|
|
1085
|
-
sliceActionType:
|
|
1082
|
+
sliceActionType: v,
|
|
1086
1083
|
slideDirection: i,
|
|
1087
1084
|
nextItem: {
|
|
1088
1085
|
index: d.current,
|
|
1089
1086
|
id: ((at = t.at(d.current)) == null ? void 0 : at.id) ?? "",
|
|
1090
|
-
startReached:
|
|
1091
|
-
endReached:
|
|
1087
|
+
startReached: x.current,
|
|
1088
|
+
endReached: I.current
|
|
1092
1089
|
}
|
|
1093
1090
|
}), Y.start({
|
|
1094
|
-
immediate:
|
|
1091
|
+
immediate: T,
|
|
1095
1092
|
from: {
|
|
1096
|
-
value:
|
|
1093
|
+
value: k
|
|
1097
1094
|
},
|
|
1098
1095
|
to: {
|
|
1099
|
-
value:
|
|
1096
|
+
value: C
|
|
1100
1097
|
},
|
|
1101
1098
|
onRest({ finished: K }) {
|
|
1102
1099
|
var ct;
|
|
1103
|
-
K &&
|
|
1100
|
+
K && U({
|
|
1104
1101
|
eventName: "onSlideChangeComplete",
|
|
1105
|
-
sliceActionType:
|
|
1102
|
+
sliceActionType: v,
|
|
1106
1103
|
slideDirection: i,
|
|
1107
1104
|
currentItem: {
|
|
1108
1105
|
index: d.current,
|
|
1109
1106
|
id: ((ct = t.at(d.current)) == null ? void 0 : ct.id) ?? "",
|
|
1110
|
-
startReached:
|
|
1111
|
-
endReached:
|
|
1107
|
+
startReached: x.current,
|
|
1108
|
+
endReached: I.current
|
|
1112
1109
|
}
|
|
1113
1110
|
});
|
|
1114
1111
|
}
|
|
1115
1112
|
});
|
|
1116
1113
|
}
|
|
1117
1114
|
function Ot() {
|
|
1118
|
-
const i =
|
|
1115
|
+
const i = P.current.children[0];
|
|
1119
1116
|
let f = 0;
|
|
1120
1117
|
return f = i.getBoundingClientRect()[a === "x" ? "width" : "height"] + Pt(), f;
|
|
1121
1118
|
}
|
|
1122
1119
|
function X(i) {
|
|
1123
|
-
const f =
|
|
1120
|
+
const f = P.current;
|
|
1124
1121
|
return f[a === "x" ? "scrollWidth" : "scrollHeight"] - f.getBoundingClientRect()[a === "x" ? "width" : "height"] - i;
|
|
1125
1122
|
}
|
|
1126
1123
|
function st() {
|
|
1127
1124
|
let i = 0, f = 0;
|
|
1128
|
-
if (
|
|
1129
|
-
const
|
|
1130
|
-
|
|
1131
|
-
),
|
|
1132
|
-
|
|
1133
|
-
|
|
1125
|
+
if (E.current) {
|
|
1126
|
+
const y = window.getComputedStyle(
|
|
1127
|
+
E.current
|
|
1128
|
+
), v = y.getPropertyValue(`--${n}-start-end-gutter`).trim();
|
|
1129
|
+
v.includes("px") && (i = Number(
|
|
1130
|
+
v.replace("px", "")
|
|
1134
1131
|
));
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1132
|
+
const T = y.getPropertyValue(`--${n}-gutter`).trim();
|
|
1133
|
+
T.includes("px") && (f = Number(T.replace("px", "")));
|
|
1137
1134
|
}
|
|
1138
1135
|
return { totalStartEndGutterCssVar: i, totalGutterCssVar: f };
|
|
1139
1136
|
}
|
|
1140
1137
|
R(() => {
|
|
1141
|
-
function i(
|
|
1142
|
-
const
|
|
1143
|
-
switch (
|
|
1138
|
+
function i(v) {
|
|
1139
|
+
const T = $t();
|
|
1140
|
+
switch (v) {
|
|
1144
1141
|
case "start":
|
|
1145
1142
|
return 0;
|
|
1146
1143
|
case "middle-start":
|
|
1147
|
-
return Math.floor((
|
|
1144
|
+
return Math.floor((T - 1) * 0.25);
|
|
1148
1145
|
case "center":
|
|
1149
|
-
return Math.floor((
|
|
1146
|
+
return Math.floor((T - 1) * 0.5);
|
|
1150
1147
|
case "middle-end":
|
|
1151
|
-
return Math.floor((
|
|
1148
|
+
return Math.floor((T - 1) * 0.75);
|
|
1152
1149
|
case "end":
|
|
1153
|
-
return
|
|
1150
|
+
return T - 1;
|
|
1154
1151
|
default:
|
|
1155
1152
|
return 0;
|
|
1156
1153
|
}
|
|
1157
1154
|
}
|
|
1158
|
-
function f(
|
|
1159
|
-
if (
|
|
1160
|
-
const { totalStartEndGutterCssVar:
|
|
1161
|
-
let
|
|
1162
|
-
r && (
|
|
1155
|
+
function f(v) {
|
|
1156
|
+
if (w.current = Ot(), M.current = w.current / 4, E.current) {
|
|
1157
|
+
const { totalStartEndGutterCssVar: T } = st();
|
|
1158
|
+
let k = 0;
|
|
1159
|
+
r && (k = w.current * t.length), k -= w.current * i(c), k -= T / 2, E.current.style.setProperty(
|
|
1163
1160
|
`--${n}-offset-modifier`,
|
|
1164
|
-
`${-
|
|
1165
|
-
),
|
|
1161
|
+
`${-k}px`
|
|
1162
|
+
), D(!0), v && v();
|
|
1166
1163
|
}
|
|
1167
1164
|
}
|
|
1168
|
-
function
|
|
1169
|
-
f(),
|
|
1165
|
+
function y() {
|
|
1166
|
+
f(), N({
|
|
1170
1167
|
type: "resize",
|
|
1171
1168
|
toIndex: d.current,
|
|
1172
1169
|
shouldAnimate: !1,
|
|
@@ -1174,11 +1171,11 @@ function Ne({
|
|
|
1174
1171
|
});
|
|
1175
1172
|
}
|
|
1176
1173
|
if (e)
|
|
1177
|
-
return
|
|
1178
|
-
window.removeEventListener("resize",
|
|
1174
|
+
return _.current = !0, f(u), window.addEventListener("resize", y), () => {
|
|
1175
|
+
window.removeEventListener("resize", y);
|
|
1179
1176
|
};
|
|
1180
1177
|
}, [e, r, n, a, s, c]), R(() => {
|
|
1181
|
-
e && g !== d.current &&
|
|
1178
|
+
e && g !== d.current && N({
|
|
1182
1179
|
type: "next",
|
|
1183
1180
|
toIndex: g,
|
|
1184
1181
|
actionType: "resize",
|
|
@@ -1187,29 +1184,29 @@ function Ne({
|
|
|
1187
1184
|
}, [e, g]);
|
|
1188
1185
|
const it = l, At = ke(
|
|
1189
1186
|
(i) => {
|
|
1190
|
-
if (!
|
|
1187
|
+
if (!_.current)
|
|
1191
1188
|
return;
|
|
1192
|
-
const f = i.dragging,
|
|
1193
|
-
f && (
|
|
1189
|
+
const f = i.dragging, y = i.offset[a === "x" ? 0 : 1], v = i.movement[a === "x" ? 0 : 1], T = v > M.current, k = v < -M.current, C = i.velocity;
|
|
1190
|
+
f && (U({
|
|
1194
1191
|
...i,
|
|
1195
1192
|
eventName: "onDrag",
|
|
1196
1193
|
slideActionType: "drag"
|
|
1197
1194
|
}), Y.start({
|
|
1198
|
-
value:
|
|
1195
|
+
value: y,
|
|
1199
1196
|
immediate: !0,
|
|
1200
1197
|
config: {
|
|
1201
|
-
velocity:
|
|
1198
|
+
velocity: C
|
|
1202
1199
|
}
|
|
1203
|
-
}), h && (
|
|
1200
|
+
}), h && (T || k) && i.cancel()), i.last && (T ? (N({
|
|
1204
1201
|
actionType: "drag",
|
|
1205
1202
|
type: "prev"
|
|
1206
|
-
}), i.cancel()) :
|
|
1203
|
+
}), i.cancel()) : k ? (N({
|
|
1207
1204
|
actionType: "drag",
|
|
1208
1205
|
type: "next"
|
|
1209
1206
|
}), i.cancel()) : (Y.start({
|
|
1210
|
-
value:
|
|
1207
|
+
value: A.current,
|
|
1211
1208
|
config: {
|
|
1212
|
-
velocity:
|
|
1209
|
+
velocity: C
|
|
1213
1210
|
}
|
|
1214
1211
|
}), i.cancel()));
|
|
1215
1212
|
},
|
|
@@ -1228,15 +1225,15 @@ function Ne({
|
|
|
1228
1225
|
from: () => [V.value.get(), V.value.get()]
|
|
1229
1226
|
}
|
|
1230
1227
|
);
|
|
1231
|
-
function
|
|
1232
|
-
var f,
|
|
1233
|
-
return typeof i == "number" ? d.current === i : ((f = t.find((
|
|
1228
|
+
function Nt(i) {
|
|
1229
|
+
var f, y;
|
|
1230
|
+
return typeof i == "number" ? d.current === i : ((f = t.find((v) => v.id === i)) == null ? void 0 : f.id) === ((y = t[d.current]) == null ? void 0 : y.id);
|
|
1234
1231
|
}
|
|
1235
1232
|
return {
|
|
1236
|
-
carouselFragment: /* @__PURE__ */
|
|
1233
|
+
carouselFragment: /* @__PURE__ */ Lt(
|
|
1237
1234
|
"div",
|
|
1238
1235
|
{
|
|
1239
|
-
ref:
|
|
1236
|
+
ref: E,
|
|
1240
1237
|
className: "ReactSpringCarouselContainer",
|
|
1241
1238
|
"data-part": "Container",
|
|
1242
1239
|
"data-part-internal": `${n}-Container`,
|
|
@@ -1303,12 +1300,12 @@ function Ne({
|
|
|
1303
1300
|
/* @__PURE__ */ q(
|
|
1304
1301
|
"div",
|
|
1305
1302
|
{
|
|
1306
|
-
ref:
|
|
1303
|
+
ref: P,
|
|
1307
1304
|
className: "ReactSpringCarouselTrack",
|
|
1308
1305
|
"data-part": "Track",
|
|
1309
1306
|
"data-part-internal": `${n}-Track`,
|
|
1310
1307
|
onScroll: () => {
|
|
1311
|
-
|
|
1308
|
+
x.current = !1, I.current = !1;
|
|
1312
1309
|
},
|
|
1313
1310
|
children: Dt.map((i, f) => /* @__PURE__ */ q(
|
|
1314
1311
|
"div",
|
|
@@ -1321,7 +1318,7 @@ function Ne({
|
|
|
1321
1318
|
useListenToCustomEvent: nt,
|
|
1322
1319
|
index: f,
|
|
1323
1320
|
isClonedItem: !!i.isClonedItem,
|
|
1324
|
-
isActiveItem:
|
|
1321
|
+
isActiveItem: Nt
|
|
1325
1322
|
}) : i.renderItem
|
|
1326
1323
|
},
|
|
1327
1324
|
`${i.id}-${f}`
|
|
@@ -1345,7 +1342,7 @@ function Ne({
|
|
|
1345
1342
|
i > d.current ? F(i) : H(i);
|
|
1346
1343
|
}
|
|
1347
1344
|
if (typeof i == "string") {
|
|
1348
|
-
const f = t.findIndex((
|
|
1345
|
+
const f = t.findIndex((y) => y.id === i);
|
|
1349
1346
|
if (f < 0) {
|
|
1350
1347
|
console.warn(
|
|
1351
1348
|
`The item you're trying to slide doesn't exist. id: ${i}`
|
|
@@ -1370,7 +1367,7 @@ function tt(e) {
|
|
|
1370
1367
|
return t.getBoundingClientRect().width + r;
|
|
1371
1368
|
}
|
|
1372
1369
|
function Me({ container: e, onReach: t }) {
|
|
1373
|
-
const r =
|
|
1370
|
+
const r = $("start"), n = $(0), [, s] = wt(() => ({
|
|
1374
1371
|
x: 0
|
|
1375
1372
|
}));
|
|
1376
1373
|
function o(c) {
|
|
@@ -1390,10 +1387,7 @@ function Me({ container: e, onReach: t }) {
|
|
|
1390
1387
|
if (!e.current || c === "next" && r.current === "end" || c === "prev" && r.current === "start")
|
|
1391
1388
|
return;
|
|
1392
1389
|
let l = 0;
|
|
1393
|
-
if (c === "next" && (n.current += 1), c === "prev" && (n.current -= 1), l = n.current * tt(e.current),
|
|
1394
|
-
toValue: l,
|
|
1395
|
-
activeItem: n.current
|
|
1396
|
-
}), c === "next") {
|
|
1390
|
+
if (c === "next" && (n.current += 1), c === "prev" && (n.current -= 1), l = n.current * tt(e.current), c === "next") {
|
|
1397
1391
|
const h = _t(e.current);
|
|
1398
1392
|
l > h && (r.current = "end", l = h, t && t("end"));
|
|
1399
1393
|
}
|
|
@@ -1401,27 +1395,28 @@ function Me({ container: e, onReach: t }) {
|
|
|
1401
1395
|
}
|
|
1402
1396
|
return R(() => {
|
|
1403
1397
|
function c() {
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1398
|
+
var w;
|
|
1399
|
+
const D = tt(e.current), _ = ((w = [...e.current.children].at(0)) == null ? void 0 : w.getBoundingClientRect().width) || 0, E = Array(e.current.childElementCount).fill(0).map((x, I) => ({
|
|
1400
|
+
index: I,
|
|
1401
|
+
start: D * I,
|
|
1402
|
+
end: D * (I + 1)
|
|
1403
|
+
})), P = e.current.scrollLeft + _, A = E.find(
|
|
1404
|
+
(x) => P >= x.start && P < x.end
|
|
1410
1405
|
);
|
|
1411
|
-
n.current = (
|
|
1406
|
+
n.current = (A == null ? void 0 : A.index) || 0;
|
|
1412
1407
|
}
|
|
1413
1408
|
function l() {
|
|
1414
1409
|
s.stop();
|
|
1415
1410
|
}
|
|
1416
|
-
function h(
|
|
1417
|
-
const
|
|
1418
|
-
|
|
1411
|
+
function h(D) {
|
|
1412
|
+
const _ = D.target;
|
|
1413
|
+
_.scrollLeft === 0 ? (n.current = 0, r.current = "start", t && t("start")) : _.scrollLeft >= _t(_) ? (r.current = "end", t && t("end")) : r.current !== "idle" && (r.current = "idle", t && t("idle"));
|
|
1419
1414
|
}
|
|
1420
1415
|
let u, g = 0;
|
|
1421
1416
|
function m() {
|
|
1422
1417
|
g = e.current.scrollLeft, clearTimeout(u), u = setTimeout(function() {
|
|
1423
1418
|
e.current.scrollLeft === g && c();
|
|
1424
|
-
},
|
|
1419
|
+
}, 200);
|
|
1425
1420
|
}
|
|
1426
1421
|
if (e.current)
|
|
1427
1422
|
return e.current.addEventListener("wheel", l, {
|
|
@@ -1448,6 +1443,6 @@ function Me({ container: e, onReach: t }) {
|
|
|
1448
1443
|
};
|
|
1449
1444
|
}
|
|
1450
1445
|
export {
|
|
1451
|
-
|
|
1446
|
+
Le as useSpringCarousel,
|
|
1452
1447
|
Me as useSpringScroll
|
|
1453
1448
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function($,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):($=typeof globalThis<"u"?globalThis:$||self,N($["react-spring-carousel"]={},$["react/jsx-runtime"],$["@react-spring/web"],$.React))})(this,function($,N,re,m){"use strict";function Ce(t,e,r){return Math.max(e,Math.min(t,r))}const _={toVector(t,e){return t===void 0&&(t=e),Array.isArray(t)?t:[t,t]},add(t,e){return[t[0]+e[0],t[1]+e[1]]},sub(t,e){return[t[0]-e[0],t[1]-e[1]]},addTo(t,e){t[0]+=e[0],t[1]+=e[1]},subTo(t,e){t[0]-=e[0],t[1]-=e[1]}};function ne(t,e,r){return e===0||Math.abs(e)===1/0?Math.pow(t,r*5):t*e*r/(e+r*t)}function se(t,e,r,n=.15){return n===0?Ce(t,e,r):t<e?-ne(e-t,r-e,n)+e:t>r?+ne(t-r,r-e,n)+r:t}function De(t,[e,r],[n,s]){const[[o,a],[c,l]]=t;return[se(e,o,a,n),se(r,c,l,s)]}function Pe(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function $e(t){var e=Pe(t,"string");return typeof e=="symbol"?e:String(e)}function E(t,e,r){return e=$e(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ie(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function p(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ie(Object(r),!0).forEach(function(n){E(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ie(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}const oe={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 ae(t){return t?t[0].toUpperCase()+t.slice(1):""}const Oe=["enter","leave"];function Ae(t=!1,e){return t&&!Oe.includes(e)}function Le(t,e="",r=!1){const n=oe[t],s=n&&n[e]||e;return"on"+ae(t)+ae(s)+(Ae(r,s)?"Capture":"")}const Ne=["gotpointercapture","lostpointercapture"];function Me(t){let e=t.substring(2).toLowerCase();const r=!!~e.indexOf("passive");r&&(e=e.replace("passive",""));const n=Ne.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:r}}function Ve(t,e=""){const r=oe[t],n=r&&r[e]||e;return t+n}function K(t){return"touches"in t}function ce(t){return K(t)?"touch":"pointerType"in t?t.pointerType:"mouse"}function je(t){return Array.from(t.touches).filter(e=>{var r,n;return e.target===t.currentTarget||((r=t.currentTarget)===null||r===void 0||(n=r.contains)===null||n===void 0?void 0:n.call(r,e.target))})}function Re(t){return t.type==="touchend"||t.type==="touchcancel"?t.changedTouches:t.targetTouches}function ue(t){return K(t)?Re(t)[0]:t}function Ue(t){return je(t).map(e=>e.identifier)}function F(t){const e=ue(t);return K(t)?e.identifier:e.pointerId}function le(t){const e=ue(t);return[e.clientX,e.clientY]}function Be(t){const e={};if("buttons"in t&&(e.buttons=t.buttons),"shiftKey"in t){const{shiftKey:r,altKey:n,metaKey:s,ctrlKey:o}=t;Object.assign(e,{shiftKey:r,altKey:n,metaKey:s,ctrlKey:o})}return e}function G(t,...e){return typeof t=="function"?t(...e):t}function Ke(){}function Ge(...t){return t.length===0?Ke:t.length===1?t[0]:function(){let e;for(const r of t)e=r.apply(this,arguments)||e;return e}}function fe(t,e){return Object.assign({},e,t||{})}const ze=32;class We{constructor(e,r,n){this.ctrl=e,this.args=r,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:r,ingKey:n,args:s}=this;r[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 r=this.state,n=this.config;r._active||(this.reset(),this.computeInitial(),r._active=!0,r.target=e.target,r.currentTarget=e.currentTarget,r.lastOffset=n.from?G(n.from,r):r.offset,r.offset=r.lastOffset,r.startTime=r.timeStamp=e.timeStamp)}computeValues(e){const r=this.state;r._values=e,r.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:r,config:n,shared:s}=this;r.args=this.args;let o=0;if(e&&(r.event=e,n.preventDefault&&e.cancelable&&r.event.preventDefault(),r.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,Be(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,o=e.timeStamp-r.timeStamp,r.timeStamp=e.timeStamp,r.elapsedTime=r.timeStamp-r.startTime),r._active){const d=r._delta.map(Math.abs);_.addTo(r._distance,d)}this.axisIntent&&this.axisIntent(e);const[a,c]=r._movement,[l,h]=n.threshold,{_step:u,values:v}=r;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(a)>=l&&v[0]),u[1]===!1&&(u[1]=Math.abs(c)>=h&&v[1])):(u[0]===!1&&(u[0]=Math.abs(a)>=l&&Math.sign(a)*l),u[1]===!1&&(u[1]=Math.abs(c)>=h&&Math.sign(c)*h)),r.intentional=u[0]!==!1||u[1]!==!1,!r.intentional)return;const g=[0,0];if(n.hasCustomTransform){const[d,B]=v;g[0]=u[0]!==!1?d-u[0]:0,g[1]=u[1]!==!1?B-u[1]:0}else g[0]=u[0]!==!1?a-u[0]:0,g[1]=u[1]!==!1?c-u[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(g);const C=r.offset,T=r._active&&!r._blocked||r.active;T&&(r.first=r._active&&!r.active,r.last=!r._active&&r.active,r.active=s[this.ingKey]=r._active,e&&(r.first&&("bounds"in n&&(r._bounds=G(n.bounds,r)),this.setup&&this.setup()),r.movement=g,this.computeOffset()));const[y,D]=r.offset,[[O,P],[A,L]]=r._bounds;r.overflow=[y<O?-1:y>P?1:0,D<A?-1:D>L?1:0],r._movementBound[0]=r.overflow[0]?r._movementBound[0]===!1?r._movement[0]:r._movementBound[0]:!1,r._movementBound[1]=r.overflow[1]?r._movementBound[1]===!1?r._movement[1]:r._movementBound[1]:!1;const U=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=De(r._bounds,r.offset,U),r.delta=_.sub(r.offset,C),this.computeMovement(),T&&(!r.last||o>ze)){r.delta=_.sub(r.offset,C);const d=r.delta.map(Math.abs);_.addTo(r.distance,d),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&o>0&&(r.velocity=[d[0]/o,d[1]/o],r.timeDelta=o)}}emit(){const e=this.state,r=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const s=this.handler(p(p(p({},r),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Ye([t,e],r){const n=Math.abs(t),s=Math.abs(e);if(n>s&&n>r)return"x";if(s>n&&s>r)return"y"}class Fe extends We{constructor(...e){super(...e),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=_.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=_.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const r=this.state,n=this.config;if(!r.axis&&e){const s=typeof n.axisThreshold=="object"?n.axisThreshold[ce(e)]:n.axisThreshold;r.axis=Ye(r._movement,s)}r._blocked=(n.lockDirection||!!n.axis)&&!r.axis||!!n.axis&&n.axis!==r.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 de=t=>t,he=.15,H={enabled(t=!0){return t},eventOptions(t,e,r){return p(p({},r.shared.eventOptions),t)},preventDefault(t=!1){return t},triggerAllEvents(t=!1){return t},rubberband(t=0){switch(t){case!0:return[he,he];case!1:return[0,0];default:return _.toVector(t)}},from(t){if(typeof t=="function")return t;if(t!=null)return _.toVector(t)},transform(t,e,r){const n=t||r.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||de;return o=>{const a=s(o);return(!isFinite(a[0])||!isFinite(a[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${a[0]},${[1]}]`),a}}return n||de},threshold(t){return _.toVector(t,0)}};process.env.NODE_ENV==="development"&&Object.assign(H,{domTarget(t){if(t!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(t){if(t!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(t){if(t!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const He=0,j=p(p({},H),{},{axis(t,e,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(t=He){return t},bounds(t={}){if(typeof t=="function")return o=>j.bounds(t(o));if("current"in t)return()=>t.current;if(typeof HTMLElement=="function"&&t instanceof HTMLElement)return t;const{left:e=-1/0,right:r=1/0,top:n=-1/0,bottom:s=1/0}=t;return[[e,r],[n,s]]}}),pe={ArrowRight:(t,e=1)=>[t*e,0],ArrowLeft:(t,e=1)=>[-1*t*e,0],ArrowUp:(t,e=1)=>[0,-1*t*e],ArrowDown:(t,e=1)=>[0,t*e]};class Xe extends Fe{constructor(...e){super(...e),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 r=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),s={left:r.left-n.left+e.offset[0],right:r.right-n.right+e.offset[0],top:r.top-n.top+e.offset[1],bottom:r.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 r=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(r.pointerButtons)?!r.pointerButtons.includes(e.buttons):r.pointerButtons!==-1&&r.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);r.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=F(e),n._pointerActive=!0,this.computeValues(le(e)),this.computeInitial(),r.preventScrollAxis&&ce(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):r.delay>0?(this.setupDelayTrigger(e),r.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const r=this.state;r._active=!0,r._preventScroll=!0,r._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const r=this.state,n=this.config;if(!r._pointerActive)return;const s=F(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;const o=le(e);if(document.pointerLockElement===e.target?r._delta=[e.movementX,e.movementY]:(r._delta=_.sub(o,r._values),this.computeValues(o)),_.addTo(r._movement,r._delta),this.compute(e),r._delayed&&r.intentional){this.timeoutStore.remove("dragDelay"),r.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!r._preventScroll)if(r.axis)if(r.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){r._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 r=this.state,n=this.config;if(!r._active||!r._pointerActive)return;const s=F(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[o,a]=r._distance;if(r.tap=o<=n.tapsThreshold&&a<=n.tapsThreshold,r.tap&&n.filterTaps)r._force=!0;else{const[c,l]=r._delta,[h,u]=r._movement,[v,g]=n.swipe.velocity,[C,T]=n.swipe.distance,y=n.swipe.duration;if(r.elapsedTime<y){const D=Math.abs(c/r.timeDelta),O=Math.abs(l/r.timeDelta);D>v&&Math.abs(h)>C&&(r.swipe[0]=Math.sign(c)),O>g&&Math.abs(u)>T&&(r.swipe[1]=Math.sign(l))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const r=this.config,n=r.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&r.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{}r.pointerLock&&e.currentTarget.requestPointerLock(),r.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,qe(e);const r=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",r),this.eventStore.add(this.sharedConfig.window,"touch","cancel",r),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 r=pe[e.key];if(r){const n=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=r(this.config.keyboardDisplacement,s),n._keyboardActive=!0,_.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in pe&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const r=this.config.device;e(r,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(r,"change",this.pointerMove.bind(this)),e(r,"end",this.pointerUp.bind(this)),e(r,"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 qe(t){"persist"in t&&typeof t.persist=="function"&&t.persist()}const R=typeof window<"u"&&window.document&&window.document.createElement;function me(){return R&&"ontouchstart"in window}function Je(){return me()||R&&window.navigator.maxTouchPoints>1}function Qe(){return R&&"onpointerdown"in window}function Ze(){return R&&"exitPointerLock"in window.document}function et(){try{return"constructor"in GestureEvent}catch{return!1}}const k={isBrowser:R,gesture:et(),touch:me(),touchscreen:Je(),pointer:Qe(),pointerLock:Ze()},tt=250,rt=180,nt=.5,st=50,it=250,ot=10,ge={mouse:0,touch:0,pen:8},ve=p(p({},j),{},{device(t,e,{pointer:{touch:r=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&k.pointerLock,k.touch&&r?"touch":this.pointerLock?"mouse":k.pointer&&!s?"pointer":k.touch?"touch":"mouse"},preventScrollAxis(t,e,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&t?tt:void 0,!(!k.touchscreen||r===!1))return t||(r!==void 0?"y":void 0)},pointerCapture(t,e,{pointer:{capture:r=!0,buttons:n=1,keys:s=!0}={}}){return this.pointerButtons=n,this.keys=s,!this.pointerLock&&this.device==="pointer"&&r},threshold(t,e,{filterTaps:r=!1,tapsThreshold:n=3,axis:s=void 0}){const o=_.toVector(t,r?n:s?1:0);return this.filterTaps=r,this.tapsThreshold=n,o},swipe({velocity:t=nt,distance:e=st,duration:r=it}={}){return{velocity:this.transform(_.toVector(t)),distance:this.transform(_.toVector(e)),duration:r}},delay(t=0){switch(t){case!0:return rt;case!1:return 0;default:return t}},axisThreshold(t){return t?p(p({},ge),t):ge},keyboardDisplacement(t=ot){return t}});process.env.NODE_ENV==="development"&&Object.assign(ve,{useTouch(t){if(t!==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(t){if(t!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(t){if(t!==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(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),p(p({},H),{},{device(t,e,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!k.touch&&k.gesture)return"gesture";if(k.touch&&n)return"touch";if(k.touchscreen){if(k.pointer)return"pointer";if(k.touch)return"touch"}},bounds(t,e,{scaleBounds:r={},angleBounds:n={}}){const s=a=>{const c=fe(G(r,a),{min:-1/0,max:1/0});return[c.min,c.max]},o=a=>{const c=fe(G(n,a),{min:-1/0,max:1/0});return[c.min,c.max]};return typeof r!="function"&&typeof n!="function"?[s(),o()]:a=>[s(a),o(a)]},threshold(t,e,r){return this.lockDirection=r.axis==="lock",_.toVector(t,this.lockDirection?[.1,3]:0)},modifierKey(t){return t===void 0?"ctrlKey":t},pinchOnWheel(t=!0){return t}}),p(p({},j),{},{mouseOnly:(t=!0)=>t}),p(p({},j),{},{mouseOnly:(t=!0)=>t});const ye=new Map,X=new Map;function at(t){ye.set(t.key,t.engine),X.set(t.key,t.resolver)}const ct={key:"drag",engine:Xe,resolver:ve};function ut(t,e){if(t==null)return{};var r={},n=Object.keys(t),s,o;for(o=0;o<n.length;o++)s=n[o],!(e.indexOf(s)>=0)&&(r[s]=t[s]);return r}function lt(t,e){if(t==null)return{};var r=ut(t,e),n,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(s=0;s<o.length;s++)n=o[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}const ft={target(t){if(t)return()=>"current"in t?t.current:t},enabled(t=!0){return t},window(t=k.isBrowser?window:void 0){return t},eventOptions({passive:t=!0,capture:e=!1}={}){return{passive:t,capture:e}},transform(t){return t}},dt=["target","eventOptions","window","enabled","transform"];function z(t={},e){const r={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const o=s.call(r,t[n],n,t);Number.isNaN(o)||(r[n]=o)}else r[n]=s.call(r,t[n],n,t);break;case"object":r[n]=z(t[n],s);break;case"boolean":s&&(r[n]=t[n]);break}return r}function ht(t,e,r={}){const n=t,{target:s,eventOptions:o,window:a,enabled:c,transform:l}=n,h=lt(n,dt);if(r.shared=z({target:s,eventOptions:o,window:a,enabled:c,transform:l},ft),e){const u=X.get(e);r[e]=z(p({shared:r.shared},h),u)}else for(const u in h){const v=X.get(u);if(v)r[u]=z(p({shared:r.shared},h[u]),v);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(u)){if(u==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${u}\` was used. Please read the documentation for further information.`)}}return r}class be{constructor(e,r){E(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=r}add(e,r,n,s,o){const a=this._listeners,c=Ve(r,n),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},h=p(p({},l),o);e.addEventListener(c,s,h);const u=()=>{e.removeEventListener(c,s,h),a.delete(u)};return a.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class pt{constructor(){E(this,"_timeouts",new Map)}add(e,r,n=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(r,n,...s))}remove(e){const r=this._timeouts.get(e);r&&window.clearTimeout(r)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class mt{constructor(e){E(this,"gestures",new Set),E(this,"_targetEventStore",new be(this)),E(this,"gestureEventStores",{}),E(this,"gestureTimeoutStores",{}),E(this,"handlers",{}),E(this,"config",{}),E(this,"pointerIds",new Set),E(this,"touchIds",new Set),E(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),gt(this,e)}setEventIds(e){if(K(e))return this.touchIds=new Set(Ue(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,r){this.handlers=e,this.nativeHandlers=r}applyConfig(e,r){this.config=ht(e,r,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 r=this.config.shared,n={};let s;if(!(r.target&&(s=r.target(),!s))){if(r.enabled){for(const a of this.gestures){const c=this.config[a],l=_e(n,c.eventOptions,!!s);if(c.enabled){const h=ye.get(a);new h(this,e,a).bind(l)}}const o=_e(n,r.eventOptions,!!s);for(const a in this.nativeHandlers)o(a,"",c=>this.nativeHandlers[a](p(p({},this.state.shared),{},{event:c,args:e})),void 0,!0)}for(const o in n)n[o]=Ge(...n[o]);if(!s)return n;for(const o in n){const{device:a,capture:c,passive:l}=Me(o);this._targetEventStore.add(s,a,"",n[o],{capture:c,passive:l})}}}}function M(t,e){t.gestures.add(e),t.gestureEventStores[e]=new be(t,e),t.gestureTimeoutStores[e]=new pt}function gt(t,e){e.drag&&M(t,"drag"),e.wheel&&M(t,"wheel"),e.scroll&&M(t,"scroll"),e.move&&M(t,"move"),e.pinch&&M(t,"pinch"),e.hover&&M(t,"hover")}const _e=(t,e,r)=>(n,s,o,a={},c=!1)=>{var l,h;const u=(l=a.capture)!==null&&l!==void 0?l:e.capture,v=(h=a.passive)!==null&&h!==void 0?h:e.passive;let g=c?n:Le(n,s,u);r&&v&&(g+="Passive"),t[g]=t[g]||[],t[g].push(o)};function vt(t,e={},r,n){const s=m.useMemo(()=>new mt(t),[]);if(s.applyHandlers(t,n),s.applyConfig(e,r),m.useEffect(s.effect.bind(s)),m.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function yt(t,e){return at(ct),vt({drag:t},e||{},"drag")}const q="RSC::Event";function bt(){const t=m.useRef(null);function e(n){m.useEffect(()=>{t.current||(t.current=document.createElement("div"));function s(o){n(o.detail)}if(t.current)return t.current.addEventListener(q,s,!1),()=>{var o;(o=t.current)==null||o.removeEventListener(q,s,!1)}},[n])}function r(n){if(t.current){const s=new CustomEvent(q,{detail:n});t.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:r}}function _t(t){let e=t.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,"");return e=e.replace(/[\n\t]+/g," "),e=e.replace(/\s*([{}:;,])\s*/g,"$1"),e=e.replace(/\s+}/g,"}"),e=e.replace(/{\s+/g,"{"),e=e.replace(/\s+/g," "),e.trim()}function wt({init:t=!0,items:e,withLoop:r=!1,id:n,gutter:s=[{breakpoint:0,gutter:0,startEndGutter:0}],itemsPerSlide:o=[{breakpoint:0,itemsPerSlide:1}],carouselAxis:a="x",startingPosition:c="start",enableGestures:l=!0,slideWhenDragThresholdIsReached:h=!0,onInit:u,initialActiveItem:v=0}){const[g,C]=m.useState(!1),T=m.useRef(t),y=m.useRef(null),D=m.useRef(null),O=m.useRef(0),P=m.useRef(0),A=m.useRef(!r),L=m.useRef(!1),U=m.useRef(0),d=m.useRef(0),[B,Q]=re.useSpring(()=>({value:0,onChange({value:i}){y.current.style.setProperty(`--${n}-offset-position`,`${i.value}px`)}}),[a]),St=r?[...e.map(i=>({...i,id:`prev-repeated-item-${i.id}`,isClonedItem:!0})),...e,...e.map(i=>({...i,id:`next-repeated-item-${i.id}`,isClonedItem:!0}))]:e,{useListenToCustomEvent:Ee,emitEvent:W}=bt();function xt(){const{totalGutterCssVar:i}=Te();return i}function It(){if(y.current){const f=window.getComputedStyle(y.current).getPropertyValue(`--${n}-items-per-slide`).trim();return Number(f)||1}return 1}function Z(i){T.current&&(L.current||V({type:"next",toIndex:i,actionType:"click"}))}function ee(i){T.current&&(A.current||V({type:"prev",toIndex:i,actionType:"click"}))}function V({type:i,shouldAnimate:f=!0,toIndex:w,actionType:b}){var xe,Ie;const S=!f;A.current=!1,L.current=!1;let x=B.value.get(),I=0;if(i==="next"&&(d.current+=1),i==="prev"&&(d.current===0?d.current=e.length-1:d.current-=1),w!==void 0&&(d.current=w),i==="next"){const Y=te(r?P.current*(e.length*2):0);I=-(d.current*P.current),r&&d.current===e.length&&(d.current=0,x=x+P.current*e.length,I=0),!r&&Math.abs(I)>=Y&&(L.current=!0,I=-Y)}i==="prev"&&(I=-(d.current*P.current),d.current===e.length-1&&(x=x-e.length*P.current),!r&&I>=0&&(A.current=!0,I=0)),O.current=I,b==="resize"?(I=-(d.current*P.current),W({eventName:"onResize",sliceActionType:b,slideDirection:i,currentItem:{index:d.current,id:((xe=e.at(d.current))==null?void 0:xe.id)??"",startReached:A.current,endReached:L.current}})):W({eventName:"onSlideStartChange",sliceActionType:b,slideDirection:i,nextItem:{index:d.current,id:((Ie=e.at(d.current))==null?void 0:Ie.id)??"",startReached:A.current,endReached:L.current}}),Q.start({immediate:S,from:{value:x},to:{value:I},onRest({finished:Y}){var ke;Y&&W({eventName:"onSlideChangeComplete",sliceActionType:b,slideDirection:i,currentItem:{index:d.current,id:((ke=e.at(d.current))==null?void 0:ke.id)??"",startReached:A.current,endReached:L.current}})}})}function kt(){const i=D.current.children[0];let f=0;return f=i.getBoundingClientRect()[a==="x"?"width":"height"]+xt(),f}function te(i){const f=D.current;return f[a==="x"?"scrollWidth":"scrollHeight"]-f.getBoundingClientRect()[a==="x"?"width":"height"]-i}function Te(){let i=0,f=0;if(y.current){const w=window.getComputedStyle(y.current),b=w.getPropertyValue(`--${n}-start-end-gutter`).trim();b.includes("px")&&(i=Number(b.replace("px","")));const S=w.getPropertyValue(`--${n}-gutter`).trim();S.includes("px")&&(f=Number(S.replace("px","")))}return{totalStartEndGutterCssVar:i,totalGutterCssVar:f}}m.useEffect(()=>{function i(b){const S=It();switch(b){case"start":return 0;case"middle-start":return Math.floor((S-1)*.25);case"center":return Math.floor((S-1)*.5);case"middle-end":return Math.floor((S-1)*.75);case"end":return S-1;default:return 0}}function f(b){if(P.current=kt(),U.current=P.current/4,y.current){const{totalStartEndGutterCssVar:S}=Te();let x=0;r&&(x=P.current*e.length),x-=P.current*i(c),x-=S/2,y.current.style.setProperty(`--${n}-offset-modifier`,`${-x}px`),C(!0),b&&b()}}function w(){f(),V({type:"resize",toIndex:d.current,shouldAnimate:!1,actionType:"resize"})}if(t)return T.current=!0,f(u),window.addEventListener("resize",w),()=>{window.removeEventListener("resize",w)}},[t,r,n,a,s,c]),m.useEffect(()=>{t&&v!==d.current&&V({type:"next",toIndex:v,actionType:"resize",shouldAnimate:!1})},[t,v]);const Se=l,Ct=yt(i=>{if(!T.current)return;const f=i.dragging,w=i.offset[a==="x"?0:1],b=i.movement[a==="x"?0:1],S=b>U.current,x=b<-U.current,I=i.velocity;f&&(W({...i,eventName:"onDrag",slideActionType:"drag"}),Q.start({value:w,immediate:!0,config:{velocity:I}}),h&&(S||x)&&i.cancel()),i.last&&(S?(V({actionType:"drag",type:"prev"}),i.cancel()):x?(V({actionType:"drag",type:"next"}),i.cancel()):(Q.start({value:O.current,config:{velocity:I}}),i.cancel()))},{enabled:Se,axis:a,rubberband:!r,...r?{}:{bounds:()=>({right:0,left:-te(0),top:-te(0),bottom:0})},from:()=>[B.value.get(),B.value.get()]});function Dt(i){var f,w;return typeof i=="number"?d.current===i:((f=e.find(b=>b.id===i))==null?void 0:f.id)===((w=e[d.current])==null?void 0:w.id)}return{carouselFragment:N.jsxs("div",{ref:y,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,...Ct(),children:[N.jsx("style",{dangerouslySetInnerHTML:{__html:_t(`
|
|
1
|
+
(function(A,L){typeof exports=="object"&&typeof module<"u"?L(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"],L):(A=typeof globalThis<"u"?globalThis:A||self,L(A["react-spring-carousel"]={},A["react/jsx-runtime"],A["@react-spring/web"],A.React))})(this,function(A,L,re,m){"use strict";function Ce(t,e,r){return Math.max(e,Math.min(t,r))}const b={toVector(t,e){return t===void 0&&(t=e),Array.isArray(t)?t:[t,t]},add(t,e){return[t[0]+e[0],t[1]+e[1]]},sub(t,e){return[t[0]-e[0],t[1]-e[1]]},addTo(t,e){t[0]+=e[0],t[1]+=e[1]},subTo(t,e){t[0]-=e[0],t[1]-=e[1]}};function ne(t,e,r){return e===0||Math.abs(e)===1/0?Math.pow(t,r*5):t*e*r/(e+r*t)}function se(t,e,r,n=.15){return n===0?Ce(t,e,r):t<e?-ne(e-t,r-e,n)+e:t>r?+ne(t-r,r-e,n)+r:t}function De(t,[e,r],[n,s]){const[[o,a],[c,l]]=t;return[se(e,o,a,n),se(r,c,l,s)]}function Pe(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function $e(t){var e=Pe(t,"string");return typeof e=="symbol"?e:String(e)}function T(t,e,r){return e=$e(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ie(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function p(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ie(Object(r),!0).forEach(function(n){T(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ie(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}const oe={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 ae(t){return t?t[0].toUpperCase()+t.slice(1):""}const Oe=["enter","leave"];function Ae(t=!1,e){return t&&!Oe.includes(e)}function Ne(t,e="",r=!1){const n=oe[t],s=n&&n[e]||e;return"on"+ae(t)+ae(s)+(Ae(r,s)?"Capture":"")}const Le=["gotpointercapture","lostpointercapture"];function Me(t){let e=t.substring(2).toLowerCase();const r=!!~e.indexOf("passive");r&&(e=e.replace("passive",""));const n=Le.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:r}}function Ve(t,e=""){const r=oe[t],n=r&&r[e]||e;return t+n}function K(t){return"touches"in t}function ce(t){return K(t)?"touch":"pointerType"in t?t.pointerType:"mouse"}function je(t){return Array.from(t.touches).filter(e=>{var r,n;return e.target===t.currentTarget||((r=t.currentTarget)===null||r===void 0||(n=r.contains)===null||n===void 0?void 0:n.call(r,e.target))})}function Re(t){return t.type==="touchend"||t.type==="touchcancel"?t.changedTouches:t.targetTouches}function ue(t){return K(t)?Re(t)[0]:t}function Be(t){return je(t).map(e=>e.identifier)}function F(t){const e=ue(t);return K(t)?e.identifier:e.pointerId}function le(t){const e=ue(t);return[e.clientX,e.clientY]}function Ue(t){const e={};if("buttons"in t&&(e.buttons=t.buttons),"shiftKey"in t){const{shiftKey:r,altKey:n,metaKey:s,ctrlKey:o}=t;Object.assign(e,{shiftKey:r,altKey:n,metaKey:s,ctrlKey:o})}return e}function G(t,...e){return typeof t=="function"?t(...e):t}function Ke(){}function Ge(...t){return t.length===0?Ke:t.length===1?t[0]:function(){let e;for(const r of t)e=r.apply(this,arguments)||e;return e}}function fe(t,e){return Object.assign({},e,t||{})}const ze=32;class We{constructor(e,r,n){this.ctrl=e,this.args=r,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:r,ingKey:n,args:s}=this;r[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 r=this.state,n=this.config;r._active||(this.reset(),this.computeInitial(),r._active=!0,r.target=e.target,r.currentTarget=e.currentTarget,r.lastOffset=n.from?G(n.from,r):r.offset,r.offset=r.lastOffset,r.startTime=r.timeStamp=e.timeStamp)}computeValues(e){const r=this.state;r._values=e,r.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:r,config:n,shared:s}=this;r.args=this.args;let o=0;if(e&&(r.event=e,n.preventDefault&&e.cancelable&&r.event.preventDefault(),r.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,Ue(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,o=e.timeStamp-r.timeStamp,r.timeStamp=e.timeStamp,r.elapsedTime=r.timeStamp-r.startTime),r._active){const d=r._delta.map(Math.abs);b.addTo(r._distance,d)}this.axisIntent&&this.axisIntent(e);const[a,c]=r._movement,[l,h]=n.threshold,{_step:u,values:v}=r;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(a)>=l&&v[0]),u[1]===!1&&(u[1]=Math.abs(c)>=h&&v[1])):(u[0]===!1&&(u[0]=Math.abs(a)>=l&&Math.sign(a)*l),u[1]===!1&&(u[1]=Math.abs(c)>=h&&Math.sign(c)*h)),r.intentional=u[0]!==!1||u[1]!==!1,!r.intentional)return;const g=[0,0];if(n.hasCustomTransform){const[d,U]=v;g[0]=u[0]!==!1?d-u[0]:0,g[1]=u[1]!==!1?U-u[1]:0}else g[0]=u[0]!==!1?a-u[0]:0,g[1]=u[1]!==!1?c-u[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(g);const $=r.offset,w=r._active&&!r._blocked||r.active;w&&(r.first=r._active&&!r.active,r.last=!r._active&&r.active,r.active=s[this.ingKey]=r._active,e&&(r.first&&("bounds"in n&&(r._bounds=G(n.bounds,r)),this.setup&&this.setup()),r.movement=g,this.computeOffset()));const[S,O]=r.offset,[[N,E],[I,k]]=r._bounds;r.overflow=[S<N?-1:S>E?1:0,O<I?-1:O>k?1:0],r._movementBound[0]=r.overflow[0]?r._movementBound[0]===!1?r._movement[0]:r._movementBound[0]:!1,r._movementBound[1]=r.overflow[1]?r._movementBound[1]===!1?r._movement[1]:r._movementBound[1]:!1;const B=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=De(r._bounds,r.offset,B),r.delta=b.sub(r.offset,$),this.computeMovement(),w&&(!r.last||o>ze)){r.delta=b.sub(r.offset,$);const d=r.delta.map(Math.abs);b.addTo(r.distance,d),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&o>0&&(r.velocity=[d[0]/o,d[1]/o],r.timeDelta=o)}}emit(){const e=this.state,r=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const s=this.handler(p(p(p({},r),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Ye([t,e],r){const n=Math.abs(t),s=Math.abs(e);if(n>s&&n>r)return"x";if(s>n&&s>r)return"y"}class Fe extends We{constructor(...e){super(...e),T(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=b.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=b.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const r=this.state,n=this.config;if(!r.axis&&e){const s=typeof n.axisThreshold=="object"?n.axisThreshold[ce(e)]:n.axisThreshold;r.axis=Ye(r._movement,s)}r._blocked=(n.lockDirection||!!n.axis)&&!r.axis||!!n.axis&&n.axis!==r.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 de=t=>t,he=.15,H={enabled(t=!0){return t},eventOptions(t,e,r){return p(p({},r.shared.eventOptions),t)},preventDefault(t=!1){return t},triggerAllEvents(t=!1){return t},rubberband(t=0){switch(t){case!0:return[he,he];case!1:return[0,0];default:return b.toVector(t)}},from(t){if(typeof t=="function")return t;if(t!=null)return b.toVector(t)},transform(t,e,r){const n=t||r.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||de;return o=>{const a=s(o);return(!isFinite(a[0])||!isFinite(a[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${a[0]},${[1]}]`),a}}return n||de},threshold(t){return b.toVector(t,0)}};process.env.NODE_ENV==="development"&&Object.assign(H,{domTarget(t){if(t!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(t){if(t!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(t){if(t!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const He=0,j=p(p({},H),{},{axis(t,e,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(t=He){return t},bounds(t={}){if(typeof t=="function")return o=>j.bounds(t(o));if("current"in t)return()=>t.current;if(typeof HTMLElement=="function"&&t instanceof HTMLElement)return t;const{left:e=-1/0,right:r=1/0,top:n=-1/0,bottom:s=1/0}=t;return[[e,r],[n,s]]}}),pe={ArrowRight:(t,e=1)=>[t*e,0],ArrowLeft:(t,e=1)=>[-1*t*e,0],ArrowUp:(t,e=1)=>[0,-1*t*e],ArrowDown:(t,e=1)=>[0,t*e]};class Xe extends Fe{constructor(...e){super(...e),T(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 r=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),s={left:r.left-n.left+e.offset[0],right:r.right-n.right+e.offset[0],top:r.top-n.top+e.offset[1],bottom:r.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 r=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(r.pointerButtons)?!r.pointerButtons.includes(e.buttons):r.pointerButtons!==-1&&r.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);r.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=F(e),n._pointerActive=!0,this.computeValues(le(e)),this.computeInitial(),r.preventScrollAxis&&ce(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):r.delay>0?(this.setupDelayTrigger(e),r.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const r=this.state;r._active=!0,r._preventScroll=!0,r._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const r=this.state,n=this.config;if(!r._pointerActive)return;const s=F(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;const o=le(e);if(document.pointerLockElement===e.target?r._delta=[e.movementX,e.movementY]:(r._delta=b.sub(o,r._values),this.computeValues(o)),b.addTo(r._movement,r._delta),this.compute(e),r._delayed&&r.intentional){this.timeoutStore.remove("dragDelay"),r.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!r._preventScroll)if(r.axis)if(r.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){r._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 r=this.state,n=this.config;if(!r._active||!r._pointerActive)return;const s=F(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[o,a]=r._distance;if(r.tap=o<=n.tapsThreshold&&a<=n.tapsThreshold,r.tap&&n.filterTaps)r._force=!0;else{const[c,l]=r._delta,[h,u]=r._movement,[v,g]=n.swipe.velocity,[$,w]=n.swipe.distance,S=n.swipe.duration;if(r.elapsedTime<S){const O=Math.abs(c/r.timeDelta),N=Math.abs(l/r.timeDelta);O>v&&Math.abs(h)>$&&(r.swipe[0]=Math.sign(c)),N>g&&Math.abs(u)>w&&(r.swipe[1]=Math.sign(l))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const r=this.config,n=r.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&r.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{}r.pointerLock&&e.currentTarget.requestPointerLock(),r.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,qe(e);const r=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",r),this.eventStore.add(this.sharedConfig.window,"touch","cancel",r),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 r=pe[e.key];if(r){const n=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=r(this.config.keyboardDisplacement,s),n._keyboardActive=!0,b.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in pe&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const r=this.config.device;e(r,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(r,"change",this.pointerMove.bind(this)),e(r,"end",this.pointerUp.bind(this)),e(r,"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 qe(t){"persist"in t&&typeof t.persist=="function"&&t.persist()}const R=typeof window<"u"&&window.document&&window.document.createElement;function me(){return R&&"ontouchstart"in window}function Je(){return me()||R&&window.navigator.maxTouchPoints>1}function Qe(){return R&&"onpointerdown"in window}function Ze(){return R&&"exitPointerLock"in window.document}function et(){try{return"constructor"in GestureEvent}catch{return!1}}const P={isBrowser:R,gesture:et(),touch:me(),touchscreen:Je(),pointer:Qe(),pointerLock:Ze()},tt=250,rt=180,nt=.5,st=50,it=250,ot=10,ge={mouse:0,touch:0,pen:8},ve=p(p({},j),{},{device(t,e,{pointer:{touch:r=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&P.pointerLock,P.touch&&r?"touch":this.pointerLock?"mouse":P.pointer&&!s?"pointer":P.touch?"touch":"mouse"},preventScrollAxis(t,e,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&t?tt:void 0,!(!P.touchscreen||r===!1))return t||(r!==void 0?"y":void 0)},pointerCapture(t,e,{pointer:{capture:r=!0,buttons:n=1,keys:s=!0}={}}){return this.pointerButtons=n,this.keys=s,!this.pointerLock&&this.device==="pointer"&&r},threshold(t,e,{filterTaps:r=!1,tapsThreshold:n=3,axis:s=void 0}){const o=b.toVector(t,r?n:s?1:0);return this.filterTaps=r,this.tapsThreshold=n,o},swipe({velocity:t=nt,distance:e=st,duration:r=it}={}){return{velocity:this.transform(b.toVector(t)),distance:this.transform(b.toVector(e)),duration:r}},delay(t=0){switch(t){case!0:return rt;case!1:return 0;default:return t}},axisThreshold(t){return t?p(p({},ge),t):ge},keyboardDisplacement(t=ot){return t}});process.env.NODE_ENV==="development"&&Object.assign(ve,{useTouch(t){if(t!==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(t){if(t!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(t){if(t!==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(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),p(p({},H),{},{device(t,e,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!P.touch&&P.gesture)return"gesture";if(P.touch&&n)return"touch";if(P.touchscreen){if(P.pointer)return"pointer";if(P.touch)return"touch"}},bounds(t,e,{scaleBounds:r={},angleBounds:n={}}){const s=a=>{const c=fe(G(r,a),{min:-1/0,max:1/0});return[c.min,c.max]},o=a=>{const c=fe(G(n,a),{min:-1/0,max:1/0});return[c.min,c.max]};return typeof r!="function"&&typeof n!="function"?[s(),o()]:a=>[s(a),o(a)]},threshold(t,e,r){return this.lockDirection=r.axis==="lock",b.toVector(t,this.lockDirection?[.1,3]:0)},modifierKey(t){return t===void 0?"ctrlKey":t},pinchOnWheel(t=!0){return t}}),p(p({},j),{},{mouseOnly:(t=!0)=>t}),p(p({},j),{},{mouseOnly:(t=!0)=>t});const ye=new Map,X=new Map;function at(t){ye.set(t.key,t.engine),X.set(t.key,t.resolver)}const ct={key:"drag",engine:Xe,resolver:ve};function ut(t,e){if(t==null)return{};var r={},n=Object.keys(t),s,o;for(o=0;o<n.length;o++)s=n[o],!(e.indexOf(s)>=0)&&(r[s]=t[s]);return r}function lt(t,e){if(t==null)return{};var r=ut(t,e),n,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(s=0;s<o.length;s++)n=o[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}const ft={target(t){if(t)return()=>"current"in t?t.current:t},enabled(t=!0){return t},window(t=P.isBrowser?window:void 0){return t},eventOptions({passive:t=!0,capture:e=!1}={}){return{passive:t,capture:e}},transform(t){return t}},dt=["target","eventOptions","window","enabled","transform"];function z(t={},e){const r={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const o=s.call(r,t[n],n,t);Number.isNaN(o)||(r[n]=o)}else r[n]=s.call(r,t[n],n,t);break;case"object":r[n]=z(t[n],s);break;case"boolean":s&&(r[n]=t[n]);break}return r}function ht(t,e,r={}){const n=t,{target:s,eventOptions:o,window:a,enabled:c,transform:l}=n,h=lt(n,dt);if(r.shared=z({target:s,eventOptions:o,window:a,enabled:c,transform:l},ft),e){const u=X.get(e);r[e]=z(p({shared:r.shared},h),u)}else for(const u in h){const v=X.get(u);if(v)r[u]=z(p({shared:r.shared},h[u]),v);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(u)){if(u==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${u}\` was used. Please read the documentation for further information.`)}}return r}class be{constructor(e,r){T(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=r}add(e,r,n,s,o){const a=this._listeners,c=Ve(r,n),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},h=p(p({},l),o);e.addEventListener(c,s,h);const u=()=>{e.removeEventListener(c,s,h),a.delete(u)};return a.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class pt{constructor(){T(this,"_timeouts",new Map)}add(e,r,n=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(r,n,...s))}remove(e){const r=this._timeouts.get(e);r&&window.clearTimeout(r)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class mt{constructor(e){T(this,"gestures",new Set),T(this,"_targetEventStore",new be(this)),T(this,"gestureEventStores",{}),T(this,"gestureTimeoutStores",{}),T(this,"handlers",{}),T(this,"config",{}),T(this,"pointerIds",new Set),T(this,"touchIds",new Set),T(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),gt(this,e)}setEventIds(e){if(K(e))return this.touchIds=new Set(Be(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,r){this.handlers=e,this.nativeHandlers=r}applyConfig(e,r){this.config=ht(e,r,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 r=this.config.shared,n={};let s;if(!(r.target&&(s=r.target(),!s))){if(r.enabled){for(const a of this.gestures){const c=this.config[a],l=_e(n,c.eventOptions,!!s);if(c.enabled){const h=ye.get(a);new h(this,e,a).bind(l)}}const o=_e(n,r.eventOptions,!!s);for(const a in this.nativeHandlers)o(a,"",c=>this.nativeHandlers[a](p(p({},this.state.shared),{},{event:c,args:e})),void 0,!0)}for(const o in n)n[o]=Ge(...n[o]);if(!s)return n;for(const o in n){const{device:a,capture:c,passive:l}=Me(o);this._targetEventStore.add(s,a,"",n[o],{capture:c,passive:l})}}}}function M(t,e){t.gestures.add(e),t.gestureEventStores[e]=new be(t,e),t.gestureTimeoutStores[e]=new pt}function gt(t,e){e.drag&&M(t,"drag"),e.wheel&&M(t,"wheel"),e.scroll&&M(t,"scroll"),e.move&&M(t,"move"),e.pinch&&M(t,"pinch"),e.hover&&M(t,"hover")}const _e=(t,e,r)=>(n,s,o,a={},c=!1)=>{var l,h;const u=(l=a.capture)!==null&&l!==void 0?l:e.capture,v=(h=a.passive)!==null&&h!==void 0?h:e.passive;let g=c?n:Ne(n,s,u);r&&v&&(g+="Passive"),t[g]=t[g]||[],t[g].push(o)};function vt(t,e={},r,n){const s=m.useMemo(()=>new mt(t),[]);if(s.applyHandlers(t,n),s.applyConfig(e,r),m.useEffect(s.effect.bind(s)),m.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function yt(t,e){return at(ct),vt({drag:t},e||{},"drag")}const q="RSC::Event";function bt(){const t=m.useRef(null);function e(n){m.useEffect(()=>{t.current||(t.current=document.createElement("div"));function s(o){n(o.detail)}if(t.current)return t.current.addEventListener(q,s,!1),()=>{var o;(o=t.current)==null||o.removeEventListener(q,s,!1)}},[n])}function r(n){if(t.current){const s=new CustomEvent(q,{detail:n});t.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:r}}function _t(t){let e=t.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,"");return e=e.replace(/[\n\t]+/g," "),e=e.replace(/\s*([{}:;,])\s*/g,"$1"),e=e.replace(/\s+}/g,"}"),e=e.replace(/{\s+/g,"{"),e=e.replace(/\s+/g," "),e.trim()}function wt({init:t=!0,items:e,withLoop:r=!1,id:n,gutter:s=[{breakpoint:0,gutter:0,startEndGutter:0}],itemsPerSlide:o=[{breakpoint:0,itemsPerSlide:1}],carouselAxis:a="x",startingPosition:c="start",enableGestures:l=!0,slideWhenDragThresholdIsReached:h=!0,onInit:u,initialActiveItem:v=0}){const[g,$]=m.useState(!1),w=m.useRef(t),S=m.useRef(null),O=m.useRef(null),N=m.useRef(0),E=m.useRef(0),I=m.useRef(!r),k=m.useRef(!1),B=m.useRef(0),d=m.useRef(0),[U,Q]=re.useSpring(()=>({value:0,onChange({value:i}){O.current.style.transform=`translate3d(${i.value}px, 0px, 0px)`}}),[a]),St=r?[...e.map(i=>({...i,id:`prev-repeated-item-${i.id}`,isClonedItem:!0})),...e,...e.map(i=>({...i,id:`next-repeated-item-${i.id}`,isClonedItem:!0}))]:e,{useListenToCustomEvent:Ee,emitEvent:W}=bt();function xt(){const{totalGutterCssVar:i}=Te();return i}function It(){if(S.current){const f=window.getComputedStyle(S.current).getPropertyValue(`--${n}-items-per-slide`).trim();return Number(f)||1}return 1}function Z(i){w.current&&(k.current||V({type:"next",toIndex:i,actionType:"click"}))}function ee(i){w.current&&(I.current||V({type:"prev",toIndex:i,actionType:"click"}))}function V({type:i,shouldAnimate:f=!0,toIndex:_,actionType:y}){var xe,Ie;const x=!f;I.current=!1,k.current=!1;let C=U.value.get(),D=0;if(i==="next"&&(d.current+=1),i==="prev"&&(d.current===0?d.current=e.length-1:d.current-=1),_!==void 0&&(d.current=_),i==="next"){const Y=te(r?E.current*(e.length*2):0);D=-(d.current*E.current),r&&d.current===e.length&&(d.current=0,C=C+E.current*e.length,D=0),!r&&Math.abs(D)>=Y&&(k.current=!0,D=-Y)}i==="prev"&&(D=-(d.current*E.current),d.current===e.length-1&&(C=C-e.length*E.current),!r&&D>=0&&(I.current=!0,D=0)),N.current=D,y==="resize"?(D=-(d.current*E.current),W({eventName:"onResize",sliceActionType:y,slideDirection:i,currentItem:{index:d.current,id:((xe=e.at(d.current))==null?void 0:xe.id)??"",startReached:I.current,endReached:k.current}})):W({eventName:"onSlideStartChange",sliceActionType:y,slideDirection:i,nextItem:{index:d.current,id:((Ie=e.at(d.current))==null?void 0:Ie.id)??"",startReached:I.current,endReached:k.current}}),Q.start({immediate:x,from:{value:C},to:{value:D},onRest({finished:Y}){var ke;Y&&W({eventName:"onSlideChangeComplete",sliceActionType:y,slideDirection:i,currentItem:{index:d.current,id:((ke=e.at(d.current))==null?void 0:ke.id)??"",startReached:I.current,endReached:k.current}})}})}function kt(){const i=O.current.children[0];let f=0;return f=i.getBoundingClientRect()[a==="x"?"width":"height"]+xt(),f}function te(i){const f=O.current;return f[a==="x"?"scrollWidth":"scrollHeight"]-f.getBoundingClientRect()[a==="x"?"width":"height"]-i}function Te(){let i=0,f=0;if(S.current){const _=window.getComputedStyle(S.current),y=_.getPropertyValue(`--${n}-start-end-gutter`).trim();y.includes("px")&&(i=Number(y.replace("px","")));const x=_.getPropertyValue(`--${n}-gutter`).trim();x.includes("px")&&(f=Number(x.replace("px","")))}return{totalStartEndGutterCssVar:i,totalGutterCssVar:f}}m.useEffect(()=>{function i(y){const x=It();switch(y){case"start":return 0;case"middle-start":return Math.floor((x-1)*.25);case"center":return Math.floor((x-1)*.5);case"middle-end":return Math.floor((x-1)*.75);case"end":return x-1;default:return 0}}function f(y){if(E.current=kt(),B.current=E.current/4,S.current){const{totalStartEndGutterCssVar:x}=Te();let C=0;r&&(C=E.current*e.length),C-=E.current*i(c),C-=x/2,S.current.style.setProperty(`--${n}-offset-modifier`,`${-C}px`),$(!0),y&&y()}}function _(){f(),V({type:"resize",toIndex:d.current,shouldAnimate:!1,actionType:"resize"})}if(t)return w.current=!0,f(u),window.addEventListener("resize",_),()=>{window.removeEventListener("resize",_)}},[t,r,n,a,s,c]),m.useEffect(()=>{t&&v!==d.current&&V({type:"next",toIndex:v,actionType:"resize",shouldAnimate:!1})},[t,v]);const Se=l,Ct=yt(i=>{if(!w.current)return;const f=i.dragging,_=i.offset[a==="x"?0:1],y=i.movement[a==="x"?0:1],x=y>B.current,C=y<-B.current,D=i.velocity;f&&(W({...i,eventName:"onDrag",slideActionType:"drag"}),Q.start({value:_,immediate:!0,config:{velocity:D}}),h&&(x||C)&&i.cancel()),i.last&&(x?(V({actionType:"drag",type:"prev"}),i.cancel()):C?(V({actionType:"drag",type:"next"}),i.cancel()):(Q.start({value:N.current,config:{velocity:D}}),i.cancel()))},{enabled:Se,axis:a,rubberband:!r,...r?{}:{bounds:()=>({right:0,left:-te(0),top:-te(0),bottom:0})},from:()=>[U.value.get(),U.value.get()]});function Dt(i){var f,_;return typeof i=="number"?d.current===i:((f=e.find(y=>y.id===i))==null?void 0:f.id)===((_=e[d.current])==null?void 0:_.id)}return{carouselFragment:L.jsxs("div",{ref:S,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,...Ct(),children:[L.jsx("style",{dangerouslySetInnerHTML:{__html:_t(`
|
|
2
2
|
[data-part-internal="${n}-Container"] {
|
|
3
3
|
display: flex;
|
|
4
4
|
width: 100%;
|
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
`).join(""):""}
|
|
47
|
-
`)}}),
|
|
47
|
+
`)}}),L.jsx("div",{ref:O,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track`,onScroll:()=>{I.current=!1,k.current=!1},children:St.map((i,f)=>L.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,"data-id":i.id,children:typeof i.renderItem=="function"?i.renderItem({useListenToCustomEvent:Ee,index:f,isClonedItem:!!i.isClonedItem,isActiveItem:Dt}):i.renderItem},`${i.id}-${f}`))})]}),useListenToCustomEvent:Ee,slideToNextItem:()=>Z(),slideToPrevItem:()=>ee(),slideToItem:i=>{if(typeof i=="number"){if(!e[i]){console.warn(`The item you're trying to slide doesn't exist. index: ${i}`);return}i>d.current?Z(i):ee(i)}if(typeof i=="string"){const f=e.findIndex(_=>_.id===i);if(f<0){console.warn(`The item you're trying to slide doesn't exist. id: ${i}`);return}f>d.current?Z(f):ee(f)}}}}function Et(t){let e=0;const r=getComputedStyle(t).getPropertyValue("gap");return r.includes("px")&&(e=Number(r.replace("px",""))),e}function we(t){return t.scrollWidth-t.clientWidth}function J(t){const e=t.children[0],r=Et(t);return e.getBoundingClientRect().width+r}function Tt({container:t,onReach:e}){const r=m.useRef("start"),n=m.useRef(0),[,s]=re.useSpring(()=>({x:0}));function o(c){s.start({from:{x:t.current.scrollLeft},to:{x:c},onChange({value:l}){t.current&&(t.current.scrollLeft=l.x)}})}function a(c){if(!t.current||c==="next"&&r.current==="end"||c==="prev"&&r.current==="start")return;let l=0;if(c==="next"&&(n.current+=1),c==="prev"&&(n.current-=1),l=n.current*J(t.current),c==="next"){const h=we(t.current);l>h&&(r.current="end",l=h,e&&e("end"))}c==="prev"&&l<=0&&(r.current="start",n.current=0,l=0,e&&e("start")),o(l)}return m.useEffect(()=>{function c(){var E;const $=J(t.current),w=((E=[...t.current.children].at(0))==null?void 0:E.getBoundingClientRect().width)||0,S=Array(t.current.childElementCount).fill(0).map((I,k)=>({index:k,start:$*k,end:$*(k+1)})),O=t.current.scrollLeft+w,N=S.find(I=>O>=I.start&&O<I.end);n.current=(N==null?void 0:N.index)||0}function l(){s.stop()}function h($){const w=$.target;w.scrollLeft===0?(n.current=0,r.current="start",e&&e("start")):w.scrollLeft>=we(w)?(r.current="end",e&&e("end")):r.current!=="idle"&&(r.current="idle",e&&e("idle"))}let u,v=0;function g(){v=t.current.scrollLeft,clearTimeout(u),u=setTimeout(function(){t.current.scrollLeft===v&&c()},200)}if(t.current)return t.current.addEventListener("wheel",l,{passive:!0}),t.current.addEventListener("scroll",h),t.current.addEventListener("scroll",g),()=>{t.current&&(t.current.removeEventListener("scroll",g),t.current.removeEventListener("scroll",h),t.current.removeEventListener("wheel",l))}},[t,e]),m.useEffect(()=>{if(t.current){const c=new ResizeObserver(()=>{o(n.current*J(t.current))});return c.observe(t.current),()=>{c.disconnect()}}},[]),{scrollToNext(){a("next")},scrollToPrev(){a("prev")}}}A.useSpringCarousel=wt,A.useSpringScroll=Tt,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|