@caspeco/casper-ui-library 11.1.0 → 11.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@ function m({ useFlushSync: e = !0, directDomUpdates: t = !1, directDomUpdatesMod
14
14
  prevRange: null
15
15
  });
16
16
  o.current.enabled = t, o.current.mode = n;
17
- let s = (e) => {
17
+ let s = d.useRef(!1), c = (e) => {
18
18
  let t = o.current;
19
19
  if (!t.enabled || !t.container) return;
20
20
  let n = e.getTotalSize();
@@ -23,34 +23,41 @@ function m({ useFlushSync: e = !0, directDomUpdates: t = !1, directDomUpdatesMod
23
23
  let r = e.options.horizontal ? "width" : "height";
24
24
  t.container.style[r] = `${n}px`;
25
25
  }
26
- }, c = (e) => {
26
+ }, l = (e) => {
27
27
  let t = o.current;
28
28
  if (!t.enabled || !t.container) return;
29
- s(e);
30
- let n = !!e.options.horizontal, r = t.mode === "transform", i = n ? "left" : "top", a = e.options.scrollMargin, c = e.getVirtualItems();
31
- for (let o of c) {
29
+ c(e);
30
+ let n = !!e.options.horizontal, r = t.mode === "transform", i = n ? "left" : "top", a = e.options.scrollMargin, s = e.getVirtualItems();
31
+ for (let o of s) {
32
32
  let s = o.start - a, c = e.elementsCache.get(o.key);
33
33
  c && t.lastPositions.get(c) !== s && (t.lastPositions.set(c, s), r ? c.style.transform = n ? `translate3d(${s}px, 0, 0)` : `translate3d(0, ${s}px, 0)` : c.style[i] = `${s}px`);
34
34
  }
35
- }, l = {
35
+ }, u = {
36
36
  ...r,
37
37
  onChange: (t, n) => {
38
38
  var i;
39
- let s = o.current, l = !0;
40
- if (s.enabled) {
41
- c(t);
42
- let e = t.range, n = s.prevRange;
43
- l = !n || n.isScrolling !== t.isScrolling || n.startIndex !== e?.startIndex || n.endIndex !== e?.endIndex, l && (s.prevRange = e ? {
39
+ let c = o.current, u = !0;
40
+ if (c.enabled) {
41
+ l(t);
42
+ let e = t.range, n = c.prevRange;
43
+ u = !n || n.isScrolling !== t.isScrolling || n.startIndex !== e?.startIndex || n.endIndex !== e?.endIndex, u && (c.prevRange = e ? {
44
44
  startIndex: e.startIndex,
45
45
  endIndex: e.endIndex,
46
46
  isScrolling: t.isScrolling
47
47
  } : null);
48
48
  }
49
- l && (e && n ? f(a) : a()), (i = r.onChange) == null || i.call(r, t, n);
49
+ u && (e && n && !s.current ? f(a) : a()), (i = r.onChange) == null || i.call(r, t, n);
50
50
  }
51
- }, [u] = d.useState(() => {
52
- let e = new i(l);
53
- return Object.assign(e, { containerRef: (t) => {
51
+ }, [m] = d.useState(() => {
52
+ let e = new i(u), t = e.measureElement;
53
+ return e.measureElement = (e) => {
54
+ s.current = !0;
55
+ try {
56
+ t(e);
57
+ } finally {
58
+ s.current = !1;
59
+ }
60
+ }, Object.assign(e, { containerRef: (t) => {
54
61
  let n = o.current;
55
62
  if (n.container = t, n.lastSize = null, t && n.enabled) {
56
63
  let r = e.getTotalSize();
@@ -60,9 +67,9 @@ function m({ useFlushSync: e = !0, directDomUpdates: t = !1, directDomUpdatesMod
60
67
  }
61
68
  } });
62
69
  });
63
- return u.setOptions(l), p(() => u._didMount(), []), p(() => (s(u), u._willUpdate())), p(() => {
64
- c(u);
65
- }), u;
70
+ return m.setOptions(u), p(() => m._didMount(), []), p(() => (c(m), m._willUpdate())), p(() => {
71
+ l(m);
72
+ }), m;
66
73
  }
67
74
  function h(e) {
68
75
  return m({
@@ -1,23 +1,23 @@
1
- import { createLazyMeasurementsView as e } from "./lazy-measurements.js";
2
- import { approxEqual as t, debounce as n, memo as r, notUndefined as i } from "./utils.js";
1
+ import { createLazyMeasurementsView as e, getMeasurementKey as t } from "./lazy-measurements.js";
2
+ import { approxEqual as n, debounce as r, memo as i, notUndefined as a } from "./utils.js";
3
3
  //#region ../../node_modules/@tanstack/virtual-core/dist/esm/index.js
4
- var a, o = () => {
5
- if (a !== void 0) return a;
6
- if (typeof navigator > "u") return a = !1;
7
- if (/iP(hone|od|ad)/.test(navigator.userAgent)) return a = !0;
4
+ var o, s = () => {
5
+ if (o !== void 0) return o;
6
+ if (typeof navigator > "u") return o = !1;
7
+ if (/iP(hone|od|ad)/.test(navigator.userAgent)) return o = !0;
8
8
  let e = navigator.maxTouchPoints;
9
- return a = navigator.platform === "MacIntel" && e !== void 0 && e > 0;
10
- }, s = (e) => {
9
+ return o = navigator.platform === "MacIntel" && e !== void 0 && e > 0;
10
+ }, c = (e) => {
11
11
  let { offsetWidth: t, offsetHeight: n } = e;
12
12
  return {
13
13
  width: t,
14
14
  height: n
15
15
  };
16
- }, c = (e) => e, l = (e) => {
16
+ }, l = (e) => e, u = (e) => {
17
17
  let t = Math.max(e.startIndex - e.overscan, 0), n = Math.min(e.endIndex + e.overscan, e.count - 1) - t + 1, r = Array(n);
18
18
  for (let e = 0; e < n; e++) r[e] = t + e;
19
19
  return r;
20
- }, u = (e, t) => {
20
+ }, d = (e, t) => {
21
21
  let n = e.scrollElement;
22
22
  if (!n) return;
23
23
  let r = e.targetWindow;
@@ -29,7 +29,7 @@ var a, o = () => {
29
29
  height: Math.round(r)
30
30
  });
31
31
  };
32
- if (i(s(n)), !r.ResizeObserver) return () => {};
32
+ if (i(c(n)), !r.ResizeObserver) return () => {};
33
33
  let a = new r.ResizeObserver((t) => {
34
34
  let r = () => {
35
35
  let e = t[0];
@@ -43,28 +43,28 @@ var a, o = () => {
43
43
  return;
44
44
  }
45
45
  }
46
- i(s(n));
46
+ i(c(n));
47
47
  };
48
48
  e.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(r) : r();
49
49
  });
50
50
  return a.observe(n, { box: "border-box" }), () => {
51
51
  a.unobserve(n);
52
52
  };
53
- }, d = { passive: !0 }, f = typeof window > "u" || "onscrollend" in window, p = (e, t, r) => {
53
+ }, f = { passive: !0 }, p = typeof window > "u" || "onscrollend" in window, m = (e, t, n) => {
54
54
  let i = e.scrollElement;
55
55
  if (!i) return;
56
56
  let a = e.targetWindow;
57
57
  if (!a) return;
58
- let o = e.options.useScrollendEvent && f, s = 0, c = o ? null : n(a, () => t(s, !1), e.options.isScrollingResetDelay), l = (e) => () => {
59
- s = r(i), c?.(), t(s, e);
60
- }, u = l(!0), p = l(!1);
61
- return i.addEventListener("scroll", u, d), o && i.addEventListener("scrollend", p, d), () => {
62
- i.removeEventListener("scroll", u), o && i.removeEventListener("scrollend", p), c?.cancel();
58
+ let o = e.options.useScrollendEvent && p, s = 0, c = o ? null : r(a, () => t(n(i), !1), e.options.isScrollingResetDelay), l = (e) => () => {
59
+ s = n(i), c?.(), t(s, e);
60
+ }, u = l(!0), d = l(!1);
61
+ return i.addEventListener("scroll", u, f), o && i.addEventListener("scrollend", d, f), () => {
62
+ i.removeEventListener("scroll", u), o && i.removeEventListener("scrollend", d), c?.cancel();
63
63
  };
64
- }, m = (e, t) => p(e, t, (t) => {
64
+ }, h = (e, t) => m(e, t, (t) => {
65
65
  let { horizontal: n, isRtl: r } = e.options;
66
66
  return n ? t.scrollLeft * (r && -1 || 1) : t.scrollTop;
67
- }), h = (e, t, n) => {
67
+ }), g = (e, t, n) => {
68
68
  if (n.options.useCachedMeasurements) {
69
69
  let t = n.indexFromElement(e), r = n.options.getItemKey(t);
70
70
  return n.itemSizeCache.get(r) ?? n.options.estimateSize(t);
@@ -78,15 +78,30 @@ var a, o = () => {
78
78
  if (i !== void 0) return i;
79
79
  }
80
80
  return e[n.options.horizontal ? "offsetWidth" : "offsetHeight"];
81
- }, g = (e, { adjustments: t = 0, behavior: n }, r) => {
81
+ }, _ = (e, { adjustments: t = 0, behavior: n }, r) => {
82
82
  var i, a;
83
83
  (a = (i = r.scrollElement)?.scrollTo) == null || a.call(i, {
84
84
  [r.options.horizontal ? "left" : "top"]: e + t,
85
85
  behavior: n
86
86
  });
87
- }, _ = class {
88
- constructor(t) {
89
- this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.scrollState = null, this.measurementsCache = [], this._flatMeasurements = null, this.itemSizeCache = /* @__PURE__ */ new Map(), this.itemSizeCacheVersion = 0, this.laneAssignments = /* @__PURE__ */ new Map(), this.pendingMin = null, this.prevLanes = void 0, this.lanesChangedFlag = !1, this.lanesSettling = !1, this.pendingScrollAnchor = null, this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this._iosDeferredAdjustment = 0, this._iosTouching = !1, this._iosJustTouchEnded = !1, this._iosTouchEndTimerId = null, this._intendedScrollOffset = null, this.elementsCache = /* @__PURE__ */ new Map(), this.now = () => {
87
+ };
88
+ function v(e, t, n, r) {
89
+ if (t === 0) return !1;
90
+ let i = r(0), a = /* @__PURE__ */ new Set(), o = 0;
91
+ for (; o < e;) {
92
+ let e = n(o);
93
+ if (e === i) break;
94
+ a.add(e), o++;
95
+ }
96
+ let s = e - o;
97
+ if (s === 0 || s >= t) return !1;
98
+ for (let e = 0; e < s; e++) if (r(e) !== n(o + e)) return !1;
99
+ for (let e = s; e < t; e++) if (a.has(r(e))) return !1;
100
+ return !0;
101
+ }
102
+ var y = class {
103
+ constructor(r) {
104
+ this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.scrollState = null, this.measurementsCache = [], this._singleLaneMeasurements = null, this.itemSizeCache = /* @__PURE__ */ new Map(), this.itemSizeCacheVersion = 0, this.laneAssignments = /* @__PURE__ */ new Map(), this.pendingMin = null, this.prevLanes = void 0, this.lanesChangedFlag = !1, this.lanesSettling = !1, this.pendingScrollAnchor = null, this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this._iosDeferredAdjustment = 0, this._iosTouching = !1, this._iosJustTouchEnded = !1, this._iosTouchEndTimerId = null, this._intendedScrollOffset = null, this._clampedAdjustment = null, this.elementsCache = /* @__PURE__ */ new Map(), this.now = () => {
90
105
  var e;
91
106
  return ((e = this.targetWindow?.performance)?.now)?.call(e) ?? Date.now();
92
107
  }, this.observer = /* @__PURE__ */ (() => {
@@ -116,7 +131,7 @@ var a, o = () => {
116
131
  unobserve: (e) => t()?.unobserve(e)
117
132
  };
118
133
  })(), this.range = null, this.setOptions = (e) => {
119
- let t = {
134
+ let n = {
120
135
  debug: !1,
121
136
  initialOffset: 0,
122
137
  overscan: 1,
@@ -125,10 +140,10 @@ var a, o = () => {
125
140
  scrollPaddingStart: 0,
126
141
  scrollPaddingEnd: 0,
127
142
  horizontal: !1,
128
- getItemKey: c,
129
- rangeExtractor: l,
143
+ getItemKey: l,
144
+ rangeExtractor: u,
130
145
  onChange: () => {},
131
- measureElement: h,
146
+ measureElement: g,
132
147
  initialRect: {
133
148
  width: 0,
134
149
  height: 0
@@ -149,44 +164,44 @@ var a, o = () => {
149
164
  laneAssignmentMode: "estimate",
150
165
  useCachedMeasurements: !1
151
166
  };
152
- for (let n in e) {
153
- let r = e[n];
154
- r !== void 0 && (t[n] = r);
167
+ for (let t in e) {
168
+ let r = e[t];
169
+ r !== void 0 && (n[t] = r);
155
170
  }
156
- let n = this.options, r = null, i = null, a = !1;
157
- if (n !== void 0 && n.enabled && t.enabled && t.anchorTo === "end" && this.scrollElement !== null) {
158
- let e = n.count, o = t.count, s = this.getMeasurements(), c = e > 0 ? s[0]?.key ?? n.getItemKey(0) : null, l = e > 0 ? s[e - 1]?.key ?? n.getItemKey(e - 1) : null;
159
- if (o !== e || e > 0 && o > 0 && (t.getItemKey(0) !== c || t.getItemKey(o - 1) !== l)) {
160
- a = !0;
161
- let c = e > 0 ? this.getVirtualItemForOffset(this.getScrollOffset()) ?? s[0] : null;
162
- c && (r = [c.key, this.getScrollOffset() - c.start]);
163
- let u = t.followOnAppend === !0 ? "auto" : t.followOnAppend || null;
164
- u && o > e && this.isAtEnd(n.scrollEndThreshold) && (e === 0 || t.getItemKey(o - 1) !== l) && (i = u);
171
+ let r = this.options, i = null, a = null, o = !1;
172
+ if (r !== void 0 && r.enabled && n.enabled && n.anchorTo === "end" && this.scrollElement !== null) {
173
+ let e = r.count, s = n.count, c = this.getMeasurements(), l = this._singleLaneMeasurements?.items ?? c, u = (e) => t(l[e]), d = e > 0 ? u(0) : null, f = e > 0 ? u(e - 1) : null;
174
+ if (s !== e || e > 0 && s > 0 && (n.getItemKey(0) !== d || n.getItemKey(s - 1) !== f)) {
175
+ o = !0;
176
+ let t = e > 0 ? this.getVirtualItemForOffset(this.getScrollOffset()) ?? c[0] : null;
177
+ t && (i = [t.key, this.getScrollOffset() - t.start]);
178
+ let l = n.followOnAppend === !0 ? "auto" : n.followOnAppend || null;
179
+ l && s > 0 && this.isAtEnd(r.scrollEndThreshold) && (e === 0 || n.getItemKey(s - 1) !== f) && (s > e || v(e, s, u, n.getItemKey)) && (a = l);
165
180
  }
166
181
  }
167
- this.options = t, a && (this.pendingMin = 0, this.itemSizeCacheVersion++);
168
- let o = !1, s = 0;
169
- if (r && this.scrollOffset !== null) {
170
- let [e, t] = r, n = this.getMeasurements(), { count: i, getItemKey: a } = this.options, c = 0;
171
- for (; c < i && a(c) !== e;) c++;
172
- if (c < i) {
173
- let e = n[c];
182
+ this.options = n, o && (this.pendingMin = 0, this.itemSizeCacheVersion++);
183
+ let s = !1, c = 0;
184
+ if (i && this.scrollOffset !== null) {
185
+ let [e, t] = i, n = this.getMeasurements(), { count: r, getItemKey: o } = this.options, l = 0;
186
+ for (; l < r && o(l) !== e;) l++;
187
+ if (l < r) {
188
+ let e = n[l];
174
189
  if (e) {
175
190
  let n = Math.max(0, e.start + t);
176
- n !== this.scrollOffset && (s = n - this.scrollOffset, this.scrollOffset = n, o = !0);
191
+ !a && n !== this.scrollOffset && (c = n - this.scrollOffset, this.scrollOffset = n, s = !0);
177
192
  }
178
193
  }
179
194
  }
180
- (o || i) && (this.pendingScrollAnchor = [
181
- o ? r[0] : null,
182
- o ? r[1] : 0,
183
- i,
184
- s
195
+ (s || a) && (this.pendingScrollAnchor = [
196
+ s ? i[0] : null,
197
+ s ? i[1] : 0,
198
+ a,
199
+ c
185
200
  ]);
186
201
  }, this.notify = (e) => {
187
202
  var t, n;
188
203
  (n = (t = this.options).onChange) == null || n.call(t, this, e);
189
- }, this.maybeNotify = r(() => (this.calculateRange(), [
204
+ }, this.maybeNotify = i(() => (this.calculateRange(), [
190
205
  this.isScrolling,
191
206
  this.range ? this.range.startIndex : null,
192
207
  this.range ? this.range.endIndex : null
@@ -201,7 +216,7 @@ var a, o = () => {
201
216
  this.range ? this.range.endIndex : null
202
217
  ]
203
218
  }), this.cleanup = () => {
204
- this.unsubs.filter(Boolean).forEach((e) => e()), this.unsubs = [], this.observer.disconnect(), this.rafId != null && this.targetWindow && (this.targetWindow.cancelAnimationFrame(this.rafId), this.rafId = null), this.scrollState = null, this.isScrolling = !1, this.scrollDirection = null, this._iosDeferredAdjustment = 0, this._iosTouching = !1, this._iosJustTouchEnded = !1, this.scrollElement = null, this.targetWindow = null;
219
+ this.unsubs.filter(Boolean).forEach((e) => e()), this.unsubs = [], this.observer.disconnect(), this.rafId != null && this.targetWindow && (this.targetWindow.cancelAnimationFrame(this.rafId), this.rafId = null), this.scrollState = null, this.isScrolling = !1, this.scrollDirection = null, this._iosDeferredAdjustment = 0, this._iosTouching = !1, this._iosJustTouchEnded = !1, this._clampedAdjustment = null, this.scrollElement = null, this.targetWindow = null;
205
220
  }, this._didMount = () => () => {
206
221
  this.cleanup();
207
222
  }, this._willUpdate = () => {
@@ -217,18 +232,18 @@ var a, o = () => {
217
232
  this.scrollRect = e, this.maybeNotify();
218
233
  })), this.unsubs.push(this.options.observeElementOffset(this, (e, t) => {
219
234
  if (t && this._intendedScrollOffset === null && e === this.scrollOffset) return;
220
- this._intendedScrollOffset !== null && Math.abs(e - this._intendedScrollOffset) < 1.5 && (e = this._intendedScrollOffset), this._intendedScrollOffset = null, this.scrollAdjustments = 0;
235
+ this._intendedScrollOffset !== null && Math.abs(e - this._intendedScrollOffset) < 1.5 && (e = this._intendedScrollOffset), this._intendedScrollOffset = null, this._clampedAdjustment !== null && Math.abs(e - this._clampedAdjustment.maxAtWrite) >= 1.5 && (this._clampedAdjustment = null), this.scrollAdjustments = 0;
221
236
  let n = this.getScrollOffset();
222
237
  this.scrollDirection = t ? n === e ? this.scrollDirection : n < e ? "forward" : "backward" : null, this.scrollOffset = e, this.isScrolling = t, this._flushIosDeferredIfReady(), this.scrollState && this.scheduleScrollReconcile(), this.maybeNotify();
223
238
  })), "addEventListener" in this.scrollElement) {
224
239
  let e = this.scrollElement, t = () => {
225
240
  this._iosTouching = !0, this._iosJustTouchEnded = !1, this._iosTouchEndTimerId !== null && this.targetWindow != null && (this.targetWindow.clearTimeout(this._iosTouchEndTimerId), this._iosTouchEndTimerId = null);
226
241
  }, n = () => {
227
- this._iosTouching = !1, !(!o() || this.targetWindow == null) && (this._iosJustTouchEnded = !0, this._iosTouchEndTimerId = this.targetWindow.setTimeout(() => {
242
+ this._iosTouching = !1, !(!s() || this.targetWindow == null) && (this._iosJustTouchEnded = !0, this._iosTouchEndTimerId = this.targetWindow.setTimeout(() => {
228
243
  this._iosJustTouchEnded = !1, this._iosTouchEndTimerId = null, this._flushIosDeferredIfReady();
229
244
  }, 150));
230
245
  };
231
- e.addEventListener("touchstart", t, d), e.addEventListener("touchend", n, d), this.unsubs.push(() => {
246
+ e.addEventListener("touchstart", t, f), e.addEventListener("touchend", n, f), this.unsubs.push(() => {
232
247
  e.removeEventListener("touchstart", t), e.removeEventListener("touchend", n), this._iosTouchEndTimerId !== null && this.targetWindow != null && (this.targetWindow.clearTimeout(this._iosTouchEndTimerId), this._iosTouchEndTimerId = null);
233
248
  });
234
249
  }
@@ -239,12 +254,23 @@ var a, o = () => {
239
254
  }
240
255
  let t = this.pendingScrollAnchor;
241
256
  if (this.pendingScrollAnchor = null, t && this.scrollElement && this.options.enabled) {
242
- let [e, n, r, i] = t;
243
- e !== null && !r && (o() && (this.isScrolling || this._iosTouching || this._iosJustTouchEnded) ? i !== 0 && (this._iosDeferredAdjustment += i) : this._scrollToOffset(this.getScrollOffset(), {
257
+ let [e, r, i, a] = t;
258
+ e !== null && !i && (s() && (this.isScrolling || this._iosTouching || this._iosJustTouchEnded) ? a !== 0 && (this._iosDeferredAdjustment += a) : this.scrollState?.behavior === "smooth" && !n(this.getScrollOffset() - a, this.scrollState.lastTargetOffset) || this._scrollToOffset(this.getScrollOffset(), {
244
259
  adjustments: void 0,
245
260
  behavior: void 0
246
- })), r && this.scrollToEnd({ behavior: r });
261
+ })), i && this.scrollToEnd({ behavior: i });
247
262
  }
263
+ this._retryClampedAdjustment();
264
+ }, this._retryClampedAdjustment = () => {
265
+ if (this._clampedAdjustment === null || !this.scrollElement || !this.options.enabled) return;
266
+ let { target: e, maxAtWrite: t } = this._clampedAdjustment, n = this.getMaxScrollOffset();
267
+ n > t + .5 && (this._clampedAdjustment = e > n + .5 ? {
268
+ target: e,
269
+ maxAtWrite: n
270
+ } : null, this._scrollToOffset(e, {
271
+ adjustments: void 0,
272
+ behavior: void 0
273
+ }));
248
274
  }, this._flushIosDeferredIfReady = () => {
249
275
  if (this._iosDeferredAdjustment === 0 || this.isScrolling || this._iosTouching || this._iosJustTouchEnded) return;
250
276
  let e = this.getScrollOffset(), t = this.getMaxScrollOffset();
@@ -258,7 +284,7 @@ var a, o = () => {
258
284
  adjustments: this.scrollAdjustments += n,
259
285
  behavior: void 0
260
286
  });
261
- }, this.rafId = null, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getMeasurementOptions = r(() => [
287
+ }, this.rafId = null, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getMeasurementOptions = i(() => [
262
288
  this.options.count,
263
289
  this.options.paddingStart,
264
290
  this.options.scrollMargin,
@@ -276,32 +302,38 @@ var a, o = () => {
276
302
  lanes: a,
277
303
  laneAssignmentMode: o,
278
304
  gap: s
279
- }), { key: !1 }), this.isIndexInRange = (e) => e >= 0 && e < this.options.count, this.getMeasurements = r(() => [this.getMeasurementOptions(), this.itemSizeCacheVersion], ({ count: t, paddingStart: n, scrollMargin: r, getItemKey: i, enabled: a, lanes: o, laneAssignmentMode: s, gap: c }, l) => {
305
+ }), { key: !1 }), this.isIndexInRange = (e) => e >= 0 && e < this.options.count, this.getMeasurements = i(() => [this.getMeasurementOptions(), this.itemSizeCacheVersion], ({ count: t, paddingStart: n, scrollMargin: r, getItemKey: i, enabled: a, lanes: o, laneAssignmentMode: s, gap: c }, l) => {
280
306
  let u = this.itemSizeCache;
281
- if (!a) return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
307
+ if (!a) return this.measurementsCache = [], this._singleLaneMeasurements = null, this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
282
308
  if (this.laneAssignments.size > t) for (let e of this.laneAssignments.keys()) e >= t && this.laneAssignments.delete(e);
283
- this.lanesChangedFlag && (this.lanesChangedFlag = !1, this.lanesSettling = !0, this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), this.pendingMin = null), this.measurementsCache.length === 0 && !this.lanesSettling && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((e) => {
309
+ this.lanesChangedFlag && (this.lanesChangedFlag = !1, this.lanesSettling = !0, this.measurementsCache = [], this._singleLaneMeasurements = null, this.itemSizeCache.clear(), this.laneAssignments.clear(), this.pendingMin = null), this.measurementsCache.length === 0 && !this.lanesSettling && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((e) => {
284
310
  this.itemSizeCache.set(e.key, e.size);
285
311
  }));
286
312
  let d = this.lanesSettling ? 0 : this.pendingMin ?? 0;
287
313
  if (this.pendingMin = null, this.lanesSettling && this.measurementsCache.length === t && (this.lanesSettling = !1), o === 1) {
288
- let a = t * 2, o = this._flatMeasurements;
314
+ let a = t * 2, o = this._singleLaneMeasurements?.flat;
289
315
  if (!o || o.length < a) {
290
316
  let e = new Float64Array(a);
291
- o && d > 0 && e.set(o.subarray(0, d * 2)), o = e, this._flatMeasurements = o;
317
+ o && d > 0 && e.set(o.subarray(0, d * 2)), o = e;
292
318
  }
293
- let s;
294
- if (d === 0) s = n + r;
319
+ let s = d === 0 ? Array(t) : this._singleLaneMeasurements.items.slice(), l;
320
+ if (d === 0) l = n + r;
295
321
  else {
296
322
  let e = d - 1;
297
- s = o[e * 2] + o[e * 2 + 1] + c;
323
+ l = o[e * 2] + o[e * 2 + 1] + c;
298
324
  }
299
325
  for (let e = d; e < t; e++) {
300
- let t = i(e), n = u.get(t), r = typeof n == "number" ? n : this.options.estimateSize(e);
301
- o[e * 2] = s, o[e * 2 + 1] = r, s += r + c;
326
+ let t = i(e);
327
+ s[e] = t;
328
+ let n = u.get(t), r = typeof n == "number" ? n : this.options.estimateSize(e);
329
+ o[e * 2] = l, o[e * 2 + 1] = r, l += r + c;
302
330
  }
303
- let l = e(t, o, i);
304
- return this.measurementsCache = l, l;
331
+ this._singleLaneMeasurements = {
332
+ flat: o,
333
+ items: s
334
+ };
335
+ let f = e(s, o);
336
+ return this.measurementsCache = f, f;
305
337
  }
306
338
  let f = this.measurementsCache.slice(0, d), p = Array(o).fill(void 0), m = new Float64Array(o), h = 0;
307
339
  for (let e = 0; e < d; e++) {
@@ -336,15 +368,15 @@ var a, o = () => {
336
368
  }, {
337
369
  key: process.env.NODE_ENV !== "production" && "getMeasurements",
338
370
  debug: () => this.options.debug
339
- }), this.calculateRange = r(() => [
371
+ }), this.calculateRange = i(() => [
340
372
  this.getMeasurements(),
341
373
  this.getSize(),
342
374
  this.getScrollOffset(),
343
375
  this.options.lanes
344
- ], (e, t, n, r) => e.length === 0 || t === 0 ? (this.range = null, null) : (this.range = b(e, t, n, r, r === 1 && this._flatMeasurements != null ? this._flatMeasurements : null), this.range), {
376
+ ], (e, t, n, r) => e.length === 0 || t === 0 ? (this.range = null, null) : (this.range = S(e, t, n, r, r === 1 && this._singleLaneMeasurements !== null ? this._singleLaneMeasurements.flat : null), this.range), {
345
377
  key: process.env.NODE_ENV !== "production" && "calculateRange",
346
378
  debug: () => this.options.debug
347
- }), this.getVirtualIndexes = r(() => {
379
+ }), this.getVirtualIndexes = i(() => {
348
380
  let e = null, t = null, n = this.calculateRange();
349
381
  return n && (e = n.startIndex, t = n.endIndex), this.maybeNotify.updateDeps([
350
382
  this.isScrolling,
@@ -389,8 +421,8 @@ var a, o = () => {
389
421
  r !== e && (r && this.observer.unobserve(r), this.observer.observe(e), this.elementsCache.set(n, e)), (!this.isScrolling || this.scrollState) && this.shouldMeasureDuringScroll(t) && this.resizeItem(t, this.options.measureElement(e, void 0, this));
390
422
  }, this.resizeItem = (e, t) => {
391
423
  if (!this.isIndexInRange(e)) return;
392
- let n, r, i, a = this._flatMeasurements;
393
- if (this.options.lanes === 1 && a !== null) i = this.options.getItemKey(e), r = a[e * 2], n = a[e * 2 + 1];
424
+ let n, r, i, a = this._singleLaneMeasurements?.flat;
425
+ if (this.options.lanes === 1 && a != null) i = this.options.getItemKey(e), r = a[e * 2], n = a[e * 2 + 1];
394
426
  else {
395
427
  let t = this.measurementsCache[e];
396
428
  if (!t) return;
@@ -408,9 +440,9 @@ var a, o = () => {
408
440
  }, s, this));
409
441
  (this.pendingMin === null || e < this.pendingMin) && (this.pendingMin = e), this.itemSizeCache.set(i, t), this.itemSizeCacheVersion++;
410
442
  let f = !1;
411
- a ? f = this.applyScrollAdjustment(this.getTotalSize() - c) : d && (f = this.applyScrollAdjustment(s)), this.notify(f);
443
+ a ? f = this.applyScrollAdjustment(this.getTotalSize() - c) : d && (f = this.applyScrollAdjustment(s)), this.notify(f), this._retryClampedAdjustment();
412
444
  }
413
- }, this.getVirtualItems = r(() => [this.getVirtualIndexes(), this.getMeasurements()], (e, t) => {
445
+ }, this.getVirtualItems = i(() => [this.getVirtualIndexes(), this.getMeasurements()], (e, t) => {
414
446
  let n = [];
415
447
  for (let r = 0, i = e.length; r < i; r++) {
416
448
  let i = t[e[r]];
@@ -423,8 +455,8 @@ var a, o = () => {
423
455
  }), this.getVirtualItemForOffset = (e) => {
424
456
  let t = this.getMeasurements();
425
457
  if (t.length === 0) return;
426
- let n = this._flatMeasurements, r = this.options.lanes === 1 && n != null, a = v(0, t.length - 1, r ? (e) => n[e * 2] : (e) => i(t[e]).start, e);
427
- return i(t[a]);
458
+ let n = this._singleLaneMeasurements?.flat, r = this.options.lanes === 1 && n != null, i = b(0, t.length - 1, r ? (e) => n[e * 2] : (e) => a(t[e]).start, e);
459
+ return a(t[i]);
428
460
  }, this.getMaxScrollOffset = () => {
429
461
  if (!this.scrollElement) return 0;
430
462
  if ("scrollHeight" in this.scrollElement) return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
@@ -506,7 +538,7 @@ var a, o = () => {
506
538
  let e = this.getMeasurements(), t;
507
539
  if (e.length === 0) t = this.options.paddingStart;
508
540
  else if (this.options.lanes === 1) {
509
- let n = e.length - 1, r = this._flatMeasurements;
541
+ let n = e.length - 1, r = this._singleLaneMeasurements?.flat;
510
542
  t = r == null ? e[n]?.end ?? 0 : r[n * 2] + r[n * 2 + 1];
511
543
  } else {
512
544
  let n = Array(this.options.lanes).fill(null), r = e.length - 1;
@@ -537,13 +569,21 @@ var a, o = () => {
537
569
  }, this);
538
570
  }, this.measure = () => {
539
571
  this.pendingMin = null, this.itemSizeCache.clear(), this.laneAssignments.clear(), this.itemSizeCacheVersion++, this.notify(!1);
540
- }, this.setOptions(t);
572
+ }, this.setOptions(r);
541
573
  }
542
574
  applyScrollAdjustment(e, t) {
543
- return e !== 0 && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", e), o() && (this.isScrolling || this._iosTouching || this._iosJustTouchEnded) ? (this._iosDeferredAdjustment += e, !1) : (this._scrollToOffset(this.getScrollOffset(), {
544
- adjustments: this.scrollAdjustments += e,
545
- behavior: t
546
- }), this.scrollOffset !== null && (this.scrollOffset += this.scrollAdjustments, this.scrollOffset < 0 && (this.scrollOffset = 0), this.scrollAdjustments = 0), !0));
575
+ if (e === 0) return !1;
576
+ if (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", e), s() && (this.isScrolling || this._iosTouching || this._iosJustTouchEnded)) return this._iosDeferredAdjustment += e, !1;
577
+ {
578
+ let n = this.getScrollOffset() + this.scrollAdjustments + e, r = this.scrollElement, i = r !== null && ("scrollHeight" in r || "document" in r) ? this.getMaxScrollOffset() : null;
579
+ return this._clampedAdjustment = i !== null && n > i + .5 ? {
580
+ target: n,
581
+ maxAtWrite: i
582
+ } : null, this._scrollToOffset(this.getScrollOffset(), {
583
+ adjustments: this.scrollAdjustments += e,
584
+ behavior: t
585
+ }), this.scrollOffset !== null && (this.scrollOffset += this.scrollAdjustments, this.scrollOffset < 0 && (this.scrollOffset = 0), this.scrollAdjustments = 0), !0;
586
+ }
547
587
  }
548
588
  scheduleScrollReconcile() {
549
589
  if (!this.targetWindow) {
@@ -560,25 +600,25 @@ var a, o = () => {
560
600
  this.scrollState = null;
561
601
  return;
562
602
  }
563
- let e = this.scrollState.index == null ? void 0 : this.getOffsetForIndex(this.scrollState.index, this.scrollState.align), n = e ? e[0] : this.scrollState.lastTargetOffset, r = n !== this.scrollState.lastTargetOffset;
564
- if (!r && t(n, this.getScrollOffset())) {
603
+ let e = this.scrollState.index == null ? void 0 : this.getOffsetForIndex(this.scrollState.index, this.scrollState.align), t = e ? e[0] : this.scrollState.lastTargetOffset, r = t !== this.scrollState.lastTargetOffset;
604
+ if (!r && n(t, this.getScrollOffset())) {
565
605
  if (this.scrollState.stableFrames++, this.scrollState.stableFrames >= 1) {
566
- this.getScrollOffset() !== n && this._scrollToOffset(n, {
606
+ this.getScrollOffset() !== t && this._scrollToOffset(t, {
567
607
  adjustments: void 0,
568
608
  behavior: "auto"
569
609
  }), this.scrollState = null;
570
610
  return;
571
611
  }
572
612
  } else if (this.scrollState.stableFrames = 0, r) {
573
- let e = this.getSize() || 600, t = Math.abs(n - this.getScrollOffset()), r = this.scrollState.behavior === "smooth" && t > e;
574
- this.scrollState.lastTargetOffset = n, r || (this.scrollState.behavior = "auto"), this._scrollToOffset(n, {
613
+ let e = this.getSize() || 600, n = Math.abs(t - this.getScrollOffset()), r = this.scrollState.behavior === "smooth" && n > e;
614
+ this.scrollState.lastTargetOffset = t, r || (this.scrollState.behavior = "auto"), this._scrollToOffset(t, {
575
615
  adjustments: void 0,
576
616
  behavior: r ? "smooth" : "auto"
577
617
  });
578
618
  }
579
619
  this.scheduleScrollReconcile();
580
620
  }
581
- }, v = (e, t, n, r) => {
621
+ }, b = (e, t, n, r) => {
582
622
  for (; e <= t;) {
583
623
  let i = (e + t) / 2 | 0, a = n(i);
584
624
  if (a < r) e = i + 1;
@@ -587,7 +627,7 @@ var a, o = () => {
587
627
  }
588
628
  return e > 0 ? e - 1 : 0;
589
629
  };
590
- function y(e, t, n) {
630
+ function x(e, t, n) {
591
631
  let r = 0;
592
632
  for (; r <= t;) {
593
633
  let i = (r + t) / 2 | 0, a = e[i * 2];
@@ -597,21 +637,21 @@ function y(e, t, n) {
597
637
  }
598
638
  return r > 0 ? r - 1 : 0;
599
639
  }
600
- function b(e, t, n, r, i) {
640
+ function S(e, t, n, r, i) {
601
641
  let a = e.length - 1;
602
642
  if (e.length <= r) return {
603
643
  startIndex: 0,
604
644
  endIndex: a
605
645
  };
606
646
  if (r === 1 && i !== null) {
607
- let e = y(i, a, n), r = e, o = n + t;
647
+ let e = x(i, a, n), r = e, o = n + t;
608
648
  for (; r < a && i[r * 2] + i[r * 2 + 1] < o;) r++;
609
649
  return {
610
650
  startIndex: e,
611
651
  endIndex: r
612
652
  };
613
653
  }
614
- let o = v(0, a, (t) => e[t].start, n), s = o;
654
+ let o = b(0, a, (t) => e[t].start, n), s = o;
615
655
  if (r === 1) for (; s < a && e[s].end < n + t;) s++;
616
656
  else if (r > 1) {
617
657
  let i = Array(r).fill(0);
@@ -632,4 +672,4 @@ function b(e, t, n, r, i) {
632
672
  };
633
673
  }
634
674
  //#endregion
635
- export { _ as Virtualizer, t as approxEqual, n as debounce, c as defaultKeyExtractor, l as defaultRangeExtractor, g as elementScroll, h as measureElement, r as memo, i as notUndefined, m as observeElementOffset, u as observeElementRect };
675
+ export { y as Virtualizer, n as approxEqual, r as debounce, l as defaultKeyExtractor, u as defaultRangeExtractor, _ as elementScroll, g as measureElement, i as memo, a as notUndefined, h as observeElementOffset, d as observeElementRect };
@@ -1,31 +1,34 @@
1
1
  //#region ../../node_modules/@tanstack/virtual-core/dist/esm/lazy-measurements.js
2
- function e(e, t, n) {
3
- let r = Array(e);
4
- return new Proxy(r, { get(r, i, a) {
5
- if (typeof i == "string") {
6
- let a = i.charCodeAt(0);
7
- if (a >= 48 && a <= 57) {
8
- let a = +i;
9
- if (Number.isInteger(a) && a >= 0 && a < e) {
10
- let e = r[a];
11
- if (!e) {
12
- let i = t[a * 2];
13
- e = r[a] = {
14
- index: a,
15
- key: n(a),
16
- start: i,
17
- size: t[a * 2 + 1],
18
- end: i + t[a * 2 + 1],
2
+ function e(e) {
3
+ return typeof e == "object" ? e.key : e;
4
+ }
5
+ function t(e, t) {
6
+ let n = e.length;
7
+ return new Proxy(e, { get(e, r, i) {
8
+ if (typeof r == "string") {
9
+ let i = r.charCodeAt(0);
10
+ if (i >= 48 && i <= 57) {
11
+ let i = +r;
12
+ if (Number.isInteger(i) && i >= 0 && i < n) {
13
+ let n = e[i];
14
+ if (typeof n != "object") {
15
+ let r = t[i * 2];
16
+ n = e[i] = {
17
+ index: i,
18
+ key: n,
19
+ start: r,
20
+ size: t[i * 2 + 1],
21
+ end: r + t[i * 2 + 1],
19
22
  lane: 0
20
23
  };
21
24
  }
22
- return e;
25
+ return n;
23
26
  }
24
27
  }
25
- if (i === "length") return e;
28
+ if (r === "length") return n;
26
29
  }
27
- return Reflect.get(r, i, a);
30
+ return Reflect.get(e, r, i);
28
31
  } });
29
32
  }
30
33
  //#endregion
31
- export { e as createLazyMeasurementsView };
34
+ export { t as createLazyMeasurementsView, e as getMeasurementKey };