@aiquants/virtualscroll 1.7.0 → 1.9.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,17 @@
1
- import { jsx as J, jsxs as Gt, Fragment as we } from "react/jsx-runtime";
2
- import { forwardRef as me, useState as Ot, useRef as y, useCallback as w, useImperativeHandle as he, useMemo as Vt, useEffect as Y, useLayoutEffect as se, useId as Le } from "react";
3
- import { twMerge as jt } from "tailwind-merge";
4
- const xe = {
1
+ import { jsx as Q, jsxs as Jt, Fragment as we } from "react/jsx-runtime";
2
+ import { memo as ze, forwardRef as ge, useState as Xt, useRef as w, useCallback as y, useImperativeHandle as xe, useMemo as Dt, useEffect as O, useLayoutEffect as ne, useId as Xe } from "react";
3
+ import { twMerge as Zt } from "tailwind-merge";
4
+ const Te = {
5
5
  active: !1,
6
6
  offsetX: 0,
7
7
  offsetY: 0,
8
8
  distance: 0,
9
- direction: 0
10
- }, de = 6, Ye = 8, ze = ({ dragState: r, normalizedDistance: t }) => {
9
+ direction: 0,
10
+ pointerId: null
11
+ }, pe = 6, He = 8, Ue = ({ dragState: r, normalizedDistance: t }) => {
11
12
  const e = 1 + t * 0.18, n = 0.16 + t * 0.24, o = 0.38 + t * 0.28, a = r.active ? "80ms ease-out" : "220ms ease";
12
- return /* @__PURE__ */ Gt(we, { children: [
13
- /* @__PURE__ */ J(
13
+ return /* @__PURE__ */ Jt(we, { children: [
14
+ /* @__PURE__ */ Q(
14
15
  "div",
15
16
  {
16
17
  className: "absolute inset-0 rounded-full",
@@ -22,7 +23,7 @@ const xe = {
22
23
  }
23
24
  }
24
25
  ),
25
- /* @__PURE__ */ J(
26
+ /* @__PURE__ */ Q(
26
27
  "div",
27
28
  {
28
29
  className: "aqvs:tap-scroll-circle-inner absolute rounded-full",
@@ -35,106 +36,109 @@ const xe = {
35
36
  }
36
37
  )
37
38
  ] });
38
- }, ye = me(({ onDragChange: r, className: t, maxVisualDistance: e = 160, size: n = 40, style: o, opacity: a = 1, renderVisual: d }, m) => {
39
- const [l, u] = Ot(xe), p = y(null), g = y({ x: 0, y: 0 }), v = y(null), b = y(0), _ = w(
40
- (c) => {
41
- u(c), r(c);
42
- },
43
- [r]
44
- ), D = w(
45
- (c, ct, P = !1) => {
46
- const { x: ut, y: it } = g.current, Tt = c - ut, H = ct - it, dt = Math.abs(H), ft = dt < de ? 0 : H < 0 ? -1 : 1, et = b.current;
47
- let f = ft;
48
- const E = de + Ye;
49
- ft === 0 ? et !== 0 && dt < E ? f = et : (f = 0, P || (b.current = 0)) : ft !== et && et !== 0 && dt < E ? f = et : b.current = ft, _({
50
- active: P || dt >= de,
51
- offsetX: Tt,
52
- offsetY: H,
53
- distance: dt,
54
- direction: f
55
- });
56
- },
57
- [_]
58
- ), Q = w((c) => {
59
- if (c === null)
60
- return;
61
- const ct = v.current;
62
- ct?.hasPointerCapture(c) && ct.releasePointerCapture(c);
63
- }, []), z = w(
64
- (c = !1) => {
65
- c && Q(p.current), p.current = null, b.current = 0, _(xe);
66
- },
67
- [_, Q]
68
- ), lt = w(
69
- (c) => {
70
- c.preventDefault(), c.stopPropagation();
71
- const ct = v.current ?? c.currentTarget, { left: P, top: ut, width: it, height: Tt } = ct.getBoundingClientRect();
72
- g.current = { x: P + it / 2, y: ut + Tt / 2 }, p.current = c.pointerId, ct.setPointerCapture(c.pointerId), D(c.clientX, c.clientY, !0);
73
- },
74
- [D]
75
- ), C = w(
76
- (c) => {
77
- p.current === c.pointerId && (c.preventDefault(), D(c.clientX, c.clientY));
78
- },
79
- [D]
80
- ), V = w(
81
- (c) => {
82
- p.current === c.pointerId && (c.preventDefault(), c.stopPropagation(), z(!0));
83
- },
84
- [z]
85
- );
86
- he(
87
- m,
88
- () => ({
89
- reset: () => {
90
- z(!0);
39
+ }, Ce = ze(
40
+ ge(({ onDragChange: r, className: t, maxVisualDistance: e = 160, size: n = 40, style: o, opacity: a = 1, renderVisual: u }, p) => {
41
+ const [l, d] = Xt(Te), c = w(null), f = w({ x: 0, y: 0 }), S = w(null), b = w(0), _ = y(
42
+ (I) => {
43
+ d(I), r(I);
91
44
  },
92
- getElement: () => v.current
93
- }),
94
- [z]
95
- );
96
- const U = Math.min(Math.max(a, 0), 1), F = n / 64, M = Math.min(l.distance, e) / e, X = l.direction * M * 10 * F, St = d ?? ze, R = {
97
- dragState: l,
98
- normalizedDistance: M,
99
- sizeScale: F,
100
- size: n,
101
- opacity: U
102
- }, L = {
103
- ...o,
104
- width: n,
105
- height: n,
106
- transform: `translateY(${X}px)`
107
- };
108
- return L.opacity = U, /* @__PURE__ */ J(
109
- "div",
110
- {
111
- ref: v,
112
- "data-testid": "virtual-scroll-tap-circle",
113
- className: jt("relative flex touch-none select-none items-center justify-center", "transition-transform duration-100 ease-out", t),
114
- style: L,
115
- tabIndex: -1,
116
- onPointerDown: lt,
117
- onPointerMove: C,
118
- onPointerUp: V,
119
- onPointerCancel: V,
120
- role: "presentation",
121
- children: St(R)
122
- }
123
- );
124
- });
125
- ye.displayName = "TapScrollCircle";
126
- const gt = (r, t, e) => Math.min(e, Math.max(t, r)), pe = "virtualscroll:tap-scroll-cancel", Ie = 20, Xe = 250, He = 60, Ue = 20, qe = 20, Be = 240, Te = { active: !1, offsetX: 0, offsetY: 0, distance: 0, direction: 0 }, fe = 2.2, $e = 8, We = 120, Ke = 1 / 60, kt = {
45
+ [r]
46
+ ), X = y(
47
+ (I, m, tt = !1) => {
48
+ const { x: A, y: et } = f.current, it = I - A, At = m - et, W = Math.abs(At), U = W < pe ? 0 : At < 0 ? -1 : 1, dt = b.current;
49
+ let ft = U;
50
+ const E = pe + He;
51
+ U === 0 ? dt !== 0 && W < E ? ft = dt : (ft = 0, tt || (b.current = 0)) : U !== dt && dt !== 0 && W < E ? ft = dt : b.current = U, _({
52
+ active: tt || W >= pe,
53
+ offsetX: it,
54
+ offsetY: At,
55
+ distance: W,
56
+ direction: ft,
57
+ pointerId: c.current
58
+ });
59
+ },
60
+ [_]
61
+ ), k = y((I) => {
62
+ if (I === null)
63
+ return;
64
+ const m = S.current;
65
+ m?.hasPointerCapture(I) && m.releasePointerCapture(I);
66
+ }, []), B = y(
67
+ (I = !1) => {
68
+ I && k(c.current), c.current = null, b.current = 0, _(Te);
69
+ },
70
+ [_, k]
71
+ ), ht = y(
72
+ (I) => {
73
+ I.preventDefault(), I.stopPropagation();
74
+ const m = S.current ?? I.currentTarget, { left: tt, top: A, width: et, height: it } = m.getBoundingClientRect();
75
+ f.current = { x: tt + et / 2, y: A + it / 2 }, c.current = I.pointerId, m.setPointerCapture(I.pointerId), X(I.clientX, I.clientY, !0);
76
+ },
77
+ [X]
78
+ ), H = y(
79
+ (I) => {
80
+ c.current === I.pointerId && (I.preventDefault(), X(I.clientX, I.clientY));
81
+ },
82
+ [X]
83
+ ), F = y(
84
+ (I) => {
85
+ c.current === I.pointerId && (I.preventDefault(), I.stopPropagation(), B(!0));
86
+ },
87
+ [B]
88
+ );
89
+ xe(
90
+ p,
91
+ () => ({
92
+ reset: () => {
93
+ B(!0);
94
+ },
95
+ getElement: () => S.current
96
+ }),
97
+ [B]
98
+ );
99
+ const C = Math.min(Math.max(a, 0), 1), L = n / 64, R = Math.min(l.distance, e) / e, N = l.direction * R * 10 * L, st = u ?? Ue, ut = {
100
+ dragState: l,
101
+ normalizedDistance: R,
102
+ sizeScale: L,
103
+ size: n,
104
+ opacity: C
105
+ }, $ = {
106
+ ...o,
107
+ width: n,
108
+ height: n,
109
+ transform: `translateY(${N}px)`
110
+ };
111
+ return $.opacity = C, /* @__PURE__ */ Q(
112
+ "div",
113
+ {
114
+ ref: S,
115
+ "data-testid": "virtual-scroll-tap-circle",
116
+ className: Zt("relative flex touch-none select-none items-center justify-center", "transition-transform duration-100 ease-out", t),
117
+ style: $,
118
+ tabIndex: -1,
119
+ onPointerDown: ht,
120
+ onPointerMove: H,
121
+ onPointerUp: F,
122
+ onPointerCancel: F,
123
+ role: "presentation",
124
+ children: st(ut)
125
+ }
126
+ );
127
+ })
128
+ );
129
+ Ce.displayName = "TapScrollCircle";
130
+ const mt = (r, t, e) => Math.min(e, Math.max(t, r)), he = "virtualscroll:tap-scroll-cancel", be = 20, qe = 250, Be = 60, $e = 20, We = 20, Ke = 240, Pe = { active: !1, offsetX: 0, offsetY: 0, distance: 0, direction: 0, pointerId: null }, me = 2.2, je = 8, Ge = 120, Ze = 1 / 60, zt = {
127
131
  enabled: !0,
128
132
  size: 40,
129
133
  offsetX: -80,
130
134
  offsetY: 0,
131
135
  className: void 0,
132
- maxVisualDistance: Be,
136
+ maxVisualDistance: Ke,
133
137
  minSpeedMultiplier: 0.2,
134
138
  opacity: 0.9,
135
139
  renderVisual: void 0,
136
140
  maxSpeedCurve: void 0
137
- }, je = (r) => r ? {
141
+ }, Je = (r) => r ? {
138
142
  mainSizeKey: "width",
139
143
  crossSizeKey: "height",
140
144
  positionKey: "left",
@@ -154,287 +158,289 @@ const gt = (r, t, e) => Math.min(e, Math.max(t, r)), pe = "virtualscroll:tap-scr
154
158
  arrowIcons: ["▲", "▼"],
155
159
  directionClass: "flex flex-col items-stretch",
156
160
  orientation: "vertical"
157
- }, Ge = (r, t) => {
158
- const e = r?.maxSpeedMultiplier, n = typeof e == "number" ? e : Qe(t);
161
+ }, Qe = (r, t) => {
162
+ const e = r?.maxSpeedMultiplier, n = typeof e == "number" ? e : nn(t);
159
163
  return {
160
- enabled: r?.enabled ?? kt.enabled,
161
- size: r?.size ?? kt.size,
162
- offsetX: r?.offsetX ?? kt.offsetX,
163
- offsetY: r?.offsetY ?? kt.offsetY,
164
- className: r?.className ?? kt.className,
165
- maxVisualDistance: r?.maxVisualDistance ?? kt.maxVisualDistance,
164
+ enabled: r?.enabled ?? zt.enabled,
165
+ size: r?.size ?? zt.size,
166
+ offsetX: r?.offsetX ?? zt.offsetX,
167
+ offsetY: r?.offsetY ?? zt.offsetY,
168
+ className: r?.className ?? zt.className,
169
+ maxVisualDistance: r?.maxVisualDistance ?? zt.maxVisualDistance,
166
170
  maxSpeedMultiplier: n,
167
- minSpeedMultiplier: Math.max(r?.minSpeedMultiplier ?? kt.minSpeedMultiplier, 0),
168
- opacity: gt(r?.opacity ?? kt.opacity, 0, 1),
169
- renderVisual: r?.renderVisual ?? kt.renderVisual,
170
- maxSpeedCurve: r?.maxSpeedCurve ?? kt.maxSpeedCurve
171
+ minSpeedMultiplier: Math.max(r?.minSpeedMultiplier ?? zt.minSpeedMultiplier, 0),
172
+ opacity: mt(r?.opacity ?? zt.opacity, 0, 1),
173
+ renderVisual: r?.renderVisual ?? zt.renderVisual,
174
+ maxSpeedCurve: r?.maxSpeedCurve ?? zt.maxSpeedCurve
171
175
  };
172
- }, Ze = ({ isDragging: r, isThumbHovered: t, enableThumbDrag: e }) => Vt(() => e ? r ? "dragging" : t ? "hover" : "idle" : "disabled", [e, r, t]), Je = ({ canUseArrowButtons: r, enableArrowButtons: t, resetTapScroll: e, scrollByStep: n }) => {
173
- const o = y(null), a = y(null), d = w(() => {
176
+ }, tn = ({ isDragging: r, isThumbHovered: t, enableThumbDrag: e }) => Dt(() => e ? r ? "dragging" : t ? "hover" : "idle" : "disabled", [e, r, t]), en = ({ canUseArrowButtons: r, enableArrowButtons: t, resetTapScroll: e, scrollByStep: n }) => {
177
+ const o = w(null), a = w(null), u = y(() => {
174
178
  o.current !== null && (window.clearInterval(o.current), o.current = null), a.current !== null && (window.clearTimeout(a.current), a.current = null);
175
- }, []), m = w(() => {
176
- d();
177
- }, [d]), l = w(
178
- (p) => (g) => {
179
- r && (g.preventDefault(), g.stopPropagation(), e(), d(), n(p), a.current = window.setTimeout(() => {
179
+ }, []), p = y(() => {
180
+ u();
181
+ }, [u]), l = y(
182
+ (c) => (f) => {
183
+ r && (f.preventDefault(), f.stopPropagation(), e(), u(), n(c), a.current = window.setTimeout(() => {
180
184
  o.current = window.setInterval(() => {
181
- n(p);
182
- }, He);
183
- }, Xe));
185
+ n(c);
186
+ }, Be);
187
+ }, qe));
184
188
  },
185
- [r, d, e, n]
186
- ), u = w(
187
- (p) => (g) => {
188
- t && (g.key === "Enter" || g.key === " " || g.key === "Spacebar") && (g.preventDefault(), n(p));
189
+ [r, u, e, n]
190
+ ), d = y(
191
+ (c) => (f) => {
192
+ t && (f.key === "Enter" || f.key === " " || f.key === "Spacebar") && (f.preventDefault(), n(c));
189
193
  },
190
194
  [t, n]
191
195
  );
192
- return Y(() => () => {
193
- d();
194
- }, [d]), { handleArrowPointerDown: l, handleArrowPointerUp: m, handleArrowKeyDown: u };
195
- }, Qe = (r) => {
196
+ return O(() => () => {
197
+ u();
198
+ }, [u]), { handleArrowPointerDown: l, handleArrowPointerUp: p, handleArrowKeyDown: d };
199
+ }, nn = (r) => {
196
200
  if (!r || r <= 0)
197
- return fe;
198
- const t = Math.max(1, r), e = Math.log10(t), n = fe + e * $e;
199
- return gt(n, fe, We);
200
- }, tn = ({
201
+ return me;
202
+ const t = Math.max(1, r), e = Math.log10(t), n = me + e * je;
203
+ return mt(n, me, Ge);
204
+ }, rn = ({
201
205
  contentSize: r,
202
206
  viewportSize: t,
203
207
  scrollPosition: e,
204
208
  onScroll: n,
205
209
  enableThumbDrag: o = !0,
206
210
  enableTrackClick: a = !0,
207
- enableArrowButtons: d = !0,
208
- horizontal: m = !1,
211
+ enableArrowButtons: u = !0,
212
+ horizontal: p = !1,
209
213
  scrollBarWidth: l = 12,
210
- className: u,
211
- ariaControls: p,
212
- tapScrollCircleOptions: g,
213
- itemCount: v,
214
- renderThumbOverlay: b
214
+ className: d,
215
+ ariaControls: c,
216
+ tapScrollCircleOptions: f,
217
+ itemCount: S,
218
+ renderThumbOverlay: b,
219
+ visibleStartIndex: _,
220
+ visibleEndIndex: X
215
221
  }) => {
216
- const [_, D] = Ot(!1), [Q, z] = Ot(!1), [lt, C] = Ot(!1), V = y(null), U = y({ pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 }), F = y({ pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 }), M = y(e), X = y(Te), St = y(null), R = y(null), L = y(null), c = Vt(() => Ge(g, v), [v, g]), ct = Vt(() => je(m), [m]), {
217
- enabled: P,
218
- size: ut,
219
- offsetX: it,
220
- offsetY: Tt,
221
- className: H,
222
+ const [k, B] = Xt(!1), [ht, H] = Xt(!1), [F, C] = Xt(!1), L = w(null), R = w({ pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 }), N = w({ pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 }), st = w(e), ut = w(Pe), $ = w(null), I = w(null), m = w(null), tt = Dt(() => Qe(f, S), [S, f]), A = Dt(() => Je(p), [p]), {
223
+ enabled: et,
224
+ size: it,
225
+ offsetX: At,
226
+ offsetY: W,
227
+ className: U,
222
228
  maxVisualDistance: dt,
223
229
  maxSpeedMultiplier: ft,
224
- minSpeedMultiplier: et,
225
- opacity: f,
226
- renderVisual: E,
227
- maxSpeedCurve: O
228
- } = c, W = y({
230
+ minSpeedMultiplier: E,
231
+ opacity: P,
232
+ renderVisual: v,
233
+ maxSpeedCurve: nt
234
+ } = tt, K = w({
229
235
  viewportSize: t,
230
236
  maxScrollPosition: Math.max(r - t, 0),
231
237
  scrollBarVisible: r > t,
232
238
  effectiveTapMaxDistance: Math.max(dt, 1),
233
239
  tapCircleMaxSpeedMultiplier: ft,
234
- tapCircleMinSpeedMultiplier: et,
235
- tapCircleMaxSpeedCurve: O,
236
- tapScrollCircleOptions: g
237
- }), { mainSizeKey: Z, crossSizeKey: vt, positionKey: pt, selectDelta: G, getPointerCoordinate: tt, arrowLabels: xt, arrowIcons: st, directionClass: bt, orientation: Ft } = ct, Ct = Math.max(dt, 1), Rt = t / r, h = l, T = Math.max(t - h * 2, 0), q = Rt * T, mt = Math.min(Math.max(Ie, q || 0), T || Ie), N = r - t, At = Math.max(T - mt, 0), It = N <= 0 || At <= 0 ? 0 : e / N * At, Xt = It + mt / 2, nt = r > t, Kt = nt && d;
238
- W.current = {
240
+ tapCircleMinSpeedMultiplier: E,
241
+ tapCircleMaxSpeedCurve: nt,
242
+ tapScrollCircleOptions: f
243
+ }), { mainSizeKey: Z, crossSizeKey: pt, positionKey: rt, selectDelta: at, getPointerCoordinate: ot, arrowLabels: It, arrowIcons: gt, directionClass: Tt, orientation: wt } = A, _t = Math.max(dt, 1), Ft = t / r, h = l, g = Math.max(t - h * 2, 0), xt = Ft * g, J = Math.min(Math.max(be, xt || 0), g || be), Y = r - t, Vt = Math.max(g - J, 0), bt = Y <= 0 || Vt <= 0 ? 0 : e / Y * Vt, Et = bt + J / 2, Pt = r > t, Nt = Pt && u;
244
+ K.current = {
239
245
  viewportSize: t,
240
- maxScrollPosition: N,
241
- scrollBarVisible: nt,
242
- effectiveTapMaxDistance: Ct,
246
+ maxScrollPosition: Y,
247
+ scrollBarVisible: Pt,
248
+ effectiveTapMaxDistance: _t,
243
249
  tapCircleMaxSpeedMultiplier: ft,
244
- tapCircleMinSpeedMultiplier: et,
245
- tapCircleMaxSpeedCurve: O,
246
- tapScrollCircleOptions: g
247
- }, Y(() => {
248
- M.current = e;
249
- }, [e]), Y(() => {
250
- o || z(!1);
250
+ tapCircleMinSpeedMultiplier: E,
251
+ tapCircleMaxSpeedCurve: nt,
252
+ tapScrollCircleOptions: f
253
+ }, O(() => {
254
+ st.current = e;
255
+ }, [e]), O(() => {
256
+ o || H(!1);
251
257
  }, [o]);
252
- const Ht = Ze({ isDragging: _, isThumbHovered: Q, enableThumbDrag: o }), wt = w(
253
- (i, x) => {
254
- const A = W.current, ht = x ?? M.current;
258
+ const Bt = tn({ isDragging: k, isThumbHovered: ht, enableThumbDrag: o }), St = y(
259
+ (s, x) => {
260
+ const V = K.current, G = x ?? st.current;
255
261
  if (n) {
256
- const _t = n(i, ht);
257
- if (typeof _t == "number" && Number.isFinite(_t))
258
- return M.current = _t, _t;
262
+ const Yt = n(s, G);
263
+ if (typeof Yt == "number" && Number.isFinite(Yt))
264
+ return st.current = Yt, Yt;
259
265
  }
260
- const j = typeof i == "function" ? i(ht) : i, Pt = Math.max(A.maxScrollPosition, 0), Dt = A.scrollBarVisible ? gt(j, 0, Pt) : 0;
261
- return M.current = Dt, Dt;
266
+ const vt = typeof s == "function" ? s(G) : s, Mt = Math.max(V.maxScrollPosition, 0), Lt = V.scrollBarVisible ? mt(vt, 0, Mt) : 0;
267
+ return st.current = Lt, Lt;
262
268
  },
263
269
  [n]
264
- ), Nt = w(
265
- (i) => {
266
- const x = W.current, A = M.current;
270
+ ), kt = y(
271
+ (s) => {
272
+ const x = K.current, V = st.current;
267
273
  if (!x.scrollBarVisible || x.maxScrollPosition <= 0) {
268
- const _t = wt(0, A), ce = _t - A;
269
- return { nextPosition: _t, actualDelta: ce, reachedBoundary: !0 };
274
+ const Yt = St(0, V), de = Yt - V;
275
+ return { nextPosition: Yt, actualDelta: de, reachedBoundary: !0 };
270
276
  }
271
- if (i === 0)
272
- return { nextPosition: A, actualDelta: 0, reachedBoundary: !1 };
273
- const j = wt((_t) => gt(_t + i, 0, x.maxScrollPosition), A), Pt = j - A, Dt = Pt === 0 || i < 0 && j <= 0 || i > 0 && j >= x.maxScrollPosition;
274
- return { nextPosition: j, actualDelta: Pt, reachedBoundary: Dt };
277
+ if (s === 0)
278
+ return { nextPosition: V, actualDelta: 0, reachedBoundary: !1 };
279
+ const vt = St((Yt) => mt(Yt + s, 0, x.maxScrollPosition), V), Mt = vt - V, Lt = Mt === 0 || s < 0 && vt <= 0 || s > 0 && vt >= x.maxScrollPosition;
280
+ return { nextPosition: vt, actualDelta: Mt, reachedBoundary: Lt };
275
281
  },
276
- [wt]
277
- ), at = w(() => {
278
- R.current !== null && (window.cancelAnimationFrame(R.current), R.current = null), L.current = null;
279
- }, []), rt = w(() => {
280
- X.current = { ...Te }, C(!1), St.current?.reset(), at();
281
- }, [at]), Bt = w(
282
- (i) => {
283
- const x = X.current, A = W.current;
282
+ [St]
283
+ ), lt = y(() => {
284
+ I.current !== null && (window.cancelAnimationFrame(I.current), I.current = null), m.current = null;
285
+ }, []), Ct = y(() => {
286
+ ut.current = { ...Pe }, C(!1), $.current?.reset(), lt();
287
+ }, [lt]), Kt = y(
288
+ (s) => {
289
+ const x = ut.current, V = K.current;
284
290
  if (!x.active || x.direction === 0) {
285
- at();
291
+ lt();
286
292
  return;
287
293
  }
288
- if (!A.scrollBarVisible || A.maxScrollPosition <= 0) {
289
- at();
294
+ if (!V.scrollBarVisible || V.maxScrollPosition <= 0) {
295
+ lt();
290
296
  return;
291
297
  }
292
- const ht = L.current ?? i, j = Math.max((i - ht) / 1e3, 0), Pt = Math.min(j, Ke);
293
- if (L.current = i, Pt <= 0) {
294
- R.current = window.requestAnimationFrame(Bt);
298
+ const G = m.current ?? s, vt = Math.max((s - G) / 1e3, 0), Mt = Math.min(vt, Ze);
299
+ if (m.current = s, Mt <= 0) {
300
+ I.current = window.requestAnimationFrame(Kt);
295
301
  return;
296
302
  }
297
- const Dt = Math.min(x.distance, A.effectiveTapMaxDistance) / A.effectiveTapMaxDistance, _t = Dt ** 1.1, ce = typeof A.tapScrollCircleOptions?.maxSpeedMultiplier == "number", Qt = Math.max(A.viewportSize * A.tapCircleMinSpeedMultiplier, 40), Me = ce ? Qt : 1200;
298
- let ue = Math.max(A.viewportSize * A.tapCircleMaxSpeedMultiplier, Me);
299
- const ne = A.tapCircleMaxSpeedCurve;
300
- if (ne) {
301
- const re = Math.max(ne.exponentialSteepness, 0), Fe = Math.max(ne.exponentialScale ?? A.tapCircleMaxSpeedMultiplier, 0), Ne = re === 0 ? Dt : Math.expm1(re * Dt), ge = re === 0 ? 1 : Math.expm1(re) || 1, ke = ge === 0 ? Dt : Math.min(Math.max(Ne / ge, 0), 1), Oe = A.viewportSize * Fe * ke;
302
- ue = Math.min(ue, Math.max(Oe, Qt));
303
+ const Lt = Math.min(x.distance, V.effectiveTapMaxDistance) / V.effectiveTapMaxDistance, Yt = Lt ** 1.1, de = typeof V.tapScrollCircleOptions?.maxSpeedMultiplier == "number", Qt = Math.max(V.viewportSize * V.tapCircleMinSpeedMultiplier, 40), Re = de ? Qt : 1200;
304
+ let fe = Math.max(V.viewportSize * V.tapCircleMaxSpeedMultiplier, Re);
305
+ const se = V.tapCircleMaxSpeedCurve;
306
+ if (se) {
307
+ const ie = Math.max(se.exponentialSteepness, 0), ke = Math.max(se.exponentialScale ?? V.tapCircleMaxSpeedMultiplier, 0), Oe = ie === 0 ? Lt : Math.expm1(ie * Lt), Ie = ie === 0 ? 1 : Math.expm1(ie) || 1, Le = Ie === 0 ? Lt : Math.min(Math.max(Oe / Ie, 0), 1), Ye = V.viewportSize * ke * Le;
308
+ fe = Math.min(fe, Math.max(Ye, Qt));
303
309
  }
304
- const Ce = Math.max(ue, Qt), Re = Math.max(ne?.easedOffset ?? 0, 0), Ae = Math.min(1, _t + Re), Ve = Qt + (Ce - Qt) * Ae, Ee = x.direction * Ve * Pt, { actualDelta: De, reachedBoundary: _e } = Nt(Ee);
305
- if (_e || De === 0) {
306
- at();
310
+ const Ae = Math.max(fe, Qt), Ve = Math.max(se?.easedOffset ?? 0, 0), Ee = Math.min(1, Yt + Ve), De = Qt + (Ae - Qt) * Ee, _e = x.direction * De * Mt, { actualDelta: Fe, reachedBoundary: Ne } = kt(_e);
311
+ if (Ne || Fe === 0) {
312
+ lt();
307
313
  return;
308
314
  }
309
- R.current = window.requestAnimationFrame(Bt);
315
+ I.current = window.requestAnimationFrame(Kt);
310
316
  },
311
- [Nt, at]
312
- ), Zt = w(() => {
313
- R.current === null && (L.current = null, R.current = window.requestAnimationFrame(Bt));
314
- }, [Bt]);
315
- Y(() => () => {
316
- at();
317
- }, [at]);
318
- const ae = w(
319
- (i) => {
320
- X.current = i, C(i.active), i.active && i.direction !== 0 ? Zt() : at();
317
+ [kt, lt]
318
+ ), re = y(() => {
319
+ I.current === null && (m.current = null, I.current = window.requestAnimationFrame(Kt));
320
+ }, [Kt]);
321
+ O(() => () => {
322
+ lt();
323
+ }, [lt]);
324
+ const ce = y(
325
+ (s) => {
326
+ ut.current = s, C(s.active), s.active && s.direction !== 0 ? re() : lt();
321
327
  },
322
- [Zt, at]
328
+ [re, lt]
323
329
  );
324
- Y(() => {
325
- P || rt();
326
- }, [rt, P]), Y(() => {
327
- const i = (x) => {
328
- const ht = x.detail?.paneId;
329
- ht && p && ht !== p || rt();
330
+ O(() => {
331
+ et || Ct();
332
+ }, [Ct, et]), O(() => {
333
+ const s = (x) => {
334
+ const G = x.detail?.paneId;
335
+ G && c && G !== c || Ct();
330
336
  };
331
- return window.addEventListener(pe, i), () => {
332
- window.removeEventListener(pe, i);
337
+ return window.addEventListener(he, s), () => {
338
+ window.removeEventListener(he, s);
333
339
  };
334
- }, [p, rt]), Y(() => {
335
- if (!P)
340
+ }, [c, Ct]), O(() => {
341
+ if (!et)
336
342
  return;
337
- const i = (x) => {
338
- if (!X.current.active)
343
+ const s = (x) => {
344
+ if (!ut.current.active || ut.current.pointerId === x.pointerId)
339
345
  return;
340
- const A = x.target;
341
- if (!(A instanceof Node)) {
342
- rt();
346
+ const V = x.target;
347
+ if (!(V instanceof Node)) {
348
+ Ct();
343
349
  return;
344
350
  }
345
- St.current?.getElement()?.contains(A) || rt();
351
+ $.current?.getElement()?.contains(V) || Ct();
346
352
  };
347
- return document.addEventListener("pointerdown", i, !0), () => {
348
- document.removeEventListener("pointerdown", i, !0);
353
+ return document.addEventListener("pointerdown", s, !0), () => {
354
+ document.removeEventListener("pointerdown", s, !0);
349
355
  };
350
- }, [rt, P]);
351
- const Jt = (i) => {
352
- if (!nt || At <= 0 || N <= 0)
356
+ }, [Ct, et]);
357
+ const i = (s) => {
358
+ if (!Pt || Vt <= 0 || Y <= 0)
353
359
  return 0;
354
- const x = gt(i, 0, At);
355
- return gt(x / At * N, 0, N);
356
- }, s = (i) => {
357
- const x = Math.max(Math.round(t / qe), Ue);
358
- Nt(i * x);
359
- }, { handleArrowPointerDown: I, handleArrowPointerUp: S, handleArrowKeyDown: k } = Je({
360
- canUseArrowButtons: Kt,
361
- enableArrowButtons: d,
362
- resetTapScroll: rt,
363
- scrollByStep: s
364
- }), $ = (i) => {
365
- if (!nt)
360
+ const x = mt(s, 0, Vt);
361
+ return mt(x / Vt * Y, 0, Y);
362
+ }, T = (s) => {
363
+ const x = Math.max(Math.round(t / We), $e);
364
+ kt(s * x);
365
+ }, { handleArrowPointerDown: M, handleArrowPointerUp: D, handleArrowKeyDown: q } = en({
366
+ canUseArrowButtons: Nt,
367
+ enableArrowButtons: u,
368
+ resetTapScroll: Ct,
369
+ scrollByStep: T
370
+ }), j = (s) => {
371
+ if (!Pt)
366
372
  return;
367
373
  if (!o) {
368
- i.preventDefault(), i.stopPropagation();
374
+ s.preventDefault(), s.stopPropagation();
369
375
  return;
370
376
  }
371
- if (i.pointerType === "mouse" && i.button !== 0 || i.ctrlKey)
377
+ if (s.pointerType === "mouse" && s.button !== 0 || s.ctrlKey)
372
378
  return;
373
- rt();
374
- const x = i.currentTarget;
375
- x.setPointerCapture && x.setPointerCapture(i.pointerId), U.current = {
376
- pointerId: i.pointerId,
377
- startThumbPosition: It,
378
- startClientX: i.clientX,
379
- startClientY: i.clientY
380
- }, D(!0), z(!0), i.preventDefault(), i.stopPropagation();
381
- }, K = (i) => {
382
- const x = U.current;
383
- if (x.pointerId !== i.pointerId)
379
+ Ct();
380
+ const x = s.currentTarget;
381
+ x.setPointerCapture && x.setPointerCapture(s.pointerId), R.current = {
382
+ pointerId: s.pointerId,
383
+ startThumbPosition: bt,
384
+ startClientX: s.clientX,
385
+ startClientY: s.clientY
386
+ }, B(!0), H(!0), s.preventDefault(), s.stopPropagation();
387
+ }, Rt = (s) => {
388
+ const x = R.current;
389
+ if (x.pointerId !== s.pointerId)
384
390
  return;
385
- const A = i.clientX - x.startClientX, ht = i.clientY - x.startClientY, j = G(A, ht), Pt = Jt(x.startThumbPosition + j);
386
- wt(Pt), i.cancelable && i.preventDefault();
387
- }, yt = (i) => {
388
- if (U.current.pointerId !== i.pointerId)
391
+ const V = s.clientX - x.startClientX, G = s.clientY - x.startClientY, vt = at(V, G), Mt = i(x.startThumbPosition + vt);
392
+ St(Mt), s.cancelable && s.preventDefault();
393
+ }, Ht = (s) => {
394
+ if (R.current.pointerId !== s.pointerId)
389
395
  return;
390
- const x = i.currentTarget;
391
- x.hasPointerCapture(i.pointerId) && x.releasePointerCapture(i.pointerId), U.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 }, D(!1), V.current && !V.current.matches(":hover") && z(!1), i.preventDefault(), i.stopPropagation();
392
- }, Lt = (i) => {
393
- if (U.current.pointerId !== i.pointerId)
396
+ const x = s.currentTarget;
397
+ x.hasPointerCapture(s.pointerId) && x.releasePointerCapture(s.pointerId), R.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 }, B(!1), L.current && !L.current.matches(":hover") && H(!1), s.preventDefault(), s.stopPropagation();
398
+ }, Ot = (s) => {
399
+ if (R.current.pointerId !== s.pointerId)
394
400
  return;
395
- const x = i.currentTarget;
396
- x.hasPointerCapture(i.pointerId) && x.releasePointerCapture(i.pointerId), U.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 }, D(!1), V.current && !V.current.matches(":hover") && z(!1);
397
- }, Et = (i) => {
398
- if (!nt)
401
+ const x = s.currentTarget;
402
+ x.hasPointerCapture(s.pointerId) && x.releasePointerCapture(s.pointerId), R.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 }, B(!1), L.current && !L.current.matches(":hover") && H(!1);
403
+ }, Ut = (s) => {
404
+ if (!Pt)
399
405
  return;
400
406
  if (!a) {
401
- i.preventDefault(), i.stopPropagation();
407
+ s.preventDefault(), s.stopPropagation();
402
408
  return;
403
409
  }
404
- if (i.pointerType === "mouse" && i.button !== 0 || i.ctrlKey)
410
+ if (s.pointerType === "mouse" && s.button !== 0 || s.ctrlKey)
405
411
  return;
406
- const x = i.currentTarget, A = x.getBoundingClientRect(), j = tt(i) - (m ? A.left : A.top);
407
- rt();
408
- const Pt = j - mt / 2, Dt = Jt(Pt);
409
- wt(Dt), x.setPointerCapture && x.setPointerCapture(i.pointerId), F.current = {
410
- pointerId: i.pointerId,
411
- startThumbPosition: Pt,
412
- startClientX: i.clientX,
413
- startClientY: i.clientY
414
- }, i.preventDefault(), i.stopPropagation();
415
- }, Yt = (i) => {
416
- const x = F.current;
417
- if (x.pointerId !== i.pointerId)
412
+ const x = s.currentTarget, V = x.getBoundingClientRect(), vt = ot(s) - (p ? V.left : V.top);
413
+ Ct();
414
+ const Mt = vt - J / 2, Lt = i(Mt);
415
+ St(Lt), x.setPointerCapture && x.setPointerCapture(s.pointerId), N.current = {
416
+ pointerId: s.pointerId,
417
+ startThumbPosition: Mt,
418
+ startClientX: s.clientX,
419
+ startClientY: s.clientY
420
+ }, s.preventDefault(), s.stopPropagation();
421
+ }, jt = (s) => {
422
+ const x = N.current;
423
+ if (x.pointerId !== s.pointerId)
418
424
  return;
419
- const A = i.clientX - x.startClientX, ht = i.clientY - x.startClientY, j = G(A, ht), Pt = Jt(x.startThumbPosition + j);
420
- wt(Pt), i.cancelable && i.preventDefault();
421
- }, $t = (i) => {
422
- if (F.current.pointerId !== i.pointerId)
425
+ const V = s.clientX - x.startClientX, G = s.clientY - x.startClientY, vt = at(V, G), Mt = i(x.startThumbPosition + vt);
426
+ St(Mt), s.cancelable && s.preventDefault();
427
+ }, qt = (s) => {
428
+ if (N.current.pointerId !== s.pointerId)
423
429
  return;
424
- const x = i.currentTarget;
425
- x.hasPointerCapture(i.pointerId) && x.releasePointerCapture(i.pointerId), F.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 }, i.preventDefault(), i.stopPropagation();
426
- }, zt = (i) => {
427
- if (F.current.pointerId !== i.pointerId)
430
+ const x = s.currentTarget;
431
+ x.hasPointerCapture(s.pointerId) && x.releasePointerCapture(s.pointerId), N.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 }, s.preventDefault(), s.stopPropagation();
432
+ }, Gt = (s) => {
433
+ if (N.current.pointerId !== s.pointerId)
428
434
  return;
429
- const x = i.currentTarget;
430
- x.hasPointerCapture(i.pointerId) && x.releasePointerCapture(i.pointerId), F.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 };
431
- }, Wt = Vt(() => gt((lt ? 1 : 0.8) * f, 0, 1), [lt, f]), B = Vt(() => {
432
- const x = `calc(50% - ${ut / 2}px + ${Tt}px)`;
435
+ const x = s.currentTarget;
436
+ x.hasPointerCapture(s.pointerId) && x.releasePointerCapture(s.pointerId), N.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 };
437
+ }, z = Dt(() => mt((F ? 1 : 0.8) * P, 0, 1), [F, P]), $t = Dt(() => {
438
+ const x = `calc(50% - ${it / 2}px + ${W}px)`;
433
439
  return {
434
- left: it,
440
+ left: At,
435
441
  top: x
436
442
  };
437
- }, [it, Tt, ut]), Ut = (i, x, A) => /* @__PURE__ */ J(
443
+ }, [At, W, it]), ue = (s, x, V) => /* @__PURE__ */ Q(
438
444
  "button",
439
445
  {
440
446
  type: "button",
@@ -442,40 +448,42 @@ const gt = (r, t, e) => Math.min(e, Math.max(t, r)), pe = "virtualscroll:tap-scr
442
448
  className: "aqvs:scrollbar-arrow-button flex items-center justify-center text-xs transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50",
443
449
  style: {
444
450
  [Z]: h,
445
- [vt]: l
451
+ [pt]: l
446
452
  },
447
453
  "aria-label": x,
448
- onMouseDown: I(i),
449
- onTouchStart: I(i),
450
- onMouseUp: S,
451
- onMouseLeave: S,
452
- onTouchEnd: S,
453
- onTouchCancel: S,
454
- onKeyDown: k(i),
455
- "aria-disabled": !d,
456
- disabled: !Kt,
457
- children: /* @__PURE__ */ J("span", { "aria-hidden": "true", children: A })
454
+ onMouseDown: M(s),
455
+ onTouchStart: M(s),
456
+ onMouseUp: D,
457
+ onMouseLeave: D,
458
+ onTouchEnd: D,
459
+ onTouchCancel: D,
460
+ onKeyDown: q(s),
461
+ "aria-disabled": !u,
462
+ disabled: !Nt,
463
+ children: /* @__PURE__ */ Q("span", { "aria-hidden": "true", children: V })
458
464
  }
459
- ), le = b && nt ? {
460
- orientation: Ft,
465
+ ), oe = b && Pt ? {
466
+ orientation: wt,
461
467
  scrollPosition: e,
462
- maxScrollPosition: N,
468
+ maxScrollPosition: Y,
463
469
  contentSize: r,
464
470
  viewportSize: t,
465
- thumbSize: mt,
466
- thumbPosition: It,
467
- thumbCenter: Xt,
468
- trackSize: T,
469
- isDragging: _,
470
- isTapScrollActive: lt
471
+ thumbSize: J,
472
+ thumbPosition: bt,
473
+ thumbCenter: Et,
474
+ trackSize: g,
475
+ isDragging: k,
476
+ isTapScrollActive: F,
477
+ visibleStartIndex: _,
478
+ visibleEndIndex: X
471
479
  } : null;
472
- return /* @__PURE__ */ Gt(
480
+ return /* @__PURE__ */ Jt(
473
481
  "div",
474
482
  {
475
- className: jt("group relative cursor-default select-none", bt, u),
483
+ className: Zt("group relative cursor-default select-none", Tt, d),
476
484
  style: {
477
485
  [Z]: t,
478
- [vt]: l,
486
+ [pt]: l,
479
487
  backgroundColor: "white",
480
488
  userSelect: "none",
481
489
  position: "relative",
@@ -483,27 +491,27 @@ const gt = (r, t, e) => Math.min(e, Math.max(t, r)), pe = "virtualscroll:tap-scr
483
491
  },
484
492
  role: "scrollbar",
485
493
  tabIndex: -1,
486
- "aria-controls": p,
494
+ "aria-controls": c,
487
495
  "aria-valuenow": e,
488
496
  "aria-valuemin": 0,
489
- "aria-valuemax": N,
490
- "aria-orientation": m ? "horizontal" : "vertical",
497
+ "aria-valuemax": Y,
498
+ "aria-orientation": p ? "horizontal" : "vertical",
491
499
  children: [
492
- !m && nt && P && /* @__PURE__ */ J(
493
- ye,
500
+ !p && Pt && et && /* @__PURE__ */ Q(
501
+ Ce,
494
502
  {
495
- ref: St,
496
- className: jt("pointer-events-auto absolute transition-opacity duration-150", H),
497
- size: ut,
498
- maxVisualDistance: Ct,
499
- style: B,
500
- opacity: Wt,
501
- renderVisual: E,
502
- onDragChange: ae
503
+ ref: $,
504
+ className: Zt("pointer-events-auto absolute transition-opacity duration-150", U),
505
+ size: it,
506
+ maxVisualDistance: _t,
507
+ style: $t,
508
+ opacity: z,
509
+ renderVisual: v,
510
+ onDragChange: ce
503
511
  }
504
512
  ),
505
- Ut(-1, xt[0], st[0]),
506
- /* @__PURE__ */ Gt(
513
+ ue(-1, It[0], gt[0]),
514
+ /* @__PURE__ */ Jt(
507
515
  "div",
508
516
  {
509
517
  className: "aqvs:scrollbar-track relative flex-1",
@@ -511,50 +519,50 @@ const gt = (r, t, e) => Math.min(e, Math.max(t, r)), pe = "virtualscroll:tap-scr
511
519
  borderRadius: l / 2,
512
520
  touchAction: "none"
513
521
  },
514
- onPointerDown: Et,
515
- onPointerMove: Yt,
516
- onPointerUp: $t,
517
- onPointerCancel: zt,
522
+ onPointerDown: Ut,
523
+ onPointerMove: jt,
524
+ onPointerUp: qt,
525
+ onPointerCancel: Gt,
518
526
  "aria-disabled": !a,
519
527
  children: [
520
- le && /* @__PURE__ */ J("div", { className: "pointer-events-none absolute inset-0", "aria-hidden": !0, children: b?.(le) }),
521
- nt && // スクロールバーのつまみの当たり判定を広げるためのラッパー
522
- /* @__PURE__ */ J(
528
+ oe && /* @__PURE__ */ Q("div", { className: "pointer-events-none absolute inset-0", "aria-hidden": !0, children: b?.(oe) }),
529
+ Pt && // スクロールバーのつまみの当たり判定を広げるためのラッパー
530
+ /* @__PURE__ */ Q(
523
531
  "div",
524
532
  {
525
533
  className: "group absolute",
526
534
  style: {
527
- [Z]: mt,
528
- [pt]: It,
529
- ...m ? { top: 0, bottom: 0 } : { left: 0, right: 0 },
535
+ [Z]: J,
536
+ [rt]: bt,
537
+ ...p ? { top: 0, bottom: 0 } : { left: 0, right: 0 },
530
538
  touchAction: "none"
531
539
  },
532
- onPointerDown: $,
533
- onPointerMove: K,
534
- onPointerUp: yt,
535
- onPointerCancel: Lt,
540
+ onPointerDown: j,
541
+ onPointerMove: Rt,
542
+ onPointerUp: Ht,
543
+ onPointerCancel: Ot,
536
544
  role: "slider",
537
- "aria-orientation": m ? "horizontal" : "vertical",
545
+ "aria-orientation": p ? "horizontal" : "vertical",
538
546
  "aria-valuenow": e,
539
547
  "aria-valuemin": 0,
540
- "aria-valuemax": N,
548
+ "aria-valuemax": Y,
541
549
  "aria-disabled": !o,
542
550
  tabIndex: -1,
543
- children: /* @__PURE__ */ J(
551
+ children: /* @__PURE__ */ Q(
544
552
  "div",
545
553
  {
546
- ref: V,
547
- className: jt("aqvs:scrollbar-thumb absolute", m ? "aqvs:scrollbar-thumb-horizontal" : "aqvs:scrollbar-thumb-vertical"),
548
- "data-thumb-state": Ht,
554
+ ref: L,
555
+ className: Zt("aqvs:scrollbar-thumb absolute", p ? "aqvs:scrollbar-thumb-horizontal" : "aqvs:scrollbar-thumb-vertical"),
556
+ "data-thumb-state": Bt,
549
557
  style: {
550
558
  borderRadius: l - 1,
551
559
  cursor: o ? "pointer" : "default"
552
560
  },
553
561
  onMouseEnter: () => {
554
- o && z(!0);
562
+ o && H(!0);
555
563
  },
556
564
  onMouseLeave: () => {
557
- o && z(!1);
565
+ o && H(!1);
558
566
  }
559
567
  }
560
568
  )
@@ -563,13 +571,13 @@ const gt = (r, t, e) => Math.min(e, Math.max(t, r)), pe = "virtualscroll:tap-scr
563
571
  ]
564
572
  }
565
573
  ),
566
- Ut(1, xt[1], st[1])
574
+ ue(1, It[1], gt[1])
567
575
  ]
568
576
  }
569
577
  );
570
- }, Mt = {
578
+ }, yt = {
571
579
  debug(r, ...t) {
572
- typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${r}`, ...t);
580
+ process.env.NODE_ENV === "___" && console.debug(`[VirtualScroll] ${r}`, ...t);
573
581
  },
574
582
  warn(r, ...t) {
575
583
  console.warn(`[VirtualScroll] ${r}`, ...t);
@@ -583,10 +591,10 @@ const gt = (r, t, e) => Math.min(e, Math.max(t, r)), pe = "virtualscroll:tap-scr
583
591
  deceleration: 25e-4,
584
592
  velocitySampleWindow: 90,
585
593
  startVelocityThreshold: 0.04
586
- }, oe = (r, t, e) => {
594
+ }, ae = (r, t, e) => {
587
595
  for (const [n, o, a] of t)
588
596
  e === "add" ? r.addEventListener(n, o, a) : r.removeEventListener(n, o, a);
589
- }, en = me(
597
+ }, on = ge(
590
598
  ({
591
599
  children: r,
592
600
  contentSize: t,
@@ -594,24 +602,26 @@ const gt = (r, t, e) => Math.min(e, Math.max(t, r)), pe = "virtualscroll:tap-scr
594
602
  scrollBarWidth: n = 12,
595
603
  enableThumbDrag: o = !0,
596
604
  enableTrackClick: a = !0,
597
- enableArrowButtons: d = !0,
598
- enablePointerDrag: m = !0,
605
+ enableArrowButtons: u = !0,
606
+ enablePointerDrag: p = !0,
599
607
  onScroll: l,
600
- className: u,
601
- style: p,
602
- background: g,
603
- tapScrollCircleOptions: v,
608
+ className: d,
609
+ style: c,
610
+ background: f,
611
+ tapScrollCircleOptions: S,
604
612
  inertiaOptions: b,
605
613
  itemCount: _,
606
- renderThumbOverlay: D,
607
- wheelSpeedMultiplier: Q = 1,
608
- contentInsets: z
609
- }, lt) => {
610
- const C = y(0), V = y(null), U = y(null), F = y({
614
+ renderThumbOverlay: X,
615
+ wheelSpeedMultiplier: k = 1,
616
+ contentInsets: B,
617
+ visibleStartIndex: ht,
618
+ visibleEndIndex: H
619
+ }, F) => {
620
+ const C = w(0), L = w(null), R = w(null), N = w({
611
621
  frame: null,
612
622
  velocity: 0,
613
623
  lastTimestamp: null
614
- }), M = Vt(
624
+ }), st = Dt(
615
625
  () => ({
616
626
  maxVelocity: b?.maxVelocity ?? te.maxVelocity,
617
627
  minVelocity: b?.minVelocity ?? te.minVelocity,
@@ -620,112 +630,119 @@ const gt = (r, t, e) => Math.min(e, Math.max(t, r)), pe = "virtualscroll:tap-scr
620
630
  startVelocityThreshold: b?.startVelocityThreshold ?? te.startVelocityThreshold
621
631
  }),
622
632
  [b]
623
- ), X = Vt(() => ({
624
- top: Math.max(0, z?.top ?? 0),
625
- bottom: Math.max(0, z?.bottom ?? 0)
626
- }), [z]);
627
- Mt.debug("[ScrollPane] ScrollPane rendered", {
633
+ ), ut = Dt(() => ({
634
+ top: Math.max(0, B?.top ?? 0),
635
+ bottom: Math.max(0, B?.bottom ?? 0)
636
+ }), [B]);
637
+ yt.debug("[ScrollPane] ScrollPane rendered", {
628
638
  contentSize: t,
629
639
  viewportSize: e,
630
640
  scrollBarWidth: n,
631
- className: u,
632
- style: p,
633
- tapScrollCircleOptions: v,
641
+ className: d,
642
+ style: c,
643
+ tapScrollCircleOptions: S,
634
644
  inertiaOptions: b,
635
- enablePointerDrag: m,
636
- contentInsets: X
645
+ enablePointerDrag: p,
646
+ contentInsets: ut
637
647
  });
638
- const St = y({ contentSize: t, viewportSize: e }), R = Vt(() => t > e, [t, e]), L = w(
639
- (f) => {
640
- const { contentSize: E, viewportSize: O } = St.current, W = E > O, Z = C.current;
641
- if (Mt.debug("[ScrollPane] scrollTo called", { newPosition: f, contentSize: E, viewportSize: O, currentIsScrollable: W, prevPosition: Z }), !W)
648
+ const $ = w({ contentSize: t, viewportSize: e }), I = Dt(() => t > e, [t, e]), m = y(
649
+ (P) => {
650
+ const { contentSize: v, viewportSize: nt } = $.current, K = v > nt, Z = C.current;
651
+ if (yt.debug("[ScrollPane] scrollTo called", { newPosition: P, contentSize: v, viewportSize: nt, currentIsScrollable: K, prevPosition: Z }), !K)
642
652
  return C.current !== 0 && (C.current = 0, l?.(0, Z)), C.current;
643
- const vt = typeof f == "function" ? f(C.current) : f, pt = Math.max(E - O, 0), G = gt(vt, 0, pt);
644
- return C.current !== G && (C.current = G, l?.(G, Z)), C.current;
653
+ const pt = typeof P == "function" ? P(C.current) : P, rt = Math.max(v - nt, 0), at = mt(pt, 0, rt);
654
+ return C.current !== at && (C.current = at, l?.(at, Z)), C.current;
645
655
  },
646
656
  [l]
647
- ), c = w(() => {
648
- const f = F.current;
649
- f.frame !== null && cancelAnimationFrame(f.frame), f.frame = null, f.velocity = 0, f.lastTimestamp = null;
650
- }, []), ct = y(c);
651
- Y(() => {
652
- ct.current = c;
653
- }, [c]);
654
- const P = w(
655
- (f) => {
656
- if (!R)
657
+ ), tt = y(() => {
658
+ const P = N.current;
659
+ P.frame !== null && cancelAnimationFrame(P.frame), P.frame = null, P.velocity = 0, P.lastTimestamp = null;
660
+ }, []), A = w(tt);
661
+ O(() => {
662
+ A.current = tt;
663
+ }, [tt]);
664
+ const et = y(
665
+ (P) => {
666
+ if (!I)
657
667
  return;
658
- const { maxVelocity: E, minVelocity: O, deceleration: W, startVelocityThreshold: Z } = M, vt = gt(f, -E, E);
659
- if (Math.abs(vt) < Z)
668
+ const { maxVelocity: v, minVelocity: nt, deceleration: K, startVelocityThreshold: Z } = st, pt = mt(P, -v, v);
669
+ if (Math.abs(pt) < Z)
660
670
  return;
661
- c(), F.current.velocity = vt, F.current.lastTimestamp = null;
662
- const pt = (G) => {
663
- const tt = F.current;
664
- if (tt.lastTimestamp === null) {
665
- tt.lastTimestamp = G, tt.frame = requestAnimationFrame(pt);
671
+ tt(), N.current.velocity = pt, N.current.lastTimestamp = null;
672
+ const rt = (at) => {
673
+ const ot = N.current;
674
+ if (ot.lastTimestamp === null) {
675
+ ot.lastTimestamp = at, ot.frame = requestAnimationFrame(rt);
666
676
  return;
667
677
  }
668
- const xt = G - tt.lastTimestamp;
669
- if (tt.lastTimestamp = G, xt <= 0) {
670
- tt.frame = requestAnimationFrame(pt);
678
+ const It = at - ot.lastTimestamp;
679
+ if (ot.lastTimestamp = at, It <= 0) {
680
+ ot.frame = requestAnimationFrame(rt);
671
681
  return;
672
682
  }
673
- const st = tt.velocity;
674
- let bt = st;
675
- const Ft = W * xt;
676
- st > 0 ? bt = Math.max(0, st - Ft) : st < 0 && (bt = Math.min(0, st + Ft));
677
- const Rt = (st + bt) / 2 * xt, h = C.current;
678
- Rt !== 0 && L((It) => It + Rt);
679
- const T = C.current, { contentSize: q, viewportSize: mt } = St.current, N = Math.max(q - mt, 0);
680
- tt.velocity = bt;
681
- const At = T === h || T <= 0 && bt <= 0 || T >= N && bt >= 0;
682
- if (Math.abs(bt) < O || At) {
683
- c();
683
+ const gt = ot.velocity;
684
+ let Tt = gt;
685
+ const wt = K * It;
686
+ gt > 0 ? Tt = Math.max(0, gt - wt) : gt < 0 && (Tt = Math.min(0, gt + wt));
687
+ const Ft = (gt + Tt) / 2 * It, h = C.current;
688
+ Ft !== 0 && m((bt) => bt + Ft);
689
+ const g = C.current, { contentSize: xt, viewportSize: J } = $.current, Y = Math.max(xt - J, 0);
690
+ ot.velocity = Tt;
691
+ const Vt = g === h || g <= 0 && Tt <= 0 || g >= Y && Tt >= 0;
692
+ if (Math.abs(Tt) < nt || Vt) {
693
+ tt();
684
694
  return;
685
695
  }
686
- tt.frame = requestAnimationFrame(pt);
696
+ ot.frame = requestAnimationFrame(rt);
687
697
  };
688
- F.current.frame = requestAnimationFrame(pt);
698
+ N.current.frame = requestAnimationFrame(rt);
689
699
  },
690
- [R, M, L, c]
691
- ), ut = y(P);
692
- Y(() => {
693
- ut.current = P;
694
- }, [P]), se(() => {
695
- St.current = { contentSize: t, viewportSize: e };
696
- }, [t, e]), se(() => {
697
- if (R) {
698
- Mt.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", { contentSize: t, viewportSize: e, scrollPosition: C.current });
699
- const f = gt(t - e, 0, t);
700
- C.current > f && L(f);
700
+ [I, st, m, tt]
701
+ ), it = w(et);
702
+ O(() => {
703
+ it.current = et;
704
+ }, [et]), ne(() => {
705
+ $.current = { contentSize: t, viewportSize: e };
706
+ }, [t, e]), ne(() => {
707
+ const P = R.current;
708
+ if (!P) return;
709
+ const v = () => {
710
+ P.scrollTop !== 0 && (yt.debug("[ScrollPane] Native scroll detected, resetting to 0", { scrollTop: P.scrollTop }), P.scrollTop = 0), P.scrollLeft !== 0 && (P.scrollLeft = 0);
711
+ };
712
+ return P.addEventListener("scroll", v), () => P.removeEventListener("scroll", v);
713
+ }, []), ne(() => {
714
+ if (I) {
715
+ yt.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", { contentSize: t, viewportSize: e, scrollPosition: C.current });
716
+ const P = mt(t - e, 0, t);
717
+ C.current > P && m(P);
701
718
  } else
702
- L(0);
703
- }, [R, L, t, e]), Y(() => {
704
- const f = (O) => {
705
- if (!R)
719
+ m(0);
720
+ }, [I, m, t, e]), O(() => {
721
+ const P = (nt) => {
722
+ if (!I)
706
723
  return;
707
- O.preventDefault(), c();
708
- let W = O.deltaY;
709
- O.deltaMode === 1 ? W *= 16 : O.deltaMode === 2 && (W *= e), Q !== 1 && (W *= Q), Mt.debug("[ScrollPane] wheel event", { deltaY: W, scrollPosition: C.current, wheelSpeedMultiplier: Q }), L((Z) => Z + W);
710
- }, E = V.current;
711
- return E && E.addEventListener("wheel", f, { passive: !1 }), () => {
712
- E && E.removeEventListener("wheel", f);
724
+ nt.preventDefault(), tt();
725
+ let K = nt.deltaY;
726
+ nt.deltaMode === 1 ? K *= 16 : nt.deltaMode === 2 && (K *= e), k !== 1 && (K *= k), yt.debug("[ScrollPane] wheel event", { deltaY: K, scrollPosition: C.current, wheelSpeedMultiplier: k, deltaMode: nt.deltaMode, scrollTop: R.current?.scrollTop }), m((Z) => Z + K);
727
+ }, v = L.current;
728
+ return v && v.addEventListener("wheel", P, { passive: !1 }), () => {
729
+ v && v.removeEventListener("wheel", P);
713
730
  };
714
- }, [R, L, c, e, Q]), he(
715
- lt,
731
+ }, [I, m, tt, e, k]), xe(
732
+ F,
716
733
  () => ({
717
- scrollTo: L,
734
+ scrollTo: m,
718
735
  getScrollPosition: () => C.current,
719
736
  getContentSize: () => t,
720
737
  getViewportSize: () => e
721
738
  }),
722
- [L, t, e]
739
+ [m, t, e]
723
740
  );
724
- const it = y(L);
725
- Y(() => {
726
- it.current = L;
727
- }, [L]);
728
- const Tt = Le(), H = y({
741
+ const At = w(m);
742
+ O(() => {
743
+ At.current = m;
744
+ }, [m]);
745
+ const W = Xe(), U = w({
729
746
  pointerId: null,
730
747
  startClientY: 0,
731
748
  startScroll: 0,
@@ -733,197 +750,199 @@ const gt = (r, t, e) => Math.min(e, Math.max(t, r)), pe = "virtualscroll:tap-scr
733
750
  shouldCancelNextClick: !1,
734
751
  clickResetTimer: null,
735
752
  velocitySamples: []
736
- }), dt = y(m);
737
- Y(() => {
738
- dt.current = m;
739
- }, [m]);
740
- const ft = y(R);
741
- Y(() => {
742
- ft.current = R;
743
- }, [R]);
744
- const et = y(M);
745
- return Y(() => {
746
- et.current = M;
747
- }, [M]), Y(() => {
748
- if (m)
753
+ }), dt = w(p);
754
+ O(() => {
755
+ dt.current = p;
756
+ }, [p]);
757
+ const ft = w(I);
758
+ O(() => {
759
+ ft.current = I;
760
+ }, [I]);
761
+ const E = w(st);
762
+ return O(() => {
763
+ E.current = st;
764
+ }, [st]), O(() => {
765
+ if (p)
749
766
  return;
750
- const f = U.current, E = H.current;
751
- E.pointerId !== null && f && f.hasPointerCapture(E.pointerId) && f.releasePointerCapture(E.pointerId), E.clickResetTimer !== null && (window.clearTimeout(E.clickResetTimer), E.clickResetTimer = null), E.pointerId = null, E.startClientY = 0, E.startScroll = 0, E.isDragging = !1, E.shouldCancelNextClick = !1, E.velocitySamples = [];
752
- }, [m]), Y(() => {
753
- const f = U.current;
754
- if (!f)
767
+ const P = R.current, v = U.current;
768
+ v.pointerId !== null && P && P.hasPointerCapture(v.pointerId) && P.releasePointerCapture(v.pointerId), v.clickResetTimer !== null && (window.clearTimeout(v.clickResetTimer), v.clickResetTimer = null), v.pointerId = null, v.startClientY = 0, v.startScroll = 0, v.isDragging = !1, v.shouldCancelNextClick = !1, v.velocitySamples = [];
769
+ }, [p]), O(() => {
770
+ const P = R.current;
771
+ if (!P)
755
772
  return;
756
- const E = 6, O = () => typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now(), W = () => {
757
- const h = H.current;
773
+ const v = 6, nt = () => typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now(), K = () => {
774
+ const h = U.current;
758
775
  h.pointerId = null, h.startClientY = 0, h.startScroll = 0, h.isDragging = !1, h.velocitySamples = [];
759
776
  }, Z = () => {
760
- const h = H.current;
777
+ const h = U.current;
761
778
  h.clickResetTimer !== null && (window.clearTimeout(h.clickResetTimer), h.clickResetTimer = null);
762
- }, vt = (h) => {
763
- const T = H.current, q = O();
764
- T.velocitySamples.push({ clientY: h, time: q });
765
- const mt = et.current.velocitySampleWindow;
766
- T.velocitySamples = T.velocitySamples.filter((N) => q - N.time <= mt);
767
- }, pt = (h) => h instanceof HTMLElement && h.closest("[data-scrollpane-ignore-drag='true']") !== null, G = (h) => {
768
- const T = H.current;
769
- T.shouldCancelNextClick && (h.preventDefault(), h.stopPropagation(), T.shouldCancelNextClick = !1);
770
- }, tt = (h) => {
771
- const T = H.current;
772
- T.isDragging || (T.isDragging = !0, T.shouldCancelNextClick = !0, f.hasPointerCapture(h.pointerId) || f.setPointerCapture(h.pointerId), vt(h.clientY));
773
- }, xt = (h) => {
774
- const T = H.current;
775
- if (T.pointerId !== h.pointerId || !(dt.current && ft.current) || !T.isDragging && (Math.abs(h.clientY - T.startClientY) < E || (tt(h), !T.isDragging)))
779
+ }, pt = (h) => {
780
+ const g = U.current, xt = nt();
781
+ g.velocitySamples.push({ clientY: h, time: xt });
782
+ const J = E.current.velocitySampleWindow;
783
+ g.velocitySamples = g.velocitySamples.filter((Y) => xt - Y.time <= J);
784
+ }, rt = (h) => h instanceof HTMLElement && h.closest("[data-scrollpane-ignore-drag='true']") !== null, at = (h) => {
785
+ const g = U.current;
786
+ g.shouldCancelNextClick && (h.preventDefault(), h.stopPropagation(), g.shouldCancelNextClick = !1);
787
+ }, ot = (h) => {
788
+ const g = U.current;
789
+ g.isDragging || (g.isDragging = !0, g.shouldCancelNextClick = !0, P.hasPointerCapture(h.pointerId) || P.setPointerCapture(h.pointerId), pt(h.clientY));
790
+ }, It = (h) => {
791
+ const g = U.current;
792
+ if (g.pointerId !== h.pointerId || !(dt.current && ft.current) || !g.isDragging && (Math.abs(h.clientY - g.startClientY) < v || (ot(h), !g.isDragging)))
776
793
  return;
777
- vt(h.clientY);
778
- const q = h.clientY - T.startClientY, mt = T.startScroll - q;
779
- it.current(mt), h.cancelable && h.preventDefault();
780
- }, st = (h) => {
781
- const T = H.current;
782
- if (T.pointerId !== h.pointerId)
794
+ pt(h.clientY);
795
+ const xt = h.clientY - g.startClientY, J = g.startScroll - xt;
796
+ At.current(J), h.cancelable && h.preventDefault();
797
+ }, gt = (h) => {
798
+ const g = U.current;
799
+ if (g.pointerId !== h.pointerId)
783
800
  return;
784
- T.isDragging && T.shouldCancelNextClick && h.cancelable && (h.preventDefault(), h.stopPropagation()), f.hasPointerCapture(h.pointerId) && f.releasePointerCapture(h.pointerId);
785
- let q = 0;
786
- if (T.isDragging && T.velocitySamples.length >= 2) {
787
- const N = T.velocitySamples, At = et.current.velocitySampleWindow, It = N[N.length - 1], Xt = N.find((nt) => It.time - nt.time <= At) ?? N[0];
788
- if (It && Xt && It.time !== Xt.time) {
789
- const nt = It.clientY - Xt.clientY, Kt = It.time - Xt.time;
790
- q = -(nt / Kt);
801
+ g.isDragging && g.shouldCancelNextClick && h.cancelable && (h.preventDefault(), h.stopPropagation()), P.hasPointerCapture(h.pointerId) && P.releasePointerCapture(h.pointerId);
802
+ let xt = 0;
803
+ if (g.isDragging && g.velocitySamples.length >= 2) {
804
+ const Y = g.velocitySamples, Vt = E.current.velocitySampleWindow, bt = Y[Y.length - 1], Et = Y.find((Pt) => bt.time - Pt.time <= Vt) ?? Y[0];
805
+ if (bt && Et && bt.time !== Et.time) {
806
+ const Pt = bt.clientY - Et.clientY, Nt = bt.time - Et.time;
807
+ xt = -(Pt / Nt);
791
808
  }
792
809
  }
793
- Z(), T.shouldCancelNextClick && (T.clickResetTimer = window.setTimeout(() => {
794
- const N = H.current;
795
- N.shouldCancelNextClick = !1, N.clickResetTimer = null;
810
+ Z(), g.shouldCancelNextClick && (g.clickResetTimer = window.setTimeout(() => {
811
+ const Y = U.current;
812
+ Y.shouldCancelNextClick = !1, Y.clickResetTimer = null;
796
813
  }, 0));
797
- const mt = et.current.startVelocityThreshold;
798
- W(), Math.abs(q) >= mt && ut.current?.(q);
799
- }, bt = (h) => {
800
- if (!(dt.current && ft.current) || h.button !== 0 && h.pointerType === "mouse" || h.ctrlKey || h.metaKey || h.altKey || pt(h.target))
814
+ const J = E.current.startVelocityThreshold;
815
+ K(), Math.abs(xt) >= J && it.current?.(xt);
816
+ }, Tt = (h) => {
817
+ if (!(dt.current && ft.current) || h.button !== 0 && h.pointerType === "mouse" || h.ctrlKey || h.metaKey || h.altKey || rt(h.target))
801
818
  return;
802
- window.dispatchEvent(new CustomEvent(pe, { detail: { paneId: Tt } })), ct.current?.();
803
- const T = H.current;
804
- Z(), T.pointerId = h.pointerId, T.startClientY = h.clientY, T.startScroll = C.current, T.isDragging = !1, T.shouldCancelNextClick = !1, T.velocitySamples = [];
805
- }, Ft = (h) => {
806
- const T = H.current;
807
- T.pointerId === h.pointerId && (T.shouldCancelNextClick = !1, f.hasPointerCapture(h.pointerId) && f.releasePointerCapture(h.pointerId), Z(), W());
808
- }, Ct = [
809
- ["click", G, !0],
810
- ["pointerdown", bt, { passive: !1 }],
811
- ["pointermove", xt, { passive: !1 }],
812
- ["pointerup", st, void 0],
813
- ["pointercancel", Ft, void 0]
814
- ], Rt = [
815
- ["pointermove", xt, { passive: !1 }],
816
- ["pointerup", st, void 0],
817
- ["pointercancel", Ft, void 0]
819
+ window.dispatchEvent(new CustomEvent(he, { detail: { paneId: W } })), A.current?.();
820
+ const g = U.current;
821
+ Z(), g.pointerId = h.pointerId, g.startClientY = h.clientY, g.startScroll = C.current, g.isDragging = !1, g.shouldCancelNextClick = !1, g.velocitySamples = [];
822
+ }, wt = (h) => {
823
+ const g = U.current;
824
+ g.pointerId === h.pointerId && (g.shouldCancelNextClick = !1, P.hasPointerCapture(h.pointerId) && P.releasePointerCapture(h.pointerId), Z(), K());
825
+ }, _t = [
826
+ ["click", at, !0],
827
+ ["pointerdown", Tt, { passive: !1 }],
828
+ ["pointermove", It, { passive: !1 }],
829
+ ["pointerup", gt, void 0],
830
+ ["pointercancel", wt, void 0]
831
+ ], Ft = [
832
+ ["pointermove", It, { passive: !1 }],
833
+ ["pointerup", gt, void 0],
834
+ ["pointercancel", wt, void 0]
818
835
  ];
819
- return oe(f, Ct, "add"), oe(window, Rt, "add"), () => {
820
- oe(f, Ct, "remove"), oe(window, Rt, "remove");
821
- const h = H.current;
822
- h.pointerId !== null && f.hasPointerCapture(h.pointerId) && f.releasePointerCapture(h.pointerId), Z(), W();
836
+ return ae(P, _t, "add"), ae(window, Ft, "add"), () => {
837
+ ae(P, _t, "remove"), ae(window, Ft, "remove");
838
+ const h = U.current;
839
+ h.pointerId !== null && P.hasPointerCapture(h.pointerId) && P.releasePointerCapture(h.pointerId), Z(), K();
823
840
  };
824
- }, [Tt]), /* @__PURE__ */ Gt("div", { ref: V, className: jt("flex", u), style: p, children: [
825
- /* @__PURE__ */ Gt(
841
+ }, [W]), /* @__PURE__ */ Jt("div", { ref: L, className: Zt("flex", d), style: c, children: [
842
+ /* @__PURE__ */ Jt(
826
843
  "div",
827
844
  {
828
- ref: U,
829
- className: jt("relative h-full flex-1 overflow-hidden"),
845
+ ref: R,
846
+ className: Zt("relative h-full flex-1 overflow-hidden"),
830
847
  style: {
831
848
  height: e,
832
- paddingTop: X.top,
833
- paddingBottom: X.bottom,
834
- ...m ? { touchAction: "none" } : {}
849
+ paddingTop: ut.top,
850
+ paddingBottom: ut.bottom,
851
+ ...p ? { touchAction: "none" } : {}
835
852
  },
836
- id: Tt,
853
+ id: W,
837
854
  children: [
838
- g,
855
+ f,
839
856
  r(C.current)
840
857
  ]
841
858
  }
842
859
  ),
843
- R && /* @__PURE__ */ J(
844
- tn,
860
+ I && /* @__PURE__ */ Q(
861
+ rn,
845
862
  {
846
863
  contentSize: t,
847
864
  viewportSize: e,
848
865
  scrollPosition: C.current,
849
- onScroll: L,
866
+ onScroll: m,
850
867
  enableThumbDrag: o,
851
868
  enableTrackClick: a,
852
- enableArrowButtons: d,
869
+ enableArrowButtons: u,
853
870
  scrollBarWidth: n,
854
- ariaControls: Tt,
855
- tapScrollCircleOptions: v,
871
+ ariaControls: W,
872
+ tapScrollCircleOptions: S,
856
873
  itemCount: _,
857
- renderThumbOverlay: D
874
+ renderThumbOverlay: X,
875
+ visibleStartIndex: ht,
876
+ visibleEndIndex: H
858
877
  }
859
878
  )
860
879
  ] });
861
880
  }
862
- ), be = (r, t, e) => Math.min(Math.max(r, t), e), In = ({ dragState: r, normalizedDistance: t, sizeScale: e, size: n }) => {
863
- const o = Math.max(n / 2, 1), a = 1 + t * 0.65, d = Math.max(0.65, 1 - t * 0.25), m = r.direction * t * 26 * e, l = 0.8 + t * 0.18, u = 3 * e, p = 6 * e, g = 22 * e, v = Math.abs(m) + p, b = m > 0 ? u : -Math.abs(m) - u, _ = Math.max(2.5, 3 * e), D = be(r.offsetX, -o, o), Q = be(r.offsetY, -o, o), z = o * 0.35, lt = D / o * z, C = Q / o * z, V = lt * 0.45, U = C * 0.45, F = Math.max(g * 0.38, 6), M = 0.65 + t * 0.2, X = r.active;
864
- return /* @__PURE__ */ Gt(we, { children: [
865
- /* @__PURE__ */ J(
881
+ ), Se = (r, t, e) => Math.min(Math.max(r, t), e), Pn = ({ dragState: r, normalizedDistance: t, sizeScale: e, size: n }) => {
882
+ const o = Math.max(n / 2, 1), a = 1 + t * 0.65, u = Math.max(0.65, 1 - t * 0.25), p = r.direction * t * 26 * e, l = 0.8 + t * 0.18, d = 3 * e, c = 6 * e, f = 22 * e, S = Math.abs(p) + c, b = p > 0 ? d : -Math.abs(p) - d, _ = Math.max(2.5, 3 * e), X = Se(r.offsetX, -o, o), k = Se(r.offsetY, -o, o), B = o * 0.35, ht = X / o * B, H = k / o * B, F = ht * 0.45, C = H * 0.45, L = Math.max(f * 0.38, 6), R = 0.65 + t * 0.2, N = r.active;
883
+ return /* @__PURE__ */ Jt(we, { children: [
884
+ /* @__PURE__ */ Q(
866
885
  "div",
867
886
  {
868
887
  className: "aqvs:tap-scroll-circle-gradient absolute inset-0 rounded-full border border-white/40 shadow-md",
869
888
  style: {
870
- transform: `scale(${d}, ${a})`,
871
- transition: X ? "40ms transform ease-out" : "200ms ease transform"
889
+ transform: `scale(${u}, ${a})`,
890
+ transition: N ? "40ms transform ease-out" : "200ms ease transform"
872
891
  }
873
892
  }
874
893
  ),
875
- /* @__PURE__ */ J(
894
+ /* @__PURE__ */ Q(
876
895
  "div",
877
896
  {
878
897
  className: "absolute top-1/2 left-1/2 rounded-full border border-white/50 bg-white/85",
879
898
  style: {
880
- width: g,
881
- height: g,
882
- transform: `translate(calc(-50% + ${lt}px), calc(-50% + ${C}px)) scale(${d}, ${l * a})`,
883
- transition: X ? "70ms transform ease-out" : "200ms ease transform"
899
+ width: f,
900
+ height: f,
901
+ transform: `translate(calc(-50% + ${ht}px), calc(-50% + ${H}px)) scale(${u}, ${l * a})`,
902
+ transition: N ? "70ms transform ease-out" : "200ms ease transform"
884
903
  }
885
904
  }
886
905
  ),
887
- /* @__PURE__ */ J(
906
+ /* @__PURE__ */ Q(
888
907
  "div",
889
908
  {
890
909
  className: "absolute top-1/2 left-1/2 rounded-full bg-white/80",
891
910
  style: {
892
- width: F,
893
- height: F,
894
- transform: `translate(calc(-50% + ${V}px), calc(-50% + ${U}px)) scale(${d}, ${a})`,
895
- opacity: M,
911
+ width: L,
912
+ height: L,
913
+ transform: `translate(calc(-50% + ${F}px), calc(-50% + ${C}px)) scale(${u}, ${a})`,
914
+ opacity: R,
896
915
  boxShadow: "0 0 8px rgba(255,255,255,0.45)",
897
- transition: X ? "120ms opacity 150ms, 120ms transform ease-out ease-out" : "220ms ease transform, 240ms opacity ease"
916
+ transition: N ? "120ms opacity 150ms, 120ms transform ease-out ease-out" : "220ms ease transform, 240ms opacity ease"
898
917
  }
899
918
  }
900
919
  ),
901
- /* @__PURE__ */ J(
920
+ /* @__PURE__ */ Q(
902
921
  "div",
903
922
  {
904
923
  className: "absolute top-1/2 left-1/2 rounded-full bg-white/50",
905
924
  style: {
906
925
  width: _,
907
- height: v,
926
+ height: S,
908
927
  transform: `translate(-50%, ${b}px)`,
909
928
  opacity: t,
910
- transition: X ? "40ms height, 60ms opacity ease-out ease-out" : "200ms ease height, 120ms ease opacity"
929
+ transition: N ? "40ms height, 60ms opacity ease-out ease-out" : "200ms ease height, 120ms ease opacity"
911
930
  }
912
931
  }
913
932
  )
914
933
  ] });
915
- }, nn = (r) => {
934
+ }, sn = (r) => {
916
935
  if (!Number.isFinite(r))
917
936
  return 0n;
918
937
  const t = Math.trunc(r);
919
938
  return t <= 0 ? 0n : BigInt(t);
920
- }, ie = (r) => {
939
+ }, le = (r) => {
921
940
  if (r <= 0 || !Number.isFinite(r))
922
941
  return 0;
923
942
  const t = Math.trunc(r), e = BigInt(t) & -BigInt(t);
924
943
  return Number(e);
925
944
  };
926
- class rn {
945
+ class an {
927
946
  /**
928
947
  * @private
929
948
  * @property {Map<number, number>} tree - The Map storing the Fenwick tree structure, specifically the sums of deltas. It is 1-indexed.
@@ -980,14 +999,14 @@ class rn {
980
999
  const a = n?.sampleRange ?? {
981
1000
  from: 0,
982
1001
  to: Math.min(99, this.size - 1)
983
- }, { mode: d, materializedValues: m } = this._calculateMode(a.from, a.to);
984
- if (this.baseValue = d, n?.materialize)
985
- for (let l = 0; l < m.length; l++) {
986
- const u = m[l], p = a.from + l;
987
- if (p >= this.size)
1002
+ }, { mode: u, materializedValues: p } = this._calculateMode(a.from, a.to);
1003
+ if (this.baseValue = u, n?.materialize)
1004
+ for (let l = 0; l < p.length; l++) {
1005
+ const d = p[l], c = a.from + l;
1006
+ if (c >= this.size)
988
1007
  break;
989
- const g = u - this.baseValue;
990
- this.deltas.set(p, g), this._updateTree(p, g);
1008
+ const f = d - this.baseValue;
1009
+ this.deltas.set(c, f), this._updateTree(c, f);
991
1010
  }
992
1011
  } else
993
1012
  this.baseValue = 0;
@@ -1017,29 +1036,29 @@ class rn {
1017
1036
  if (!this.valueFn)
1018
1037
  return { mode: 0, materializedValues: [] };
1019
1038
  const n = [];
1020
- for (let u = t; u <= e && !(u >= this.size); u++)
1021
- n.push(this.valueFn(u));
1039
+ for (let d = t; d <= e && !(d >= this.size); d++)
1040
+ n.push(this.valueFn(d));
1022
1041
  const o = [...n];
1023
1042
  if (n.length === 0)
1024
1043
  return { mode: 0, materializedValues: [] };
1025
- n.sort((u, p) => u - p);
1044
+ n.sort((d, c) => d - c);
1026
1045
  const a = Math.floor(n.length / 2);
1027
- let d;
1028
- n.length % 2 === 0 ? d = Math.floor((n[a - 1] + n[a]) / 2) : d = n[a];
1029
- const m = /* @__PURE__ */ new Map();
1046
+ let u;
1047
+ n.length % 2 === 0 ? u = Math.floor((n[a - 1] + n[a]) / 2) : u = n[a];
1048
+ const p = /* @__PURE__ */ new Map();
1030
1049
  let l = 0;
1031
- for (const u of n) {
1032
- const p = (m.get(u) ?? 0) + 1;
1033
- m.set(u, p), p > l && (l = p);
1050
+ for (const d of n) {
1051
+ const c = (p.get(d) ?? 0) + 1;
1052
+ p.set(d, c), c > l && (l = c);
1034
1053
  }
1035
- if (l > 1) {
1036
- const u = [];
1037
- for (const [g, v] of m.entries())
1038
- v === l && u.push(g);
1039
- const p = u.reduce((g, v) => g + v, 0);
1040
- d = Math.floor(p / u.length);
1054
+ if (l > n.length * 0.2) {
1055
+ const d = [];
1056
+ for (const [f, S] of p.entries())
1057
+ S === l && d.push(f);
1058
+ const c = d.reduce((f, S) => f + S, 0);
1059
+ u = Math.floor(c / d.length);
1041
1060
  }
1042
- return { mode: d, materializedValues: o };
1061
+ return { mode: u, materializedValues: o };
1043
1062
  }
1044
1063
  /**
1045
1064
  * @method update
@@ -1100,7 +1119,7 @@ class rn {
1100
1119
  let n = t + 1;
1101
1120
  for (; n <= this.size; ) {
1102
1121
  this.tree.set(n, (this.tree.get(n) ?? 0) + e);
1103
- const o = ie(n);
1122
+ const o = le(n);
1104
1123
  if (o === 0)
1105
1124
  break;
1106
1125
  n += o;
@@ -1122,8 +1141,8 @@ class rn {
1122
1141
  throw new Error(`Index ${n} out of bounds`);
1123
1142
  if (o < 0)
1124
1143
  throw new Error("Value cannot be negative.");
1125
- const a = this.deltas.has(n) ? (this.deltas.get(n) ?? 0) + this.baseValue : this.baseValue, d = o - a;
1126
- d !== 0 && e.push({ index: n, change: d });
1144
+ const a = this.deltas.has(n) ? (this.deltas.get(n) ?? 0) + this.baseValue : this.baseValue, u = o - a;
1145
+ u !== 0 && e.push({ index: n, change: u });
1127
1146
  }
1128
1147
  return e;
1129
1148
  }
@@ -1140,7 +1159,7 @@ class rn {
1140
1159
  let t = 0, e = this.size;
1141
1160
  for (; e > 0; ) {
1142
1161
  t += this.tree.get(e) ?? 0;
1143
- const n = ie(e);
1162
+ const n = le(e);
1144
1163
  if (n === 0)
1145
1164
  break;
1146
1165
  e -= n;
@@ -1159,8 +1178,8 @@ class rn {
1159
1178
  if (this.valueFn) {
1160
1179
  const n = this.deltas.get(t) ?? 0, a = this.valueFn(t) - this.baseValue;
1161
1180
  if (a !== n && (this.deltas.set(t, a), e)) {
1162
- const d = a - n;
1163
- this._updateTree(t, d);
1181
+ const u = a - n;
1182
+ this._updateTree(t, u);
1164
1183
  }
1165
1184
  }
1166
1185
  }
@@ -1178,10 +1197,10 @@ class rn {
1178
1197
  return;
1179
1198
  const o = t.ranges;
1180
1199
  if (o && o.length > 0) {
1181
- for (const m of o) {
1182
- const l = m.from, u = Math.min(m.to, this.size - 1);
1183
- for (let p = l; p <= u; p++)
1184
- this._materialize(p);
1200
+ for (const p of o) {
1201
+ const l = p.from, d = Math.min(p.to, this.size - 1);
1202
+ for (let c = l; c <= d; c++)
1203
+ this._materialize(c);
1185
1204
  }
1186
1205
  if (e === void 0)
1187
1206
  return;
@@ -1189,8 +1208,8 @@ class rn {
1189
1208
  this._materialize(e);
1190
1209
  return;
1191
1210
  }
1192
- const a = o[0].from, d = o[o.length - 1].to;
1193
- e >= a && e <= d && this._materialize(e);
1211
+ const a = o[0].from, u = o[o.length - 1].to;
1212
+ e >= a && e <= u && this._materialize(e);
1194
1213
  return;
1195
1214
  }
1196
1215
  e !== void 0 && this._materialize(e);
@@ -1210,12 +1229,13 @@ class rn {
1210
1229
  return this._findIndexLarge(t, e, n);
1211
1230
  if (this.size === 0)
1212
1231
  return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
1213
- let o = 0, a = this.size - 1, d = -1, m, l = this.total;
1232
+ let o = 0, a = this.size - 1, u = -1, p, l, d = this.total;
1214
1233
  for (; o <= a; ) {
1215
- const u = Math.floor((o + a) / 2);
1216
- m = this.prefixSum(u, e), l = m.total, (n ? m.cumulative >= t : m.cumulative <= t) ? (d = u, n ? a = u - 1 : o = u + 1) : n ? o = u + 1 : a = u - 1;
1234
+ const f = Math.floor((o + a) / 2);
1235
+ p = this.prefixSum(f, e), d = p.total, (n ? p.cumulative >= t : p.cumulative <= t) ? (u = f, l = p, n ? a = f - 1 : o = f + 1) : n ? o = f + 1 : a = f - 1;
1217
1236
  }
1218
- return { index: d, total: l, cumulative: m?.cumulative, currentValue: m?.currentValue, safeIndex: m?.safeIndex };
1237
+ const c = l ?? p;
1238
+ return { index: u, total: d, cumulative: c?.cumulative, currentValue: c?.currentValue, safeIndex: c?.safeIndex };
1219
1239
  }
1220
1240
  /**
1221
1241
  * Executes a binary search using bigint arithmetic for extremely large sizes.
@@ -1225,17 +1245,17 @@ class rn {
1225
1245
  _findIndexLarge(t, e, n) {
1226
1246
  if (this.size === 0)
1227
1247
  return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
1228
- const o = nn(this.size);
1248
+ const o = sn(this.size);
1229
1249
  if (o === 0n)
1230
1250
  return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
1231
- let a = 0n, d = o - 1n, m, l, u, p = this.total;
1232
- for (; a <= d; ) {
1233
- const b = a + d >> 1n, _ = Number(b), D = this.prefixSum(_, e);
1234
- if (u = D, p = D.total, n ? D.cumulative >= t : D.cumulative <= t)
1235
- if (m = b, l = D, n) {
1251
+ let a = 0n, u = o - 1n, p, l, d, c = this.total;
1252
+ for (; a <= u; ) {
1253
+ const b = a + u >> 1n, _ = Number(b), X = this.prefixSum(_, e);
1254
+ if (d = X, c = X.total, n ? X.cumulative >= t : X.cumulative <= t)
1255
+ if (p = b, l = X, n) {
1236
1256
  if (b === 0n)
1237
1257
  break;
1238
- d = b - 1n;
1258
+ u = b - 1n;
1239
1259
  } else
1240
1260
  a = b + 1n;
1241
1261
  else if (n)
@@ -1243,16 +1263,16 @@ class rn {
1243
1263
  else {
1244
1264
  if (b === 0n)
1245
1265
  break;
1246
- d = b - 1n;
1266
+ u = b - 1n;
1247
1267
  }
1248
1268
  }
1249
- const g = l ?? u;
1269
+ const f = l ?? d;
1250
1270
  return {
1251
- index: m !== void 0 ? Number(m) : -1,
1252
- total: p,
1253
- cumulative: g?.cumulative,
1254
- currentValue: g?.currentValue,
1255
- safeIndex: g?.safeIndex
1271
+ index: p !== void 0 ? Number(p) : -1,
1272
+ total: c,
1273
+ cumulative: f?.cumulative,
1274
+ currentValue: f?.currentValue,
1275
+ safeIndex: f?.safeIndex
1256
1276
  };
1257
1277
  }
1258
1278
  /**
@@ -1266,19 +1286,19 @@ class rn {
1266
1286
  prefixSum(t, e) {
1267
1287
  if (t < 0)
1268
1288
  return { cumulative: 0, total: this.total, currentValue: 0, safeIndex: 0 };
1269
- const n = gt(t, 0, this.size - 1), o = e?.materializeOption;
1289
+ const n = mt(t, 0, this.size - 1), o = e?.materializeOption;
1270
1290
  this._materializeRanges(o, n, !0);
1271
- let a = 0, d = n + 1;
1272
- for (; d > 0; ) {
1273
- const l = this.tree.get(d) ?? 0;
1291
+ let a = 0, u = n + 1;
1292
+ for (; u > 0; ) {
1293
+ const l = this.tree.get(u) ?? 0;
1274
1294
  a += l;
1275
- const u = ie(d);
1276
- if (u === 0)
1295
+ const d = le(u);
1296
+ if (d === 0)
1277
1297
  break;
1278
- d -= u;
1298
+ u -= d;
1279
1299
  }
1280
- const m = o?.materialize ? this.get(n) : (this.deltas.get(n) || 0) + this.baseValue;
1281
- return { cumulative: a + this.baseValue * (n + 1), total: this.total, currentValue: m, safeIndex: n };
1300
+ const p = o?.materialize ? this.get(n) : (this.deltas.get(n) || 0) + this.baseValue;
1301
+ return { cumulative: a + this.baseValue * (n + 1), total: this.total, currentValue: p, safeIndex: n };
1282
1302
  }
1283
1303
  /**
1284
1304
  * @method get
@@ -1333,10 +1353,10 @@ class rn {
1333
1353
  let a = n + 1;
1334
1354
  for (; a <= this.size; ) {
1335
1355
  e.set(a, (e.get(a) ?? 0) + o);
1336
- const d = ie(a);
1337
- if (d === 0)
1356
+ const u = le(a);
1357
+ if (u === 0)
1338
1358
  break;
1339
- a += d;
1359
+ a += u;
1340
1360
  }
1341
1361
  }
1342
1362
  this.tree = e, this.total = this._computeTreeTotal();
@@ -1410,11 +1430,11 @@ class rn {
1410
1430
  return this._findIndex(t, e ?? {}, !1);
1411
1431
  }
1412
1432
  }
1413
- const on = (r, t, e) => {
1414
- const n = Math.max(0, r), o = y(null), a = Vt(() => new rn(n, t, e), [n, t, e]);
1433
+ const ln = (r, t, e) => {
1434
+ const n = Math.max(0, r), o = w(null), a = Dt(() => new an(n, t, e), [n, t, e]);
1415
1435
  return Object.is(o.current, a) || console.warn("[useFenwickMapTree] instance changed"), o.current = a, a;
1416
1436
  };
1417
- class sn {
1437
+ class cn {
1418
1438
  key;
1419
1439
  value;
1420
1440
  prev = null;
@@ -1423,7 +1443,7 @@ class sn {
1423
1443
  this.key = t, this.value = e;
1424
1444
  }
1425
1445
  }
1426
- class Pe {
1446
+ class ve {
1427
1447
  head = null;
1428
1448
  tail = null;
1429
1449
  /**
@@ -1464,484 +1484,495 @@ class Pe {
1464
1484
  this.remove(t), this.addToTail(t);
1465
1485
  }
1466
1486
  }
1467
- function an(r) {
1468
- const t = y(/* @__PURE__ */ new Map()), e = y(new Pe());
1469
- Y(() => {
1487
+ function un(r) {
1488
+ const t = w(/* @__PURE__ */ new Map()), e = w(new ve());
1489
+ O(() => {
1470
1490
  for (; t.current.size > r; ) {
1471
- const p = e.current.removeHead();
1472
- if (p)
1473
- t.current.delete(p.key);
1491
+ const c = e.current.removeHead();
1492
+ if (c)
1493
+ t.current.delete(c.key);
1474
1494
  else
1475
1495
  break;
1476
1496
  }
1477
1497
  }, [r]);
1478
- const n = w((p) => {
1479
- const g = t.current.get(p);
1480
- if (g)
1481
- return e.current.moveToTail(g), g.value;
1482
- }, []), o = w(
1483
- (p, g) => {
1498
+ const n = y((c) => {
1499
+ const f = t.current.get(c);
1500
+ if (f)
1501
+ return e.current.moveToTail(f), f.value;
1502
+ }, []), o = y(
1503
+ (c, f) => {
1484
1504
  if (r <= 0)
1485
1505
  return;
1486
- let v = t.current.get(p);
1487
- if (v)
1488
- v.value = g, e.current.moveToTail(v);
1506
+ let S = t.current.get(c);
1507
+ if (S)
1508
+ S.value = f, e.current.moveToTail(S);
1489
1509
  else {
1490
1510
  if (t.current.size >= r) {
1491
1511
  const b = e.current.removeHead();
1492
1512
  b && t.current.delete(b.key);
1493
1513
  }
1494
- v = new sn(p, g), t.current.set(p, v), e.current.addToTail(v);
1514
+ S = new cn(c, f), t.current.set(c, S), e.current.addToTail(S);
1495
1515
  }
1496
1516
  },
1497
1517
  [r]
1498
- ), a = w((p) => t.current.has(p), []), d = w((p) => {
1499
- const g = t.current.get(p);
1500
- g && (e.current.remove(g), t.current.delete(p));
1501
- }, []), m = w(() => {
1502
- t.current.clear(), e.current = new Pe();
1503
- }, []), [l, u] = Ot(() => ({ get: n, set: o, has: a, remove: d, clear: m }));
1504
- return Y(() => u({ get: n, set: o, has: a, remove: d, clear: m }), [n, o, a, d, m]), l;
1518
+ ), a = y((c) => t.current.has(c), []), u = y((c) => {
1519
+ const f = t.current.get(c);
1520
+ f && (e.current.remove(f), t.current.delete(c));
1521
+ }, []), p = y(() => {
1522
+ t.current.clear(), e.current = new ve();
1523
+ }, []), [l, d] = Xt(() => ({ get: n, set: o, has: a, remove: u, clear: p }));
1524
+ return O(() => d({ get: n, set: o, has: a, remove: u, clear: p }), [n, o, a, u, p]), l;
1505
1525
  }
1506
- const ln = 1e4, Tn = () => {
1507
- const { get: r, set: t, has: e, clear: n } = an(ln);
1526
+ const dn = 1e4, Sn = () => {
1527
+ const { get: r, set: t, has: e, clear: n } = un(dn);
1508
1528
  return { get: r, set: t, has: e, clear: n };
1509
- }, ot = (r, t) => t <= 0 ? 0 : gt(r, 0, t - 1), cn = (r) => ({
1529
+ }, ct = (r, t) => t <= 0 ? 0 : mt(r, 0, t - 1), fn = (r) => ({
1510
1530
  top: Math.max(0, r?.top ?? 0),
1511
1531
  bottom: Math.max(0, r?.bottom ?? 0)
1512
- }), qt = (r, t) => r <= t ? 0 : r - t, ee = (r, t) => r <= 0 ? t : r + t, Se = (r) => {
1532
+ }), Wt = (r, t) => r <= t ? 0 : r - t, ee = (r, t) => r <= 0 ? t : r + t, Me = (r) => {
1513
1533
  if (!Number.isFinite(r))
1514
1534
  return 0n;
1515
1535
  const t = Math.trunc(r);
1516
1536
  return t <= 0 ? 0n : BigInt(t);
1517
- }, un = (r, t, e, n, o, a, d, m) => {
1518
- const l = Se(n);
1537
+ }, pn = (r, t, e, n, o, a, u, p) => {
1538
+ const l = Me(n);
1519
1539
  if (l === 0n)
1520
1540
  return { renderingStartIndex: 0, renderingEndIndex: 0, visibleStartIndex: 0, visibleEndIndex: 0 };
1521
- const u = (V) => V < 0n ? 0n : V >= l ? l - 1n : V, p = { materializeOption: { materialize: !1 } }, { index: g } = a.findIndexAtOrAfter(r, p);
1522
- let v;
1523
- g === -1 ? v = l - 1n : (v = Se(g), v >= l && (v = l - 1n)), r <= 0 && (v = 0n), m && r >= d && (v = l - 1n);
1524
- const b = (V) => {
1525
- let U = 0, F = V, M = V, X = 0n;
1526
- for (; F < l && U < t; ) {
1527
- const St = Number(F), R = o(St);
1528
- if (U += R, M = F, F += 1n, X += 1n, !Number.isFinite(R) || R <= 0)
1541
+ const d = (F) => F < 0n ? 0n : F >= l ? l - 1n : F, c = { materializeOption: { materialize: !1 } }, { index: f } = a.findIndexAtOrAfter(r, c);
1542
+ let S;
1543
+ f === -1 ? S = l - 1n : (S = Me(f), S >= l && (S = l - 1n)), r <= 0 && (S = 0n), p && r >= u && (S = l - 1n);
1544
+ const b = (F) => {
1545
+ let C = 0, L = F, R = F, N = 0n;
1546
+ for (; L < l && C < t; ) {
1547
+ const st = Number(L), ut = o(st);
1548
+ if (C += ut, R = L, L += 1n, N += 1n, !Number.isFinite(ut) || ut <= 0)
1529
1549
  break;
1530
1550
  }
1531
- return X === 0n && (M = V), { height: U, end: M };
1551
+ return N === 0n && (R = F), { height: C, end: R };
1532
1552
  };
1533
- let { height: _, end: D } = b(v);
1534
- if (_ < t && v > 0n) {
1535
- let V = v, U = _;
1536
- for (; V > 0n && U < t; ) {
1537
- V -= 1n;
1538
- const M = Number(V), X = o(M);
1539
- if (U += X, !Number.isFinite(X) || X <= 0)
1553
+ let { height: _, end: X } = b(S);
1554
+ if (_ < t && S > 0n) {
1555
+ let F = S, C = _;
1556
+ for (; F > 0n && C < t; ) {
1557
+ F -= 1n;
1558
+ const R = Number(F), N = o(R);
1559
+ if (C += N, !Number.isFinite(N) || N <= 0)
1540
1560
  break;
1541
1561
  }
1542
- v = u(V);
1543
- const F = b(v);
1544
- _ = F.height, D = F.end;
1562
+ S = d(F);
1563
+ const L = b(S);
1564
+ _ = L.height, X = L.end;
1545
1565
  }
1546
- const Q = u(v), z = u(D), lt = u(Q - BigInt(Math.max(0, e))), C = u(z + BigInt(Math.max(0, e)));
1566
+ const k = d(S), B = d(X), ht = d(k - BigInt(Math.max(0, e))), H = d(B + BigInt(Math.max(0, e)));
1547
1567
  return {
1548
- renderingStartIndex: ot(Number(lt), n),
1549
- renderingEndIndex: ot(Number(C), n),
1550
- visibleStartIndex: ot(Number(Q), n),
1551
- visibleEndIndex: ot(Number(z), n)
1568
+ renderingStartIndex: ct(Number(ht), n),
1569
+ renderingEndIndex: ct(Number(H), n),
1570
+ visibleStartIndex: ct(Number(k), n),
1571
+ visibleEndIndex: ct(Number(B), n)
1552
1572
  };
1553
- }, dn = (r, t, e, n, o, a) => {
1573
+ }, mn = (r, t, e, n, o, a, u) => {
1554
1574
  if (n === 0)
1555
1575
  return { renderingStartIndex: 0, renderingEndIndex: 0, visibleStartIndex: 0, visibleEndIndex: 0 };
1556
- const d = a.getTotal(), m = Number.isFinite(d), l = m ? Math.min(r, d) : r;
1557
- if (n > Number.MAX_SAFE_INTEGER)
1558
- return un(l, t, e, n, o, a, d, m);
1559
- const { index: u, cumulative: p, currentValue: g } = a.findIndexAtOrAfter(l, { materializeOption: { materialize: !1 } }), v = u === -1 ? t <= 0 || (p ?? 0) < l + (g ?? 0) ? n - 1 : 0 : u;
1560
- let b = ot(v, n), _ = 0, D = b;
1561
- for (; D < n && _ < t; )
1562
- _ += o(D), D++;
1576
+ const p = Number.isFinite(u), l = p ? Math.min(Math.max(0, r), u) : Math.max(0, r);
1577
+ if (n >= Number.MAX_SAFE_INTEGER)
1578
+ return pn(l, t, e, n, o, a, u, p);
1579
+ const { index: d, cumulative: c, currentValue: f } = a.findIndexAtOrAfter(l, { materializeOption: { materialize: !1 } }), S = d === -1 ? t <= 0 || (c ?? 0) < l + (f ?? 0) ? n - 1 : 0 : d;
1580
+ let b = ct(S, n), _ = 0;
1581
+ if (b === d && c !== void 0 && f !== void 0)
1582
+ _ = c - f - l;
1583
+ else {
1584
+ const { cumulative: F, currentValue: C } = a.prefixSum(b, { materializeOption: { materialize: !1 } });
1585
+ _ = (F ?? 0) - (C ?? 0) - l;
1586
+ }
1587
+ const X = _;
1588
+ let k = b;
1589
+ for (; k < n && _ < t; )
1590
+ _ += o(k), k++;
1563
1591
  if (_ < t && b > 0) {
1564
- let C = _, V = b - 1;
1565
- for (; V >= 0 && C < t; )
1566
- C += o(V), V--;
1567
- for (b = ot(V + 1, n), _ = 0, D = b; D < n && _ < t; )
1568
- _ += o(D), D++;
1592
+ let F = _ + Math.abs(Math.min(0, X)), C = b - 1;
1593
+ for (; C >= 0 && F < t; )
1594
+ F += o(C), C--;
1595
+ for (b = ct(C + 1, n), _ = 0, k = b; k < n && _ < t; )
1596
+ _ += o(k), k++;
1569
1597
  }
1570
- const Q = ot(b - e, n), z = ot(Math.max(D - 1, b), n), lt = ot(z + e, n);
1571
- return { renderingStartIndex: Q, renderingEndIndex: lt, visibleStartIndex: b, visibleEndIndex: z };
1572
- }, fn = () => typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now(), ve = (r, t, e) => {
1573
- const n = Math.max(0, t ?? 0), o = y({
1598
+ const B = ct(b - e, n), ht = ct(Math.max(k - 1, b), n), H = ct(ht + e, n);
1599
+ return { renderingStartIndex: B, renderingEndIndex: H, visibleStartIndex: b, visibleEndIndex: ht };
1600
+ }, hn = () => typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now(), ye = (r, t, e) => {
1601
+ const n = Math.max(0, t ?? 0), o = w({
1574
1602
  lastInvokeAt: 0,
1575
1603
  rafId: null,
1576
1604
  pendingPayload: null,
1577
1605
  loopActive: !1,
1578
1606
  normalizedThrottle: n
1579
- }), a = w(() => {
1607
+ }), a = y(() => {
1580
1608
  const l = o.current;
1581
1609
  l.rafId !== null && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(l.rafId), l.rafId = null, l.loopActive = !1;
1582
- }, []), d = w(
1610
+ }, []), u = y(
1583
1611
  (l) => {
1584
- const u = o.current;
1585
- u.rafId = null;
1586
- const p = typeof l == "number" ? l : fn(), g = u.normalizedThrottle, v = u.pendingPayload, b = r.current;
1587
- if (v !== null && b) {
1588
- const _ = p - u.lastInvokeAt;
1589
- (g === 0 || u.lastInvokeAt === 0 || _ >= g) && (u.pendingPayload = null, u.lastInvokeAt = p, e(b, v));
1612
+ const d = o.current;
1613
+ d.rafId = null;
1614
+ const c = typeof l == "number" ? l : hn(), f = d.normalizedThrottle, S = d.pendingPayload, b = r.current;
1615
+ if (S !== null && b) {
1616
+ const _ = c - d.lastInvokeAt;
1617
+ (f === 0 || d.lastInvokeAt === 0 || _ >= f) && (d.pendingPayload = null, d.lastInvokeAt = c, e(b, S));
1590
1618
  }
1591
- if (u.pendingPayload !== null) {
1592
- typeof requestAnimationFrame == "function" ? u.rafId = requestAnimationFrame(d) : u.loopActive = !1;
1619
+ if (d.pendingPayload !== null) {
1620
+ typeof requestAnimationFrame == "function" ? d.rafId = requestAnimationFrame(u) : d.loopActive = !1;
1593
1621
  return;
1594
1622
  }
1595
- u.loopActive = !1;
1623
+ d.loopActive = !1;
1596
1624
  },
1597
1625
  [r, e]
1598
- ), m = w(() => {
1626
+ ), p = y(() => {
1599
1627
  const l = o.current;
1600
1628
  if (!l.loopActive) {
1601
1629
  if (l.loopActive = !0, typeof requestAnimationFrame == "function") {
1602
- l.rafId = requestAnimationFrame(d);
1630
+ l.rafId = requestAnimationFrame(u);
1603
1631
  return;
1604
1632
  }
1605
1633
  l.loopActive = !1;
1606
1634
  }
1607
- }, [d]);
1608
- return Y(() => () => {
1635
+ }, [u]);
1636
+ return O(() => () => {
1609
1637
  a(), o.current.pendingPayload = null;
1610
- }, [a]), Y(() => {
1638
+ }, [a]), O(() => {
1611
1639
  a();
1612
1640
  const l = o.current;
1613
1641
  l.lastInvokeAt = 0, l.pendingPayload = null, l.normalizedThrottle = n;
1614
- }, [n, a]), w(
1642
+ }, [n, a]), y(
1615
1643
  (l) => {
1616
- const u = o.current;
1617
- u.pendingPayload = l, m();
1644
+ const d = o.current;
1645
+ d.pendingPayload = l, p();
1618
1646
  },
1619
- [m]
1647
+ [p]
1620
1648
  );
1621
- }, pn = ({
1649
+ }, gn = ({
1622
1650
  itemCount: r,
1623
1651
  getItem: t,
1624
1652
  getItemHeight: e,
1625
1653
  viewportSize: n,
1626
1654
  overscanCount: o = 15,
1627
1655
  className: a,
1628
- onScroll: d,
1629
- onRangeChange: m,
1656
+ onScroll: u,
1657
+ onRangeChange: p,
1630
1658
  children: l,
1631
- background: u,
1632
- initialScrollIndex: p,
1633
- initialScrollOffset: g,
1634
- tapScrollCircleOptions: v,
1659
+ background: d,
1660
+ initialScrollIndex: c,
1661
+ initialScrollOffset: f,
1662
+ tapScrollCircleOptions: S,
1635
1663
  scrollBarWidth: b,
1636
1664
  enableThumbDrag: _,
1637
- enableTrackClick: D,
1638
- enableArrowButtons: Q,
1639
- enablePointerDrag: z,
1640
- inertiaOptions: lt,
1641
- callbackThrottleMs: C = 5,
1642
- renderThumbOverlay: V,
1643
- wheelSpeedMultiplier: U,
1644
- contentInsets: F,
1645
- enableKeyboardNavigation: M = !0,
1646
- onItemFocus: X
1647
- }, St) => {
1648
- const R = y(null), L = y(!1), c = Vt(() => cn(F), [F]), ct = y({ size: r, valueOrFn: e, options: { sampleRange: { from: 0, to: 100 } } }), P = on(ct.current.size, ct.current.valueOrFn, ct.current.options), [ut] = Ot(() => {
1649
- let s = c.top, I = 0;
1650
- if (typeof p == "number") {
1651
- const S = gt(p, 0, r - 1), k = gt(S - o * 2, 0, r - 1), $ = gt(S + o * 2, 0, r - 1), K = p > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: k, to: $ }] } } : void 0, { cumulative: yt, total: Lt, currentValue: Et } = P.prefixSum(p, K), Yt = Math.max(yt - Et, 0);
1652
- s = ee(Yt, c.top), I = Lt ?? P.getTotal();
1653
- } else typeof g == "number" && (s = ee(Math.max(g, 0), c.top)), I = P.getTotal();
1654
- return { position: s, total: I };
1655
- }), [it, Tt] = Ot(ut.position), [H, dt] = Ot(ut.total), [ft, et] = Ot(ut.position), [f, E] = Ot(r), O = y(ut.position), W = y(c.top), Z = y(d ?? void 0), vt = y(m ?? void 0), pt = y(/* @__PURE__ */ new Map()), G = y(null), tt = y(null);
1656
- Y(() => {
1657
- Z.current = d ?? void 0, vt.current = m ?? void 0;
1658
- }, [m, d]);
1659
- const xt = w(
1660
- (s) => {
1661
- if (M && s && typeof s.focus == "function")
1665
+ enableTrackClick: X,
1666
+ enableArrowButtons: k,
1667
+ enablePointerDrag: B,
1668
+ inertiaOptions: ht,
1669
+ callbackThrottleMs: H = 5,
1670
+ renderThumbOverlay: F,
1671
+ wheelSpeedMultiplier: C,
1672
+ contentInsets: L,
1673
+ enableKeyboardNavigation: R = !0,
1674
+ onItemFocus: N,
1675
+ clipItemHeight: st = !1
1676
+ }, ut) => {
1677
+ const $ = w(null), I = w(!1), m = Dt(() => fn(L), [L]), tt = w({ size: r, valueOrFn: e, options: { sampleRange: { from: 0, to: 100 } } }), A = ln(tt.current.size, tt.current.valueOrFn, tt.current.options), [et] = Xt(() => {
1678
+ let i = m.top, T = 0;
1679
+ if (typeof c == "number") {
1680
+ const M = mt(c, 0, r - 1), D = mt(M - o * 2, 0, r - 1), q = mt(M + o * 2, 0, r - 1), j = c > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: D, to: q }] } } : void 0, { cumulative: Rt, total: Ht, currentValue: Ot } = A.prefixSum(c, j), Ut = Math.max(Rt - Ot, 0);
1681
+ i = ee(Ut, m.top), T = Ht ?? A.getTotal();
1682
+ } else typeof f == "number" && (i = ee(Math.max(f, 0), m.top)), T = A.getTotal();
1683
+ return { position: i, total: T };
1684
+ }), [it, At] = Xt(et.position), [W, U] = Xt(et.total), [dt, ft] = Xt(et.position), [E, P] = Xt(r), v = w(et.position), nt = w(m.top), K = w(u ?? void 0), Z = w(p ?? void 0), pt = w(/* @__PURE__ */ new Map()), rt = w(null), at = w(null);
1685
+ O(() => {
1686
+ K.current = u ?? void 0, Z.current = p ?? void 0;
1687
+ }, [p, u]);
1688
+ const ot = y(
1689
+ (i) => {
1690
+ if (R && i && typeof i.focus == "function")
1662
1691
  try {
1663
- s.focus({ preventScroll: !0 });
1692
+ i.focus({ preventScroll: !0 });
1664
1693
  } catch {
1665
- s.focus();
1694
+ i.focus();
1666
1695
  }
1667
1696
  },
1668
- [M]
1669
- ), st = ve(Z, C, (s, { position: I, totalHeight: S }) => {
1670
- s(I, S);
1671
- }), bt = ve(vt, C, (s, { renderingStartIndex: I, renderingEndIndex: S, visibleStartIndex: k, visibleEndIndex: $, scrollPosition: K, totalHeight: yt }) => {
1672
- s(I, S, k, $, K, yt);
1697
+ [R]
1698
+ ), It = ye(K, H, (i, { position: T, totalHeight: M }) => {
1699
+ i(T, M);
1700
+ }), gt = ye(Z, H, (i, { renderingStartIndex: T, renderingEndIndex: M, visibleStartIndex: D, visibleEndIndex: q, scrollPosition: j, totalHeight: Rt }) => {
1701
+ i(T, M, D, q, j, Rt);
1673
1702
  });
1674
- Y(() => (L.current = !0, () => {
1675
- L.current = !1;
1676
- }), []), Y(() => {
1677
- M || (pt.current.clear(), G.current = null, tt.current = null);
1678
- }, [M]);
1679
- const Ft = 0.01, Ct = y({
1703
+ O(() => (I.current = !0, () => {
1704
+ I.current = !1;
1705
+ }), []), O(() => {
1706
+ R || (pt.current.clear(), rt.current = null, at.current = null);
1707
+ }, [R]);
1708
+ const Tt = 0.01, wt = w({
1680
1709
  rafId: null,
1681
1710
  loopActive: !1,
1682
1711
  idleFrames: 0,
1683
- lastRenderedPosition: ut.position
1684
- }), Rt = w(() => {
1685
- const s = Ct.current;
1686
- s.rafId !== null && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(s.rafId), s.rafId = null, s.loopActive = !1, s.idleFrames = 0;
1712
+ lastRenderedPosition: et.position
1713
+ }), _t = y(() => {
1714
+ const i = wt.current;
1715
+ i.rafId !== null && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(i.rafId), i.rafId = null, i.loopActive = !1, i.idleFrames = 0;
1687
1716
  }, []);
1688
- Y(
1717
+ O(
1689
1718
  () => () => {
1690
- Rt();
1719
+ _t();
1691
1720
  },
1692
- [Rt]
1721
+ [_t]
1693
1722
  );
1694
- const h = w(() => {
1695
- const s = Ct.current;
1696
- s.rafId = null;
1697
- const I = O.current, S = qt(I, c.top), k = P.getTotal();
1698
- if (Tt((K) => Math.abs(K - I) < Ft ? K : I), st({ position: S, totalHeight: k }), Math.abs(s.lastRenderedPosition - I) >= Ft ? (s.lastRenderedPosition = I, s.idleFrames = 0) : s.idleFrames += 1, s.idleFrames >= 2) {
1699
- Rt();
1723
+ const Ft = y(() => {
1724
+ const i = wt.current;
1725
+ i.rafId = null;
1726
+ const T = v.current, M = Wt(T, m.top), D = A.getTotal();
1727
+ if (At((j) => Math.abs(j - T) < Tt ? j : T), It({ position: M, totalHeight: D }), Math.abs(i.lastRenderedPosition - T) >= Tt ? (i.lastRenderedPosition = T, i.idleFrames = 0) : i.idleFrames += 1, i.idleFrames >= 2) {
1728
+ _t();
1700
1729
  return;
1701
1730
  }
1702
1731
  if (typeof requestAnimationFrame == "function") {
1703
- s.rafId = requestAnimationFrame(h);
1732
+ i.rafId = requestAnimationFrame(Ft);
1704
1733
  return;
1705
1734
  }
1706
- s.loopActive = !1;
1707
- }, [P, c.top, st, Rt]), T = w(() => {
1708
- const s = Ct.current;
1709
- if (s.idleFrames = 0, !s.loopActive) {
1710
- if (s.loopActive = !0, typeof requestAnimationFrame == "function") {
1711
- s.rafId = requestAnimationFrame(h);
1735
+ i.loopActive = !1;
1736
+ }, [A, m.top, It, _t]), h = y(() => {
1737
+ const i = wt.current;
1738
+ if (i.idleFrames = 0, !i.loopActive) {
1739
+ if (i.loopActive = !0, typeof requestAnimationFrame == "function") {
1740
+ i.rafId = requestAnimationFrame(Ft);
1712
1741
  return;
1713
1742
  }
1714
- s.loopActive = !1;
1743
+ i.loopActive = !1;
1715
1744
  }
1716
- }, [h]), q = w(
1717
- (s, I) => {
1718
- const S = I?.immediate ?? !1, k = qt(s, c.top);
1719
- if (O.current = s, S) {
1720
- Ct.current.lastRenderedPosition = s, Ct.current.idleFrames = 0, Tt(s), st({ position: k, totalHeight: P.getTotal() });
1745
+ }, [Ft]), g = y(
1746
+ (i, T) => {
1747
+ const M = T?.immediate ?? !1, D = Wt(i, m.top);
1748
+ if (v.current = i, M) {
1749
+ wt.current.lastRenderedPosition = i, wt.current.idleFrames = 0, At(i), It({ position: D, totalHeight: A.getTotal() });
1721
1750
  return;
1722
1751
  }
1723
- T();
1752
+ h();
1724
1753
  },
1725
- [T, P, c.top, st]
1726
- ), mt = y(!1);
1727
- Y(() => {
1728
- if (!mt.current)
1729
- if (mt.current = !0, typeof g == "number") {
1730
- const s = ee(Math.max(g, 0), c.top), I = Math.abs(s - O.current) > 0.5;
1731
- q(s, { immediate: !0 }), I && et(s);
1754
+ [h, A, m.top, It]
1755
+ ), xt = w(!1);
1756
+ O(() => {
1757
+ if (!xt.current)
1758
+ if (xt.current = !0, typeof f == "number") {
1759
+ const i = ee(Math.max(f, 0), m.top), T = Math.abs(i - v.current) > 0.5;
1760
+ g(i, { immediate: !0 }), T && ft(i);
1732
1761
  } else
1733
- q(O.current, { immediate: !0 });
1734
- }, [g, c.top, q]), se(() => {
1735
- P.setValueFn(e), f !== r && (P.changeSize(r), E(r));
1736
- const s = P.getTotal();
1737
- H !== s && dt(s);
1738
- }, [P, f, r, H, e]), se(() => {
1739
- ft !== null && R.current && (Mt.debug("[VirtualScroll] Scrolling to position:", ft), R.current.scrollTo(ft), et(null));
1740
- }, [ft]), Y(() => {
1741
- const s = W.current;
1742
- if (s === c.top)
1762
+ g(v.current, { immediate: !0 });
1763
+ }, [f, m.top, g]), ne(() => {
1764
+ A.setValueFn(e), E !== r && (A.changeSize(r), P(r));
1765
+ const i = A.getTotal();
1766
+ W !== i && U(i);
1767
+ }, [A, E, r, W, e]), ne(() => {
1768
+ dt !== null && $.current && (yt.debug("[VirtualScroll] Scrolling to position:", dt), $.current.scrollTo(dt), ft(null));
1769
+ }, [dt]), O(() => {
1770
+ const i = nt.current;
1771
+ if (i === m.top)
1743
1772
  return;
1744
- const I = qt(O.current, s), S = ee(I, c.top);
1745
- W.current = c.top, O.current = S, et(S), q(S, { immediate: !0 });
1746
- }, [c.top, q]);
1747
- const N = w(
1748
- (s) => {
1749
- if (!R.current)
1773
+ const T = Wt(v.current, i), M = ee(T, m.top);
1774
+ nt.current = m.top, v.current = M, ft(M), g(M, { immediate: !0 });
1775
+ }, [m.top, g]);
1776
+ const J = y(
1777
+ (i) => {
1778
+ if (!$.current)
1750
1779
  return;
1751
- const I = ot(s, f), S = ot(I - o * 2, f), k = ot(I + o * 2, f), { cumulative: $, total: K, currentValue: yt } = P.prefixSum(I, { materializeOption: { materialize: !0, ranges: [{ from: S, to: k }] } });
1752
- if (Mt.debug("[VirtualScroll] Scrolling to index:", I, "Offset:", $, "Total height:", K, "Current value:", yt, "safeIndexFrom:", S, "safeIndexTo:", k), !K)
1780
+ const T = ct(i, E), M = ct(T - o * 2, E), D = ct(T + o * 2, E), { cumulative: q, total: j, currentValue: Rt } = A.prefixSum(T, { materializeOption: { materialize: !0, ranges: [{ from: M, to: D }] } });
1781
+ if (yt.debug("[VirtualScroll] Scrolling to index:", T, "Offset:", q, "Total height:", j, "Current value:", Rt, "safeIndexFrom:", M, "safeIndexTo:", D), !j)
1753
1782
  return;
1754
- const Lt = Math.max($ - yt, 0), Et = ee(Lt, c.top);
1755
- dt(K), et(Et), Mt.debug("[VirtualScroll] Setting scroll position to:", Et);
1783
+ const Ht = Math.max(q - Rt, 0), Ot = ee(Ht, m.top);
1784
+ U(j), ft(Ot), yt.debug("[VirtualScroll] Setting scroll position to:", Ot);
1756
1785
  },
1757
- [P, o, f, c.top]
1758
- ), At = w(
1759
- (s) => {
1760
- if (!R.current)
1786
+ [A, o, E, m.top]
1787
+ ), Y = y(
1788
+ (i) => {
1789
+ if (!$.current)
1761
1790
  return;
1762
- const I = P.getTotal(), S = gt(Math.floor(s), 0, I), k = P.findIndexAtOrAfter(S, { materializeOption: { materialize: !1 } }).index;
1763
- N(k);
1791
+ const T = A.getTotal(), M = mt(Math.floor(i), 0, T), D = A.findIndexAtOrAfter(M, { materializeOption: { materialize: !1 } }).index;
1792
+ J(D);
1764
1793
  },
1765
- [P, N]
1766
- ), It = w(
1767
- (s) => {
1768
- const I = qt(O.current, c.top), S = typeof s == "function" ? s(I) : s;
1769
- At(S);
1770
- const k = R.current?.getScrollPosition(), $ = typeof k == "number" ? k : O.current;
1771
- return q($), $;
1794
+ [A, J]
1795
+ ), Vt = y(
1796
+ (i) => {
1797
+ const T = Wt(v.current, m.top), M = typeof i == "function" ? i(T) : i;
1798
+ Y(M);
1799
+ const D = $.current?.getScrollPosition(), q = typeof D == "number" ? D : v.current;
1800
+ return g(q), q;
1772
1801
  },
1773
- [c.top, At, q]
1774
- ), Xt = w(
1775
- (s, I) => {
1776
- Mt.debug("[VirtualScroll] Scroll position changed:", s), q(s);
1802
+ [m.top, Y, g]
1803
+ ), bt = y(
1804
+ (i, T) => {
1805
+ yt.debug("[VirtualScroll] Scroll position changed:", i), g(i);
1777
1806
  },
1778
- [q]
1779
- ), nt = Vt(() => qt(it, c.top), [c.top, it]), Kt = Vt(() => {
1780
- const s = dn(nt, n, o, f, e, P);
1781
- return Mt.debug("[VirtualScroll] Calculated rendering range:", {
1782
- ...s,
1783
- scrollPosition: nt,
1784
- renderingContentSize: P.getTotal(),
1807
+ [g]
1808
+ ), Et = Dt(() => Wt(it, m.top), [m.top, it]), Pt = Dt(() => {
1809
+ const i = mn(Et, n, o, E, e, A, W);
1810
+ return yt.debug("[VirtualScroll] Calculated rendering range:", {
1811
+ ...i,
1812
+ scrollPosition: Et,
1813
+ renderingContentSize: A.getTotal(),
1785
1814
  overscanCount: o,
1786
1815
  viewportSize: n
1787
- }), s;
1788
- }, [nt, n, o, f, e, P]), { renderingStartIndex: Ht, renderingEndIndex: wt, visibleStartIndex: Nt, visibleEndIndex: at } = Kt, rt = w(
1789
- (s, I) => {
1790
- if (!M || f === 0)
1816
+ }), i;
1817
+ }, [Et, n, o, E, e, A, W]), { renderingStartIndex: Nt, renderingEndIndex: Bt, visibleStartIndex: St, visibleEndIndex: kt } = Pt, lt = y(
1818
+ (i, T) => {
1819
+ if (!R || E === 0)
1791
1820
  return;
1792
- const S = ot(s, f);
1793
- if (!(I?.ensureVisible ?? !0)) {
1794
- const Wt = pt.current.get(S);
1795
- Wt && (G.current = null, tt.current = S, xt(Wt));
1821
+ const M = ct(i, E);
1822
+ if (!(T?.ensureVisible ?? !0)) {
1823
+ const Gt = pt.current.get(M);
1824
+ Gt && (rt.current = null, at.current = M, ot(Gt));
1796
1825
  return;
1797
1826
  }
1798
- const $ = P.prefixSum(S, { materializeOption: { materialize: !1 } }), K = $.currentValue, yt = Math.max($.cumulative - K, 0), Lt = yt + K, Et = qt(O.current, c.top), Yt = Et + n;
1799
- if (yt < Et || Lt > Yt) {
1800
- G.current = S, N(S);
1827
+ const q = A.prefixSum(M, { materializeOption: { materialize: !1 } }), j = q.currentValue, Rt = Math.max(q.cumulative - j, 0), Ht = Rt + j, Ot = Wt(v.current, m.top), Ut = Ot + n;
1828
+ if (Rt < Ot || Ht > Ut) {
1829
+ rt.current = M, J(M);
1801
1830
  return;
1802
1831
  }
1803
- const zt = pt.current.get(S);
1804
- if (zt) {
1805
- G.current = null, tt.current = S, xt(zt);
1832
+ const qt = pt.current.get(M);
1833
+ if (qt) {
1834
+ rt.current = null, at.current = M, ot(qt);
1806
1835
  return;
1807
1836
  }
1808
- G.current = S;
1837
+ rt.current = M;
1809
1838
  },
1810
- [M, f, P, c.top, N, xt, n]
1811
- ), Bt = w(
1812
- (s, I) => {
1813
- if (!M || s.defaultPrevented || s.altKey || s.metaKey || s.ctrlKey)
1839
+ [R, E, A, m.top, J, ot, n]
1840
+ ), Ct = y(
1841
+ (i, T) => {
1842
+ if (!R || i.defaultPrevented || i.altKey || i.metaKey || i.ctrlKey)
1814
1843
  return;
1815
- const S = s.target;
1816
- if (S) {
1817
- const k = S.tagName;
1818
- if (k === "INPUT" || k === "TEXTAREA" || k === "SELECT" || S.isContentEditable)
1844
+ const M = i.target;
1845
+ if (M) {
1846
+ const D = M.tagName;
1847
+ if (D === "INPUT" || D === "TEXTAREA" || D === "SELECT" || M.isContentEditable)
1819
1848
  return;
1820
1849
  }
1821
- if (s.key === "ArrowDown") {
1822
- I < f - 1 && (s.preventDefault(), rt(I + 1));
1850
+ if (i.key === "ArrowDown") {
1851
+ T < E - 1 && (i.preventDefault(), lt(T + 1));
1823
1852
  return;
1824
1853
  }
1825
- if (s.key === "ArrowUp") {
1826
- I > 0 && (s.preventDefault(), rt(I - 1));
1854
+ if (i.key === "ArrowUp") {
1855
+ T > 0 && (i.preventDefault(), lt(T - 1));
1827
1856
  return;
1828
1857
  }
1829
- if (s.key === "PageDown") {
1830
- if (I < f - 1) {
1831
- s.preventDefault();
1832
- const k = Math.max(at - Nt + 1, 1), $ = Math.max(k, 1), K = ot(Math.min(I + $, f - 1), f);
1833
- rt(K);
1858
+ if (i.key === "PageDown") {
1859
+ if (T < E - 1) {
1860
+ i.preventDefault();
1861
+ const D = Math.max(kt - St + 1, 1), q = Math.max(D, 1), j = ct(Math.min(T + q, E - 1), E);
1862
+ lt(j);
1834
1863
  }
1835
1864
  return;
1836
1865
  }
1837
- if (s.key === "PageUp" && I > 0) {
1838
- s.preventDefault();
1839
- const k = Math.max(at - Nt + 1, 1), $ = Math.max(k, 1), K = ot(I - $, f);
1840
- rt(K);
1866
+ if (i.key === "PageUp" && T > 0) {
1867
+ i.preventDefault();
1868
+ const D = Math.max(kt - St + 1, 1), q = Math.max(D, 1), j = ct(T - q, E);
1869
+ lt(j);
1841
1870
  }
1842
1871
  },
1843
- [M, f, rt, at, Nt]
1844
- ), Zt = w(
1845
- (s) => {
1846
- if (!M)
1872
+ [R, E, lt, kt, St]
1873
+ ), Kt = y(
1874
+ (i) => {
1875
+ if (!R)
1847
1876
  return;
1848
- const I = ot(s, f);
1849
- G.current = null, tt.current = I, X?.(I);
1877
+ const T = ct(i, E);
1878
+ rt.current = null, at.current = T, N?.(T);
1850
1879
  },
1851
- [M, f, X]
1880
+ [R, E, N]
1852
1881
  );
1853
- Y(() => {
1854
- const s = R.current?.getScrollPosition() ?? 0, I = O.current, S = qt(I, c.top);
1855
- Mt.debug("[VirtualScroll] Range change effect triggered", {
1856
- renderingStartIndex: Ht,
1857
- renderingEndIndex: wt,
1858
- visibleStartIndex: Nt,
1859
- visibleEndIndex: at,
1882
+ O(() => {
1883
+ const i = $.current?.getScrollPosition() ?? 0, T = v.current, M = Wt(T, m.top);
1884
+ yt.debug("[VirtualScroll] Range change effect triggered", {
1885
+ renderingStartIndex: Nt,
1886
+ renderingEndIndex: Bt,
1887
+ visibleStartIndex: St,
1888
+ visibleEndIndex: kt,
1860
1889
  scrollPositionState: it,
1861
- paneScrollPosition: I,
1862
- logicalScrollPosition: S,
1863
- contentSize: H,
1864
- scrollPaneScrollPosition: s
1865
- }), bt({
1866
- renderingStartIndex: Ht,
1867
- renderingEndIndex: wt,
1868
- visibleStartIndex: Nt,
1869
- visibleEndIndex: at,
1870
- scrollPosition: S,
1871
- totalHeight: H
1890
+ paneScrollPosition: T,
1891
+ logicalScrollPosition: M,
1892
+ contentSize: W,
1893
+ scrollPaneScrollPosition: i
1894
+ }), gt({
1895
+ renderingStartIndex: Nt,
1896
+ renderingEndIndex: Bt,
1897
+ visibleStartIndex: St,
1898
+ visibleEndIndex: kt,
1899
+ scrollPosition: M,
1900
+ totalHeight: W
1872
1901
  });
1873
- }, [H, wt, Ht, c.top, bt, it, at, Nt]);
1874
- const ae = w(
1875
- (s) => {
1876
- const I = (C ?? 0) > 0, S = Math.abs(s - it), k = I && S > 0.5 ? it : s, $ = qt(k, c.top);
1877
- if (Mt.debug("[VirtualScroll] Rendering visible items", {
1878
- currentScrollPosition: s,
1879
- effectiveScrollPosition: $,
1880
- renderingStartIndex: Ht,
1881
- renderingEndIndex: wt,
1882
- fenwickSize: f,
1902
+ }, [W, Bt, Nt, m.top, gt, it, kt, St]);
1903
+ const re = y(
1904
+ (i) => {
1905
+ const T = (H ?? 0) > 0, M = Math.abs(i - it), D = T && M > 0.5 ? it : i, q = Wt(D, m.top);
1906
+ if (yt.debug("[VirtualScroll] Rendering visible items", {
1907
+ currentScrollPosition: i,
1908
+ effectiveScrollPosition: q,
1909
+ renderingStartIndex: Nt,
1910
+ renderingEndIndex: Bt,
1911
+ fenwickSize: E,
1883
1912
  viewportSize: n,
1884
- callbackThrottleMs: C,
1885
- diff: S,
1886
- rawEffectiveScrollPosition: k
1887
- }), f === 0)
1888
- return /* @__PURE__ */ J("div", { className: "absolute w-full", style: { top: 0 }, children: /* @__PURE__ */ J("div", { className: "text-center text-gray-500", children: "No items" }) });
1889
- const K = ot(Ht, f), yt = ot(wt, f), { cumulative: Lt, currentValue: Et } = P.prefixSum(K, { materializeOption: { materialize: !1 } }), Yt = Lt - Et, $t = [], zt = [];
1890
- for (let B = K; B <= yt; B++) {
1891
- const Ut = e(B);
1892
- P.get(B) !== Ut && $t.push({ index: B, value: Ut });
1893
- const { cumulative: i, currentValue: x } = P.prefixSum(B, { materializeOption: { materialize: !1 } }), A = i - x, ht = (j) => {
1894
- if (!j) {
1895
- pt.current.delete(B);
1913
+ callbackThrottleMs: H,
1914
+ diff: M,
1915
+ rawEffectiveScrollPosition: D
1916
+ }), E === 0)
1917
+ return /* @__PURE__ */ Q("div", { className: "absolute w-full", style: { top: 0 }, children: /* @__PURE__ */ Q("div", { className: "text-center text-gray-500", children: "No items" }) });
1918
+ const j = ct(Nt, E), Rt = ct(Bt, E), { cumulative: Ht, currentValue: Ot } = A.prefixSum(j, { materializeOption: { materialize: !1 } }), Ut = Ht - Ot, jt = [], qt = [];
1919
+ for (let z = j; z <= Rt; z++) {
1920
+ const $t = e(z);
1921
+ A.get(z) !== $t && jt.push({ index: z, value: $t });
1922
+ const { cumulative: oe, currentValue: s } = A.prefixSum(z, { materializeOption: { materialize: !1 } }), x = oe - s, V = (G) => {
1923
+ if (!G) {
1924
+ pt.current.delete(z);
1896
1925
  return;
1897
1926
  }
1898
- M && (pt.current.set(B, j), G.current === B && (G.current = null, tt.current = B, xt(j)));
1927
+ R && (pt.current.set(z, G), rt.current === z && (rt.current = null, at.current = z, ot(G)));
1899
1928
  };
1900
- zt.push(
1901
- /* @__PURE__ */ J(
1929
+ qt.push(
1930
+ /* @__PURE__ */ Q(
1902
1931
  "div",
1903
1932
  {
1904
- ref: ht,
1905
- "data-index": B,
1933
+ ref: V,
1934
+ "data-index": z,
1906
1935
  "data-virtualscroll-item": "true",
1907
1936
  style: {
1908
1937
  position: "absolute",
1909
- top: A - Yt + c.top,
1910
- width: "100%"
1938
+ top: x - Ut + m.top,
1939
+ width: "100%",
1940
+ height: $t,
1941
+ overflow: st ? "hidden" : void 0
1911
1942
  },
1912
- tabIndex: M ? -1 : void 0,
1913
- onPointerDown: M ? (j) => {
1914
- j.currentTarget.focus({ preventScroll: !0 });
1943
+ tabIndex: R ? -1 : void 0,
1944
+ onPointerDown: R ? (G) => {
1945
+ G.currentTarget.focus({ preventScroll: !0 });
1915
1946
  } : void 0,
1916
- onKeyDownCapture: M ? (j) => Bt(j, B) : void 0,
1917
- onFocusCapture: M ? () => Zt(B) : void 0,
1918
- children: l(t(B), B)
1947
+ onKeyDownCapture: R ? (G) => Ct(G, z) : void 0,
1948
+ onFocusCapture: R ? () => Kt(z) : void 0,
1949
+ children: l(t(z), z)
1919
1950
  },
1920
- B
1951
+ z
1921
1952
  )
1922
1953
  );
1923
1954
  }
1924
- $t.length > 0 && Promise.resolve().then(() => {
1925
- if (!L.current)
1955
+ jt.length > 0 && Promise.resolve().then(() => {
1956
+ if (!I.current)
1926
1957
  return;
1927
- const B = P.updates($t);
1928
- if (!L.current || typeof B != "number")
1958
+ const z = A.updates(jt);
1959
+ if (!I.current || typeof z != "number")
1929
1960
  return;
1930
- dt(B), Mt.debug("[VirtualScroll] Updated heights for items", $t, "New total height:", B);
1931
- const Ut = R.current?.getScrollPosition() ?? O.current;
1932
- Ut === O.current || !L.current || q(Ut);
1961
+ U(z), yt.debug("[VirtualScroll] Updated heights for items", jt, "New total height:", z);
1962
+ const $t = $.current?.getScrollPosition() ?? v.current;
1963
+ $t === v.current || !I.current || g($t);
1933
1964
  });
1934
- const Wt = Yt - $;
1935
- if (c.bottom > 0) {
1936
- const B = P.getTotal() + c.top - Yt;
1937
- zt.push(
1938
- /* @__PURE__ */ J(
1965
+ const Gt = Ut - q;
1966
+ if (m.bottom > 0) {
1967
+ const z = A.getTotal() + m.top - Ut;
1968
+ qt.push(
1969
+ /* @__PURE__ */ Q(
1939
1970
  "div",
1940
1971
  {
1941
1972
  style: {
1942
1973
  position: "absolute",
1943
- top: B,
1944
- height: c.bottom,
1974
+ top: z,
1975
+ height: m.bottom,
1945
1976
  width: "100%"
1946
1977
  }
1947
1978
  },
@@ -1949,81 +1980,84 @@ const ln = 1e4, Tn = () => {
1949
1980
  )
1950
1981
  );
1951
1982
  }
1952
- return Mt.debug("[VirtualScroll] Rendering items", {
1953
- nodeCount: zt.length,
1954
- containerTop: Wt,
1955
- logicalScrollPosition: nt,
1956
- resolvedInsets: c,
1957
- effectiveScrollPosition: $
1958
- }), /* @__PURE__ */ J("div", { className: "absolute w-full", style: { top: Wt }, children: zt });
1983
+ return yt.debug("[VirtualScroll] Rendering items", {
1984
+ nodeCount: qt.length,
1985
+ containerTop: Gt,
1986
+ logicalScrollPosition: Et,
1987
+ resolvedInsets: m,
1988
+ effectiveScrollPosition: q
1989
+ }), /* @__PURE__ */ Q("div", { className: "absolute w-full", style: { top: Gt }, children: qt });
1959
1990
  },
1960
1991
  [
1961
- C,
1992
+ H,
1962
1993
  l,
1963
- M,
1964
- P,
1965
- f,
1994
+ R,
1995
+ A,
1996
+ E,
1966
1997
  t,
1967
1998
  e,
1968
- Zt,
1999
+ Kt,
2000
+ Ct,
2001
+ Et,
1969
2002
  Bt,
1970
- nt,
1971
- wt,
1972
- Ht,
1973
- c,
2003
+ Nt,
2004
+ m,
1974
2005
  it,
1975
- xt,
1976
- q,
1977
- n
2006
+ ot,
2007
+ g,
2008
+ n,
2009
+ st
1978
2010
  ]
1979
2011
  );
1980
- he(
1981
- St,
2012
+ xe(
2013
+ ut,
1982
2014
  () => ({
1983
- getScrollPosition: () => R.current?.getScrollPosition() ?? -1,
1984
- getContentSize: () => R.current?.getContentSize() ?? -1,
1985
- getViewportSize: () => R.current?.getViewportSize() ?? -1,
1986
- scrollTo: It,
1987
- scrollToIndex: N,
1988
- getFenwickTreeTotalHeight: () => P.getTotal(),
1989
- getFenwickSize: () => P.getSize(),
1990
- focusItemAtIndex: rt
2015
+ getScrollPosition: () => $.current?.getScrollPosition() ?? -1,
2016
+ getContentSize: () => $.current?.getContentSize() ?? -1,
2017
+ getViewportSize: () => $.current?.getViewportSize() ?? -1,
2018
+ scrollTo: Vt,
2019
+ scrollToIndex: J,
2020
+ getFenwickTreeTotalHeight: () => A.getTotal(),
2021
+ getFenwickSize: () => A.getSize(),
2022
+ focusItemAtIndex: lt
1991
2023
  }),
1992
- [It, N, P, rt]
2024
+ [Vt, J, A, lt]
1993
2025
  );
1994
- const Jt = H + c.top + c.bottom;
1995
- return /* @__PURE__ */ J(
1996
- en,
2026
+ const ce = W + m.top + m.bottom;
2027
+ return /* @__PURE__ */ Q(
2028
+ on,
1997
2029
  {
1998
- ref: R,
1999
- contentSize: Jt,
2030
+ ref: $,
2031
+ contentSize: ce,
2000
2032
  viewportSize: n,
2001
2033
  className: a,
2002
- onScroll: Xt,
2003
- background: u,
2004
- tapScrollCircleOptions: v,
2005
- inertiaOptions: lt,
2034
+ onScroll: bt,
2035
+ background: d,
2036
+ tapScrollCircleOptions: S,
2037
+ inertiaOptions: ht,
2006
2038
  itemCount: r,
2007
2039
  scrollBarWidth: b,
2008
2040
  enableThumbDrag: _,
2009
- enableTrackClick: D,
2010
- enableArrowButtons: Q,
2011
- enablePointerDrag: z,
2012
- renderThumbOverlay: V,
2013
- wheelSpeedMultiplier: U,
2014
- contentInsets: c,
2015
- children: ae
2041
+ enableTrackClick: X,
2042
+ enableArrowButtons: k,
2043
+ enablePointerDrag: B,
2044
+ renderThumbOverlay: F,
2045
+ wheelSpeedMultiplier: C,
2046
+ contentInsets: m,
2047
+ visibleStartIndex: St,
2048
+ visibleEndIndex: kt,
2049
+ children: re
2016
2050
  }
2017
2051
  );
2018
- }, bn = me(pn);
2052
+ }, vn = ge(gn);
2019
2053
  export {
2020
- rn as FenwickMapTree,
2021
- tn as ScrollBar,
2022
- en as ScrollPane,
2023
- bn as VirtualScroll,
2024
- gt as minmax,
2025
- In as tapScrollCircleSampleVisual,
2026
- on as useFenwickMapTree,
2027
- Tn as useHeightCache,
2028
- an as useLruCache
2054
+ an as FenwickMapTree,
2055
+ rn as ScrollBar,
2056
+ on as ScrollPane,
2057
+ vn as VirtualScroll,
2058
+ mt as minmax,
2059
+ Pn as tapScrollCircleSampleVisual,
2060
+ ln as useFenwickMapTree,
2061
+ Sn as useHeightCache,
2062
+ un as useLruCache
2029
2063
  };