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