@aiquants/virtualscroll 1.0.0 → 1.2.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.js CHANGED
@@ -1,16 +1,16 @@
1
- import { jsx as $, jsxs as Se, Fragment as Je } from "react/jsx-runtime";
2
- import { forwardRef as ke, useState as de, useRef as k, useCallback as A, useImperativeHandle as Oe, useMemo as xe, useEffect as se, useReducer as st, useLayoutEffect as Ee, useId as ot } from "react";
3
- import { twMerge as we } from "tailwind-merge";
4
- const Ke = {
1
+ import { jsx as H, jsxs as Se, Fragment as rt } from "react/jsx-runtime";
2
+ import { forwardRef as ke, useState as pe, useRef as F, useCallback as y, useImperativeHandle as Ye, useMemo as Te, useEffect as se, useReducer as bt, useLayoutEffect as Ae, useId as Tt } from "react";
3
+ import { twMerge as Ie } from "tailwind-merge";
4
+ const Ze = {
5
5
  active: !1,
6
6
  offsetX: 0,
7
7
  offsetY: 0,
8
8
  distance: 0,
9
9
  direction: 0
10
- }, qe = 6, it = ({ dragState: o, normalizedDistance: e }) => {
11
- const t = 1 + e * 0.18, n = 0.16 + e * 0.24, r = 0.38 + e * 0.28, i = o.active ? "80ms ease-out" : "220ms ease";
12
- return /* @__PURE__ */ Se(Je, { children: [
13
- /* @__PURE__ */ $(
10
+ }, Je = 6, yt = ({ dragState: s, normalizedDistance: e }) => {
11
+ const t = 1 + e * 0.18, n = 0.16 + e * 0.24, r = 0.38 + e * 0.28, o = s.active ? "80ms ease-out" : "220ms ease";
12
+ return /* @__PURE__ */ Se(rt, { children: [
13
+ /* @__PURE__ */ H(
14
14
  "div",
15
15
  {
16
16
  className: "absolute inset-0 rounded-full",
@@ -18,11 +18,11 @@ const Ke = {
18
18
  background: "linear-gradient(140deg, rgba(255,255,255,0.62), rgba(72,72,72,0.48))",
19
19
  boxShadow: `0 0 0 1px rgba(255,255,255,0.28), 0 10px 22px rgba(0,0,0,${n})`,
20
20
  transform: `scale(${t})`,
21
- transition: `${i}, ${o.active ? "80ms" : "260ms"} box-shadow ease`
21
+ transition: `${o}, ${s.active ? "80ms" : "260ms"} box-shadow ease`
22
22
  }
23
23
  }
24
24
  ),
25
- /* @__PURE__ */ $(
25
+ /* @__PURE__ */ H(
26
26
  "div",
27
27
  {
28
28
  className: "absolute inset-[18%] rounded-full",
@@ -30,693 +30,767 @@ const Ke = {
30
30
  background: "linear-gradient(140deg, rgba(255,255,255,0.72), rgba(28,28,28,0.58))",
31
31
  boxShadow: "inset 0 4px 10px rgba(0,0,0,0.24), inset 0 0 2px rgba(255,255,255,0.55)",
32
32
  opacity: r,
33
- transition: o.active ? "120ms opacity ease-out" : "220ms opacity ease"
33
+ transition: s.active ? "120ms opacity ease-out" : "220ms opacity ease"
34
34
  }
35
35
  }
36
36
  )
37
37
  ] });
38
- }, Qe = ke(({ onDragChange: o, className: e, maxVisualDistance: t = 160, size: n = 40, style: r, opacity: i = 1, renderVisual: l }, a) => {
39
- const [h, u] = de(Ke), d = k(null), p = k({ x: 0, y: 0 }), R = k(null), V = A((m) => {
40
- u(m), o(m);
41
- }, [o]), X = A(
42
- (m, D, f = !1) => {
43
- const { x: F, y: g } = p.current, N = m - F, L = D - g, C = Math.abs(L), M = C < qe ? 0 : L < 0 ? -1 : 1;
44
- V({
45
- active: f || C >= qe,
46
- offsetX: N,
47
- offsetY: L,
48
- distance: C,
49
- direction: M
38
+ }, st = ke(({ onDragChange: s, className: e, maxVisualDistance: t = 160, size: n = 40, style: r, opacity: o = 1, renderVisual: i }, a) => {
39
+ const [f, c] = pe(Ze), u = F(null), p = F({ x: 0, y: 0 }), E = F(null), A = y((d) => {
40
+ c(d), s(d);
41
+ }, [s]), O = y(
42
+ (d, M, z = !1) => {
43
+ const { x: Z, y: h } = p.current, _ = d - Z, g = M - h, P = Math.abs(g), R = P < Je ? 0 : g < 0 ? -1 : 1;
44
+ A({
45
+ active: z || P >= Je,
46
+ offsetX: _,
47
+ offsetY: g,
48
+ distance: P,
49
+ direction: R
50
50
  });
51
51
  },
52
- [V]
53
- ), ee = A((m) => {
54
- if (m === null)
52
+ [A]
53
+ ), te = y((d) => {
54
+ if (d === null)
55
55
  return;
56
- const D = R.current;
57
- D?.hasPointerCapture(m) && D.releasePointerCapture(m);
58
- }, []), b = A(
59
- (m = !1) => {
60
- m && ee(d.current), d.current = null, V(Ke);
56
+ const M = E.current;
57
+ M?.hasPointerCapture(d) && M.releasePointerCapture(d);
58
+ }, []), X = y(
59
+ (d = !1) => {
60
+ d && te(u.current), u.current = null, A(Ze);
61
61
  },
62
- [V, ee]
63
- ), ae = A(
64
- (m) => {
65
- m.preventDefault(), m.stopPropagation();
66
- const D = R.current ?? m.currentTarget, { left: f, top: F, width: g, height: N } = D.getBoundingClientRect();
67
- p.current = { x: f + g / 2, y: F + N / 2 }, d.current = m.pointerId, D.setPointerCapture(m.pointerId), X(m.clientX, m.clientY, !0);
62
+ [A, te]
63
+ ), ne = y(
64
+ (d) => {
65
+ d.preventDefault(), d.stopPropagation();
66
+ const M = E.current ?? d.currentTarget, { left: z, top: Z, width: h, height: _ } = M.getBoundingClientRect();
67
+ p.current = { x: z + h / 2, y: Z + _ / 2 }, u.current = d.pointerId, M.setPointerCapture(d.pointerId), O(d.clientX, d.clientY, !0);
68
68
  },
69
- [X]
70
- ), le = A(
71
- (m) => {
72
- d.current === m.pointerId && (m.preventDefault(), X(m.clientX, m.clientY));
69
+ [O]
70
+ ), S = y(
71
+ (d) => {
72
+ u.current === d.pointerId && (d.preventDefault(), O(d.clientX, d.clientY));
73
73
  },
74
- [X]
75
- ), Z = A(
76
- (m) => {
77
- d.current === m.pointerId && (m.preventDefault(), m.stopPropagation(), b(!0));
74
+ [O]
75
+ ), ce = y(
76
+ (d) => {
77
+ u.current === d.pointerId && (d.preventDefault(), d.stopPropagation(), X(!0));
78
78
  },
79
- [b]
79
+ [X]
80
80
  );
81
- Oe(
81
+ Ye(
82
82
  a,
83
83
  () => ({
84
84
  reset: () => {
85
- b(!0);
85
+ X(!0);
86
86
  },
87
- getElement: () => R.current
87
+ getElement: () => E.current
88
88
  }),
89
- [b]
89
+ [X]
90
90
  );
91
- const _ = Math.min(Math.max(i, 0), 1), U = n / 64, O = Math.min(h.distance, t) / t, x = h.direction * O * 10 * U, P = l ?? it, w = {
92
- dragState: h,
93
- normalizedDistance: O,
94
- sizeScale: U,
91
+ const le = Math.min(Math.max(o, 0), 1), G = n / 64, C = Math.min(f.distance, t) / t, K = f.direction * C * 10 * G, I = i ?? yt, x = {
92
+ dragState: f,
93
+ normalizedDistance: C,
94
+ sizeScale: G,
95
95
  size: n,
96
- opacity: _
97
- }, H = {
96
+ opacity: le
97
+ }, $ = {
98
98
  ...r,
99
99
  width: n,
100
100
  height: n,
101
- transform: `translateY(${x}px)`
101
+ transform: `translateY(${K}px)`
102
102
  };
103
- return H.opacity = _, /* @__PURE__ */ $(
103
+ return $.opacity = le, /* @__PURE__ */ H(
104
104
  "div",
105
105
  {
106
- ref: R,
107
- className: we(
106
+ ref: E,
107
+ className: Ie(
108
108
  "relative flex touch-none select-none items-center justify-center",
109
109
  "transition-transform duration-100 ease-out",
110
110
  e
111
111
  ),
112
- style: H,
113
- onPointerDown: ae,
114
- onPointerMove: le,
115
- onPointerUp: Z,
116
- onPointerCancel: Z,
112
+ style: $,
113
+ onPointerDown: ne,
114
+ onPointerMove: S,
115
+ onPointerUp: ce,
116
+ onPointerCancel: ce,
117
117
  role: "presentation",
118
- children: P(w)
118
+ children: I(x)
119
119
  }
120
120
  );
121
121
  });
122
- Qe.displayName = "TapScrollCircle";
123
- const G = (o, e, t) => Math.min(t, Math.max(e, o)), je = (o, e, t) => {
124
- const n = "touches" in o.nativeEvent, r = n ? o.nativeEvent.touches[0] : o.nativeEvent, i = (a) => {
122
+ st.displayName = "TapScrollCircle";
123
+ const W = (s, e, t) => Math.min(t, Math.max(e, s)), Qe = (s, e, t) => {
124
+ const n = "touches" in s.nativeEvent, r = n ? s.nativeEvent.touches[0] : s.nativeEvent, o = (a) => {
125
125
  n && a.cancelable && a.preventDefault();
126
- const h = "touches" in a ? a.touches[0] : a;
126
+ const f = "touches" in a ? a.touches[0] : a;
127
127
  e({
128
- deltaX: h.clientX - r.clientX,
129
- deltaY: h.clientY - r.clientY
128
+ deltaX: f.clientX - r.clientX,
129
+ deltaY: f.clientY - r.clientY
130
130
  });
131
- }, l = () => {
132
- n ? (document.removeEventListener("touchmove", i), document.removeEventListener("touchend", l)) : (document.removeEventListener("mousemove", i), document.removeEventListener("mouseup", l)), t?.();
131
+ }, i = () => {
132
+ n ? (document.removeEventListener("touchmove", o), document.removeEventListener("touchend", i)) : (document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", i)), t?.();
133
133
  };
134
- n ? (document.addEventListener("touchmove", i, { passive: !1 }), document.addEventListener("touchend", l)) : (document.addEventListener("mousemove", i), document.addEventListener("mouseup", l));
135
- }, Ne = "virtualscroll:tap-scroll-cancel", We = 20, at = 250, lt = 60, ct = 20, ut = 20, dt = 220, Be = { active: !1, offsetX: 0, offsetY: 0, distance: 0, direction: 0 }, De = 2.2, ft = 8, ht = 120, pe = {
134
+ n ? (document.addEventListener("touchmove", o, { passive: !1 }), document.addEventListener("touchend", i)) : (document.addEventListener("mousemove", o), document.addEventListener("mouseup", i));
135
+ }, ze = "virtualscroll:tap-scroll-cancel", Be = 20, St = 250, wt = 60, It = 20, Mt = 20, Pt = 220, et = { active: !1, offsetX: 0, offsetY: 0, distance: 0, direction: 0 }, Oe = 2.2, Vt = 8, Et = 120, me = {
136
136
  enabled: !0,
137
137
  size: 40,
138
138
  offsetX: -80,
139
139
  offsetY: 0,
140
140
  className: void 0,
141
- maxVisualDistance: dt,
141
+ maxVisualDistance: Pt,
142
+ minSpeedMultiplier: 0.2,
142
143
  opacity: 1,
143
- renderVisual: void 0
144
- }, mt = (o) => {
145
- if (!o || o <= 0)
146
- return De;
147
- const e = Math.max(1, o), t = Math.log10(e), n = De + t * ft;
148
- return G(n, De, ht);
149
- }, pt = ({ contentSize: o, viewportSize: e, scrollPosition: t, onScroll: n, enableThumbDrag: r = !0, enableTrackClick: i = !0, enableArrowButtons: l = !0, horizontal: a = !1, scrollBarWidth: h = 12, className: u, ariaControls: d, tapScrollCircleOptions: p, itemCount: R }) => {
150
- const [V, X] = de(!1), [ee, b] = de(!1), [ae, le] = de(!1), Z = k(null), _ = k(t), U = k(null), O = k(null), x = k(Be), P = k(null), w = k(null), H = k(null), m = xe(() => {
151
- const s = p?.maxSpeedMultiplier, v = typeof s == "number" ? s : mt(R);
152
- return {
153
- enabled: p?.enabled ?? pe.enabled,
154
- size: p?.size ?? pe.size,
155
- offsetX: p?.offsetX ?? pe.offsetX,
156
- offsetY: p?.offsetY ?? pe.offsetY,
157
- className: p?.className ?? pe.className,
158
- maxVisualDistance: p?.maxVisualDistance ?? pe.maxVisualDistance,
159
- maxSpeedMultiplier: v,
160
- opacity: G(p?.opacity ?? pe.opacity, 0, 1),
161
- renderVisual: p?.renderVisual ?? pe.renderVisual
162
- };
163
- }, [R, p]), {
164
- enabled: D,
165
- size: f,
166
- offsetX: F,
167
- offsetY: g,
168
- className: N,
169
- maxVisualDistance: L,
170
- maxSpeedMultiplier: C,
171
- opacity: M,
172
- renderVisual: y
173
- } = m, I = a ? "width" : "height", T = a ? "height" : "width", S = a ? "left" : "top", E = a ? "clientX" : "clientY", q = (s, v) => a ? s : v, oe = (s) => s[E], j = a ? ["Scroll left", "Scroll right"] : ["Scroll up", "Scroll down"], W = a ? ["◀", "▶"] : ["▲", "▼"], ne = a ? "flex flex-row items-stretch" : "flex flex-col items-stretch", B = Math.max(L, 1), fe = e / o, Y = h, c = Math.max(e - Y * 2, 0), J = fe * c, Q = Math.min(Math.max(We, J || 0), c || We), z = o - e, ie = Math.max(c - Q, 0), ge = z <= 0 || ie <= 0 ? 0 : t / z * ie, he = o > e, Ye = he && l;
144
+ renderVisual: void 0,
145
+ maxSpeedCurve: void 0
146
+ }, Ct = (s) => s ? {
147
+ mainSizeKey: "width",
148
+ crossSizeKey: "height",
149
+ positionKey: "left",
150
+ selectDelta: (e, t) => e,
151
+ getPointerCoordinate: ({ clientX: e }) => e,
152
+ arrowLabels: ["Scroll left", "Scroll right"],
153
+ arrowIcons: ["◀", "▶"],
154
+ directionClass: "flex flex-row items-stretch",
155
+ orientation: "horizontal"
156
+ } : {
157
+ mainSizeKey: "height",
158
+ crossSizeKey: "width",
159
+ positionKey: "top",
160
+ selectDelta: (e, t) => t,
161
+ getPointerCoordinate: ({ clientY: e }) => e,
162
+ arrowLabels: ["Scroll up", "Scroll down"],
163
+ arrowIcons: ["▲", "▼"],
164
+ directionClass: "flex flex-col items-stretch",
165
+ orientation: "vertical"
166
+ }, At = (s, e) => {
167
+ const t = s?.maxSpeedMultiplier, n = typeof t == "number" ? t : Ft(e);
168
+ return {
169
+ enabled: s?.enabled ?? me.enabled,
170
+ size: s?.size ?? me.size,
171
+ offsetX: s?.offsetX ?? me.offsetX,
172
+ offsetY: s?.offsetY ?? me.offsetY,
173
+ className: s?.className ?? me.className,
174
+ maxVisualDistance: s?.maxVisualDistance ?? me.maxVisualDistance,
175
+ maxSpeedMultiplier: n,
176
+ minSpeedMultiplier: Math.max(s?.minSpeedMultiplier ?? me.minSpeedMultiplier, 0),
177
+ opacity: W(s?.opacity ?? me.opacity, 0, 1),
178
+ renderVisual: s?.renderVisual ?? me.renderVisual,
179
+ maxSpeedCurve: s?.maxSpeedCurve ?? me.maxSpeedCurve
180
+ };
181
+ }, _t = ({ thumbRef: s, isDragging: e, isThumbHovered: t, enableThumbDrag: n, horizontal: r }) => {
174
182
  se(() => {
175
- _.current = t;
176
- }, [t]), se(() => {
177
- r || b(!1);
178
- }, [r]), se(() => {
179
- const s = Z.current;
180
- if (!s)
183
+ const o = s.current;
184
+ if (!o)
181
185
  return;
182
- const v = a ? "scaleY(1.06)" : "scaleX(1.06)", K = a ? "scaleY(1.12)" : "scaleX(1.12)";
183
- if (!r) {
184
- s.style.removeProperty("transform"), s.style.backgroundColor = "#7F7F7F", s.style.removeProperty("transition");
186
+ const i = r ? "scaleY(1.06)" : "scaleX(1.06)", a = r ? "scaleY(1.12)" : "scaleX(1.12)";
187
+ if (!n) {
188
+ o.style.removeProperty("transform"), o.style.backgroundColor = "#7F7F7F", o.style.removeProperty("transition");
185
189
  return;
186
190
  }
187
- if (V) {
188
- s.style.transform = K, s.style.backgroundColor = "#4F4F4F", s.style.transition = "transform 60ms ease-out";
191
+ if (e) {
192
+ o.style.transform = a, o.style.backgroundColor = "#4F4F4F", o.style.transition = "transform 60ms ease-out";
189
193
  return;
190
194
  }
191
- s.style.transition = "transform 80ms ease-out", ee ? (s.style.transform = v, s.style.backgroundColor = "#5F5F5F") : (s.style.removeProperty("transform"), s.style.backgroundColor = "#7F7F7F");
192
- }, [r, a, V, ee]);
193
- const Ie = A(() => {
194
- U.current !== null && (window.clearInterval(U.current), U.current = null), O.current !== null && (window.clearTimeout(O.current), O.current = null);
195
- }, []), ce = A(() => {
196
- w.current !== null && (window.cancelAnimationFrame(w.current), w.current = null), H.current = null;
197
- }, []), ue = A(() => {
198
- x.current = { ...Be }, le(!1), P.current?.reset(), ce();
199
- }, [ce]), Ve = A(
200
- (s) => {
201
- const v = x.current;
202
- if (!v.active || v.direction === 0) {
203
- ce();
195
+ o.style.transition = "transform 80ms ease-out", t ? (o.style.transform = i, o.style.backgroundColor = "#5F5F5F") : (o.style.removeProperty("transform"), o.style.backgroundColor = "#7F7F7F");
196
+ }, [n, r, e, t, s]);
197
+ }, Rt = ({ canUseArrowButtons: s, enableArrowButtons: e, resetTapScroll: t, scrollByStep: n }) => {
198
+ const r = F(null), o = F(null), i = y(() => {
199
+ r.current !== null && (window.clearInterval(r.current), r.current = null), o.current !== null && (window.clearTimeout(o.current), o.current = null);
200
+ }, []), a = y(() => {
201
+ i();
202
+ }, [i]), f = y(
203
+ (u) => (p) => {
204
+ s && (p.preventDefault(), p.stopPropagation(), t(), i(), n(u), o.current = window.setTimeout(() => {
205
+ r.current = window.setInterval(() => {
206
+ n(u);
207
+ }, wt);
208
+ }, St));
209
+ },
210
+ [s, i, t, n]
211
+ ), c = y(
212
+ (u) => (p) => {
213
+ e && (p.key === "Enter" || p.key === " " || p.key === "Spacebar") && (p.preventDefault(), n(u));
214
+ },
215
+ [e, n]
216
+ );
217
+ return se(() => () => {
218
+ i();
219
+ }, [i]), { handleArrowPointerDown: f, handleArrowPointerUp: a, handleArrowKeyDown: c };
220
+ }, Ft = (s) => {
221
+ if (!s || s <= 0)
222
+ return Oe;
223
+ const e = Math.max(1, s), t = Math.log10(e), n = Oe + t * Vt;
224
+ return W(n, Oe, Et);
225
+ }, Lt = ({
226
+ contentSize: s,
227
+ viewportSize: e,
228
+ scrollPosition: t,
229
+ onScroll: n,
230
+ enableThumbDrag: r = !0,
231
+ enableTrackClick: o = !0,
232
+ enableArrowButtons: i = !0,
233
+ horizontal: a = !1,
234
+ scrollBarWidth: f = 12,
235
+ className: c,
236
+ ariaControls: u,
237
+ tapScrollCircleOptions: p,
238
+ itemCount: E,
239
+ renderThumbOverlay: A
240
+ }) => {
241
+ const [O, te] = pe(!1), [X, ne] = pe(!1), [S, ce] = pe(!1), le = F(null), G = F(t), C = F(et), K = F(null), I = F(null), x = F(null), $ = Te(() => At(p, E), [E, p]), d = Te(() => Ct(a), [a]), {
242
+ enabled: M,
243
+ size: z,
244
+ offsetX: Z,
245
+ offsetY: h,
246
+ className: _,
247
+ maxVisualDistance: g,
248
+ maxSpeedMultiplier: P,
249
+ minSpeedMultiplier: R,
250
+ opacity: k,
251
+ renderVisual: L,
252
+ maxSpeedCurve: v
253
+ } = $, { mainSizeKey: w, crossSizeKey: b, positionKey: T, selectDelta: V, getPointerCoordinate: J, arrowLabels: oe, arrowIcons: q, directionClass: Q, orientation: ie } = d, j = Math.max(g, 1), ge = e / s, D = f, l = Math.max(e - D * 2, 0), B = ge * l, U = Math.min(Math.max(Be, B || 0), l || Be), N = s - e, ue = Math.max(l - U, 0), xe = N <= 0 || ue <= 0 ? 0 : t / N * ue, ot = xe + U / 2, de = s > e, He = de && i;
254
+ se(() => {
255
+ G.current = t;
256
+ }, [t]), se(() => {
257
+ r || ne(!1);
258
+ }, [r]), _t({ thumbRef: le, isDragging: O, isThumbHovered: X, enableThumbDrag: r, horizontal: a });
259
+ const fe = y(() => {
260
+ I.current !== null && (window.cancelAnimationFrame(I.current), I.current = null), x.current = null;
261
+ }, []), he = y(() => {
262
+ C.current = { ...et }, ce(!1), K.current?.reset(), fe();
263
+ }, [fe]), Me = y(
264
+ (m) => {
265
+ const Y = C.current;
266
+ if (!Y.active || Y.direction === 0) {
267
+ fe();
204
268
  return;
205
269
  }
206
- if (!he || z <= 0) {
207
- ce();
270
+ if (!de || N <= 0) {
271
+ fe();
208
272
  return;
209
273
  }
210
- const K = H.current ?? s, te = Math.max((s - K) / 1e3, 0);
211
- if (H.current = s, te <= 0) {
212
- w.current = window.requestAnimationFrame(Ve);
274
+ const ee = x.current ?? m, re = Math.max((m - ee) / 1e3, 0);
275
+ if (x.current = m, re <= 0) {
276
+ I.current = window.requestAnimationFrame(Me);
213
277
  return;
214
278
  }
215
- const _e = (Math.min(v.distance, B) / B) ** 1.1, be = Math.max(e * 0.2, 40), Fe = Math.max(e * C, 1200), Le = be + (Fe - be) * _e, Te = _.current, Ce = G(Te + v.direction * Le * te, 0, z);
216
- if (Ce === Te) {
217
- ce();
279
+ const ve = Math.min(Y.distance, j) / j, Re = ve ** 1.1, Ve = typeof p?.maxSpeedMultiplier == "number", ye = Math.max(e * R, 40), Fe = Ve ? ye : 1200;
280
+ let Le = Math.max(e * P, Fe);
281
+ if (v) {
282
+ const Ee = Math.max(v.exponentialSteepness, 0), pt = Math.max(v.exponentialScale ?? P, 0), gt = Ee === 0 ? ve : Math.expm1(Ee * ve), Ge = Ee === 0 ? 1 : Math.expm1(Ee) || 1, xt = Ge === 0 ? ve : Math.min(Math.max(gt / Ge, 0), 1), vt = e * pt * xt;
283
+ Le = Math.min(Le, Math.max(vt, ye));
284
+ }
285
+ const dt = Math.max(Le, ye), ft = Math.max(v?.easedOffset ?? 0, 0), ht = Math.min(1, Re + ft), mt = ye + (dt - ye) * ht, De = G.current, Ne = W(De + Y.direction * mt * re, 0, N);
286
+ if (Ne === De) {
287
+ fe();
218
288
  return;
219
289
  }
220
- _.current = Ce, n?.(Ce, Te), w.current = window.requestAnimationFrame(Ve);
290
+ G.current = Ne, n?.(Ne, De), I.current = window.requestAnimationFrame(Me);
221
291
  },
222
- [B, z, n, he, ce, C, e]
223
- ), ze = A(() => {
224
- w.current === null && (H.current = null, w.current = window.requestAnimationFrame(Ve));
225
- }, [Ve]);
292
+ [j, N, n, de, fe, v, P, R, p, e]
293
+ ), $e = y(() => {
294
+ I.current === null && (x.current = null, I.current = window.requestAnimationFrame(Me));
295
+ }, [Me]);
226
296
  se(() => () => {
227
- Ie(), ce();
228
- }, [Ie, ce]);
229
- const et = A(
230
- (s) => {
231
- x.current = s, le(s.active), s.active && s.direction !== 0 ? ze() : ce();
297
+ fe();
298
+ }, [fe]);
299
+ const it = y(
300
+ (m) => {
301
+ C.current = m, ce(m.active), m.active && m.direction !== 0 ? $e() : fe();
232
302
  },
233
- [ze, ce]
303
+ [$e, fe]
234
304
  );
235
305
  se(() => {
236
- D || ue();
237
- }, [ue, D]), se(() => {
238
- const s = (v) => {
239
- const te = v.detail?.paneId;
240
- te && d && te !== d || ue();
306
+ M || he();
307
+ }, [he, M]), se(() => {
308
+ const m = (Y) => {
309
+ const re = Y.detail?.paneId;
310
+ re && u && re !== u || he();
241
311
  };
242
- return window.addEventListener(Ne, s), () => {
243
- window.removeEventListener(Ne, s);
312
+ return window.addEventListener(ze, m), () => {
313
+ window.removeEventListener(ze, m);
244
314
  };
245
- }, [d, ue]), se(() => {
246
- if (!D)
315
+ }, [u, he]), se(() => {
316
+ if (!M)
247
317
  return;
248
- const s = (v) => {
249
- if (!x.current.active)
318
+ const m = (Y) => {
319
+ if (!C.current.active)
250
320
  return;
251
- const K = v.target;
252
- if (!(K instanceof Node)) {
253
- ue();
321
+ const ee = Y.target;
322
+ if (!(ee instanceof Node)) {
323
+ he();
254
324
  return;
255
325
  }
256
- P.current?.getElement()?.contains(K) || ue();
326
+ K.current?.getElement()?.contains(ee) || he();
257
327
  };
258
- return document.addEventListener("pointerdown", s, !0), () => {
259
- document.removeEventListener("pointerdown", s, !0);
328
+ return document.addEventListener("pointerdown", m, !0), () => {
329
+ document.removeEventListener("pointerdown", m, !0);
260
330
  };
261
- }, [ue, D]);
262
- const Ae = (s) => {
263
- if (!he || ie <= 0 || z <= 0)
331
+ }, [he, M]);
332
+ const _e = (m) => {
333
+ if (!de || ue <= 0 || N <= 0)
264
334
  return 0;
265
- const v = G(s, 0, ie);
266
- return G(v / ie * z, 0, z);
267
- }, Re = (s) => {
268
- if (!he || z <= 0)
335
+ const Y = W(m, 0, ue);
336
+ return W(Y / ue * N, 0, N);
337
+ }, at = (m) => {
338
+ if (!de || N <= 0)
269
339
  return;
270
- const v = Math.max(Math.round(e / ut), ct), K = _.current, te = G(K + s * v, 0, z);
271
- te !== K && (_.current = te, n?.(te, K));
272
- }, Pe = () => {
273
- Ie();
274
- }, He = (s) => (v) => {
275
- Ye && (v.preventDefault(), v.stopPropagation(), ue(), Ie(), Re(s), O.current = window.setTimeout(() => {
276
- U.current = window.setInterval(() => {
277
- Re(s);
278
- }, lt);
279
- }, at));
280
- }, tt = (s) => (v) => {
281
- l && (v.key === "Enter" || v.key === " " || v.key === "Spacebar") && (v.preventDefault(), Re(s));
282
- }, $e = (s) => {
283
- if (!he)
340
+ const Y = Math.max(Math.round(e / Mt), It), ee = G.current, re = W(ee + m * Y, 0, N);
341
+ re !== ee && (G.current = re, n?.(re, ee));
342
+ }, { handleArrowPointerDown: Xe, handleArrowPointerUp: Pe, handleArrowKeyDown: lt } = Rt({
343
+ canUseArrowButtons: He,
344
+ enableArrowButtons: i,
345
+ resetTapScroll: he,
346
+ scrollByStep: at
347
+ }), Ue = (m) => {
348
+ if (!de)
284
349
  return;
285
350
  if (!r) {
286
- s.preventDefault(), s.stopPropagation();
351
+ m.preventDefault(), m.stopPropagation();
287
352
  return;
288
353
  }
289
- if ("button" in s && s.button !== 0 || s.ctrlKey)
354
+ if ("button" in m && m.button !== 0 || m.ctrlKey)
290
355
  return;
291
- s.stopPropagation(), ue();
292
- const v = ge;
293
- X(!0), b(!0), je(
294
- s,
295
- ({ deltaX: K, deltaY: te }) => {
296
- const ve = q(K, te);
297
- n?.(Ae(v + ve), ge);
356
+ m.stopPropagation(), he();
357
+ const Y = xe;
358
+ te(!0), ne(!0), Qe(
359
+ m,
360
+ ({ deltaX: ee, deltaY: re }) => {
361
+ const ve = V(ee, re);
362
+ n?.(_e(Y + ve), xe);
298
363
  },
299
364
  () => {
300
- X(!1), Z.current && !Z.current.matches(":hover") && b(!1);
365
+ te(!1), le.current && !le.current.matches(":hover") && ne(!1);
301
366
  }
302
367
  );
303
- }, Xe = (s) => {
304
- if (!he)
368
+ }, Ke = (m) => {
369
+ if (!de)
305
370
  return;
306
- if (!i) {
307
- s.preventDefault(), s.stopPropagation();
371
+ if (!o) {
372
+ m.preventDefault(), m.stopPropagation();
308
373
  return;
309
374
  }
310
- if ("button" in s && s.button !== 0 || s.ctrlKey)
375
+ if ("button" in m && m.button !== 0 || m.ctrlKey)
311
376
  return;
312
- const K = "touches" in s.nativeEvent ? s.nativeEvent.touches[0] : s.nativeEvent, te = oe(K), ve = s.currentTarget.getBoundingClientRect(), _e = te - (a ? ve.left : ve.top);
313
- ue();
314
- const be = _e - Q / 2;
315
- n?.(Ae(be), ge), je(s, ({ deltaX: Fe, deltaY: Le }) => {
316
- const Te = q(Fe, Le);
317
- n?.(Ae(be + Te), ge);
377
+ const ee = "touches" in m.nativeEvent ? m.nativeEvent.touches[0] : m.nativeEvent, re = J(ee), ve = m.currentTarget.getBoundingClientRect(), Re = re - (a ? ve.left : ve.top);
378
+ he();
379
+ const Ve = Re - U / 2;
380
+ n?.(_e(Ve), xe), Qe(m, ({ deltaX: ye, deltaY: Fe }) => {
381
+ const We = V(ye, Fe);
382
+ n?.(_e(Ve + We), xe);
318
383
  });
319
- }, nt = xe(() => G((ae ? 1 : 0.8) * M, 0, 1), [ae, M]), rt = xe(() => {
320
- const v = `calc(50% - ${f / 2}px + ${g}px)`;
384
+ }, ct = Te(() => W((S ? 1 : 0.8) * k, 0, 1), [S, k]), ut = Te(() => {
385
+ const Y = `calc(50% - ${z / 2}px + ${h}px)`;
321
386
  return {
322
- left: F,
323
- top: v
387
+ left: Z,
388
+ top: Y
324
389
  };
325
- }, [F, g, f]), Ue = (s, v, K) => /* @__PURE__ */ $(
390
+ }, [Z, h, z]), qe = (m, Y, ee) => /* @__PURE__ */ H(
326
391
  "button",
327
392
  {
328
393
  type: "button",
329
394
  className: "flex items-center justify-center text-[#313131] text-xs transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[#60a5fa] focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50",
330
395
  style: {
331
- [I]: Y,
332
- [T]: h,
396
+ [w]: D,
397
+ [b]: f,
333
398
  backgroundColor: "#E0E0E0"
334
399
  },
335
- "aria-label": v,
336
- onMouseDown: He(s),
337
- onTouchStart: He(s),
400
+ "aria-label": Y,
401
+ onMouseDown: Xe(m),
402
+ onTouchStart: Xe(m),
338
403
  onMouseUp: Pe,
339
404
  onMouseLeave: Pe,
340
405
  onTouchEnd: Pe,
341
406
  onTouchCancel: Pe,
342
- onKeyDown: tt(s),
343
- "aria-disabled": !l,
344
- disabled: !Ye,
345
- children: /* @__PURE__ */ $("span", { "aria-hidden": "true", children: K })
407
+ onKeyDown: lt(m),
408
+ "aria-disabled": !i,
409
+ disabled: !He,
410
+ children: /* @__PURE__ */ H("span", { "aria-hidden": "true", children: ee })
346
411
  }
347
- );
412
+ ), je = A && de ? {
413
+ orientation: ie,
414
+ scrollPosition: t,
415
+ maxScrollPosition: N,
416
+ contentSize: s,
417
+ viewportSize: e,
418
+ thumbSize: U,
419
+ thumbPosition: xe,
420
+ thumbCenter: ot,
421
+ trackSize: l,
422
+ isDragging: O,
423
+ isTapScrollActive: S
424
+ } : null;
348
425
  return /* @__PURE__ */ Se(
349
426
  "div",
350
427
  {
351
- className: we(
352
- "group relative cursor-default select-none",
353
- ne,
354
- u
355
- ),
428
+ className: Ie("group relative cursor-default select-none", Q, c),
356
429
  style: {
357
- [I]: e,
358
- [T]: h,
430
+ [w]: e,
431
+ [b]: f,
359
432
  backgroundColor: "white",
360
433
  userSelect: "none",
361
434
  position: "relative"
362
435
  },
363
436
  role: "scrollbar",
364
437
  tabIndex: -1,
365
- "aria-controls": d,
438
+ "aria-controls": u,
366
439
  "aria-valuenow": t,
367
440
  "aria-valuemin": 0,
368
- "aria-valuemax": z,
441
+ "aria-valuemax": N,
369
442
  "aria-orientation": a ? "horizontal" : "vertical",
370
443
  children: [
371
- !a && he && D && /* @__PURE__ */ $(
372
- Qe,
444
+ !a && de && M && /* @__PURE__ */ H(
445
+ st,
373
446
  {
374
- ref: P,
375
- className: we(
376
- "pointer-events-auto absolute transition-opacity duration-150",
377
- N
378
- ),
379
- size: f,
380
- maxVisualDistance: B,
381
- style: rt,
382
- opacity: nt,
383
- renderVisual: y,
384
- onDragChange: et
447
+ ref: K,
448
+ className: Ie("pointer-events-auto absolute transition-opacity duration-150", _),
449
+ size: z,
450
+ maxVisualDistance: j,
451
+ style: ut,
452
+ opacity: ct,
453
+ renderVisual: L,
454
+ onDragChange: it
385
455
  }
386
456
  ),
387
- Ue(-1, j[0], W[0]),
388
- /* @__PURE__ */ $(
457
+ qe(-1, oe[0], q[0]),
458
+ /* @__PURE__ */ Se(
389
459
  "div",
390
460
  {
391
461
  className: "relative flex-1",
392
462
  style: {
393
463
  backgroundColor: "#F5F5F5",
394
- borderRadius: h / 2
464
+ borderRadius: f / 2
395
465
  },
396
- onMouseDown: Xe,
397
- onTouchStart: Xe,
398
- "aria-disabled": !i,
399
- children: he && // スクロールバーのつまみの当たり判定を広げるためのラッパー
400
- /* @__PURE__ */ $(
401
- "div",
402
- {
403
- className: "group absolute",
404
- style: {
405
- [I]: Q,
406
- [S]: ge,
407
- ...a ? { top: 0, bottom: 0 } : { left: 0, right: 0 }
408
- },
409
- onMouseDown: $e,
410
- onTouchStart: $e,
411
- role: "slider",
412
- "aria-orientation": a ? "horizontal" : "vertical",
413
- "aria-valuenow": t,
414
- "aria-valuemin": 0,
415
- "aria-valuemax": z,
416
- "aria-disabled": !r,
417
- tabIndex: r ? 0 : -1,
418
- children: /* @__PURE__ */ $(
419
- "div",
420
- {
421
- ref: Z,
422
- className: we(
423
- "absolute",
424
- a ? `inset-x-0 inset-y-[1.5px] group-hover:inset-y-[-0.5px] ${V ? "-inset-y-0.5" : "group-active:-inset-y-0.5"}` : `inset-x-[1.5px] inset-y-0 group-hover:inset-x-[-0.5px] ${V ? "-inset-x-0.5" : "group-active:-inset-x-0.5"}`
425
- ),
426
- style: {
427
- backgroundColor: "#7F7F7F",
428
- borderRadius: h - 1,
429
- cursor: r ? "pointer" : "default",
430
- ...a ? {
431
- left: 0,
432
- right: 0,
433
- top: 1.5,
434
- bottom: 1.5
435
- } : {
436
- top: 0,
437
- bottom: 0,
438
- left: 1.5,
439
- right: 1.5
466
+ onMouseDown: Ke,
467
+ onTouchStart: Ke,
468
+ "aria-disabled": !o,
469
+ children: [
470
+ je && /* @__PURE__ */ H("div", { className: "pointer-events-none absolute inset-0", "aria-hidden": !0, children: A?.(je) }),
471
+ de && // スクロールバーのつまみの当たり判定を広げるためのラッパー
472
+ /* @__PURE__ */ H(
473
+ "div",
474
+ {
475
+ className: "group absolute",
476
+ style: {
477
+ [w]: U,
478
+ [T]: xe,
479
+ ...a ? { top: 0, bottom: 0 } : { left: 0, right: 0 }
480
+ },
481
+ onMouseDown: Ue,
482
+ onTouchStart: Ue,
483
+ role: "slider",
484
+ "aria-orientation": a ? "horizontal" : "vertical",
485
+ "aria-valuenow": t,
486
+ "aria-valuemin": 0,
487
+ "aria-valuemax": N,
488
+ "aria-disabled": !r,
489
+ tabIndex: r ? 0 : -1,
490
+ children: /* @__PURE__ */ H(
491
+ "div",
492
+ {
493
+ ref: le,
494
+ className: Ie(
495
+ "absolute",
496
+ a ? `inset-x-0 inset-y-[1.5px] group-hover:inset-y-[-0.5px] ${O ? "-inset-y-0.5" : "group-active:-inset-y-0.5"}` : `inset-x-[1.5px] inset-y-0 group-hover:inset-x-[-0.5px] ${O ? "-inset-x-0.5" : "group-active:-inset-x-0.5"}`
497
+ ),
498
+ style: {
499
+ backgroundColor: "#7F7F7F",
500
+ borderRadius: f - 1,
501
+ cursor: r ? "pointer" : "default",
502
+ ...a ? {
503
+ left: 0,
504
+ right: 0,
505
+ top: 1.5,
506
+ bottom: 1.5
507
+ } : {
508
+ top: 0,
509
+ bottom: 0,
510
+ left: 1.5,
511
+ right: 1.5
512
+ }
513
+ },
514
+ onMouseEnter: () => {
515
+ r && ne(!0);
516
+ },
517
+ onMouseLeave: () => {
518
+ r && ne(!1);
440
519
  }
441
- },
442
- onMouseEnter: () => {
443
- r && b(!0);
444
- },
445
- onMouseLeave: () => {
446
- r && b(!1);
447
520
  }
448
- }
449
- )
450
- }
451
- )
521
+ )
522
+ }
523
+ )
524
+ ]
452
525
  }
453
526
  ),
454
- Ue(1, j[1], W[1])
527
+ qe(1, oe[1], q[1])
455
528
  ]
456
529
  }
457
530
  );
458
- }, re = {
459
- debug(o, ...e) {
460
- typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${o}`, ...e);
531
+ }, ae = {
532
+ debug(s, ...e) {
533
+ typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${s}`, ...e);
461
534
  },
462
- warn(o, ...e) {
463
- console.warn(`[VirtualScroll] ${o}`, ...e);
535
+ warn(s, ...e) {
536
+ console.warn(`[VirtualScroll] ${s}`, ...e);
464
537
  },
465
- error(o, ...e) {
466
- console.error(`[VirtualScroll] ${o}`, ...e);
538
+ error(s, ...e) {
539
+ console.error(`[VirtualScroll] ${s}`, ...e);
467
540
  }
468
- }, ye = {
541
+ }, we = {
469
542
  maxVelocity: 6,
470
543
  minVelocity: 0.02,
471
544
  deceleration: 25e-4,
472
545
  velocitySampleWindow: 90,
473
546
  startVelocityThreshold: 0.04
474
- }, Me = (o, e, t) => {
475
- for (const [n, r, i] of e)
476
- t === "add" ? o.addEventListener(n, r, i) : o.removeEventListener(n, r, i);
477
- }, gt = ke(({ children: o, contentSize: e, viewportSize: t, scrollBarWidth: n = 12, enableThumbDrag: r = !0, enableTrackClick: i = !0, enableArrowButtons: l = !0, enablePointerDrag: a = !0, onScroll: h, className: u, style: d, background: p, tapScrollCircleOptions: R, inertiaOptions: V, itemCount: X }, ee) => {
478
- const b = k(0), [ae, le] = st((f) => f + 1, 0), Z = k(null), _ = k(null), U = k({
547
+ }, Ce = (s, e, t) => {
548
+ for (const [n, r, o] of e)
549
+ t === "add" ? s.addEventListener(n, r, o) : s.removeEventListener(n, r, o);
550
+ }, Dt = ke(({ children: s, contentSize: e, viewportSize: t, scrollBarWidth: n = 12, enableThumbDrag: r = !0, enableTrackClick: o = !0, enableArrowButtons: i = !0, enablePointerDrag: a = !0, onScroll: f, className: c, style: u, background: p, tapScrollCircleOptions: E, inertiaOptions: A, itemCount: O, renderThumbOverlay: te, wheelSpeedMultiplier: X = 1 }, ne) => {
551
+ const S = F(0), [ce, le] = bt((h) => h + 1, 0), G = F(null), C = F(null), K = F({
479
552
  frame: null,
480
553
  velocity: 0,
481
554
  lastTimestamp: null
482
- }), O = xe(
555
+ }), I = Te(
483
556
  () => ({
484
- maxVelocity: V?.maxVelocity ?? ye.maxVelocity,
485
- minVelocity: V?.minVelocity ?? ye.minVelocity,
486
- deceleration: V?.deceleration ?? ye.deceleration,
487
- velocitySampleWindow: V?.velocitySampleWindow ?? ye.velocitySampleWindow,
488
- startVelocityThreshold: V?.startVelocityThreshold ?? ye.startVelocityThreshold
557
+ maxVelocity: A?.maxVelocity ?? we.maxVelocity,
558
+ minVelocity: A?.minVelocity ?? we.minVelocity,
559
+ deceleration: A?.deceleration ?? we.deceleration,
560
+ velocitySampleWindow: A?.velocitySampleWindow ?? we.velocitySampleWindow,
561
+ startVelocityThreshold: A?.startVelocityThreshold ?? we.startVelocityThreshold
489
562
  }),
490
- [V]
563
+ [A]
491
564
  );
492
- re.debug("[ScrollPane] ScrollPane rendered", { contentSize: e, viewportSize: t, scrollBarWidth: n, className: u, style: d, tapScrollCircleOptions: R, inertiaOptions: V, enablePointerDrag: a });
493
- const x = k({ contentSize: e, viewportSize: t }), P = xe(() => e > t, [e, t]), w = A(
494
- (f) => {
495
- const { contentSize: F, viewportSize: g } = x.current, N = F > g, L = b.current;
496
- if (re.debug("[ScrollPane] scrollTo called", { newPosition: f, contentSize: F, viewportSize: g, currentIsScrollable: N, prevPosition: L }), !N) {
497
- b.current !== 0 && (b.current = 0, h?.(0, L));
565
+ ae.debug("[ScrollPane] ScrollPane rendered", { contentSize: e, viewportSize: t, scrollBarWidth: n, className: c, style: u, tapScrollCircleOptions: E, inertiaOptions: A, enablePointerDrag: a });
566
+ const x = F({ contentSize: e, viewportSize: t }), $ = Te(() => e > t, [e, t]), d = y(
567
+ (h) => {
568
+ const { contentSize: _, viewportSize: g } = x.current, P = _ > g, R = S.current;
569
+ if (ae.debug("[ScrollPane] scrollTo called", { newPosition: h, contentSize: _, viewportSize: g, currentIsScrollable: P, prevPosition: R }), !P) {
570
+ S.current !== 0 && (S.current = 0, f?.(0, R));
498
571
  return;
499
572
  }
500
- const C = typeof f == "function" ? f(b.current) : f, M = G(C, 0, F - g);
501
- b.current !== M && (b.current = M, h?.(M, L));
573
+ const k = typeof h == "function" ? h(S.current) : h, L = W(k, 0, _ - g);
574
+ S.current !== L && (S.current = L, f?.(L, R));
502
575
  },
503
- [h]
504
- ), H = A(() => {
505
- const f = U.current;
506
- f.frame !== null && cancelAnimationFrame(f.frame), f.frame = null, f.velocity = 0, f.lastTimestamp = null;
507
- }, []), m = A(
508
- (f) => {
509
- if (!P)
576
+ [f]
577
+ ), M = y(() => {
578
+ const h = K.current;
579
+ h.frame !== null && cancelAnimationFrame(h.frame), h.frame = null, h.velocity = 0, h.lastTimestamp = null;
580
+ }, []), z = y(
581
+ (h) => {
582
+ if (!$)
510
583
  return;
511
- const { maxVelocity: F, minVelocity: g, deceleration: N, startVelocityThreshold: L } = O, C = G(f, -F, F);
512
- if (Math.abs(C) < L)
584
+ const { maxVelocity: _, minVelocity: g, deceleration: P, startVelocityThreshold: R } = I, k = W(h, -_, _);
585
+ if (Math.abs(k) < R)
513
586
  return;
514
- H(), U.current.velocity = C, U.current.lastTimestamp = null;
515
- const M = (y) => {
516
- const I = U.current;
517
- if (I.lastTimestamp === null) {
518
- I.lastTimestamp = y, I.frame = requestAnimationFrame(M);
587
+ M(), K.current.velocity = k, K.current.lastTimestamp = null;
588
+ const L = (v) => {
589
+ const w = K.current;
590
+ if (w.lastTimestamp === null) {
591
+ w.lastTimestamp = v, w.frame = requestAnimationFrame(L);
519
592
  return;
520
593
  }
521
- const T = y - I.lastTimestamp;
522
- if (I.lastTimestamp = y, T <= 0) {
523
- I.frame = requestAnimationFrame(M);
594
+ const b = v - w.lastTimestamp;
595
+ if (w.lastTimestamp = v, b <= 0) {
596
+ w.frame = requestAnimationFrame(L);
524
597
  return;
525
598
  }
526
- const S = I.velocity;
527
- let E = S;
528
- const q = N * T;
529
- S > 0 ? E = Math.max(0, S - q) : S < 0 && (E = Math.min(0, S + q));
530
- const j = (S + E) / 2 * T, W = b.current;
531
- j !== 0 && w((J) => J + j);
532
- const ne = b.current, { contentSize: B, viewportSize: fe } = x.current, Y = Math.max(B - fe, 0);
533
- I.velocity = E;
534
- const c = ne === W || ne <= 0 && E <= 0 || ne >= Y && E >= 0;
535
- if (Math.abs(E) < g || c) {
536
- H();
599
+ const T = w.velocity;
600
+ let V = T;
601
+ const J = P * b;
602
+ T > 0 ? V = Math.max(0, T - J) : T < 0 && (V = Math.min(0, T + J));
603
+ const q = (T + V) / 2 * b, Q = S.current;
604
+ q !== 0 && d((B) => B + q);
605
+ const ie = S.current, { contentSize: j, viewportSize: ge } = x.current, D = Math.max(j - ge, 0);
606
+ w.velocity = V;
607
+ const l = ie === Q || ie <= 0 && V <= 0 || ie >= D && V >= 0;
608
+ if (Math.abs(V) < g || l) {
609
+ M();
537
610
  return;
538
611
  }
539
- I.frame = requestAnimationFrame(M);
612
+ w.frame = requestAnimationFrame(L);
540
613
  };
541
- U.current.frame = requestAnimationFrame(M);
614
+ K.current.frame = requestAnimationFrame(L);
542
615
  },
543
- [P, O, w, H]
616
+ [$, I, d, M]
544
617
  );
545
- Ee(() => {
618
+ Ae(() => {
546
619
  x.current = { contentSize: e, viewportSize: t };
547
- }, [e, t]), Ee(() => {
548
- if (P) {
549
- re.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", { contentSize: e, viewportSize: t, scrollPosition: b.current });
550
- const f = G(e - t, 0, e);
551
- b.current > f && w(f);
620
+ }, [e, t]), Ae(() => {
621
+ if ($) {
622
+ ae.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", { contentSize: e, viewportSize: t, scrollPosition: S.current });
623
+ const h = W(e - t, 0, e);
624
+ S.current > h && d(h);
552
625
  } else
553
- w(0);
554
- }, [P, w, e, t]), se(() => {
555
- const f = (g) => {
556
- if (!P)
626
+ d(0);
627
+ }, [$, d, e, t]), se(() => {
628
+ const h = (g) => {
629
+ if (!$)
557
630
  return;
558
- g.preventDefault(), H();
559
- let N = g.deltaY;
560
- g.deltaMode === 1 ? N *= 16 : g.deltaMode === 2 && (N *= t), re.debug("[ScrollPane] wheel event", { deltaY: N, scrollPosition: b.current }), w((L) => L + N);
561
- }, F = Z.current;
562
- return F && F.addEventListener("wheel", f, { passive: !1 }), () => {
563
- F && F.removeEventListener("wheel", f);
631
+ g.preventDefault(), M();
632
+ let P = g.deltaY;
633
+ g.deltaMode === 1 ? P *= 16 : g.deltaMode === 2 && (P *= t), X !== 1 && (P *= X), ae.debug("[ScrollPane] wheel event", { deltaY: P, scrollPosition: S.current, wheelSpeedMultiplier: X }), d((R) => R + P);
634
+ }, _ = G.current;
635
+ return _ && _.addEventListener("wheel", h, { passive: !1 }), () => {
636
+ _ && _.removeEventListener("wheel", h);
564
637
  };
565
- }, [P, w, H, t]), Oe(
566
- ee,
638
+ }, [$, d, M, t, X]), Ye(
639
+ ne,
567
640
  () => ({
568
- scrollTo: w,
569
- getScrollPosition: () => b.current,
641
+ scrollTo: d,
642
+ getScrollPosition: () => S.current,
570
643
  getContentSize: () => e,
571
644
  getViewportSize: () => t
572
645
  }),
573
- [w, e, t]
646
+ [d, e, t]
574
647
  );
575
- const D = ot();
648
+ const Z = Tt();
576
649
  return se(() => {
577
- const f = _.current;
578
- if (!f)
650
+ const h = C.current;
651
+ if (!h)
579
652
  return;
580
653
  if (!a) {
581
- H();
654
+ M();
582
655
  return;
583
656
  }
584
- const F = 6;
585
- let g = null, N = 0, L = 0, C = !1, M = !1, y = null, I = [];
586
- const T = () => {
587
- g = null, N = 0, L = 0, C = !1, I = [];
588
- }, S = (c) => {
589
- const J = performance.now();
590
- I.push({ clientY: c, time: J }), I = I.filter((Q) => J - Q.time <= O.velocitySampleWindow);
591
- }, E = (c) => c instanceof HTMLElement && c.closest("[data-scrollpane-ignore-drag='true']") !== null, q = (c) => {
592
- M && (c.preventDefault(), c.stopPropagation(), M = !1);
593
- }, oe = (c) => {
594
- C || (C = !0, M = !0, f.hasPointerCapture(c.pointerId) || f.setPointerCapture(c.pointerId), S(c.clientY));
595
- }, j = (c) => {
596
- if (g !== c.pointerId || !C && (Math.abs(c.clientY - N) < F || (oe(c), !C)))
657
+ const _ = 6;
658
+ let g = null, P = 0, R = 0, k = !1, L = !1, v = null, w = [];
659
+ const b = () => {
660
+ g = null, P = 0, R = 0, k = !1, w = [];
661
+ }, T = (l) => {
662
+ const B = performance.now();
663
+ w.push({ clientY: l, time: B }), w = w.filter((U) => B - U.time <= I.velocitySampleWindow);
664
+ }, V = (l) => l instanceof HTMLElement && l.closest("[data-scrollpane-ignore-drag='true']") !== null, J = (l) => {
665
+ L && (l.preventDefault(), l.stopPropagation(), L = !1);
666
+ }, oe = (l) => {
667
+ k || (k = !0, L = !0, h.hasPointerCapture(l.pointerId) || h.setPointerCapture(l.pointerId), T(l.clientY));
668
+ }, q = (l) => {
669
+ if (g !== l.pointerId || !k && (Math.abs(l.clientY - P) < _ || (oe(l), !k)))
597
670
  return;
598
- S(c.clientY);
599
- const J = c.clientY - N, Q = L - J;
600
- w(Q), c.cancelable && c.preventDefault();
601
- }, W = (c) => {
602
- if (g !== c.pointerId)
671
+ T(l.clientY);
672
+ const B = l.clientY - P, U = R - B;
673
+ d(U), l.cancelable && l.preventDefault();
674
+ }, Q = (l) => {
675
+ if (g !== l.pointerId)
603
676
  return;
604
- C && M && c.cancelable && (c.preventDefault(), c.stopPropagation()), f.hasPointerCapture(c.pointerId) && f.releasePointerCapture(c.pointerId);
605
- let J = 0;
606
- if (C && I.length >= 2) {
607
- const Q = I[I.length - 1], z = I.find((ie) => Q.time - ie.time <= O.velocitySampleWindow) ?? I[0];
608
- if (Q && z && Q.time !== z.time) {
609
- const ie = Q.clientY - z.clientY, ge = Q.time - z.time;
610
- J = -(ie / ge);
677
+ k && L && l.cancelable && (l.preventDefault(), l.stopPropagation()), h.hasPointerCapture(l.pointerId) && h.releasePointerCapture(l.pointerId);
678
+ let B = 0;
679
+ if (k && w.length >= 2) {
680
+ const U = w[w.length - 1], N = w.find((ue) => U.time - ue.time <= I.velocitySampleWindow) ?? w[0];
681
+ if (U && N && U.time !== N.time) {
682
+ const ue = U.clientY - N.clientY, xe = U.time - N.time;
683
+ B = -(ue / xe);
611
684
  }
612
685
  }
613
- T(), y !== null && window.clearTimeout(y), M && (y = window.setTimeout(() => {
614
- M = !1, y = null;
615
- }, 0)), Math.abs(J) >= O.startVelocityThreshold && m(J);
616
- }, ne = (c) => {
617
- P && (c.button !== 0 && c.pointerType === "mouse" || c.ctrlKey || c.metaKey || c.altKey || E(c.target) || (window.dispatchEvent(new CustomEvent(Ne, { detail: { paneId: D } })), H(), g = c.pointerId, N = c.clientY, L = b.current, C = !1, M = !1, I = []));
618
- }, B = (c) => {
619
- g === c.pointerId && (M = !1, f.hasPointerCapture(c.pointerId) && f.releasePointerCapture(c.pointerId), y !== null && (window.clearTimeout(y), y = null), T());
620
- }, fe = [
621
- ["click", q, !0],
622
- ["pointerdown", ne, { passive: !1 }],
623
- ["pointermove", j, { passive: !1 }],
624
- ["pointerup", W, void 0],
625
- ["pointercancel", B, void 0]
626
- ], Y = [
627
- ["pointermove", j, { passive: !1 }],
628
- ["pointerup", W, void 0],
629
- ["pointercancel", B, void 0]
686
+ b(), v !== null && window.clearTimeout(v), L && (v = window.setTimeout(() => {
687
+ L = !1, v = null;
688
+ }, 0)), Math.abs(B) >= I.startVelocityThreshold && z(B);
689
+ }, ie = (l) => {
690
+ $ && (l.button !== 0 && l.pointerType === "mouse" || l.ctrlKey || l.metaKey || l.altKey || V(l.target) || (window.dispatchEvent(new CustomEvent(ze, { detail: { paneId: Z } })), M(), g = l.pointerId, P = l.clientY, R = S.current, k = !1, L = !1, w = []));
691
+ }, j = (l) => {
692
+ g === l.pointerId && (L = !1, h.hasPointerCapture(l.pointerId) && h.releasePointerCapture(l.pointerId), v !== null && (window.clearTimeout(v), v = null), b());
693
+ }, ge = [
694
+ ["click", J, !0],
695
+ ["pointerdown", ie, { passive: !1 }],
696
+ ["pointermove", q, { passive: !1 }],
697
+ ["pointerup", Q, void 0],
698
+ ["pointercancel", j, void 0]
699
+ ], D = [
700
+ ["pointermove", q, { passive: !1 }],
701
+ ["pointerup", Q, void 0],
702
+ ["pointercancel", j, void 0]
630
703
  ];
631
- return Me(f, fe, "add"), Me(window, Y, "add"), () => {
632
- Me(f, fe, "remove"), Me(window, Y, "remove"), g !== null && f.hasPointerCapture(g) && f.releasePointerCapture(g), y !== null && window.clearTimeout(y), H();
704
+ return Ce(h, ge, "add"), Ce(window, D, "add"), () => {
705
+ Ce(h, ge, "remove"), Ce(window, D, "remove"), g !== null && h.hasPointerCapture(g) && h.releasePointerCapture(g), v !== null && window.clearTimeout(v), M();
633
706
  };
634
- }, [a, D, P, O, w, m, H]), /* @__PURE__ */ Se("div", { ref: Z, className: we("flex", u), style: d, children: [
707
+ }, [a, Z, $, I, d, z, M]), /* @__PURE__ */ Se("div", { ref: G, className: Ie("flex", c), style: u, children: [
635
708
  /* @__PURE__ */ Se(
636
709
  "div",
637
710
  {
638
- ref: _,
711
+ ref: C,
639
712
  className: "relative h-full flex-1 overflow-hidden",
640
713
  style: { height: t, ...a ? { touchAction: "none" } : {} },
641
- id: D,
714
+ id: Z,
642
715
  children: [
643
716
  p,
644
- o(b.current)
717
+ s(S.current)
645
718
  ]
646
719
  }
647
720
  ),
648
- P && /* @__PURE__ */ $(
649
- pt,
721
+ $ && /* @__PURE__ */ H(
722
+ Lt,
650
723
  {
651
724
  contentSize: e,
652
725
  viewportSize: t,
653
- scrollPosition: b.current,
654
- onScroll: w,
726
+ scrollPosition: S.current,
727
+ onScroll: d,
655
728
  enableThumbDrag: r,
656
- enableTrackClick: i,
657
- enableArrowButtons: l,
729
+ enableTrackClick: o,
730
+ enableArrowButtons: i,
658
731
  scrollBarWidth: n,
659
- ariaControls: D,
660
- tapScrollCircleOptions: R,
661
- itemCount: X
732
+ ariaControls: Z,
733
+ tapScrollCircleOptions: E,
734
+ itemCount: O,
735
+ renderThumbOverlay: te
662
736
  }
663
737
  )
664
738
  ] });
665
- }), Ge = (o, e, t) => Math.min(Math.max(o, e), t), Mt = ({ dragState: o, normalizedDistance: e, sizeScale: t, size: n }) => {
666
- const r = Math.max(n / 2, 1), i = 1 + e * 0.65, l = Math.max(0.65, 1 - e * 0.25), a = o.direction * e * 26 * t, h = 0.8 + e * 0.18, u = 3 * t, d = 6 * t, p = 22 * t, R = Math.abs(a) + d, V = a > 0 ? u : -Math.abs(a) - u, X = Math.max(2.5, 3 * t), ee = Ge(o.offsetX, -r, r), b = Ge(o.offsetY, -r, r), ae = r * 0.35, le = ee / r * ae, Z = b / r * ae, _ = le * 0.45, U = Z * 0.45, O = Math.max(p * 0.38, 6), x = 0.65 + e * 0.2, P = o.active;
667
- return /* @__PURE__ */ Se(Je, { children: [
668
- /* @__PURE__ */ $(
739
+ }), tt = (s, e, t) => Math.min(Math.max(s, e), t), qt = ({ dragState: s, normalizedDistance: e, sizeScale: t, size: n }) => {
740
+ const r = Math.max(n / 2, 1), o = 1 + e * 0.65, i = Math.max(0.65, 1 - e * 0.25), a = s.direction * e * 26 * t, f = 0.8 + e * 0.18, c = 3 * t, u = 6 * t, p = 22 * t, E = Math.abs(a) + u, A = a > 0 ? c : -Math.abs(a) - c, O = Math.max(2.5, 3 * t), te = tt(s.offsetX, -r, r), X = tt(s.offsetY, -r, r), ne = r * 0.35, S = te / r * ne, ce = X / r * ne, le = S * 0.45, G = ce * 0.45, C = Math.max(p * 0.38, 6), K = 0.65 + e * 0.2, I = s.active;
741
+ return /* @__PURE__ */ Se(rt, { children: [
742
+ /* @__PURE__ */ H(
669
743
  "div",
670
744
  {
671
745
  className: "absolute inset-0 rounded-full border border-white/40 bg-linear-to-br from-[#1d4ed8]/60 via-[#60a5fa]/55 to-[#bfdbfe]/40 shadow-md",
672
746
  style: {
673
- transform: `scale(${l}, ${i})`,
674
- transition: P ? "40ms transform ease-out" : "200ms ease transform"
747
+ transform: `scale(${i}, ${o})`,
748
+ transition: I ? "40ms transform ease-out" : "200ms ease transform"
675
749
  }
676
750
  }
677
751
  ),
678
- /* @__PURE__ */ $(
752
+ /* @__PURE__ */ H(
679
753
  "div",
680
754
  {
681
755
  className: "absolute top-1/2 left-1/2 rounded-full border border-white/50 bg-white/85",
682
756
  style: {
683
757
  width: p,
684
758
  height: p,
685
- transform: `translate(calc(-50% + ${le}px), calc(-50% + ${Z}px)) scale(${l}, ${h * i})`,
686
- transition: P ? "70ms transform ease-out" : "200ms ease transform"
759
+ transform: `translate(calc(-50% + ${S}px), calc(-50% + ${ce}px)) scale(${i}, ${f * o})`,
760
+ transition: I ? "70ms transform ease-out" : "200ms ease transform"
687
761
  }
688
762
  }
689
763
  ),
690
- /* @__PURE__ */ $(
764
+ /* @__PURE__ */ H(
691
765
  "div",
692
766
  {
693
767
  className: "absolute top-1/2 left-1/2 rounded-full bg-white/80",
694
768
  style: {
695
- width: O,
696
- height: O,
697
- transform: `translate(calc(-50% + ${_}px), calc(-50% + ${U}px)) scale(${l}, ${i})`,
698
- opacity: x,
769
+ width: C,
770
+ height: C,
771
+ transform: `translate(calc(-50% + ${le}px), calc(-50% + ${G}px)) scale(${i}, ${o})`,
772
+ opacity: K,
699
773
  boxShadow: "0 0 8px rgba(255,255,255,0.45)",
700
- transition: P ? "120ms opacity 150ms, 120ms transform ease-out ease-out" : "220ms ease transform, 240ms opacity ease"
774
+ transition: I ? "120ms opacity 150ms, 120ms transform ease-out ease-out" : "220ms ease transform, 240ms opacity ease"
701
775
  }
702
776
  }
703
777
  ),
704
- /* @__PURE__ */ $(
778
+ /* @__PURE__ */ H(
705
779
  "div",
706
780
  {
707
781
  className: "absolute top-1/2 left-1/2 rounded-full bg-white/50",
708
782
  style: {
709
- width: X,
710
- height: R,
711
- transform: `translate(-50%, ${V}px)`,
783
+ width: O,
784
+ height: E,
785
+ transform: `translate(-50%, ${A}px)`,
712
786
  opacity: e,
713
- transition: P ? "40ms height, 60ms opacity ease-out ease-out" : "200ms ease height, 120ms ease opacity"
787
+ transition: I ? "40ms height, 60ms opacity ease-out ease-out" : "200ms ease height, 120ms ease opacity"
714
788
  }
715
789
  }
716
790
  )
717
791
  ] });
718
792
  };
719
- class xt {
793
+ class Nt {
720
794
  /**
721
795
  * @private
722
796
  * @property {Map<number, number>} tree - The Map storing the Fenwick tree structure, specifically the sums of deltas. It is 1-indexed.
@@ -770,17 +844,17 @@ class xt {
770
844
  reset(e, t, n) {
771
845
  if (this.size = e, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.total = void 0, typeof t == "function") {
772
846
  if (this.valueFn = t, this.size > 0) {
773
- const i = n?.sampleRange ?? {
847
+ const o = n?.sampleRange ?? {
774
848
  from: 0,
775
849
  to: Math.min(99, this.size - 1)
776
- }, { mode: l, materializedValues: a } = this._calculateMode(i.from, i.to);
777
- if (this.baseValue = l, n?.materialize)
778
- for (let h = 0; h < a.length; h++) {
779
- const u = a[h], d = i.from + h;
780
- if (d >= this.size)
850
+ }, { mode: i, materializedValues: a } = this._calculateMode(o.from, o.to);
851
+ if (this.baseValue = i, n?.materialize)
852
+ for (let f = 0; f < a.length; f++) {
853
+ const c = a[f], u = o.from + f;
854
+ if (u >= this.size)
781
855
  break;
782
- const p = u - this.baseValue;
783
- this.deltas.set(d, p), this._updateTree(d, p);
856
+ const p = c - this.baseValue;
857
+ this.deltas.set(u, p), this._updateTree(u, p);
784
858
  }
785
859
  } else
786
860
  this.baseValue = 0;
@@ -810,29 +884,29 @@ class xt {
810
884
  if (!this.valueFn)
811
885
  return { mode: 0, materializedValues: [] };
812
886
  const n = [];
813
- for (let u = e; u <= t && !(u >= this.size); u++)
814
- n.push(this.valueFn(u));
887
+ for (let c = e; c <= t && !(c >= this.size); c++)
888
+ n.push(this.valueFn(c));
815
889
  const r = [...n];
816
890
  if (n.length === 0)
817
891
  return { mode: 0, materializedValues: [] };
818
- n.sort((u, d) => u - d);
819
- const i = Math.floor(n.length / 2);
820
- let l;
821
- n.length % 2 === 0 ? l = Math.floor((n[i - 1] + n[i]) / 2) : l = n[i];
892
+ n.sort((c, u) => c - u);
893
+ const o = Math.floor(n.length / 2);
894
+ let i;
895
+ n.length % 2 === 0 ? i = Math.floor((n[o - 1] + n[o]) / 2) : i = n[o];
822
896
  const a = /* @__PURE__ */ new Map();
823
- let h = 0;
824
- for (const u of n) {
825
- const d = (a.get(u) ?? 0) + 1;
826
- a.set(u, d), d > h && (h = d);
897
+ let f = 0;
898
+ for (const c of n) {
899
+ const u = (a.get(c) ?? 0) + 1;
900
+ a.set(c, u), u > f && (f = u);
827
901
  }
828
- if (h > 1) {
829
- const u = [];
830
- for (const [p, R] of a.entries())
831
- R === h && u.push(p);
832
- const d = u.reduce((p, R) => p + R, 0);
833
- l = Math.floor(d / u.length);
902
+ if (f > 1) {
903
+ const c = [];
904
+ for (const [p, E] of a.entries())
905
+ E === f && c.push(p);
906
+ const u = c.reduce((p, E) => p + E, 0);
907
+ i = Math.floor(u / c.length);
834
908
  }
835
- return { mode: l, materializedValues: r };
909
+ return { mode: i, materializedValues: r };
836
910
  }
837
911
  /**
838
912
  * @method update
@@ -910,8 +984,8 @@ class xt {
910
984
  throw new Error(`Index ${n} out of bounds`);
911
985
  if (r < 0)
912
986
  throw new Error("Value cannot be negative.");
913
- const i = this.deltas.has(n) ? (this.deltas.get(n) ?? 0) + this.baseValue : this.baseValue, l = r - i;
914
- l !== 0 && t.push({ index: n, change: l });
987
+ const o = this.deltas.has(n) ? (this.deltas.get(n) ?? 0) + this.baseValue : this.baseValue, i = r - o;
988
+ i !== 0 && t.push({ index: n, change: i });
915
989
  }
916
990
  return t;
917
991
  }
@@ -925,10 +999,10 @@ class xt {
925
999
  */
926
1000
  _materialize(e, t = !0) {
927
1001
  if (this.valueFn) {
928
- const n = this.deltas.get(e) ?? 0, i = this.valueFn(e) - this.baseValue;
929
- if (i !== n && (this.deltas.set(e, i), t)) {
930
- const l = i - n;
931
- this._updateTree(e, l);
1002
+ const n = this.deltas.get(e) ?? 0, o = this.valueFn(e) - this.baseValue;
1003
+ if (o !== n && (this.deltas.set(e, o), t)) {
1004
+ const i = o - n;
1005
+ this._updateTree(e, i);
932
1006
  }
933
1007
  }
934
1008
  }
@@ -947,9 +1021,9 @@ class xt {
947
1021
  const r = e.ranges;
948
1022
  if (r && r.length > 0) {
949
1023
  for (const a of r) {
950
- const h = a.from, u = Math.min(a.to, this.size - 1);
951
- for (let d = h; d <= u; d++)
952
- this._materialize(d);
1024
+ const f = a.from, c = Math.min(a.to, this.size - 1);
1025
+ for (let u = f; u <= c; u++)
1026
+ this._materialize(u);
953
1027
  }
954
1028
  if (t === void 0)
955
1029
  return;
@@ -957,8 +1031,8 @@ class xt {
957
1031
  this._materialize(t);
958
1032
  return;
959
1033
  }
960
- const i = r[0].from, l = r[r.length - 1].to;
961
- t >= i && t <= l && this._materialize(t);
1034
+ const o = r[0].from, i = r[r.length - 1].to;
1035
+ t >= o && t <= i && this._materialize(t);
962
1036
  return;
963
1037
  }
964
1038
  t !== void 0 && this._materialize(t);
@@ -976,12 +1050,12 @@ class xt {
976
1050
  _findIndex(e, t = {}, n) {
977
1051
  if (this.size === 0)
978
1052
  return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
979
- let r = 0, i = this.size - 1, l = -1, a, h = this.total;
980
- for (; r <= i; ) {
981
- const u = Math.floor((r + i) / 2);
982
- a = this.prefixSum(u, t), h = a.total, (n ? a.cumulative >= e : a.cumulative <= e) ? (l = u, n ? i = u - 1 : r = u + 1) : n ? r = u + 1 : i = u - 1;
1053
+ let r = 0, o = this.size - 1, i = -1, a, f = this.total;
1054
+ for (; r <= o; ) {
1055
+ const c = Math.floor((r + o) / 2);
1056
+ a = this.prefixSum(c, t), f = a.total, (n ? a.cumulative >= e : a.cumulative <= e) ? (i = c, n ? o = c - 1 : r = c + 1) : n ? r = c + 1 : o = c - 1;
983
1057
  }
984
- return { index: l, total: h, cumulative: a?.cumulative, currentValue: a?.currentValue, safeIndex: a?.safeIndex };
1058
+ return { index: i, total: f, cumulative: a?.cumulative, currentValue: a?.currentValue, safeIndex: a?.safeIndex };
985
1059
  }
986
1060
  /**
987
1061
  * @method prefixSum
@@ -994,15 +1068,15 @@ class xt {
994
1068
  prefixSum(e, t) {
995
1069
  if (e < 0)
996
1070
  return { cumulative: 0, total: this.total, currentValue: 0, safeIndex: 0 };
997
- const n = G(e, 0, this.size - 1), r = t?.materializeOption;
1071
+ const n = W(e, 0, this.size - 1), r = t?.materializeOption;
998
1072
  this._materializeRanges(r, n, !0);
999
- let i = 0, l = n + 1;
1000
- for (; l > 0; ) {
1001
- const h = this.tree.get(l) ?? 0;
1002
- i += h, l -= l & -l;
1073
+ let o = 0, i = n + 1;
1074
+ for (; i > 0; ) {
1075
+ const f = this.tree.get(i) ?? 0;
1076
+ o += f, i -= i & -i;
1003
1077
  }
1004
1078
  const a = r?.materialize ? this.get(n) : (this.deltas.get(n) || 0) + this.baseValue;
1005
- return { cumulative: i + this.baseValue * (n + 1), total: this.total, currentValue: a, safeIndex: n };
1079
+ return { cumulative: o + this.baseValue * (n + 1), total: this.total, currentValue: a, safeIndex: n };
1006
1080
  }
1007
1081
  /**
1008
1082
  * @method get
@@ -1032,8 +1106,8 @@ class xt {
1032
1106
  this.total = 0;
1033
1107
  else {
1034
1108
  let n = this.baseValue * this.size;
1035
- for (const i of this.deltas.values())
1036
- n += i;
1109
+ for (const o of this.deltas.values())
1110
+ n += o;
1037
1111
  this.total = n;
1038
1112
  const r = this.prefixSum(this.getSize() - 1);
1039
1113
  console.assert(r.cumulative === r.total, "Inconsistent Fenwick Tree state");
@@ -1050,17 +1124,17 @@ class xt {
1050
1124
  rebuildTree(e) {
1051
1125
  if (e?.materialize && this.valueFn) {
1052
1126
  const r = this.valueFn;
1053
- this.reset(this.size, (i) => r(i), { materialize: !0 });
1127
+ this.reset(this.size, (o) => r(o), { materialize: !0 });
1054
1128
  return;
1055
1129
  }
1056
1130
  const t = /* @__PURE__ */ new Map();
1057
1131
  let n = this.baseValue * this.size;
1058
- for (const [r, i] of this.deltas.entries()) {
1059
- if (n += i, i === 0)
1132
+ for (const [r, o] of this.deltas.entries()) {
1133
+ if (n += o, o === 0)
1060
1134
  continue;
1061
- let l = r + 1;
1062
- for (; l <= this.size; )
1063
- t.set(l, (t.get(l) ?? 0) + i), l += l & -l;
1135
+ let i = r + 1;
1136
+ for (; i <= this.size; )
1137
+ t.set(i, (t.get(i) ?? 0) + o), i += i & -i;
1064
1138
  }
1065
1139
  this.tree = t, this.total = n;
1066
1140
  }
@@ -1133,11 +1207,11 @@ class xt {
1133
1207
  return this._findIndex(e, t ?? {}, !1);
1134
1208
  }
1135
1209
  }
1136
- const vt = (o, e, t) => {
1137
- const n = Math.max(0, o), r = k(null), i = xe(() => new xt(n, e, t), [n, e, t]);
1138
- return Object.is(r.current, i) || console.warn("[useFenwickMapTree] instance changed"), r.current = i, i;
1210
+ const Ot = (s, e, t) => {
1211
+ const n = Math.max(0, s), r = F(null), o = Te(() => new Nt(n, e, t), [n, e, t]);
1212
+ return Object.is(r.current, o) || console.warn("[useFenwickMapTree] instance changed"), r.current = o, o;
1139
1213
  };
1140
- class bt {
1214
+ class zt {
1141
1215
  key;
1142
1216
  value;
1143
1217
  prev = null;
@@ -1146,7 +1220,7 @@ class bt {
1146
1220
  this.key = e, this.value = t;
1147
1221
  }
1148
1222
  }
1149
- class Ze {
1223
+ class nt {
1150
1224
  head = null;
1151
1225
  tail = null;
1152
1226
  /**
@@ -1187,193 +1261,195 @@ class Ze {
1187
1261
  this.remove(e), this.addToTail(e);
1188
1262
  }
1189
1263
  }
1190
- function Tt(o) {
1191
- const e = k(/* @__PURE__ */ new Map()), t = k(new Ze());
1264
+ function kt(s) {
1265
+ const e = F(/* @__PURE__ */ new Map()), t = F(new nt());
1192
1266
  se(() => {
1193
- for (; e.current.size > o; ) {
1194
- const u = t.current.removeHead();
1195
- if (u)
1196
- e.current.delete(u.key);
1267
+ for (; e.current.size > s; ) {
1268
+ const c = t.current.removeHead();
1269
+ if (c)
1270
+ e.current.delete(c.key);
1197
1271
  else
1198
1272
  break;
1199
1273
  }
1200
- }, [o]);
1201
- const n = A((u) => {
1202
- const d = e.current.get(u);
1203
- if (d)
1204
- return t.current.moveToTail(d), d.value;
1205
- }, []), r = A(
1206
- (u, d) => {
1207
- if (o <= 0)
1274
+ }, [s]);
1275
+ const n = y((c) => {
1276
+ const u = e.current.get(c);
1277
+ if (u)
1278
+ return t.current.moveToTail(u), u.value;
1279
+ }, []), r = y(
1280
+ (c, u) => {
1281
+ if (s <= 0)
1208
1282
  return;
1209
- let p = e.current.get(u);
1283
+ let p = e.current.get(c);
1210
1284
  if (p)
1211
- p.value = d, t.current.moveToTail(p);
1285
+ p.value = u, t.current.moveToTail(p);
1212
1286
  else {
1213
- if (e.current.size >= o) {
1214
- const R = t.current.removeHead();
1215
- R && e.current.delete(R.key);
1287
+ if (e.current.size >= s) {
1288
+ const E = t.current.removeHead();
1289
+ E && e.current.delete(E.key);
1216
1290
  }
1217
- p = new bt(u, d), e.current.set(u, p), t.current.addToTail(p);
1291
+ p = new zt(c, u), e.current.set(c, p), t.current.addToTail(p);
1218
1292
  }
1219
1293
  },
1220
- [o]
1221
- ), i = A((u) => e.current.has(u), []), l = A(() => {
1222
- e.current.clear(), t.current = new Ze();
1223
- }, []), [a, h] = de(() => ({ get: n, set: r, has: i, clear: l }));
1224
- return se(() => h({ get: n, set: r, has: i, clear: l }), [n, r, i, l]), a;
1294
+ [s]
1295
+ ), o = y((c) => e.current.has(c), []), i = y(() => {
1296
+ e.current.clear(), t.current = new nt();
1297
+ }, []), [a, f] = pe(() => ({ get: n, set: r, has: o, clear: i }));
1298
+ return se(() => f({ get: n, set: r, has: o, clear: i }), [n, r, o, i]), a;
1225
1299
  }
1226
- const yt = 1e4, Et = () => {
1227
- const { get: o, set: e, has: t, clear: n } = Tt(yt);
1228
- return { get: o, set: e, has: t, clear: n };
1229
- }, me = (o, e) => e <= 0 ? 0 : G(o, 0, e - 1), wt = (o, e, t, n, r, i) => {
1300
+ const Yt = 1e4, jt = () => {
1301
+ const { get: s, set: e, has: t, clear: n } = kt(Yt);
1302
+ return { get: s, set: e, has: t, clear: n };
1303
+ }, be = (s, e) => e <= 0 ? 0 : W(s, 0, e - 1), Ht = (s, e, t, n, r, o) => {
1230
1304
  if (n === 0)
1231
1305
  return { renderingStartIndex: 0, renderingEndIndex: 0, visibleStartIndex: 0, visibleEndIndex: 0 };
1232
- const { index: l, cumulative: a, currentValue: h } = i.findIndexAtOrAfter(o, { materializeOption: { materialize: !1 } }), u = l === -1 ? 0 : l, d = l !== -1 && (a ?? 0) < o + (h ?? 0) ? u + 1 : u, p = me(d, n), R = me(p - t, n);
1233
- let V = 0, X = p;
1234
- for (; X < n && V < e; )
1235
- V += r(X), X++;
1236
- const ee = me(X - 1, n), b = me(ee + t, n);
1237
- return { renderingStartIndex: R, renderingEndIndex: b, visibleStartIndex: p, visibleEndIndex: ee };
1306
+ const { index: i, cumulative: a, currentValue: f } = o.findIndexAtOrAfter(s, { materializeOption: { materialize: !1 } }), c = i === -1 ? 0 : i, u = i !== -1 && (a ?? 0) < s + (f ?? 0) ? c + 1 : c, p = be(u, n), E = be(p - t, n);
1307
+ let A = 0, O = p;
1308
+ for (; O < n && A < e; )
1309
+ A += r(O), O++;
1310
+ const te = be(O - 1, n), X = be(te + t, n);
1311
+ return { renderingStartIndex: E, renderingEndIndex: X, visibleStartIndex: p, visibleEndIndex: te };
1238
1312
  };
1239
- function St({ itemCount: o, getItem: e, getItemHeight: t, viewportSize: n, overscanCount: r = 5, className: i, onScroll: l, onRangeChange: a, children: h, background: u, initialScrollIndex: d, initialScrollOffset: p, tapScrollCircleOptions: R, scrollBarWidth: V, enableThumbDrag: X, enableTrackClick: ee, enableArrowButtons: b, enablePointerDrag: ae, inertiaOptions: le }, Z) {
1240
- const _ = k(null), U = k(!1);
1241
- se(() => (U.current = !0, () => {
1242
- U.current = !1;
1313
+ function $t({ itemCount: s, getItem: e, getItemHeight: t, viewportSize: n, overscanCount: r = 5, className: o, onScroll: i, onRangeChange: a, children: f, background: c, initialScrollIndex: u, initialScrollOffset: p, tapScrollCircleOptions: E, scrollBarWidth: A, enableThumbDrag: O, enableTrackClick: te, enableArrowButtons: X, enablePointerDrag: ne, inertiaOptions: S, renderThumbOverlay: ce, wheelSpeedMultiplier: le }, G) {
1314
+ const C = F(null), K = F(!1);
1315
+ se(() => (K.current = !0, () => {
1316
+ K.current = !1;
1243
1317
  }), []);
1244
- const O = k({ size: o, valueOrFn: t, options: { sampleRange: { from: 0, to: 100 } } }), x = vt(O.current.size, O.current.valueOrFn, O.current.options), [P] = de(() => {
1245
- let T = 0, S = 0;
1246
- if (typeof d == "number") {
1247
- const E = G(d, 0, o - 1), q = G(E - r * 2, 0, o - 1), oe = G(E + r * 2, 0, o - 1), j = d > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: q, to: oe }] } } : void 0, { cumulative: W, total: ne, currentValue: B } = x.prefixSum(d, j);
1248
- T = W - B, S = ne ?? x.getTotal();
1249
- } else typeof p == "number" && (T = p), S = x.getTotal();
1250
- return { position: T, total: S };
1251
- }), [w, H] = de(P.position), [m, D] = de(P.total), [f, F] = de(P.position), [g, N] = de(o);
1252
- Ee(() => {
1253
- x.setValueFn(t), g !== o && (x.changeSize(o), N(o));
1254
- const T = x.getTotal();
1255
- m !== T && D(T);
1256
- }, [x, g, o, m, t]), Ee(() => {
1257
- f !== null && _.current && (re.debug("[VirtualScroll] Scrolling to position:", f), _.current.scrollTo(f), F(null));
1258
- }, [f]);
1259
- const L = A(
1260
- (T) => {
1261
- if (!_.current)
1318
+ const I = F({ size: s, valueOrFn: t, options: { sampleRange: { from: 0, to: 100 } } }), x = Ot(I.current.size, I.current.valueOrFn, I.current.options), [$] = pe(() => {
1319
+ let b = 0, T = 0;
1320
+ if (typeof u == "number") {
1321
+ const V = W(u, 0, s - 1), J = W(V - r * 2, 0, s - 1), oe = W(V + r * 2, 0, s - 1), q = u > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: J, to: oe }] } } : void 0, { cumulative: Q, total: ie, currentValue: j } = x.prefixSum(u, q);
1322
+ b = Q - j, T = ie ?? x.getTotal();
1323
+ } else typeof p == "number" && (b = p), T = x.getTotal();
1324
+ return { position: b, total: T };
1325
+ }), [d, M] = pe($.position), [z, Z] = pe($.total), [h, _] = pe($.position), [g, P] = pe(s);
1326
+ Ae(() => {
1327
+ x.setValueFn(t), g !== s && (x.changeSize(s), P(s));
1328
+ const b = x.getTotal();
1329
+ z !== b && Z(b);
1330
+ }, [x, g, s, z, t]), Ae(() => {
1331
+ h !== null && C.current && (ae.debug("[VirtualScroll] Scrolling to position:", h), C.current.scrollTo(h), _(null));
1332
+ }, [h]);
1333
+ const R = y(
1334
+ (b) => {
1335
+ if (!C.current)
1262
1336
  return;
1263
- const S = me(T, g), E = me(S - r * 2, g), q = me(S + r * 2, g), { cumulative: oe, total: j, currentValue: W } = x.prefixSum(S, { materializeOption: { materialize: !0, ranges: [{ from: E, to: q }] } });
1264
- re.debug("[VirtualScroll] Scrolling to index:", S, "Offset:", oe, "Total height:", j, "Current value:", W, "safeIndexFrom:", E, "safeIndexTo:", q), j && (D(j), F(oe - W), re.debug("[VirtualScroll] Setting scroll position to:", oe - W));
1337
+ const T = be(b, g), V = be(T - r * 2, g), J = be(T + r * 2, g), { cumulative: oe, total: q, currentValue: Q } = x.prefixSum(T, { materializeOption: { materialize: !0, ranges: [{ from: V, to: J }] } });
1338
+ ae.debug("[VirtualScroll] Scrolling to index:", T, "Offset:", oe, "Total height:", q, "Current value:", Q, "safeIndexFrom:", V, "safeIndexTo:", J), q && (Z(q), _(oe - Q), ae.debug("[VirtualScroll] Setting scroll position to:", oe - Q));
1265
1339
  },
1266
1340
  [x, r, g]
1267
- ), C = A(
1268
- (T) => {
1269
- if (!_.current)
1341
+ ), k = y(
1342
+ (b) => {
1343
+ if (!C.current)
1270
1344
  return;
1271
- const S = x.getTotal(), E = G(Math.floor(T), 0, S), q = x.findIndexAtOrAfter(E, { materializeOption: { materialize: !1 } }).index;
1272
- L(q);
1345
+ const T = x.getTotal(), V = W(Math.floor(b), 0, T), J = x.findIndexAtOrAfter(V, { materializeOption: { materialize: !1 } }).index;
1346
+ R(J);
1273
1347
  },
1274
- [x, L]
1275
- ), M = A(
1276
- (T, S) => {
1277
- re.debug("[VirtualScroll] Scroll position changed:", T), H(T);
1278
- const E = x.getTotal();
1279
- l?.(T, E);
1348
+ [x, R]
1349
+ ), L = y(
1350
+ (b, T) => {
1351
+ ae.debug("[VirtualScroll] Scroll position changed:", b), M(b);
1352
+ const V = x.getTotal();
1353
+ i?.(b, V);
1280
1354
  },
1281
- [x, l]
1282
- ), y = xe(() => {
1283
- const T = wt(w, n, r, g, t, x);
1284
- return re.debug("[VirtualScroll] Calculated rendering range:", {
1285
- ...T,
1286
- scrollPosition: w,
1355
+ [x, i]
1356
+ ), v = Te(() => {
1357
+ const b = Ht(d, n, r, g, t, x);
1358
+ return ae.debug("[VirtualScroll] Calculated rendering range:", {
1359
+ ...b,
1360
+ scrollPosition: d,
1287
1361
  renderingContentSize: x.getTotal(),
1288
1362
  overscanCount: r,
1289
1363
  viewportSize: n
1290
- }), T;
1291
- }, [w, n, r, g, t, x]);
1364
+ }), b;
1365
+ }, [d, n, r, g, t, x]);
1292
1366
  se(() => {
1293
- const T = _.current?.getScrollPosition() ?? 0;
1294
- re.debug("[VirtualScroll] Range change effect triggered", {
1295
- renderingStartIndex: y.renderingStartIndex,
1296
- renderingEndIndex: y.renderingEndIndex,
1297
- visibleStartIndex: y.visibleStartIndex,
1298
- visibleEndIndex: y.visibleEndIndex,
1299
- scrollPosition: w,
1300
- contentSize: m,
1301
- scrollPaneScrollPosition: T
1302
- }), a?.(y.renderingStartIndex, y.renderingEndIndex, y.visibleStartIndex, y.visibleEndIndex, w, m);
1303
- }, [y.renderingStartIndex, y.renderingEndIndex, y.visibleStartIndex, y.visibleEndIndex, a, w, m]);
1304
- const I = A(
1305
- (T) => {
1306
- const { renderingStartIndex: S, renderingEndIndex: E } = y;
1307
- if (re.debug("[VirtualScroll] Rendering visible items", { currentScrollPosition: T, renderingStartIndex: S, renderingEndIndex: E, fenwickSize: g, viewportSize: n }), g === 0)
1308
- return /* @__PURE__ */ $("div", { className: "absolute w-full", style: { top: 0 }, children: /* @__PURE__ */ $("div", { className: "text-center text-gray-500", children: "No items" }) });
1309
- const q = me(S, g), { cumulative: oe, currentValue: j } = x.prefixSum(q, { materializeOption: { materialize: !1 } }), W = oe - j, ne = [], B = [];
1310
- for (let Y = S; Y <= E; Y++) {
1311
- const c = t(Y);
1312
- ne.push({ item: e(Y), height: c, index: Y }), x.get(Y) !== c && B.push({ index: Y, value: c });
1367
+ const b = C.current?.getScrollPosition() ?? 0;
1368
+ ae.debug("[VirtualScroll] Range change effect triggered", {
1369
+ renderingStartIndex: v.renderingStartIndex,
1370
+ renderingEndIndex: v.renderingEndIndex,
1371
+ visibleStartIndex: v.visibleStartIndex,
1372
+ visibleEndIndex: v.visibleEndIndex,
1373
+ scrollPosition: d,
1374
+ contentSize: z,
1375
+ scrollPaneScrollPosition: b
1376
+ }), a?.(v.renderingStartIndex, v.renderingEndIndex, v.visibleStartIndex, v.visibleEndIndex, d, z);
1377
+ }, [v.renderingStartIndex, v.renderingEndIndex, v.visibleStartIndex, v.visibleEndIndex, a, d, z]);
1378
+ const w = y(
1379
+ (b) => {
1380
+ const { renderingStartIndex: T, renderingEndIndex: V } = v;
1381
+ if (ae.debug("[VirtualScroll] Rendering visible items", { currentScrollPosition: b, renderingStartIndex: T, renderingEndIndex: V, fenwickSize: g, viewportSize: n }), g === 0)
1382
+ return /* @__PURE__ */ H("div", { className: "absolute w-full", style: { top: 0 }, children: /* @__PURE__ */ H("div", { className: "text-center text-gray-500", children: "No items" }) });
1383
+ const J = be(T, g), { cumulative: oe, currentValue: q } = x.prefixSum(J, { materializeOption: { materialize: !1 } }), Q = oe - q, ie = [], j = [];
1384
+ for (let D = T; D <= V; D++) {
1385
+ const l = t(D);
1386
+ ie.push({ item: e(D), height: l, index: D }), x.get(D) !== l && j.push({ index: D, value: l });
1313
1387
  }
1314
- B.length > 0 && Promise.resolve().then(() => {
1315
- const Y = x.updates(B);
1316
- Y && (D(Y), re.debug("[VirtualScroll] Updated heights for items", B, "New total height:", Y));
1388
+ j.length > 0 && Promise.resolve().then(() => {
1389
+ const D = x.updates(j);
1390
+ D && (Z(D), ae.debug("[VirtualScroll] Updated heights for items", j, "New total height:", D));
1317
1391
  });
1318
- const fe = m < n ? 0 : W - T;
1319
- return re.debug("[VirtualScroll] Rendering items", { visibleItems: ne, containerTop: fe }), /* @__PURE__ */ $("div", { className: "absolute w-full", style: { top: fe }, children: ne.map(({ item: Y, index: c }) => {
1320
- const J = me(c, g), { cumulative: Q, currentValue: z } = x.prefixSum(J, { materializeOption: { materialize: !1 } }), ie = Q - z;
1321
- return /* @__PURE__ */ $(
1392
+ const ge = z < n ? 0 : Q - b;
1393
+ return ae.debug("[VirtualScroll] Rendering items", { visibleItems: ie, containerTop: ge }), /* @__PURE__ */ H("div", { className: "absolute w-full", style: { top: ge }, children: ie.map(({ item: D, index: l }) => {
1394
+ const B = be(l, g), { cumulative: U, currentValue: N } = x.prefixSum(B, { materializeOption: { materialize: !1 } }), ue = U - N;
1395
+ return /* @__PURE__ */ H(
1322
1396
  "div",
1323
1397
  {
1324
- "data-index": c,
1398
+ "data-index": l,
1325
1399
  style: {
1326
1400
  position: "absolute",
1327
- top: ie - W,
1401
+ top: ue - Q,
1328
1402
  width: "100%"
1329
1403
  },
1330
- children: h(Y, c)
1404
+ children: f(D, l)
1331
1405
  },
1332
- c
1406
+ l
1333
1407
  );
1334
1408
  }) });
1335
1409
  },
1336
- [e, h, m, n, y, x, g, t]
1410
+ [e, f, z, n, v, x, g, t]
1337
1411
  );
1338
- return Oe(Z, () => ({
1339
- getScrollPosition: () => _.current?.getScrollPosition() ?? -1,
1340
- getContentSize: () => _.current?.getContentSize() ?? -1,
1341
- getViewportSize: () => _.current?.getViewportSize() ?? -1,
1342
- scrollTo: C,
1343
- scrollToIndex: L,
1412
+ return Ye(G, () => ({
1413
+ getScrollPosition: () => C.current?.getScrollPosition() ?? -1,
1414
+ getContentSize: () => C.current?.getContentSize() ?? -1,
1415
+ getViewportSize: () => C.current?.getViewportSize() ?? -1,
1416
+ scrollTo: k,
1417
+ scrollToIndex: R,
1344
1418
  getFenwickTreeTotalHeight: () => x.getTotal(),
1345
1419
  getFenwickSize: () => x.getSize()
1346
- }), [C, L, x]), /* @__PURE__ */ $(
1347
- gt,
1420
+ }), [k, R, x]), /* @__PURE__ */ H(
1421
+ Dt,
1348
1422
  {
1349
- ref: _,
1350
- contentSize: m,
1423
+ ref: C,
1424
+ contentSize: z,
1351
1425
  viewportSize: n,
1352
- className: i,
1353
- onScroll: M,
1354
- background: u,
1355
- tapScrollCircleOptions: R,
1356
- inertiaOptions: le,
1357
- itemCount: o,
1358
- scrollBarWidth: V,
1359
- enableThumbDrag: X,
1360
- enableTrackClick: ee,
1361
- enableArrowButtons: b,
1362
- enablePointerDrag: ae,
1363
- children: I
1426
+ className: o,
1427
+ onScroll: L,
1428
+ background: c,
1429
+ tapScrollCircleOptions: E,
1430
+ inertiaOptions: S,
1431
+ itemCount: s,
1432
+ scrollBarWidth: A,
1433
+ enableThumbDrag: O,
1434
+ enableTrackClick: te,
1435
+ enableArrowButtons: X,
1436
+ enablePointerDrag: ne,
1437
+ renderThumbOverlay: ce,
1438
+ wheelSpeedMultiplier: le,
1439
+ children: w
1364
1440
  }
1365
1441
  );
1366
1442
  }
1367
- const At = ke(St);
1443
+ const Wt = ke($t);
1368
1444
  export {
1369
- xt as FenwickMapTree,
1370
- pt as ScrollBar,
1371
- gt as ScrollPane,
1372
- At as VirtualScroll,
1373
- G as minmax,
1374
- Mt as tapScrollCircleSampleVisual,
1375
- vt as useFenwickMapTree,
1376
- Et as useHeightCache,
1377
- Tt as useLruCache
1445
+ Nt as FenwickMapTree,
1446
+ Lt as ScrollBar,
1447
+ Dt as ScrollPane,
1448
+ Wt as VirtualScroll,
1449
+ W as minmax,
1450
+ qt as tapScrollCircleSampleVisual,
1451
+ Ot as useFenwickMapTree,
1452
+ jt as useHeightCache,
1453
+ kt as useLruCache
1378
1454
  };
1379
1455
  //# sourceMappingURL=index.js.map