react-spring-carousel 3.0.0-beta-2.0.5061 → 3.0.0-beta-2.0.5063
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 +91 -88
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as Me, jsx as J } from "react/jsx-runtime";
|
|
2
2
|
import { useSpringRef as Ve, useSpring as Ee } from "@react-spring/web";
|
|
3
|
-
import Q, { useRef as
|
|
3
|
+
import Q, { useRef as D, useEffect as j, useState as Re } from "react";
|
|
4
4
|
function je(t, e, r) {
|
|
5
5
|
return Math.max(e, Math.min(t, r));
|
|
6
6
|
}
|
|
@@ -45,7 +45,7 @@ function Ke(t) {
|
|
|
45
45
|
var e = Ue(t, "string");
|
|
46
46
|
return typeof e == "symbol" ? e : String(e);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function x(t, e, r) {
|
|
49
49
|
return e = Ke(e), e in t ? Object.defineProperty(t, e, {
|
|
50
50
|
value: r,
|
|
51
51
|
enumerable: !0,
|
|
@@ -67,7 +67,7 @@ function p(t) {
|
|
|
67
67
|
for (var e = 1; e < arguments.length; e++) {
|
|
68
68
|
var r = arguments[e] != null ? arguments[e] : {};
|
|
69
69
|
e % 2 ? de(Object(r), !0).forEach(function(n) {
|
|
70
|
-
|
|
70
|
+
x(t, n, r[n]);
|
|
71
71
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : de(Object(r)).forEach(function(n) {
|
|
72
72
|
Object.defineProperty(t, n, Object.getOwnPropertyDescriptor(r, n));
|
|
73
73
|
});
|
|
@@ -126,7 +126,7 @@ function He(t, e = "") {
|
|
|
126
126
|
function Y(t) {
|
|
127
127
|
return "touches" in t;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function xe(t) {
|
|
130
130
|
return Y(t) ? "touch" : "pointerType" in t ? t.pointerType : "mouse";
|
|
131
131
|
}
|
|
132
132
|
function Xe(t) {
|
|
@@ -138,18 +138,18 @@ function Xe(t) {
|
|
|
138
138
|
function qe(t) {
|
|
139
139
|
return t.type === "touchend" || t.type === "touchcancel" ? t.changedTouches : t.targetTouches;
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function Se(t) {
|
|
142
142
|
return Y(t) ? qe(t)[0] : t;
|
|
143
143
|
}
|
|
144
144
|
function Je(t) {
|
|
145
145
|
return Xe(t).map((e) => e.identifier);
|
|
146
146
|
}
|
|
147
147
|
function Z(t) {
|
|
148
|
-
const e =
|
|
148
|
+
const e = Se(t);
|
|
149
149
|
return Y(t) ? e.identifier : e.pointerId;
|
|
150
150
|
}
|
|
151
151
|
function pe(t) {
|
|
152
|
-
const e =
|
|
152
|
+
const e = Se(t);
|
|
153
153
|
return [e.clientX, e.clientY];
|
|
154
154
|
}
|
|
155
155
|
function Qe(t) {
|
|
@@ -263,8 +263,8 @@ class rt {
|
|
|
263
263
|
this.restrictToAxis && !r._blocked && this.restrictToAxis(m);
|
|
264
264
|
const E = r.offset, k = r._active && !r._blocked || r.active;
|
|
265
265
|
k && (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 = W(n.bounds, r)), this.setup && this.setup()), r.movement = m, this.computeOffset()));
|
|
266
|
-
const [P, y] = r.offset, [[
|
|
267
|
-
r.overflow = [P <
|
|
266
|
+
const [P, y] = r.offset, [[C, N], [b, S]] = r._bounds;
|
|
267
|
+
r.overflow = [P < C ? -1 : P > N ? 1 : 0, y < b ? -1 : y > S ? 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 L = r._active ? n.rubberband || [0, 0] : [0, 0];
|
|
269
269
|
if (r.offset = Be(r._bounds, r.offset, L), r.delta = w.sub(r.offset, E), this.computeMovement(), k && (!r.last || o > tt)) {
|
|
270
270
|
r.delta = w.sub(r.offset, E);
|
|
@@ -293,7 +293,7 @@ function nt([t, e], r) {
|
|
|
293
293
|
}
|
|
294
294
|
class st extends rt {
|
|
295
295
|
constructor(...e) {
|
|
296
|
-
super(...e),
|
|
296
|
+
super(...e), x(this, "aliasKey", "xy");
|
|
297
297
|
}
|
|
298
298
|
reset() {
|
|
299
299
|
super.reset(), this.state.axis = void 0;
|
|
@@ -310,7 +310,7 @@ class st extends rt {
|
|
|
310
310
|
axisIntent(e) {
|
|
311
311
|
const r = this.state, n = this.config;
|
|
312
312
|
if (!r.axis && e) {
|
|
313
|
-
const s = typeof n.axisThreshold == "object" ? n.axisThreshold[
|
|
313
|
+
const s = typeof n.axisThreshold == "object" ? n.axisThreshold[xe(e)] : n.axisThreshold;
|
|
314
314
|
r.axis = nt(r._movement, s);
|
|
315
315
|
}
|
|
316
316
|
r._blocked = (n.lockDirection || !!n.axis) && !r.axis || !!n.axis && n.axis !== r.axis;
|
|
@@ -386,7 +386,7 @@ process.env.NODE_ENV === "development" && Object.assign(ne, {
|
|
|
386
386
|
return NaN;
|
|
387
387
|
}
|
|
388
388
|
});
|
|
389
|
-
const it = 0,
|
|
389
|
+
const it = 0, B = p(p({}, ne), {}, {
|
|
390
390
|
axis(t, e, {
|
|
391
391
|
axis: r
|
|
392
392
|
}) {
|
|
@@ -397,7 +397,7 @@ const it = 0, j = p(p({}, ne), {}, {
|
|
|
397
397
|
},
|
|
398
398
|
bounds(t = {}) {
|
|
399
399
|
if (typeof t == "function")
|
|
400
|
-
return (o) =>
|
|
400
|
+
return (o) => B.bounds(t(o));
|
|
401
401
|
if ("current" in t)
|
|
402
402
|
return () => t.current;
|
|
403
403
|
if (typeof HTMLElement == "function" && t instanceof HTMLElement)
|
|
@@ -418,7 +418,7 @@ const it = 0, j = p(p({}, ne), {}, {
|
|
|
418
418
|
};
|
|
419
419
|
class ot extends st {
|
|
420
420
|
constructor(...e) {
|
|
421
|
-
super(...e),
|
|
421
|
+
super(...e), x(this, "ingKey", "dragging");
|
|
422
422
|
}
|
|
423
423
|
reset() {
|
|
424
424
|
super.reset();
|
|
@@ -434,7 +434,7 @@ class ot extends st {
|
|
|
434
434
|
top: r.top - n.top + e.offset[1],
|
|
435
435
|
bottom: r.bottom - n.bottom + e.offset[1]
|
|
436
436
|
};
|
|
437
|
-
e._bounds =
|
|
437
|
+
e._bounds = B.bounds(s);
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
440
|
cancel() {
|
|
@@ -453,7 +453,7 @@ class ot extends st {
|
|
|
453
453
|
const r = this.config, n = this.state;
|
|
454
454
|
if (e.buttons != null && (Array.isArray(r.pointerButtons) ? !r.pointerButtons.includes(e.buttons) : r.pointerButtons !== -1 && r.pointerButtons !== e.buttons)) return;
|
|
455
455
|
const s = this.ctrl.setEventIds(e);
|
|
456
|
-
r.pointerCapture && e.target.setPointerCapture(e.pointerId), !(s && s.size > 1 && n._pointerActive) && (this.start(e), this.setupPointer(e), n._pointerId = Z(e), n._pointerActive = !0, this.computeValues(pe(e)), this.computeInitial(), r.preventScrollAxis &&
|
|
456
|
+
r.pointerCapture && e.target.setPointerCapture(e.pointerId), !(s && s.size > 1 && n._pointerActive) && (this.start(e), this.setupPointer(e), n._pointerId = Z(e), n._pointerActive = !0, this.computeValues(pe(e)), this.computeInitial(), r.preventScrollAxis && xe(e) !== "mouse" ? (n._active = !1, this.setupScrollPrevention(e)) : r.delay > 0 ? (this.setupDelayTrigger(e), r.triggerAllEvents && (this.compute(e), this.emit())) : this.startPointerDrag(e));
|
|
457
457
|
}
|
|
458
458
|
startPointerDrag(e) {
|
|
459
459
|
const r = this.state;
|
|
@@ -500,8 +500,8 @@ class ot extends st {
|
|
|
500
500
|
else {
|
|
501
501
|
const [c, l] = r._delta, [d, u] = r._movement, [v, m] = n.swipe.velocity, [E, k] = n.swipe.distance, P = n.swipe.duration;
|
|
502
502
|
if (r.elapsedTime < P) {
|
|
503
|
-
const y = Math.abs(c / r.timeDelta),
|
|
504
|
-
y > v && Math.abs(d) > E && (r.swipe[0] = Math.sign(c)),
|
|
503
|
+
const y = Math.abs(c / r.timeDelta), C = Math.abs(l / r.timeDelta);
|
|
504
|
+
y > v && Math.abs(d) > E && (r.swipe[0] = Math.sign(c)), C > m && Math.abs(u) > k && (r.swipe[1] = Math.sign(l));
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
this.emit();
|
|
@@ -560,18 +560,18 @@ class ot extends st {
|
|
|
560
560
|
function at(t) {
|
|
561
561
|
"persist" in t && typeof t.persist == "function" && t.persist();
|
|
562
562
|
}
|
|
563
|
-
const
|
|
563
|
+
const U = typeof window < "u" && window.document && window.document.createElement;
|
|
564
564
|
function Ie() {
|
|
565
|
-
return
|
|
565
|
+
return U && "ontouchstart" in window;
|
|
566
566
|
}
|
|
567
567
|
function ct() {
|
|
568
|
-
return Ie() ||
|
|
568
|
+
return Ie() || U && window.navigator.maxTouchPoints > 1;
|
|
569
569
|
}
|
|
570
570
|
function ut() {
|
|
571
|
-
return
|
|
571
|
+
return U && "onpointerdown" in window;
|
|
572
572
|
}
|
|
573
573
|
function lt() {
|
|
574
|
-
return
|
|
574
|
+
return U && "exitPointerLock" in window.document;
|
|
575
575
|
}
|
|
576
576
|
function ft() {
|
|
577
577
|
try {
|
|
@@ -580,8 +580,8 @@ function ft() {
|
|
|
580
580
|
return !1;
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
|
-
const
|
|
584
|
-
isBrowser:
|
|
583
|
+
const $ = {
|
|
584
|
+
isBrowser: U,
|
|
585
585
|
gesture: ft(),
|
|
586
586
|
touch: Ie(),
|
|
587
587
|
touchscreen: ct(),
|
|
@@ -591,7 +591,7 @@ const D = {
|
|
|
591
591
|
mouse: 0,
|
|
592
592
|
touch: 0,
|
|
593
593
|
pen: 8
|
|
594
|
-
}, ke = p(p({},
|
|
594
|
+
}, ke = p(p({}, B), {}, {
|
|
595
595
|
device(t, e, {
|
|
596
596
|
pointer: {
|
|
597
597
|
touch: r = !1,
|
|
@@ -599,12 +599,12 @@ const D = {
|
|
|
599
599
|
mouse: s = !1
|
|
600
600
|
} = {}
|
|
601
601
|
}) {
|
|
602
|
-
return this.pointerLock = n &&
|
|
602
|
+
return this.pointerLock = n && $.pointerLock, $.touch && r ? "touch" : this.pointerLock ? "mouse" : $.pointer && !s ? "pointer" : $.touch ? "touch" : "mouse";
|
|
603
603
|
},
|
|
604
604
|
preventScrollAxis(t, e, {
|
|
605
605
|
preventScroll: r
|
|
606
606
|
}) {
|
|
607
|
-
if (this.preventScrollDelay = typeof r == "number" ? r : r || r === void 0 && t ? dt : void 0, !(
|
|
607
|
+
if (this.preventScrollDelay = typeof r == "number" ? r : r || r === void 0 && t ? dt : void 0, !(!$.touchscreen || r === !1))
|
|
608
608
|
return t || (r !== void 0 ? "y" : void 0);
|
|
609
609
|
},
|
|
610
610
|
pointerCapture(t, e, {
|
|
@@ -686,11 +686,11 @@ p(p({}, ne), {}, {
|
|
|
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 && !$.touch && $.gesture) return "gesture";
|
|
690
|
+
if ($.touch && n) return "touch";
|
|
691
|
+
if ($.touchscreen) {
|
|
692
|
+
if ($.pointer) return "pointer";
|
|
693
|
+
if ($.touch) return "touch";
|
|
694
694
|
}
|
|
695
695
|
},
|
|
696
696
|
bounds(t, e, {
|
|
@@ -722,10 +722,10 @@ p(p({}, ne), {}, {
|
|
|
722
722
|
return t;
|
|
723
723
|
}
|
|
724
724
|
});
|
|
725
|
-
p(p({},
|
|
725
|
+
p(p({}, B), {}, {
|
|
726
726
|
mouseOnly: (t = !0) => t
|
|
727
727
|
});
|
|
728
|
-
p(p({},
|
|
728
|
+
p(p({}, B), {}, {
|
|
729
729
|
mouseOnly: (t = !0) => t
|
|
730
730
|
});
|
|
731
731
|
const Ce = /* @__PURE__ */ new Map(), re = /* @__PURE__ */ new Map();
|
|
@@ -762,7 +762,7 @@ const Et = {
|
|
|
762
762
|
enabled(t = !0) {
|
|
763
763
|
return t;
|
|
764
764
|
},
|
|
765
|
-
window(t =
|
|
765
|
+
window(t = $.isBrowser ? window : void 0) {
|
|
766
766
|
return t;
|
|
767
767
|
},
|
|
768
768
|
eventOptions({
|
|
@@ -798,7 +798,7 @@ function G(t = {}, e) {
|
|
|
798
798
|
}
|
|
799
799
|
return r;
|
|
800
800
|
}
|
|
801
|
-
function
|
|
801
|
+
function xt(t, e, r = {}) {
|
|
802
802
|
const n = t, {
|
|
803
803
|
target: s,
|
|
804
804
|
eventOptions: o,
|
|
@@ -834,7 +834,7 @@ function St(t, e, r = {}) {
|
|
|
834
834
|
}
|
|
835
835
|
class De {
|
|
836
836
|
constructor(e, r) {
|
|
837
|
-
|
|
837
|
+
x(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = e, this._gestureKey = r;
|
|
838
838
|
}
|
|
839
839
|
add(e, r, n, s, o) {
|
|
840
840
|
const a = this._listeners, c = He(r, n), l = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, d = p(p({}, l), o);
|
|
@@ -848,9 +848,9 @@ class De {
|
|
|
848
848
|
this._listeners.forEach((e) => e()), this._listeners.clear();
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
|
-
class
|
|
851
|
+
class St {
|
|
852
852
|
constructor() {
|
|
853
|
-
|
|
853
|
+
x(this, "_timeouts", /* @__PURE__ */ new Map());
|
|
854
854
|
}
|
|
855
855
|
add(e, r, n = 140, ...s) {
|
|
856
856
|
this.remove(e), this._timeouts.set(e, window.setTimeout(r, n, ...s));
|
|
@@ -865,7 +865,7 @@ class xt {
|
|
|
865
865
|
}
|
|
866
866
|
class It {
|
|
867
867
|
constructor(e) {
|
|
868
|
-
|
|
868
|
+
x(this, "gestures", /* @__PURE__ */ new Set()), x(this, "_targetEventStore", new De(this)), x(this, "gestureEventStores", {}), x(this, "gestureTimeoutStores", {}), x(this, "handlers", {}), x(this, "config", {}), x(this, "pointerIds", /* @__PURE__ */ new Set()), x(this, "touchIds", /* @__PURE__ */ new Set()), x(this, "state", {
|
|
869
869
|
shared: {
|
|
870
870
|
shiftKey: !1,
|
|
871
871
|
metaKey: !1,
|
|
@@ -884,7 +884,7 @@ class It {
|
|
|
884
884
|
this.handlers = e, this.nativeHandlers = r;
|
|
885
885
|
}
|
|
886
886
|
applyConfig(e, r) {
|
|
887
|
-
this.config =
|
|
887
|
+
this.config = xt(e, r, this.config);
|
|
888
888
|
}
|
|
889
889
|
clean() {
|
|
890
890
|
this._targetEventStore.clean();
|
|
@@ -930,11 +930,11 @@ class It {
|
|
|
930
930
|
}
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
|
-
function
|
|
934
|
-
t.gestures.add(e), t.gestureEventStores[e] = new De(t, e), t.gestureTimeoutStores[e] = new
|
|
933
|
+
function R(t, e) {
|
|
934
|
+
t.gestures.add(e), t.gestureEventStores[e] = new De(t, e), t.gestureTimeoutStores[e] = new St();
|
|
935
935
|
}
|
|
936
936
|
function kt(t, e) {
|
|
937
|
-
e.drag &&
|
|
937
|
+
e.drag && R(t, "drag"), e.wheel && R(t, "wheel"), e.scroll && R(t, "scroll"), e.move && R(t, "move"), e.pinch && R(t, "pinch"), e.hover && R(t, "hover");
|
|
938
938
|
}
|
|
939
939
|
const _e = (t, e, r) => (n, s, o, a = {}, c = !1) => {
|
|
940
940
|
var l, d;
|
|
@@ -953,10 +953,10 @@ function Dt(t, e) {
|
|
|
953
953
|
}, e || {}, "drag");
|
|
954
954
|
}
|
|
955
955
|
const ee = "RSC::Event";
|
|
956
|
-
function
|
|
957
|
-
const t =
|
|
956
|
+
function $t() {
|
|
957
|
+
const t = D(null);
|
|
958
958
|
function e(n) {
|
|
959
|
-
|
|
959
|
+
j(() => {
|
|
960
960
|
t.current || (t.current = document.createElement("div"));
|
|
961
961
|
function s(o) {
|
|
962
962
|
n(o.detail);
|
|
@@ -985,7 +985,7 @@ function Pt() {
|
|
|
985
985
|
emitEvent: r
|
|
986
986
|
};
|
|
987
987
|
}
|
|
988
|
-
function
|
|
988
|
+
function Pt(t) {
|
|
989
989
|
let e = t.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm, "");
|
|
990
990
|
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();
|
|
991
991
|
}
|
|
@@ -1004,13 +1004,13 @@ function Vt({
|
|
|
1004
1004
|
initialActiveItem: v = 0,
|
|
1005
1005
|
slideType: m = "item"
|
|
1006
1006
|
}) {
|
|
1007
|
-
const [E, k] = Re(!1), P =
|
|
1007
|
+
const [E, k] = Re(!1), P = D(t), y = D(null), C = D(null), N = D(0), b = D(0), S = D(!r), L = D(!1), O = D(0), h = D(0), K = Ve(), F = Ee({
|
|
1008
1008
|
value: 0,
|
|
1009
|
-
ref:
|
|
1009
|
+
ref: K,
|
|
1010
1010
|
onChange({ value: i }) {
|
|
1011
|
-
|
|
1011
|
+
C.current.style.transform = `translate3d(calc(${i.value}px + var(--${n}-offset-modifier)), 0px, 0px)`;
|
|
1012
1012
|
}
|
|
1013
|
-
}),
|
|
1013
|
+
}), $e = r ? [
|
|
1014
1014
|
...e.map((i) => ({
|
|
1015
1015
|
...i,
|
|
1016
1016
|
id: `prev-repeated-item-${i.id}`,
|
|
@@ -1022,8 +1022,8 @@ function Vt({
|
|
|
1022
1022
|
id: `next-repeated-item-${i.id}`,
|
|
1023
1023
|
isClonedItem: !0
|
|
1024
1024
|
}))
|
|
1025
|
-
] : e, { useListenToCustomEvent: se, emitEvent:
|
|
1026
|
-
function
|
|
1025
|
+
] : e, { useListenToCustomEvent: se, emitEvent: z } = $t();
|
|
1026
|
+
function Pe() {
|
|
1027
1027
|
const { totalGutterCssVar: i } = ie();
|
|
1028
1028
|
return i;
|
|
1029
1029
|
}
|
|
@@ -1044,7 +1044,7 @@ function Vt({
|
|
|
1044
1044
|
}));
|
|
1045
1045
|
}
|
|
1046
1046
|
function X(i) {
|
|
1047
|
-
P.current && (
|
|
1047
|
+
P.current && (S.current || M({
|
|
1048
1048
|
type: "prev",
|
|
1049
1049
|
toIndex: i,
|
|
1050
1050
|
actionType: "click"
|
|
@@ -1058,35 +1058,35 @@ function Vt({
|
|
|
1058
1058
|
}) {
|
|
1059
1059
|
var ae, ce;
|
|
1060
1060
|
const A = !f;
|
|
1061
|
-
|
|
1061
|
+
S.current = !1, L.current = !1;
|
|
1062
1062
|
let g = F.value.get(), I = 0;
|
|
1063
1063
|
if (i === "next" && (h.current += 1), i === "prev" && (h.current === 0 ? h.current = e.length - 1 : h.current -= 1), _ !== void 0 && (h.current = _), i === "next") {
|
|
1064
|
-
const
|
|
1064
|
+
const V = q(
|
|
1065
1065
|
r ? b.current * (e.length * 2) : 0
|
|
1066
1066
|
);
|
|
1067
|
-
I = -(h.current * b.current), r && h.current === e.length && (h.current = 0, g = g + b.current * e.length, I = 0), !r && (Math.abs(I) >=
|
|
1067
|
+
I = -(h.current * b.current), r && h.current === e.length && (h.current = 0, g = g + b.current * e.length, I = 0), !r && (Math.abs(I) >= V || h.current === e.length - 1) && (L.current = !0, I = -V);
|
|
1068
1068
|
}
|
|
1069
|
-
i === "prev" && (I = -(h.current * b.current), h.current === e.length - 1 && (g = g - e.length * b.current), !r && I >= 0 && (
|
|
1069
|
+
i === "prev" && (I = -(h.current * b.current), h.current === e.length - 1 && (g = g - e.length * b.current), !r && I >= 0 && (S.current = !0, I = 0)), N.current = I, T === "resize" ? (I = -(h.current * b.current), z({
|
|
1070
1070
|
eventName: "onResize",
|
|
1071
1071
|
sliceActionType: T,
|
|
1072
1072
|
slideDirection: i,
|
|
1073
1073
|
currentItem: {
|
|
1074
1074
|
index: h.current,
|
|
1075
1075
|
id: ((ae = e.at(h.current)) == null ? void 0 : ae.id) ?? "",
|
|
1076
|
-
startReached:
|
|
1076
|
+
startReached: S.current,
|
|
1077
1077
|
endReached: L.current
|
|
1078
1078
|
}
|
|
1079
|
-
})) :
|
|
1079
|
+
})) : z({
|
|
1080
1080
|
eventName: "onSlideStartChange",
|
|
1081
1081
|
sliceActionType: T,
|
|
1082
1082
|
slideDirection: i,
|
|
1083
1083
|
nextItem: {
|
|
1084
1084
|
index: h.current,
|
|
1085
1085
|
id: ((ce = e.at(h.current)) == null ? void 0 : ce.id) ?? "",
|
|
1086
|
-
startReached:
|
|
1086
|
+
startReached: S.current,
|
|
1087
1087
|
endReached: L.current
|
|
1088
1088
|
}
|
|
1089
|
-
}), console.log("12312312312312312"),
|
|
1089
|
+
}), console.log("12312312312312312"), K.start({
|
|
1090
1090
|
immediate: A,
|
|
1091
1091
|
from: {
|
|
1092
1092
|
value: g
|
|
@@ -1094,26 +1094,29 @@ function Vt({
|
|
|
1094
1094
|
to: {
|
|
1095
1095
|
value: I
|
|
1096
1096
|
},
|
|
1097
|
-
onRest({ finished:
|
|
1097
|
+
onRest({ finished: V }) {
|
|
1098
1098
|
var ue;
|
|
1099
|
-
|
|
1099
|
+
V && z({
|
|
1100
1100
|
eventName: "onSlideChangeComplete",
|
|
1101
1101
|
sliceActionType: T,
|
|
1102
1102
|
slideDirection: i,
|
|
1103
1103
|
currentItem: {
|
|
1104
1104
|
index: h.current,
|
|
1105
1105
|
id: ((ue = e.at(h.current)) == null ? void 0 : ue.id) ?? "",
|
|
1106
|
-
startReached:
|
|
1106
|
+
startReached: S.current,
|
|
1107
1107
|
endReached: L.current
|
|
1108
1108
|
}
|
|
1109
1109
|
});
|
|
1110
|
+
},
|
|
1111
|
+
onChange({ value: V }) {
|
|
1112
|
+
C.current.style.transform = `translate3d(calc(${V.value}px + var(--${n}-offset-modifier)), 0px, 0px)`;
|
|
1110
1113
|
}
|
|
1111
1114
|
});
|
|
1112
1115
|
}
|
|
1113
1116
|
function Ae() {
|
|
1114
|
-
const i = m === "item" ?
|
|
1117
|
+
const i = m === "item" ? C.current.children[0] : y.current;
|
|
1115
1118
|
let f = 0;
|
|
1116
|
-
return f = i.getBoundingClientRect()[a === "x" ? "width" : "height"] +
|
|
1119
|
+
return f = i.getBoundingClientRect()[a === "x" ? "width" : "height"] + Pe(), f;
|
|
1117
1120
|
}
|
|
1118
1121
|
function q(i) {
|
|
1119
1122
|
const f = y.current;
|
|
@@ -1133,7 +1136,7 @@ function Vt({
|
|
|
1133
1136
|
}
|
|
1134
1137
|
return { totalStartEndGutterCssVar: i, totalGutterCssVar: f };
|
|
1135
1138
|
}
|
|
1136
|
-
|
|
1139
|
+
j(() => {
|
|
1137
1140
|
function i(A) {
|
|
1138
1141
|
const g = Oe();
|
|
1139
1142
|
switch (A) {
|
|
@@ -1175,14 +1178,14 @@ function Vt({
|
|
|
1175
1178
|
return P.current = !0, _(), window.addEventListener("resize", T), () => {
|
|
1176
1179
|
window.removeEventListener("resize", T);
|
|
1177
1180
|
};
|
|
1178
|
-
}, [t]),
|
|
1181
|
+
}, [t]), j(() => {
|
|
1179
1182
|
t && v !== h.current && (console.log("resize also ere?"), M({
|
|
1180
1183
|
type: "next",
|
|
1181
1184
|
toIndex: v,
|
|
1182
1185
|
actionType: "resize",
|
|
1183
1186
|
shouldAnimate: !1
|
|
1184
1187
|
}));
|
|
1185
|
-
}, [t, v]),
|
|
1188
|
+
}, [t, v]), j(() => {
|
|
1186
1189
|
E && u && u();
|
|
1187
1190
|
}, [E, u]);
|
|
1188
1191
|
const oe = l, Le = Dt(
|
|
@@ -1190,11 +1193,11 @@ function Vt({
|
|
|
1190
1193
|
if (!P.current)
|
|
1191
1194
|
return;
|
|
1192
1195
|
const f = i.dragging, _ = i.offset[a === "x" ? 0 : 1], T = i.movement[a === "x" ? 0 : 1], A = T > O.current, g = T < -O.current, I = i.velocity;
|
|
1193
|
-
f && (
|
|
1196
|
+
f && (z({
|
|
1194
1197
|
...i,
|
|
1195
1198
|
eventName: "onDrag",
|
|
1196
1199
|
slideActionType: "drag"
|
|
1197
|
-
}), console.log("222222"),
|
|
1200
|
+
}), console.log("222222"), K.start({
|
|
1198
1201
|
value: _,
|
|
1199
1202
|
immediate: !0,
|
|
1200
1203
|
config: {
|
|
@@ -1206,7 +1209,7 @@ function Vt({
|
|
|
1206
1209
|
}), i.cancel()) : g ? (M({
|
|
1207
1210
|
actionType: "drag",
|
|
1208
1211
|
type: "next"
|
|
1209
|
-
}), i.cancel()) : (console.log("333333"),
|
|
1212
|
+
}), i.cancel()) : (console.log("333333"), K.start({
|
|
1210
1213
|
value: N.current,
|
|
1211
1214
|
config: {
|
|
1212
1215
|
velocity: I
|
|
@@ -1246,7 +1249,7 @@ function Vt({
|
|
|
1246
1249
|
"style",
|
|
1247
1250
|
{
|
|
1248
1251
|
dangerouslySetInnerHTML: {
|
|
1249
|
-
__html:
|
|
1252
|
+
__html: Pt(`
|
|
1250
1253
|
[data-part-internal="${n}-Container"] {
|
|
1251
1254
|
display: flex;
|
|
1252
1255
|
width: 100%;
|
|
@@ -1303,14 +1306,14 @@ function Vt({
|
|
|
1303
1306
|
/* @__PURE__ */ J(
|
|
1304
1307
|
"div",
|
|
1305
1308
|
{
|
|
1306
|
-
ref:
|
|
1309
|
+
ref: C,
|
|
1307
1310
|
className: "ReactSpringCarouselTrack",
|
|
1308
1311
|
"data-part": "Track",
|
|
1309
1312
|
"data-part-internal": `${n}-Track`,
|
|
1310
1313
|
onScroll: () => {
|
|
1311
|
-
|
|
1314
|
+
S.current = !1, L.current = !1;
|
|
1312
1315
|
},
|
|
1313
|
-
children:
|
|
1316
|
+
children: $e.map((i, f) => /* @__PURE__ */ J(
|
|
1314
1317
|
"div",
|
|
1315
1318
|
{
|
|
1316
1319
|
className: "ReactSpringCarouselItem",
|
|
@@ -1370,7 +1373,7 @@ function te(t) {
|
|
|
1370
1373
|
return e.getBoundingClientRect().width + r;
|
|
1371
1374
|
}
|
|
1372
1375
|
function Rt({ container: t, onReach: e }) {
|
|
1373
|
-
const r =
|
|
1376
|
+
const r = D("start"), n = D(0), [, s] = Ee(() => ({
|
|
1374
1377
|
x: 0
|
|
1375
1378
|
}));
|
|
1376
1379
|
function o(c) {
|
|
@@ -1396,17 +1399,17 @@ function Rt({ container: t, onReach: e }) {
|
|
|
1396
1399
|
}
|
|
1397
1400
|
c === "prev" && l <= 0 && (r.current = "start", n.current = 0, l = 0, e && e("start")), o(l);
|
|
1398
1401
|
}
|
|
1399
|
-
return
|
|
1402
|
+
return j(() => {
|
|
1400
1403
|
function c() {
|
|
1401
1404
|
var N;
|
|
1402
|
-
const E = te(t.current), k = ((N = [...t.current.children].at(0)) == null ? void 0 : N.getBoundingClientRect().width) || 0, P = Array(t.current.childElementCount).fill(0).map((b,
|
|
1403
|
-
index:
|
|
1404
|
-
start: E *
|
|
1405
|
-
end: E * (
|
|
1406
|
-
})), y = t.current.scrollLeft + k,
|
|
1405
|
+
const E = te(t.current), k = ((N = [...t.current.children].at(0)) == null ? void 0 : N.getBoundingClientRect().width) || 0, P = Array(t.current.childElementCount).fill(0).map((b, S) => ({
|
|
1406
|
+
index: S,
|
|
1407
|
+
start: E * S,
|
|
1408
|
+
end: E * (S + 1)
|
|
1409
|
+
})), y = t.current.scrollLeft + k, C = P.find(
|
|
1407
1410
|
(b) => y >= b.start && y < b.end
|
|
1408
1411
|
);
|
|
1409
|
-
n.current = (
|
|
1412
|
+
n.current = (C == null ? void 0 : C.index) || 0;
|
|
1410
1413
|
}
|
|
1411
1414
|
function l() {
|
|
1412
1415
|
s.stop();
|
|
@@ -1427,7 +1430,7 @@ function Rt({ container: t, onReach: e }) {
|
|
|
1427
1430
|
}), t.current.addEventListener("scroll", d), t.current.addEventListener("scroll", m), () => {
|
|
1428
1431
|
t.current && (t.current.removeEventListener("scroll", m), t.current.removeEventListener("scroll", d), t.current.removeEventListener("wheel", l));
|
|
1429
1432
|
};
|
|
1430
|
-
}, [t, e]),
|
|
1433
|
+
}, [t, e]), j(() => {
|
|
1431
1434
|
if (t.current) {
|
|
1432
1435
|
const c = new ResizeObserver(() => {
|
|
1433
1436
|
o(n.current * te(t.current));
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(L,M){typeof exports=="object"&&typeof module<"u"?M(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"],M):(L=typeof globalThis<"u"?globalThis:L||self,M(L["react-spring-carousel"]={},L["react/jsx-runtime"],L["@react-spring/web"],L.React))})(this,function(L,M,H,g){"use strict";function De(t,e,r){return Math.max(e,Math.min(t,r))}const w={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 se(t,e,r){return e===0||Math.abs(e)===1/0?Math.pow(t,r*5):t*e*r/(e+r*t)}function ie(t,e,r,n=.15){return n===0?De(t,e,r):t<e?-se(e-t,r-e,n)+e:t>r?+se(t-r,r-e,n)+r:t}function Pe(t,[e,r],[n,s]){const[[o,a],[c,l]]=t;return[ie(e,o,a,n),ie(r,c,l,s)]}function $e(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 Oe(t){var e=$e(t,"string");return typeof e=="symbol"?e:String(e)}function x(t,e,r){return e=Oe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function oe(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?oe(Object(r),!0).forEach(function(n){x(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):oe(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}const ae={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 ce(t){return t?t[0].toUpperCase()+t.slice(1):""}const Ae=["enter","leave"];function Le(t=!1,e){return t&&!Ae.includes(e)}function Ne(t,e="",r=!1){const n=ae[t],s=n&&n[e]||e;return"on"+ce(t)+ce(s)+(Le(r,s)?"Capture":"")}const Me=["gotpointercapture","lostpointercapture"];function Ve(t){let e=t.substring(2).toLowerCase();const r=!!~e.indexOf("passive");r&&(e=e.replace("passive",""));const n=Me.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:r}}function je(t,e=""){const r=ae[t],n=r&&r[e]||e;return t+n}function K(t){return"touches"in t}function ue(t){return K(t)?"touch":"pointerType"in t?t.pointerType:"mouse"}function Re(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 Be(t){return t.type==="touchend"||t.type==="touchcancel"?t.changedTouches:t.targetTouches}function le(t){return K(t)?Be(t)[0]:t}function Ue(t){return Re(t).map(e=>e.identifier)}function X(t){const e=le(t);return K(t)?e.identifier:e.pointerId}function fe(t){const e=le(t);return[e.clientX,e.clientY]}function Ke(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 z(t,...e){return typeof t=="function"?t(...e):t}function ze(){}function Ge(...t){return t.length===0?ze:t.length===1?t[0]:function(){let e;for(const r of t)e=r.apply(this,arguments)||e;return e}}function de(t,e){return Object.assign({},e,t||{})}const We=32;class Ye{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?z(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,Ke(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 O=r._delta.map(Math.abs);w.addTo(r._distance,O)}this.axisIntent&&this.axisIntent(e);const[a,c]=r._movement,[l,d]=n.threshold,{_step:u,values:y}=r;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(a)>=l&&y[0]),u[1]===!1&&(u[1]=Math.abs(c)>=d&&y[1])):(u[0]===!1&&(u[0]=Math.abs(a)>=l&&Math.sign(a)*l),u[1]===!1&&(u[1]=Math.abs(c)>=d&&Math.sign(c)*d)),r.intentional=u[0]!==!1||u[1]!==!1,!r.intentional)return;const m=[0,0];if(n.hasCustomTransform){const[O,h]=y;m[0]=u[0]!==!1?O-u[0]:0,m[1]=u[1]!==!1?h-u[1]:0}else m[0]=u[0]!==!1?a-u[0]:0,m[1]=u[1]!==!1?c-u[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(m);const T=r.offset,D=r._active&&!r._blocked||r.active;D&&(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=z(n.bounds,r)),this.setup&&this.setup()),r.movement=m,this.computeOffset()));const[P,b]=r.offset,[[$,V],[_,I]]=r._bounds;r.overflow=[P<$?-1:P>V?1:0,b<_?-1:b>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;const N=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=Pe(r._bounds,r.offset,N),r.delta=w.sub(r.offset,T),this.computeMovement(),D&&(!r.last||o>We)){r.delta=w.sub(r.offset,T);const O=r.delta.map(Math.abs);w.addTo(r.distance,O),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&o>0&&(r.velocity=[O[0]/o,O[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 Fe([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 He extends Ye{constructor(...e){super(...e),x(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=w.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=w.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[ue(e)]:n.axisThreshold;r.axis=Fe(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 he=t=>t,pe=.15,q={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[pe,pe];case!1:return[0,0];default:return w.toVector(t)}},from(t){if(typeof t=="function")return t;if(t!=null)return w.toVector(t)},transform(t,e,r){const n=t||r.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||he;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||he},threshold(t){return w.toVector(t,0)}};process.env.NODE_ENV==="development"&&Object.assign(q,{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 Xe=0,B=p(p({},q),{},{axis(t,e,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(t=Xe){return t},bounds(t={}){if(typeof t=="function")return o=>B.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]]}}),ge={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 qe extends He{constructor(...e){super(...e),x(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=B.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=X(e),n._pointerActive=!0,this.computeValues(fe(e)),this.computeInitial(),r.preventScrollAxis&&ue(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=X(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;const o=fe(e);if(document.pointerLockElement===e.target?r._delta=[e.movementX,e.movementY]:(r._delta=w.sub(o,r._values),this.computeValues(o)),w.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=X(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,[d,u]=r._movement,[y,m]=n.swipe.velocity,[T,D]=n.swipe.distance,P=n.swipe.duration;if(r.elapsedTime<P){const b=Math.abs(c/r.timeDelta),$=Math.abs(l/r.timeDelta);b>y&&Math.abs(d)>T&&(r.swipe[0]=Math.sign(c)),$>m&&Math.abs(u)>D&&(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,Je(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=ge[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,w.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in ge&&(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 Je(t){"persist"in t&&typeof t.persist=="function"&&t.persist()}const U=typeof window<"u"&&window.document&&window.document.createElement;function me(){return U&&"ontouchstart"in window}function Qe(){return me()||U&&window.navigator.maxTouchPoints>1}function Ze(){return U&&"onpointerdown"in window}function et(){return U&&"exitPointerLock"in window.document}function tt(){try{return"constructor"in GestureEvent}catch{return!1}}const C={isBrowser:U,gesture:tt(),touch:me(),touchscreen:Qe(),pointer:Ze(),pointerLock:et()},rt=250,nt=180,st=.5,it=50,ot=250,at=10,ve={mouse:0,touch:0,pen:8},ye=p(p({},B),{},{device(t,e,{pointer:{touch:r=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&C.pointerLock,C.touch&&r?"touch":this.pointerLock?"mouse":C.pointer&&!s?"pointer":C.touch?"touch":"mouse"},preventScrollAxis(t,e,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&t?rt:void 0,!(!C.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=w.toVector(t,r?n:s?1:0);return this.filterTaps=r,this.tapsThreshold=n,o},swipe({velocity:t=st,distance:e=it,duration:r=ot}={}){return{velocity:this.transform(w.toVector(t)),distance:this.transform(w.toVector(e)),duration:r}},delay(t=0){switch(t){case!0:return nt;case!1:return 0;default:return t}},axisThreshold(t){return t?p(p({},ve),t):ve},keyboardDisplacement(t=at){return t}});process.env.NODE_ENV==="development"&&Object.assign(ye,{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({},q),{},{device(t,e,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!C.touch&&C.gesture)return"gesture";if(C.touch&&n)return"touch";if(C.touchscreen){if(C.pointer)return"pointer";if(C.touch)return"touch"}},bounds(t,e,{scaleBounds:r={},angleBounds:n={}}){const s=a=>{const c=de(z(r,a),{min:-1/0,max:1/0});return[c.min,c.max]},o=a=>{const c=de(z(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",w.toVector(t,this.lockDirection?[.1,3]:0)},modifierKey(t){return t===void 0?"ctrlKey":t},pinchOnWheel(t=!0){return t}}),p(p({},B),{},{mouseOnly:(t=!0)=>t}),p(p({},B),{},{mouseOnly:(t=!0)=>t});const be=new Map,J=new Map;function ct(t){be.set(t.key,t.engine),J.set(t.key,t.resolver)}const ut={key:"drag",engine:qe,resolver:ye};function lt(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 ft(t,e){if(t==null)return{};var r=lt(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 dt={target(t){if(t)return()=>"current"in t?t.current:t},enabled(t=!0){return t},window(t=C.isBrowser?window:void 0){return t},eventOptions({passive:t=!0,capture:e=!1}={}){return{passive:t,capture:e}},transform(t){return t}},ht=["target","eventOptions","window","enabled","transform"];function G(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]=G(t[n],s);break;case"boolean":s&&(r[n]=t[n]);break}return r}function pt(t,e,r={}){const n=t,{target:s,eventOptions:o,window:a,enabled:c,transform:l}=n,d=ft(n,ht);if(r.shared=G({target:s,eventOptions:o,window:a,enabled:c,transform:l},dt),e){const u=J.get(e);r[e]=G(p({shared:r.shared},d),u)}else for(const u in d){const y=J.get(u);if(y)r[u]=G(p({shared:r.shared},d[u]),y);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 _e{constructor(e,r){x(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=r}add(e,r,n,s,o){const a=this._listeners,c=je(r,n),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},d=p(p({},l),o);e.addEventListener(c,s,d);const u=()=>{e.removeEventListener(c,s,d),a.delete(u)};return a.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class gt{constructor(){x(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){x(this,"gestures",new Set),x(this,"_targetEventStore",new _e(this)),x(this,"gestureEventStores",{}),x(this,"gestureTimeoutStores",{}),x(this,"handlers",{}),x(this,"config",{}),x(this,"pointerIds",new Set),x(this,"touchIds",new Set),x(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),vt(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=pt(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=we(n,c.eventOptions,!!s);if(c.enabled){const d=be.get(a);new d(this,e,a).bind(l)}}const o=we(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}=Ve(o);this._targetEventStore.add(s,a,"",n[o],{capture:c,passive:l})}}}}function j(t,e){t.gestures.add(e),t.gestureEventStores[e]=new _e(t,e),t.gestureTimeoutStores[e]=new gt}function vt(t,e){e.drag&&j(t,"drag"),e.wheel&&j(t,"wheel"),e.scroll&&j(t,"scroll"),e.move&&j(t,"move"),e.pinch&&j(t,"pinch"),e.hover&&j(t,"hover")}const we=(t,e,r)=>(n,s,o,a={},c=!1)=>{var l,d;const u=(l=a.capture)!==null&&l!==void 0?l:e.capture,y=(d=a.passive)!==null&&d!==void 0?d:e.passive;let m=c?n:Ne(n,s,u);r&&y&&(m+="Passive"),t[m]=t[m]||[],t[m].push(o)};function yt(t,e={},r,n){const s=g.useMemo(()=>new mt(t),[]);if(s.applyHandlers(t,n),s.applyConfig(e,r),g.useEffect(s.effect.bind(s)),g.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function bt(t,e){return ct(ut),yt({drag:t},e||{},"drag")}const Q="RSC::Event";function _t(){const t=g.useRef(null);function e(n){g.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 wt(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 Et({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:d=!0,onInit:u,initialActiveItem:y=0,slideType:m="item"}){const[T,D]=g.useState(!1),P=g.useRef(t),b=g.useRef(null),$=g.useRef(null),V=g.useRef(0),_=g.useRef(0),I=g.useRef(!r),N=g.useRef(!1),O=g.useRef(0),h=g.useRef(0),W=H.useSpringRef(),ee=H.useSpring({value:0,ref:W,onChange({value:i}){$.current.style.transform=`translate3d(calc(${i.value}px + var(--${n}-offset-modifier)), 0px, 0px)`}}),xt=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:Te,emitEvent:Y}=_t();function It(){const{totalGutterCssVar:i}=Se();return i}function kt(){if(b.current){const f=window.getComputedStyle(b.current).getPropertyValue(`--${n}-items-per-slide`).trim();return Number(f)||1}return 1}function te(i){P.current&&(N.current||R({type:"next",toIndex:i,actionType:"click"}))}function re(i){P.current&&(I.current||R({type:"prev",toIndex:i,actionType:"click"}))}function R({type:i,shouldAnimate:f=!0,toIndex:E,actionType:S}){var Ie,ke;const A=!f;I.current=!1,N.current=!1;let v=ee.value.get(),k=0;if(i==="next"&&(h.current+=1),i==="prev"&&(h.current===0?h.current=e.length-1:h.current-=1),E!==void 0&&(h.current=E),i==="next"){const F=ne(r?_.current*(e.length*2):0);k=-(h.current*_.current),r&&h.current===e.length&&(h.current=0,v=v+_.current*e.length,k=0),!r&&(Math.abs(k)>=F||h.current===e.length-1)&&(N.current=!0,k=-F)}i==="prev"&&(k=-(h.current*_.current),h.current===e.length-1&&(v=v-e.length*_.current),!r&&k>=0&&(I.current=!0,k=0)),V.current=k,S==="resize"?(k=-(h.current*_.current),Y({eventName:"onResize",sliceActionType:S,slideDirection:i,currentItem:{index:h.current,id:((Ie=e.at(h.current))==null?void 0:Ie.id)??"",startReached:I.current,endReached:N.current}})):Y({eventName:"onSlideStartChange",sliceActionType:S,slideDirection:i,nextItem:{index:h.current,id:((ke=e.at(h.current))==null?void 0:ke.id)??"",startReached:I.current,endReached:N.current}}),console.log("12312312312312312"),W.start({immediate:A,from:{value:v},to:{value:k},onRest({finished:F}){var Ce;F&&Y({eventName:"onSlideChangeComplete",sliceActionType:S,slideDirection:i,currentItem:{index:h.current,id:((Ce=e.at(h.current))==null?void 0:Ce.id)??"",startReached:I.current,endReached:N.current}})}})}function Ct(){const i=m==="item"?$.current.children[0]:b.current;let f=0;return f=i.getBoundingClientRect()[a==="x"?"width":"height"]+It(),f}function ne(i){const f=b.current;return f[a==="x"?"scrollWidth":"scrollHeight"]-f.getBoundingClientRect()[a==="x"?"width":"height"]-i}function Se(){let i=0,f=0;if(b.current){const E=window.getComputedStyle(b.current),S=E.getPropertyValue(`--${n}-start-end-gutter`).trim();S.includes("px")&&(i=Number(S.replace("px","")));const A=E.getPropertyValue(`--${n}-gutter`).trim();A.includes("px")&&(f=Number(A.replace("px","")))}return{totalStartEndGutterCssVar:i,totalGutterCssVar:f}}g.useEffect(()=>{function i(A){const v=kt();switch(A){case"start":return 0;case"middle-start":return Math.floor((v-1)*.25);case"center":return Math.floor((v-1)*.5);case"middle-end":return Math.floor((v-1)*.75);case"end":return v-1;default:return 0}}function f(){_.current=Ct(),console.log(_.current),O.current=_.current/4;const{totalStartEndGutterCssVar:A}=Se();let v=0;r&&(v=_.current*e.length),v-=_.current*i(c),v-=A/2,b.current.style.setProperty(`--${n}-offset-modifier`,`${-v}px`)}function E(){b.current&&(f(),D(!0))}function S(){console.log("fucking resize?"),E(),R({type:"resize",toIndex:h.current,shouldAnimate:!1,actionType:"resize"})}if(t)return P.current=!0,E(),window.addEventListener("resize",S),()=>{window.removeEventListener("resize",S)}},[t]),g.useEffect(()=>{t&&y!==h.current&&(console.log("resize also ere?"),R({type:"next",toIndex:y,actionType:"resize",shouldAnimate:!1}))},[t,y]),g.useEffect(()=>{T&&u&&u()},[T,u]);const xe=l,Dt=bt(i=>{if(!P.current)return;const f=i.dragging,E=i.offset[a==="x"?0:1],S=i.movement[a==="x"?0:1],A=S>O.current,v=S<-O.current,k=i.velocity;f&&(Y({...i,eventName:"onDrag",slideActionType:"drag"}),console.log("222222"),W.start({value:E,immediate:!0,config:{velocity:k}}),d&&(A||v)&&i.cancel()),i.last&&(A?(R({actionType:"drag",type:"prev"}),i.cancel()):v?(R({actionType:"drag",type:"next"}),i.cancel()):(console.log("333333"),W.start({value:V.current,config:{velocity:k}}),i.cancel()))},{enabled:xe,axis:a,rubberband:!r,...r?{}:{bounds:()=>({right:0,left:-ne(0),top:-ne(0),bottom:0})},from:()=>[ee.value.get(),ee.value.get()]});function Pt(i){var f,E;return typeof i=="number"?h.current===i:((f=e.find(S=>S.id===i))==null?void 0:f.id)===((E=e[h.current])==null?void 0:E.id)}return{carouselFragment:M.jsxs("div",{ref:b,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,...Dt(),children:[M.jsx("style",{dangerouslySetInnerHTML:{__html:wt(`
|
|
1
|
+
(function(L,M){typeof exports=="object"&&typeof module<"u"?M(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"],M):(L=typeof globalThis<"u"?globalThis:L||self,M(L["react-spring-carousel"]={},L["react/jsx-runtime"],L["@react-spring/web"],L.React))})(this,function(L,M,H,g){"use strict";function De(t,e,r){return Math.max(e,Math.min(t,r))}const w={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 se(t,e,r){return e===0||Math.abs(e)===1/0?Math.pow(t,r*5):t*e*r/(e+r*t)}function ie(t,e,r,n=.15){return n===0?De(t,e,r):t<e?-se(e-t,r-e,n)+e:t>r?+se(t-r,r-e,n)+r:t}function Pe(t,[e,r],[n,s]){const[[o,a],[c,l]]=t;return[ie(e,o,a,n),ie(r,c,l,s)]}function $e(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 Oe(t){var e=$e(t,"string");return typeof e=="symbol"?e:String(e)}function x(t,e,r){return e=Oe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function oe(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?oe(Object(r),!0).forEach(function(n){x(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):oe(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}const ae={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 ce(t){return t?t[0].toUpperCase()+t.slice(1):""}const Ae=["enter","leave"];function Le(t=!1,e){return t&&!Ae.includes(e)}function Ne(t,e="",r=!1){const n=ae[t],s=n&&n[e]||e;return"on"+ce(t)+ce(s)+(Le(r,s)?"Capture":"")}const Me=["gotpointercapture","lostpointercapture"];function Ve(t){let e=t.substring(2).toLowerCase();const r=!!~e.indexOf("passive");r&&(e=e.replace("passive",""));const n=Me.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:r}}function je(t,e=""){const r=ae[t],n=r&&r[e]||e;return t+n}function z(t){return"touches"in t}function ue(t){return z(t)?"touch":"pointerType"in t?t.pointerType:"mouse"}function Re(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 Be(t){return t.type==="touchend"||t.type==="touchcancel"?t.changedTouches:t.targetTouches}function le(t){return z(t)?Be(t)[0]:t}function Ue(t){return Re(t).map(e=>e.identifier)}function X(t){const e=le(t);return z(t)?e.identifier:e.pointerId}function fe(t){const e=le(t);return[e.clientX,e.clientY]}function Ke(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 ze(){}function Ge(...t){return t.length===0?ze:t.length===1?t[0]:function(){let e;for(const r of t)e=r.apply(this,arguments)||e;return e}}function de(t,e){return Object.assign({},e,t||{})}const We=32;class Ye{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,Ke(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 O=r._delta.map(Math.abs);w.addTo(r._distance,O)}this.axisIntent&&this.axisIntent(e);const[a,c]=r._movement,[l,d]=n.threshold,{_step:u,values:y}=r;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(a)>=l&&y[0]),u[1]===!1&&(u[1]=Math.abs(c)>=d&&y[1])):(u[0]===!1&&(u[0]=Math.abs(a)>=l&&Math.sign(a)*l),u[1]===!1&&(u[1]=Math.abs(c)>=d&&Math.sign(c)*d)),r.intentional=u[0]!==!1||u[1]!==!1,!r.intentional)return;const m=[0,0];if(n.hasCustomTransform){const[O,h]=y;m[0]=u[0]!==!1?O-u[0]:0,m[1]=u[1]!==!1?h-u[1]:0}else m[0]=u[0]!==!1?a-u[0]:0,m[1]=u[1]!==!1?c-u[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(m);const T=r.offset,D=r._active&&!r._blocked||r.active;D&&(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=m,this.computeOffset()));const[$,b]=r.offset,[[P,V],[_,I]]=r._bounds;r.overflow=[$<P?-1:$>V?1:0,b<_?-1:b>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;const N=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=Pe(r._bounds,r.offset,N),r.delta=w.sub(r.offset,T),this.computeMovement(),D&&(!r.last||o>We)){r.delta=w.sub(r.offset,T);const O=r.delta.map(Math.abs);w.addTo(r.distance,O),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&o>0&&(r.velocity=[O[0]/o,O[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 Fe([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 He extends Ye{constructor(...e){super(...e),x(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=w.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=w.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[ue(e)]:n.axisThreshold;r.axis=Fe(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 he=t=>t,pe=.15,q={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[pe,pe];case!1:return[0,0];default:return w.toVector(t)}},from(t){if(typeof t=="function")return t;if(t!=null)return w.toVector(t)},transform(t,e,r){const n=t||r.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||he;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||he},threshold(t){return w.toVector(t,0)}};process.env.NODE_ENV==="development"&&Object.assign(q,{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 Xe=0,U=p(p({},q),{},{axis(t,e,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(t=Xe){return t},bounds(t={}){if(typeof t=="function")return o=>U.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]]}}),ge={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 qe extends He{constructor(...e){super(...e),x(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=U.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=X(e),n._pointerActive=!0,this.computeValues(fe(e)),this.computeInitial(),r.preventScrollAxis&&ue(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=X(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;const o=fe(e);if(document.pointerLockElement===e.target?r._delta=[e.movementX,e.movementY]:(r._delta=w.sub(o,r._values),this.computeValues(o)),w.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=X(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,[d,u]=r._movement,[y,m]=n.swipe.velocity,[T,D]=n.swipe.distance,$=n.swipe.duration;if(r.elapsedTime<$){const b=Math.abs(c/r.timeDelta),P=Math.abs(l/r.timeDelta);b>y&&Math.abs(d)>T&&(r.swipe[0]=Math.sign(c)),P>m&&Math.abs(u)>D&&(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,Je(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=ge[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,w.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in ge&&(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 Je(t){"persist"in t&&typeof t.persist=="function"&&t.persist()}const K=typeof window<"u"&&window.document&&window.document.createElement;function me(){return K&&"ontouchstart"in window}function Qe(){return me()||K&&window.navigator.maxTouchPoints>1}function Ze(){return K&&"onpointerdown"in window}function et(){return K&&"exitPointerLock"in window.document}function tt(){try{return"constructor"in GestureEvent}catch{return!1}}const C={isBrowser:K,gesture:tt(),touch:me(),touchscreen:Qe(),pointer:Ze(),pointerLock:et()},rt=250,nt=180,st=.5,it=50,ot=250,at=10,ve={mouse:0,touch:0,pen:8},ye=p(p({},U),{},{device(t,e,{pointer:{touch:r=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&C.pointerLock,C.touch&&r?"touch":this.pointerLock?"mouse":C.pointer&&!s?"pointer":C.touch?"touch":"mouse"},preventScrollAxis(t,e,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&t?rt:void 0,!(!C.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=w.toVector(t,r?n:s?1:0);return this.filterTaps=r,this.tapsThreshold=n,o},swipe({velocity:t=st,distance:e=it,duration:r=ot}={}){return{velocity:this.transform(w.toVector(t)),distance:this.transform(w.toVector(e)),duration:r}},delay(t=0){switch(t){case!0:return nt;case!1:return 0;default:return t}},axisThreshold(t){return t?p(p({},ve),t):ve},keyboardDisplacement(t=at){return t}});process.env.NODE_ENV==="development"&&Object.assign(ye,{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({},q),{},{device(t,e,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!C.touch&&C.gesture)return"gesture";if(C.touch&&n)return"touch";if(C.touchscreen){if(C.pointer)return"pointer";if(C.touch)return"touch"}},bounds(t,e,{scaleBounds:r={},angleBounds:n={}}){const s=a=>{const c=de(G(r,a),{min:-1/0,max:1/0});return[c.min,c.max]},o=a=>{const c=de(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",w.toVector(t,this.lockDirection?[.1,3]:0)},modifierKey(t){return t===void 0?"ctrlKey":t},pinchOnWheel(t=!0){return t}}),p(p({},U),{},{mouseOnly:(t=!0)=>t}),p(p({},U),{},{mouseOnly:(t=!0)=>t});const be=new Map,J=new Map;function ct(t){be.set(t.key,t.engine),J.set(t.key,t.resolver)}const ut={key:"drag",engine:qe,resolver:ye};function lt(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 ft(t,e){if(t==null)return{};var r=lt(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 dt={target(t){if(t)return()=>"current"in t?t.current:t},enabled(t=!0){return t},window(t=C.isBrowser?window:void 0){return t},eventOptions({passive:t=!0,capture:e=!1}={}){return{passive:t,capture:e}},transform(t){return t}},ht=["target","eventOptions","window","enabled","transform"];function W(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]=W(t[n],s);break;case"boolean":s&&(r[n]=t[n]);break}return r}function pt(t,e,r={}){const n=t,{target:s,eventOptions:o,window:a,enabled:c,transform:l}=n,d=ft(n,ht);if(r.shared=W({target:s,eventOptions:o,window:a,enabled:c,transform:l},dt),e){const u=J.get(e);r[e]=W(p({shared:r.shared},d),u)}else for(const u in d){const y=J.get(u);if(y)r[u]=W(p({shared:r.shared},d[u]),y);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 _e{constructor(e,r){x(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=r}add(e,r,n,s,o){const a=this._listeners,c=je(r,n),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},d=p(p({},l),o);e.addEventListener(c,s,d);const u=()=>{e.removeEventListener(c,s,d),a.delete(u)};return a.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class gt{constructor(){x(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){x(this,"gestures",new Set),x(this,"_targetEventStore",new _e(this)),x(this,"gestureEventStores",{}),x(this,"gestureTimeoutStores",{}),x(this,"handlers",{}),x(this,"config",{}),x(this,"pointerIds",new Set),x(this,"touchIds",new Set),x(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),vt(this,e)}setEventIds(e){if(z(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=pt(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=we(n,c.eventOptions,!!s);if(c.enabled){const d=be.get(a);new d(this,e,a).bind(l)}}const o=we(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}=Ve(o);this._targetEventStore.add(s,a,"",n[o],{capture:c,passive:l})}}}}function j(t,e){t.gestures.add(e),t.gestureEventStores[e]=new _e(t,e),t.gestureTimeoutStores[e]=new gt}function vt(t,e){e.drag&&j(t,"drag"),e.wheel&&j(t,"wheel"),e.scroll&&j(t,"scroll"),e.move&&j(t,"move"),e.pinch&&j(t,"pinch"),e.hover&&j(t,"hover")}const we=(t,e,r)=>(n,s,o,a={},c=!1)=>{var l,d;const u=(l=a.capture)!==null&&l!==void 0?l:e.capture,y=(d=a.passive)!==null&&d!==void 0?d:e.passive;let m=c?n:Ne(n,s,u);r&&y&&(m+="Passive"),t[m]=t[m]||[],t[m].push(o)};function yt(t,e={},r,n){const s=g.useMemo(()=>new mt(t),[]);if(s.applyHandlers(t,n),s.applyConfig(e,r),g.useEffect(s.effect.bind(s)),g.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function bt(t,e){return ct(ut),yt({drag:t},e||{},"drag")}const Q="RSC::Event";function _t(){const t=g.useRef(null);function e(n){g.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 wt(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 Et({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:d=!0,onInit:u,initialActiveItem:y=0,slideType:m="item"}){const[T,D]=g.useState(!1),$=g.useRef(t),b=g.useRef(null),P=g.useRef(null),V=g.useRef(0),_=g.useRef(0),I=g.useRef(!r),N=g.useRef(!1),O=g.useRef(0),h=g.useRef(0),Y=H.useSpringRef(),ee=H.useSpring({value:0,ref:Y,onChange({value:i}){P.current.style.transform=`translate3d(calc(${i.value}px + var(--${n}-offset-modifier)), 0px, 0px)`}}),xt=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:Te,emitEvent:F}=_t();function It(){const{totalGutterCssVar:i}=Se();return i}function kt(){if(b.current){const f=window.getComputedStyle(b.current).getPropertyValue(`--${n}-items-per-slide`).trim();return Number(f)||1}return 1}function te(i){$.current&&(N.current||R({type:"next",toIndex:i,actionType:"click"}))}function re(i){$.current&&(I.current||R({type:"prev",toIndex:i,actionType:"click"}))}function R({type:i,shouldAnimate:f=!0,toIndex:E,actionType:S}){var Ie,ke;const A=!f;I.current=!1,N.current=!1;let v=ee.value.get(),k=0;if(i==="next"&&(h.current+=1),i==="prev"&&(h.current===0?h.current=e.length-1:h.current-=1),E!==void 0&&(h.current=E),i==="next"){const B=ne(r?_.current*(e.length*2):0);k=-(h.current*_.current),r&&h.current===e.length&&(h.current=0,v=v+_.current*e.length,k=0),!r&&(Math.abs(k)>=B||h.current===e.length-1)&&(N.current=!0,k=-B)}i==="prev"&&(k=-(h.current*_.current),h.current===e.length-1&&(v=v-e.length*_.current),!r&&k>=0&&(I.current=!0,k=0)),V.current=k,S==="resize"?(k=-(h.current*_.current),F({eventName:"onResize",sliceActionType:S,slideDirection:i,currentItem:{index:h.current,id:((Ie=e.at(h.current))==null?void 0:Ie.id)??"",startReached:I.current,endReached:N.current}})):F({eventName:"onSlideStartChange",sliceActionType:S,slideDirection:i,nextItem:{index:h.current,id:((ke=e.at(h.current))==null?void 0:ke.id)??"",startReached:I.current,endReached:N.current}}),console.log("12312312312312312"),Y.start({immediate:A,from:{value:v},to:{value:k},onRest({finished:B}){var Ce;B&&F({eventName:"onSlideChangeComplete",sliceActionType:S,slideDirection:i,currentItem:{index:h.current,id:((Ce=e.at(h.current))==null?void 0:Ce.id)??"",startReached:I.current,endReached:N.current}})},onChange({value:B}){P.current.style.transform=`translate3d(calc(${B.value}px + var(--${n}-offset-modifier)), 0px, 0px)`}})}function Ct(){const i=m==="item"?P.current.children[0]:b.current;let f=0;return f=i.getBoundingClientRect()[a==="x"?"width":"height"]+It(),f}function ne(i){const f=b.current;return f[a==="x"?"scrollWidth":"scrollHeight"]-f.getBoundingClientRect()[a==="x"?"width":"height"]-i}function Se(){let i=0,f=0;if(b.current){const E=window.getComputedStyle(b.current),S=E.getPropertyValue(`--${n}-start-end-gutter`).trim();S.includes("px")&&(i=Number(S.replace("px","")));const A=E.getPropertyValue(`--${n}-gutter`).trim();A.includes("px")&&(f=Number(A.replace("px","")))}return{totalStartEndGutterCssVar:i,totalGutterCssVar:f}}g.useEffect(()=>{function i(A){const v=kt();switch(A){case"start":return 0;case"middle-start":return Math.floor((v-1)*.25);case"center":return Math.floor((v-1)*.5);case"middle-end":return Math.floor((v-1)*.75);case"end":return v-1;default:return 0}}function f(){_.current=Ct(),console.log(_.current),O.current=_.current/4;const{totalStartEndGutterCssVar:A}=Se();let v=0;r&&(v=_.current*e.length),v-=_.current*i(c),v-=A/2,b.current.style.setProperty(`--${n}-offset-modifier`,`${-v}px`)}function E(){b.current&&(f(),D(!0))}function S(){console.log("fucking resize?"),E(),R({type:"resize",toIndex:h.current,shouldAnimate:!1,actionType:"resize"})}if(t)return $.current=!0,E(),window.addEventListener("resize",S),()=>{window.removeEventListener("resize",S)}},[t]),g.useEffect(()=>{t&&y!==h.current&&(console.log("resize also ere?"),R({type:"next",toIndex:y,actionType:"resize",shouldAnimate:!1}))},[t,y]),g.useEffect(()=>{T&&u&&u()},[T,u]);const xe=l,Dt=bt(i=>{if(!$.current)return;const f=i.dragging,E=i.offset[a==="x"?0:1],S=i.movement[a==="x"?0:1],A=S>O.current,v=S<-O.current,k=i.velocity;f&&(F({...i,eventName:"onDrag",slideActionType:"drag"}),console.log("222222"),Y.start({value:E,immediate:!0,config:{velocity:k}}),d&&(A||v)&&i.cancel()),i.last&&(A?(R({actionType:"drag",type:"prev"}),i.cancel()):v?(R({actionType:"drag",type:"next"}),i.cancel()):(console.log("333333"),Y.start({value:V.current,config:{velocity:k}}),i.cancel()))},{enabled:xe,axis:a,rubberband:!r,...r?{}:{bounds:()=>({right:0,left:-ne(0),top:-ne(0),bottom:0})},from:()=>[ee.value.get(),ee.value.get()]});function Pt(i){var f,E;return typeof i=="number"?h.current===i:((f=e.find(S=>S.id===i))==null?void 0:f.id)===((E=e[h.current])==null?void 0:E.id)}return{carouselFragment:M.jsxs("div",{ref:b,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,...Dt(),children:[M.jsx("style",{dangerouslySetInnerHTML:{__html:wt(`
|
|
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
|
-
`)}}),M.jsx("div",{ref
|
|
47
|
+
`)}}),M.jsx("div",{ref:P,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track`,onScroll:()=>{I.current=!1,N.current=!1},children:xt.map((i,f)=>M.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,"data-id":i.id,children:typeof i.renderItem=="function"?i.renderItem({useListenToCustomEvent:Te,index:f,isClonedItem:!!i.isClonedItem,isActiveItem:Pt}):i.renderItem},`${i.id}-${f}`))})]}),useListenToCustomEvent:Te,slideToNextItem:()=>te(),slideToPrevItem:()=>re(),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>h.current?te(i):re(i)}if(typeof i=="string"){const f=e.findIndex(E=>E.id===i);if(f<0){console.warn(`The item you're trying to slide doesn't exist. id: ${i}`);return}f>h.current?te(f):re(f)}}}}function Tt(t){let e=0;const r=getComputedStyle(t).getPropertyValue("gap");return r.includes("px")&&(e=Number(r.replace("px",""))),e}function Ee(t){return t.scrollWidth-t.clientWidth}function Z(t){const e=t.children[0],r=Tt(t);return e.getBoundingClientRect().width+r}function St({container:t,onReach:e}){const r=g.useRef("start"),n=g.useRef(0),[,s]=H.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*Z(t.current),c==="next"){const d=Ee(t.current);l>d&&(r.current="end",l=d,e&&e("end"))}c==="prev"&&l<=0&&(r.current="start",n.current=0,l=0,e&&e("start")),o(l)}return g.useEffect(()=>{function c(){var V;const T=Z(t.current),D=((V=[...t.current.children].at(0))==null?void 0:V.getBoundingClientRect().width)||0,$=Array(t.current.childElementCount).fill(0).map((_,I)=>({index:I,start:T*I,end:T*(I+1)})),b=t.current.scrollLeft+D,P=$.find(_=>b>=_.start&&b<_.end);n.current=(P==null?void 0:P.index)||0}function l(){s.stop()}function d(T){const D=T.target;D.scrollLeft===0?(n.current=0,r.current="start",e&&e("start")):D.scrollLeft>=Ee(D)?(r.current="end",e&&e("end")):r.current!=="idle"&&(r.current="idle",e&&e("idle"))}let u,y=0;function m(){y=t.current.scrollLeft,clearTimeout(u),u=setTimeout(function(){t.current.scrollLeft===y&&c()},200)}if(t.current)return t.current.addEventListener("wheel",l,{passive:!0}),t.current.addEventListener("scroll",d),t.current.addEventListener("scroll",m),()=>{t.current&&(t.current.removeEventListener("scroll",m),t.current.removeEventListener("scroll",d),t.current.removeEventListener("wheel",l))}},[t,e]),g.useEffect(()=>{if(t.current){const c=new ResizeObserver(()=>{o(n.current*Z(t.current))});return c.observe(t.current),()=>{c.disconnect()}}},[]),{scrollToNext(){a("next")},scrollToPrev(){a("prev")}}}L.useSpringCarousel=Et,L.useSpringScroll=St,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})});
|