vue-virtual-flow 0.0.2 → 0.0.4

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