vue-virtual-flow 0.0.8 → 0.1.0

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