vue-virtual-flow 0.0.1 → 0.0.2

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.
@@ -1,51 +1,51 @@
1
- import { watch as ae, defineComponent as ge, ref as A, computed as i, nextTick as $, onMounted as pe, onUpdated as ze, onBeforeUnmount as ye, openBlock as w, createElementBlock as b, normalizeStyle as C, createElementVNode as Be, renderSlot as X, createTextVNode as me, createCommentVNode as he, Fragment as ve, renderList as Me, unref as m, normalizeClass as $e, toDisplayString as ke } from "vue";
2
- function Ve(n) {
1
+ import { watch as Z, defineComponent as ge, ref as P, computed as i, nextTick as k, onMounted as pe, onUpdated as ze, onBeforeUnmount as ye, openBlock as b, createElementBlock as S, normalizeStyle as A, createElementVNode as Be, renderSlot as le, createTextVNode as ve, createCommentVNode as he, Fragment as me, renderList as Me, unref as f, normalizeClass as $e, toDisplayString as ke } from "vue";
2
+ function Ee(n) {
3
3
  return typeof n == "string" || typeof n == "number" || typeof n == "symbol";
4
4
  }
5
- function Ie(n, W) {
6
- const k = n[W];
7
- return Ve(k) ? k : void 0;
5
+ function Ie(n, _) {
6
+ const H = n[_];
7
+ return Ee(H) ? H : void 0;
8
8
  }
9
- function Ee(n) {
9
+ function Ve(n) {
10
10
  return Ie(n, "id") ?? Ie(n, "key");
11
11
  }
12
12
  function xe(n) {
13
- function W(e, S) {
14
- const g = n.itemKey();
15
- if (typeof g == "function")
16
- return g(e, S);
13
+ function _(e, I) {
14
+ const m = n.itemKey();
15
+ if (typeof m == "function")
16
+ return m(e, I);
17
17
  if (e !== null && typeof e == "object") {
18
- if (g !== void 0) {
19
- const u = Ie(e, g);
18
+ if (m !== void 0) {
19
+ const u = Ie(e, m);
20
20
  if (u !== void 0) return u;
21
21
  }
22
- const x = Ee(e);
23
- if (x !== void 0) return x;
22
+ const w = Ve(e);
23
+ if (w !== void 0) return w;
24
24
  }
25
- return S;
25
+ return I;
26
26
  }
27
- function k() {
27
+ function H() {
28
28
  }
29
- return ae(
29
+ return Z(
30
30
  () => [n.itemKey(), n.items()],
31
- k,
31
+ H,
32
32
  { immediate: !0 }
33
- ), { getItemKey: W };
33
+ ), { getItemKey: _ };
34
34
  }
35
35
  function we(n) {
36
36
  return n === "fill" ? "100%" : typeof n == "number" ? `${n}px` : n;
37
37
  }
38
38
  function be(n) {
39
- return (W, k) => {
40
- typeof k == "string" && (k === "fill" || k.trim().endsWith("%"));
39
+ return (_, H) => {
40
+ typeof H == "string" && (H === "fill" || H.trim().endsWith("%"));
41
41
  };
42
42
  }
43
- const Ke = ["aria-label"], Ce = {
43
+ const Ke = ["aria-label"], De = {
44
44
  key: 0,
45
45
  class: "vue-chat-virtual-scroll__loading-older",
46
46
  role: "status",
47
47
  "aria-live": "polite"
48
- }, De = ["aria-posinset", "aria-setsize"], Re = /* @__PURE__ */ ge({
48
+ }, Ce = ["aria-posinset", "aria-setsize"], Ae = /* @__PURE__ */ ge({
49
49
  name: "ChatVirtualScroll",
50
50
  __name: "ChatVirtualScroll",
51
51
  props: {
@@ -63,304 +63,304 @@ const Ke = ["aria-label"], Ce = {
63
63
  loadOlderThreshold: { default: 120 }
64
64
  },
65
65
  emits: ["scroll", "loadOlder", "bottomChange"],
66
- setup(n, { expose: W, emit: k }) {
67
- const e = n, S = k, g = A(), x = A(0), u = A(0), V = A(0), P = A(!0), O = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map();
68
- let N, p, H = -1, T = !1;
69
- const B = be(), { getItemKey: F } = xe({
66
+ setup(n, { expose: _, emit: H }) {
67
+ const e = n, I = H, m = P(), w = P(0), u = P(0), L = P(0), N = P(!0), R = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map();
68
+ let E, M, z = -1, T = !1;
69
+ const $ = be(), { getItemKey: F } = xe({
70
70
  componentName: "ChatVirtualScroll",
71
71
  items: () => e.items,
72
72
  itemKey: () => e.itemKey
73
- }), I = i(
73
+ }), Y = i(
74
74
  () => Math.max(1, e.estimatedItemSize)
75
- ), U = i(() => Math.max(0, Math.floor(e.overscan))), ee = i(() => u.value > 0 ? u.value : typeof e.height == "number" ? Math.max(0, e.height) : I.value), K = i(() => {
76
- V.value;
77
- const a = new Array(e.items.length + 1), f = new Array(e.items.length);
78
- a[0] = 0;
75
+ ), J = i(() => Math.max(0, Math.floor(e.overscan))), ae = i(() => u.value > 0 ? u.value : typeof e.height == "number" ? Math.max(0, e.height) : Y.value), V = i(() => {
76
+ L.value;
77
+ const o = new Array(e.items.length + 1), d = new Array(e.items.length);
78
+ o[0] = 0;
79
79
  for (let r = 0; r < e.items.length; r += 1) {
80
- const D = F(e.items[r], r), R = O.get(D) ?? I.value;
81
- f[r] = R, a[r + 1] = a[r] + R;
80
+ const K = F(e.items[r], r), D = R.get(K) ?? Y.value;
81
+ d[r] = D, o[r + 1] = o[r] + D;
82
82
  }
83
83
  return {
84
- offsets: a,
85
- sizes: f,
86
- total: a[e.items.length] ?? 0
84
+ offsets: o,
85
+ sizes: d,
86
+ total: o[e.items.length] ?? 0
87
87
  };
88
- }), z = i(() => {
89
- const a = /* @__PURE__ */ new Map();
90
- return e.items.forEach((f, r) => {
91
- a.set(F(f, r), r);
92
- }), a;
88
+ }), x = i(() => {
89
+ const o = /* @__PURE__ */ new Map();
90
+ return e.items.forEach((d, r) => {
91
+ o.set(F(d, r), r);
92
+ }), o;
93
93
  });
94
- function te(a) {
94
+ function j(o) {
95
95
  if (e.items.length === 0) return 0;
96
- const f = K.value.offsets;
97
- let r = 0, D = e.items.length;
98
- for (; r < D; ) {
99
- const R = Math.floor((r + D) / 2);
100
- f[R + 1] <= a ? r = R + 1 : D = R;
96
+ const d = V.value.offsets;
97
+ let r = 0, K = e.items.length;
98
+ for (; r < K; ) {
99
+ const D = Math.floor((r + K) / 2);
100
+ d[D + 1] <= o ? r = D + 1 : K = D;
101
101
  }
102
102
  return Math.min(r, e.items.length - 1);
103
103
  }
104
- const G = i(
104
+ const q = i(
105
105
  () => Math.max(
106
106
  0,
107
- te(x.value) - U.value
107
+ j(w.value) - J.value
108
108
  )
109
- ), J = i(() => {
109
+ ), Q = i(() => {
110
110
  if (e.items.length === 0) return 0;
111
- const a = te(x.value + ee.value) + 1;
111
+ const o = j(w.value + ae.value) + 1;
112
112
  return Math.min(
113
113
  e.items.length,
114
- a + U.value
114
+ o + J.value
115
115
  );
116
- }), _ = i(
117
- () => e.items.slice(G.value, J.value).map((a, f) => {
118
- const r = G.value + f;
116
+ }), U = i(
117
+ () => e.items.slice(q.value, Q.value).map((o, d) => {
118
+ const r = q.value + d;
119
119
  return {
120
- item: a,
120
+ item: o,
121
121
  index: r,
122
- key: F(a, r),
123
- top: K.value.offsets[r]
122
+ key: F(o, r),
123
+ top: V.value.offsets[r]
124
124
  };
125
125
  })
126
- ), oe = i(() => ({
126
+ ), ue = i(() => ({
127
127
  height: we(e.height)
128
128
  }));
129
- function Y() {
130
- const a = g.value;
131
- if (!a) return;
129
+ function O() {
130
+ const o = m.value;
131
+ if (!o) return;
132
132
  const r = Math.max(
133
133
  0,
134
- K.value.total - a.scrollTop - a.clientHeight
134
+ V.value.total - o.scrollTop - o.clientHeight
135
135
  ) <= Math.max(0, e.bottomThreshold);
136
- r !== P.value && (P.value = r, T && S("bottomChange", r));
136
+ r !== N.value && (N.value = r, T && I("bottomChange", r));
137
137
  }
138
138
  function c() {
139
- var a;
140
- u.value = ((a = g.value) == null ? void 0 : a.clientHeight) ?? 0, B(g.value, e.height), $(() => {
141
- Y(), L();
139
+ var o;
140
+ u.value = ((o = m.value) == null ? void 0 : o.clientHeight) ?? 0, $(m.value, e.height), k(() => {
141
+ O(), B();
142
142
  });
143
143
  }
144
- function v(a) {
145
- x.value = a.currentTarget.scrollTop, Y(), S("scroll", {
146
- scrollTop: x.value,
147
- startIndex: G.value,
148
- endIndex: J.value
149
- }), L();
150
- }
151
- function L() {
152
- const a = g.value;
153
- !T || !a || !e.hasOlder || e.loadingOlder || H === e.items.length || a.scrollTop <= Math.max(0, e.loadOlderThreshold) && (H = e.items.length, S("loadOlder"));
154
- }
155
- function j(a) {
156
- const f = a.borderBoxSize;
157
- if (f) {
158
- const r = Array.isArray(f) ? f[0] : f;
144
+ function g(o) {
145
+ w.value = o.currentTarget.scrollTop, O(), I("scroll", {
146
+ scrollTop: w.value,
147
+ startIndex: q.value,
148
+ endIndex: Q.value
149
+ }), B();
150
+ }
151
+ function B() {
152
+ const o = m.value;
153
+ !T || !o || !e.hasOlder || e.loadingOlder || z === e.items.length || o.scrollTop <= Math.max(0, e.loadOlderThreshold) && (z = e.items.length, I("loadOlder"));
154
+ }
155
+ function oe(o) {
156
+ const d = o.borderBoxSize;
157
+ if (d) {
158
+ const r = Array.isArray(d) ? d[0] : d;
159
159
  if (r != null && r.blockSize) return r.blockSize;
160
160
  }
161
- return a.contentRect.height;
162
- }
163
- function re(a) {
164
- const f = K.value, r = P.value && e.stickToBottom;
165
- let D = 0, R = !1;
166
- for (const Z of a) {
167
- const ue = Z.target, t = E.get(ue), o = j(Z);
168
- if (t === void 0 || o <= 0) continue;
169
- const l = O.get(t) ?? I.value;
170
- if (Math.abs(l - o) < 0.5) continue;
171
- const M = z.value.get(t);
172
- M !== void 0 && f.offsets[M + 1] <= x.value && (D += o - l), O.set(t, o), R = !0;
161
+ return o.contentRect.height;
162
+ }
163
+ function ne(o) {
164
+ const d = V.value, r = N.value && e.stickToBottom;
165
+ let K = 0, D = !1;
166
+ for (const W of o) {
167
+ const s = W.target, t = C.get(s), a = oe(W);
168
+ if (t === void 0 || a <= 0) continue;
169
+ const l = R.get(t) ?? Y.value;
170
+ if (Math.abs(l - a) < 0.5) continue;
171
+ const y = x.value.get(t);
172
+ y !== void 0 && d.offsets[y + 1] <= w.value && (K += a - l), R.set(t, a), D = !0;
173
173
  }
174
- R && (V.value += 1, $(() => {
175
- const Z = g.value;
176
- Z && (r ? s("auto") : D !== 0 && (Z.scrollTop += D, x.value = Z.scrollTop, Y()));
174
+ D && (L.value += 1, k(() => {
175
+ const W = m.value;
176
+ W && (r ? h("auto") : K !== 0 && (W.scrollTop += K, w.value = W.scrollTop, O()));
177
177
  }));
178
178
  }
179
- function se(a, f) {
180
- a instanceof HTMLElement && (E.set(a, f), p == null || p.observe(a));
179
+ function se(o, d) {
180
+ o instanceof HTMLElement && (C.set(o, d), M == null || M.observe(o));
181
181
  }
182
- function ne() {
183
- for (const [a] of E)
184
- a.isConnected || (p == null || p.unobserve(a), E.delete(a));
182
+ function X() {
183
+ for (const [o] of C)
184
+ o.isConnected || (M == null || M.unobserve(o), C.delete(o));
185
185
  }
186
- function fe(a, f = {}) {
187
- const r = g.value;
186
+ function ie(o, d = {}) {
187
+ const r = m.value;
188
188
  if (!r) return;
189
- const D = Math.max(0, K.value.total - r.clientHeight), R = Math.min(
190
- Math.max(0, Number.isFinite(a) ? a : 0),
191
- D
192
- ), Z = f.behavior ?? "auto";
193
- Z === "auto" && (x.value = R), r.scrollTo({ ...f, top: R, behavior: Z }), $(Y);
194
- }
195
- function le(a, f = {}) {
196
- const r = g.value;
189
+ const K = Math.max(0, V.value.total - r.clientHeight), D = Math.min(
190
+ Math.max(0, Number.isFinite(o) ? o : 0),
191
+ K
192
+ ), W = d.behavior ?? "auto";
193
+ W === "auto" && (w.value = D), r.scrollTo({ ...d, top: D, behavior: W }), k(O);
194
+ }
195
+ function ee(o, d = {}) {
196
+ const r = m.value;
197
197
  if (!r || e.items.length === 0) return;
198
- const D = Math.min(
198
+ const K = Math.min(
199
199
  e.items.length - 1,
200
- Math.max(0, Math.floor(a))
201
- ), { align: R = "start", ...Z } = f, ue = K.value.sizes[D];
202
- let t = K.value.offsets[D];
203
- R === "center" ? t -= (r.clientHeight - ue) / 2 : R === "end" && (t -= r.clientHeight - ue);
204
- const o = Math.max(
200
+ Math.max(0, Math.floor(o))
201
+ ), { align: D = "start", ...W } = d, s = V.value.sizes[K];
202
+ let t = V.value.offsets[K];
203
+ D === "center" ? t -= (r.clientHeight - s) / 2 : D === "end" && (t -= r.clientHeight - s);
204
+ const a = Math.max(
205
205
  0,
206
- Math.min(t, K.value.total - r.clientHeight)
207
- ), l = Z.behavior ?? "auto", M = Math.max(
206
+ Math.min(t, V.value.total - r.clientHeight)
207
+ ), l = W.behavior ?? "auto", y = Math.max(
208
208
  r.clientHeight * 3,
209
- I.value * 10
210
- ), y = l === "smooth" && Math.abs(o - r.scrollTop) > M ? "auto" : l;
211
- y === "auto" && (x.value = o), r.scrollTo({
212
- ...Z,
213
- top: o,
214
- behavior: y
215
- }), $(Y);
216
- }
217
- function d(a = "auto") {
218
- const f = g.value;
219
- f && (a === "auto" && (x.value = 0), f.scrollTo({ top: 0, behavior: a }), $(Y));
220
- }
221
- function s(a = "auto") {
222
- const f = g.value;
223
- if (!f) return;
224
- const r = Math.max(0, K.value.total - f.clientHeight);
225
- a === "auto" ? (f.scrollTop = r, x.value = r) : f.scrollTo({ top: r, behavior: a }), $(Y);
226
- }
227
- let h = e.items.map((a, f) => F(a, f));
228
- return ae(
229
- () => e.items.map((a, f) => F(a, f)),
230
- async (a) => {
231
- const f = h;
232
- h = a;
233
- const r = g.value, D = (r == null ? void 0 : r.scrollTop) ?? 0, R = P.value && e.stickToBottom, Z = f[0], ue = Z === void 0 ? 0 : a.indexOf(Z), t = ue > 0 ? a.slice(0, ue).reduce(
234
- (l, M) => l + (O.get(M) ?? I.value),
209
+ Y.value * 10
210
+ ), p = l === "smooth" && Math.abs(a - r.scrollTop) > y ? "auto" : l;
211
+ p === "auto" && (w.value = a), r.scrollTo({
212
+ ...W,
213
+ top: a,
214
+ behavior: p
215
+ }), k(O);
216
+ }
217
+ function de(o = "auto") {
218
+ const d = m.value;
219
+ d && (o === "auto" && (w.value = 0), d.scrollTo({ top: 0, behavior: o }), k(O));
220
+ }
221
+ function h(o = "auto") {
222
+ const d = m.value;
223
+ if (!d) return;
224
+ const r = Math.max(0, V.value.total - d.clientHeight);
225
+ o === "auto" ? (d.scrollTop = r, w.value = r) : d.scrollTo({ top: r, behavior: o }), k(O);
226
+ }
227
+ let v = e.items.map((o, d) => F(o, d));
228
+ return Z(
229
+ () => e.items.map((o, d) => F(o, d)),
230
+ async (o) => {
231
+ const d = v;
232
+ v = o;
233
+ const r = m.value, K = (r == null ? void 0 : r.scrollTop) ?? 0, D = N.value && e.stickToBottom, W = d[0], s = W === void 0 ? 0 : o.indexOf(W), t = s > 0 ? o.slice(0, s).reduce(
234
+ (l, y) => l + (R.get(y) ?? Y.value),
235
235
  0
236
- ) : 0, o = new Set(a);
237
- for (const l of O.keys())
238
- o.has(l) || O.delete(l);
239
- V.value += 1, await $(), r && (t > 0 ? (r.scrollTop = D + t, x.value = r.scrollTop) : a.length > f.length && R && s("auto"), Y(), L());
236
+ ) : 0, a = new Set(o);
237
+ for (const l of R.keys())
238
+ a.has(l) || R.delete(l);
239
+ L.value += 1, await k(), r && (t > 0 ? (r.scrollTop = K + t, w.value = r.scrollTop) : o.length > d.length && D && h("auto"), O(), B());
240
240
  }
241
- ), ae(
241
+ ), Z(
242
242
  () => [e.hasOlder, e.loadingOlder],
243
- async ([a]) => {
244
- a || (H = -1), await $(), L();
243
+ async ([o]) => {
244
+ o || (z = -1), await k(), B();
245
245
  }
246
246
  ), pe(() => {
247
247
  if (c(), typeof ResizeObserver < "u") {
248
- N = new ResizeObserver(c), p = new ResizeObserver(re), g.value && N.observe(g.value);
249
- for (const [a] of E)
250
- p.observe(a);
248
+ E = new ResizeObserver(c), M = new ResizeObserver(ne), m.value && E.observe(m.value);
249
+ for (const [o] of C)
250
+ M.observe(o);
251
251
  }
252
- $(() => {
253
- e.initialScroll === "bottom" && s("auto"), T = !0, Y(), L();
252
+ k(() => {
253
+ e.initialScroll === "bottom" && h("auto"), T = !0, O(), B();
254
254
  });
255
- }), ze(ne), ye(() => {
256
- N == null || N.disconnect(), p == null || p.disconnect(), E.clear();
257
- }), W({
258
- isAtBottom: P,
259
- scrollTo: fe,
260
- scrollToIndex: le,
261
- scrollToTop: d,
262
- scrollToBottom: s
263
- }), (a, f) => (w(), b("div", {
255
+ }), ze(X), ye(() => {
256
+ E == null || E.disconnect(), M == null || M.disconnect(), C.clear();
257
+ }), _({
258
+ isAtBottom: N,
259
+ scrollTo: ie,
260
+ scrollToIndex: ee,
261
+ scrollToTop: de,
262
+ scrollToBottom: h
263
+ }), (o, d) => (b(), S("div", {
264
264
  ref_key: "viewport",
265
- ref: g,
265
+ ref: m,
266
266
  class: "vue-chat-virtual-scroll",
267
- style: C(oe.value),
267
+ style: A(ue.value),
268
268
  role: "log",
269
269
  "aria-label": n.ariaLabel,
270
270
  "aria-live": "polite",
271
271
  tabindex: "0",
272
- onScrollPassive: v
272
+ onScrollPassive: g
273
273
  }, [
274
- n.loadingOlder ? (w(), b("div", Ce, [
274
+ n.loadingOlder ? (b(), S("div", De, [
275
275
  Be("div", null, [
276
- X(a.$slots, "loadingOlder", {}, () => [
277
- f[0] || (f[0] = me("Loading older messages…", -1))
276
+ le(o.$slots, "loadingOlder", {}, () => [
277
+ d[0] || (d[0] = ve("Loading older messages…", -1))
278
278
  ])
279
279
  ])
280
280
  ])) : he("", !0),
281
- n.items.length ? (w(), b("div", {
281
+ n.items.length ? (b(), S("div", {
282
282
  key: 1,
283
283
  class: "vue-chat-virtual-scroll__spacer",
284
- style: C({ height: `${K.value.total}px` })
284
+ style: A({ height: `${V.value.total}px` })
285
285
  }, [
286
- (w(!0), b(ve, null, Me(_.value, ({ item: r, index: D, key: R, top: Z }) => (w(), b("div", {
287
- key: R,
286
+ (b(!0), S(me, null, Me(U.value, ({ item: r, index: K, key: D, top: W }) => (b(), S("div", {
287
+ key: D,
288
288
  ref_for: !0,
289
- ref: (ue) => se(ue, R),
289
+ ref: (s) => se(s, D),
290
290
  class: "vue-chat-virtual-scroll__item",
291
- style: C({ transform: `translateY(${Z}px)` }),
291
+ style: A({ transform: `translateY(${W}px)` }),
292
292
  role: "article",
293
- "aria-posinset": D + 1,
293
+ "aria-posinset": K + 1,
294
294
  "aria-setsize": n.items.length
295
295
  }, [
296
- X(a.$slots, "default", {
296
+ le(o.$slots, "default", {
297
297
  item: r,
298
- index: D
298
+ index: K
299
299
  })
300
- ], 12, De))), 128))
301
- ], 4)) : X(a.$slots, "empty", {}, void 0, void 0, 2)
300
+ ], 12, Ce))), 128))
301
+ ], 4)) : le(o.$slots, "empty", {}, void 0, void 0, 2)
302
302
  ], 44, Ke));
303
303
  }
304
304
  });
305
305
  function He(n) {
306
- const W = A(), k = A(0), e = A(!1), S = A(!1), g = i(() => Math.max(1, n.threshold())), x = i(
307
- () => n.refreshing() || S.value ? g.value : k.value
306
+ const _ = P(), H = P(0), e = P(!1), I = P(!1), m = i(() => Math.max(1, n.threshold())), w = i(
307
+ () => n.refreshing() || I.value ? m.value : H.value
308
308
  ), u = i(
309
- () => Math.min(1, k.value / g.value)
310
- ), V = i(() => n.refreshing() || S.value ? "Refreshing…" : u.value >= 1 ? "Release to refresh" : "Pull to refresh");
311
- function P() {
312
- W.value = void 0, e.value = !1, k.value = 0;
309
+ () => Math.min(1, H.value / m.value)
310
+ ), L = i(() => n.refreshing() || I.value ? "Refreshing…" : u.value >= 1 ? "Release to refresh" : "Pull to refresh");
311
+ function N() {
312
+ _.value = void 0, e.value = !1, H.value = 0;
313
313
  }
314
- function O(p) {
315
- var B;
316
- const H = p.currentTarget, T = ((B = n.scrollTop) == null ? void 0 : B.call(n)) ?? H.scrollTop;
317
- !n.enabled() || n.refreshing() || T > 0 || p.touches.length !== 1 || (W.value = p.touches[0].clientY, e.value = !0);
314
+ function R(M) {
315
+ var $;
316
+ const z = M.currentTarget, T = (($ = n.scrollTop) == null ? void 0 : $.call(n)) ?? z.scrollTop;
317
+ !n.enabled() || n.refreshing() || T > 0 || M.touches.length !== 1 || (_.value = M.touches[0].clientY, e.value = !0);
318
318
  }
319
- function E(p) {
319
+ function C(M) {
320
320
  var F;
321
- if (W.value === void 0 || !e.value) return;
322
- const H = p.currentTarget;
323
- if ((((F = n.scrollTop) == null ? void 0 : F.call(n)) ?? H.scrollTop) > 0 || p.touches.length !== 1) {
324
- P();
321
+ if (_.value === void 0 || !e.value) return;
322
+ const z = M.currentTarget;
323
+ if ((((F = n.scrollTop) == null ? void 0 : F.call(n)) ?? z.scrollTop) > 0 || M.touches.length !== 1) {
324
+ N();
325
325
  return;
326
326
  }
327
- const B = p.touches[0].clientY - W.value;
328
- if (B <= 0) {
329
- k.value = 0;
327
+ const $ = M.touches[0].clientY - _.value;
328
+ if ($ <= 0) {
329
+ H.value = 0;
330
330
  return;
331
331
  }
332
- p.preventDefault(), k.value = Math.min(B * 0.5, g.value * 2);
332
+ M.preventDefault(), H.value = Math.min($ * 0.5, m.value * 2);
333
333
  }
334
- function N() {
335
- if (W.value === void 0) return;
336
- const p = k.value >= g.value && n.enabled() && !n.refreshing();
337
- if (W.value = void 0, e.value = !1, !p) {
338
- k.value = 0;
334
+ function E() {
335
+ if (_.value === void 0) return;
336
+ const M = H.value >= m.value && n.enabled() && !n.refreshing();
337
+ if (_.value = void 0, e.value = !1, !M) {
338
+ H.value = 0;
339
339
  return;
340
340
  }
341
- k.value = g.value, S.value = !0, n.onRefresh(), $(() => {
342
- n.refreshing() || (S.value = !1, k.value = 0);
341
+ H.value = m.value, I.value = !0, n.onRefresh(), k(() => {
342
+ n.refreshing() || (I.value = !1, H.value = 0);
343
343
  });
344
344
  }
345
- return ae(
345
+ return Z(
346
346
  () => n.refreshing(),
347
- (p, H) => {
348
- p ? (S.value = !1, k.value = g.value) : H && (S.value = !1, k.value = 0);
347
+ (M, z) => {
348
+ M ? (I.value = !1, H.value = m.value) : z && (I.value = !1, H.value = 0);
349
349
  }
350
350
  ), {
351
351
  pulling: e,
352
- pullDistance: k,
353
- pullOffset: x,
352
+ pullDistance: H,
353
+ pullOffset: w,
354
354
  pullProgress: u,
355
- refreshMessage: V,
356
- refreshThreshold: g,
357
- handleTouchStart: O,
358
- handleTouchMove: E,
359
- handleTouchEnd: N,
360
- handleTouchCancel: P
355
+ refreshMessage: L,
356
+ refreshThreshold: m,
357
+ handleTouchStart: R,
358
+ handleTouchMove: C,
359
+ handleTouchEnd: E,
360
+ handleTouchCancel: N
361
361
  };
362
362
  }
363
- const Ae = ["aria-label"], Pe = ["aria-posinset", "aria-setsize"], Le = /* @__PURE__ */ ge({
363
+ const Re = ["aria-label"], Pe = ["aria-posinset", "aria-setsize"], Le = /* @__PURE__ */ ge({
364
364
  name: "DynamicVirtualScroll",
365
365
  __name: "DynamicVirtualScroll",
366
366
  props: {
@@ -379,292 +379,292 @@ const Ae = ["aria-label"], Pe = ["aria-posinset", "aria-setsize"], Le = /* @__PU
379
379
  pullRefreshThreshold: { default: 64 }
380
380
  },
381
381
  emits: ["scroll", "loadMore", "refresh"],
382
- setup(n, { expose: W, emit: k }) {
383
- const e = n, S = k, {
384
- pulling: g,
385
- pullDistance: x,
382
+ setup(n, { expose: _, emit: H }) {
383
+ const e = n, I = H, {
384
+ pulling: m,
385
+ pullDistance: w,
386
386
  pullOffset: u,
387
- pullProgress: V,
388
- refreshMessage: P,
389
- refreshThreshold: O,
390
- handleTouchStart: E,
391
- handleTouchMove: N,
392
- handleTouchEnd: p,
393
- handleTouchCancel: H
387
+ pullProgress: L,
388
+ refreshMessage: N,
389
+ refreshThreshold: R,
390
+ handleTouchStart: C,
391
+ handleTouchMove: E,
392
+ handleTouchEnd: M,
393
+ handleTouchCancel: z
394
394
  } = He({
395
395
  enabled: () => e.pullToRefresh,
396
396
  refreshing: () => e.refreshing,
397
397
  threshold: () => e.pullRefreshThreshold,
398
- onRefresh: () => S("refresh")
399
- }), T = A(), B = A(0), F = A(0), I = A(0), U = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Map();
400
- let K, z, te = -1;
401
- const G = be(), { getItemKey: J } = xe({
398
+ onRefresh: () => I("refresh")
399
+ }), T = P(), $ = P(0), F = P(0), Y = P(0), J = /* @__PURE__ */ new Map(), ae = /* @__PURE__ */ new Map();
400
+ let V, x, j = -1;
401
+ const q = be(), { getItemKey: Q } = xe({
402
402
  componentName: "DynamicVirtualScroll",
403
403
  items: () => e.items,
404
404
  itemKey: () => e.itemKey
405
- }), _ = i(
405
+ }), U = i(
406
406
  () => Math.max(1, e.estimatedItemSize)
407
- ), oe = i(
408
- () => Math.max(1, e.loadingItemSize ?? _.value)
409
- ), Y = i(() => Math.max(0, Math.floor(e.overscan))), c = i(() => F.value > 0 ? F.value : typeof e.height == "number" ? Math.max(0, e.height) : _.value), v = i(() => {
410
- I.value;
411
- const t = new Array(e.items.length + 1), o = new Array(e.items.length);
407
+ ), ue = i(
408
+ () => Math.max(1, e.loadingItemSize ?? U.value)
409
+ ), O = i(() => Math.max(0, Math.floor(e.overscan))), c = i(() => F.value > 0 ? F.value : typeof e.height == "number" ? Math.max(0, e.height) : U.value), g = i(() => {
410
+ Y.value;
411
+ const t = new Array(e.items.length + 1), a = new Array(e.items.length);
412
412
  t[0] = 0;
413
413
  for (let l = 0; l < e.items.length; l += 1) {
414
- const M = J(e.items[l], l), y = U.get(M) ?? _.value;
415
- o[l] = y, t[l + 1] = t[l] + y;
414
+ const y = Q(e.items[l], l), p = J.get(y) ?? U.value;
415
+ a[l] = p, t[l + 1] = t[l] + p;
416
416
  }
417
417
  return {
418
418
  offsets: t,
419
- sizes: o,
419
+ sizes: a,
420
420
  total: t[e.items.length] ?? 0
421
421
  };
422
- }), L = i(
423
- () => v.value.total + (e.loading ? oe.value : 0)
424
- ), j = i(() => {
422
+ }), B = i(
423
+ () => g.value.total + (e.loading ? ue.value : 0)
424
+ ), oe = i(() => {
425
425
  const t = /* @__PURE__ */ new Map();
426
- return e.items.forEach((o, l) => {
427
- t.set(J(o, l), l);
426
+ return e.items.forEach((a, l) => {
427
+ t.set(Q(a, l), l);
428
428
  }), t;
429
429
  });
430
- function re(t) {
430
+ function ne(t) {
431
431
  if (e.items.length === 0) return 0;
432
- const o = v.value.offsets;
433
- let l = 0, M = e.items.length;
434
- for (; l < M; ) {
435
- const y = Math.floor((l + M) / 2);
436
- o[y + 1] <= t ? l = y + 1 : M = y;
432
+ const a = g.value.offsets;
433
+ let l = 0, y = e.items.length;
434
+ for (; l < y; ) {
435
+ const p = Math.floor((l + y) / 2);
436
+ a[p + 1] <= t ? l = p + 1 : y = p;
437
437
  }
438
438
  return Math.min(l, e.items.length - 1);
439
439
  }
440
440
  const se = i(
441
441
  () => Math.max(
442
442
  0,
443
- re(B.value) - Y.value
443
+ ne($.value) - O.value
444
444
  )
445
- ), ne = i(() => {
445
+ ), X = i(() => {
446
446
  if (e.items.length === 0) return 0;
447
- const t = re(B.value + c.value) + 1;
447
+ const t = ne($.value + c.value) + 1;
448
448
  return Math.min(
449
449
  e.items.length,
450
- t + Y.value
450
+ t + O.value
451
451
  );
452
- }), fe = i(
453
- () => e.items.slice(se.value, ne.value).map((t, o) => {
454
- const l = se.value + o;
452
+ }), ie = i(
453
+ () => e.items.slice(se.value, X.value).map((t, a) => {
454
+ const l = se.value + a;
455
455
  return {
456
456
  item: t,
457
457
  index: l,
458
- key: J(t, l),
459
- top: v.value.offsets[l]
458
+ key: Q(t, l),
459
+ top: g.value.offsets[l]
460
460
  };
461
461
  })
462
- ), le = i(() => ({
462
+ ), ee = i(() => ({
463
463
  height: we(e.height)
464
464
  }));
465
- function d() {
465
+ function de() {
466
466
  var t;
467
- F.value = ((t = T.value) == null ? void 0 : t.clientHeight) ?? 0, G(T.value, e.height), $(h);
467
+ F.value = ((t = T.value) == null ? void 0 : t.clientHeight) ?? 0, q(T.value, e.height), k(v);
468
468
  }
469
- function s(t) {
470
- B.value = t.currentTarget.scrollTop, S("scroll", {
471
- scrollTop: B.value,
469
+ function h(t) {
470
+ $.value = t.currentTarget.scrollTop, I("scroll", {
471
+ scrollTop: $.value,
472
472
  startIndex: se.value,
473
- endIndex: ne.value
474
- }), h();
473
+ endIndex: X.value
474
+ }), v();
475
475
  }
476
- function h() {
476
+ function v() {
477
477
  const t = T.value;
478
- if (!t || !e.hasMore || e.loading || te === e.items.length)
478
+ if (!t || !e.hasMore || e.loading || j === e.items.length)
479
479
  return;
480
- const o = Math.max(0, e.loadMoreThreshold);
481
- L.value - t.scrollTop - t.clientHeight <= o && (te = e.items.length, S("loadMore"));
480
+ const a = Math.max(0, e.loadMoreThreshold);
481
+ B.value - t.scrollTop - t.clientHeight <= a && (j = e.items.length, I("loadMore"));
482
482
  }
483
- function a(t) {
484
- const o = t.borderBoxSize;
485
- if (o) {
486
- const l = Array.isArray(o) ? o[0] : o;
483
+ function o(t) {
484
+ const a = t.borderBoxSize;
485
+ if (a) {
486
+ const l = Array.isArray(a) ? a[0] : a;
487
487
  if (l != null && l.blockSize) return l.blockSize;
488
488
  }
489
489
  return t.contentRect.height;
490
490
  }
491
- function f(t) {
492
- const o = v.value;
493
- let l = 0, M = !1;
494
- for (const y of t) {
495
- const Q = y.target, q = ee.get(Q), ie = a(y);
496
- if (q === void 0 || ie <= 0) continue;
497
- const ce = U.get(q) ?? _.value;
498
- if (Math.abs(ce - ie) < 0.5) continue;
499
- const de = j.value.get(q);
500
- de !== void 0 && o.offsets[de + 1] <= B.value && (l += ie - ce), U.set(q, ie), M = !0;
491
+ function d(t) {
492
+ const a = g.value;
493
+ let l = 0, y = !1;
494
+ for (const p of t) {
495
+ const te = p.target, G = ae.get(te), re = o(p);
496
+ if (G === void 0 || re <= 0) continue;
497
+ const ce = J.get(G) ?? U.value;
498
+ if (Math.abs(ce - re) < 0.5) continue;
499
+ const fe = oe.value.get(G);
500
+ fe !== void 0 && a.offsets[fe + 1] <= $.value && (l += re - ce), J.set(G, re), y = !0;
501
501
  }
502
- M && (I.value += 1, $(h), l !== 0 && $(() => {
503
- const y = T.value;
504
- y && (y.scrollTop += l, B.value = y.scrollTop);
502
+ y && (Y.value += 1, k(v), l !== 0 && k(() => {
503
+ const p = T.value;
504
+ p && (p.scrollTop += l, $.value = p.scrollTop);
505
505
  }));
506
506
  }
507
- function r(t, o) {
508
- t instanceof HTMLElement && (ee.set(t, o), z == null || z.observe(t));
507
+ function r(t, a) {
508
+ t instanceof HTMLElement && (ae.set(t, a), x == null || x.observe(t));
509
509
  }
510
- function D() {
511
- for (const [t] of ee)
512
- t.isConnected || (z == null || z.unobserve(t), ee.delete(t));
510
+ function K() {
511
+ for (const [t] of ae)
512
+ t.isConnected || (x == null || x.unobserve(t), ae.delete(t));
513
513
  }
514
- function R(t, o = {}) {
514
+ function D(t, a = {}) {
515
515
  const l = T.value;
516
516
  if (!l) return;
517
- const M = Math.max(0, L.value - l.clientHeight), y = Math.min(
517
+ const y = Math.max(0, B.value - l.clientHeight), p = Math.min(
518
518
  Math.max(0, Number.isFinite(t) ? t : 0),
519
- M
520
- ), Q = o.behavior ?? "auto";
521
- Q === "auto" && (B.value = y), l.scrollTo({ ...o, top: y, behavior: Q });
519
+ y
520
+ ), te = a.behavior ?? "auto";
521
+ te === "auto" && ($.value = p), l.scrollTo({ ...a, top: p, behavior: te });
522
522
  }
523
- function Z(t, o = {}) {
523
+ function W(t, a = {}) {
524
524
  const l = T.value;
525
525
  if (!l || e.items.length === 0) return;
526
- const M = Math.min(
526
+ const y = Math.min(
527
527
  e.items.length - 1,
528
528
  Math.max(0, Math.floor(t))
529
- ), { align: y = "start", ...Q } = o;
530
- let q = v.value.offsets[M];
531
- const ie = v.value.sizes[M];
532
- y === "center" ? q -= (l.clientHeight - ie) / 2 : y === "end" && (q -= l.clientHeight - ie);
529
+ ), { align: p = "start", ...te } = a;
530
+ let G = g.value.offsets[y];
531
+ const re = g.value.sizes[y];
532
+ p === "center" ? G -= (l.clientHeight - re) / 2 : p === "end" && (G -= l.clientHeight - re);
533
533
  const ce = Math.max(
534
534
  0,
535
- Math.min(q, L.value - l.clientHeight)
536
- ), de = Q.behavior ?? "auto", Se = Math.max(
535
+ Math.min(G, B.value - l.clientHeight)
536
+ ), fe = te.behavior ?? "auto", Se = Math.max(
537
537
  l.clientHeight * 3,
538
- _.value * 10
539
- ), Te = de === "smooth" && Math.abs(ce - l.scrollTop) > Se ? "auto" : de;
540
- Te === "auto" && (B.value = ce), l.scrollTo({
541
- ...Q,
538
+ U.value * 10
539
+ ), Te = fe === "smooth" && Math.abs(ce - l.scrollTop) > Se ? "auto" : fe;
540
+ Te === "auto" && ($.value = ce), l.scrollTo({
541
+ ...te,
542
542
  top: ce,
543
543
  behavior: Te
544
544
  });
545
545
  }
546
- function ue(t = "auto") {
547
- var o;
548
- (o = T.value) == null || o.scrollTo({ top: 0, behavior: t });
546
+ function s(t = "auto") {
547
+ var a;
548
+ (a = T.value) == null || a.scrollTo({ top: 0, behavior: t });
549
549
  }
550
- return ae(
550
+ return Z(
551
551
  () => e.itemKey,
552
552
  () => {
553
- U.clear(), I.value += 1;
553
+ J.clear(), Y.value += 1;
554
554
  }
555
- ), ae(
555
+ ), Z(
556
556
  () => e.items.length,
557
557
  async () => {
558
558
  const t = new Set(
559
- e.items.map((M, y) => J(M, y))
559
+ e.items.map((y, p) => Q(y, p))
560
560
  );
561
- for (const M of U.keys())
562
- t.has(M) || U.delete(M);
563
- I.value += 1, await $();
564
- const o = T.value;
565
- if (!o) return;
566
- const l = Math.max(0, L.value - o.clientHeight);
567
- o.scrollTop > l && (o.scrollTop = l, B.value = l), h();
561
+ for (const y of J.keys())
562
+ t.has(y) || J.delete(y);
563
+ Y.value += 1, await k();
564
+ const a = T.value;
565
+ if (!a) return;
566
+ const l = Math.max(0, B.value - a.clientHeight);
567
+ a.scrollTop > l && (a.scrollTop = l, $.value = l), v();
568
568
  }
569
- ), ae(
569
+ ), Z(
570
570
  () => [e.hasMore, e.loading],
571
571
  async ([t]) => {
572
- t || (te = -1), await $(), h();
572
+ t || (j = -1), await k(), v();
573
573
  }
574
574
  ), pe(() => {
575
- if (d(), typeof ResizeObserver < "u") {
576
- K = new ResizeObserver(d), z = new ResizeObserver(f), T.value && K.observe(T.value);
577
- for (const [t] of ee)
578
- z.observe(t);
575
+ if (de(), typeof ResizeObserver < "u") {
576
+ V = new ResizeObserver(de), x = new ResizeObserver(d), T.value && V.observe(T.value);
577
+ for (const [t] of ae)
578
+ x.observe(t);
579
579
  }
580
- $(h);
581
- }), ze(D), ye(() => {
582
- K == null || K.disconnect(), z == null || z.disconnect(), ee.clear();
583
- }), W({
584
- scrollTo: R,
585
- scrollToIndex: Z,
586
- scrollToTop: ue
587
- }), (t, o) => (w(), b("div", {
580
+ k(v);
581
+ }), ze(K), ye(() => {
582
+ V == null || V.disconnect(), x == null || x.disconnect(), ae.clear();
583
+ }), _({
584
+ scrollTo: D,
585
+ scrollToIndex: W,
586
+ scrollToTop: s
587
+ }), (t, a) => (b(), S("div", {
588
588
  ref_key: "viewport",
589
589
  ref: T,
590
- class: $e(["vue-dynamic-virtual-scroll", { "vue-dynamic-virtual-scroll--pulling": m(g) }]),
591
- style: C(le.value),
590
+ class: $e(["vue-dynamic-virtual-scroll", { "vue-dynamic-virtual-scroll--pulling": f(m) }]),
591
+ style: A(ee.value),
592
592
  role: "list",
593
593
  "aria-label": n.ariaLabel,
594
594
  tabindex: "0",
595
- onScrollPassive: s,
596
- onTouchstartPassive: o[0] || (o[0] = //@ts-ignore
597
- (...l) => m(E) && m(E)(...l)),
598
- onTouchmove: o[1] || (o[1] = //@ts-ignore
599
- (...l) => m(N) && m(N)(...l)),
600
- onTouchend: o[2] || (o[2] = //@ts-ignore
601
- (...l) => m(p) && m(p)(...l)),
602
- onTouchcancel: o[3] || (o[3] = //@ts-ignore
603
- (...l) => m(H) && m(H)(...l))
595
+ onScrollPassive: h,
596
+ onTouchstartPassive: a[0] || (a[0] = //@ts-ignore
597
+ (...l) => f(C) && f(C)(...l)),
598
+ onTouchmove: a[1] || (a[1] = //@ts-ignore
599
+ (...l) => f(E) && f(E)(...l)),
600
+ onTouchend: a[2] || (a[2] = //@ts-ignore
601
+ (...l) => f(M) && f(M)(...l)),
602
+ onTouchcancel: a[3] || (a[3] = //@ts-ignore
603
+ (...l) => f(z) && f(z)(...l))
604
604
  }, [
605
- n.pullToRefresh || n.refreshing ? (w(), b("div", {
605
+ n.pullToRefresh || n.refreshing ? (b(), S("div", {
606
606
  key: 0,
607
607
  class: "vue-dynamic-virtual-scroll__refresh",
608
- style: C({
609
- height: `${m(O)}px`,
610
- transform: `translateY(${m(u) - m(O)}px)`
608
+ style: A({
609
+ height: `${f(R)}px`,
610
+ transform: `translateY(${f(u) - f(R)}px)`
611
611
  }),
612
612
  role: "status",
613
613
  "aria-live": "polite"
614
614
  }, [
615
- X(t.$slots, "refresh", {
616
- pullDistance: m(x),
617
- progress: m(V),
615
+ le(t.$slots, "refresh", {
616
+ pullDistance: f(w),
617
+ progress: f(L),
618
618
  refreshing: n.refreshing
619
619
  }, () => [
620
- me(ke(m(P)), 1)
620
+ ve(ke(f(N)), 1)
621
621
  ])
622
622
  ], 4)) : he("", !0),
623
- n.items.length || n.loading ? (w(), b("div", {
623
+ n.items.length || n.loading ? (b(), S("div", {
624
624
  key: 1,
625
625
  class: "vue-dynamic-virtual-scroll__spacer",
626
- style: C({
627
- height: `${L.value}px`,
628
- transform: `translateY(${m(u)}px)`
626
+ style: A({
627
+ height: `${B.value}px`,
628
+ transform: `translateY(${f(u)}px)`
629
629
  })
630
630
  }, [
631
- (w(!0), b(ve, null, Me(fe.value, ({ item: l, index: M, key: y, top: Q }) => (w(), b("div", {
632
- key: y,
631
+ (b(!0), S(me, null, Me(ie.value, ({ item: l, index: y, key: p, top: te }) => (b(), S("div", {
632
+ key: p,
633
633
  ref_for: !0,
634
- ref: (q) => r(q, y),
634
+ ref: (G) => r(G, p),
635
635
  class: "vue-dynamic-virtual-scroll__item",
636
- style: C({ transform: `translateY(${Q}px)` }),
636
+ style: A({ transform: `translateY(${te}px)` }),
637
637
  role: "listitem",
638
- "aria-posinset": M + 1,
638
+ "aria-posinset": y + 1,
639
639
  "aria-setsize": n.items.length
640
640
  }, [
641
- X(t.$slots, "default", {
641
+ le(t.$slots, "default", {
642
642
  item: l,
643
- index: M
643
+ index: y
644
644
  })
645
645
  ], 12, Pe))), 128)),
646
- n.loading ? (w(), b("div", {
646
+ n.loading ? (b(), S("div", {
647
647
  key: 0,
648
648
  class: "vue-dynamic-virtual-scroll__loading",
649
- style: C({
650
- height: `${oe.value}px`,
651
- transform: `translateY(${v.value.total}px)`
649
+ style: A({
650
+ height: `${ue.value}px`,
651
+ transform: `translateY(${g.value.total}px)`
652
652
  }),
653
653
  role: "status",
654
654
  "aria-live": "polite"
655
655
  }, [
656
- X(t.$slots, "loading", {}, () => [
657
- o[4] || (o[4] = me("Loading more…", -1))
656
+ le(t.$slots, "loading", {}, () => [
657
+ a[4] || (a[4] = ve("Loading more…", -1))
658
658
  ])
659
659
  ], 4)) : he("", !0)
660
- ], 4)) : (w(), b("div", {
660
+ ], 4)) : (b(), S("div", {
661
661
  key: 2,
662
662
  class: "vue-dynamic-virtual-scroll__empty",
663
- style: C({ transform: `translateY(${m(u)}px)` })
663
+ style: A({ transform: `translateY(${f(u)}px)` })
664
664
  }, [
665
- X(t.$slots, "empty")
665
+ le(t.$slots, "empty")
666
666
  ], 4))
667
- ], 46, Ae));
667
+ ], 46, Re));
668
668
  }
669
669
  }), Oe = ["aria-label"], Ne = ["aria-current", "aria-posinset", "aria-setsize"], Ye = {
670
670
  key: 1,
@@ -684,151 +684,151 @@ const Ae = ["aria-label"], Pe = ["aria-posinset", "aria-setsize"], Le = /* @__PU
684
684
  loadMoreThreshold: { default: 2 }
685
685
  },
686
686
  emits: ["update:activeIndex", "change", "reachStart", "reachEnd", "loadMore"],
687
- setup(n, { expose: W, emit: k }) {
688
- const e = n, S = k, g = A(), x = A(0), u = A(K(e.activeIndex));
689
- let V, P = -1;
690
- const O = be(), { getItemKey: E } = xe({
687
+ setup(n, { expose: _, emit: H }) {
688
+ const e = n, I = H, m = P(), w = P(0), u = P(V(e.activeIndex));
689
+ let L, N = -1;
690
+ const R = be(), { getItemKey: C } = xe({
691
691
  componentName: "ShortMediaFeed",
692
692
  items: () => e.items,
693
693
  itemKey: () => e.itemKey
694
- }), N = i(
694
+ }), E = i(
695
695
  () => Math.max(0, Math.floor(e.buffer))
696
- ), p = i(
696
+ ), M = i(
697
697
  () => Math.max(
698
698
  0,
699
699
  Math.floor(
700
700
  Number.isFinite(e.loadMoreThreshold) ? e.loadMoreThreshold : 0
701
701
  )
702
702
  )
703
- ), H = i(() => x.value > 0 ? x.value : typeof e.height == "number" ? Math.max(1, e.height) : 0), T = i(
704
- () => Math.max(0, u.value - N.value)
705
- ), B = i(
703
+ ), z = i(() => w.value > 0 ? w.value : typeof e.height == "number" ? Math.max(1, e.height) : 0), T = i(
704
+ () => Math.max(0, u.value - E.value)
705
+ ), $ = i(
706
706
  () => Math.min(
707
707
  e.items.length,
708
- u.value + N.value + 1
708
+ u.value + E.value + 1
709
709
  )
710
710
  ), F = i(
711
- () => e.items.slice(T.value, B.value).map((c, v) => ({
711
+ () => e.items.slice(T.value, $.value).map((c, g) => ({
712
712
  item: c,
713
- index: T.value + v
713
+ index: T.value + g
714
714
  }))
715
- ), I = i(() => T.value * H.value), U = i(
716
- () => (e.items.length - B.value) * H.value
717
- ), ee = i(() => ({
715
+ ), Y = i(() => T.value * z.value), J = i(
716
+ () => (e.items.length - $.value) * z.value
717
+ ), ae = i(() => ({
718
718
  height: we(e.height)
719
719
  }));
720
- function K(c) {
720
+ function V(c) {
721
721
  return e.items.length === 0 ? 0 : Math.min(
722
722
  e.items.length - 1,
723
723
  Math.max(0, Math.floor(Number.isFinite(c) ? c : 0))
724
724
  );
725
725
  }
726
- function z() {
727
- if (!e.hasMore || e.loading || P === e.items.length)
726
+ function x() {
727
+ if (!e.hasMore || e.loading || N === e.items.length)
728
728
  return;
729
- (e.items.length === 0 ? 0 : e.items.length - 1 - u.value) <= p.value && (P = e.items.length, S("loadMore"));
729
+ (e.items.length === 0 ? 0 : e.items.length - 1 - u.value) <= M.value && (N = e.items.length, I("loadMore"));
730
730
  }
731
- function te(c) {
732
- const v = K(c);
733
- v === u.value || e.items.length === 0 || (u.value = v, S("update:activeIndex", v), S("change", {
734
- index: v,
735
- item: e.items[v]
736
- }), v === 0 && S("reachStart"), v === e.items.length - 1 && S("reachEnd"), z());
731
+ function j(c) {
732
+ const g = V(c);
733
+ g === u.value || e.items.length === 0 || (u.value = g, I("update:activeIndex", g), I("change", {
734
+ index: g,
735
+ item: e.items[g]
736
+ }), g === 0 && I("reachStart"), g === e.items.length - 1 && I("reachEnd"), x());
737
737
  }
738
- function G(c, v = {}) {
739
- const L = g.value;
740
- L && (typeof L.scrollTo == "function" ? L.scrollTo({ ...v, top: c }) : L.scrollTop = c);
738
+ function q(c, g = {}) {
739
+ const B = m.value;
740
+ B && (typeof B.scrollTo == "function" ? B.scrollTo({ ...g, top: c }) : B.scrollTop = c);
741
741
  }
742
- function J(c, v = {}) {
742
+ function Q(c, g = {}) {
743
743
  if (e.items.length === 0) return;
744
- const L = K(c);
745
- te(L), G(L * H.value, v);
746
- }
747
- function _(c) {
748
- if (H.value <= 0) return;
749
- const v = c.currentTarget.scrollTop;
750
- te(Math.round(v / H.value));
751
- }
752
- function oe(c) {
753
- let v;
754
- c.key === "ArrowDown" || c.key === "PageDown" ? v = u.value + 1 : c.key === "ArrowUp" || c.key === "PageUp" ? v = u.value - 1 : c.key === "Home" ? v = 0 : c.key === "End" && (v = e.items.length - 1), v !== void 0 && (c.preventDefault(), J(v, { behavior: "smooth" }));
755
- }
756
- function Y() {
757
- var v;
758
- const c = ((v = g.value) == null ? void 0 : v.clientHeight) ?? 0;
759
- O(g.value, e.height), !(c <= 0 || c === x.value) && (x.value = c, $(() => {
760
- G(u.value * c);
744
+ const B = V(c);
745
+ j(B), q(B * z.value, g);
746
+ }
747
+ function U(c) {
748
+ if (z.value <= 0) return;
749
+ const g = c.currentTarget.scrollTop;
750
+ j(Math.round(g / z.value));
751
+ }
752
+ function ue(c) {
753
+ let g;
754
+ c.key === "ArrowDown" || c.key === "PageDown" ? g = u.value + 1 : c.key === "ArrowUp" || c.key === "PageUp" ? g = u.value - 1 : c.key === "Home" ? g = 0 : c.key === "End" && (g = e.items.length - 1), g !== void 0 && (c.preventDefault(), Q(g, { behavior: "smooth" }));
755
+ }
756
+ function O() {
757
+ var g;
758
+ const c = ((g = m.value) == null ? void 0 : g.clientHeight) ?? 0;
759
+ R(m.value, e.height), !(c <= 0 || c === w.value) && (w.value = c, k(() => {
760
+ q(u.value * c);
761
761
  }));
762
762
  }
763
- return ae(
763
+ return Z(
764
764
  () => e.activeIndex,
765
765
  async (c) => {
766
- const v = K(c);
767
- v !== u.value && (u.value = v, await $(), G(v * H.value), z());
766
+ const g = V(c);
767
+ g !== u.value && (u.value = g, await k(), q(g * z.value), x());
768
768
  }
769
- ), ae(
769
+ ), Z(
770
770
  () => [
771
771
  e.hasMore,
772
772
  e.loading,
773
773
  e.loadMoreThreshold
774
774
  ],
775
775
  async ([c]) => {
776
- c || (P = -1), await $(), z();
776
+ c || (N = -1), await k(), x();
777
777
  }
778
- ), ae(
778
+ ), Z(
779
779
  () => e.items.length,
780
780
  async () => {
781
- const c = K(u.value);
782
- e.items.length === 0 ? u.value !== 0 && (u.value = 0, S("update:activeIndex", 0)) : te(c), await $(), G(c * H.value), z();
781
+ const c = V(u.value);
782
+ e.items.length === 0 ? u.value !== 0 && (u.value = 0, I("update:activeIndex", 0)) : j(c), await k(), q(c * z.value), x();
783
783
  }
784
784
  ), pe(async () => {
785
- Y(), typeof ResizeObserver < "u" && g.value && (V = new ResizeObserver(Y), V.observe(g.value)), await $(), G(u.value * H.value), z();
785
+ O(), typeof ResizeObserver < "u" && m.value && (L = new ResizeObserver(O), L.observe(m.value)), await k(), q(u.value * z.value), x();
786
786
  }), ye(() => {
787
- V == null || V.disconnect();
788
- }), W({
789
- scrollToIndex: J
790
- }), (c, v) => (w(), b("div", {
787
+ L == null || L.disconnect();
788
+ }), _({
789
+ scrollToIndex: Q
790
+ }), (c, g) => (b(), S("div", {
791
791
  ref_key: "viewport",
792
- ref: g,
792
+ ref: m,
793
793
  class: "vue-short-media-feed",
794
- style: C(ee.value),
794
+ style: A(ae.value),
795
795
  role: "list",
796
796
  "aria-orientation": "vertical",
797
797
  "aria-label": n.ariaLabel,
798
798
  tabindex: "0",
799
- onScrollPassive: _,
800
- onKeydown: oe
799
+ onScrollPassive: U,
800
+ onKeydown: ue
801
801
  }, [
802
- n.items.length ? (w(), b(ve, { key: 0 }, [
803
- I.value > 0 ? (w(), b("div", {
802
+ n.items.length ? (b(), S(me, { key: 0 }, [
803
+ Y.value > 0 ? (b(), S("div", {
804
804
  key: 0,
805
805
  class: "vue-short-media-feed__spacer",
806
- style: C({ height: `${I.value}px` }),
806
+ style: A({ height: `${Y.value}px` }),
807
807
  "aria-hidden": "true"
808
808
  }, null, 4)) : he("", !0),
809
- (w(!0), b(ve, null, Me(F.value, ({ item: L, index: j }) => (w(), b("div", {
810
- key: m(E)(L, j),
809
+ (b(!0), S(me, null, Me(F.value, ({ item: B, index: oe }) => (b(), S("div", {
810
+ key: f(C)(B, oe),
811
811
  class: "vue-short-media-feed__item",
812
- style: C({ height: `${H.value}px` }),
812
+ style: A({ height: `${z.value}px` }),
813
813
  role: "listitem",
814
- "aria-current": j === u.value ? "true" : void 0,
815
- "aria-posinset": j + 1,
814
+ "aria-current": oe === u.value ? "true" : void 0,
815
+ "aria-posinset": oe + 1,
816
816
  "aria-setsize": n.items.length
817
817
  }, [
818
- X(c.$slots, "default", {
819
- item: L,
820
- index: j,
821
- active: j === u.value
818
+ le(c.$slots, "default", {
819
+ item: B,
820
+ index: oe,
821
+ active: oe === u.value
822
822
  })
823
823
  ], 12, Ne))), 128)),
824
- U.value > 0 ? (w(), b("div", {
824
+ J.value > 0 ? (b(), S("div", {
825
825
  key: 1,
826
826
  class: "vue-short-media-feed__spacer",
827
- style: C({ height: `${U.value}px` }),
827
+ style: A({ height: `${J.value}px` }),
828
828
  "aria-hidden": "true"
829
829
  }, null, 4)) : he("", !0)
830
- ], 64)) : (w(), b("div", Ye, [
831
- X(c.$slots, "empty")
830
+ ], 64)) : (b(), S("div", Ye, [
831
+ le(c.$slots, "empty")
832
832
  ]))
833
833
  ], 44, Oe));
834
834
  }
@@ -854,225 +854,277 @@ const Ae = ["aria-label"], Pe = ["aria-posinset", "aria-setsize"], Le = /* @__PU
854
854
  ariaLabel: { default: "Carousel" },
855
855
  hasMore: { type: Boolean, default: !1 },
856
856
  loading: { type: Boolean, default: !1 },
857
- loadMoreThreshold: { default: 2 }
857
+ loadMoreThreshold: { default: 2 },
858
+ autoplay: { type: Boolean, default: !1 },
859
+ autoplayDelay: { default: 3e3 },
860
+ autoplayLoop: { type: Boolean, default: !0 },
861
+ pauseOnHover: { type: Boolean, default: !0 }
858
862
  },
859
863
  emits: ["update:activeIndex", "change", "reachStart", "reachEnd", "loadMore"],
860
- setup(n, { expose: W, emit: k }) {
861
- const e = n, S = k, g = A(), x = A(0), u = A(0);
862
- let V, P = -1;
863
- const { getItemKey: O } = xe({
864
+ setup(n, { expose: _, emit: H }) {
865
+ const e = n, I = H, m = P(), w = P(0), u = P(0);
866
+ let L, N = -1, R, C;
867
+ const E = P(!1), { getItemKey: M } = xe({
864
868
  componentName: "VirtualCarousel",
865
869
  items: () => e.items,
866
870
  itemKey: () => e.itemKey
867
- }), E = i(
871
+ }), z = i(
868
872
  () => Math.max(
869
873
  1,
870
874
  Math.floor(
871
875
  Number.isFinite(e.slidesPerView) ? e.slidesPerView : 1
872
876
  )
873
877
  )
874
- ), N = i(
878
+ ), T = i(
875
879
  () => Math.max(
876
880
  1,
877
881
  Math.floor(
878
882
  Number.isFinite(e.slidesToScroll) ? e.slidesToScroll : 1
879
883
  )
880
884
  )
881
- ), p = i(
885
+ ), $ = i(
882
886
  () => Math.max(0, Number.isFinite(e.gap) ? e.gap : 0)
883
- ), H = i(
887
+ ), F = i(
884
888
  () => Math.max(
885
889
  0,
886
890
  Math.floor(Number.isFinite(e.buffer) ? e.buffer : 0)
887
891
  )
888
- ), T = i(
892
+ ), Y = i(
889
893
  () => Math.max(
890
894
  0,
891
895
  Math.floor(
892
896
  Number.isFinite(e.loadMoreThreshold) ? e.loadMoreThreshold : 0
893
897
  )
894
898
  )
895
- ), B = i(() => Math.max(0, x.value)), F = i(() => {
896
- if (B.value <= 0) return 0;
897
- const d = (E.value - 1) * p.value;
899
+ ), J = i(() => Number.isFinite(e.autoplayDelay) ? Math.max(1, e.autoplayDelay) : 3e3), ae = i(() => Math.max(0, w.value)), V = i(() => {
900
+ if (ae.value <= 0) return 0;
901
+ const s = (z.value - 1) * $.value;
898
902
  return Math.max(
899
903
  1,
900
- (B.value - d) / E.value
904
+ (ae.value - s) / z.value
901
905
  );
902
- }), I = i(() => F.value + p.value), U = i(
906
+ }), x = i(() => V.value + $.value), j = i(
903
907
  () => Math.max(
904
908
  0,
905
- e.items.length - E.value
909
+ e.items.length - z.value
906
910
  )
907
- ), ee = i(
908
- () => Math.max(0, u.value - H.value)
909
- ), K = i(
911
+ ), q = i(
912
+ () => Math.max(0, u.value - F.value)
913
+ ), Q = i(
910
914
  () => Math.min(
911
915
  e.items.length,
912
- u.value + E.value + H.value
916
+ u.value + z.value + F.value
913
917
  )
914
- ), z = i(
915
- () => e.items.slice(ee.value, K.value).map((d, s) => ({
916
- item: d,
917
- index: ee.value + s
918
+ ), U = i(
919
+ () => e.items.slice(q.value, Q.value).map((s, t) => ({
920
+ item: s,
921
+ index: q.value + t
918
922
  }))
919
- ), te = i(() => e.items.length === 0 ? 0 : e.items.length * F.value + (e.items.length - 1) * p.value), G = i(
920
- () => ee.value * I.value
921
- ), J = i(
923
+ ), ue = i(() => e.items.length === 0 ? 0 : e.items.length * V.value + (e.items.length - 1) * $.value), O = i(
924
+ () => q.value * x.value
925
+ ), c = i(
922
926
  () => Math.max(
923
927
  0,
924
- te.value - K.value * I.value
928
+ ue.value - Q.value * x.value
925
929
  )
926
- ), _ = i(() => ({
930
+ ), g = i(() => ({
927
931
  height: we(e.height)
928
932
  }));
929
- function oe(d) {
933
+ function B(s) {
930
934
  return Math.min(
931
- U.value,
932
- Math.max(0, Math.floor(Number.isFinite(d) ? d : 0))
935
+ j.value,
936
+ Math.max(0, Math.floor(Number.isFinite(s) ? s : 0))
933
937
  );
934
938
  }
935
- u.value = oe(e.activeIndex);
936
- function Y(d) {
937
- return d >= u.value && d < Math.min(
939
+ u.value = B(e.activeIndex);
940
+ function oe(s) {
941
+ return s >= u.value && s < Math.min(
938
942
  e.items.length,
939
- u.value + E.value
943
+ u.value + z.value
940
944
  );
941
945
  }
942
- function c() {
943
- if (!e.hasMore || e.loading || P === e.items.length)
946
+ function ne() {
947
+ if (!e.hasMore || e.loading || N === e.items.length)
944
948
  return;
945
- const d = e.items.length === 0 ? -1 : Math.min(
949
+ const s = e.items.length === 0 ? -1 : Math.min(
946
950
  e.items.length - 1,
947
- u.value + E.value - 1
951
+ u.value + z.value - 1
948
952
  );
949
- e.items.length - 1 - d <= T.value && (P = e.items.length, S("loadMore"));
950
- }
951
- function v(d) {
952
- const s = oe(d);
953
- s === u.value || e.items.length === 0 || (u.value = s, S("update:activeIndex", s), S("change", {
954
- index: s,
955
- item: e.items[s]
956
- }), s === 0 && S("reachStart"), s === U.value && S("reachEnd"), c());
957
- }
958
- function L(d, s = {}) {
959
- const h = g.value;
960
- h && (typeof h.scrollTo == "function" ? h.scrollTo({ ...s, left: d }) : h.scrollLeft = d);
961
- }
962
- function j(d, s = {}) {
963
- if (e.items.length === 0 || I.value <= 0) return;
964
- const h = oe(d), a = Math.abs(h - u.value), f = s.behavior === "smooth" && a > H.value ? "auto" : s.behavior;
965
- v(h), L(h * I.value, {
966
- ...s,
967
- behavior: f
953
+ e.items.length - 1 - s <= Y.value && (N = e.items.length, I("loadMore"));
954
+ }
955
+ function se(s) {
956
+ const t = B(s);
957
+ t === u.value || e.items.length === 0 || (u.value = t, I("update:activeIndex", t), I("change", {
958
+ index: t,
959
+ item: e.items[t]
960
+ }), t === 0 && I("reachStart"), t === j.value && I("reachEnd"), ne(), e.autoplay && !E.value && h());
961
+ }
962
+ function X(s, t = {}) {
963
+ const a = m.value;
964
+ a && (typeof a.scrollTo == "function" ? a.scrollTo({ ...t, left: s }) : a.scrollLeft = s);
965
+ }
966
+ function ie(s, t = {}) {
967
+ if (e.items.length === 0 || x.value <= 0) return;
968
+ const a = B(s), l = Math.abs(a - u.value), y = t.behavior === "smooth" && l > F.value ? "auto" : t.behavior;
969
+ C = y === "smooth" ? a : void 0, se(a), X(a * x.value, {
970
+ ...t,
971
+ behavior: y
968
972
  });
969
973
  }
970
- function re(d = "smooth") {
971
- j(
972
- u.value + N.value,
973
- { behavior: d }
974
+ function ee(s = "smooth") {
975
+ ie(
976
+ u.value + T.value,
977
+ { behavior: s }
974
978
  );
975
979
  }
976
- function se(d = "smooth") {
977
- j(
978
- u.value - N.value,
979
- { behavior: d }
980
+ function de(s = "smooth") {
981
+ ie(
982
+ u.value - T.value,
983
+ { behavior: s }
980
984
  );
981
985
  }
982
- function ne(d) {
983
- if (I.value <= 0) return;
984
- const s = d.currentTarget.scrollLeft;
985
- v(Math.round(s / I.value));
986
+ function h() {
987
+ v(), !(!e.autoplay || e.items.length === 0) && (R = setTimeout(() => {
988
+ u.value >= j.value ? e.autoplayLoop ? ie(0, { behavior: "smooth" }) : v() : ee("smooth");
989
+ }, J.value));
990
+ }
991
+ function v() {
992
+ R !== void 0 && (clearTimeout(R), R = void 0);
986
993
  }
987
- function fe(d) {
988
- d.key === "ArrowRight" || d.key === "PageDown" ? (d.preventDefault(), re()) : d.key === "ArrowLeft" || d.key === "PageUp" ? (d.preventDefault(), se()) : d.key === "Home" ? (d.preventDefault(), j(0, { behavior: "smooth" })) : d.key === "End" && (d.preventDefault(), j(U.value, { behavior: "auto" }));
994
+ function o() {
995
+ E.value = !0, e.pauseOnHover && v();
989
996
  }
990
- function le() {
991
- var s;
992
- const d = ((s = g.value) == null ? void 0 : s.clientWidth) ?? 0;
993
- d <= 0 || d === x.value || (x.value = d, $(() => {
994
- L(u.value * I.value);
997
+ function d() {
998
+ E.value = !1, e.autoplay && h();
999
+ }
1000
+ function r() {
1001
+ C = void 0;
1002
+ }
1003
+ function K(s) {
1004
+ if (x.value <= 0) return;
1005
+ const t = s.currentTarget.scrollLeft;
1006
+ if (C !== void 0) {
1007
+ const a = C * x.value;
1008
+ if (Math.abs(t - a) > 1) return;
1009
+ C = void 0;
1010
+ }
1011
+ se(Math.round(t / x.value));
1012
+ }
1013
+ function D(s) {
1014
+ s.key === "ArrowRight" || s.key === "PageDown" ? (s.preventDefault(), ee()) : s.key === "ArrowLeft" || s.key === "PageUp" ? (s.preventDefault(), de()) : s.key === "Home" ? (s.preventDefault(), ie(0, { behavior: "smooth" })) : s.key === "End" && (s.preventDefault(), ie(j.value, { behavior: "auto" }));
1015
+ }
1016
+ function W() {
1017
+ var t;
1018
+ const s = ((t = m.value) == null ? void 0 : t.clientWidth) ?? 0;
1019
+ s <= 0 || s === w.value || (w.value = s, k(() => {
1020
+ X(u.value * x.value);
995
1021
  }));
996
1022
  }
997
- return ae(
1023
+ return Z(
998
1024
  () => e.activeIndex,
999
- async (d) => {
1000
- const s = oe(d);
1001
- s !== u.value && (u.value = s, await $(), L(s * I.value), c());
1025
+ async (s) => {
1026
+ const t = B(s);
1027
+ t !== u.value && (r(), u.value = t, await k(), X(t * x.value), ne());
1002
1028
  }
1003
- ), ae(
1029
+ ), Z(
1004
1030
  () => [
1005
1031
  e.items.length,
1006
1032
  e.slidesPerView,
1007
1033
  e.gap
1008
1034
  ],
1009
1035
  async () => {
1010
- const d = oe(u.value);
1011
- e.items.length === 0 ? u.value !== 0 && (u.value = 0, S("update:activeIndex", 0)) : v(d), await $(), L(d * I.value), c();
1036
+ const s = B(u.value);
1037
+ e.items.length === 0 ? u.value !== 0 && (u.value = 0, I("update:activeIndex", 0)) : se(s), await k(), X(s * x.value), ne(), e.autoplay && e.items.length > 0 && !E.value && h();
1012
1038
  }
1013
- ), ae(
1039
+ ), Z(
1014
1040
  () => [
1015
1041
  e.hasMore,
1016
1042
  e.loading,
1017
1043
  e.loadMoreThreshold
1018
1044
  ],
1019
- async ([d]) => {
1020
- d || (P = -1), await $(), c();
1045
+ async ([s]) => {
1046
+ s || (N = -1), await k(), ne();
1047
+ }
1048
+ ), Z(
1049
+ () => e.autoplay,
1050
+ (s) => {
1051
+ s && !E.value ? h() : v();
1052
+ }
1053
+ ), Z(
1054
+ () => e.autoplayDelay,
1055
+ () => {
1056
+ e.autoplay && !E.value && h();
1057
+ }
1058
+ ), Z(
1059
+ () => e.autoplayLoop,
1060
+ (s) => {
1061
+ !e.autoplay || E.value || (!s && u.value >= j.value ? v() : h());
1062
+ }
1063
+ ), Z(
1064
+ () => e.pauseOnHover,
1065
+ (s) => {
1066
+ s && E.value ? v() : !s && e.autoplay && h();
1021
1067
  }
1022
1068
  ), pe(async () => {
1023
- le(), typeof ResizeObserver < "u" && g.value && (V = new ResizeObserver(le), V.observe(g.value)), await $(), L(u.value * I.value), c();
1069
+ W(), typeof ResizeObserver < "u" && m.value && (L = new ResizeObserver(W), L.observe(m.value)), await k(), X(u.value * x.value), ne(), e.autoplay && h();
1024
1070
  }), ye(() => {
1025
- V == null || V.disconnect();
1026
- }), W({
1027
- next: re,
1028
- previous: se,
1029
- scrollToIndex: j
1030
- }), (d, s) => (w(), b("div", {
1071
+ L == null || L.disconnect(), v();
1072
+ }), _({
1073
+ next: ee,
1074
+ previous: de,
1075
+ scrollToIndex: ie,
1076
+ startAutoplay: h,
1077
+ stopAutoplay: v
1078
+ }), (s, t) => (b(), S("div", {
1031
1079
  ref_key: "viewport",
1032
- ref: g,
1080
+ ref: m,
1033
1081
  class: "vue-virtual-carousel",
1034
- style: C(_.value),
1082
+ style: A(g.value),
1035
1083
  role: "region",
1036
1084
  "aria-roledescription": "carousel",
1037
1085
  "aria-label": n.ariaLabel,
1038
1086
  tabindex: "0",
1039
- onScrollPassive: ne,
1040
- onKeydown: fe
1087
+ onScrollPassive: K,
1088
+ onPointerdown: r,
1089
+ onWheelPassive: r,
1090
+ onKeydown: D,
1091
+ onMouseenter: o,
1092
+ onMouseleave: d
1041
1093
  }, [
1042
- n.items.length ? (w(), b("div", _e, [
1043
- G.value > 0 ? (w(), b("div", {
1094
+ n.items.length ? (b(), S("div", _e, [
1095
+ O.value > 0 ? (b(), S("div", {
1044
1096
  key: 0,
1045
1097
  class: "vue-virtual-carousel__spacer",
1046
- style: C({ flexBasis: `${G.value}px` }),
1098
+ style: A({ flexBasis: `${O.value}px` }),
1047
1099
  "aria-hidden": "true"
1048
1100
  }, null, 4)) : he("", !0),
1049
- (w(!0), b(ve, null, Me(z.value, ({ item: h, index: a }) => (w(), b("div", {
1050
- key: m(O)(h, a),
1101
+ (b(!0), S(me, null, Me(U.value, ({ item: a, index: l }) => (b(), S("div", {
1102
+ key: f(M)(a, l),
1051
1103
  class: "vue-virtual-carousel__item",
1052
- style: C({
1053
- flexBasis: `${F.value}px`,
1054
- marginRight: a < n.items.length - 1 ? `${p.value}px` : "0px"
1104
+ style: A({
1105
+ flexBasis: `${V.value}px`,
1106
+ marginRight: l < n.items.length - 1 ? `${$.value}px` : "0px"
1055
1107
  }),
1056
1108
  role: "listitem",
1057
1109
  "aria-roledescription": "slide",
1058
- "aria-label": `${a + 1} of ${n.items.length}`,
1059
- "aria-current": a === u.value ? "true" : void 0
1110
+ "aria-label": `${l + 1} of ${n.items.length}`,
1111
+ "aria-current": l === u.value ? "true" : void 0
1060
1112
  }, [
1061
- X(d.$slots, "default", {
1062
- item: h,
1063
- index: a,
1064
- active: a === u.value,
1065
- visible: Y(a)
1113
+ le(s.$slots, "default", {
1114
+ item: a,
1115
+ index: l,
1116
+ active: l === u.value,
1117
+ visible: oe(l)
1066
1118
  })
1067
1119
  ], 12, Ue))), 128)),
1068
- J.value > 0 ? (w(), b("div", {
1120
+ c.value > 0 ? (b(), S("div", {
1069
1121
  key: 1,
1070
1122
  class: "vue-virtual-carousel__spacer",
1071
- style: C({ flexBasis: `${J.value}px` }),
1123
+ style: A({ flexBasis: `${c.value}px` }),
1072
1124
  "aria-hidden": "true"
1073
1125
  }, null, 4)) : he("", !0)
1074
- ])) : (w(), b("div", je, [
1075
- X(d.$slots, "empty")
1126
+ ])) : (b(), S("div", je, [
1127
+ le(s.$slots, "empty")
1076
1128
  ]))
1077
1129
  ], 44, We));
1078
1130
  }
@@ -1095,206 +1147,206 @@ const Ae = ["aria-label"], Pe = ["aria-posinset", "aria-setsize"], Le = /* @__PU
1095
1147
  pullRefreshThreshold: { default: 64 }
1096
1148
  },
1097
1149
  emits: ["scroll", "loadMore", "refresh"],
1098
- setup(n, { expose: W, emit: k }) {
1099
- const e = n, S = k, {
1100
- pulling: g,
1101
- pullDistance: x,
1150
+ setup(n, { expose: _, emit: H }) {
1151
+ const e = n, I = H, {
1152
+ pulling: m,
1153
+ pullDistance: w,
1102
1154
  pullOffset: u,
1103
- pullProgress: V,
1104
- refreshMessage: P,
1105
- refreshThreshold: O,
1106
- handleTouchStart: E,
1107
- handleTouchMove: N,
1108
- handleTouchEnd: p,
1109
- handleTouchCancel: H
1155
+ pullProgress: L,
1156
+ refreshMessage: N,
1157
+ refreshThreshold: R,
1158
+ handleTouchStart: C,
1159
+ handleTouchMove: E,
1160
+ handleTouchEnd: M,
1161
+ handleTouchCancel: z
1110
1162
  } = He({
1111
1163
  enabled: () => e.pullToRefresh,
1112
1164
  refreshing: () => e.refreshing,
1113
1165
  threshold: () => e.pullRefreshThreshold,
1114
- onRefresh: () => S("refresh")
1115
- }), T = A(), B = A(0), F = A(0);
1116
- let I, U = -1;
1117
- const ee = be(), { getItemKey: K } = xe({
1166
+ onRefresh: () => I("refresh")
1167
+ }), T = P(), $ = P(0), F = P(0);
1168
+ let Y, J = -1;
1169
+ const ae = be(), { getItemKey: V } = xe({
1118
1170
  componentName: "VirtualScroll",
1119
1171
  items: () => e.items,
1120
1172
  itemKey: () => e.itemKey
1121
- }), z = i(() => Math.max(1, e.itemSize)), te = i(() => Math.max(0, Math.floor(e.overscan))), G = i(
1122
- () => e.items.length * z.value
1123
- ), J = i(
1124
- () => Math.max(1, e.loadingItemSize ?? z.value)
1125
- ), _ = i(
1126
- () => G.value + (e.loading ? J.value : 0)
1127
- ), oe = i(() => F.value > 0 ? F.value : typeof e.height == "number" ? e.height : 0), Y = i(
1173
+ }), x = i(() => Math.max(1, e.itemSize)), j = i(() => Math.max(0, Math.floor(e.overscan))), q = i(
1174
+ () => e.items.length * x.value
1175
+ ), Q = i(
1176
+ () => Math.max(1, e.loadingItemSize ?? x.value)
1177
+ ), U = i(
1178
+ () => q.value + (e.loading ? Q.value : 0)
1179
+ ), ue = i(() => F.value > 0 ? F.value : typeof e.height == "number" ? e.height : 0), O = i(
1128
1180
  () => Math.max(
1129
1181
  0,
1130
- Math.floor(B.value / z.value) - te.value
1182
+ Math.floor($.value / x.value) - j.value
1131
1183
  )
1132
1184
  ), c = i(() => {
1133
- const s = Math.ceil(
1134
- (B.value + oe.value) / z.value
1185
+ const h = Math.ceil(
1186
+ ($.value + ue.value) / x.value
1135
1187
  );
1136
1188
  return Math.min(
1137
1189
  e.items.length,
1138
- s + te.value
1190
+ h + j.value
1139
1191
  );
1140
- }), v = i(
1141
- () => e.items.slice(Y.value, c.value).map((s, h) => ({
1142
- item: s,
1143
- index: Y.value + h
1192
+ }), g = i(
1193
+ () => e.items.slice(O.value, c.value).map((h, v) => ({
1194
+ item: h,
1195
+ index: O.value + v
1144
1196
  }))
1145
- ), L = i(() => ({
1197
+ ), B = i(() => ({
1146
1198
  height: we(e.height)
1147
- })), j = i(() => ({
1148
- transform: `translateY(${Y.value * z.value}px)`
1199
+ })), oe = i(() => ({
1200
+ transform: `translateY(${O.value * x.value}px)`
1149
1201
  }));
1150
- function re() {
1151
- var s;
1152
- F.value = ((s = T.value) == null ? void 0 : s.clientHeight) ?? 0, ee(T.value, e.height), $(ne);
1202
+ function ne() {
1203
+ var h;
1204
+ F.value = ((h = T.value) == null ? void 0 : h.clientHeight) ?? 0, ae(T.value, e.height), k(X);
1153
1205
  }
1154
- function se(s) {
1155
- B.value = s.currentTarget.scrollTop, S("scroll", {
1156
- scrollTop: B.value,
1157
- startIndex: Y.value,
1206
+ function se(h) {
1207
+ $.value = h.currentTarget.scrollTop, I("scroll", {
1208
+ scrollTop: $.value,
1209
+ startIndex: O.value,
1158
1210
  endIndex: c.value
1159
- }), ne();
1211
+ }), X();
1160
1212
  }
1161
- function ne() {
1162
- const s = T.value;
1163
- if (!s || !e.hasMore || e.loading || U === e.items.length)
1213
+ function X() {
1214
+ const h = T.value;
1215
+ if (!h || !e.hasMore || e.loading || J === e.items.length)
1164
1216
  return;
1165
- const h = Math.max(0, e.loadMoreThreshold);
1166
- _.value - s.scrollTop - s.clientHeight <= h && (U = e.items.length, S("loadMore"));
1167
- }
1168
- function fe(s, h = {}) {
1169
- const a = T.value;
1170
- if (!a) return;
1171
- const f = Math.max(0, _.value - a.clientHeight), r = Math.min(
1172
- Math.max(0, Number.isFinite(s) ? s : 0),
1173
- f
1174
- ), D = h.behavior ?? "auto";
1175
- D === "auto" && (B.value = r), a.scrollTo({ ...h, top: r, behavior: D });
1176
- }
1177
- function le(s, h = {}) {
1178
- const a = T.value;
1179
- if (!a || e.items.length === 0) return;
1180
- const f = Math.min(
1217
+ const v = Math.max(0, e.loadMoreThreshold);
1218
+ U.value - h.scrollTop - h.clientHeight <= v && (J = e.items.length, I("loadMore"));
1219
+ }
1220
+ function ie(h, v = {}) {
1221
+ const o = T.value;
1222
+ if (!o) return;
1223
+ const d = Math.max(0, U.value - o.clientHeight), r = Math.min(
1224
+ Math.max(0, Number.isFinite(h) ? h : 0),
1225
+ d
1226
+ ), K = v.behavior ?? "auto";
1227
+ K === "auto" && ($.value = r), o.scrollTo({ ...v, top: r, behavior: K });
1228
+ }
1229
+ function ee(h, v = {}) {
1230
+ const o = T.value;
1231
+ if (!o || e.items.length === 0) return;
1232
+ const d = Math.min(
1181
1233
  e.items.length - 1,
1182
- Math.max(0, Math.floor(s))
1183
- ), { align: r = "start", ...D } = h;
1184
- let R = f * z.value;
1185
- r === "center" ? R -= (a.clientHeight - z.value) / 2 : r === "end" && (R -= a.clientHeight - z.value), a.scrollTo({
1186
- ...D,
1187
- top: Math.max(0, Math.min(R, _.value - a.clientHeight))
1234
+ Math.max(0, Math.floor(h))
1235
+ ), { align: r = "start", ...K } = v;
1236
+ let D = d * x.value;
1237
+ r === "center" ? D -= (o.clientHeight - x.value) / 2 : r === "end" && (D -= o.clientHeight - x.value), o.scrollTo({
1238
+ ...K,
1239
+ top: Math.max(0, Math.min(D, U.value - o.clientHeight))
1188
1240
  });
1189
1241
  }
1190
- function d(s = "auto") {
1191
- var h;
1192
- (h = T.value) == null || h.scrollTo({ top: 0, behavior: s });
1242
+ function de(h = "auto") {
1243
+ var v;
1244
+ (v = T.value) == null || v.scrollTo({ top: 0, behavior: h });
1193
1245
  }
1194
- return ae(
1246
+ return Z(
1195
1247
  () => [e.items.length, e.itemSize],
1196
1248
  async () => {
1197
- await $();
1198
- const s = T.value;
1199
- if (!s) return;
1200
- const h = Math.max(0, _.value - s.clientHeight);
1201
- s.scrollTop > h && (s.scrollTop = h, B.value = h), ne();
1249
+ await k();
1250
+ const h = T.value;
1251
+ if (!h) return;
1252
+ const v = Math.max(0, U.value - h.clientHeight);
1253
+ h.scrollTop > v && (h.scrollTop = v, $.value = v), X();
1202
1254
  }
1203
- ), ae(
1255
+ ), Z(
1204
1256
  () => [e.hasMore, e.loading],
1205
- async ([s]) => {
1206
- s || (U = -1), await $(), ne();
1257
+ async ([h]) => {
1258
+ h || (J = -1), await k(), X();
1207
1259
  }
1208
1260
  ), pe(() => {
1209
- re(), typeof ResizeObserver < "u" && T.value && (I = new ResizeObserver(re), I.observe(T.value)), $(ne);
1261
+ ne(), typeof ResizeObserver < "u" && T.value && (Y = new ResizeObserver(ne), Y.observe(T.value)), k(X);
1210
1262
  }), ye(() => {
1211
- I == null || I.disconnect();
1212
- }), W({
1213
- scrollTo: fe,
1214
- scrollToIndex: le,
1215
- scrollToTop: d
1216
- }), (s, h) => (w(), b("div", {
1263
+ Y == null || Y.disconnect();
1264
+ }), _({
1265
+ scrollTo: ie,
1266
+ scrollToIndex: ee,
1267
+ scrollToTop: de
1268
+ }), (h, v) => (b(), S("div", {
1217
1269
  ref_key: "viewport",
1218
1270
  ref: T,
1219
- class: $e(["vue-virtual-scroll", { "vue-virtual-scroll--pulling": m(g) }]),
1220
- style: C(L.value),
1271
+ class: $e(["vue-virtual-scroll", { "vue-virtual-scroll--pulling": f(m) }]),
1272
+ style: A(B.value),
1221
1273
  role: "list",
1222
1274
  "aria-label": n.ariaLabel,
1223
1275
  tabindex: "0",
1224
1276
  onScrollPassive: se,
1225
- onTouchstartPassive: h[0] || (h[0] = //@ts-ignore
1226
- (...a) => m(E) && m(E)(...a)),
1227
- onTouchmove: h[1] || (h[1] = //@ts-ignore
1228
- (...a) => m(N) && m(N)(...a)),
1229
- onTouchend: h[2] || (h[2] = //@ts-ignore
1230
- (...a) => m(p) && m(p)(...a)),
1231
- onTouchcancel: h[3] || (h[3] = //@ts-ignore
1232
- (...a) => m(H) && m(H)(...a))
1277
+ onTouchstartPassive: v[0] || (v[0] = //@ts-ignore
1278
+ (...o) => f(C) && f(C)(...o)),
1279
+ onTouchmove: v[1] || (v[1] = //@ts-ignore
1280
+ (...o) => f(E) && f(E)(...o)),
1281
+ onTouchend: v[2] || (v[2] = //@ts-ignore
1282
+ (...o) => f(M) && f(M)(...o)),
1283
+ onTouchcancel: v[3] || (v[3] = //@ts-ignore
1284
+ (...o) => f(z) && f(z)(...o))
1233
1285
  }, [
1234
- n.pullToRefresh || n.refreshing ? (w(), b("div", {
1286
+ n.pullToRefresh || n.refreshing ? (b(), S("div", {
1235
1287
  key: 0,
1236
1288
  class: "vue-virtual-scroll__refresh",
1237
- style: C({
1238
- height: `${m(O)}px`,
1239
- transform: `translateY(${m(u) - m(O)}px)`
1289
+ style: A({
1290
+ height: `${f(R)}px`,
1291
+ transform: `translateY(${f(u) - f(R)}px)`
1240
1292
  }),
1241
1293
  role: "status",
1242
1294
  "aria-live": "polite"
1243
1295
  }, [
1244
- X(s.$slots, "refresh", {
1245
- pullDistance: m(x),
1246
- progress: m(V),
1296
+ le(h.$slots, "refresh", {
1297
+ pullDistance: f(w),
1298
+ progress: f(L),
1247
1299
  refreshing: n.refreshing
1248
1300
  }, () => [
1249
- me(ke(m(P)), 1)
1301
+ ve(ke(f(N)), 1)
1250
1302
  ])
1251
1303
  ], 4)) : he("", !0),
1252
- n.items.length || n.loading ? (w(), b("div", {
1304
+ n.items.length || n.loading ? (b(), S("div", {
1253
1305
  key: 1,
1254
1306
  class: "vue-virtual-scroll__spacer",
1255
- style: C({
1256
- height: `${_.value}px`,
1257
- transform: `translateY(${m(u)}px)`
1307
+ style: A({
1308
+ height: `${U.value}px`,
1309
+ transform: `translateY(${f(u)}px)`
1258
1310
  })
1259
1311
  }, [
1260
1312
  Be("div", {
1261
1313
  class: "vue-virtual-scroll__content",
1262
- style: C(j.value)
1314
+ style: A(oe.value)
1263
1315
  }, [
1264
- (w(!0), b(ve, null, Me(v.value, ({ item: a, index: f }) => (w(), b("div", {
1265
- key: m(K)(a, f),
1316
+ (b(!0), S(me, null, Me(g.value, ({ item: o, index: d }) => (b(), S("div", {
1317
+ key: f(V)(o, d),
1266
1318
  class: "vue-virtual-scroll__item",
1267
- style: C({ height: `${z.value}px` }),
1319
+ style: A({ height: `${x.value}px` }),
1268
1320
  role: "listitem",
1269
- "aria-posinset": f + 1,
1321
+ "aria-posinset": d + 1,
1270
1322
  "aria-setsize": n.items.length
1271
1323
  }, [
1272
- X(s.$slots, "default", {
1273
- item: a,
1274
- index: f
1324
+ le(h.$slots, "default", {
1325
+ item: o,
1326
+ index: d
1275
1327
  })
1276
1328
  ], 12, Ge))), 128))
1277
1329
  ], 4),
1278
- n.loading ? (w(), b("div", {
1330
+ n.loading ? (b(), S("div", {
1279
1331
  key: 0,
1280
1332
  class: "vue-virtual-scroll__loading",
1281
- style: C({
1282
- height: `${J.value}px`,
1283
- transform: `translateY(${G.value}px)`
1333
+ style: A({
1334
+ height: `${Q.value}px`,
1335
+ transform: `translateY(${q.value}px)`
1284
1336
  }),
1285
1337
  role: "status",
1286
1338
  "aria-live": "polite"
1287
1339
  }, [
1288
- X(s.$slots, "loading", {}, () => [
1289
- h[4] || (h[4] = me("Loading more…", -1))
1340
+ le(h.$slots, "loading", {}, () => [
1341
+ v[4] || (v[4] = ve("Loading more…", -1))
1290
1342
  ])
1291
1343
  ], 4)) : he("", !0)
1292
- ], 4)) : (w(), b("div", {
1344
+ ], 4)) : (b(), S("div", {
1293
1345
  key: 2,
1294
1346
  class: "vue-virtual-scroll__empty",
1295
- style: C({ transform: `translateY(${m(u)}px)` })
1347
+ style: A({ transform: `translateY(${f(u)}px)` })
1296
1348
  }, [
1297
- X(s.$slots, "empty")
1349
+ le(h.$slots, "empty")
1298
1350
  ], 4))
1299
1351
  ], 46, qe));
1300
1352
  }
@@ -1316,85 +1368,85 @@ const Ae = ["aria-label"], Pe = ["aria-posinset", "aria-setsize"], Le = /* @__PU
1316
1368
  pullRefreshThreshold: { default: 64 }
1317
1369
  },
1318
1370
  emits: ["scroll", "loadMore", "refresh"],
1319
- setup(n, { expose: W, emit: k }) {
1320
- const e = n, S = k, g = A(), x = A(0), u = A(0), V = A(0), P = A(0), O = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map();
1321
- let N, p, H = -1;
1371
+ setup(n, { expose: _, emit: H }) {
1372
+ const e = n, I = H, m = P(), w = P(0), u = P(0), L = P(0), N = P(0), R = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map();
1373
+ let E, M, z = -1;
1322
1374
  const { getItemKey: T } = xe({
1323
1375
  componentName: "WindowDynamicVirtualScroll",
1324
1376
  items: () => e.items,
1325
1377
  itemKey: () => e.itemKey
1326
1378
  }), {
1327
- pulling: B,
1379
+ pulling: $,
1328
1380
  pullDistance: F,
1329
- pullOffset: I,
1330
- pullProgress: U,
1331
- refreshMessage: ee,
1332
- refreshThreshold: K,
1333
- handleTouchStart: z,
1334
- handleTouchMove: te,
1335
- handleTouchEnd: G,
1336
- handleTouchCancel: J
1381
+ pullOffset: Y,
1382
+ pullProgress: J,
1383
+ refreshMessage: ae,
1384
+ refreshThreshold: V,
1385
+ handleTouchStart: x,
1386
+ handleTouchMove: j,
1387
+ handleTouchEnd: q,
1388
+ handleTouchCancel: Q
1337
1389
  } = He({
1338
1390
  enabled: () => e.pullToRefresh,
1339
1391
  refreshing: () => e.refreshing,
1340
1392
  threshold: () => e.pullRefreshThreshold,
1341
- onRefresh: () => S("refresh"),
1393
+ onRefresh: () => I("refresh"),
1342
1394
  scrollTop: () => typeof window > "u" ? 0 : Math.max(0, window.scrollY)
1343
- }), _ = i(
1395
+ }), U = i(
1344
1396
  () => Math.max(1, e.estimatedItemSize)
1345
- ), oe = i(
1346
- () => Math.max(1, e.loadingItemSize ?? _.value)
1347
- ), Y = i(() => Math.max(0, Math.floor(e.overscan))), c = i(() => {
1348
- P.value;
1349
- const t = new Array(e.items.length + 1), o = new Array(e.items.length);
1397
+ ), ue = i(
1398
+ () => Math.max(1, e.loadingItemSize ?? U.value)
1399
+ ), O = i(() => Math.max(0, Math.floor(e.overscan))), c = i(() => {
1400
+ N.value;
1401
+ const t = new Array(e.items.length + 1), a = new Array(e.items.length);
1350
1402
  t[0] = 0;
1351
1403
  for (let l = 0; l < e.items.length; l += 1) {
1352
- const M = T(e.items[l], l), y = O.get(M) ?? _.value;
1353
- o[l] = y, t[l + 1] = t[l] + y;
1404
+ const y = T(e.items[l], l), p = R.get(y) ?? U.value;
1405
+ a[l] = p, t[l + 1] = t[l] + p;
1354
1406
  }
1355
1407
  return {
1356
1408
  offsets: t,
1357
- sizes: o,
1409
+ sizes: a,
1358
1410
  total: t[e.items.length] ?? 0
1359
1411
  };
1360
- }), v = i(
1361
- () => c.value.total + (e.loading ? oe.value : 0)
1362
- ), L = i(() => {
1412
+ }), g = i(
1413
+ () => c.value.total + (e.loading ? ue.value : 0)
1414
+ ), B = i(() => {
1363
1415
  const t = /* @__PURE__ */ new Map();
1364
- return e.items.forEach((o, l) => {
1365
- t.set(T(o, l), l);
1416
+ return e.items.forEach((a, l) => {
1417
+ t.set(T(a, l), l);
1366
1418
  }), t;
1367
- }), j = i(
1368
- () => Math.max(0, x.value - V.value)
1419
+ }), oe = i(
1420
+ () => Math.max(0, w.value - L.value)
1369
1421
  );
1370
- function re(t) {
1422
+ function ne(t) {
1371
1423
  if (e.items.length === 0) return 0;
1372
- const o = c.value.offsets;
1373
- let l = 0, M = e.items.length;
1374
- for (; l < M; ) {
1375
- const y = Math.floor((l + M) / 2);
1376
- o[y + 1] <= t ? l = y + 1 : M = y;
1424
+ const a = c.value.offsets;
1425
+ let l = 0, y = e.items.length;
1426
+ for (; l < y; ) {
1427
+ const p = Math.floor((l + y) / 2);
1428
+ a[p + 1] <= t ? l = p + 1 : y = p;
1377
1429
  }
1378
1430
  return Math.min(l, e.items.length - 1);
1379
1431
  }
1380
1432
  const se = i(
1381
1433
  () => Math.max(
1382
1434
  0,
1383
- re(j.value) - Y.value
1435
+ ne(oe.value) - O.value
1384
1436
  )
1385
- ), ne = i(() => {
1437
+ ), X = i(() => {
1386
1438
  if (e.items.length === 0) return 0;
1387
- const t = x.value + u.value - V.value, o = Math.max(
1388
- _.value,
1439
+ const t = w.value + u.value - L.value, a = Math.max(
1440
+ U.value,
1389
1441
  t
1390
- ), l = re(o) + 1;
1442
+ ), l = ne(a) + 1;
1391
1443
  return Math.min(
1392
1444
  e.items.length,
1393
- l + Y.value
1445
+ l + O.value
1394
1446
  );
1395
- }), fe = i(
1396
- () => e.items.slice(se.value, ne.value).map((t, o) => {
1397
- const l = se.value + o;
1447
+ }), ie = i(
1448
+ () => e.items.slice(se.value, X.value).map((t, a) => {
1449
+ const l = se.value + a;
1398
1450
  return {
1399
1451
  item: t,
1400
1452
  index: l,
@@ -1403,220 +1455,220 @@ const Ae = ["aria-label"], Pe = ["aria-posinset", "aria-setsize"], Le = /* @__PU
1403
1455
  };
1404
1456
  })
1405
1457
  );
1406
- function le() {
1407
- typeof window > "u" || (x.value = Math.max(0, window.scrollY), u.value = window.innerHeight, g.value && (V.value = g.value.getBoundingClientRect().top + x.value));
1458
+ function ee() {
1459
+ typeof window > "u" || (w.value = Math.max(0, window.scrollY), u.value = window.innerHeight, m.value && (L.value = m.value.getBoundingClientRect().top + w.value));
1408
1460
  }
1409
- function d() {
1410
- S("scroll", {
1411
- scrollTop: j.value,
1461
+ function de() {
1462
+ I("scroll", {
1463
+ scrollTop: oe.value,
1412
1464
  startIndex: se.value,
1413
- endIndex: ne.value
1465
+ endIndex: X.value
1414
1466
  });
1415
1467
  }
1416
- function s() {
1417
- le(), d(), h();
1418
- }
1419
1468
  function h() {
1420
- if (typeof window > "u" || !e.hasMore || e.loading || H === e.items.length)
1469
+ ee(), de(), v();
1470
+ }
1471
+ function v() {
1472
+ if (typeof window > "u" || !e.hasMore || e.loading || z === e.items.length)
1421
1473
  return;
1422
- const t = Math.max(0, e.loadMoreThreshold), o = V.value + v.value, l = x.value + u.value;
1423
- o - l <= t && (H = e.items.length, S("loadMore"));
1474
+ const t = Math.max(0, e.loadMoreThreshold), a = L.value + g.value, l = w.value + u.value;
1475
+ a - l <= t && (z = e.items.length, I("loadMore"));
1424
1476
  }
1425
- function a(t) {
1426
- const o = t.borderBoxSize;
1427
- if (o) {
1428
- const l = Array.isArray(o) ? o[0] : o;
1477
+ function o(t) {
1478
+ const a = t.borderBoxSize;
1479
+ if (a) {
1480
+ const l = Array.isArray(a) ? a[0] : a;
1429
1481
  if (l != null && l.blockSize) return l.blockSize;
1430
1482
  }
1431
1483
  return t.contentRect.height;
1432
1484
  }
1433
- function f(t) {
1434
- const o = c.value;
1435
- let l = 0, M = !1;
1436
- for (const y of t) {
1437
- const Q = y.target, q = E.get(Q), ie = a(y);
1438
- if (q === void 0 || ie <= 0) continue;
1439
- const ce = O.get(q) ?? _.value;
1440
- if (Math.abs(ce - ie) < 0.5) continue;
1441
- const de = L.value.get(q);
1442
- de !== void 0 && o.offsets[de + 1] <= j.value && (l += ie - ce), O.set(q, ie), M = !0;
1485
+ function d(t) {
1486
+ const a = c.value;
1487
+ let l = 0, y = !1;
1488
+ for (const p of t) {
1489
+ const te = p.target, G = C.get(te), re = o(p);
1490
+ if (G === void 0 || re <= 0) continue;
1491
+ const ce = R.get(G) ?? U.value;
1492
+ if (Math.abs(ce - re) < 0.5) continue;
1493
+ const fe = B.value.get(G);
1494
+ fe !== void 0 && a.offsets[fe + 1] <= oe.value && (l += re - ce), R.set(G, re), y = !0;
1443
1495
  }
1444
- M && (P.value += 1, $(() => {
1496
+ y && (N.value += 1, k(() => {
1445
1497
  if (l !== 0 && typeof window < "u") {
1446
- const y = Math.max(
1498
+ const p = Math.max(
1447
1499
  0,
1448
- x.value + l
1500
+ w.value + l
1449
1501
  );
1450
- x.value = y, window.scrollTo({ top: y, behavior: "auto" });
1502
+ w.value = p, window.scrollTo({ top: p, behavior: "auto" });
1451
1503
  }
1452
- le(), h();
1504
+ ee(), v();
1453
1505
  }));
1454
1506
  }
1455
- function r(t, o) {
1456
- t instanceof HTMLElement && (E.set(t, o), p == null || p.observe(t));
1507
+ function r(t, a) {
1508
+ t instanceof HTMLElement && (C.set(t, a), M == null || M.observe(t));
1457
1509
  }
1458
- function D() {
1459
- for (const [t] of E)
1460
- t.isConnected || (p == null || p.unobserve(t), E.delete(t));
1510
+ function K() {
1511
+ for (const [t] of C)
1512
+ t.isConnected || (M == null || M.unobserve(t), C.delete(t));
1461
1513
  }
1462
- function R(t, o = {}) {
1514
+ function D(t, a = {}) {
1463
1515
  if (typeof window > "u") return;
1464
- le();
1465
- const l = Math.max(0, v.value - u.value), M = Math.min(
1516
+ ee();
1517
+ const l = Math.max(0, g.value - u.value), y = Math.min(
1466
1518
  Math.max(0, Number.isFinite(t) ? t : 0),
1467
1519
  l
1468
- ), y = Math.max(0, V.value + M), Q = o.behavior ?? "auto";
1469
- Q === "auto" && (x.value = y), window.scrollTo({ ...o, top: y, behavior: Q });
1520
+ ), p = Math.max(0, L.value + y), te = a.behavior ?? "auto";
1521
+ te === "auto" && (w.value = p), window.scrollTo({ ...a, top: p, behavior: te });
1470
1522
  }
1471
- function Z(t, o = {}) {
1523
+ function W(t, a = {}) {
1472
1524
  if (typeof window > "u" || e.items.length === 0) return;
1473
- le();
1525
+ ee();
1474
1526
  const l = Math.min(
1475
1527
  e.items.length - 1,
1476
1528
  Math.max(0, Math.floor(t))
1477
- ), { align: M = "start", ...y } = o, Q = c.value.sizes[l];
1478
- let q = V.value + c.value.offsets[l];
1479
- M === "center" ? q -= (u.value - Q) / 2 : M === "end" && (q -= u.value - Q);
1480
- const ie = Math.max(
1481
- V.value,
1482
- V.value + v.value - u.value
1483
- ), ce = Math.max(0, Math.min(q, ie)), de = y.behavior ?? "auto", Se = Math.max(
1529
+ ), { align: y = "start", ...p } = a, te = c.value.sizes[l];
1530
+ let G = L.value + c.value.offsets[l];
1531
+ y === "center" ? G -= (u.value - te) / 2 : y === "end" && (G -= u.value - te);
1532
+ const re = Math.max(
1533
+ L.value,
1534
+ L.value + g.value - u.value
1535
+ ), ce = Math.max(0, Math.min(G, re)), fe = p.behavior ?? "auto", Se = Math.max(
1484
1536
  u.value * 3,
1485
- _.value * 10
1486
- ), Te = de === "smooth" && Math.abs(ce - x.value) > Se ? "auto" : de;
1487
- Te === "auto" && (x.value = ce), window.scrollTo({
1488
- ...y,
1537
+ U.value * 10
1538
+ ), Te = fe === "smooth" && Math.abs(ce - w.value) > Se ? "auto" : fe;
1539
+ Te === "auto" && (w.value = ce), window.scrollTo({
1540
+ ...p,
1489
1541
  top: ce,
1490
1542
  behavior: Te
1491
1543
  });
1492
1544
  }
1493
- function ue(t = "auto") {
1494
- typeof window > "u" || (le(), window.scrollTo({ top: Math.max(0, V.value), behavior: t }));
1545
+ function s(t = "auto") {
1546
+ typeof window > "u" || (ee(), window.scrollTo({ top: Math.max(0, L.value), behavior: t }));
1495
1547
  }
1496
- return ae(
1548
+ return Z(
1497
1549
  () => e.itemKey,
1498
1550
  () => {
1499
- O.clear(), P.value += 1;
1551
+ R.clear(), N.value += 1;
1500
1552
  }
1501
- ), ae(
1553
+ ), Z(
1502
1554
  () => e.items.length,
1503
1555
  async () => {
1504
1556
  const t = new Set(
1505
- e.items.map((o, l) => T(o, l))
1557
+ e.items.map((a, l) => T(a, l))
1506
1558
  );
1507
- for (const o of O.keys())
1508
- t.has(o) || O.delete(o);
1509
- P.value += 1, await $(), le(), h();
1559
+ for (const a of R.keys())
1560
+ t.has(a) || R.delete(a);
1561
+ N.value += 1, await k(), ee(), v();
1510
1562
  }
1511
- ), ae(
1563
+ ), Z(
1512
1564
  () => [e.hasMore, e.loading],
1513
1565
  async ([t]) => {
1514
- t || (H = -1), await $(), le(), h();
1566
+ t || (z = -1), await k(), ee(), v();
1515
1567
  }
1516
1568
  ), pe(() => {
1517
- if (le(), window.addEventListener("scroll", s, { passive: !0 }), window.addEventListener("resize", s, { passive: !0 }), typeof ResizeObserver < "u") {
1518
- N = new ResizeObserver(() => {
1519
- le(), h();
1520
- }), p = new ResizeObserver(f), g.value && N.observe(g.value);
1521
- for (const [t] of E)
1522
- p.observe(t);
1569
+ if (ee(), window.addEventListener("scroll", h, { passive: !0 }), window.addEventListener("resize", h, { passive: !0 }), typeof ResizeObserver < "u") {
1570
+ E = new ResizeObserver(() => {
1571
+ ee(), v();
1572
+ }), M = new ResizeObserver(d), m.value && E.observe(m.value);
1573
+ for (const [t] of C)
1574
+ M.observe(t);
1523
1575
  }
1524
- $(h);
1525
- }), ze(D), ye(() => {
1526
- window.removeEventListener("scroll", s), window.removeEventListener("resize", s), N == null || N.disconnect(), p == null || p.disconnect(), E.clear();
1527
- }), W({
1528
- scrollTo: R,
1529
- scrollToIndex: Z,
1530
- scrollToTop: ue
1531
- }), (t, o) => (w(), b("div", {
1576
+ k(v);
1577
+ }), ze(K), ye(() => {
1578
+ window.removeEventListener("scroll", h), window.removeEventListener("resize", h), E == null || E.disconnect(), M == null || M.disconnect(), C.clear();
1579
+ }), _({
1580
+ scrollTo: D,
1581
+ scrollToIndex: W,
1582
+ scrollToTop: s
1583
+ }), (t, a) => (b(), S("div", {
1532
1584
  ref_key: "root",
1533
- ref: g,
1534
- class: $e(["vue-window-dynamic-virtual-scroll", { "vue-window-dynamic-virtual-scroll--pulling": m(B) }]),
1585
+ ref: m,
1586
+ class: $e(["vue-window-dynamic-virtual-scroll", { "vue-window-dynamic-virtual-scroll--pulling": f($) }]),
1535
1587
  role: "list",
1536
1588
  "aria-label": n.ariaLabel,
1537
- onTouchstartPassive: o[0] || (o[0] = //@ts-ignore
1538
- (...l) => m(z) && m(z)(...l)),
1539
- onTouchmove: o[1] || (o[1] = //@ts-ignore
1540
- (...l) => m(te) && m(te)(...l)),
1541
- onTouchend: o[2] || (o[2] = //@ts-ignore
1542
- (...l) => m(G) && m(G)(...l)),
1543
- onTouchcancel: o[3] || (o[3] = //@ts-ignore
1544
- (...l) => m(J) && m(J)(...l))
1589
+ onTouchstartPassive: a[0] || (a[0] = //@ts-ignore
1590
+ (...l) => f(x) && f(x)(...l)),
1591
+ onTouchmove: a[1] || (a[1] = //@ts-ignore
1592
+ (...l) => f(j) && f(j)(...l)),
1593
+ onTouchend: a[2] || (a[2] = //@ts-ignore
1594
+ (...l) => f(q) && f(q)(...l)),
1595
+ onTouchcancel: a[3] || (a[3] = //@ts-ignore
1596
+ (...l) => f(Q) && f(Q)(...l))
1545
1597
  }, [
1546
- n.pullToRefresh || n.refreshing ? (w(), b("div", {
1598
+ n.pullToRefresh || n.refreshing ? (b(), S("div", {
1547
1599
  key: 0,
1548
1600
  class: "vue-window-dynamic-virtual-scroll__refresh",
1549
- style: C({
1550
- height: `${m(K)}px`,
1551
- transform: `translateY(${m(I) - m(K)}px)`
1601
+ style: A({
1602
+ height: `${f(V)}px`,
1603
+ transform: `translateY(${f(Y) - f(V)}px)`
1552
1604
  }),
1553
1605
  role: "status",
1554
1606
  "aria-live": "polite"
1555
1607
  }, [
1556
- X(t.$slots, "refresh", {
1557
- pullDistance: m(F),
1558
- progress: m(U),
1608
+ le(t.$slots, "refresh", {
1609
+ pullDistance: f(F),
1610
+ progress: f(J),
1559
1611
  refreshing: n.refreshing
1560
1612
  }, () => [
1561
- me(ke(m(ee)), 1)
1613
+ ve(ke(f(ae)), 1)
1562
1614
  ])
1563
1615
  ], 4)) : he("", !0),
1564
- n.items.length || n.loading ? (w(), b("div", {
1616
+ n.items.length || n.loading ? (b(), S("div", {
1565
1617
  key: 1,
1566
1618
  class: "vue-window-dynamic-virtual-scroll__spacer",
1567
- style: C({
1568
- height: `${v.value}px`,
1569
- transform: `translateY(${m(I)}px)`
1619
+ style: A({
1620
+ height: `${g.value}px`,
1621
+ transform: `translateY(${f(Y)}px)`
1570
1622
  })
1571
1623
  }, [
1572
- (w(!0), b(ve, null, Me(fe.value, ({ item: l, index: M, key: y, top: Q }) => (w(), b("div", {
1573
- key: y,
1624
+ (b(!0), S(me, null, Me(ie.value, ({ item: l, index: y, key: p, top: te }) => (b(), S("div", {
1625
+ key: p,
1574
1626
  ref_for: !0,
1575
- ref: (q) => r(q, y),
1627
+ ref: (G) => r(G, p),
1576
1628
  class: "vue-window-dynamic-virtual-scroll__item",
1577
- style: C({ transform: `translateY(${Q}px)` }),
1629
+ style: A({ transform: `translateY(${te}px)` }),
1578
1630
  role: "listitem",
1579
- "aria-posinset": M + 1,
1631
+ "aria-posinset": y + 1,
1580
1632
  "aria-setsize": n.items.length
1581
1633
  }, [
1582
- X(t.$slots, "default", {
1634
+ le(t.$slots, "default", {
1583
1635
  item: l,
1584
- index: M
1636
+ index: y
1585
1637
  })
1586
1638
  ], 12, Xe))), 128)),
1587
- n.loading ? (w(), b("div", {
1639
+ n.loading ? (b(), S("div", {
1588
1640
  key: 0,
1589
1641
  class: "vue-window-dynamic-virtual-scroll__loading",
1590
- style: C({
1591
- height: `${oe.value}px`,
1642
+ style: A({
1643
+ height: `${ue.value}px`,
1592
1644
  transform: `translateY(${c.value.total}px)`
1593
1645
  }),
1594
1646
  role: "status",
1595
1647
  "aria-live": "polite"
1596
1648
  }, [
1597
- X(t.$slots, "loading", {}, () => [
1598
- o[4] || (o[4] = me("Loading more…", -1))
1649
+ le(t.$slots, "loading", {}, () => [
1650
+ a[4] || (a[4] = ve("Loading more…", -1))
1599
1651
  ])
1600
1652
  ], 4)) : he("", !0)
1601
- ], 4)) : (w(), b("div", {
1653
+ ], 4)) : (b(), S("div", {
1602
1654
  key: 2,
1603
1655
  class: "vue-window-dynamic-virtual-scroll__empty",
1604
- style: C({ transform: `translateY(${m(I)}px)` })
1656
+ style: A({ transform: `translateY(${f(Y)}px)` })
1605
1657
  }, [
1606
- X(t.$slots, "empty")
1658
+ le(t.$slots, "empty")
1607
1659
  ], 4))
1608
1660
  ], 42, Qe));
1609
1661
  }
1610
1662
  }), tt = Le, at = {
1611
1663
  install(n) {
1612
- n.component("ChatVirtualScroll", Re), n.component("DynamicVirtualScroll", Le), n.component("ShortMediaFeed", Fe), n.component("VirtualCarousel", Ze), n.component("VirtualList", tt), n.component("VirtualScroll", Je), n.component(
1664
+ n.component("ChatVirtualScroll", Ae), n.component("DynamicVirtualScroll", Le), n.component("ShortMediaFeed", Fe), n.component("VirtualCarousel", Ze), n.component("VirtualList", tt), n.component("VirtualScroll", Je), n.component(
1613
1665
  "WindowDynamicVirtualScroll",
1614
1666
  et
1615
1667
  );
1616
1668
  }
1617
1669
  };
1618
1670
  export {
1619
- Re as ChatVirtualScroll,
1671
+ Ae as ChatVirtualScroll,
1620
1672
  Le as DynamicVirtualScroll,
1621
1673
  Fe as ShortMediaFeed,
1622
1674
  Ze as VirtualCarousel,