react-spring-carousel 3.0.0-beta-1.0.422 → 3.0.0-beta-2.0.0

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