vue-virtual-flow 0.0.9 → 0.1.1

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/README.md +100 -10
  3. package/README.vi.md +92 -10
  4. package/dist/components/ChatVirtualScroll.d.cts +29 -2
  5. package/dist/components/ChatVirtualScroll.d.ts +29 -2
  6. package/dist/components/DynamicVirtualScroll.d.cts +3 -3
  7. package/dist/components/DynamicVirtualScroll.d.ts +3 -3
  8. package/dist/components/ShortMediaFeed.d.cts +2 -2
  9. package/dist/components/ShortMediaFeed.d.ts +2 -2
  10. package/dist/components/VirtualCarousel.d.cts +16 -2
  11. package/dist/components/VirtualCarousel.d.ts +16 -2
  12. package/dist/components/VirtualScroll.d.cts +3 -3
  13. package/dist/components/VirtualScroll.d.ts +3 -3
  14. package/dist/components/WindowDynamicVirtualScroll.d.cts +3 -3
  15. package/dist/components/WindowDynamicVirtualScroll.d.ts +3 -3
  16. package/dist/components/WindowGirdVirtualScroll.d.cts +3 -3
  17. package/dist/components/WindowGirdVirtualScroll.d.ts +3 -3
  18. package/dist/composables/useCarouselAutoplay.d.cts +15 -0
  19. package/dist/composables/useCarouselAutoplay.d.ts +15 -0
  20. package/dist/composables/useCarouselInteraction.d.cts +42 -0
  21. package/dist/composables/useCarouselInteraction.d.ts +42 -0
  22. package/dist/composables/useScrollActivity.d.cts +28 -0
  23. package/dist/composables/useScrollActivity.d.ts +28 -0
  24. package/dist/index.d.cts +1 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/types.d.cts +48 -0
  27. package/dist/types.d.ts +48 -0
  28. package/dist/utils/carouselLayout.d.cts +8 -0
  29. package/dist/utils/carouselLayout.d.ts +8 -0
  30. package/dist/utils/carouselMotion.d.cts +5 -0
  31. package/dist/utils/carouselMotion.d.ts +5 -0
  32. package/dist/utils/keyedSizeIndex.d.cts +19 -0
  33. package/dist/utils/keyedSizeIndex.d.ts +19 -0
  34. package/dist/vue-virtual-flow.cjs +1 -1
  35. package/dist/vue-virtual-flow.css +1 -1
  36. package/dist/vue-virtual-flow.js +2200 -1515
  37. package/package.json +3 -2
@@ -1,101 +1,254 @@
1
- import { watch as ie, defineComponent as Oe, ref as j, computed as n, nextTick as C, onMounted as Ae, onUpdated as Xe, onBeforeUnmount as Ce, openBlock as I, createElementBlock as $, normalizeStyle as N, createElementVNode as Ge, renderSlot as ce, createTextVNode as Ve, createCommentVNode as ze, Fragment as Re, renderList as De, unref as c, normalizeClass as Ye, toDisplayString as je } from "vue";
2
- function tt(l) {
3
- return typeof l == "string" || typeof l == "number" || typeof l == "symbol";
1
+ import { watch as ye, ref as X, defineComponent as tt, computed as h, shallowRef as ft, nextTick as Z, onMounted as at, onUpdated as $t, onBeforeUnmount as Xe, openBlock as j, createElementBlock as U, normalizeStyle as re, createElementVNode as rt, mergeProps as Ot, unref as f, renderSlot as Se, createTextVNode as Ge, createCommentVNode as Re, Fragment as et, renderList as nt, toDisplayString as ht, normalizeClass as st } from "vue";
2
+ function At(t) {
3
+ return typeof t == "string" || typeof t == "number" || typeof t == "symbol";
4
4
  }
5
- function Ze(l, P) {
6
- const x = l[P];
7
- return tt(x) ? x : void 0;
5
+ function zt(t, s) {
6
+ const I = t[s];
7
+ return At(I) ? I : void 0;
8
8
  }
9
- function lt(l) {
10
- return Ze(l, "id") ?? Ze(l, "key");
9
+ function Ft(t) {
10
+ return zt(t, "id") ?? zt(t, "key");
11
11
  }
12
- function Pe(l) {
13
- function P(e, p) {
14
- const f = l.itemKey();
15
- if (typeof f == "function")
16
- return f(e, p);
17
- if (e !== null && typeof e == "object") {
18
- if (f !== void 0) {
19
- const o = Ze(e, f);
20
- if (o !== void 0) return o;
12
+ function lt(t) {
13
+ const s = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new Map();
14
+ function e(y) {
15
+ if (At(y)) return y;
16
+ if (y !== null && typeof y == "object") {
17
+ let u = s.get(y);
18
+ return u || (u = Symbol(`${t.componentName} item`), s.set(y, u)), u;
19
+ }
20
+ let r = I.get(y);
21
+ return r || (r = Symbol(`${t.componentName} primitive`), I.set(y, r)), r;
22
+ }
23
+ function z(y, r) {
24
+ const u = t.itemKey();
25
+ if (typeof u == "function")
26
+ return u(y, r);
27
+ if (y !== null && typeof y == "object") {
28
+ if (u !== void 0) {
29
+ const M = zt(y, u);
30
+ if (M !== void 0) return M;
21
31
  }
22
- const r = lt(e);
23
- if (r !== void 0) return r;
32
+ const n = Ft(y);
33
+ if (n !== void 0) return n;
24
34
  }
25
- return p;
35
+ return e(y);
26
36
  }
27
37
  function x() {
28
38
  }
29
- return ie(
30
- () => [l.itemKey(), l.items()],
39
+ return ye(
40
+ () => [t.itemKey(), t.items(), t.items().length],
31
41
  x,
32
42
  { immediate: !0 }
33
- ), { getItemKey: P };
43
+ ), { getItemKey: z };
34
44
  }
35
- function Fe(l) {
36
- return l === "fill" ? "100%" : typeof l == "number" ? `${l}px` : l;
45
+ const Nt = /* @__PURE__ */ new Set([
46
+ "ArrowDown",
47
+ "ArrowUp",
48
+ "End",
49
+ "Home",
50
+ "PageDown",
51
+ "PageUp",
52
+ " "
53
+ ]);
54
+ function Yt(t) {
55
+ const s = X(!1);
56
+ let I = !1, e = !1, z;
57
+ function x() {
58
+ clearTimeout(z), z = void 0;
59
+ }
60
+ function y($) {
61
+ $ !== s.value && (s.value = $, t.onChange($));
62
+ }
63
+ function r() {
64
+ I || e || (x(), y(!1), t.onSettled());
65
+ }
66
+ function u() {
67
+ x(), (s.value || t.hasProgrammaticScroll()) && !I && !e && (z = setTimeout(r, t.delay()));
68
+ }
69
+ function n() {
70
+ t.onInterrupt(), x(), y(!0), t.onStart();
71
+ }
72
+ function M() {
73
+ I = !0, n();
74
+ }
75
+ function R($) {
76
+ I = $.touches.length > 0, u();
77
+ }
78
+ function D() {
79
+ n(), u();
80
+ }
81
+ function b($) {
82
+ t.onInterrupt(), Nt.has($.key) && (n(), u());
83
+ }
84
+ function A($) {
85
+ t.onInterrupt(), $.pointerType === "mouse" && $.target === t.viewport() && (e = !0, n());
86
+ }
87
+ function C() {
88
+ e && (e = !1, u());
89
+ }
90
+ return {
91
+ isScrolling: s,
92
+ setScrolling: y,
93
+ scheduleScrollEnd: u,
94
+ handleScrollEnd: r,
95
+ handleTouchStart: M,
96
+ handleTouchEnd: R,
97
+ handleWheel: D,
98
+ handleKeyDown: b,
99
+ handlePointerDown: A,
100
+ handlePointerUp: C,
101
+ dispose: x
102
+ };
37
103
  }
38
- function Ue(l) {
39
- return (P, x) => {
40
- typeof x == "string" && (x === "fill" || x.trim().endsWith("%"));
104
+ function gt(t) {
105
+ return t === "fill" ? "100%" : typeof t == "number" ? `${t}px` : t;
106
+ }
107
+ function Mt(t) {
108
+ return (s, I) => {
109
+ typeof I == "string" && (I === "fill" || I.trim().endsWith("%"));
41
110
  };
42
111
  }
43
- function at(l) {
44
- const P = Float64Array.from(l), x = P.length, e = new Float64Array(x + 1);
45
- let p = 0;
46
- for (let r = 1; r <= x; r += 1) {
47
- const o = P[r - 1];
48
- p += o, e[r] += o;
49
- const m = r + (r & -r);
50
- m <= x && (e[m] += e[r]);
112
+ function Ne(t) {
113
+ return (t == null ? void 0 : t.count) ?? 0;
114
+ }
115
+ function vt(t) {
116
+ return (t == null ? void 0 : t.total) ?? 0;
117
+ }
118
+ function kt(t) {
119
+ t.count = 1 + Ne(t.left) + Ne(t.right), t.total = t.size + vt(t.left) + vt(t.right), t.left && (t.left.parent = t), t.right && (t.right.parent = t);
120
+ }
121
+ function mt(t, s) {
122
+ return t ? s ? t.priority < s.priority ? (t.right = mt(t.right, s), kt(t), t) : (s.left = mt(t, s.left), kt(s), s) : t : s;
123
+ }
124
+ function jt(t) {
125
+ let s, I = 0;
126
+ const e = /* @__PURE__ */ new Map();
127
+ function z(u) {
128
+ const n = /* @__PURE__ */ new Set();
129
+ for (const M of u) {
130
+ if (e.has(M.key) || n.has(M.key))
131
+ throw new Error(
132
+ `[vue-virtual-flow] Duplicate item key \`${String(M.key)}\`. ChatVirtualScroll requires a unique stable key for every message.`
133
+ );
134
+ n.add(M.key);
135
+ }
51
136
  }
52
- let f = 1;
53
- for (; f * 2 <= x; ) f *= 2;
54
- return {
55
- length: x,
56
- get total() {
57
- return p;
137
+ function x(u) {
138
+ I += 1;
139
+ let n = Math.imul(I ^ 2654435769, 2246822507);
140
+ n ^= n >>> 13, n = Math.imul(n, 3266489909) ^ n >>> 16;
141
+ const M = {
142
+ key: u.key,
143
+ size: u.size,
144
+ priority: n >>> 0,
145
+ count: 1,
146
+ total: u.size
147
+ };
148
+ return e.set(u.key, M), M;
149
+ }
150
+ function y(u) {
151
+ let n;
152
+ for (const M of u) n = mt(n, x(M));
153
+ return n && (n.parent = void 0), n;
154
+ }
155
+ function r(u) {
156
+ let n = s, M = u;
157
+ for (; n; ) {
158
+ const R = Ne(n.left);
159
+ if (M < R) n = n.left;
160
+ else {
161
+ if (M === R) return n;
162
+ M -= R + 1, n = n.right;
163
+ }
164
+ }
165
+ }
166
+ return z(t), s = y(t), {
167
+ get length() {
168
+ return Ne(s);
58
169
  },
59
- getSize(r) {
60
- return P[r];
170
+ get total() {
171
+ return vt(s);
61
172
  },
62
- getOffset(r) {
63
- let o = 0;
64
- for (let m = r; m > 0; m -= m & -m)
65
- o += e[m];
66
- return o;
173
+ getSize(u) {
174
+ var n;
175
+ return ((n = r(u)) == null ? void 0 : n.size) ?? 0;
67
176
  },
68
- setSize(r, o) {
69
- const m = o - P[r];
70
- if (m !== 0) {
71
- P[r] = o, p += m;
72
- for (let A = r + 1; A <= x; A += A & -A)
73
- e[A] += m;
177
+ getOffset(u) {
178
+ let n = s, M = Math.max(0, Math.min(u, Ne(s))), R = 0;
179
+ for (; n && M > 0; ) {
180
+ const D = Ne(n.left);
181
+ M <= D ? n = n.left : (R += vt(n.left) + n.size, M -= D + 1, n = n.right);
74
182
  }
183
+ return R;
184
+ },
185
+ setSize(u, n) {
186
+ let M = r(u);
187
+ if (!(!M || M.size === n))
188
+ for (M.size = n; M; )
189
+ kt(M), M = M.parent;
75
190
  },
76
- findIndex(r) {
77
- if (x === 0 || r <= 0) return 0;
78
- if (r >= p) return x - 1;
79
- let o = 0, m = 0;
80
- for (let A = f; A > 0; A = Math.floor(A / 2)) {
81
- const O = o + A;
82
- O <= x && m + e[O] <= r && (o = O, m += e[O]);
191
+ findIndex(u) {
192
+ if (!s || u <= 0) return 0;
193
+ if (u >= s.total) return s.count - 1;
194
+ let n = s, M = 0, R = u;
195
+ for (; n; ) {
196
+ const D = vt(n.left), b = Ne(n.left);
197
+ if (R < D)
198
+ n = n.left;
199
+ else {
200
+ if (R < D + n.size)
201
+ return M + b;
202
+ R -= D + n.size, M += b + 1, n = n.right;
203
+ }
83
204
  }
84
- return Math.min(o, x - 1);
205
+ return Math.max(0, Ne(s) - 1);
206
+ },
207
+ getKey(u) {
208
+ var n;
209
+ return (n = r(u)) == null ? void 0 : n.key;
210
+ },
211
+ getIndex(u) {
212
+ let n = e.get(u);
213
+ if (!n) return;
214
+ let M = Ne(n.left);
215
+ for (; n.parent; )
216
+ n === n.parent.right && (M += Ne(n.parent.left) + 1), n = n.parent;
217
+ return n === s ? M : void 0;
218
+ },
219
+ getSizeByKey(u) {
220
+ var n;
221
+ return (n = e.get(u)) == null ? void 0 : n.size;
222
+ },
223
+ hasKey(u) {
224
+ return e.has(u);
225
+ },
226
+ append(u) {
227
+ u.length !== 0 && (z(u), s = mt(s, y(u)), s && (s.parent = void 0));
228
+ },
229
+ prepend(u) {
230
+ u.length !== 0 && (z(u), s = mt(y(u), s), s && (s.parent = void 0));
85
231
  }
86
232
  };
87
233
  }
88
- const ot = ["aria-label"], nt = {
234
+ const Ut = ["aria-label", "aria-live"], qt = {
89
235
  key: 0,
90
236
  class: "vue-chat-virtual-scroll__loading-older",
91
237
  role: "status",
92
238
  "aria-live": "polite"
93
- }, it = ["aria-posinset", "aria-setsize"], st = /* @__PURE__ */ Oe({
239
+ }, Gt = ["aria-posinset", "aria-setsize"], Xt = {
240
+ key: 0,
241
+ class: "vue-chat-virtual-scroll__new-items",
242
+ role: "status"
243
+ }, Zt = /* @__PURE__ */ tt({
94
244
  name: "ChatVirtualScroll",
245
+ inheritAttrs: !1,
95
246
  __name: "ChatVirtualScroll",
96
247
  props: {
97
248
  items: {},
249
+ itemsVersion: {},
98
250
  estimatedItemSize: { default: 48 },
251
+ estimateItemSize: {},
99
252
  height: { default: 400 },
100
253
  overscan: { default: 5 },
101
254
  size: { default: void 0 },
@@ -106,379 +259,559 @@ const ot = ["aria-label"], nt = {
106
259
  initialScroll: { default: "bottom" },
107
260
  hasOlder: { type: Boolean, default: !1 },
108
261
  loadingOlder: { type: Boolean, default: !1 },
109
- loadOlderThreshold: { default: 120 }
262
+ loadOlderThreshold: { default: 120 },
263
+ scrollEndDelay: { default: 150 },
264
+ syncMeasurement: { type: Boolean, default: !0 },
265
+ pinnedKeys: { default: () => [] },
266
+ maxPinnedItems: { default: 20 },
267
+ keepFocusedItem: { type: Boolean, default: !0 },
268
+ showNewItemsIndicator: { type: Boolean, default: !0 },
269
+ newItemsLabel: { type: Function, default: void 0 },
270
+ forceStickToBottom: { type: Function, default: void 0 },
271
+ contain: { type: Boolean, default: !0 }
110
272
  },
111
- emits: ["scroll", "loadOlder", "bottomChange"],
112
- setup(l, { expose: P, emit: x }) {
113
- const e = l, p = x, f = j(), r = j(0), o = j(0), m = j(0), A = j(0), O = j(!0), U = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Set();
114
- let D, w, k = -1, E = !1, F = !1, W = !1, ne, Z = 0, H = !1, ae = 0, R, J, Y, le = 0;
115
- const se = Ue(), { getItemKey: me } = Pe({
273
+ emits: ["scroll", "loadOlder", "bottomChange", "scrollingChange", "newItemsChange", "visibleChange"],
274
+ setup(t, { expose: s, emit: I }) {
275
+ const e = t, z = I, x = X(), y = X(0), r = X(0), u = X(0), n = X(0), M = X(!0), R = X(0), D = X(), b = /* @__PURE__ */ new Set(), A = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Set();
276
+ let $, B, V = -1, G = !1, Y = 0, se = !1, H = 0, ae, ne, le, ie = 0;
277
+ const te = Mt(), { getItemKey: ue } = lt({
116
278
  componentName: "ChatVirtualScroll",
117
279
  items: () => e.items,
118
280
  itemKey: () => e.itemKey
119
- }), de = n(
281
+ }), fe = h(
120
282
  () => Number.isFinite(e.estimatedItemSize) ? Math.max(1, e.estimatedItemSize) : 48
121
- ), ue = n(() => Math.max(0, Math.floor(e.overscan))), we = n(
283
+ ), he = h(() => Math.max(0, Math.floor(e.overscan))), ve = h(
284
+ () => Number.isFinite(e.scrollEndDelay) ? Math.max(0, e.scrollEndDelay) : 150
285
+ ), {
286
+ isScrolling: J,
287
+ setScrolling: O,
288
+ scheduleScrollEnd: S,
289
+ handleScrollEnd: P,
290
+ handleTouchStart: oe,
291
+ handleTouchEnd: me,
292
+ handleWheel: Ae,
293
+ handleKeyDown: E,
294
+ handlePointerDown: F,
295
+ handlePointerUp: _,
296
+ dispose: pe
297
+ } = Yt({
298
+ delay: () => ve.value,
299
+ viewport: () => x.value,
300
+ hasProgrammaticScroll: () => le !== void 0,
301
+ onInterrupt: $e,
302
+ onStart: () => {
303
+ r.value = Y;
304
+ },
305
+ onSettled: () => {
306
+ const o = le;
307
+ if (le = void 0, o) {
308
+ o();
309
+ return;
310
+ }
311
+ y.value = L(), xe();
312
+ },
313
+ onChange: (o) => {
314
+ G && z("scrollingChange", o);
315
+ }
316
+ }), ze = h(
317
+ () => Number.isFinite(e.maxPinnedItems) ? Math.max(0, Math.floor(e.maxPinnedItems)) : 20
318
+ ), be = h(
122
319
  () => e.size !== void 0 && Number.isFinite(e.size) && e.size > 0 ? Math.max(1, Math.floor(e.size)) : void 0
123
- ), G = n(() => m.value > 0 ? m.value : typeof e.height == "number" ? Math.max(0, e.height) : de.value), u = n(() => {
124
- const i = e.items.map((h, M) => me(h, M));
125
- return {
126
- keys: i,
127
- indexes: new Map(i.map((h, M) => [h, M])),
128
- sizes: at(i.map((h) => U.get(h) ?? de.value))
129
- };
130
- }), d = n(() => (A.value, { sizes: u.value.sizes, total: u.value.sizes.total }));
131
- function z(i = d.value.total) {
132
- return Math.max(0, i - G.value);
320
+ ), Me = h(() => u.value > 0 ? u.value : typeof e.height == "number" ? Math.max(0, e.height) : fe.value);
321
+ function ce(o, c) {
322
+ var N;
323
+ const p = (N = e.estimateItemSize) == null ? void 0 : N.call(e, o, c);
324
+ return Number.isFinite(p) && (p ?? 0) > 0 ? p : fe.value;
325
+ }
326
+ function de(o) {
327
+ return jt(e.items.map((c, p) => {
328
+ const N = ue(c, p);
329
+ return {
330
+ key: N,
331
+ size: b.has(N) ? (o == null ? void 0 : o.getSizeByKey(N)) ?? ce(c, p) : ce(c, p)
332
+ };
333
+ }));
133
334
  }
134
- function Q(i) {
135
- return d.value.sizes.findIndex(i);
335
+ const v = ft({ sizes: de() }), T = h(() => (n.value, { sizes: v.value.sizes, total: v.value.sizes.total }));
336
+ function i(o = T.value.total) {
337
+ return Math.max(0, o - Me.value);
136
338
  }
137
- r.value = e.initialScroll === "bottom" ? z() : 0;
138
- const he = n(() => {
339
+ function q(o) {
340
+ return T.value.sizes.findIndex(o);
341
+ }
342
+ y.value = e.initialScroll === "bottom" ? i() : 0;
343
+ const Q = h(() => {
139
344
  if (e.items.length === 0) return { start: 0, end: 0 };
140
- const i = Q(r.value), h = Q(r.value + G.value) + 1, M = Math.max(0, i - ue.value), K = Math.min(
345
+ const o = q(y.value), c = q(y.value + Me.value) + 1;
346
+ return {
347
+ start: o,
348
+ end: Math.min(e.items.length, c)
349
+ };
350
+ }), ke = h(() => {
351
+ if (e.items.length === 0) return { start: 0, end: 0 };
352
+ const o = Q.value.start, c = Q.value.end, p = Math.max(0, o - he.value), N = Math.min(
141
353
  e.items.length,
142
- h + ue.value
143
- ), pe = we.value;
144
- if (pe === void 0 || K - M <= pe) return { start: M, end: K };
145
- const xe = Math.max(0, pe - (h - i)), Te = i - M, Se = K - h;
146
- let Ee = Math.min(Te, Math.ceil(xe / 2));
147
- const $e = Math.min(Se, xe - Ee);
148
- return Ee = Math.min(Te, xe - $e), { start: i - Ee, end: h + $e };
149
- }), y = n(() => he.value.start), L = n(() => he.value.end), B = n(
150
- () => e.items.slice(y.value, L.value).map((i, h) => {
151
- const M = y.value + h;
152
- return {
153
- item: i,
154
- index: M,
155
- key: me(i, M),
156
- bottom: Math.max(d.value.total, G.value) - d.value.sizes.getOffset(M + 1) + o.value
157
- };
158
- })
159
- ), te = n(() => ({
160
- height: Fe(e.height)
161
- }));
162
- function oe(i = d.value.total) {
163
- var K;
164
- const h = z(i), M = Math.min(0, ((K = f.value) == null ? void 0 : K.scrollTop) ?? 0);
165
- return Math.max(0, Math.min(h, h + M + Z));
166
- }
167
- function re(i = !1) {
168
- if (H || (W || Y) && !i || Z === 0) return;
169
- H = !0;
170
- const h = le, M = ++ae;
171
- o.value = 0, C(() => {
172
- if (M !== ae) return;
173
- H = !1;
174
- const K = f.value;
175
- !K || h !== le || Z === 0 || (Z = 0, K.scrollTop = Math.min(0, r.value - z()), J = K.scrollTop, r.value = oe(), b(), ve());
354
+ c + he.value
355
+ ), Pe = be.value;
356
+ if (Pe === void 0 || N - p <= Pe) return { start: p, end: N };
357
+ const Ce = Math.max(0, Pe - (c - o)), Ve = o - p, Oe = N - c;
358
+ let Fe = Math.min(Ve, Math.ceil(Ce / 2));
359
+ const Je = Math.min(Oe, Ce - Fe);
360
+ return Fe = Math.min(Ve, Ce - Je), { start: o - Fe, end: c + Je };
361
+ }), ge = h(() => ke.value.start), Ee = h(() => ke.value.end), d = h(() => {
362
+ const o = /* @__PURE__ */ new Set();
363
+ for (let c = ge.value; c < Ee.value; c += 1)
364
+ o.add(c);
365
+ for (const c of e.pinnedKeys.slice(0, ze.value)) {
366
+ const p = v.value.sizes.getIndex(c);
367
+ p !== void 0 && o.add(p);
368
+ }
369
+ if (e.keepFocusedItem && D.value !== void 0) {
370
+ const c = v.value.sizes.getIndex(D.value);
371
+ c !== void 0 && o.add(c);
372
+ }
373
+ return [...o].sort((c, p) => c - p);
374
+ }), K = h(() => d.value.map((o) => {
375
+ const c = e.items[o];
376
+ return {
377
+ item: c,
378
+ index: o,
379
+ key: ue(c, o),
380
+ bottom: Math.max(T.value.total, Me.value) - T.value.sizes.getOffset(o + 1) + r.value
381
+ };
382
+ })), m = h(() => ({
383
+ height: gt(e.height)
384
+ })), w = h(() => ({
385
+ "vue-chat-virtual-scroll--contained": e.contain
386
+ })), k = h(() => M.value && !J.value ? "polite" : "off");
387
+ function ee(o) {
388
+ var c;
389
+ return ((c = e.newItemsLabel) == null ? void 0 : c.call(e, o)) ?? `${o} new ${o === 1 ? "message" : "messages"}`;
390
+ }
391
+ function L(o = T.value.total) {
392
+ var N;
393
+ const c = i(o), p = Math.min(0, ((N = x.value) == null ? void 0 : N.scrollTop) ?? 0);
394
+ return Math.max(0, Math.min(c, c + p + Y));
395
+ }
396
+ function xe(o = !1) {
397
+ if (se || (J.value || le) && !o || Y === 0) return;
398
+ se = !0;
399
+ const c = ie, p = ++H;
400
+ r.value = 0, Z(() => {
401
+ if (p !== H) return;
402
+ se = !1;
403
+ const N = x.value;
404
+ !N || c !== ie || Y === 0 || (Y = 0, N.scrollTop = Math.min(0, y.value - i()), ne = N.scrollTop, y.value = L(), a(), W());
176
405
  });
177
406
  }
178
- function ye(i) {
179
- const h = f.value;
180
- if (h) {
181
- if (Z += i, r.value = oe(), Z === 0 || z() === 0) {
182
- Z = 0, o.value = 0;
407
+ function we(o) {
408
+ const c = x.value;
409
+ if (c) {
410
+ if (Y += o, y.value = L(), Y === 0 || i() === 0) {
411
+ Y = 0, r.value = 0;
183
412
  return;
184
413
  }
185
- (W || Y) && !H ? (o.value = Z, h.scrollTop >= -1 && re(!0)) : re();
414
+ (J.value || le) && !se ? (r.value = Y, c.scrollTop >= -1 && xe(!0)) : xe();
186
415
  }
187
416
  }
188
- function _() {
189
- clearTimeout(ne), ne = void 0;
190
- }
191
- function ee() {
192
- if (F) return;
193
- _(), W = !1;
194
- const i = Y;
195
- if (Y = void 0, i) {
196
- i();
417
+ function $e() {
418
+ ae = void 0, le = void 0;
419
+ }
420
+ function De() {
421
+ if (!e.keepFocusedItem) {
422
+ D.value = void 0;
197
423
  return;
198
424
  }
199
- r.value = oe(), re();
425
+ const o = document.activeElement, c = o instanceof Element ? o.closest(".vue-chat-virtual-scroll__item") : null;
426
+ D.value = c ? A.get(c) : void 0;
200
427
  }
201
- function s() {
202
- _(), (W || Y) && !F && (ne = setTimeout(ee, 150));
428
+ function Ie() {
429
+ De();
203
430
  }
204
- function t() {
205
- R = void 0, Y = void 0;
431
+ function Ye() {
432
+ Z(De);
206
433
  }
207
- function a() {
208
- t(), _(), F = !0, W = !0, o.value = Z;
434
+ function je(o) {
435
+ const c = Math.max(0, Math.floor(o));
436
+ c !== R.value && (R.value = c, G && z("newItemsChange", c));
209
437
  }
210
- function g(i) {
211
- F = i.touches.length > 0, s();
438
+ function Ze() {
439
+ je(0);
212
440
  }
213
- function b() {
214
- const i = f.value;
215
- if (!i) return;
216
- const M = Math.max(
441
+ function ut() {
442
+ z("visibleChange", {
443
+ scrollTop: L(),
444
+ startIndex: Q.value.start,
445
+ endIndex: Q.value.end
446
+ });
447
+ }
448
+ function a() {
449
+ const o = x.value;
450
+ if (!o) return;
451
+ const p = Math.max(
217
452
  0,
218
- d.value.total - oe() - i.clientHeight
453
+ T.value.total - L() - o.clientHeight
219
454
  ) <= Math.max(0, e.bottomThreshold);
220
- M !== O.value && (O.value = M, E && p("bottomChange", M));
455
+ p !== M.value && (M.value = p, G && z("bottomChange", p)), p && Ze();
221
456
  }
222
- function Me() {
223
- var i;
224
- m.value = ((i = f.value) == null ? void 0 : i.clientHeight) ?? 0, E && (r.value = oe()), se(f.value, e.height), C(() => {
225
- b(), ve();
457
+ function l() {
458
+ var o;
459
+ u.value = ((o = x.value) == null ? void 0 : o.clientHeight) ?? 0, G && (y.value = L()), te(x.value, e.height), Z(() => {
460
+ a(), W();
226
461
  });
227
462
  }
228
- function ge() {
229
- var i, h;
230
- R && J !== void 0 && Math.abs((((i = f.value) == null ? void 0 : i.scrollTop) ?? 0) - J) > 1 && t(), r.value = oe(), Z !== 0 && (((h = f.value) == null ? void 0 : h.scrollTop) ?? 0) >= -1 && re(!0), s(), b(), p("scroll", {
231
- scrollTop: r.value,
232
- startIndex: y.value,
233
- endIndex: L.value
234
- }), ve();
235
- }
236
- function ve() {
237
- const i = f.value;
238
- !E || !i || !e.hasOlder || e.loadingOlder || k === e.items.length || oe() <= Math.max(0, e.loadOlderThreshold) && (k = e.items.length, p("loadOlder"));
239
- }
240
- function Le(i) {
241
- const h = i.borderBoxSize;
242
- if (h) {
243
- const M = Array.isArray(h) ? h[0] : h;
244
- if (M != null && M.blockSize) return M.blockSize;
463
+ function g() {
464
+ var o, c;
465
+ ae && ne !== void 0 && Math.abs((((o = x.value) == null ? void 0 : o.scrollTop) ?? 0) - ne) > 1 && $e(), y.value = L(), Y !== 0 && (((c = x.value) == null ? void 0 : c.scrollTop) ?? 0) >= -1 && xe(!0), S(), a(), z("scroll", {
466
+ scrollTop: y.value,
467
+ startIndex: ge.value,
468
+ endIndex: Ee.value
469
+ }), W();
470
+ }
471
+ function W() {
472
+ const o = x.value;
473
+ !G || !o || !e.hasOlder || e.loadingOlder || V === e.items.length || L() <= Math.max(0, e.loadOlderThreshold) && (V = e.items.length, z("loadOlder"));
474
+ }
475
+ function Te(o) {
476
+ const c = o.borderBoxSize;
477
+ if (c) {
478
+ const p = Array.isArray(c) ? c[0] : c;
479
+ if (p != null && p.blockSize) return p.blockSize;
245
480
  }
246
- return i.contentRect.height;
247
- }
248
- function ke(i) {
249
- const h = d.value.total, M = oe(), K = !W && !Y && O.value && e.stickToBottom && (E || e.initialScroll === "bottom"), pe = Q(M + G.value - 1), xe = !K && M <= 0;
250
- let Te = 0, Se = !1;
251
- for (const { key: Je, height: We } of i) {
252
- if (!Number.isFinite(We) || We <= 0) continue;
253
- const _e = u.value.indexes.get(Je);
254
- if (_e === void 0) continue;
255
- const Qe = d.value.sizes.getSize(_e);
256
- U.set(Je, We), !(Math.abs(Qe - We) < 0.5) && (_e <= pe && (Te += We - Qe), d.value.sizes.setSize(_e, We), Se = !0);
481
+ return o.contentRect.height;
482
+ }
483
+ function Ke(o) {
484
+ const c = T.value.total, p = L(), N = !J.value && !le && M.value && e.stickToBottom && (G || e.initialScroll === "bottom"), Pe = q(p + Me.value - 1), Ce = !N && p <= 0;
485
+ let Ve = 0, Oe = !1;
486
+ for (const { key: yt, height: Qe } of o) {
487
+ if (!Number.isFinite(Qe) || Qe <= 0) continue;
488
+ const Ue = v.value.sizes.getIndex(yt);
489
+ if (Ue === void 0) continue;
490
+ const _e = T.value.sizes.getSize(Ue);
491
+ b.add(yt), !(Math.abs(_e - Qe) < 0.5) && (Ue <= Pe && (Ve += Qe - _e), T.value.sizes.setSize(Ue, Qe), Oe = !0);
257
492
  }
258
- if (!Se) return;
259
- A.value += 1;
260
- const Ee = z() - z(h), $e = R && u.value.indexes.get(R.key), Ne = $e !== void 0 && R ? Ie($e, R.align) : K ? z() : xe ? 0 : M + Te;
261
- ye(Ne - M - Ee), C(b);
262
- }
263
- function v(i) {
264
- const h = [];
265
- for (const M of i) {
266
- const K = q.get(M.target);
267
- K !== void 0 && h.push({ key: K, height: Le(M) });
493
+ if (!Oe) return;
494
+ n.value += 1;
495
+ const Fe = i() - i(c), Je = ae && v.value.sizes.getIndex(ae.key), bt = Je !== void 0 && ae ? Ct(Je, ae.align) : N ? i() : Ce ? 0 : p + Ve;
496
+ we(bt - p - Fe), Z(a);
497
+ }
498
+ function Be(o) {
499
+ const c = [];
500
+ for (const p of o) {
501
+ const N = A.get(p.target);
502
+ N !== void 0 && c.push({ key: N, height: Te(p) });
268
503
  }
269
- ke(h);
504
+ Ke(c);
270
505
  }
271
- function S() {
272
- const i = [];
273
- for (const h of V) {
274
- const M = q.get(h);
275
- M !== void 0 && h.isConnected && i.push({ key: M, height: h.getBoundingClientRect().height });
506
+ function He() {
507
+ const o = [];
508
+ for (const c of C) {
509
+ const p = A.get(c);
510
+ p !== void 0 && c.isConnected && o.push({ key: p, height: c.getBoundingClientRect().height });
276
511
  }
277
- V.clear(), ke(i);
278
- }
279
- function T(i, h) {
280
- i instanceof HTMLElement && q.get(i) !== h && (q.set(i, h), U.has(h) || V.add(i), w == null || w.observe(i));
281
- }
282
- function fe() {
283
- for (const [i] of q)
284
- i.isConnected || (w == null || w.unobserve(i), q.delete(i), V.delete(i));
285
- }
286
- function X(i, h, M = !1) {
287
- const K = f.value;
288
- if (!K) return;
289
- const pe = oe(), xe = o.value !== 0, Te = ++le;
290
- ae += 1, H = !1, R = void 0;
291
- const Se = h.behavior ?? "auto";
292
- Y = Se === "smooth" ? () => be(i) : void 0, Z = 0, o.value = 0, W = !1, _(), Se === "auto" && (r.value = i);
293
- const Ee = () => {
294
- f.value !== K || Te !== le || (xe && Se !== "auto" && (K.scrollTop = pe - z()), M && Se === "auto" ? K.scrollTop = i - z() : K.scrollTo({ ...h, top: i - z(), behavior: Se }), J = K.scrollTop, Se === "auto" ? r.value = oe() : s(), C(b));
512
+ C.clear(), Ke(o);
513
+ }
514
+ function ot(o, c) {
515
+ o instanceof HTMLElement && A.get(o) !== c && (A.set(o, c), e.syncMeasurement && !b.has(c) && C.add(o), B == null || B.observe(o));
516
+ }
517
+ function Bt() {
518
+ for (const [o] of A)
519
+ o.isConnected || (B == null || B.unobserve(o), A.delete(o), C.delete(o));
520
+ }
521
+ function ct(o, c, p = !1) {
522
+ const N = x.value;
523
+ if (!N) return;
524
+ const Pe = L(), Ce = r.value !== 0, Ve = ++ie;
525
+ H += 1, se = !1, ae = void 0;
526
+ const Oe = c.behavior ?? "auto";
527
+ le = Oe === "smooth" ? () => Et(o) : void 0, Y = 0, r.value = 0, O(!1), pe(), Oe === "auto" && (y.value = o);
528
+ const Fe = () => {
529
+ x.value !== N || Ve !== ie || (Ce && Oe !== "auto" && (N.scrollTop = Pe - i()), p && Oe === "auto" ? N.scrollTop = o - i() : N.scrollTo({ ...c, top: o - i(), behavior: Oe }), ne = N.scrollTop, Oe === "auto" ? y.value = L() : S(), Z(a));
295
530
  };
296
- xe ? C(Ee) : Ee();
297
- }
298
- function be(i, h = {}) {
299
- const M = f.value;
300
- if (!M) return;
301
- const K = Math.max(0, d.value.total - M.clientHeight), pe = Math.min(
302
- Math.max(0, Number.isFinite(i) ? i : 0),
303
- K
531
+ Ce ? Z(Fe) : Fe();
532
+ }
533
+ function Et(o, c = {}) {
534
+ const p = x.value;
535
+ if (!p) return;
536
+ const N = Math.max(0, T.value.total - p.clientHeight), Pe = Math.min(
537
+ Math.max(0, Number.isFinite(o) ? o : 0),
538
+ N
304
539
  );
305
- X(pe, h);
540
+ ct(Pe, c);
306
541
  }
307
- function Ie(i, h) {
308
- const M = d.value.sizes.getSize(i);
309
- let K = d.value.sizes.getOffset(i);
310
- return h === "center" ? K -= (G.value - M) / 2 : h === "end" && (K -= G.value - M), Math.max(0, Math.min(K, z()));
542
+ function Ct(o, c) {
543
+ const p = T.value.sizes.getSize(o);
544
+ let N = T.value.sizes.getOffset(o);
545
+ return c === "center" ? N -= (Me.value - p) / 2 : c === "end" && (N -= Me.value - p), Math.max(0, Math.min(N, i()));
311
546
  }
312
- function Be(i, h = {}) {
313
- if (!f.value || e.items.length === 0) return;
314
- const M = Math.min(
547
+ function Tt(o, c = {}) {
548
+ if (!x.value || e.items.length === 0) return;
549
+ const p = Math.min(
315
550
  e.items.length - 1,
316
- Math.max(0, Math.floor(Number.isFinite(i) ? i : 0))
317
- ), { align: K = "start", ...pe } = h;
318
- X(Ie(M, K), pe);
319
- const xe = u.value.keys[M];
320
- h.behavior === "smooth" ? Y = () => {
321
- const Te = u.value.indexes.get(xe);
322
- Te !== void 0 && Be(Te, { align: K });
323
- } : R = { key: xe, align: K };
324
- }
325
- function Ke(i = "auto") {
326
- X(0, { behavior: i });
327
- }
328
- function He(i = "auto") {
329
- const h = f.value;
330
- if (!h) return;
331
- const M = Math.max(0, d.value.total - h.clientHeight);
332
- X(M, { behavior: i }, !0), i === "smooth" && (Y = () => He());
333
- }
334
- return ie(
335
- u,
336
- async (i, h) => {
337
- const M = h.sizes.total, K = oe(M), pe = !W && !Y && O.value && e.stickToBottom, xe = h.sizes.findIndex(K + G.value - 1), Te = h.keys[xe], Se = Te === void 0 ? void 0 : i.indexes.get(Te), Ee = z() - z(M);
338
- for (const $e of U.keys())
339
- i.indexes.has($e) || U.delete($e);
340
- if (i.keys.length === 0 || Se === void 0) {
341
- Z = 0, o.value = 0, r.value = pe ? z() : Math.min(K, z());
342
- const $e = r.value, Ne = le;
343
- await C(), Ne === le && u.value === i && X($e, {}, !0);
551
+ Math.max(0, Math.floor(Number.isFinite(o) ? o : 0))
552
+ ), { align: N = "start", ...Pe } = c;
553
+ ct(Ct(p, N), Pe);
554
+ const Ce = v.value.sizes.getKey(p);
555
+ c.behavior === "smooth" ? le = () => {
556
+ const Ve = v.value.sizes.getIndex(Ce);
557
+ Ve !== void 0 && Tt(Ve, { align: N });
558
+ } : ae = { key: Ce, align: N };
559
+ }
560
+ function Kt(o, c = {}) {
561
+ const p = v.value.sizes.getIndex(o);
562
+ p !== void 0 && Tt(p, c);
563
+ }
564
+ function Vt() {
565
+ return L();
566
+ }
567
+ function Wt(o = "auto") {
568
+ ct(0, { behavior: o });
569
+ }
570
+ function pt(o = "auto") {
571
+ const c = x.value;
572
+ if (!c) return;
573
+ const p = Math.max(0, T.value.total - c.clientHeight);
574
+ ct(p, { behavior: o }, !0), o === "smooth" && (le = () => pt());
575
+ }
576
+ const Lt = X(0);
577
+ function Rt() {
578
+ Lt.value += 1;
579
+ }
580
+ return ye(
581
+ () => {
582
+ const o = e.items.length;
583
+ return [
584
+ e.items,
585
+ o,
586
+ o > 0 ? ue(e.items[0], 0) : void 0,
587
+ o > 0 ? ue(e.items[Math.floor(o / 2)], Math.floor(o / 2)) : void 0,
588
+ o > 0 ? ue(e.items[o - 1], o - 1) : void 0,
589
+ e.itemKey,
590
+ e.estimatedItemSize,
591
+ e.estimateItemSize,
592
+ e.itemsVersion,
593
+ Lt.value
594
+ ];
595
+ },
596
+ async (o, c) => {
597
+ const p = v.value.sizes, N = p.length, Pe = p.total, Ce = L(Pe), Ve = p.findIndex(Ce + Me.value - 1), Oe = p.getKey(Ve), Fe = p.getOffset(Ve + 1), Je = e.items.length, bt = o[5] !== c[5] || o[6] !== c[6] || o[7] !== c[7], yt = o[8] !== c[8] || o[9] !== c[9];
598
+ function Qe(Le) {
599
+ if (N === 0) return !0;
600
+ const We = /* @__PURE__ */ new Set([0, Math.floor(N / 2), N - 1]);
601
+ for (const it of We) {
602
+ const wt = Le + it;
603
+ if (wt >= Je || p.getKey(it) !== ue(e.items[wt], wt))
604
+ return !1;
605
+ }
606
+ return !0;
607
+ }
608
+ const Ue = Je - N;
609
+ let _e = "rebuild";
610
+ !bt && !yt && Ue > 0 && (Qe(0) ? _e = "append" : Qe(Ue) && (_e = "prepend"));
611
+ let qe = p;
612
+ _e === "append" ? qe.append(e.items.slice(N).map((Le, We) => {
613
+ const it = N + We;
614
+ return { key: ue(Le, it), size: ce(Le, it) };
615
+ })) : _e === "prepend" ? qe.prepend(e.items.slice(0, Ue).map((Le, We) => ({ key: ue(Le, We), size: ce(Le, We) }))) : qe = de(p), v.value = { sizes: qe };
616
+ const St = _e === "append" ? Array.from({ length: Ue }, (Le, We) => N + We) : [], It = St.some(
617
+ (Le) => {
618
+ var We;
619
+ return ((We = e.forceStickToBottom) == null ? void 0 : We.call(e, e.items[Le], Le)) === !0;
620
+ }
621
+ ) || !J.value && !le && M.value && e.stickToBottom;
622
+ St.length > 0 && !It && je(R.value + St.length);
623
+ const Pt = Oe === void 0 ? void 0 : qe.getIndex(Oe), Ht = i() - i(Pe);
624
+ for (const Le of b)
625
+ qe.hasKey(Le) || b.delete(Le);
626
+ if (qe.length === 0 || Pt === void 0) {
627
+ Y = 0, r.value = 0, y.value = It ? i() : Math.min(Ce, i());
628
+ const Le = y.value, We = ie;
629
+ await Z(), We === ie && v.value.sizes === qe && ct(Le, {}, !0);
344
630
  } else {
345
- const $e = i.sizes.getOffset(Se + 1) - h.sizes.getOffset(xe + 1), Ne = pe ? z() : K + $e;
346
- ye(Ne - K - Ee), await C();
631
+ const Le = qe.getOffset(Pt + 1) - Fe, We = It ? i() : Ce + Le;
632
+ we(We - Ce - Ht), await Z();
347
633
  }
348
- f.value && (r.value = oe(), b(), ve());
634
+ x.value && (y.value = L(), a(), W());
349
635
  }
350
- ), ie(
636
+ ), ye(
351
637
  () => [e.hasOlder, e.loadingOlder],
352
- async ([i]) => {
353
- i || (k = -1), await C(), ve();
638
+ async ([o]) => {
639
+ o || (V = -1), await Z(), W();
354
640
  }
355
- ), Ae(() => {
356
- if (Me(), f.value && (f.value.scrollTop = e.initialScroll === "bottom" ? 0 : -z(), r.value = oe()), S(), typeof ResizeObserver < "u") {
357
- D = new ResizeObserver(Me), w = new ResizeObserver(v), f.value && D.observe(f.value);
358
- for (const [i] of q)
359
- w.observe(i);
641
+ ), ye(
642
+ () => e.syncMeasurement,
643
+ (o) => {
644
+ if (C.clear(), !!o) {
645
+ for (const [c, p] of A)
646
+ b.has(p) || C.add(c);
647
+ Z(He);
648
+ }
360
649
  }
361
- C(() => {
362
- E = !0, b(), ve();
650
+ ), ye(
651
+ Q,
652
+ () => {
653
+ G && ut();
654
+ },
655
+ { flush: "post" }
656
+ ), at(() => {
657
+ if (window.addEventListener("pointerup", _, { passive: !0 }), window.addEventListener("pointercancel", _, { passive: !0 }), l(), x.value && (x.value.scrollTop = e.initialScroll === "bottom" ? 0 : -i(), y.value = L()), He(), typeof ResizeObserver < "u") {
658
+ $ = new ResizeObserver(l), B = new ResizeObserver(Be), x.value && $.observe(x.value);
659
+ for (const [o] of A)
660
+ B.observe(o);
661
+ }
662
+ Z(() => {
663
+ G = !0, a(), W(), ut();
363
664
  });
665
+ }), $t(() => {
666
+ Bt(), He();
364
667
  }), Xe(() => {
365
- fe(), S();
366
- }), Ce(() => {
367
- E = !1, _(), t(), Z = 0, le += 1, ae += 1, D && (D.disconnect(), D = void 0), w && (w.disconnect(), w = void 0), q.clear(), V.clear();
368
- }), P({
369
- isAtBottom: O,
370
- scrollTo: be,
371
- scrollToIndex: Be,
372
- scrollToTop: Ke,
373
- scrollToBottom: He
374
- }), (i, h) => (I(), $("div", {
375
- ref_key: "viewport",
376
- ref: f,
377
- class: "vue-chat-virtual-scroll",
378
- style: N(te.value),
379
- role: "log",
380
- "aria-label": l.ariaLabel,
381
- "aria-live": "polite",
382
- tabindex: "0",
383
- onScrollPassive: ge,
384
- onScrollendPassive: ee,
385
- onPointerdownPassive: t,
386
- onWheelPassive: t,
387
- onKeydown: t,
388
- onTouchstartPassive: a,
389
- onTouchendPassive: g,
390
- onTouchcancelPassive: g
668
+ G = !1, window.removeEventListener("pointerup", _), window.removeEventListener("pointercancel", _), pe(), $e(), Y = 0, ie += 1, H += 1, $ && ($.disconnect(), $ = void 0), B && (B.disconnect(), B = void 0), A.clear(), C.clear();
669
+ }), s({
670
+ isAtBottom: M,
671
+ isScrolling: J,
672
+ newItemsCount: R,
673
+ clearNewItems: Ze,
674
+ refresh: Rt,
675
+ getScrollPosition: Vt,
676
+ scrollTo: Et,
677
+ scrollToIndex: Tt,
678
+ scrollToKey: Kt,
679
+ scrollToTop: Wt,
680
+ scrollToBottom: pt
681
+ }), (o, c) => (j(), U("div", {
682
+ class: "vue-chat-virtual-scroll__root",
683
+ style: re(m.value)
391
684
  }, [
392
- Ge("div", {
393
- class: "vue-chat-virtual-scroll__spacer",
394
- style: N({ height: `${Math.max(G.value, d.value.total + o.value)}px` })
395
- }, [
396
- l.loadingOlder ? (I(), $("div", nt, [
397
- Ge("div", null, [
398
- ce(i.$slots, "loadingOlder", {}, () => [
399
- h[0] || (h[0] = Ve("Loading older messages…", -1))
400
- ])
401
- ])
402
- ])) : ze("", !0),
403
- (I(!0), $(Re, null, De(B.value, ({ item: M, index: K, key: pe, bottom: xe }) => (I(), $("div", {
404
- key: pe,
405
- ref_for: !0,
406
- ref: (Te) => T(Te, pe),
407
- class: "vue-chat-virtual-scroll__item",
408
- style: N({ transform: `translateY(${-xe}px)` }),
409
- role: "article",
410
- "aria-posinset": K + 1,
411
- "aria-setsize": l.items.length
685
+ rt("div", Ot(o.$attrs, {
686
+ ref_key: "viewport",
687
+ ref: x,
688
+ class: ["vue-chat-virtual-scroll", w.value],
689
+ role: "log",
690
+ "aria-label": t.ariaLabel,
691
+ "aria-live": k.value,
692
+ "aria-relevant": "additions",
693
+ "aria-atomic": "false",
694
+ tabindex: "0",
695
+ onScrollPassive: g,
696
+ onScrollendPassive: c[0] || (c[0] = //@ts-ignore
697
+ (...p) => f(P) && f(P)(...p)),
698
+ onPointerdownPassive: c[1] || (c[1] = //@ts-ignore
699
+ (...p) => f(F) && f(F)(...p)),
700
+ onWheelPassive: c[2] || (c[2] = //@ts-ignore
701
+ (...p) => f(Ae) && f(Ae)(...p)),
702
+ onKeydown: c[3] || (c[3] = //@ts-ignore
703
+ (...p) => f(E) && f(E)(...p)),
704
+ onFocusin: Ie,
705
+ onFocusout: Ye,
706
+ onTouchstartPassive: c[4] || (c[4] = //@ts-ignore
707
+ (...p) => f(oe) && f(oe)(...p)),
708
+ onTouchendPassive: c[5] || (c[5] = //@ts-ignore
709
+ (...p) => f(me) && f(me)(...p)),
710
+ onTouchcancelPassive: c[6] || (c[6] = //@ts-ignore
711
+ (...p) => f(me) && f(me)(...p))
712
+ }), [
713
+ rt("div", {
714
+ class: "vue-chat-virtual-scroll__spacer",
715
+ style: re({ height: `${Math.max(Me.value, T.value.total + r.value)}px` })
412
716
  }, [
413
- ce(i.$slots, "default", {
414
- item: M,
415
- index: K
416
- })
417
- ], 12, it))), 128)),
418
- l.items.length ? ze("", !0) : ce(i.$slots, "empty", {}, void 0, void 0, 1)
419
- ], 4)
420
- ], 44, ot));
717
+ t.loadingOlder ? (j(), U("div", qt, [
718
+ rt("div", null, [
719
+ Se(o.$slots, "loadingOlder", {}, () => [
720
+ c[8] || (c[8] = Ge("Loading older messages…", -1))
721
+ ])
722
+ ])
723
+ ])) : Re("", !0),
724
+ (j(!0), U(et, null, nt(K.value, ({ item: p, index: N, key: Pe, bottom: Ce }) => (j(), U("div", {
725
+ key: Pe,
726
+ ref_for: !0,
727
+ ref: (Ve) => ot(Ve, Pe),
728
+ class: "vue-chat-virtual-scroll__item",
729
+ style: re({ transform: `translateY(${-Ce}px)` }),
730
+ role: "article",
731
+ "aria-posinset": N + 1,
732
+ "aria-setsize": t.items.length
733
+ }, [
734
+ Se(o.$slots, "default", {
735
+ item: p,
736
+ index: N
737
+ })
738
+ ], 12, Gt))), 128)),
739
+ t.items.length ? Re("", !0) : Se(o.$slots, "empty", {}, void 0, void 0, 1)
740
+ ], 4)
741
+ ], 16, Ut),
742
+ t.showNewItemsIndicator && R.value > 0 ? (j(), U("div", Xt, [
743
+ Se(o.$slots, "newItems", {
744
+ count: R.value,
745
+ scrollToBottom: pt
746
+ }, () => [
747
+ rt("button", {
748
+ type: "button",
749
+ onClick: c[7] || (c[7] = (p) => pt("smooth"))
750
+ }, ht(ee(R.value)), 1)
751
+ ])
752
+ ])) : Re("", !0)
753
+ ], 4));
421
754
  }
422
755
  });
423
- function qe(l) {
424
- const P = j(), x = j(0), e = j(!1), p = j(!1), f = n(() => Math.max(1, l.threshold())), r = n(
425
- () => l.refreshing() || p.value ? f.value : x.value
426
- ), o = n(
427
- () => Math.min(1, x.value / f.value)
428
- ), m = n(() => l.refreshing() || p.value ? "Refreshing…" : o.value >= 1 ? "Release to refresh" : "Pull to refresh");
429
- function A() {
430
- P.value = void 0, e.value = !1, x.value = 0;
756
+ function xt(t) {
757
+ const s = X(), I = X(0), e = X(!1), z = X(!1), x = h(() => Math.max(1, t.threshold())), y = h(
758
+ () => t.refreshing() || z.value ? x.value : I.value
759
+ ), r = h(
760
+ () => Math.min(1, I.value / x.value)
761
+ ), u = h(() => t.refreshing() || z.value ? "Refreshing…" : r.value >= 1 ? "Release to refresh" : "Pull to refresh");
762
+ function n() {
763
+ s.value = void 0, e.value = !1, I.value = 0;
431
764
  }
432
- function O(V) {
433
- var k;
434
- const D = V.currentTarget, w = ((k = l.scrollTop) == null ? void 0 : k.call(l)) ?? D.scrollTop;
435
- !l.enabled() || l.refreshing() || w > 0 || V.touches.length !== 1 || (P.value = V.touches[0].clientY, e.value = !0);
765
+ function M(b) {
766
+ var $;
767
+ const A = b.currentTarget, C = (($ = t.scrollTop) == null ? void 0 : $.call(t)) ?? A.scrollTop;
768
+ !t.enabled() || t.refreshing() || C > 0 || b.touches.length !== 1 || (s.value = b.touches[0].clientY, e.value = !0);
436
769
  }
437
- function U(V) {
438
- var E;
439
- if (P.value === void 0 || !e.value) return;
440
- const D = V.currentTarget;
441
- if ((((E = l.scrollTop) == null ? void 0 : E.call(l)) ?? D.scrollTop) > 0 || V.touches.length !== 1) {
442
- A();
770
+ function R(b) {
771
+ var B;
772
+ if (s.value === void 0 || !e.value) return;
773
+ const A = b.currentTarget;
774
+ if ((((B = t.scrollTop) == null ? void 0 : B.call(t)) ?? A.scrollTop) > 0 || b.touches.length !== 1) {
775
+ n();
443
776
  return;
444
777
  }
445
- const k = V.touches[0].clientY - P.value;
446
- if (k <= 0) {
447
- x.value = 0;
778
+ const $ = b.touches[0].clientY - s.value;
779
+ if ($ <= 0) {
780
+ I.value = 0;
448
781
  return;
449
782
  }
450
- V.preventDefault(), x.value = Math.min(k * 0.5, f.value * 2);
783
+ b.preventDefault(), I.value = Math.min($ * 0.5, x.value * 2);
451
784
  }
452
- function q() {
453
- if (P.value === void 0) return;
454
- const V = x.value >= f.value && l.enabled() && !l.refreshing();
455
- if (P.value = void 0, e.value = !1, !V) {
456
- x.value = 0;
785
+ function D() {
786
+ if (s.value === void 0) return;
787
+ const b = I.value >= x.value && t.enabled() && !t.refreshing();
788
+ if (s.value = void 0, e.value = !1, !b) {
789
+ I.value = 0;
457
790
  return;
458
791
  }
459
- x.value = f.value, p.value = !0, l.onRefresh(), C(() => {
460
- l.refreshing() || (p.value = !1, x.value = 0);
792
+ I.value = x.value, z.value = !0, t.onRefresh(), Z(() => {
793
+ t.refreshing() || (z.value = !1, I.value = 0);
461
794
  });
462
795
  }
463
- return ie(
464
- () => l.refreshing(),
465
- (V, D) => {
466
- V ? (p.value = !1, x.value = f.value) : D && (p.value = !1, x.value = 0);
796
+ return ye(
797
+ () => t.refreshing(),
798
+ (b, A) => {
799
+ b ? (z.value = !1, I.value = x.value) : A && (z.value = !1, I.value = 0);
467
800
  }
468
801
  ), {
469
802
  pulling: e,
470
- pullDistance: x,
471
- pullOffset: r,
472
- pullProgress: o,
473
- refreshMessage: m,
474
- refreshThreshold: f,
475
- handleTouchStart: O,
476
- handleTouchMove: U,
477
- handleTouchEnd: q,
478
- handleTouchCancel: A
803
+ pullDistance: I,
804
+ pullOffset: y,
805
+ pullProgress: r,
806
+ refreshMessage: u,
807
+ refreshThreshold: x,
808
+ handleTouchStart: M,
809
+ handleTouchMove: R,
810
+ handleTouchEnd: D,
811
+ handleTouchCancel: n
479
812
  };
480
813
  }
481
- const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PURE__ */ Oe({
814
+ const Jt = ["aria-label"], Qt = ["aria-posinset", "aria-setsize"], Dt = /* @__PURE__ */ tt({
482
815
  name: "DynamicVirtualScroll",
483
816
  __name: "DynamicVirtualScroll",
484
817
  props: {
@@ -497,294 +830,294 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
497
830
  pullRefreshThreshold: { default: 64 }
498
831
  },
499
832
  emits: ["scroll", "loadMore", "refresh"],
500
- setup(l, { expose: P, emit: x }) {
501
- const e = l, p = x, {
502
- pulling: f,
503
- pullDistance: r,
504
- pullOffset: o,
505
- pullProgress: m,
506
- refreshMessage: A,
507
- refreshThreshold: O,
508
- handleTouchStart: U,
509
- handleTouchMove: q,
510
- handleTouchEnd: V,
511
- handleTouchCancel: D
512
- } = qe({
833
+ setup(t, { expose: s, emit: I }) {
834
+ const e = t, z = I, {
835
+ pulling: x,
836
+ pullDistance: y,
837
+ pullOffset: r,
838
+ pullProgress: u,
839
+ refreshMessage: n,
840
+ refreshThreshold: M,
841
+ handleTouchStart: R,
842
+ handleTouchMove: D,
843
+ handleTouchEnd: b,
844
+ handleTouchCancel: A
845
+ } = xt({
513
846
  enabled: () => e.pullToRefresh,
514
847
  refreshing: () => e.refreshing,
515
848
  threshold: () => e.pullRefreshThreshold,
516
- onRefresh: () => p("refresh")
517
- }), w = j(), k = j(0), E = j(0), F = j(0), W = /* @__PURE__ */ new Map(), ne = /* @__PURE__ */ new Map();
518
- let Z, H, ae = -1;
519
- const R = Ue(), { getItemKey: J } = Pe({
849
+ onRefresh: () => z("refresh")
850
+ }), C = X(), $ = X(0), B = X(0), V = X(0), G = /* @__PURE__ */ new Map(), Y = /* @__PURE__ */ new Map();
851
+ let se, H, ae = -1;
852
+ const ne = Mt(), { getItemKey: le } = lt({
520
853
  componentName: "DynamicVirtualScroll",
521
854
  items: () => e.items,
522
855
  itemKey: () => e.itemKey
523
- }), Y = n(
856
+ }), ie = h(
524
857
  () => Math.max(1, e.estimatedItemSize)
525
- ), le = n(
526
- () => Math.max(1, e.loadingItemSize ?? Y.value)
527
- ), se = n(() => Math.max(0, Math.floor(e.overscan))), me = n(() => E.value > 0 ? E.value : typeof e.height == "number" ? Math.max(0, e.height) : Y.value), de = n(() => {
528
- F.value;
529
- const s = new Array(e.items.length + 1), t = new Array(e.items.length);
530
- s[0] = 0;
531
- for (let a = 0; a < e.items.length; a += 1) {
532
- const g = J(e.items[a], a), b = W.get(g) ?? Y.value;
533
- t[a] = b, s[a + 1] = s[a] + b;
858
+ ), te = h(
859
+ () => Math.max(1, e.loadingItemSize ?? ie.value)
860
+ ), ue = h(() => Math.max(0, Math.floor(e.overscan))), fe = h(() => B.value > 0 ? B.value : typeof e.height == "number" ? Math.max(0, e.height) : ie.value), he = h(() => {
861
+ V.value;
862
+ const v = new Array(e.items.length + 1), T = new Array(e.items.length);
863
+ v[0] = 0;
864
+ for (let i = 0; i < e.items.length; i += 1) {
865
+ const q = le(e.items[i], i), Q = G.get(q) ?? ie.value;
866
+ T[i] = Q, v[i + 1] = v[i] + Q;
534
867
  }
535
868
  return {
536
- offsets: s,
537
- sizes: t,
538
- total: s[e.items.length] ?? 0
869
+ offsets: v,
870
+ sizes: T,
871
+ total: v[e.items.length] ?? 0
539
872
  };
540
- }), ue = n(
541
- () => de.value.total + (e.loading ? le.value : 0)
542
- ), we = n(() => {
543
- const s = /* @__PURE__ */ new Map();
544
- return e.items.forEach((t, a) => {
545
- s.set(J(t, a), a);
546
- }), s;
873
+ }), ve = h(
874
+ () => he.value.total + (e.loading ? te.value : 0)
875
+ ), J = h(() => {
876
+ const v = /* @__PURE__ */ new Map();
877
+ return e.items.forEach((T, i) => {
878
+ v.set(le(T, i), i);
879
+ }), v;
547
880
  });
548
- function G(s) {
881
+ function O(v) {
549
882
  if (e.items.length === 0) return 0;
550
- const t = de.value.offsets;
551
- let a = 0, g = e.items.length;
552
- for (; a < g; ) {
553
- const b = Math.floor((a + g) / 2);
554
- t[b + 1] <= s ? a = b + 1 : g = b;
883
+ const T = he.value.offsets;
884
+ let i = 0, q = e.items.length;
885
+ for (; i < q; ) {
886
+ const Q = Math.floor((i + q) / 2);
887
+ T[Q + 1] <= v ? i = Q + 1 : q = Q;
555
888
  }
556
- return Math.min(a, e.items.length - 1);
889
+ return Math.min(i, e.items.length - 1);
557
890
  }
558
- const u = n(
891
+ const S = h(
559
892
  () => Math.max(
560
893
  0,
561
- G(k.value) - se.value
894
+ O($.value) - ue.value
562
895
  )
563
- ), d = n(() => {
896
+ ), P = h(() => {
564
897
  if (e.items.length === 0) return 0;
565
- const s = G(k.value + me.value) + 1;
898
+ const v = O($.value + fe.value) + 1;
566
899
  return Math.min(
567
900
  e.items.length,
568
- s + se.value
901
+ v + ue.value
569
902
  );
570
- }), z = n(
571
- () => e.items.slice(u.value, d.value).map((s, t) => {
572
- const a = u.value + t;
903
+ }), oe = h(
904
+ () => e.items.slice(S.value, P.value).map((v, T) => {
905
+ const i = S.value + T;
573
906
  return {
574
- item: s,
575
- index: a,
576
- key: J(s, a),
577
- top: de.value.offsets[a]
907
+ item: v,
908
+ index: i,
909
+ key: le(v, i),
910
+ top: he.value.offsets[i]
578
911
  };
579
912
  })
580
- ), Q = n(() => ({
581
- height: Fe(e.height)
913
+ ), me = h(() => ({
914
+ height: gt(e.height)
582
915
  }));
583
- function he() {
584
- var s;
585
- E.value = ((s = w.value) == null ? void 0 : s.clientHeight) ?? 0, R(w.value, e.height), C(L);
586
- }
587
- function y(s) {
588
- k.value = s.currentTarget.scrollTop, p("scroll", {
589
- scrollTop: k.value,
590
- startIndex: u.value,
591
- endIndex: d.value
592
- }), L();
593
- }
594
- function L() {
595
- const s = w.value;
596
- if (!s || !e.hasMore || e.loading || ae === e.items.length)
916
+ function Ae() {
917
+ var v;
918
+ B.value = ((v = C.value) == null ? void 0 : v.clientHeight) ?? 0, ne(C.value, e.height), Z(F);
919
+ }
920
+ function E(v) {
921
+ $.value = v.currentTarget.scrollTop, z("scroll", {
922
+ scrollTop: $.value,
923
+ startIndex: S.value,
924
+ endIndex: P.value
925
+ }), F();
926
+ }
927
+ function F() {
928
+ const v = C.value;
929
+ if (!v || !e.hasMore || e.loading || ae === e.items.length)
597
930
  return;
598
- const t = Math.max(0, e.loadMoreThreshold);
599
- ue.value - s.scrollTop - s.clientHeight <= t && (ae = e.items.length, p("loadMore"));
600
- }
601
- function B(s) {
602
- const t = s.borderBoxSize;
603
- if (t) {
604
- const a = Array.isArray(t) ? t[0] : t;
605
- if (a != null && a.blockSize) return a.blockSize;
931
+ const T = Math.max(0, e.loadMoreThreshold);
932
+ ve.value - v.scrollTop - v.clientHeight <= T && (ae = e.items.length, z("loadMore"));
933
+ }
934
+ function _(v) {
935
+ const T = v.borderBoxSize;
936
+ if (T) {
937
+ const i = Array.isArray(T) ? T[0] : T;
938
+ if (i != null && i.blockSize) return i.blockSize;
606
939
  }
607
- return s.contentRect.height;
608
- }
609
- function te(s) {
610
- const t = de.value;
611
- let a = 0, g = !1;
612
- for (const b of s) {
613
- const Me = b.target, ge = ne.get(Me), ve = B(b);
614
- if (ge === void 0 || ve <= 0) continue;
615
- const Le = W.get(ge) ?? Y.value;
616
- if (Math.abs(Le - ve) < 0.5) continue;
617
- const ke = we.value.get(ge);
618
- ke !== void 0 && t.offsets[ke + 1] <= k.value && (a += ve - Le), W.set(ge, ve), g = !0;
940
+ return v.contentRect.height;
941
+ }
942
+ function pe(v) {
943
+ const T = he.value;
944
+ let i = 0, q = !1;
945
+ for (const Q of v) {
946
+ const ke = Q.target, ge = Y.get(ke), Ee = _(Q);
947
+ if (ge === void 0 || Ee <= 0) continue;
948
+ const d = G.get(ge) ?? ie.value;
949
+ if (Math.abs(d - Ee) < 0.5) continue;
950
+ const K = J.value.get(ge);
951
+ K !== void 0 && T.offsets[K + 1] <= $.value && (i += Ee - d), G.set(ge, Ee), q = !0;
619
952
  }
620
- g && (F.value += 1, C(L), a !== 0 && C(() => {
621
- const b = w.value;
622
- b && (b.scrollTop += a, k.value = b.scrollTop);
953
+ q && (V.value += 1, Z(F), i !== 0 && Z(() => {
954
+ const Q = C.value;
955
+ Q && (Q.scrollTop += i, $.value = Q.scrollTop);
623
956
  }));
624
957
  }
625
- function oe(s, t) {
626
- s instanceof HTMLElement && (ne.set(s, t), H == null || H.observe(s));
627
- }
628
- function re() {
629
- for (const [s] of ne)
630
- s.isConnected || (H == null || H.unobserve(s), ne.delete(s));
631
- }
632
- function ye(s, t = {}) {
633
- const a = w.value;
634
- if (!a) return;
635
- const g = Math.max(0, ue.value - a.clientHeight), b = Math.min(
636
- Math.max(0, Number.isFinite(s) ? s : 0),
637
- g
638
- ), Me = t.behavior ?? "auto";
639
- Me === "auto" && (k.value = b), a.scrollTo({ ...t, top: b, behavior: Me });
640
- }
641
- function _(s, t = {}) {
642
- const a = w.value;
643
- if (!a || e.items.length === 0) return;
644
- const g = Math.min(
958
+ function ze(v, T) {
959
+ v instanceof HTMLElement && (Y.set(v, T), H == null || H.observe(v));
960
+ }
961
+ function be() {
962
+ for (const [v] of Y)
963
+ v.isConnected || (H == null || H.unobserve(v), Y.delete(v));
964
+ }
965
+ function Me(v, T = {}) {
966
+ const i = C.value;
967
+ if (!i) return;
968
+ const q = Math.max(0, ve.value - i.clientHeight), Q = Math.min(
969
+ Math.max(0, Number.isFinite(v) ? v : 0),
970
+ q
971
+ ), ke = T.behavior ?? "auto";
972
+ ke === "auto" && ($.value = Q), i.scrollTo({ ...T, top: Q, behavior: ke });
973
+ }
974
+ function ce(v, T = {}) {
975
+ const i = C.value;
976
+ if (!i || e.items.length === 0) return;
977
+ const q = Math.min(
645
978
  e.items.length - 1,
646
- Math.max(0, Math.floor(s))
647
- ), { align: b = "start", ...Me } = t;
648
- let ge = de.value.offsets[g];
649
- const ve = de.value.sizes[g];
650
- b === "center" ? ge -= (a.clientHeight - ve) / 2 : b === "end" && (ge -= a.clientHeight - ve);
651
- const Le = Math.max(
979
+ Math.max(0, Math.floor(v))
980
+ ), { align: Q = "start", ...ke } = T;
981
+ let ge = he.value.offsets[q];
982
+ const Ee = he.value.sizes[q];
983
+ Q === "center" ? ge -= (i.clientHeight - Ee) / 2 : Q === "end" && (ge -= i.clientHeight - Ee);
984
+ const d = Math.max(
652
985
  0,
653
- Math.min(ge, ue.value - a.clientHeight)
654
- ), ke = Me.behavior ?? "auto";
655
- ke === "auto" && (k.value = Le), a.scrollTo({
656
- ...Me,
657
- top: Le,
658
- behavior: ke
986
+ Math.min(ge, ve.value - i.clientHeight)
987
+ ), K = ke.behavior ?? "auto";
988
+ K === "auto" && ($.value = d), i.scrollTo({
989
+ ...ke,
990
+ top: d,
991
+ behavior: K
659
992
  });
660
993
  }
661
- function ee(s = "auto") {
662
- var t;
663
- (t = w.value) == null || t.scrollTo({ top: 0, behavior: s });
994
+ function de(v = "auto") {
995
+ var T;
996
+ (T = C.value) == null || T.scrollTo({ top: 0, behavior: v });
664
997
  }
665
- return ie(
998
+ return ye(
666
999
  () => e.itemKey,
667
1000
  () => {
668
- W.clear(), F.value += 1;
1001
+ G.clear(), V.value += 1;
669
1002
  }
670
- ), ie(
1003
+ ), ye(
671
1004
  () => e.items.length,
672
1005
  async () => {
673
- const s = new Set(
674
- e.items.map((g, b) => J(g, b))
1006
+ const v = new Set(
1007
+ e.items.map((q, Q) => le(q, Q))
675
1008
  );
676
- for (const g of W.keys())
677
- s.has(g) || W.delete(g);
678
- F.value += 1, await C();
679
- const t = w.value;
680
- if (!t) return;
681
- const a = Math.max(0, ue.value - t.clientHeight);
682
- t.scrollTop > a && (t.scrollTop = a, k.value = a), L();
1009
+ for (const q of G.keys())
1010
+ v.has(q) || G.delete(q);
1011
+ V.value += 1, await Z();
1012
+ const T = C.value;
1013
+ if (!T) return;
1014
+ const i = Math.max(0, ve.value - T.clientHeight);
1015
+ T.scrollTop > i && (T.scrollTop = i, $.value = i), F();
683
1016
  }
684
- ), ie(
1017
+ ), ye(
685
1018
  () => [e.hasMore, e.loading],
686
- async ([s]) => {
687
- s || (ae = -1), await C(), L();
1019
+ async ([v]) => {
1020
+ v || (ae = -1), await Z(), F();
688
1021
  }
689
- ), Ae(() => {
690
- if (he(), typeof ResizeObserver < "u") {
691
- Z = new ResizeObserver(he), H = new ResizeObserver(te), w.value && Z.observe(w.value);
692
- for (const [s] of ne)
693
- H.observe(s);
1022
+ ), at(() => {
1023
+ if (Ae(), typeof ResizeObserver < "u") {
1024
+ se = new ResizeObserver(Ae), H = new ResizeObserver(pe), C.value && se.observe(C.value);
1025
+ for (const [v] of Y)
1026
+ H.observe(v);
694
1027
  }
695
- C(L);
696
- }), Xe(re), Ce(() => {
697
- Z && (Z.disconnect(), Z = void 0), H && (H.disconnect(), H = void 0), ne.clear();
698
- }), P({
699
- scrollTo: ye,
700
- scrollToIndex: _,
701
- scrollToTop: ee
702
- }), (s, t) => (I(), $("div", {
1028
+ Z(F);
1029
+ }), $t(be), Xe(() => {
1030
+ se && (se.disconnect(), se = void 0), H && (H.disconnect(), H = void 0), Y.clear();
1031
+ }), s({
1032
+ scrollTo: Me,
1033
+ scrollToIndex: ce,
1034
+ scrollToTop: de
1035
+ }), (v, T) => (j(), U("div", {
703
1036
  ref_key: "viewport",
704
- ref: w,
705
- class: Ye(["vue-dynamic-virtual-scroll", { "vue-dynamic-virtual-scroll--pulling": c(f) }]),
706
- style: N(Q.value),
1037
+ ref: C,
1038
+ class: st(["vue-dynamic-virtual-scroll", { "vue-dynamic-virtual-scroll--pulling": f(x) }]),
1039
+ style: re(me.value),
707
1040
  role: "list",
708
- "aria-label": l.ariaLabel,
1041
+ "aria-label": t.ariaLabel,
709
1042
  tabindex: "0",
710
- onScrollPassive: y,
711
- onTouchstartPassive: t[0] || (t[0] = //@ts-ignore
712
- (...a) => c(U) && c(U)(...a)),
713
- onTouchmove: t[1] || (t[1] = //@ts-ignore
714
- (...a) => c(q) && c(q)(...a)),
715
- onTouchend: t[2] || (t[2] = //@ts-ignore
716
- (...a) => c(V) && c(V)(...a)),
717
- onTouchcancel: t[3] || (t[3] = //@ts-ignore
718
- (...a) => c(D) && c(D)(...a))
1043
+ onScrollPassive: E,
1044
+ onTouchstartPassive: T[0] || (T[0] = //@ts-ignore
1045
+ (...i) => f(R) && f(R)(...i)),
1046
+ onTouchmove: T[1] || (T[1] = //@ts-ignore
1047
+ (...i) => f(D) && f(D)(...i)),
1048
+ onTouchend: T[2] || (T[2] = //@ts-ignore
1049
+ (...i) => f(b) && f(b)(...i)),
1050
+ onTouchcancel: T[3] || (T[3] = //@ts-ignore
1051
+ (...i) => f(A) && f(A)(...i))
719
1052
  }, [
720
- l.pullToRefresh || l.refreshing ? (I(), $("div", {
1053
+ t.pullToRefresh || t.refreshing ? (j(), U("div", {
721
1054
  key: 0,
722
1055
  class: "vue-dynamic-virtual-scroll__refresh",
723
- style: N({
724
- height: `${c(O)}px`,
725
- transform: `translateY(${c(o) - c(O)}px)`
1056
+ style: re({
1057
+ height: `${f(M)}px`,
1058
+ transform: `translateY(${f(r) - f(M)}px)`
726
1059
  }),
727
1060
  role: "status",
728
1061
  "aria-live": "polite"
729
1062
  }, [
730
- ce(s.$slots, "refresh", {
731
- pullDistance: c(r),
732
- progress: c(m),
733
- refreshing: l.refreshing
1063
+ Se(v.$slots, "refresh", {
1064
+ pullDistance: f(y),
1065
+ progress: f(u),
1066
+ refreshing: t.refreshing
734
1067
  }, () => [
735
- Ve(je(c(A)), 1)
1068
+ Ge(ht(f(n)), 1)
736
1069
  ])
737
- ], 4)) : ze("", !0),
738
- l.items.length || l.loading ? (I(), $("div", {
1070
+ ], 4)) : Re("", !0),
1071
+ t.items.length || t.loading ? (j(), U("div", {
739
1072
  key: 1,
740
1073
  class: "vue-dynamic-virtual-scroll__spacer",
741
- style: N({
742
- height: `${ue.value}px`,
743
- transform: `translateY(${c(o)}px)`
1074
+ style: re({
1075
+ height: `${ve.value}px`,
1076
+ transform: `translateY(${f(r)}px)`
744
1077
  })
745
1078
  }, [
746
- (I(!0), $(Re, null, De(z.value, ({ item: a, index: g, key: b, top: Me }) => (I(), $("div", {
747
- key: b,
1079
+ (j(!0), U(et, null, nt(oe.value, ({ item: i, index: q, key: Q, top: ke }) => (j(), U("div", {
1080
+ key: Q,
748
1081
  ref_for: !0,
749
- ref: (ge) => oe(ge, b),
1082
+ ref: (ge) => ze(ge, Q),
750
1083
  class: "vue-dynamic-virtual-scroll__item",
751
- style: N({ transform: `translateY(${Me}px)` }),
1084
+ style: re({ transform: `translateY(${ke}px)` }),
752
1085
  role: "listitem",
753
- "aria-posinset": g + 1,
754
- "aria-setsize": l.items.length
1086
+ "aria-posinset": q + 1,
1087
+ "aria-setsize": t.items.length
755
1088
  }, [
756
- ce(s.$slots, "default", {
757
- item: a,
758
- index: g
1089
+ Se(v.$slots, "default", {
1090
+ item: i,
1091
+ index: q
759
1092
  })
760
- ], 12, ut))), 128)),
761
- l.loading ? (I(), $("div", {
1093
+ ], 12, Qt))), 128)),
1094
+ t.loading ? (j(), U("div", {
762
1095
  key: 0,
763
1096
  class: "vue-dynamic-virtual-scroll__loading",
764
- style: N({
765
- height: `${le.value}px`,
766
- transform: `translateY(${de.value.total}px)`
1097
+ style: re({
1098
+ height: `${te.value}px`,
1099
+ transform: `translateY(${he.value.total}px)`
767
1100
  }),
768
1101
  role: "status",
769
1102
  "aria-live": "polite"
770
1103
  }, [
771
- ce(s.$slots, "loading", {}, () => [
772
- t[4] || (t[4] = Ve("Loading more…", -1))
1104
+ Se(v.$slots, "loading", {}, () => [
1105
+ T[4] || (T[4] = Ge("Loading more…", -1))
773
1106
  ])
774
- ], 4)) : ze("", !0)
775
- ], 4)) : (I(), $("div", {
1107
+ ], 4)) : Re("", !0)
1108
+ ], 4)) : (j(), U("div", {
776
1109
  key: 2,
777
1110
  class: "vue-dynamic-virtual-scroll__empty",
778
- style: N({ transform: `translateY(${c(o)}px)` })
1111
+ style: re({ transform: `translateY(${f(r)}px)` })
779
1112
  }, [
780
- ce(s.$slots, "empty")
1113
+ Se(v.$slots, "empty")
781
1114
  ], 4))
782
- ], 46, rt));
1115
+ ], 46, Jt));
783
1116
  }
784
- }), ct = ["aria-label"], dt = ["aria-current", "aria-posinset", "aria-setsize"], ft = {
1117
+ }), _t = ["aria-label"], ea = ["aria-current", "aria-posinset", "aria-setsize"], ta = {
785
1118
  key: 1,
786
1119
  class: "vue-short-media-feed__empty"
787
- }, vt = 36, ht = 700, mt = /* @__PURE__ */ Oe({
1120
+ }, aa = 36, na = 700, la = /* @__PURE__ */ tt({
788
1121
  name: "ShortMediaFeed",
789
1122
  __name: "ShortMediaFeed",
790
1123
  props: {
@@ -799,170 +1132,174 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
799
1132
  loadMoreThreshold: { default: 2 }
800
1133
  },
801
1134
  emits: ["update:activeIndex", "change", "reachStart", "reachEnd", "loadMore"],
802
- setup(l, { expose: P, emit: x }) {
803
- const e = l, p = x, f = j(), r = j(0), o = j(R(e.activeIndex));
804
- let m, A = -1, O = 0, U = !1, q;
805
- const V = Ue(), { getItemKey: D } = Pe({
1135
+ setup(t, { expose: s, emit: I }) {
1136
+ const e = t, z = I, x = X(), y = X(0), r = X(ne(e.activeIndex));
1137
+ let u, n = -1, M = 0, R = !1, D;
1138
+ const b = Mt(), { getItemKey: A } = lt({
806
1139
  componentName: "ShortMediaFeed",
807
1140
  items: () => e.items,
808
1141
  itemKey: () => e.itemKey
809
- }), w = n(
1142
+ }), C = h(
810
1143
  () => Math.max(0, Math.floor(e.buffer))
811
- ), k = n(
1144
+ ), $ = h(
812
1145
  () => Math.max(
813
1146
  0,
814
1147
  Math.floor(
815
1148
  Number.isFinite(e.loadMoreThreshold) ? e.loadMoreThreshold : 0
816
1149
  )
817
1150
  )
818
- ), E = n(() => r.value > 0 ? r.value : typeof e.height == "number" ? Math.max(1, e.height) : 0), F = n(
819
- () => Math.max(0, o.value - w.value)
820
- ), W = n(
1151
+ ), B = h(() => y.value > 0 ? y.value : typeof e.height == "number" ? Math.max(1, e.height) : 0), V = h(
1152
+ () => Math.max(0, r.value - C.value)
1153
+ ), G = h(
821
1154
  () => Math.min(
822
1155
  e.items.length,
823
- o.value + w.value + 1
1156
+ r.value + C.value + 1
824
1157
  )
825
- ), ne = n(
826
- () => e.items.slice(F.value, W.value).map((u, d) => ({
827
- item: u,
828
- index: F.value + d
829
- }))
830
- ), Z = n(() => F.value * E.value), H = n(
831
- () => (e.items.length - W.value) * E.value
832
- ), ae = n(() => ({
833
- height: Fe(e.height)
1158
+ ), Y = h(
1159
+ () => (
1160
+ // Do not register zero-sized snap targets before a CSS height is measured.
1161
+ // WebKit can retain the second target at scrollTop=0 and jump to it on resize.
1162
+ (B.value > 0 ? e.items : []).slice(V.value, G.value).map((S, P) => ({
1163
+ item: S,
1164
+ index: V.value + P
1165
+ }))
1166
+ )
1167
+ ), se = h(() => V.value * B.value), H = h(
1168
+ () => (e.items.length - G.value) * B.value
1169
+ ), ae = h(() => ({
1170
+ height: gt(e.height)
834
1171
  }));
835
- function R(u) {
1172
+ function ne(S) {
836
1173
  return e.items.length === 0 ? 0 : Math.min(
837
1174
  e.items.length - 1,
838
- Math.max(0, Math.floor(Number.isFinite(u) ? u : 0))
1175
+ Math.max(0, Math.floor(Number.isFinite(S) ? S : 0))
839
1176
  );
840
1177
  }
841
- function J() {
842
- if (!e.hasMore || e.loading || A === e.items.length)
1178
+ function le() {
1179
+ if (!e.hasMore || e.loading || n === e.items.length)
843
1180
  return;
844
- (e.items.length === 0 ? 0 : e.items.length - 1 - o.value) <= k.value && (A = e.items.length, p("loadMore"));
1181
+ (e.items.length === 0 ? 0 : e.items.length - 1 - r.value) <= $.value && (n = e.items.length, z("loadMore"));
845
1182
  }
846
- function Y(u) {
847
- const d = R(u);
848
- d === o.value || e.items.length === 0 || (o.value = d, p("update:activeIndex", d), p("change", {
849
- index: d,
850
- item: e.items[d]
851
- }), d === 0 && p("reachStart"), d === e.items.length - 1 && p("reachEnd"), J());
1183
+ function ie(S) {
1184
+ const P = ne(S);
1185
+ P === r.value || e.items.length === 0 || (r.value = P, z("update:activeIndex", P), z("change", {
1186
+ index: P,
1187
+ item: e.items[P]
1188
+ }), P === 0 && z("reachStart"), P === e.items.length - 1 && z("reachEnd"), le());
852
1189
  }
853
- function le(u, d = {}) {
854
- const z = f.value;
855
- z && (typeof z.scrollTo == "function" ? z.scrollTo({ ...d, top: u }) : z.scrollTop = u);
1190
+ function te(S, P = {}) {
1191
+ const oe = x.value;
1192
+ oe && (typeof oe.scrollTo == "function" ? oe.scrollTo({ ...P, top: S }) : oe.scrollTop = S);
856
1193
  }
857
- function se(u, d = {}) {
1194
+ function ue(S, P = {}) {
858
1195
  if (e.items.length === 0) return;
859
- const z = R(u);
860
- Y(z), le(z * E.value, d);
861
- }
862
- function me(u) {
863
- if (E.value <= 0) return;
864
- const d = u.currentTarget.scrollTop;
865
- Y(Math.round(d / E.value));
866
- }
867
- function de(u) {
868
- let d;
869
- u.key === "ArrowDown" || u.key === "PageDown" ? d = o.value + 1 : u.key === "ArrowUp" || u.key === "PageUp" ? d = o.value - 1 : u.key === "Home" ? d = 0 : u.key === "End" && (d = e.items.length - 1), d !== void 0 && (u.preventDefault(), se(d, { behavior: "smooth" }));
870
- }
871
- function ue(u) {
872
- return u.deltaMode === WheelEvent.DOM_DELTA_LINE ? u.deltaY * 16 : u.deltaMode === WheelEvent.DOM_DELTA_PAGE ? u.deltaY * (E.value || 1) : u.deltaY;
873
- }
874
- function we(u) {
875
- if (u.ctrlKey || Math.abs(u.deltaX) > Math.abs(u.deltaY) || e.items.length === 0 || E.value <= 0 || (u.preventDefault(), U)) return;
876
- const d = ue(u);
877
- if (d * O < 0 && (O = 0), O += d, Math.abs(O) < vt) return;
878
- const z = O > 0 ? 1 : -1;
879
- O = 0;
880
- const Q = o.value + z;
881
- Q < 0 || Q >= e.items.length || (U = !0, se(Q, { behavior: "smooth" }), q = setTimeout(() => {
882
- U = !1;
883
- }, ht));
884
- }
885
- function G() {
886
- var d;
887
- const u = ((d = f.value) == null ? void 0 : d.clientHeight) ?? 0;
888
- V(f.value, e.height), !(u <= 0 || u === r.value) && (r.value = u, C(() => {
889
- le(o.value * u);
1196
+ const oe = ne(S);
1197
+ ie(oe), te(oe * B.value, P);
1198
+ }
1199
+ function fe(S) {
1200
+ if (B.value <= 0) return;
1201
+ const P = S.currentTarget.scrollTop;
1202
+ ie(Math.round(P / B.value));
1203
+ }
1204
+ function he(S) {
1205
+ let P;
1206
+ S.key === "ArrowDown" || S.key === "PageDown" ? P = r.value + 1 : S.key === "ArrowUp" || S.key === "PageUp" ? P = r.value - 1 : S.key === "Home" ? P = 0 : S.key === "End" && (P = e.items.length - 1), P !== void 0 && (S.preventDefault(), ue(P, { behavior: "smooth" }));
1207
+ }
1208
+ function ve(S) {
1209
+ return S.deltaMode === WheelEvent.DOM_DELTA_LINE ? S.deltaY * 16 : S.deltaMode === WheelEvent.DOM_DELTA_PAGE ? S.deltaY * (B.value || 1) : S.deltaY;
1210
+ }
1211
+ function J(S) {
1212
+ if (S.ctrlKey || Math.abs(S.deltaX) > Math.abs(S.deltaY) || e.items.length === 0 || B.value <= 0 || (S.preventDefault(), R)) return;
1213
+ const P = ve(S);
1214
+ if (P * M < 0 && (M = 0), M += P, Math.abs(M) < aa) return;
1215
+ const oe = M > 0 ? 1 : -1;
1216
+ M = 0;
1217
+ const me = r.value + oe;
1218
+ me < 0 || me >= e.items.length || (R = !0, ue(me, { behavior: "smooth" }), D = setTimeout(() => {
1219
+ R = !1;
1220
+ }, na));
1221
+ }
1222
+ function O() {
1223
+ var P;
1224
+ const S = ((P = x.value) == null ? void 0 : P.clientHeight) ?? 0;
1225
+ b(x.value, e.height), !(S <= 0 || S === y.value) && (y.value = S, Z(() => {
1226
+ te(r.value * S);
890
1227
  }));
891
1228
  }
892
- return ie(
1229
+ return ye(
893
1230
  () => e.activeIndex,
894
- async (u) => {
895
- const d = R(u);
896
- d !== o.value && (o.value = d, await C(), le(d * E.value), J());
1231
+ async (S) => {
1232
+ const P = ne(S);
1233
+ P !== r.value && (r.value = P, await Z(), te(P * B.value), le());
897
1234
  }
898
- ), ie(
1235
+ ), ye(
899
1236
  () => [
900
1237
  e.hasMore,
901
1238
  e.loading,
902
1239
  e.loadMoreThreshold
903
1240
  ],
904
- async ([u]) => {
905
- u || (A = -1), await C(), J();
1241
+ async ([S]) => {
1242
+ S || (n = -1), await Z(), le();
906
1243
  }
907
- ), ie(
1244
+ ), ye(
908
1245
  () => e.items.length,
909
1246
  async () => {
910
- const u = R(o.value);
911
- e.items.length === 0 ? o.value !== 0 && (o.value = 0, p("update:activeIndex", 0)) : Y(u), await C(), le(u * E.value), J();
1247
+ const S = ne(r.value);
1248
+ e.items.length === 0 ? r.value !== 0 && (r.value = 0, z("update:activeIndex", 0)) : ie(S), await Z(), te(S * B.value), le();
912
1249
  }
913
- ), Ae(async () => {
914
- G(), typeof ResizeObserver < "u" && f.value && (m = new ResizeObserver(G), m.observe(f.value)), await C(), le(o.value * E.value), J();
915
- }), Ce(() => {
916
- m && (m.disconnect(), m = void 0), q && (clearTimeout(q), q = void 0);
917
- }), P({
918
- scrollToIndex: se
919
- }), (u, d) => (I(), $("div", {
1250
+ ), at(async () => {
1251
+ O(), typeof ResizeObserver < "u" && x.value && (u = new ResizeObserver(O), u.observe(x.value)), await Z(), te(r.value * B.value), le();
1252
+ }), Xe(() => {
1253
+ u && (u.disconnect(), u = void 0), D && (clearTimeout(D), D = void 0);
1254
+ }), s({
1255
+ scrollToIndex: ue
1256
+ }), (S, P) => (j(), U("div", {
920
1257
  ref_key: "viewport",
921
- ref: f,
1258
+ ref: x,
922
1259
  class: "vue-short-media-feed",
923
- style: N(ae.value),
1260
+ style: re(ae.value),
924
1261
  role: "list",
925
1262
  "aria-orientation": "vertical",
926
- "aria-label": l.ariaLabel,
1263
+ "aria-label": t.ariaLabel,
927
1264
  tabindex: "0",
928
- onScrollPassive: me,
929
- onWheel: we,
930
- onKeydown: de
1265
+ onScrollPassive: fe,
1266
+ onWheel: J,
1267
+ onKeydown: he
931
1268
  }, [
932
- l.items.length ? (I(), $(Re, { key: 0 }, [
933
- Z.value > 0 ? (I(), $("div", {
1269
+ t.items.length ? (j(), U(et, { key: 0 }, [
1270
+ se.value > 0 ? (j(), U("div", {
934
1271
  key: 0,
935
1272
  class: "vue-short-media-feed__spacer",
936
- style: N({ height: `${Z.value}px` }),
1273
+ style: re({ height: `${se.value}px` }),
937
1274
  "aria-hidden": "true"
938
- }, null, 4)) : ze("", !0),
939
- (I(!0), $(Re, null, De(ne.value, ({ item: z, index: Q }) => (I(), $("div", {
940
- key: c(D)(z, Q),
1275
+ }, null, 4)) : Re("", !0),
1276
+ (j(!0), U(et, null, nt(Y.value, ({ item: oe, index: me }) => (j(), U("div", {
1277
+ key: f(A)(oe, me),
941
1278
  class: "vue-short-media-feed__item",
942
- style: N({ height: `${E.value}px` }),
1279
+ style: re({ height: `${B.value}px` }),
943
1280
  role: "listitem",
944
- "aria-current": Q === o.value ? "true" : void 0,
945
- "aria-posinset": Q + 1,
946
- "aria-setsize": l.items.length
1281
+ "aria-current": me === r.value ? "true" : void 0,
1282
+ "aria-posinset": me + 1,
1283
+ "aria-setsize": t.items.length
947
1284
  }, [
948
- ce(u.$slots, "default", {
949
- item: z,
950
- index: Q,
951
- active: Q === o.value
1285
+ Se(S.$slots, "default", {
1286
+ item: oe,
1287
+ index: me,
1288
+ active: me === r.value
952
1289
  })
953
- ], 12, dt))), 128)),
954
- H.value > 0 ? (I(), $("div", {
1290
+ ], 12, ea))), 128)),
1291
+ H.value > 0 ? (j(), U("div", {
955
1292
  key: 1,
956
1293
  class: "vue-short-media-feed__spacer",
957
- style: N({ height: `${H.value}px` }),
1294
+ style: re({ height: `${H.value}px` }),
958
1295
  "aria-hidden": "true"
959
- }, null, 4)) : ze("", !0)
960
- ], 64)) : (I(), $("div", ft, [
961
- ce(u.$slots, "empty")
1296
+ }, null, 4)) : Re("", !0)
1297
+ ], 64)) : (j(), U("div", ta, [
1298
+ Se(S.$slots, "empty")
962
1299
  ]))
963
- ], 44, ct));
1300
+ ], 44, _t));
964
1301
  }
965
- }), gt = ["aria-label"], pt = /* @__PURE__ */ Oe({
1302
+ }), oa = ["aria-label"], ia = /* @__PURE__ */ tt({
966
1303
  __name: "SkeletonLoader",
967
1304
  props: {
968
1305
  width: { default: "100%" },
@@ -971,38 +1308,323 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
971
1308
  animated: { type: Boolean, default: !0 },
972
1309
  ariaLabel: { default: "Loading…" }
973
1310
  },
974
- setup(l) {
975
- const P = l;
976
- function x(p) {
977
- return typeof p == "number" ? `${Math.max(0, p)}px` : p;
978
- }
979
- const e = n(() => ({
980
- width: x(P.width),
981
- height: x(P.height)
1311
+ setup(t) {
1312
+ const s = t;
1313
+ function I(z) {
1314
+ return typeof z == "number" ? `${Math.max(0, z)}px` : z;
1315
+ }
1316
+ const e = h(() => ({
1317
+ width: I(s.width),
1318
+ height: I(s.height)
982
1319
  }));
983
- return (p, f) => (I(), $("div", {
984
- class: Ye(["vue-skeleton-loader", [
985
- `vue-skeleton-loader--${l.variant}`,
986
- { "vue-skeleton-loader--animated": l.animated }
1320
+ return (z, x) => (j(), U("div", {
1321
+ class: st(["vue-skeleton-loader", [
1322
+ `vue-skeleton-loader--${t.variant}`,
1323
+ { "vue-skeleton-loader--animated": t.animated }
987
1324
  ]]),
988
- style: N(e.value),
1325
+ style: re(e.value),
989
1326
  role: "status",
990
- "aria-label": l.ariaLabel
991
- }, null, 14, gt));
1327
+ "aria-label": t.ariaLabel
1328
+ }, null, 14, oa));
992
1329
  }
993
- }), yt = (l, P) => {
994
- const x = l.__vccOpts || l;
995
- for (const [e, p] of P)
996
- x[e] = p;
997
- return x;
998
- }, Mt = /* @__PURE__ */ yt(pt, [["__scopeId", "data-v-fc92f61f"]]), xt = ["aria-label"], wt = {
999
- key: 0,
1000
- class: "vue-virtual-carousel__track",
1001
- role: "list"
1002
- }, Tt = ["aria-label", "aria-current"], bt = {
1330
+ }), ra = (t, s) => {
1331
+ const I = t.__vccOpts || t;
1332
+ for (const [e, z] of s)
1333
+ I[e] = z;
1334
+ return I;
1335
+ }, sa = /* @__PURE__ */ ra(ia, [["__scopeId", "data-v-fc92f61f"]]), ua = 6e-3;
1336
+ function ca(t, s) {
1337
+ const I = t * Math.abs(t) / (2 * ua), e = s * 2;
1338
+ return Math.max(-e, Math.min(e, I));
1339
+ }
1340
+ function da(t, s, I, e = 250) {
1341
+ const z = s - t, x = Math.abs(I);
1342
+ if (!(x >= 0.1 && z * I > 0))
1343
+ return {
1344
+ keyframes: [
1345
+ { transform: `translate3d(${t}px, 0, 0)` },
1346
+ { transform: `translate3d(${s}px, 0, 0)` }
1347
+ ],
1348
+ options: {
1349
+ duration: Math.round(
1350
+ Math.max(120, Math.min(650, (190 + Math.abs(z) * 0.35) * e / 250))
1351
+ ),
1352
+ easing: "cubic-bezier(0.22, 1, 0.36, 1)",
1353
+ fill: "forwards"
1354
+ }
1355
+ };
1356
+ const r = Math.round(
1357
+ Math.max(180, Math.min(650, 2 * Math.abs(z) / x * e / 250))
1358
+ ), u = Math.min(3, x * r / Math.abs(z)), n = Math.ceil(r / 8);
1359
+ return {
1360
+ keyframes: Array.from({ length: n + 1 }, (R, D) => {
1361
+ const b = D / n, A = b * b, C = A * b, $ = u * (C - 2 * A + b) + (-2 * C + 3 * A), B = t + z * $;
1362
+ return {
1363
+ offset: b,
1364
+ transform: `translate3d(${B}px, 0, 0)`
1365
+ };
1366
+ }),
1367
+ options: { duration: r, easing: "linear", fill: "forwards" }
1368
+ };
1369
+ }
1370
+ function fa(t) {
1371
+ const s = X("idle"), I = X(!1), e = X(!1), z = h(() => s.value !== "idle" || I.value), x = h(() => s.value === "dragging" || e.value), y = X(!1);
1372
+ let r, u = "", n = 0, M = 0, R = 0, D = 0, b = 0, A = 0, C = 0, $ = 0, B = 0, V, G, Y, se = 0, H = !1, ae, ne, le = "", ie = !1, te, ue = !1;
1373
+ const fe = () => t.rtl() ? -1 : 1, he = () => {
1374
+ var d;
1375
+ return (((d = t.viewport()) == null ? void 0 : d.scrollLeft) ?? 0) * fe();
1376
+ };
1377
+ function ve(d, K) {
1378
+ const m = t.viewport();
1379
+ if (!m) return;
1380
+ const w = d * fe();
1381
+ m.scrollTo ? m.scrollTo(K === void 0 ? { left: w } : { left: w, behavior: K }) : m.scrollLeft = w;
1382
+ }
1383
+ function J() {
1384
+ const d = t.viewport();
1385
+ d && (ie || (le = d.style.scrollSnapType), ie = !0, d.style.scrollSnapType = "none");
1386
+ }
1387
+ function O() {
1388
+ const d = se;
1389
+ Z(() => {
1390
+ ue || d !== se || s.value !== "idle" || (t.viewport() && (t.viewport().style.scrollSnapType = le), ie = !1);
1391
+ });
1392
+ }
1393
+ function S() {
1394
+ const d = t.track();
1395
+ d && (d.style.transform = "", d.style.willChange = "");
1396
+ }
1397
+ function P() {
1398
+ const d = t.track();
1399
+ if (!d || !V) return b;
1400
+ const K = getComputedStyle(d).transform, m = K.slice(K.indexOf("(") + 1, -1).split(",").map(Number), w = K.startsWith("matrix3d") ? m[12] : m[4];
1401
+ return Number.isFinite(w) ? w : b;
1402
+ }
1403
+ function oe() {
1404
+ return V ? D - P() * fe() : y.value ? D - b * fe() : he();
1405
+ }
1406
+ function me() {
1407
+ const d = V;
1408
+ V = void 0, d && (d.onfinish = null, d.oncancel = null, d.cancel()), Y !== void 0 && cancelAnimationFrame(Y), Y = void 0;
1409
+ }
1410
+ function Ae() {
1411
+ var m;
1412
+ const d = r;
1413
+ r = void 0, I.value = !1, e.value = !1;
1414
+ const K = t.viewport();
1415
+ d !== void 0 && ((m = K == null ? void 0 : K.hasPointerCapture) != null && m.call(K, d)) && K.releasePointerCapture(d), window.removeEventListener("pointermove", de), window.removeEventListener("pointerup", T), window.removeEventListener("pointercancel", i), window.removeEventListener("blur", q);
1416
+ }
1417
+ function E(d, K) {
1418
+ const m = ++se;
1419
+ J(), s.value = "committing", me(), S(), y.value = !1, b = 0;
1420
+ const w = t.canonical(d);
1421
+ ve(w, K), t.onPosition(w), t.onCommit(d), Z(() => {
1422
+ ue || m !== se || (ve(w), s.value = "idle", O());
1423
+ });
1424
+ }
1425
+ function F(d = !0) {
1426
+ ne !== void 0 && clearTimeout(ne), ne = void 0;
1427
+ const K = V !== void 0 || b !== 0, m = d ? oe() : he();
1428
+ return ++se, J(), Ae(), me(), S(), y.value = !1, G = void 0, b = 0, s.value = "idle", d && (K && ve(m), t.onPosition(m)), O(), m;
1429
+ }
1430
+ function _() {
1431
+ V && (t.onPosition(oe()), Y = requestAnimationFrame(_));
1432
+ }
1433
+ function pe() {
1434
+ return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1435
+ }
1436
+ function ze(d, K, m) {
1437
+ const w = t.track(), k = (D - K) * fe();
1438
+ if (!(w != null && w.animate) || pe() || t.settleDuration() === 0 || Math.abs(k - b) < 1) {
1439
+ S(), y.value = !1, b = 0, s.value = "idle", !(w != null && w.animate) && !pe() && t.settleDuration() !== 0 ? (t.onCommit(d), G = K, ve(K, "smooth"), O()) : E(d);
1440
+ return;
1441
+ }
1442
+ ++se, J(), s.value = "settling", y.value = !0;
1443
+ const ee = da(b, k, m, t.settleDuration()), L = w.animate(ee.keyframes, ee.options);
1444
+ V = L, L.onfinish = () => {
1445
+ V === L && E(d);
1446
+ }, L.oncancel = () => {
1447
+ V === L && F();
1448
+ }, Y = requestAnimationFrame(_);
1449
+ }
1450
+ function be(d, K = "smooth", m = 0, w = !1) {
1451
+ const k = F(), ee = t.target(d, k, m);
1452
+ t.onCommit(d), Math.abs(ee - k) < 0.5 || K !== "smooth" || pe() ? E(d, K) : w ? (D = he(), b = (D - k) * fe(), ze(d, ee, 0)) : (s.value = "settling", G = ee, ve(ee, K), t.viewport() && (t.viewport().style.scrollSnapType = le), ie = !1);
1453
+ }
1454
+ function Me(d) {
1455
+ const K = d.currentTarget.scrollLeft * fe();
1456
+ if (!(V || s.value === "dragging" || s.value === "committing")) {
1457
+ if (t.onPosition(K), G !== void 0) {
1458
+ if (Math.abs(K - G) > 1) return;
1459
+ G = void 0, s.value = "idle";
1460
+ }
1461
+ t.onCommit(t.indexAt(K));
1462
+ }
1463
+ }
1464
+ function ce(d) {
1465
+ var w, k;
1466
+ if (r !== void 0 || d.isPrimary === !1 || d.pointerType === "mouse" && (!t.mouseDrag() || d.button !== 0) || !["mouse", "touch", "pen"].includes(d.pointerType) || (k = (w = d.target) == null ? void 0 : w.closest) != null && k.call(w, 'input, textarea, select, [contenteditable="true"], [data-carousel-no-drag]')) return;
1467
+ G !== void 0 && ve(he(), "auto");
1468
+ const K = oe();
1469
+ V !== void 0 ? (b = P(), me(), t.track().style.transform = `translate3d(${b}px, 0, 0)`, y.value = !0) : (b = 0, D = he()), ++se, G = void 0, s.value = "pending", r = d.pointerId, I.value = !0, u = d.pointerType, n = A = d.clientX, M = d.clientY, R = K, C = d.timeStamp, $ = 0, B = 0, H = !1, ae !== void 0 && clearTimeout(ae), window.addEventListener("pointermove", de), window.addEventListener("pointerup", T), window.addEventListener("pointercancel", i), window.addEventListener("blur", q);
1470
+ }
1471
+ function de(d) {
1472
+ var $e, De;
1473
+ if (r !== d.pointerId || d === te) return;
1474
+ if (te = d, e.value) {
1475
+ d.cancelable && d.preventDefault();
1476
+ return;
1477
+ }
1478
+ const K = d.clientX - n, m = d.clientY - M, w = Number.isFinite(t.dragThreshold()) ? Math.max(1, t.dragThreshold()) : 8, k = u === "mouse" && t.mouseDragMode() === "snap";
1479
+ if (s.value === "pending") {
1480
+ if (Math.max(Math.abs(K), Math.abs(m)) < w || k && Math.abs(K) < w) return;
1481
+ if (u !== "mouse" && Math.abs(m) >= Math.abs(K)) {
1482
+ F();
1483
+ return;
1484
+ }
1485
+ J(), s.value = "dragging", (De = ($e = t.viewport()) == null ? void 0 : $e.setPointerCapture) == null || De.call($e, d.pointerId);
1486
+ }
1487
+ if (s.value !== "dragging") return;
1488
+ if (d.cancelable && d.preventDefault(), H = !0, k) {
1489
+ e.value = !0;
1490
+ const Ie = -Math.sign(K) * fe(), Ye = t.target(t.indexAt(R) + Ie, R, Ie), je = t.indexAt(Ye);
1491
+ t.onCommit(je), ze(je, Ye, 0);
1492
+ return;
1493
+ }
1494
+ const ee = d.timeStamp - C;
1495
+ if (ee > 0 && ee <= 80) {
1496
+ const Ie = Math.max(-2.5, Math.min(2.5, (d.clientX - A) / ee));
1497
+ $ = B === 0 ? Ie : $ * 0.25 + Ie * 0.75, B += 1;
1498
+ } else ee > 80 && ($ = 0, B = 0);
1499
+ A = d.clientX, C = d.timeStamp;
1500
+ let L = R - K * fe();
1501
+ const [xe, we] = t.limits();
1502
+ L < xe && (L = xe + (L - xe) * 0.35), L > we && (L = we + (L - we) * 0.35), b = (D - L) * fe(), Y === void 0 && (Y = requestAnimationFrame(() => {
1503
+ Y = void 0;
1504
+ const Ie = t.track();
1505
+ !Ie || s.value !== "dragging" || (Ie.style.willChange = "transform", Ie.style.transform = `translate3d(${b}px, 0, 0)`, t.onPosition(D - b * fe()));
1506
+ }));
1507
+ }
1508
+ function v(d, K = !1) {
1509
+ if (r === void 0 || d && r !== d.pointerId) return;
1510
+ const m = s.value === "dragging", w = e.value, k = b !== 0;
1511
+ if (Ae(), w) {
1512
+ ae !== void 0 && clearTimeout(ae), ae = setTimeout(() => {
1513
+ H = !1;
1514
+ }, 0);
1515
+ return;
1516
+ }
1517
+ if (Y !== void 0 && cancelAnimationFrame(Y), Y = void 0, !m && !k) {
1518
+ s.value = "idle", O();
1519
+ return;
1520
+ }
1521
+ const ee = D - b * fe(), L = d ? Math.max(0, d.timeStamp - C) : 101, xe = !K && t.momentum() && L <= 100 ? $ * Math.exp(-L / 80) : 0, we = ee - R, $e = Math.min(80, Math.max(40, t.step() * 0.12)), De = B >= 2 && Math.abs(we) >= $e ? ca(-xe * fe(), t.step()) : 0;
1522
+ let Ie = t.indexAt(ee + De);
1523
+ const Ye = t.indexAt(R), je = Math.max(1, t.dragThreshold());
1524
+ !K && m && Ie === Ye && Math.abs(we) >= je && (Ie = Ye + Math.sign(we));
1525
+ const Ze = t.target(Ie, ee);
1526
+ t.onPosition(ee), ze(t.indexAt(Ze), Ze, xe), ae !== void 0 && clearTimeout(ae), ae = setTimeout(() => {
1527
+ H = !1;
1528
+ }, 0);
1529
+ }
1530
+ function T(d) {
1531
+ v(d);
1532
+ }
1533
+ function i(d) {
1534
+ v(d, !0);
1535
+ }
1536
+ function q() {
1537
+ v(void 0, !0);
1538
+ }
1539
+ function Q(d) {
1540
+ d.target === t.viewport() && r === d.pointerId && s.value === "dragging" && v(d, !0);
1541
+ }
1542
+ function ke(d) {
1543
+ !H || d.detail === 0 || (d.preventDefault(), d.stopPropagation(), H = !1);
1544
+ }
1545
+ function ge() {
1546
+ const d = V !== void 0 || s.value === "dragging", K = F();
1547
+ d && t.onCommit(t.indexAt(K)), t.nativeSnap() || (ne = setTimeout(() => {
1548
+ if (ne = void 0, ue || s.value !== "idle") return;
1549
+ D = he(), b = 0;
1550
+ const m = t.indexAt(D);
1551
+ ze(m, t.target(m, D), 0);
1552
+ }, 120));
1553
+ }
1554
+ function Ee(d) {
1555
+ r !== void 0 && d.preventDefault();
1556
+ }
1557
+ return Xe(() => {
1558
+ F(!1), ue = !0, ae !== void 0 && clearTimeout(ae), t.viewport() && (t.viewport().style.scrollSnapType = le);
1559
+ }), {
1560
+ phase: s,
1561
+ busy: z,
1562
+ dragging: x,
1563
+ pointerActive: I,
1564
+ transformed: y,
1565
+ read: he,
1566
+ write: ve,
1567
+ cancel: F,
1568
+ commit: E,
1569
+ navigate: be,
1570
+ displayedPosition: oe,
1571
+ handleScroll: Me,
1572
+ handlePointerDown: ce,
1573
+ handlePointerMove: de,
1574
+ handlePointerUp: T,
1575
+ handlePointerCancel: i,
1576
+ handleLostPointerCapture: Q,
1577
+ handleClick: ke,
1578
+ handleWheel: ge,
1579
+ handleDragStart: Ee
1580
+ };
1581
+ }
1582
+ function va(t) {
1583
+ let s;
1584
+ function I() {
1585
+ s !== void 0 && clearTimeout(s), s = void 0;
1586
+ }
1587
+ function e() {
1588
+ if (I(), !t.enabled() || t.paused() || t.count() < 2 || t.atEnd() && !t.loop()) return;
1589
+ const z = Number.isFinite(t.delay()) ? Math.max(1, t.delay()) : 3e3;
1590
+ s = setTimeout(() => {
1591
+ s = void 0, !t.paused() && (t.atEnd() ? t.rewind() : t.advance(), e());
1592
+ }, z);
1593
+ }
1594
+ return ye(
1595
+ () => [t.enabled(), t.paused(), t.delay(), t.count(), t.loop(), t.atEnd()],
1596
+ e,
1597
+ { immediate: !0 }
1598
+ ), Xe(I), { start: e, stop: I };
1599
+ }
1600
+ function dt(t, s) {
1601
+ return s > 0 ? (t % s + s) % s : 0;
1602
+ }
1603
+ function ma(t, s) {
1604
+ const I = new Array(t.length + 1);
1605
+ I[0] = 0;
1606
+ for (let r = 0; r < t.length; r += 1)
1607
+ I[r + 1] = I[r] + t[r] + s;
1608
+ const e = I[t.length], z = Math.max(0, e - (t.length ? s : 0));
1609
+ function x(r) {
1610
+ if (!t.length) return 0;
1611
+ let u = 0, n = t.length - 1;
1612
+ for (; u < n; ) {
1613
+ const M = Math.ceil((u + n) / 2);
1614
+ I[M] <= r ? u = M : n = M - 1;
1615
+ }
1616
+ return u;
1617
+ }
1618
+ function y(r) {
1619
+ const u = x(r), n = Math.min(t.length - 1, u + 1);
1620
+ return r - I[u] <= I[n] - r ? u : n;
1621
+ }
1622
+ return { offsets: I, cycleWidth: e, totalWidth: z, indexAt: x, nearestIndex: y };
1623
+ }
1624
+ const ha = ["dir", "aria-label"], ga = ["data-carousel-index", "aria-label", "aria-current", "aria-hidden", "inert"], pa = {
1003
1625
  key: 1,
1004
1626
  class: "vue-virtual-carousel__empty"
1005
- }, St = /* @__PURE__ */ Oe({
1627
+ }, ya = /* @__PURE__ */ tt({
1006
1628
  name: "VirtualCarousel",
1007
1629
  __name: "VirtualCarousel",
1008
1630
  props: {
@@ -1022,310 +1644,373 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
1022
1644
  autoplayDelay: { default: 3e3 },
1023
1645
  autoplayLoop: { type: Boolean, default: !0 },
1024
1646
  pauseOnHover: { type: Boolean, default: !0 },
1647
+ mouseDrag: { type: Boolean, default: !0 },
1648
+ mouseDragMode: { default: "drag" },
1649
+ dragThreshold: { default: 8 },
1650
+ momentum: { type: Boolean, default: !0 },
1651
+ settleDuration: { default: 250 },
1652
+ nativeSnap: { type: Boolean, default: !0 },
1653
+ autoWidth: { type: Boolean, default: !1 },
1654
+ estimatedItemWidth: { default: 240 },
1655
+ rtl: { type: Boolean, default: !1 },
1656
+ loop: { type: Boolean, default: !1 },
1657
+ keepAlive: { type: Boolean, default: !1 },
1658
+ maxCachedItems: { default: 20 },
1659
+ pinnedIndexes: { default: () => [] },
1025
1660
  responsive: { default: void 0 }
1026
1661
  },
1027
1662
  emits: ["update:activeIndex", "change", "reachStart", "reachEnd", "loadMore"],
1028
- setup(l, { expose: P, emit: x }) {
1029
- const e = l, p = x, f = j(), r = j(0), o = j(0);
1030
- let m, A = -1, O, U, q = !1;
1031
- const V = j(!1), { getItemKey: D } = Pe({
1663
+ setup(t, { expose: s, emit: I }) {
1664
+ const e = t, z = I, x = X(), y = X(), r = X(0), u = X(0), n = X(0), M = X(!1), R = X(!1), D = X(), b = ft([]), A = ft([0, 1]), C = ft(/* @__PURE__ */ new Map()), $ = ft([]);
1665
+ let B, V, G = -1, Y = !1;
1666
+ const se = /* @__PURE__ */ new Map(), H = /* @__PURE__ */ new Map(), { getItemKey: ae } = lt({
1032
1667
  componentName: "VirtualCarousel",
1033
1668
  items: () => e.items,
1034
1669
  itemKey: () => e.itemKey
1035
- }), w = n(() => Math.max(0, r.value)), k = n(() => {
1036
- if (!e.responsive || e.responsive.length === 0)
1037
- return {
1038
- slidesPerView: e.slidesPerView,
1039
- slidesToScroll: e.slidesToScroll,
1040
- gap: e.gap
1041
- };
1042
- const t = w.value, a = [...e.responsive].sort(
1043
- (g, b) => b.breakpoint - g.breakpoint
1044
- );
1045
- for (const g of a)
1046
- if (t >= g.breakpoint)
1047
- return {
1048
- slidesPerView: g.slidesPerView ?? e.slidesPerView,
1049
- slidesToScroll: g.slidesToScroll ?? e.slidesToScroll,
1050
- gap: g.gap ?? e.gap
1051
- };
1670
+ }), ne = h(() => e.items.map((a, l) => ae(a, l))), le = h(() => new Map(ne.value.map((a, l) => [a, l]))), ie = (a, l, g) => Math.max(l, Math.floor(Number.isFinite(a) ? a : g)), te = h(() => {
1671
+ const a = [...e.responsive ?? []].sort((l, g) => g.breakpoint - l.breakpoint).find((l) => r.value >= l.breakpoint);
1052
1672
  return {
1053
- slidesPerView: e.slidesPerView,
1054
- slidesToScroll: e.slidesToScroll,
1055
- gap: e.gap
1673
+ slidesPerView: ie((a == null ? void 0 : a.slidesPerView) ?? e.slidesPerView, 1, 1),
1674
+ slidesToScroll: ie((a == null ? void 0 : a.slidesToScroll) ?? e.slidesToScroll, 1, 1),
1675
+ gap: Math.max(0, Number.isFinite((a == null ? void 0 : a.gap) ?? e.gap) ? (a == null ? void 0 : a.gap) ?? e.gap : 0)
1056
1676
  };
1057
- }), E = n(
1058
- () => Math.max(
1059
- 1,
1060
- Math.floor(
1061
- Number.isFinite(k.value.slidesPerView) ? k.value.slidesPerView : 1
1062
- )
1063
- )
1064
- ), F = n(
1065
- () => Math.max(
1066
- 1,
1067
- Math.floor(
1068
- Number.isFinite(k.value.slidesToScroll) ? k.value.slidesToScroll : 1
1069
- )
1070
- )
1071
- ), W = n(
1072
- () => Math.max(0, Number.isFinite(k.value.gap) ? k.value.gap : 0)
1073
- ), ne = n(
1074
- () => Math.max(
1075
- 0,
1076
- Math.floor(Number.isFinite(e.buffer) ? e.buffer : 0)
1077
- )
1078
- ), Z = n(
1079
- () => Math.max(
1080
- 0,
1081
- Math.floor(
1082
- Number.isFinite(e.loadMoreThreshold) ? e.loadMoreThreshold : 0
1083
- )
1084
- )
1085
- ), H = n(() => Number.isFinite(e.autoplayDelay) ? Math.max(1, e.autoplayDelay) : 3e3), ae = n(() => {
1086
- if (w.value <= 0) return 0;
1087
- const t = (E.value - 1) * W.value;
1088
- return Math.max(
1089
- 1,
1090
- (w.value - t) / E.value
1091
- );
1092
- }), R = n(() => ae.value + W.value), J = n(
1093
- () => Math.max(
1094
- 0,
1095
- e.items.length - E.value
1096
- )
1097
- ), Y = n(
1098
- () => Math.max(0, o.value - ne.value)
1099
- ), le = n(
1100
- () => Math.min(
1101
- e.items.length,
1102
- o.value + E.value + ne.value
1103
- )
1104
- ), se = n(
1105
- () => e.items.slice(Y.value, le.value).map((t, a) => ({
1106
- item: t,
1107
- index: Y.value + a
1108
- }))
1109
- ), me = n(() => e.items.length === 0 ? 0 : e.items.length * ae.value + (e.items.length - 1) * W.value), de = n(
1110
- () => Y.value * R.value
1111
- ), ue = n(
1112
- () => Math.max(
1113
- 0,
1114
- me.value - le.value * R.value
1115
- )
1116
- ), we = n(() => ({
1117
- height: Fe(e.height)
1677
+ }), ue = h(() => ie(e.buffer, 0, 1)), fe = h(() => ie(e.maxCachedItems, 0, 20)), he = h(() => r.value > 0 ? Math.max(
1678
+ 1,
1679
+ (r.value - (te.value.slidesPerView - 1) * te.value.gap) / te.value.slidesPerView
1680
+ ) : 0), ve = h(() => e.items.map((a, l) => e.autoWidth ? C.value.get(ne.value[l]) ?? Math.max(1, Number.isFinite(e.estimatedItemWidth) ? e.estimatedItemWidth : 240) : he.value)), J = h(() => ma(ve.value, te.value.gap)), O = h(() => e.loop && e.items.length > 1 && J.value.totalWidth > r.value), S = h(() => Math.max(0, J.value.totalWidth - r.value)), P = h(() => {
1681
+ if (O.value) return e.items.length - 1;
1682
+ if (!e.autoWidth) return Math.max(0, e.items.length - te.value.slidesPerView);
1683
+ if (S.value <= 0) return 0;
1684
+ const a = J.value.indexAt(S.value), l = J.value.offsets[a] < S.value - 0.01 ? a + 1 : a;
1685
+ return Math.min(e.items.length - 1, l);
1686
+ }), oe = h(() => O.value ? J.value.cycleWidth * 3 : J.value.totalWidth), me = h(() => ({ height: gt(e.height) })), Ae = h(() => ({
1687
+ width: `${oe.value}px`,
1688
+ height: e.height === "auto" ? `${Math.max(1, u.value)}px` : "100%"
1118
1689
  }));
1119
- function G(t) {
1120
- return Math.min(
1121
- J.value,
1122
- Math.max(0, Math.floor(Number.isFinite(t) ? t : 0))
1123
- );
1124
- }
1125
- o.value = G(e.activeIndex);
1126
- function u(t) {
1127
- return t >= o.value && t < Math.min(
1128
- e.items.length,
1129
- o.value + E.value
1130
- );
1131
- }
1132
- function d() {
1133
- if (!e.hasMore || e.loading || A === e.items.length)
1690
+ function E(a) {
1691
+ const l = Math.floor(Number.isFinite(a) ? a : 0);
1692
+ return O.value ? dt(l, e.items.length) : Math.max(0, Math.min(P.value, l));
1693
+ }
1694
+ n.value = E(e.activeIndex);
1695
+ function F(a) {
1696
+ const l = J.value.offsets[E(a)] ?? 0;
1697
+ return O.value ? J.value.cycleWidth + l : Math.min(S.value, l);
1698
+ }
1699
+ function _(a) {
1700
+ const l = J.value.cycleWidth;
1701
+ return O.value && l > 0 ? (a % l + l) % l : Math.max(0, a);
1702
+ }
1703
+ function pe(a) {
1704
+ if (!O.value && a >= S.value - 1 && S.value > 0) return P.value;
1705
+ const l = _(a);
1706
+ return O.value && l > (J.value.offsets[e.items.length - 1] + J.value.cycleWidth) / 2 ? 0 : E(J.value.nearestIndex(l));
1707
+ }
1708
+ function ze(a, l, g = 0) {
1709
+ const W = F(a);
1710
+ if (!O.value) return W;
1711
+ const Te = J.value.cycleWidth, Ke = [W - Te, W, W + Te], Be = Ke.filter((He) => g > 0 ? He > l + 0.5 : g < 0 ? He < l - 0.5 : !0);
1712
+ return (Be.length ? Be : Ke).sort((He, ot) => Math.abs(He - l) - Math.abs(ot - l))[0];
1713
+ }
1714
+ function be(a) {
1715
+ if (!O.value) return J.value.indexAt(Math.max(0, a));
1716
+ const l = J.value.cycleWidth, g = Math.floor(a / l);
1717
+ return g * e.items.length + J.value.indexAt(a - g * l);
1718
+ }
1719
+ function Me(a) {
1720
+ return O.value ? Math.floor(a / e.items.length) * J.value.cycleWidth + J.value.offsets[dt(a, e.items.length)] : J.value.offsets[a] ?? 0;
1721
+ }
1722
+ function ce(a) {
1723
+ if (e.items.length === 0) {
1724
+ b.value = [], A.value = [0, 0];
1134
1725
  return;
1135
- const t = e.items.length === 0 ? -1 : Math.min(
1136
- e.items.length - 1,
1137
- o.value + E.value - 1
1138
- );
1139
- e.items.length - 1 - t <= Z.value && (A = e.items.length, p("loadMore"));
1140
- }
1141
- function z(t) {
1142
- const a = G(t);
1143
- a === o.value || e.items.length === 0 || (o.value = a, p("update:activeIndex", a), p("change", {
1144
- index: a,
1145
- item: e.items[a]
1146
- }), a === 0 && p("reachStart"), a === J.value && p("reachEnd"), d(), e.autoplay && !V.value && B());
1147
- }
1148
- function Q(t, a = {}) {
1149
- const g = f.value;
1150
- g && (typeof g.scrollTo == "function" ? g.scrollTo({ ...a, left: t }) : g.scrollLeft = t);
1151
- }
1152
- function he(t, a = {}) {
1153
- if (e.items.length === 0 || R.value <= 0) return;
1154
- const g = G(t);
1155
- U = a.behavior === "smooth" ? g : void 0, z(g), Q(g * R.value, {
1156
- ...a,
1157
- behavior: a.behavior
1158
- });
1726
+ }
1727
+ if (r.value <= 0) return;
1728
+ const l = be(a), g = be(a + r.value - 0.01);
1729
+ (A.value[0] !== l || A.value[1] !== g + 1) && (A.value = [l, g + 1]);
1730
+ const W = [];
1731
+ for (let Te = l; Te <= g; Te += 1) {
1732
+ const Ke = O.value ? dt(Te, e.items.length) : Te;
1733
+ if (Ke < 0 || Ke >= e.items.length) continue;
1734
+ const Be = Me(Te);
1735
+ Be + ve.value[Ke] > a + 0.01 && Be < a + r.value - 0.01 && !W.includes(Ke) && W.push(Ke);
1736
+ }
1737
+ W.join(",") !== b.value.join(",") && (b.value = W);
1159
1738
  }
1160
- function y(t = "smooth") {
1161
- he(
1162
- o.value + F.value,
1163
- { behavior: t }
1164
- );
1739
+ function de(a) {
1740
+ if (e.autoWidth) {
1741
+ const l = F(n.value), g = ze(a, l);
1742
+ return g + ve.value[a] > l && g < l + r.value;
1743
+ }
1744
+ return O.value ? dt(a - n.value, e.items.length) < te.value.slidesPerView : a >= n.value && a < n.value + te.value.slidesPerView;
1745
+ }
1746
+ function v() {
1747
+ if (!e.hasMore || e.loading || G === e.items.length) return;
1748
+ const a = e.autoWidth ? b.value.length : te.value.slidesPerView;
1749
+ e.items.length - n.value - Math.max(1, a) <= ie(e.loadMoreThreshold, 0, 2) && (G = e.items.length, z("loadMore"));
1750
+ }
1751
+ function T(a) {
1752
+ const l = E(a);
1753
+ !e.items.length || l === n.value || (n.value = l, z("update:activeIndex", l), z("change", { index: l, item: e.items[l] }), l === 0 && z("reachStart"), l === P.value && z("reachEnd"), v());
1754
+ }
1755
+ const i = fa({
1756
+ viewport: () => x.value,
1757
+ track: () => y.value,
1758
+ rtl: () => e.rtl,
1759
+ mouseDrag: () => e.mouseDrag,
1760
+ mouseDragMode: () => e.mouseDragMode,
1761
+ nativeSnap: () => e.nativeSnap && !O.value,
1762
+ dragThreshold: () => Math.max(1, Number.isFinite(e.dragThreshold) ? e.dragThreshold : 8),
1763
+ momentum: () => e.momentum,
1764
+ settleDuration: () => Math.max(0, Number.isFinite(e.settleDuration) ? e.settleDuration : 250),
1765
+ limits: () => [0, O.value ? Math.max(0, oe.value - r.value) : S.value],
1766
+ step: () => ve.value[n.value] + te.value.gap || 1,
1767
+ indexAt: pe,
1768
+ target: ze,
1769
+ canonical: F,
1770
+ onPosition: ce,
1771
+ onCommit: T
1772
+ }), { phase: q, dragging: Q } = i, ke = va({
1773
+ enabled: () => R.value && e.autoplay,
1774
+ paused: () => i.pointerActive.value || q.value === "pending" || q.value === "dragging" || q.value === "committing" || O.value && q.value === "settling" || M.value && e.pauseOnHover,
1775
+ delay: () => e.autoplayDelay,
1776
+ count: () => e.items.length,
1777
+ atEnd: () => !O.value && n.value >= P.value,
1778
+ loop: () => O.value || e.autoplayLoop,
1779
+ advance: () => $e(),
1780
+ rewind: () => we(0, { behavior: "smooth" })
1781
+ }), ge = h(() => {
1782
+ const a = Q.value || i.transformed.value, l = ue.value + (a ? te.value.slidesPerView + 2 : 0);
1783
+ let g, W;
1784
+ !e.autoWidth && !O.value && !a ? (g = Math.max(0, n.value - l), W = Math.min(e.items.length, n.value + te.value.slidesPerView + l)) : (g = Math.max(0, A.value[0] - l), W = Math.min(O.value ? e.items.length * 3 : e.items.length, A.value[1] + l));
1785
+ const Te = (A.value[0] + A.value[1] - 1) / 2, Ke = /* @__PURE__ */ new Map();
1786
+ for (let Be = g; Be < W; Be += 1) {
1787
+ const He = O.value ? dt(Be, e.items.length) : Be, ot = Ke.get(He);
1788
+ (!ot || Math.abs(Be - Te) < Math.abs(ot.virtual - Te)) && Ke.set(He, { index: He, virtual: Be, cached: !1 });
1789
+ }
1790
+ return [...Ke.values()].sort((Be, He) => Be.virtual - He.virtual);
1791
+ });
1792
+ ye([b, q, ne], () => {
1793
+ if (q.value !== "idle") return;
1794
+ const a = b.value.filter((g) => g < e.items.length).map((g) => ne.value[g]);
1795
+ if (!e.keepAlive) {
1796
+ $.value = [];
1797
+ return;
1798
+ }
1799
+ const l = $.value.filter((g) => le.value.has(g) && !a.includes(g));
1800
+ $.value = [...l, ...a].slice(-(fe.value + a.length));
1801
+ }, { immediate: !0 });
1802
+ const Ee = h(() => {
1803
+ const a = [...ge.value], l = new Set(a.map((W) => W.index)), g = /* @__PURE__ */ new Set();
1804
+ for (const W of e.pinnedIndexes.slice(0, fe.value))
1805
+ Number.isInteger(W) && W >= 0 && W < e.items.length && g.add(W);
1806
+ if (D.value !== void 0 && D.value < e.items.length && g.add(D.value), e.keepAlive)
1807
+ for (const W of [...$.value].reverse()) {
1808
+ const Te = le.value.get(W);
1809
+ Te !== void 0 && !l.has(Te) && g.size < fe.value && g.add(Te);
1810
+ }
1811
+ for (const W of g)
1812
+ l.has(W) || a.push({ index: W, virtual: O.value ? e.items.length + W : W, cached: W !== D.value });
1813
+ return a.sort((W, Te) => W.virtual - Te.virtual).map((W) => ({
1814
+ ...W,
1815
+ item: e.items[W.index],
1816
+ key: ne.value[W.index]
1817
+ }));
1818
+ }), d = h(() => ge.value.length ? Me(ge.value[0].virtual) : 0), K = h(() => !e.autoWidth && !O.value && !e.keepAlive && !e.pinnedIndexes.length && (D.value === void 0 || ge.value.some((a) => a.index === D.value))), m = h(() => {
1819
+ const a = ge.value[ge.value.length - 1];
1820
+ return a ? Math.max(0, oe.value - Me(a.virtual) - ve.value[a.index] - te.value.gap) : 0;
1821
+ });
1822
+ function w(a) {
1823
+ const l = ve.value[a.index];
1824
+ return {
1825
+ position: K.value ? "relative" : "absolute",
1826
+ [e.rtl ? "right" : "left"]: K.value ? void 0 : `${Me(a.virtual)}px`,
1827
+ width: e.autoWidth ? "max-content" : `${l}px`,
1828
+ flexBasis: e.autoWidth ? "auto" : `${l}px`,
1829
+ marginRight: !e.rtl && a.index < e.items.length - 1 ? `${te.value.gap}px` : "0px",
1830
+ marginLeft: e.rtl && a.index < e.items.length - 1 ? `${te.value.gap}px` : "0px",
1831
+ height: e.height === "auto" ? "auto" : "100%",
1832
+ visibility: a.cached ? "hidden" : void 0,
1833
+ scrollSnapAlign: e.nativeSnap && !O.value && r.value > 0 ? "start" : "none"
1834
+ };
1165
1835
  }
1166
- function L(t = "smooth") {
1167
- he(
1168
- o.value - F.value,
1169
- { behavior: t }
1170
- );
1836
+ function k() {
1837
+ if (!H.size || q.value !== "idle") return;
1838
+ const a = new Map(C.value);
1839
+ for (const [l, g] of H) a.set(l, g);
1840
+ H.clear(), C.value = a;
1171
1841
  }
1172
- function B() {
1173
- te(), !(!e.autoplay || e.items.length === 0) && (O = setTimeout(() => {
1174
- o.value >= J.value ? e.autoplayLoop ? he(0, { behavior: "smooth" }) : te() : y("smooth");
1175
- }, H.value));
1842
+ function ee(a, l) {
1843
+ if (l < 0 || l >= e.items.length) return;
1844
+ const { width: g, height: W } = a.getBoundingClientRect();
1845
+ W > u.value && (u.value = W);
1846
+ const Te = ne.value[l];
1847
+ e.autoWidth && g > 0 && Math.abs((C.value.get(Te) ?? 0) - g) > 0.5 && H.set(Te, g);
1176
1848
  }
1177
- function te() {
1178
- O !== void 0 && (clearTimeout(O), O = void 0);
1849
+ function L() {
1850
+ var l;
1851
+ if (Y || e.height !== "auto") return;
1852
+ let a = 0;
1853
+ for (const g of ge.value)
1854
+ a = Math.max(a, ((l = se.get(g.index)) == null ? void 0 : l.getBoundingClientRect().height) ?? 0);
1855
+ Math.abs(u.value - a) > 0.5 && (u.value = a);
1856
+ }
1857
+ function xe(a, l) {
1858
+ const g = se.get(l);
1859
+ if (g && (V == null || V.unobserve(g)), !(a instanceof HTMLElement)) {
1860
+ se.delete(l);
1861
+ return;
1862
+ }
1863
+ se.set(l, a), (e.autoWidth || e.height === "auto") && (V == null || V.observe(a), ee(a, l), Z(k), Z(L));
1179
1864
  }
1180
- function oe() {
1181
- V.value = !0, e.pauseOnHover && te();
1865
+ function we(a, l = {}) {
1866
+ !e.items.length || r.value <= 0 || i.navigate(E(a), l.behavior ?? "auto", 0, O.value || !e.nativeSnap);
1182
1867
  }
1183
- function re() {
1184
- V.value = !1, e.autoplay && B();
1868
+ function $e(a = "smooth") {
1869
+ !e.items.length || r.value <= 0 || i.navigate(E(n.value + te.value.slidesToScroll), a, 1, O.value || !e.nativeSnap);
1185
1870
  }
1186
- function ye() {
1187
- U = void 0;
1871
+ function De(a = "smooth") {
1872
+ !e.items.length || r.value <= 0 || i.navigate(E(n.value - te.value.slidesToScroll), a, -1, O.value || !e.nativeSnap);
1188
1873
  }
1189
- function _(t) {
1190
- if (R.value <= 0 || q) return;
1191
- const a = t.currentTarget.scrollLeft;
1192
- if (U !== void 0) {
1193
- const g = U * R.value;
1194
- if (Math.abs(a - g) > 1) return;
1195
- U = void 0;
1196
- }
1197
- z(Math.round(a / R.value));
1874
+ function Ie(a) {
1875
+ var W, Te;
1876
+ if ((Te = (W = a.target) == null ? void 0 : W.closest) != null && Te.call(W, 'input, textarea, select, [contenteditable="true"]')) return;
1877
+ const l = e.rtl ? "ArrowLeft" : "ArrowRight", g = e.rtl ? "ArrowRight" : "ArrowLeft";
1878
+ a.key === l || a.key === "PageDown" ? (a.preventDefault(), $e()) : a.key === g || a.key === "PageUp" ? (a.preventDefault(), De()) : a.key === "Home" ? (a.preventDefault(), we(0, { behavior: "smooth" })) : a.key === "End" && (a.preventDefault(), we(P.value));
1198
1879
  }
1199
- function ee(t) {
1200
- t.key === "ArrowRight" || t.key === "PageDown" ? (t.preventDefault(), y()) : t.key === "ArrowLeft" || t.key === "PageUp" ? (t.preventDefault(), L()) : t.key === "Home" ? (t.preventDefault(), he(0, { behavior: "smooth" })) : t.key === "End" && (t.preventDefault(), he(J.value, { behavior: "auto" }));
1880
+ function Ye(a) {
1881
+ var g, W;
1882
+ const l = (W = (g = a.target) == null ? void 0 : g.closest) == null ? void 0 : W.call(g, "[data-carousel-index]");
1883
+ D.value = l ? Number(l.getAttribute("data-carousel-index")) : void 0;
1201
1884
  }
1202
- function s() {
1203
- var a;
1204
- const t = ((a = f.value) == null ? void 0 : a.clientWidth) ?? 0;
1205
- t <= 0 || t === r.value || (q = !0, r.value = t, C(() => {
1206
- const g = G(o.value);
1207
- Q(g * R.value), q = !1;
1208
- }));
1885
+ function je() {
1886
+ Z(() => {
1887
+ var a;
1888
+ (a = x.value) != null && a.contains(document.activeElement) || (D.value = void 0);
1889
+ });
1209
1890
  }
1210
- return ie(
1211
- () => e.activeIndex,
1212
- async (t) => {
1213
- const a = G(t);
1214
- a !== o.value && (ye(), o.value = a, await C(), Q(a * R.value), d());
1215
- }
1216
- ), ie(
1217
- () => [
1218
- e.items.length,
1219
- k.value.slidesPerView,
1220
- k.value.gap,
1221
- k.value.slidesToScroll
1222
- ],
1223
- async () => {
1224
- const t = G(o.value);
1225
- e.items.length === 0 ? o.value !== 0 && (o.value = 0, p("update:activeIndex", 0)) : z(t), await C(), Q(t * R.value), d(), e.autoplay && e.items.length > 0 && !V.value && B();
1226
- }
1227
- ), ie(
1228
- () => e.responsive,
1229
- () => {
1230
- C(() => {
1231
- const t = G(o.value);
1232
- Q(t * R.value);
1233
- });
1234
- },
1235
- { deep: !0 }
1236
- ), ie(
1237
- () => [
1238
- e.hasMore,
1239
- e.loading,
1240
- e.loadMoreThreshold
1241
- ],
1242
- async ([t]) => {
1243
- t || (A = -1), await C(), d();
1244
- }
1245
- ), ie(
1246
- () => e.autoplay,
1247
- (t) => {
1248
- t && !V.value ? B() : te();
1249
- }
1250
- ), ie(
1251
- () => e.autoplayDelay,
1252
- () => {
1253
- e.autoplay && !V.value && B();
1254
- }
1255
- ), ie(
1256
- () => e.autoplayLoop,
1257
- (t) => {
1258
- !e.autoplay || V.value || (!t && o.value >= J.value ? te() : B());
1259
- }
1260
- ), ie(
1261
- () => e.pauseOnHover,
1262
- (t) => {
1263
- t && V.value ? te() : !t && e.autoplay && B();
1264
- }
1265
- ), Ae(async () => {
1266
- s(), typeof ResizeObserver < "u" && f.value && (m = new ResizeObserver(s), m.observe(f.value)), await C(), Q(o.value * R.value), d(), e.autoplay && B();
1267
- }), Ce(() => {
1268
- m && (m.disconnect(), m = void 0), te();
1269
- }), P({
1270
- next: y,
1271
- previous: L,
1272
- scrollToIndex: he,
1273
- startAutoplay: B,
1274
- stopAutoplay: te
1275
- }), (t, a) => (I(), $("div", {
1891
+ function Ze() {
1892
+ i.cancel(!1), e.items.length ? T(E(n.value)) : n.value !== 0 && (n.value = 0, z("update:activeIndex", 0)), Y || i.commit(n.value), Z(v);
1893
+ }
1894
+ function ut() {
1895
+ var l;
1896
+ const a = ((l = x.value) == null ? void 0 : l.clientWidth) ?? 0;
1897
+ a <= 0 || a === r.value || (r.value = a);
1898
+ }
1899
+ return ye(() => [
1900
+ e.items.length,
1901
+ r.value,
1902
+ te.value.slidesPerView,
1903
+ te.value.gap,
1904
+ e.rtl,
1905
+ O.value,
1906
+ e.autoWidth,
1907
+ e.nativeSnap,
1908
+ C.value
1909
+ ], Ze), ye(() => e.activeIndex, (a) => {
1910
+ const l = E(a);
1911
+ l !== n.value && (i.cancel(!1), n.value = l, i.commit(l), Z(v));
1912
+ }), ye(() => [e.hasMore, e.loading, e.loadMoreThreshold], () => {
1913
+ e.hasMore || (G = -1), Z(v);
1914
+ }), ye(() => ne.value, (a) => {
1915
+ const l = new Set(a);
1916
+ C.value = new Map([...C.value].filter(([g]) => l.has(g))), $.value = $.value.filter((g) => l.has(g));
1917
+ }), ye(q, (a) => {
1918
+ a === "idle" && Z(k);
1919
+ }), ye(() => [e.keepAlive, e.maxCachedItems], () => {
1920
+ const a = b.value.map((l) => ne.value[l]);
1921
+ $.value = e.keepAlive ? [...$.value.filter((l) => !a.includes(l)), ...a].slice(-(fe.value + a.length)) : [];
1922
+ }), at(async () => {
1923
+ if (ut(), typeof ResizeObserver < "u" && (B = new ResizeObserver(ut), x.value && B.observe(x.value), V = new ResizeObserver((a) => {
1924
+ for (const l of a) ee(l.target, Number(l.target.dataset.carouselIndex));
1925
+ k(), L();
1926
+ }), e.autoWidth || e.height === "auto"))
1927
+ for (const [a, l] of se)
1928
+ V.observe(l), ee(l, a);
1929
+ await Z(), Ze(), R.value = !0;
1930
+ }), Xe(() => {
1931
+ Y = !0, B == null || B.disconnect(), V == null || V.disconnect();
1932
+ }), s({ next: $e, previous: De, scrollToIndex: we, startAutoplay: ke.start, stopAutoplay: ke.stop }), (a, l) => (j(), U("div", {
1276
1933
  ref_key: "viewport",
1277
- ref: f,
1278
- class: "vue-virtual-carousel",
1279
- style: N(we.value),
1934
+ ref: x,
1935
+ class: st(["vue-virtual-carousel", { "vue-virtual-carousel--mouse-drag": t.mouseDrag, "vue-virtual-carousel--dragging": f(Q), "vue-virtual-carousel--controlled": O.value || !t.nativeSnap }]),
1936
+ style: re(me.value),
1937
+ dir: t.rtl ? "rtl" : "ltr",
1280
1938
  role: "region",
1281
1939
  "aria-roledescription": "carousel",
1282
- "aria-label": l.ariaLabel,
1940
+ "aria-label": t.ariaLabel,
1283
1941
  tabindex: "0",
1284
- onScrollPassive: _,
1285
- onPointerdown: ye,
1286
- onWheelPassive: ye,
1287
- onKeydown: ee,
1288
- onMouseenter: oe,
1289
- onMouseleave: re
1942
+ onScrollPassive: l[0] || (l[0] = //@ts-ignore
1943
+ (...g) => f(i).handleScroll && f(i).handleScroll(...g)),
1944
+ onPointerdown: l[1] || (l[1] = //@ts-ignore
1945
+ (...g) => f(i).handlePointerDown && f(i).handlePointerDown(...g)),
1946
+ onPointermove: l[2] || (l[2] = //@ts-ignore
1947
+ (...g) => f(i).handlePointerMove && f(i).handlePointerMove(...g)),
1948
+ onPointerup: l[3] || (l[3] = //@ts-ignore
1949
+ (...g) => f(i).handlePointerUp && f(i).handlePointerUp(...g)),
1950
+ onPointercancel: l[4] || (l[4] = //@ts-ignore
1951
+ (...g) => f(i).handlePointerCancel && f(i).handlePointerCancel(...g)),
1952
+ onLostpointercapture: l[5] || (l[5] = //@ts-ignore
1953
+ (...g) => f(i).handleLostPointerCapture && f(i).handleLostPointerCapture(...g)),
1954
+ onClickCapture: l[6] || (l[6] = //@ts-ignore
1955
+ (...g) => f(i).handleClick && f(i).handleClick(...g)),
1956
+ onDragstart: l[7] || (l[7] = //@ts-ignore
1957
+ (...g) => f(i).handleDragStart && f(i).handleDragStart(...g)),
1958
+ onWheelPassive: l[8] || (l[8] = //@ts-ignore
1959
+ (...g) => f(i).handleWheel && f(i).handleWheel(...g)),
1960
+ onKeydown: Ie,
1961
+ onMouseenter: l[9] || (l[9] = (g) => M.value = !0),
1962
+ onMouseleave: l[10] || (l[10] = (g) => M.value = !1),
1963
+ onFocusin: Ye,
1964
+ onFocusout: je
1290
1965
  }, [
1291
- l.items.length ? (I(), $("div", wt, [
1292
- de.value > 0 ? (I(), $("div", {
1966
+ t.items.length ? (j(), U("div", {
1967
+ key: 0,
1968
+ ref_key: "track",
1969
+ ref: y,
1970
+ class: "vue-virtual-carousel__track",
1971
+ style: re(Ae.value),
1972
+ role: "list"
1973
+ }, [
1974
+ d.value > 0 ? (j(), U("div", {
1293
1975
  key: 0,
1294
1976
  class: "vue-virtual-carousel__spacer",
1295
- style: N({ flexBasis: `${de.value}px` }),
1977
+ style: re({ flexBasis: `${d.value}px`, position: K.value ? "relative" : "absolute" }),
1296
1978
  "aria-hidden": "true"
1297
- }, null, 4)) : ze("", !0),
1298
- (I(!0), $(Re, null, De(se.value, ({ item: g, index: b }) => (I(), $("div", {
1299
- key: c(D)(g, b),
1979
+ }, null, 4)) : Re("", !0),
1980
+ (j(!0), U(et, null, nt(Ee.value, (g) => (j(), U("div", {
1981
+ key: g.key,
1982
+ ref_for: !0,
1983
+ ref: (W) => xe(W, g.index),
1300
1984
  class: "vue-virtual-carousel__item",
1301
- style: N({
1302
- flexBasis: `${ae.value}px`,
1303
- marginRight: b < l.items.length - 1 ? `${W.value}px` : "0px"
1304
- }),
1985
+ "data-carousel-index": g.index,
1986
+ style: re(w(g)),
1305
1987
  role: "listitem",
1306
1988
  "aria-roledescription": "slide",
1307
- "aria-label": `${b + 1} of ${l.items.length}`,
1308
- "aria-current": b === o.value ? "true" : void 0
1989
+ "aria-label": `${g.index + 1} of ${t.items.length}`,
1990
+ "aria-current": g.index === n.value ? "true" : void 0,
1991
+ "aria-hidden": g.cached ? "true" : void 0,
1992
+ inert: g.cached ? !0 : void 0
1309
1993
  }, [
1310
- ce(t.$slots, "default", {
1311
- item: g,
1312
- index: b,
1313
- active: b === o.value,
1314
- visible: u(b)
1994
+ Se(a.$slots, "default", {
1995
+ item: g.item,
1996
+ index: g.index,
1997
+ active: g.index === n.value,
1998
+ visible: de(g.index),
1999
+ inViewport: b.value.includes(g.index)
1315
2000
  })
1316
- ], 12, Tt))), 128)),
1317
- ue.value > 0 ? (I(), $("div", {
2001
+ ], 12, ga))), 128)),
2002
+ m.value > 0 ? (j(), U("div", {
1318
2003
  key: 1,
1319
2004
  class: "vue-virtual-carousel__spacer",
1320
- style: N({ flexBasis: `${ue.value}px` }),
2005
+ style: re({ flexBasis: `${m.value}px`, position: K.value ? "relative" : "absolute" }),
1321
2006
  "aria-hidden": "true"
1322
- }, null, 4)) : ze("", !0)
1323
- ])) : (I(), $("div", bt, [
1324
- ce(t.$slots, "empty")
2007
+ }, null, 4)) : Re("", !0)
2008
+ ], 4)) : (j(), U("div", pa, [
2009
+ Se(a.$slots, "empty")
1325
2010
  ]))
1326
- ], 44, xt));
2011
+ ], 46, ha));
1327
2012
  }
1328
- }), zt = ["aria-label"], It = ["aria-posinset", "aria-setsize"], $t = /* @__PURE__ */ Oe({
2013
+ }), wa = ["aria-label"], Ma = ["aria-posinset", "aria-setsize"], xa = /* @__PURE__ */ tt({
1329
2014
  name: "VirtualScroll",
1330
2015
  __name: "VirtualScroll",
1331
2016
  props: {
@@ -1344,210 +2029,210 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
1344
2029
  pullRefreshThreshold: { default: 64 }
1345
2030
  },
1346
2031
  emits: ["scroll", "loadMore", "refresh"],
1347
- setup(l, { expose: P, emit: x }) {
1348
- const e = l, p = x, {
1349
- pulling: f,
1350
- pullDistance: r,
1351
- pullOffset: o,
1352
- pullProgress: m,
1353
- refreshMessage: A,
1354
- refreshThreshold: O,
1355
- handleTouchStart: U,
1356
- handleTouchMove: q,
1357
- handleTouchEnd: V,
1358
- handleTouchCancel: D
1359
- } = qe({
2032
+ setup(t, { expose: s, emit: I }) {
2033
+ const e = t, z = I, {
2034
+ pulling: x,
2035
+ pullDistance: y,
2036
+ pullOffset: r,
2037
+ pullProgress: u,
2038
+ refreshMessage: n,
2039
+ refreshThreshold: M,
2040
+ handleTouchStart: R,
2041
+ handleTouchMove: D,
2042
+ handleTouchEnd: b,
2043
+ handleTouchCancel: A
2044
+ } = xt({
1360
2045
  enabled: () => e.pullToRefresh,
1361
2046
  refreshing: () => e.refreshing,
1362
2047
  threshold: () => e.pullRefreshThreshold,
1363
- onRefresh: () => p("refresh")
1364
- }), w = j(), k = j(0), E = j(0);
1365
- let F, W = -1;
1366
- const ne = Ue(), { getItemKey: Z } = Pe({
2048
+ onRefresh: () => z("refresh")
2049
+ }), C = X(), $ = X(0), B = X(0);
2050
+ let V, G = -1;
2051
+ const Y = Mt(), { getItemKey: se } = lt({
1367
2052
  componentName: "VirtualScroll",
1368
2053
  items: () => e.items,
1369
2054
  itemKey: () => e.itemKey
1370
- }), H = n(() => Math.max(1, e.itemSize)), ae = n(() => Math.max(0, Math.floor(e.overscan))), R = n(
2055
+ }), H = h(() => Math.max(1, e.itemSize)), ae = h(() => Math.max(0, Math.floor(e.overscan))), ne = h(
1371
2056
  () => e.items.length * H.value
1372
- ), J = n(
2057
+ ), le = h(
1373
2058
  () => Math.max(1, e.loadingItemSize ?? H.value)
1374
- ), Y = n(
1375
- () => R.value + (e.loading ? J.value : 0)
1376
- ), le = n(() => E.value > 0 ? E.value : typeof e.height == "number" ? e.height : 0), se = n(
2059
+ ), ie = h(
2060
+ () => ne.value + (e.loading ? le.value : 0)
2061
+ ), te = h(() => B.value > 0 ? B.value : typeof e.height == "number" ? e.height : 0), ue = h(
1377
2062
  () => Math.max(
1378
2063
  0,
1379
- Math.floor(k.value / H.value) - ae.value
2064
+ Math.floor($.value / H.value) - ae.value
1380
2065
  )
1381
- ), me = n(() => {
1382
- const y = Math.ceil(
1383
- (k.value + le.value) / H.value
2066
+ ), fe = h(() => {
2067
+ const E = Math.ceil(
2068
+ ($.value + te.value) / H.value
1384
2069
  );
1385
2070
  return Math.min(
1386
2071
  e.items.length,
1387
- y + ae.value
2072
+ E + ae.value
1388
2073
  );
1389
- }), de = n(
1390
- () => e.items.slice(se.value, me.value).map((y, L) => ({
1391
- item: y,
1392
- index: se.value + L
2074
+ }), he = h(
2075
+ () => e.items.slice(ue.value, fe.value).map((E, F) => ({
2076
+ item: E,
2077
+ index: ue.value + F
1393
2078
  }))
1394
- ), ue = n(() => ({
1395
- height: Fe(e.height)
1396
- })), we = n(() => ({
1397
- transform: `translateY(${se.value * H.value}px)`
2079
+ ), ve = h(() => ({
2080
+ height: gt(e.height)
2081
+ })), J = h(() => ({
2082
+ transform: `translateY(${ue.value * H.value}px)`
1398
2083
  }));
1399
- function G() {
1400
- var y;
1401
- E.value = ((y = w.value) == null ? void 0 : y.clientHeight) ?? 0, ne(w.value, e.height), C(d);
1402
- }
1403
- function u(y) {
1404
- k.value = y.currentTarget.scrollTop, p("scroll", {
1405
- scrollTop: k.value,
1406
- startIndex: se.value,
1407
- endIndex: me.value
1408
- }), d();
1409
- }
1410
- function d() {
1411
- const y = w.value;
1412
- if (!y || !e.hasMore || e.loading || W === e.items.length)
2084
+ function O() {
2085
+ var E;
2086
+ B.value = ((E = C.value) == null ? void 0 : E.clientHeight) ?? 0, Y(C.value, e.height), Z(P);
2087
+ }
2088
+ function S(E) {
2089
+ $.value = E.currentTarget.scrollTop, z("scroll", {
2090
+ scrollTop: $.value,
2091
+ startIndex: ue.value,
2092
+ endIndex: fe.value
2093
+ }), P();
2094
+ }
2095
+ function P() {
2096
+ const E = C.value;
2097
+ if (!E || !e.hasMore || e.loading || G === e.items.length)
1413
2098
  return;
1414
- const L = Math.max(0, e.loadMoreThreshold);
1415
- Y.value - y.scrollTop - y.clientHeight <= L && (W = e.items.length, p("loadMore"));
1416
- }
1417
- function z(y, L = {}) {
1418
- const B = w.value;
1419
- if (!B) return;
1420
- const te = Math.max(0, Y.value - B.clientHeight), oe = Math.min(
1421
- Math.max(0, Number.isFinite(y) ? y : 0),
1422
- te
1423
- ), re = L.behavior ?? "auto";
1424
- re === "auto" && (k.value = oe), B.scrollTo({ ...L, top: oe, behavior: re });
1425
- }
1426
- function Q(y, L = {}) {
1427
- const B = w.value;
1428
- if (!B || e.items.length === 0) return;
1429
- const te = Math.min(
2099
+ const F = Math.max(0, e.loadMoreThreshold);
2100
+ ie.value - E.scrollTop - E.clientHeight <= F && (G = e.items.length, z("loadMore"));
2101
+ }
2102
+ function oe(E, F = {}) {
2103
+ const _ = C.value;
2104
+ if (!_) return;
2105
+ const pe = Math.max(0, ie.value - _.clientHeight), ze = Math.min(
2106
+ Math.max(0, Number.isFinite(E) ? E : 0),
2107
+ pe
2108
+ ), be = F.behavior ?? "auto";
2109
+ be === "auto" && ($.value = ze), _.scrollTo({ ...F, top: ze, behavior: be });
2110
+ }
2111
+ function me(E, F = {}) {
2112
+ const _ = C.value;
2113
+ if (!_ || e.items.length === 0) return;
2114
+ const pe = Math.min(
1430
2115
  e.items.length - 1,
1431
- Math.max(0, Math.floor(y))
1432
- ), { align: oe = "start", ...re } = L;
1433
- let ye = te * H.value;
1434
- oe === "center" ? ye -= (B.clientHeight - H.value) / 2 : oe === "end" && (ye -= B.clientHeight - H.value), B.scrollTo({
1435
- ...re,
1436
- top: Math.max(0, Math.min(ye, Y.value - B.clientHeight))
2116
+ Math.max(0, Math.floor(E))
2117
+ ), { align: ze = "start", ...be } = F;
2118
+ let Me = pe * H.value;
2119
+ ze === "center" ? Me -= (_.clientHeight - H.value) / 2 : ze === "end" && (Me -= _.clientHeight - H.value), _.scrollTo({
2120
+ ...be,
2121
+ top: Math.max(0, Math.min(Me, ie.value - _.clientHeight))
1437
2122
  });
1438
2123
  }
1439
- function he(y = "auto") {
1440
- var L;
1441
- (L = w.value) == null || L.scrollTo({ top: 0, behavior: y });
2124
+ function Ae(E = "auto") {
2125
+ var F;
2126
+ (F = C.value) == null || F.scrollTo({ top: 0, behavior: E });
1442
2127
  }
1443
- return ie(
2128
+ return ye(
1444
2129
  () => [e.items.length, e.itemSize],
1445
2130
  async () => {
1446
- await C();
1447
- const y = w.value;
1448
- if (!y) return;
1449
- const L = Math.max(0, Y.value - y.clientHeight);
1450
- y.scrollTop > L && (y.scrollTop = L, k.value = L), d();
2131
+ await Z();
2132
+ const E = C.value;
2133
+ if (!E) return;
2134
+ const F = Math.max(0, ie.value - E.clientHeight);
2135
+ E.scrollTop > F && (E.scrollTop = F, $.value = F), P();
1451
2136
  }
1452
- ), ie(
2137
+ ), ye(
1453
2138
  () => [e.hasMore, e.loading],
1454
- async ([y]) => {
1455
- y || (W = -1), await C(), d();
2139
+ async ([E]) => {
2140
+ E || (G = -1), await Z(), P();
1456
2141
  }
1457
- ), Ae(() => {
1458
- G(), typeof ResizeObserver < "u" && w.value && (F = new ResizeObserver(G), F.observe(w.value)), C(d);
1459
- }), Ce(() => {
1460
- F && (F.disconnect(), F = void 0);
1461
- }), P({
1462
- scrollTo: z,
1463
- scrollToIndex: Q,
1464
- scrollToTop: he
1465
- }), (y, L) => (I(), $("div", {
2142
+ ), at(() => {
2143
+ O(), typeof ResizeObserver < "u" && C.value && (V = new ResizeObserver(O), V.observe(C.value)), Z(P);
2144
+ }), Xe(() => {
2145
+ V && (V.disconnect(), V = void 0);
2146
+ }), s({
2147
+ scrollTo: oe,
2148
+ scrollToIndex: me,
2149
+ scrollToTop: Ae
2150
+ }), (E, F) => (j(), U("div", {
1466
2151
  ref_key: "viewport",
1467
- ref: w,
1468
- class: Ye(["vue-virtual-scroll", { "vue-virtual-scroll--pulling": c(f) }]),
1469
- style: N(ue.value),
2152
+ ref: C,
2153
+ class: st(["vue-virtual-scroll", { "vue-virtual-scroll--pulling": f(x) }]),
2154
+ style: re(ve.value),
1470
2155
  role: "list",
1471
- "aria-label": l.ariaLabel,
2156
+ "aria-label": t.ariaLabel,
1472
2157
  tabindex: "0",
1473
- onScrollPassive: u,
1474
- onTouchstartPassive: L[0] || (L[0] = //@ts-ignore
1475
- (...B) => c(U) && c(U)(...B)),
1476
- onTouchmove: L[1] || (L[1] = //@ts-ignore
1477
- (...B) => c(q) && c(q)(...B)),
1478
- onTouchend: L[2] || (L[2] = //@ts-ignore
1479
- (...B) => c(V) && c(V)(...B)),
1480
- onTouchcancel: L[3] || (L[3] = //@ts-ignore
1481
- (...B) => c(D) && c(D)(...B))
2158
+ onScrollPassive: S,
2159
+ onTouchstartPassive: F[0] || (F[0] = //@ts-ignore
2160
+ (..._) => f(R) && f(R)(..._)),
2161
+ onTouchmove: F[1] || (F[1] = //@ts-ignore
2162
+ (..._) => f(D) && f(D)(..._)),
2163
+ onTouchend: F[2] || (F[2] = //@ts-ignore
2164
+ (..._) => f(b) && f(b)(..._)),
2165
+ onTouchcancel: F[3] || (F[3] = //@ts-ignore
2166
+ (..._) => f(A) && f(A)(..._))
1482
2167
  }, [
1483
- l.pullToRefresh || l.refreshing ? (I(), $("div", {
2168
+ t.pullToRefresh || t.refreshing ? (j(), U("div", {
1484
2169
  key: 0,
1485
2170
  class: "vue-virtual-scroll__refresh",
1486
- style: N({
1487
- height: `${c(O)}px`,
1488
- transform: `translateY(${c(o) - c(O)}px)`
2171
+ style: re({
2172
+ height: `${f(M)}px`,
2173
+ transform: `translateY(${f(r) - f(M)}px)`
1489
2174
  }),
1490
2175
  role: "status",
1491
2176
  "aria-live": "polite"
1492
2177
  }, [
1493
- ce(y.$slots, "refresh", {
1494
- pullDistance: c(r),
1495
- progress: c(m),
1496
- refreshing: l.refreshing
2178
+ Se(E.$slots, "refresh", {
2179
+ pullDistance: f(y),
2180
+ progress: f(u),
2181
+ refreshing: t.refreshing
1497
2182
  }, () => [
1498
- Ve(je(c(A)), 1)
2183
+ Ge(ht(f(n)), 1)
1499
2184
  ])
1500
- ], 4)) : ze("", !0),
1501
- l.items.length || l.loading ? (I(), $("div", {
2185
+ ], 4)) : Re("", !0),
2186
+ t.items.length || t.loading ? (j(), U("div", {
1502
2187
  key: 1,
1503
2188
  class: "vue-virtual-scroll__spacer",
1504
- style: N({
1505
- height: `${Y.value}px`,
1506
- transform: `translateY(${c(o)}px)`
2189
+ style: re({
2190
+ height: `${ie.value}px`,
2191
+ transform: `translateY(${f(r)}px)`
1507
2192
  })
1508
2193
  }, [
1509
- Ge("div", {
2194
+ rt("div", {
1510
2195
  class: "vue-virtual-scroll__content",
1511
- style: N(we.value)
2196
+ style: re(J.value)
1512
2197
  }, [
1513
- (I(!0), $(Re, null, De(de.value, ({ item: B, index: te }) => (I(), $("div", {
1514
- key: c(Z)(B, te),
2198
+ (j(!0), U(et, null, nt(he.value, ({ item: _, index: pe }) => (j(), U("div", {
2199
+ key: f(se)(_, pe),
1515
2200
  class: "vue-virtual-scroll__item",
1516
- style: N({ height: `${H.value}px` }),
2201
+ style: re({ height: `${H.value}px` }),
1517
2202
  role: "listitem",
1518
- "aria-posinset": te + 1,
1519
- "aria-setsize": l.items.length
2203
+ "aria-posinset": pe + 1,
2204
+ "aria-setsize": t.items.length
1520
2205
  }, [
1521
- ce(y.$slots, "default", {
1522
- item: B,
1523
- index: te
2206
+ Se(E.$slots, "default", {
2207
+ item: _,
2208
+ index: pe
1524
2209
  })
1525
- ], 12, It))), 128))
2210
+ ], 12, Ma))), 128))
1526
2211
  ], 4),
1527
- l.loading ? (I(), $("div", {
2212
+ t.loading ? (j(), U("div", {
1528
2213
  key: 0,
1529
2214
  class: "vue-virtual-scroll__loading",
1530
- style: N({
1531
- height: `${J.value}px`,
1532
- transform: `translateY(${R.value}px)`
2215
+ style: re({
2216
+ height: `${le.value}px`,
2217
+ transform: `translateY(${ne.value}px)`
1533
2218
  }),
1534
2219
  role: "status",
1535
2220
  "aria-live": "polite"
1536
2221
  }, [
1537
- ce(y.$slots, "loading", {}, () => [
1538
- L[4] || (L[4] = Ve("Loading more…", -1))
2222
+ Se(E.$slots, "loading", {}, () => [
2223
+ F[4] || (F[4] = Ge("Loading more…", -1))
1539
2224
  ])
1540
- ], 4)) : ze("", !0)
1541
- ], 4)) : (I(), $("div", {
2225
+ ], 4)) : Re("", !0)
2226
+ ], 4)) : (j(), U("div", {
1542
2227
  key: 2,
1543
2228
  class: "vue-virtual-scroll__empty",
1544
- style: N({ transform: `translateY(${c(o)}px)` })
2229
+ style: re({ transform: `translateY(${f(r)}px)` })
1545
2230
  }, [
1546
- ce(y.$slots, "empty")
2231
+ Se(E.$slots, "empty")
1547
2232
  ], 4))
1548
- ], 46, zt));
2233
+ ], 46, wa));
1549
2234
  }
1550
- }), kt = ["aria-label"], Et = ["aria-posinset", "aria-setsize"], Lt = /* @__PURE__ */ Oe({
2235
+ }), Ta = ["aria-label"], ba = ["aria-posinset", "aria-setsize"], Sa = /* @__PURE__ */ tt({
1551
2236
  name: "WindowDynamicVirtualScroll",
1552
2237
  __name: "WindowDynamicVirtualScroll",
1553
2238
  props: {
@@ -1565,329 +2250,329 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
1565
2250
  pullRefreshThreshold: { default: 64 }
1566
2251
  },
1567
2252
  emits: ["scroll", "loadMore", "refresh"],
1568
- setup(l, { expose: P, emit: x }) {
1569
- const e = l, p = x, f = j(), r = j(0), o = j(0), m = j(0), A = j(0), O = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map();
1570
- let V, D, w, k, E = !1, F = !1, W = -1;
1571
- const { getItemKey: ne } = Pe({
2253
+ setup(t, { expose: s, emit: I }) {
2254
+ const e = t, z = I, x = X(), y = X(0), r = X(0), u = X(0), n = X(0), M = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map();
2255
+ let b, A, C, $, B = !1, V = !1, G = -1;
2256
+ const { getItemKey: Y } = lt({
1572
2257
  componentName: "WindowDynamicVirtualScroll",
1573
2258
  items: () => e.items,
1574
2259
  itemKey: () => e.itemKey
1575
2260
  });
1576
- function Z(v) {
2261
+ function se(m) {
1577
2262
  return typeof window.requestAnimationFrame == "function" ? {
1578
- id: window.requestAnimationFrame(v),
2263
+ id: window.requestAnimationFrame(m),
1579
2264
  type: "animation"
1580
2265
  } : {
1581
- id: window.setTimeout(v, 0),
2266
+ id: window.setTimeout(m, 0),
1582
2267
  type: "timeout"
1583
2268
  };
1584
2269
  }
1585
- function H(v) {
1586
- v && (v.type === "animation" ? window.cancelAnimationFrame(v.id) : window.clearTimeout(v.id));
2270
+ function H(m) {
2271
+ m && (m.type === "animation" ? window.cancelAnimationFrame(m.id) : window.clearTimeout(m.id));
1587
2272
  }
1588
2273
  const {
1589
2274
  pulling: ae,
1590
- pullDistance: R,
1591
- pullOffset: J,
1592
- pullProgress: Y,
1593
- refreshMessage: le,
1594
- refreshThreshold: se,
1595
- handleTouchStart: me,
1596
- handleTouchMove: de,
1597
- handleTouchEnd: ue,
1598
- handleTouchCancel: we
1599
- } = qe({
2275
+ pullDistance: ne,
2276
+ pullOffset: le,
2277
+ pullProgress: ie,
2278
+ refreshMessage: te,
2279
+ refreshThreshold: ue,
2280
+ handleTouchStart: fe,
2281
+ handleTouchMove: he,
2282
+ handleTouchEnd: ve,
2283
+ handleTouchCancel: J
2284
+ } = xt({
1600
2285
  enabled: () => e.pullToRefresh,
1601
2286
  refreshing: () => e.refreshing,
1602
2287
  threshold: () => e.pullRefreshThreshold,
1603
- onRefresh: () => p("refresh"),
2288
+ onRefresh: () => z("refresh"),
1604
2289
  scrollTop: () => typeof window > "u" ? 0 : Math.max(0, window.scrollY)
1605
- }), G = n(
2290
+ }), O = h(
1606
2291
  () => Math.max(1, e.estimatedItemSize)
1607
- ), u = n(
1608
- () => Math.max(1, e.loadingItemSize ?? G.value)
1609
- ), d = n(() => Math.max(0, Math.floor(e.overscan))), z = n(() => {
1610
- A.value;
1611
- const v = new Array(e.items.length + 1), S = new Array(e.items.length);
1612
- v[0] = 0;
1613
- for (let T = 0; T < e.items.length; T += 1) {
1614
- const fe = ne(e.items[T], T), X = O.get(fe) ?? G.value;
1615
- S[T] = X, v[T + 1] = v[T] + X;
2292
+ ), S = h(
2293
+ () => Math.max(1, e.loadingItemSize ?? O.value)
2294
+ ), P = h(() => Math.max(0, Math.floor(e.overscan))), oe = h(() => {
2295
+ n.value;
2296
+ const m = new Array(e.items.length + 1), w = new Array(e.items.length);
2297
+ m[0] = 0;
2298
+ for (let k = 0; k < e.items.length; k += 1) {
2299
+ const ee = Y(e.items[k], k), L = M.get(ee) ?? O.value;
2300
+ w[k] = L, m[k + 1] = m[k] + L;
1616
2301
  }
1617
2302
  return {
1618
- offsets: v,
1619
- sizes: S,
1620
- total: v[e.items.length] ?? 0
2303
+ offsets: m,
2304
+ sizes: w,
2305
+ total: m[e.items.length] ?? 0
1621
2306
  };
1622
- }), Q = n(
1623
- () => z.value.total + (e.loading ? u.value : 0)
1624
- ), he = n(() => {
1625
- const v = /* @__PURE__ */ new Map();
1626
- return e.items.forEach((S, T) => {
1627
- v.set(ne(S, T), T);
1628
- }), v;
1629
- }), y = n(
1630
- () => Math.max(0, r.value - m.value)
2307
+ }), me = h(
2308
+ () => oe.value.total + (e.loading ? S.value : 0)
2309
+ ), Ae = h(() => {
2310
+ const m = /* @__PURE__ */ new Map();
2311
+ return e.items.forEach((w, k) => {
2312
+ m.set(Y(w, k), k);
2313
+ }), m;
2314
+ }), E = h(
2315
+ () => Math.max(0, y.value - u.value)
1631
2316
  );
1632
- function L(v) {
2317
+ function F(m) {
1633
2318
  if (e.items.length === 0) return 0;
1634
- const S = z.value.offsets;
1635
- let T = 0, fe = e.items.length;
1636
- for (; T < fe; ) {
1637
- const X = Math.floor((T + fe) / 2);
1638
- S[X + 1] <= v ? T = X + 1 : fe = X;
2319
+ const w = oe.value.offsets;
2320
+ let k = 0, ee = e.items.length;
2321
+ for (; k < ee; ) {
2322
+ const L = Math.floor((k + ee) / 2);
2323
+ w[L + 1] <= m ? k = L + 1 : ee = L;
1639
2324
  }
1640
- return Math.min(T, e.items.length - 1);
2325
+ return Math.min(k, e.items.length - 1);
1641
2326
  }
1642
- const B = n(
2327
+ const _ = h(
1643
2328
  () => Math.max(
1644
2329
  0,
1645
- L(y.value) - d.value
2330
+ F(E.value) - P.value
1646
2331
  )
1647
- ), te = n(() => {
2332
+ ), pe = h(() => {
1648
2333
  if (e.items.length === 0) return 0;
1649
- const v = r.value + o.value - m.value, S = Math.max(
1650
- G.value,
1651
- v
1652
- ), T = L(S) + 1;
2334
+ const m = y.value + r.value - u.value, w = Math.max(
2335
+ O.value,
2336
+ m
2337
+ ), k = F(w) + 1;
1653
2338
  return Math.min(
1654
2339
  e.items.length,
1655
- T + d.value
2340
+ k + P.value
1656
2341
  );
1657
- }), oe = n(
1658
- () => e.items.slice(B.value, te.value).map((v, S) => {
1659
- const T = B.value + S;
2342
+ }), ze = h(
2343
+ () => e.items.slice(_.value, pe.value).map((m, w) => {
2344
+ const k = _.value + w;
1660
2345
  return {
1661
- item: v,
1662
- index: T,
1663
- key: ne(v, T),
1664
- top: z.value.offsets[T]
2346
+ item: m,
2347
+ index: k,
2348
+ key: Y(m, k),
2349
+ top: oe.value.offsets[k]
1665
2350
  };
1666
2351
  })
1667
2352
  );
1668
- function re() {
1669
- typeof window > "u" || (r.value = Math.max(0, window.scrollY), o.value = window.innerHeight, f.value && (m.value = f.value.getBoundingClientRect().top + r.value));
2353
+ function be() {
2354
+ typeof window > "u" || (y.value = Math.max(0, window.scrollY), r.value = window.innerHeight, x.value && (u.value = x.value.getBoundingClientRect().top + y.value));
1670
2355
  }
1671
- function ye() {
1672
- p("scroll", {
1673
- scrollTop: y.value,
1674
- startIndex: B.value,
1675
- endIndex: te.value
2356
+ function Me() {
2357
+ z("scroll", {
2358
+ scrollTop: E.value,
2359
+ startIndex: _.value,
2360
+ endIndex: pe.value
1676
2361
  });
1677
2362
  }
1678
- function _(v = !1) {
1679
- F && (E || (E = v), !w && (w = Z(() => {
1680
- w = void 0, re(), E && (E = !1, ye()), t();
2363
+ function ce(m = !1) {
2364
+ V && (B || (B = m), !C && (C = se(() => {
2365
+ C = void 0, be(), B && (B = !1, Me()), T();
1681
2366
  })));
1682
2367
  }
1683
- function ee() {
1684
- _(!0);
2368
+ function de() {
2369
+ ce(!0);
1685
2370
  }
1686
- function s() {
1687
- _();
2371
+ function v() {
2372
+ ce();
1688
2373
  }
1689
- function t() {
1690
- if (typeof window > "u" || !e.hasMore || e.loading || W === e.items.length)
2374
+ function T() {
2375
+ if (typeof window > "u" || !e.hasMore || e.loading || G === e.items.length)
1691
2376
  return;
1692
- const v = Math.max(0, e.loadMoreThreshold), S = m.value + Q.value, T = r.value + o.value;
1693
- S - T <= v && (W = e.items.length, p("loadMore"));
1694
- }
1695
- function a(v) {
1696
- const S = v.borderBoxSize;
1697
- if (S) {
1698
- const T = Array.isArray(S) ? S[0] : S;
1699
- if (T != null && T.blockSize) return T.blockSize;
2377
+ const m = Math.max(0, e.loadMoreThreshold), w = u.value + me.value, k = y.value + r.value;
2378
+ w - k <= m && (G = e.items.length, z("loadMore"));
2379
+ }
2380
+ function i(m) {
2381
+ const w = m.borderBoxSize;
2382
+ if (w) {
2383
+ const k = Array.isArray(w) ? w[0] : w;
2384
+ if (k != null && k.blockSize) return k.blockSize;
1700
2385
  }
1701
- return v.contentRect.height;
1702
- }
1703
- function g(v) {
1704
- const S = z.value;
1705
- let T = 0, fe = !1;
1706
- for (const X of v) {
1707
- const be = X.target, Ie = U.get(be), Be = a(X);
1708
- if (Ie === void 0 || Be <= 0) continue;
1709
- const Ke = O.get(Ie) ?? G.value;
1710
- if (Math.abs(Ke - Be) < 0.5) continue;
1711
- const He = he.value.get(Ie);
1712
- He !== void 0 && S.offsets[He + 1] <= y.value && (T += Be - Ke), O.set(Ie, Be), fe = !0;
2386
+ return m.contentRect.height;
2387
+ }
2388
+ function q(m) {
2389
+ const w = oe.value;
2390
+ let k = 0, ee = !1;
2391
+ for (const L of m) {
2392
+ const xe = L.target, we = R.get(xe), $e = i(L);
2393
+ if (we === void 0 || $e <= 0) continue;
2394
+ const De = M.get(we) ?? O.value;
2395
+ if (Math.abs(De - $e) < 0.5) continue;
2396
+ const Ie = Ae.value.get(we);
2397
+ Ie !== void 0 && w.offsets[Ie + 1] <= E.value && (k += $e - De), M.set(we, $e), ee = !0;
1713
2398
  }
1714
- fe && (A.value += 1, C(() => {
1715
- if (F) {
1716
- if (T !== 0 && typeof window < "u") {
1717
- const X = Math.max(
2399
+ ee && (n.value += 1, Z(() => {
2400
+ if (V) {
2401
+ if (k !== 0 && typeof window < "u") {
2402
+ const L = Math.max(
1718
2403
  0,
1719
- r.value + T
2404
+ y.value + k
1720
2405
  );
1721
- r.value = X, window.scrollTo({ top: X, behavior: "auto" });
2406
+ y.value = L, window.scrollTo({ top: L, behavior: "auto" });
1722
2407
  }
1723
- re(), t();
2408
+ be(), T();
1724
2409
  }
1725
2410
  }));
1726
2411
  }
1727
- function b(v) {
1728
- if (F) {
1729
- for (const S of v)
1730
- q.set(S.target, S);
1731
- k || (k = Z(() => {
1732
- k = void 0;
1733
- const S = Array.from(q.values());
1734
- q.clear(), g(S);
2412
+ function Q(m) {
2413
+ if (V) {
2414
+ for (const w of m)
2415
+ D.set(w.target, w);
2416
+ $ || ($ = se(() => {
2417
+ $ = void 0;
2418
+ const w = Array.from(D.values());
2419
+ D.clear(), q(w);
1735
2420
  }));
1736
2421
  }
1737
2422
  }
1738
- function Me(v, S) {
1739
- v instanceof HTMLElement && (U.set(v, S), D == null || D.observe(v));
2423
+ function ke(m, w) {
2424
+ m instanceof HTMLElement && (R.set(m, w), A == null || A.observe(m));
1740
2425
  }
1741
2426
  function ge() {
1742
- for (const [v] of U)
1743
- v.isConnected || (D == null || D.unobserve(v), U.delete(v));
2427
+ for (const [m] of R)
2428
+ m.isConnected || (A == null || A.unobserve(m), R.delete(m));
1744
2429
  }
1745
- function ve(v, S = {}) {
2430
+ function Ee(m, w = {}) {
1746
2431
  if (typeof window > "u") return;
1747
- re();
1748
- const T = Math.max(0, Q.value - o.value), fe = Math.min(
1749
- Math.max(0, Number.isFinite(v) ? v : 0),
1750
- T
1751
- ), X = Math.max(0, m.value + fe), be = S.behavior ?? "auto";
1752
- be === "auto" && (r.value = X), window.scrollTo({ ...S, top: X, behavior: be });
1753
- }
1754
- function Le(v, S = {}) {
2432
+ be();
2433
+ const k = Math.max(0, me.value - r.value), ee = Math.min(
2434
+ Math.max(0, Number.isFinite(m) ? m : 0),
2435
+ k
2436
+ ), L = Math.max(0, u.value + ee), xe = w.behavior ?? "auto";
2437
+ xe === "auto" && (y.value = L), window.scrollTo({ ...w, top: L, behavior: xe });
2438
+ }
2439
+ function d(m, w = {}) {
1755
2440
  if (typeof window > "u" || e.items.length === 0) return;
1756
- re();
1757
- const T = Math.min(
2441
+ be();
2442
+ const k = Math.min(
1758
2443
  e.items.length - 1,
1759
- Math.max(0, Math.floor(v))
1760
- ), { align: fe = "start", ...X } = S, be = z.value.sizes[T];
1761
- let Ie = m.value + z.value.offsets[T];
1762
- fe === "center" ? Ie -= (o.value - be) / 2 : fe === "end" && (Ie -= o.value - be);
1763
- const Be = Math.max(
1764
- m.value,
1765
- m.value + Q.value - o.value
1766
- ), Ke = Math.max(0, Math.min(Ie, Be)), He = X.behavior ?? "auto";
1767
- He === "auto" && (r.value = Ke), window.scrollTo({
1768
- ...X,
1769
- top: Ke,
1770
- behavior: He
2444
+ Math.max(0, Math.floor(m))
2445
+ ), { align: ee = "start", ...L } = w, xe = oe.value.sizes[k];
2446
+ let we = u.value + oe.value.offsets[k];
2447
+ ee === "center" ? we -= (r.value - xe) / 2 : ee === "end" && (we -= r.value - xe);
2448
+ const $e = Math.max(
2449
+ u.value,
2450
+ u.value + me.value - r.value
2451
+ ), De = Math.max(0, Math.min(we, $e)), Ie = L.behavior ?? "auto";
2452
+ Ie === "auto" && (y.value = De), window.scrollTo({
2453
+ ...L,
2454
+ top: De,
2455
+ behavior: Ie
1771
2456
  });
1772
2457
  }
1773
- function ke(v = "auto") {
1774
- typeof window > "u" || (re(), window.scrollTo({ top: Math.max(0, m.value), behavior: v }));
2458
+ function K(m = "auto") {
2459
+ typeof window > "u" || (be(), window.scrollTo({ top: Math.max(0, u.value), behavior: m }));
1775
2460
  }
1776
- return ie(
2461
+ return ye(
1777
2462
  () => e.itemKey,
1778
2463
  () => {
1779
- O.clear(), A.value += 1, W = -1;
2464
+ M.clear(), n.value += 1, G = -1;
1780
2465
  }
1781
- ), ie(
1782
- () => e.items.map((v, S) => ne(v, S)),
1783
- async (v, S) => {
1784
- const T = v.length !== S.length || v.some((X, be) => X !== S[be]), fe = new Set(v);
1785
- for (const X of O.keys())
1786
- fe.has(X) || O.delete(X);
1787
- T && (W = -1), A.value += 1, await C(), F && (re(), t());
2466
+ ), ye(
2467
+ () => e.items.map((m, w) => Y(m, w)),
2468
+ async (m, w) => {
2469
+ const k = m.length !== w.length || m.some((L, xe) => L !== w[xe]), ee = new Set(m);
2470
+ for (const L of M.keys())
2471
+ ee.has(L) || M.delete(L);
2472
+ k && (G = -1), n.value += 1, await Z(), V && (be(), T());
1788
2473
  }
1789
- ), ie(
2474
+ ), ye(
1790
2475
  () => [e.hasMore, e.loading],
1791
- async ([v]) => {
1792
- v || (W = -1), await C(), F && (re(), t());
2476
+ async ([m]) => {
2477
+ m || (G = -1), await Z(), V && (be(), T());
1793
2478
  }
1794
- ), Ae(() => {
1795
- if (F = !0, re(), window.addEventListener("scroll", ee, { passive: !0 }), window.addEventListener("resize", s, { passive: !0 }), typeof ResizeObserver < "u") {
1796
- V = new ResizeObserver(() => {
1797
- _();
1798
- }), D = new ResizeObserver(b), f.value && V.observe(f.value);
1799
- for (const [v] of U)
1800
- D.observe(v);
2479
+ ), at(() => {
2480
+ if (V = !0, be(), window.addEventListener("scroll", de, { passive: !0 }), window.addEventListener("resize", v, { passive: !0 }), typeof ResizeObserver < "u") {
2481
+ b = new ResizeObserver(() => {
2482
+ ce();
2483
+ }), A = new ResizeObserver(Q), x.value && b.observe(x.value);
2484
+ for (const [m] of R)
2485
+ A.observe(m);
1801
2486
  }
1802
- C(() => {
1803
- F && t();
2487
+ Z(() => {
2488
+ V && T();
1804
2489
  });
1805
- }), Xe(ge), Ce(() => {
1806
- F = !1, window.removeEventListener("scroll", ee), window.removeEventListener("resize", s), H(w), H(k), w = void 0, k = void 0, E = !1, q.clear(), V && (V.disconnect(), V = void 0), D && (D.disconnect(), D = void 0), U.clear();
1807
- }), P({
1808
- scrollTo: ve,
1809
- scrollToIndex: Le,
1810
- scrollToTop: ke
1811
- }), (v, S) => (I(), $("div", {
2490
+ }), $t(ge), Xe(() => {
2491
+ V = !1, window.removeEventListener("scroll", de), window.removeEventListener("resize", v), H(C), H($), C = void 0, $ = void 0, B = !1, D.clear(), b && (b.disconnect(), b = void 0), A && (A.disconnect(), A = void 0), R.clear();
2492
+ }), s({
2493
+ scrollTo: Ee,
2494
+ scrollToIndex: d,
2495
+ scrollToTop: K
2496
+ }), (m, w) => (j(), U("div", {
1812
2497
  ref_key: "root",
1813
- ref: f,
1814
- class: Ye(["vue-window-dynamic-virtual-scroll", { "vue-window-dynamic-virtual-scroll--pulling": c(ae) }]),
2498
+ ref: x,
2499
+ class: st(["vue-window-dynamic-virtual-scroll", { "vue-window-dynamic-virtual-scroll--pulling": f(ae) }]),
1815
2500
  role: "list",
1816
- "aria-label": l.ariaLabel,
1817
- onTouchstartPassive: S[0] || (S[0] = //@ts-ignore
1818
- (...T) => c(me) && c(me)(...T)),
1819
- onTouchmove: S[1] || (S[1] = //@ts-ignore
1820
- (...T) => c(de) && c(de)(...T)),
1821
- onTouchend: S[2] || (S[2] = //@ts-ignore
1822
- (...T) => c(ue) && c(ue)(...T)),
1823
- onTouchcancel: S[3] || (S[3] = //@ts-ignore
1824
- (...T) => c(we) && c(we)(...T))
2501
+ "aria-label": t.ariaLabel,
2502
+ onTouchstartPassive: w[0] || (w[0] = //@ts-ignore
2503
+ (...k) => f(fe) && f(fe)(...k)),
2504
+ onTouchmove: w[1] || (w[1] = //@ts-ignore
2505
+ (...k) => f(he) && f(he)(...k)),
2506
+ onTouchend: w[2] || (w[2] = //@ts-ignore
2507
+ (...k) => f(ve) && f(ve)(...k)),
2508
+ onTouchcancel: w[3] || (w[3] = //@ts-ignore
2509
+ (...k) => f(J) && f(J)(...k))
1825
2510
  }, [
1826
- l.pullToRefresh || l.refreshing ? (I(), $("div", {
2511
+ t.pullToRefresh || t.refreshing ? (j(), U("div", {
1827
2512
  key: 0,
1828
2513
  class: "vue-window-dynamic-virtual-scroll__refresh",
1829
- style: N({
1830
- height: `${c(se)}px`,
1831
- transform: `translateY(${c(J) - c(se)}px)`
2514
+ style: re({
2515
+ height: `${f(ue)}px`,
2516
+ transform: `translateY(${f(le) - f(ue)}px)`
1832
2517
  }),
1833
2518
  role: "status",
1834
2519
  "aria-live": "polite"
1835
2520
  }, [
1836
- ce(v.$slots, "refresh", {
1837
- pullDistance: c(R),
1838
- progress: c(Y),
1839
- refreshing: l.refreshing
2521
+ Se(m.$slots, "refresh", {
2522
+ pullDistance: f(ne),
2523
+ progress: f(ie),
2524
+ refreshing: t.refreshing
1840
2525
  }, () => [
1841
- Ve(je(c(le)), 1)
2526
+ Ge(ht(f(te)), 1)
1842
2527
  ])
1843
- ], 4)) : ze("", !0),
1844
- l.items.length || l.loading ? (I(), $("div", {
2528
+ ], 4)) : Re("", !0),
2529
+ t.items.length || t.loading ? (j(), U("div", {
1845
2530
  key: 1,
1846
2531
  class: "vue-window-dynamic-virtual-scroll__spacer",
1847
- style: N({
1848
- height: `${Q.value}px`,
1849
- transform: `translateY(${c(J)}px)`
2532
+ style: re({
2533
+ height: `${me.value}px`,
2534
+ transform: `translateY(${f(le)}px)`
1850
2535
  })
1851
2536
  }, [
1852
- (I(!0), $(Re, null, De(oe.value, ({ item: T, index: fe, key: X, top: be }) => (I(), $("div", {
1853
- key: X,
2537
+ (j(!0), U(et, null, nt(ze.value, ({ item: k, index: ee, key: L, top: xe }) => (j(), U("div", {
2538
+ key: L,
1854
2539
  ref_for: !0,
1855
- ref: (Ie) => Me(Ie, X),
2540
+ ref: (we) => ke(we, L),
1856
2541
  class: "vue-window-dynamic-virtual-scroll__item",
1857
- style: N({ transform: `translateY(${be}px)` }),
2542
+ style: re({ transform: `translateY(${xe}px)` }),
1858
2543
  role: "listitem",
1859
- "aria-posinset": fe + 1,
1860
- "aria-setsize": l.items.length
2544
+ "aria-posinset": ee + 1,
2545
+ "aria-setsize": t.items.length
1861
2546
  }, [
1862
- ce(v.$slots, "default", {
1863
- item: T,
1864
- index: fe
2547
+ Se(m.$slots, "default", {
2548
+ item: k,
2549
+ index: ee
1865
2550
  })
1866
- ], 12, Et))), 128)),
1867
- l.loading ? (I(), $("div", {
2551
+ ], 12, ba))), 128)),
2552
+ t.loading ? (j(), U("div", {
1868
2553
  key: 0,
1869
2554
  class: "vue-window-dynamic-virtual-scroll__loading",
1870
- style: N({
1871
- height: `${u.value}px`,
1872
- transform: `translateY(${z.value.total}px)`
2555
+ style: re({
2556
+ height: `${S.value}px`,
2557
+ transform: `translateY(${oe.value.total}px)`
1873
2558
  }),
1874
2559
  role: "status",
1875
2560
  "aria-live": "polite"
1876
2561
  }, [
1877
- ce(v.$slots, "loading", {}, () => [
1878
- S[4] || (S[4] = Ve("Loading more…", -1))
2562
+ Se(m.$slots, "loading", {}, () => [
2563
+ w[4] || (w[4] = Ge("Loading more…", -1))
1879
2564
  ])
1880
- ], 4)) : ze("", !0)
1881
- ], 4)) : (I(), $("div", {
2565
+ ], 4)) : Re("", !0)
2566
+ ], 4)) : (j(), U("div", {
1882
2567
  key: 2,
1883
2568
  class: "vue-window-dynamic-virtual-scroll__empty",
1884
- style: N({ transform: `translateY(${c(J)}px)` })
2569
+ style: re({ transform: `translateY(${f(le)}px)` })
1885
2570
  }, [
1886
- ce(v.$slots, "empty")
2571
+ Se(m.$slots, "empty")
1887
2572
  ], 4))
1888
- ], 42, kt));
2573
+ ], 42, Ta));
1889
2574
  }
1890
- }), Bt = ["aria-label"], Vt = ["aria-posinset", "aria-setsize"], Ht = /* @__PURE__ */ Oe({
2575
+ }), Ia = ["aria-label"], za = ["aria-posinset", "aria-setsize"], ka = /* @__PURE__ */ tt({
1891
2576
  name: "WindowGirdVirtualScroll",
1892
2577
  __name: "WindowGirdVirtualScroll",
1893
2578
  props: {
@@ -1907,133 +2592,133 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
1907
2592
  pullRefreshThreshold: { default: 64 }
1908
2593
  },
1909
2594
  emits: ["scroll", "loadMore", "refresh"],
1910
- setup(l, { expose: P, emit: x }) {
1911
- const e = l, p = x, f = j(), r = j(0), o = j(0), m = j(0);
1912
- let A, O = -1;
1913
- const { getItemKey: U } = Pe({
2595
+ setup(t, { expose: s, emit: I }) {
2596
+ const e = t, z = I, x = X(), y = X(0), r = X(0), u = X(0);
2597
+ let n, M = -1;
2598
+ const { getItemKey: R } = lt({
1914
2599
  componentName: "WindowGirdVirtualScroll",
1915
2600
  items: () => e.items,
1916
2601
  itemKey: () => e.itemKey
1917
2602
  }), {
1918
- pulling: q,
1919
- pullDistance: V,
1920
- pullOffset: D,
1921
- pullProgress: w,
1922
- refreshMessage: k,
1923
- refreshThreshold: E,
1924
- handleTouchStart: F,
1925
- handleTouchMove: W,
1926
- handleTouchEnd: ne,
1927
- handleTouchCancel: Z
1928
- } = qe({
2603
+ pulling: D,
2604
+ pullDistance: b,
2605
+ pullOffset: A,
2606
+ pullProgress: C,
2607
+ refreshMessage: $,
2608
+ refreshThreshold: B,
2609
+ handleTouchStart: V,
2610
+ handleTouchMove: G,
2611
+ handleTouchEnd: Y,
2612
+ handleTouchCancel: se
2613
+ } = xt({
1929
2614
  enabled: () => e.pullToRefresh,
1930
2615
  refreshing: () => e.refreshing,
1931
2616
  threshold: () => e.pullRefreshThreshold,
1932
- onRefresh: () => p("refresh"),
2617
+ onRefresh: () => z("refresh"),
1933
2618
  scrollTop: () => typeof window > "u" ? 0 : Math.max(0, window.scrollY)
1934
- }), H = n(() => Math.max(1, e.itemSize)), ae = n(
2619
+ }), H = h(() => Math.max(1, e.itemSize)), ae = h(
1935
2620
  () => Math.max(1, Math.floor(e.columns))
1936
- ), R = n(() => Math.max(0, e.gap)), J = n(() => Math.max(0, Math.floor(e.overscan))), Y = n(
2621
+ ), ne = h(() => Math.max(0, e.gap)), le = h(() => Math.max(0, Math.floor(e.overscan))), ie = h(
1937
2622
  () => Math.max(1, e.loadingItemSize ?? H.value)
1938
- ), le = n(
1939
- () => H.value + R.value
1940
- ), se = n(
2623
+ ), te = h(
2624
+ () => H.value + ne.value
2625
+ ), ue = h(
1941
2626
  () => Math.ceil(e.items.length / ae.value)
1942
- ), me = n(() => se.value === 0 ? 0 : se.value * H.value + (se.value - 1) * R.value), de = n(
1943
- () => me.value + (e.items.length ? R.value : 0)
1944
- ), ue = n(
1945
- () => me.value + (e.loading ? Y.value + (e.items.length ? R.value : 0) : 0)
1946
- ), we = n(
1947
- () => Math.max(0, r.value - m.value)
1948
- ), G = n(
2627
+ ), fe = h(() => ue.value === 0 ? 0 : ue.value * H.value + (ue.value - 1) * ne.value), he = h(
2628
+ () => fe.value + (e.items.length ? ne.value : 0)
2629
+ ), ve = h(
2630
+ () => fe.value + (e.loading ? ie.value + (e.items.length ? ne.value : 0) : 0)
2631
+ ), J = h(
2632
+ () => Math.max(0, y.value - u.value)
2633
+ ), O = h(
1949
2634
  () => Math.max(
1950
2635
  0,
1951
- Math.floor(we.value / le.value) - J.value
2636
+ Math.floor(J.value / te.value) - le.value
1952
2637
  )
1953
- ), u = n(() => {
1954
- if (se.value === 0) return 0;
1955
- const _ = Math.max(
2638
+ ), S = h(() => {
2639
+ if (ue.value === 0) return 0;
2640
+ const ce = Math.max(
1956
2641
  H.value,
1957
- r.value + o.value - m.value
1958
- ), ee = Math.ceil(
1959
- (_ + R.value) / le.value
2642
+ y.value + r.value - u.value
2643
+ ), de = Math.ceil(
2644
+ (ce + ne.value) / te.value
1960
2645
  );
1961
2646
  return Math.min(
1962
- se.value,
1963
- ee + J.value
2647
+ ue.value,
2648
+ de + le.value
1964
2649
  );
1965
- }), d = n(
1966
- () => Math.min(e.items.length, G.value * ae.value)
1967
- ), z = n(
1968
- () => Math.min(e.items.length, u.value * ae.value)
1969
- ), Q = n(
1970
- () => e.items.slice(d.value, z.value).map((_, ee) => {
1971
- const s = d.value + ee;
2650
+ }), P = h(
2651
+ () => Math.min(e.items.length, O.value * ae.value)
2652
+ ), oe = h(
2653
+ () => Math.min(e.items.length, S.value * ae.value)
2654
+ ), me = h(
2655
+ () => e.items.slice(P.value, oe.value).map((ce, de) => {
2656
+ const v = P.value + de;
1972
2657
  return {
1973
- item: _,
1974
- index: s,
1975
- key: U(_, s),
1976
- rowIndex: Math.floor(s / ae.value),
1977
- columnIndex: s % ae.value
2658
+ item: ce,
2659
+ index: v,
2660
+ key: R(ce, v),
2661
+ rowIndex: Math.floor(v / ae.value),
2662
+ columnIndex: v % ae.value
1978
2663
  };
1979
2664
  })
1980
- ), he = n(() => ({
2665
+ ), Ae = h(() => ({
1981
2666
  gridTemplateColumns: `repeat(${ae.value}, minmax(0, 1fr))`,
1982
- columnGap: `${R.value}px`,
1983
- rowGap: `${R.value}px`,
1984
- transform: `translateY(${G.value * le.value}px)`
2667
+ columnGap: `${ne.value}px`,
2668
+ rowGap: `${ne.value}px`,
2669
+ transform: `translateY(${O.value * te.value}px)`
1985
2670
  }));
1986
- function y() {
1987
- typeof window > "u" || (r.value = Math.max(0, window.scrollY), o.value = window.innerHeight, f.value && (m.value = f.value.getBoundingClientRect().top + r.value));
1988
- }
1989
- function L() {
1990
- p("scroll", {
1991
- scrollTop: we.value,
1992
- startIndex: d.value,
1993
- endIndex: z.value
2671
+ function E() {
2672
+ typeof window > "u" || (y.value = Math.max(0, window.scrollY), r.value = window.innerHeight, x.value && (u.value = x.value.getBoundingClientRect().top + y.value));
2673
+ }
2674
+ function F() {
2675
+ z("scroll", {
2676
+ scrollTop: J.value,
2677
+ startIndex: P.value,
2678
+ endIndex: oe.value
1994
2679
  });
1995
2680
  }
1996
- function B() {
1997
- y(), L(), te();
2681
+ function _() {
2682
+ E(), F(), pe();
1998
2683
  }
1999
- function te() {
2000
- if (typeof window > "u" || !e.hasMore || e.loading || O === e.items.length)
2684
+ function pe() {
2685
+ if (typeof window > "u" || !e.hasMore || e.loading || M === e.items.length)
2001
2686
  return;
2002
- const _ = Math.max(0, e.loadMoreThreshold), ee = m.value + ue.value, s = r.value + o.value;
2003
- ee - s <= _ && (O = e.items.length, p("loadMore"));
2687
+ const ce = Math.max(0, e.loadMoreThreshold), de = u.value + ve.value, v = y.value + r.value;
2688
+ de - v <= ce && (M = e.items.length, z("loadMore"));
2004
2689
  }
2005
- function oe(_, ee = {}) {
2690
+ function ze(ce, de = {}) {
2006
2691
  if (typeof window > "u") return;
2007
- y();
2008
- const s = Math.max(0, ue.value - o.value), t = Math.min(
2009
- Math.max(0, Number.isFinite(_) ? _ : 0),
2010
- s
2011
- ), a = Math.max(0, m.value + t), g = ee.behavior ?? "auto";
2012
- g === "auto" && (r.value = a), window.scrollTo({ ...ee, top: a, behavior: g });
2013
- }
2014
- function re(_, ee = {}) {
2692
+ E();
2693
+ const v = Math.max(0, ve.value - r.value), T = Math.min(
2694
+ Math.max(0, Number.isFinite(ce) ? ce : 0),
2695
+ v
2696
+ ), i = Math.max(0, u.value + T), q = de.behavior ?? "auto";
2697
+ q === "auto" && (y.value = i), window.scrollTo({ ...de, top: i, behavior: q });
2698
+ }
2699
+ function be(ce, de = {}) {
2015
2700
  if (typeof window > "u" || e.items.length === 0) return;
2016
- y();
2017
- const s = Math.min(
2701
+ E();
2702
+ const v = Math.min(
2018
2703
  e.items.length - 1,
2019
- Math.max(0, Math.floor(_))
2020
- ), t = Math.floor(s / ae.value), { align: a = "start", ...g } = ee;
2021
- let b = m.value + t * le.value;
2022
- a === "center" ? b -= (o.value - H.value) / 2 : a === "end" && (b -= o.value - H.value);
2023
- const Me = Math.max(
2024
- m.value,
2025
- m.value + ue.value - o.value
2026
- ), ge = Math.max(0, Math.min(b, Me)), ve = g.behavior ?? "auto";
2027
- ve === "auto" && (r.value = ge), window.scrollTo({
2028
- ...g,
2704
+ Math.max(0, Math.floor(ce))
2705
+ ), T = Math.floor(v / ae.value), { align: i = "start", ...q } = de;
2706
+ let Q = u.value + T * te.value;
2707
+ i === "center" ? Q -= (r.value - H.value) / 2 : i === "end" && (Q -= r.value - H.value);
2708
+ const ke = Math.max(
2709
+ u.value,
2710
+ u.value + ve.value - r.value
2711
+ ), ge = Math.max(0, Math.min(Q, ke)), Ee = q.behavior ?? "auto";
2712
+ Ee === "auto" && (y.value = ge), window.scrollTo({
2713
+ ...q,
2029
2714
  top: ge,
2030
- behavior: ve
2715
+ behavior: Ee
2031
2716
  });
2032
2717
  }
2033
- function ye(_ = "auto") {
2034
- typeof window > "u" || (y(), window.scrollTo({ top: Math.max(0, m.value), behavior: _ }));
2718
+ function Me(ce = "auto") {
2719
+ typeof window > "u" || (E(), window.scrollTo({ top: Math.max(0, u.value), behavior: ce }));
2035
2720
  }
2036
- return ie(
2721
+ return ye(
2037
2722
  () => [
2038
2723
  e.items.length,
2039
2724
  e.itemSize,
@@ -2041,128 +2726,128 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
2041
2726
  e.gap
2042
2727
  ],
2043
2728
  async () => {
2044
- await C(), y(), te();
2729
+ await Z(), E(), pe();
2045
2730
  }
2046
- ), ie(
2731
+ ), ye(
2047
2732
  () => [e.hasMore, e.loading],
2048
- async ([_]) => {
2049
- _ || (O = -1), await C(), y(), te();
2733
+ async ([ce]) => {
2734
+ ce || (M = -1), await Z(), E(), pe();
2050
2735
  }
2051
- ), Ae(() => {
2052
- y(), window.addEventListener("scroll", B, { passive: !0 }), window.addEventListener("resize", B, { passive: !0 }), typeof ResizeObserver < "u" && (A = new ResizeObserver(() => {
2053
- y(), te();
2054
- }), f.value && A.observe(f.value)), C(te);
2055
- }), Ce(() => {
2056
- window.removeEventListener("scroll", B), window.removeEventListener("resize", B), A && (A.disconnect(), A = void 0);
2057
- }), P({
2058
- scrollTo: oe,
2059
- scrollToIndex: re,
2060
- scrollToTop: ye
2061
- }), (_, ee) => (I(), $("div", {
2736
+ ), at(() => {
2737
+ E(), window.addEventListener("scroll", _, { passive: !0 }), window.addEventListener("resize", _, { passive: !0 }), typeof ResizeObserver < "u" && (n = new ResizeObserver(() => {
2738
+ E(), pe();
2739
+ }), x.value && n.observe(x.value)), Z(pe);
2740
+ }), Xe(() => {
2741
+ window.removeEventListener("scroll", _), window.removeEventListener("resize", _), n && (n.disconnect(), n = void 0);
2742
+ }), s({
2743
+ scrollTo: ze,
2744
+ scrollToIndex: be,
2745
+ scrollToTop: Me
2746
+ }), (ce, de) => (j(), U("div", {
2062
2747
  ref_key: "root",
2063
- ref: f,
2064
- class: Ye(["vue-window-gird-virtual-scroll", { "vue-window-gird-virtual-scroll--pulling": c(q) }]),
2748
+ ref: x,
2749
+ class: st(["vue-window-gird-virtual-scroll", { "vue-window-gird-virtual-scroll--pulling": f(D) }]),
2065
2750
  role: "list",
2066
- "aria-label": l.ariaLabel,
2067
- onTouchstartPassive: ee[0] || (ee[0] = //@ts-ignore
2068
- (...s) => c(F) && c(F)(...s)),
2069
- onTouchmove: ee[1] || (ee[1] = //@ts-ignore
2070
- (...s) => c(W) && c(W)(...s)),
2071
- onTouchend: ee[2] || (ee[2] = //@ts-ignore
2072
- (...s) => c(ne) && c(ne)(...s)),
2073
- onTouchcancel: ee[3] || (ee[3] = //@ts-ignore
2074
- (...s) => c(Z) && c(Z)(...s))
2751
+ "aria-label": t.ariaLabel,
2752
+ onTouchstartPassive: de[0] || (de[0] = //@ts-ignore
2753
+ (...v) => f(V) && f(V)(...v)),
2754
+ onTouchmove: de[1] || (de[1] = //@ts-ignore
2755
+ (...v) => f(G) && f(G)(...v)),
2756
+ onTouchend: de[2] || (de[2] = //@ts-ignore
2757
+ (...v) => f(Y) && f(Y)(...v)),
2758
+ onTouchcancel: de[3] || (de[3] = //@ts-ignore
2759
+ (...v) => f(se) && f(se)(...v))
2075
2760
  }, [
2076
- l.pullToRefresh || l.refreshing ? (I(), $("div", {
2761
+ t.pullToRefresh || t.refreshing ? (j(), U("div", {
2077
2762
  key: 0,
2078
2763
  class: "vue-window-gird-virtual-scroll__refresh",
2079
- style: N({
2080
- height: `${c(E)}px`,
2081
- transform: `translateY(${c(D) - c(E)}px)`
2764
+ style: re({
2765
+ height: `${f(B)}px`,
2766
+ transform: `translateY(${f(A) - f(B)}px)`
2082
2767
  }),
2083
2768
  role: "status",
2084
2769
  "aria-live": "polite"
2085
2770
  }, [
2086
- ce(_.$slots, "refresh", {
2087
- pullDistance: c(V),
2088
- progress: c(w),
2089
- refreshing: l.refreshing
2771
+ Se(ce.$slots, "refresh", {
2772
+ pullDistance: f(b),
2773
+ progress: f(C),
2774
+ refreshing: t.refreshing
2090
2775
  }, () => [
2091
- Ve(je(c(k)), 1)
2776
+ Ge(ht(f($)), 1)
2092
2777
  ])
2093
- ], 4)) : ze("", !0),
2094
- l.items.length || l.loading ? (I(), $("div", {
2778
+ ], 4)) : Re("", !0),
2779
+ t.items.length || t.loading ? (j(), U("div", {
2095
2780
  key: 1,
2096
2781
  class: "vue-window-gird-virtual-scroll__spacer",
2097
- style: N({
2098
- height: `${ue.value}px`,
2099
- transform: `translateY(${c(D)}px)`
2782
+ style: re({
2783
+ height: `${ve.value}px`,
2784
+ transform: `translateY(${f(A)}px)`
2100
2785
  })
2101
2786
  }, [
2102
- Ge("div", {
2787
+ rt("div", {
2103
2788
  class: "vue-window-gird-virtual-scroll__content",
2104
- style: N(he.value)
2789
+ style: re(Ae.value)
2105
2790
  }, [
2106
- (I(!0), $(Re, null, De(Q.value, ({ item: s, index: t, key: a, rowIndex: g, columnIndex: b }) => (I(), $("div", {
2107
- key: a,
2791
+ (j(!0), U(et, null, nt(me.value, ({ item: v, index: T, key: i, rowIndex: q, columnIndex: Q }) => (j(), U("div", {
2792
+ key: i,
2108
2793
  class: "vue-window-gird-virtual-scroll__item",
2109
- style: N({ height: `${H.value}px` }),
2794
+ style: re({ height: `${H.value}px` }),
2110
2795
  role: "listitem",
2111
- "aria-posinset": t + 1,
2112
- "aria-setsize": l.items.length
2796
+ "aria-posinset": T + 1,
2797
+ "aria-setsize": t.items.length
2113
2798
  }, [
2114
- ce(_.$slots, "default", {
2115
- item: s,
2116
- index: t,
2117
- rowIndex: g,
2118
- columnIndex: b
2799
+ Se(ce.$slots, "default", {
2800
+ item: v,
2801
+ index: T,
2802
+ rowIndex: q,
2803
+ columnIndex: Q
2119
2804
  })
2120
- ], 12, Vt))), 128))
2805
+ ], 12, za))), 128))
2121
2806
  ], 4),
2122
- l.loading ? (I(), $("div", {
2807
+ t.loading ? (j(), U("div", {
2123
2808
  key: 0,
2124
2809
  class: "vue-window-gird-virtual-scroll__loading",
2125
- style: N({
2126
- height: `${Y.value}px`,
2127
- transform: `translateY(${de.value}px)`
2810
+ style: re({
2811
+ height: `${ie.value}px`,
2812
+ transform: `translateY(${he.value}px)`
2128
2813
  }),
2129
2814
  role: "status",
2130
2815
  "aria-live": "polite"
2131
2816
  }, [
2132
- ce(_.$slots, "loading", {}, () => [
2133
- ee[4] || (ee[4] = Ve("Loading more…", -1))
2817
+ Se(ce.$slots, "loading", {}, () => [
2818
+ de[4] || (de[4] = Ge("Loading more…", -1))
2134
2819
  ])
2135
- ], 4)) : ze("", !0)
2136
- ], 4)) : (I(), $("div", {
2820
+ ], 4)) : Re("", !0)
2821
+ ], 4)) : (j(), U("div", {
2137
2822
  key: 2,
2138
2823
  class: "vue-window-gird-virtual-scroll__empty",
2139
- style: N({ transform: `translateY(${c(D)}px)` })
2824
+ style: re({ transform: `translateY(${f(A)}px)` })
2140
2825
  }, [
2141
- ce(_.$slots, "empty")
2826
+ Se(ce.$slots, "empty")
2142
2827
  ], 4))
2143
- ], 42, Bt));
2828
+ ], 42, Ia));
2144
2829
  }
2145
- }), Rt = et, Kt = {
2146
- install(l) {
2147
- l.component("ChatVirtualScroll", st), l.component("DynamicVirtualScroll", et), l.component("ShortMediaFeed", mt), l.component("SkeletonLoader", Mt), l.component("VirtualCarousel", St), l.component("VirtualList", Rt), l.component("VirtualScroll", $t), l.component(
2830
+ }), $a = Dt, La = {
2831
+ install(t) {
2832
+ t.component("ChatVirtualScroll", Zt), t.component("DynamicVirtualScroll", Dt), t.component("ShortMediaFeed", la), t.component("SkeletonLoader", sa), t.component("VirtualCarousel", ya), t.component("VirtualList", $a), t.component("VirtualScroll", xa), t.component(
2148
2833
  "WindowDynamicVirtualScroll",
2149
- Lt
2150
- ), l.component(
2834
+ Sa
2835
+ ), t.component(
2151
2836
  "WindowGirdVirtualScroll",
2152
- Ht
2837
+ ka
2153
2838
  );
2154
2839
  }
2155
2840
  };
2156
2841
  export {
2157
- st as ChatVirtualScroll,
2158
- et as DynamicVirtualScroll,
2159
- mt as ShortMediaFeed,
2160
- Mt as SkeletonLoader,
2161
- St as VirtualCarousel,
2162
- Rt as VirtualList,
2163
- $t as VirtualScroll,
2164
- Kt as VueVirtualScroll,
2165
- Lt as WindowDynamicVirtualScroll,
2166
- Ht as WindowGirdVirtualScroll,
2167
- Kt as default
2842
+ Zt as ChatVirtualScroll,
2843
+ Dt as DynamicVirtualScroll,
2844
+ la as ShortMediaFeed,
2845
+ sa as SkeletonLoader,
2846
+ ya as VirtualCarousel,
2847
+ $a as VirtualList,
2848
+ xa as VirtualScroll,
2849
+ La as VueVirtualScroll,
2850
+ Sa as WindowDynamicVirtualScroll,
2851
+ ka as WindowGirdVirtualScroll,
2852
+ La as default
2168
2853
  };