@wyxos/vibe 2.1.6 → 2.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/lib/index.cjs +1 -1
  2. package/lib/index.js +348 -335
  3. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { defineComponent as we, ref as w, computed as I, onMounted as Ee, onUnmounted as Pt, createElementBlock as S, openBlock as k, normalizeStyle as $, createCommentVNode as j, createElementVNode as T, normalizeClass as ht, mergeDefaults as Wt, useAttrs as Ut, shallowRef as gt, provide as Gt, watch as J, mergeProps as Kt, renderSlot as Jt, toDisplayString as pt, Fragment as yt, renderList as wt, createVNode as X, unref as ie, nextTick as xt, inject as Qt } from "vue";
2
- const Zt = {
1
+ import { defineComponent as xe, ref as w, computed as I, onMounted as Ee, onUnmounted as St, createElementBlock as k, openBlock as S, normalizeStyle as $, createCommentVNode as j, createElementVNode as T, normalizeClass as vt, mergeDefaults as jt, useAttrs as Wt, shallowRef as mt, provide as Ut, watch as te, mergeProps as Gt, renderSlot as Kt, toDisplayString as ht, Fragment as gt, renderList as pt, createVNode as X, unref as ce, nextTick as yt, inject as Jt } from "vue";
2
+ const Qt = {
3
3
  mode: "default",
4
4
  pageSize: 20,
5
5
  backfillRequestDelayMs: 2e3,
@@ -11,15 +11,15 @@ const Zt = {
11
11
  headerHeight: 0,
12
12
  footerHeight: 0,
13
13
  overscanPx: 600
14
- }, en = {
14
+ }, Zt = {
15
15
  key: 0,
16
16
  "data-testid": "masonry-loader-spinner",
17
17
  class: "absolute inset-0 flex items-center justify-center"
18
- }, tn = {
18
+ }, en = {
19
19
  key: 1,
20
20
  "data-testid": "masonry-loader-error",
21
21
  class: "absolute inset-0 flex flex-col items-center justify-center gap-2 p-3"
22
- }, nn = ["src", "width", "height", "alt"], on = ["poster"], ln = ["src"], bt = /* @__PURE__ */ we({
22
+ }, tn = ["src", "width", "height", "alt"], nn = ["poster"], on = ["src"], wt = /* @__PURE__ */ xe({
23
23
  __name: "MasonryLoader",
24
24
  props: {
25
25
  item: {},
@@ -27,23 +27,23 @@ const Zt = {
27
27
  },
28
28
  emits: ["success", "error"],
29
29
  setup(o, { emit: g }) {
30
- const u = o, s = g, i = w(null), f = w(!1), c = w(!1), r = w(!1), v = w(0), m = I(() => {
30
+ const u = o, a = g, i = w(null), f = w(!1), c = w(!1), r = w(!1), v = w(0), m = I(() => {
31
31
  const _ = u.item?.width, P = u.item?.height;
32
32
  return { aspectRatio: `${_} / ${P}` };
33
33
  }), M = I(() => u.item?.type === "image");
34
34
  let F = null, B = null;
35
- function N() {
35
+ function C() {
36
36
  B != null && (window.clearTimeout(B), B = null);
37
37
  }
38
- function R() {
39
- N();
38
+ function A() {
39
+ C();
40
40
  const _ = typeof u.timeoutMs == "number" && Number.isFinite(u.timeoutMs) ? u.timeoutMs : 0;
41
41
  _ <= 0 || (B = window.setTimeout(() => {
42
42
  f.value && (c.value || r.value || W(new Error("timeout")));
43
43
  }, _));
44
44
  }
45
45
  function L() {
46
- f.value || (f.value = !0, c.value = !1, r.value = !1, R());
46
+ f.value || (f.value = !0, c.value = !1, r.value = !1, A());
47
47
  }
48
48
  Ee(() => {
49
49
  if (typeof IntersectionObserver > "u") {
@@ -60,25 +60,25 @@ const Zt = {
60
60
  },
61
61
  { threshold: [0, 0.5, 1] }
62
62
  ), i.value && F.observe(i.value);
63
- }), Pt(() => {
64
- F?.disconnect(), F = null, N();
63
+ }), St(() => {
64
+ F?.disconnect(), F = null, C();
65
65
  });
66
- function A() {
67
- c.value || (c.value = !0, r.value = !1, N(), s("success", u.item));
66
+ function N() {
67
+ c.value || (c.value = !0, r.value = !1, C(), a("success", u.item));
68
68
  }
69
69
  function W(_) {
70
- r.value || (c.value = !1, r.value = !0, N(), s("error", { item: u.item, error: _ }));
70
+ r.value || (c.value = !1, r.value = !0, C(), a("error", { item: u.item, error: _ }));
71
71
  }
72
- function O() {
73
- f.value && (c.value = !1, r.value = !1, v.value += 1, R());
72
+ function D() {
73
+ f.value && (c.value = !1, r.value = !1, v.value += 1, A());
74
74
  }
75
- return (_, P) => (k(), S("div", {
75
+ return (_, P) => (S(), k("div", {
76
76
  ref_key: "rootEl",
77
77
  ref: i,
78
78
  class: "relative bg-slate-100",
79
79
  style: $(m.value)
80
80
  }, [
81
- f.value && !c.value && !r.value ? (k(), S("div", en, P[2] || (P[2] = [
81
+ f.value && !c.value && !r.value ? (S(), k("div", Zt, P[2] || (P[2] = [
82
82
  T("svg", {
83
83
  class: "h-5 w-5 animate-spin text-slate-500",
84
84
  viewBox: "0 0 24 24",
@@ -99,18 +99,18 @@ const Zt = {
99
99
  d: "M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"
100
100
  })
101
101
  ], -1)
102
- ]))) : f.value && r.value ? (k(), S("div", tn, [
102
+ ]))) : f.value && r.value ? (S(), k("div", en, [
103
103
  P[3] || (P[3] = T("p", { class: "text-center text-xs font-medium text-red-700" }, "Failed to load", -1)),
104
104
  T("button", {
105
105
  type: "button",
106
106
  "data-testid": "masonry-loader-retry",
107
107
  class: "inline-flex items-center rounded-md border border-slate-200 bg-white px-2 py-1 text-xs font-medium text-slate-700",
108
- onClick: O
108
+ onClick: D
109
109
  }, " Retry ")
110
110
  ])) : j("", !0),
111
- f.value && M.value && !r.value ? (k(), S("img", {
111
+ f.value && M.value && !r.value ? (S(), k("img", {
112
112
  key: u.item.id + ":img:" + v.value,
113
- class: ht([
113
+ class: vt([
114
114
  "h-full w-full object-cover transition-opacity duration-300",
115
115
  c.value ? "opacity-100" : "opacity-0"
116
116
  ]),
@@ -119,49 +119,49 @@ const Zt = {
119
119
  height: u.item.height,
120
120
  loading: "lazy",
121
121
  alt: u.item.id,
122
- onLoad: A,
122
+ onLoad: N,
123
123
  onError: P[0] || (P[0] = (q) => W(q))
124
- }, null, 42, nn)) : f.value && !r.value ? (k(), S("video", {
124
+ }, null, 42, tn)) : f.value && !r.value ? (S(), k("video", {
125
125
  key: u.item.id + ":vid:" + v.value,
126
- class: ht([
126
+ class: vt([
127
127
  "h-full w-full object-cover transition-opacity duration-300",
128
128
  c.value ? "opacity-100" : "opacity-0"
129
129
  ]),
130
130
  poster: u.item.preview,
131
131
  controls: "",
132
132
  preload: "metadata",
133
- onLoadedmetadata: A,
133
+ onLoadedmetadata: N,
134
134
  onError: P[1] || (P[1] = (q) => W(q))
135
135
  }, [
136
136
  T("source", {
137
137
  src: u.item.original,
138
138
  type: "video/mp4"
139
- }, null, 8, ln)
140
- ], 42, on)) : j("", !0)
139
+ }, null, 8, on)
140
+ ], 42, nn)) : j("", !0)
141
141
  ], 4));
142
142
  }
143
- }), Tt = Symbol("masonryItemRegistry");
144
- function sn(o, g) {
143
+ }), Ft = Symbol("masonryItemRegistry");
144
+ function ln(o, g) {
145
145
  return !o || o <= 0 || !g || g <= 0 ? 1 : Math.max(1, Math.floor(o / g));
146
146
  }
147
- function an(o, g, u, s = 0) {
147
+ function an(o, g, u, a = 0) {
148
148
  if (!o || o <= 0 || !g || g <= 0) return u;
149
- const i = typeof s == "number" && s > 0 ? s : 0, f = Math.max(0, g - 1) * i, c = o - f;
149
+ const i = typeof a == "number" && a > 0 ? a : 0, f = Math.max(0, g - 1) * i, c = o - f;
150
150
  return !c || c <= 0 ? u : c / g;
151
151
  }
152
- function rn(o, g) {
153
- const u = o?.width, s = o?.height;
154
- return typeof u == "number" && typeof s == "number" && u > 0 && s > 0 ? s / u * g : g;
152
+ function sn(o, g) {
153
+ const u = o?.width, a = o?.height;
154
+ return typeof u == "number" && typeof a == "number" && u > 0 && a > 0 ? a / u * g : g;
155
155
  }
156
- function _t(o) {
156
+ function Pt(o) {
157
157
  return Number.isFinite(o) && o > 0 ? Math.floor(o) : 1;
158
158
  }
159
159
  function Ne(o) {
160
160
  return Number.isFinite(o) && o > 0 ? Math.floor(o) : 0;
161
161
  }
162
- function un(o) {
163
- async function g(s) {
164
- const i = Ne(s);
162
+ function rn(o) {
163
+ async function g(a) {
164
+ const i = Ne(a);
165
165
  if (i <= 0) return;
166
166
  o.stats.value = {
167
167
  ...o.stats.value,
@@ -180,8 +180,8 @@ function un(o) {
180
180
  }, c);
181
181
  });
182
182
  }
183
- async function u(s) {
184
- const i = _t(o.getPageSize()), f = o.isEnabled(), c = Ne(o.getRequestDelayMs()), r = [];
183
+ async function u(a) {
184
+ const i = Pt(o.getPageSize()), f = o.isEnabled(), c = Ne(o.getRequestDelayMs()), r = [];
185
185
  let v = 0;
186
186
  o.buffer.value.length && (v = o.buffer.value.length, r.push(...o.buffer.value), o.buffer.value = []), o.stats.value = {
187
187
  ...o.stats.value,
@@ -199,7 +199,7 @@ function un(o) {
199
199
  bufferSize: 0
200
200
  };
201
201
  const m = [];
202
- let M = s, F = 0, B = !1;
202
+ let M = a, F = 0, B = !1;
203
203
  for (; r.length < i && M != null; ) {
204
204
  const L = M;
205
205
  B && (o.stats.value = {
@@ -216,14 +216,14 @@ function un(o) {
216
216
  cooldownMsRemaining: 0,
217
217
  pageSize: i
218
218
  });
219
- const A = await o.getContent(L);
219
+ const N = await o.getContent(L);
220
220
  m.push(L), B && (o.stats.value = {
221
221
  ...o.stats.value,
222
222
  enabled: f,
223
223
  isBackfillActive: !0,
224
224
  isRequestInFlight: !1,
225
225
  requestPage: null
226
- }), F += A.items.length, o.markEnterFromLeft(A.items), r.push(...A.items), M = A.nextPage, !B && r.length < i && M != null ? (B = !0, o.stats.value = {
226
+ }), F += N.items.length, o.markEnterFromLeft(N.items), r.push(...N.items), M = N.nextPage, !B && r.length < i && M != null ? (B = !0, o.stats.value = {
227
227
  ...o.stats.value,
228
228
  enabled: f,
229
229
  isBackfillActive: !0,
@@ -246,8 +246,8 @@ function un(o) {
246
246
  }
247
247
  }), B && r.length < i && M != null && await g(c);
248
248
  }
249
- const N = r.slice(0, i), R = r.slice(i);
250
- return o.buffer.value = R, o.stats.value = {
249
+ const C = r.slice(0, i), A = r.slice(i);
250
+ return o.buffer.value = A, o.stats.value = {
251
251
  ...o.stats.value,
252
252
  enabled: f,
253
253
  isBackfillActive: !1,
@@ -260,48 +260,48 @@ function un(o) {
260
260
  cooldownMsTotal: c,
261
261
  cooldownMsRemaining: 0,
262
262
  pageSize: i,
263
- bufferSize: R.length,
263
+ bufferSize: A.length,
264
264
  lastBatch: {
265
- startPage: s,
265
+ startPage: a,
266
266
  pages: m,
267
267
  usedFromBuffer: v,
268
268
  fetchedFromNetwork: F,
269
269
  collectedTotal: r.length,
270
- emitted: N.length,
271
- carried: R.length
270
+ emitted: C.length,
271
+ carried: A.length
272
272
  },
273
273
  totals: {
274
274
  pagesFetched: o.stats.value.totals.pagesFetched + m.length,
275
275
  itemsFetchedFromNetwork: o.stats.value.totals.itemsFetchedFromNetwork + F
276
276
  }
277
- }, { batchItems: N, pages: m, nextPage: M };
277
+ }, { batchItems: C, pages: m, nextPage: M };
278
278
  }
279
279
  return { loadBackfillBatch: u };
280
280
  }
281
- function cn(o) {
282
- const g = o.columnCount, u = o.columnWidth, s = o.gapX, i = o.gapY, f = o.headerHeight, c = o.footerHeight, r = o.bucketPx, v = Array.from({ length: g }, () => 0), m = new Array(o.items.length), M = new Array(o.items.length), F = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map();
283
- let N = 0;
284
- for (let R = 0; R < o.items.length; R += 1) {
285
- const L = o.items[R];
286
- L?.id && B.set(L.id, R);
287
- let A = 0;
281
+ function un(o) {
282
+ const g = o.columnCount, u = o.columnWidth, a = o.gapX, i = o.gapY, f = o.headerHeight, c = o.footerHeight, r = o.bucketPx, v = Array.from({ length: g }, () => 0), m = new Array(o.items.length), M = new Array(o.items.length), F = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map();
283
+ let C = 0;
284
+ for (let A = 0; A < o.items.length; A += 1) {
285
+ const L = o.items[A];
286
+ L?.id && B.set(L.id, A);
287
+ let N = 0;
288
288
  for (let H = 1; H < v.length; H += 1)
289
- v[H] < v[A] && (A = H);
290
- const W = A * (u + s), O = v[A], _ = rn(L, u) + f + c;
291
- m[R] = { x: W, y: O }, M[R] = _, v[A] = O + _ + i, N = Math.max(N, O + _);
292
- const P = Math.floor(O / r), q = Math.floor((O + _) / r);
289
+ v[H] < v[N] && (N = H);
290
+ const W = N * (u + a), D = v[N], _ = sn(L, u) + f + c;
291
+ m[A] = { x: W, y: D }, M[A] = _, v[N] = D + _ + i, C = Math.max(C, D + _);
292
+ const P = Math.floor(D / r), q = Math.floor((D + _) / r);
293
293
  for (let H = P; H <= q; H += 1) {
294
- const Q = F.get(H);
295
- Q ? Q.push(R) : F.set(H, [R]);
294
+ const ne = F.get(H);
295
+ ne ? ne.push(A) : F.set(H, [A]);
296
296
  }
297
297
  }
298
- return { positions: m, heights: M, buckets: F, contentHeight: N, indexById: B };
298
+ return { positions: m, heights: M, buckets: F, contentHeight: C, indexById: B };
299
299
  }
300
- function fn(o) {
300
+ function cn(o) {
301
301
  const g = o.itemCount;
302
302
  if (!g) return [];
303
303
  if (o.viewportHeight <= 0) return Array.from({ length: g }, (v, m) => m);
304
- const u = Math.max(0, o.scrollTop - o.overscanPx), s = o.scrollTop + o.viewportHeight + o.overscanPx, i = Math.floor(u / o.bucketPx), f = Math.floor(s / o.bucketPx), c = /* @__PURE__ */ new Set();
304
+ const u = Math.max(0, o.scrollTop - o.overscanPx), a = o.scrollTop + o.viewportHeight + o.overscanPx, i = Math.floor(u / o.bucketPx), f = Math.floor(a / o.bucketPx), c = /* @__PURE__ */ new Set();
305
305
  for (let v = i; v <= f; v += 1) {
306
306
  const m = o.buckets.get(v);
307
307
  if (m)
@@ -310,32 +310,32 @@ function fn(o) {
310
310
  const r = Array.from(c);
311
311
  return r.sort((v, m) => v - m), r;
312
312
  }
313
- const dn = { class: "hidden" }, vn = {
313
+ const fn = { class: "hidden" }, dn = {
314
314
  key: 0,
315
315
  class: "flex h-full items-center justify-center"
316
- }, mn = {
316
+ }, vn = {
317
317
  key: 1,
318
318
  class: "text-sm font-medium text-red-700"
319
- }, hn = { class: "relative" }, gn = {
319
+ }, mn = { class: "relative" }, hn = {
320
320
  key: 0,
321
321
  class: "pointer-events-auto absolute inset-0"
322
- }, pn = { class: "relative" }, yn = {
322
+ }, gn = { class: "relative" }, pn = {
323
323
  key: 0,
324
324
  class: "pointer-events-auto absolute inset-0"
325
- }, wn = { class: "mt-4 pb-2 text-center text-xs text-slate-600" }, xn = {
325
+ }, yn = { class: "mt-4 pb-2 text-center text-xs text-slate-600" }, wn = {
326
326
  key: 0,
327
327
  class: "inline-flex items-center justify-center gap-2"
328
- }, bn = { key: 1 }, Mn = { key: 2 }, Mt = 100, In = 200, It = 600, St = 300, kt = 600, Ft = 600, Sn = 5, kn = 1e3, Fn = /* @__PURE__ */ we({
328
+ }, xn = { key: 1 }, bn = { key: 2 }, xt = 100, Mn = 200, bt = 600, Mt = 300, It = 600, kt = 600, In = 5, kn = 1e3, Sn = /* @__PURE__ */ xe({
329
329
  inheritAttrs: !1,
330
330
  __name: "Masonry",
331
- props: /* @__PURE__ */ Wt({
331
+ props: /* @__PURE__ */ jt({
332
332
  getContent: {},
333
333
  mode: {},
334
334
  pageSize: {},
335
335
  backfillRequestDelayMs: {},
336
336
  items: {},
337
337
  page: {},
338
- restoredPagesLoaded: {},
338
+ restoredPages: {},
339
339
  itemWidth: {},
340
340
  prefetchThresholdPx: {},
341
341
  gapX: {},
@@ -343,10 +343,10 @@ const dn = { class: "hidden" }, vn = {
343
343
  headerHeight: {},
344
344
  footerHeight: {},
345
345
  overscanPx: {}
346
- }, Zt),
346
+ }, Qt),
347
347
  emits: ["update:items", "preloaded", "failures"],
348
348
  setup(o, { expose: g, emit: u }) {
349
- const s = o, i = u, f = Ut(), c = we({
349
+ const a = o, i = u, f = Wt(), c = xe({
350
350
  name: "SlotRenderer",
351
351
  props: {
352
352
  slotFn: {
@@ -364,8 +364,8 @@ const dn = { class: "hidden" }, vn = {
364
364
  return n ? n(e.slotProps) : null;
365
365
  };
366
366
  }
367
- }), r = gt(null);
368
- Gt(Tt, (e) => {
367
+ }), r = mt(null);
368
+ Ut(Ft, (e) => {
369
369
  r.value || (r.value = e);
370
370
  });
371
371
  const v = [], m = [];
@@ -375,23 +375,23 @@ const dn = { class: "hidden" }, vn = {
375
375
  const e = v.splice(0, v.length);
376
376
  i("preloaded", e);
377
377
  }
378
- function N() {
378
+ function C() {
379
379
  if (!m.length) return;
380
380
  const e = m.splice(0, m.length);
381
381
  i("failures", e);
382
382
  }
383
- function R() {
383
+ function A() {
384
384
  M || (M = setTimeout(() => {
385
385
  M = null, B();
386
- }, Mt));
386
+ }, xt));
387
387
  }
388
388
  function L() {
389
389
  F || (F = setTimeout(() => {
390
- F = null, N();
391
- }, Mt));
390
+ F = null, C();
391
+ }, xt));
392
392
  }
393
- function A(e) {
394
- r.value?.onPreloaded?.(e), v.push(e), R();
393
+ function N(e) {
394
+ r.value?.onPreloaded?.(e), v.push(e), A();
395
395
  }
396
396
  function W(e) {
397
397
  r.value?.onFailed?.(e), m.push(e), L();
@@ -400,44 +400,44 @@ const dn = { class: "hidden" }, vn = {
400
400
  if (!r.value)
401
401
  throw new Error("[Masonry] Missing <MasonryItem> definition. Add <MasonryItem> as a child of <Masonry>.");
402
402
  });
403
- const O = I(() => {
403
+ const D = I(() => {
404
404
  const { class: e, ...n } = f;
405
405
  return n;
406
406
  }), _ = w(null), P = w(0), q = w(0), H = w(0);
407
- let Q;
408
- const Z = I(() => s.gapX), Ce = I(() => s.gapY);
407
+ let ne;
408
+ const oe = I(() => a.gapX), Ce = I(() => a.gapY);
409
409
  function He(e) {
410
410
  if (!e) return 0;
411
- const n = Math.max(0, Z.value);
411
+ const n = Math.max(0, oe.value);
412
412
  return Math.max(0, e.clientWidth - n);
413
413
  }
414
- const ee = I(() => s.headerHeight), te = I(() => s.footerHeight), xe = I(() => r.value?.header), be = I(() => r.value?.footer), Me = I(() => r.value?.overlay), Le = I(() => !!xe.value), ze = I(() => !!be.value), qe = I(() => !!Me.value), Oe = I(() => {
415
- if (ee.value > 0) return { height: `${ee.value}px` };
414
+ const le = I(() => a.headerHeight), ae = I(() => a.footerHeight), be = I(() => r.value?.header), Me = I(() => r.value?.footer), Ie = I(() => r.value?.overlay), Le = I(() => !!be.value), ze = I(() => !!Me.value), qe = I(() => !!Ie.value), Oe = I(() => {
415
+ if (le.value > 0) return { height: `${le.value}px` };
416
416
  }), De = I(() => {
417
- if (te.value > 0) return { height: `${te.value}px` };
418
- }), ue = w([]), Ie = w([]), $e = w(/* @__PURE__ */ new Map()), Ve = w(0), he = w(/* @__PURE__ */ new Map());
417
+ if (ae.value > 0) return { height: `${ae.value}px` };
418
+ }), fe = w([]), ke = w([]), $e = w(/* @__PURE__ */ new Map()), Ve = w(0), he = w(/* @__PURE__ */ new Map());
419
419
  function Ye(e) {
420
420
  const n = typeof e == "number" && Number.isFinite(e) ? e : 0;
421
- return rt.value + Math.max(0, n);
421
+ return lt.value + Math.max(0, n);
422
422
  }
423
- const U = w(/* @__PURE__ */ new Set()), ne = w(/* @__PURE__ */ new Set()), ge = /* @__PURE__ */ new Set(), pe = w(/* @__PURE__ */ new Map()), V = w(/* @__PURE__ */ new Set()), Y = w([]);
424
- function Bt(e) {
423
+ const U = w(/* @__PURE__ */ new Set()), se = w(/* @__PURE__ */ new Set()), ge = /* @__PURE__ */ new Set(), pe = w(/* @__PURE__ */ new Map()), V = w(/* @__PURE__ */ new Set()), Y = w([]);
424
+ function Tt(e) {
425
425
  const n = pe.value.get(e);
426
426
  return n || { dx: 0, dy: 0 };
427
427
  }
428
- function Rt(e) {
429
- if (ne.value.has(e)) return `transform ${kt}ms ease-out`;
430
- if (V.value.has(e)) return `transform ${St}ms ease-out`;
428
+ function _t(e) {
429
+ if (se.value.has(e)) return `transform ${It}ms ease-out`;
430
+ if (V.value.has(e)) return `transform ${Mt}ms ease-out`;
431
431
  }
432
- function At(e) {
433
- const t = d.value[e]?.id, l = ue.value[e] ?? { x: 0, y: 0 }, a = Ie.value[e] ?? 0, h = a > 0 ? a : ve.value, p = l.x, x = t && U.value.has(t) ? Ye(h) : l.y, b = t ? Bt(t) : { dx: 0, dy: 0 };
432
+ function Bt(e) {
433
+ const t = d.value[e]?.id, l = fe.value[e] ?? { x: 0, y: 0 }, s = ke.value[e] ?? 0, h = s > 0 ? s : ve.value, p = l.x, x = t && U.value.has(t) ? Ye(h) : l.y, b = t ? Tt(t) : { dx: 0, dy: 0 };
434
434
  return `translate3d(${p + b.dx}px,${x + b.dy}px,0)`;
435
435
  }
436
- function oe(e) {
436
+ function re(e) {
437
437
  (typeof requestAnimationFrame == "function" ? requestAnimationFrame : (t) => setTimeout(() => t(0), 0))(() => e());
438
438
  }
439
- function Et(e) {
440
- oe(() => oe(e));
439
+ function At(e) {
440
+ re(() => re(e));
441
441
  }
442
442
  const Xe = /* @__PURE__ */ new Set();
443
443
  function je(e) {
@@ -448,28 +448,28 @@ const dn = { class: "hidden" }, vn = {
448
448
  const n = new Set(U.value);
449
449
  let t = !1;
450
450
  for (const l of e) {
451
- const a = l?.id;
452
- if (a) {
453
- if (!Xe.has(a)) {
451
+ const s = l?.id;
452
+ if (s) {
453
+ if (!Xe.has(s)) {
454
454
  const h = l?.width, p = l?.height;
455
- (!je(h) || !je(p)) && (Xe.add(a), console.warn(
456
- `[Masonry] Item "${a}" has invalid dimensions (width=${String(h)}, height=${String(
455
+ (!je(h) || !je(p)) && (Xe.add(s), console.warn(
456
+ `[Masonry] Item "${s}" has invalid dimensions (width=${String(h)}, height=${String(
457
457
  p
458
458
  )}); layout expects { id, width, height }.`
459
459
  ));
460
460
  }
461
- n.has(a) || (n.add(a), t = !0);
461
+ n.has(s) || (n.add(s), t = !0);
462
462
  }
463
463
  }
464
464
  t && (U.value = n);
465
465
  }
466
466
  function We() {
467
467
  const e = /* @__PURE__ */ new Map();
468
- for (const n of Re.value) {
468
+ for (const n of Ae.value) {
469
469
  const l = d.value[n]?.id;
470
470
  if (!l) continue;
471
- const a = ue.value[n];
472
- a && e.set(l, { x: a.x, y: a.y });
471
+ const s = fe.value[n];
472
+ s && e.set(l, { x: s.x, y: s.y });
473
473
  }
474
474
  return e;
475
475
  }
@@ -480,26 +480,26 @@ const dn = { class: "hidden" }, vn = {
480
480
  if (n?.has(h)) continue;
481
481
  const x = he.value.get(h);
482
482
  if (x == null) continue;
483
- const b = ue.value[x];
483
+ const b = fe.value[x];
484
484
  if (!b) continue;
485
485
  const y = p.x - b.x, z = p.y - b.y;
486
486
  (y || z) && (t.set(h, { dx: y, dy: z }), l.push(h));
487
487
  }
488
488
  if (!t.size) return;
489
489
  pe.value = t;
490
- const a = new Set(V.value);
491
- for (const h of l) a.delete(h);
492
- V.value = a, oe(() => {
493
- V.value = /* @__PURE__ */ new Set([...V.value, ...l]), oe(() => {
490
+ const s = new Set(V.value);
491
+ for (const h of l) s.delete(h);
492
+ V.value = s, re(() => {
493
+ V.value = /* @__PURE__ */ new Set([...V.value, ...l]), re(() => {
494
494
  pe.value = /* @__PURE__ */ new Map();
495
495
  });
496
496
  }), setTimeout(() => {
497
497
  const h = new Set(V.value);
498
498
  for (const p of l) h.delete(p);
499
499
  V.value = h;
500
- }, St);
500
+ }, Mt);
501
501
  }
502
- const ce = w(!0), fe = w(!1), le = w("");
502
+ const G = w(!0), K = w(!1), ie = w("");
503
503
  let E = 0;
504
504
  function Ge(e) {
505
505
  return e instanceof Error && e.name === "AbortError";
@@ -508,7 +508,7 @@ const dn = { class: "hidden" }, vn = {
508
508
  const e = new Error("aborted");
509
509
  return e.name = "AbortError", e;
510
510
  }
511
- function Nt(e) {
511
+ function Rt(e) {
512
512
  return new Promise((n) => setTimeout(n, e));
513
513
  }
514
514
  async function Je(e, n) {
@@ -516,33 +516,33 @@ const dn = { class: "hidden" }, vn = {
516
516
  for (; ; ) {
517
517
  if (n !== E) throw Ke();
518
518
  try {
519
- return await s.getContent(e);
519
+ return await a.getContent(e);
520
520
  } catch (l) {
521
521
  if (n !== E) throw Ke();
522
- if (t >= Sn) throw l;
523
- t += 1, await Nt(t * kn);
522
+ if (t >= In) throw l;
523
+ t += 1, await Rt(t * kn);
524
524
  }
525
525
  }
526
526
  }
527
- const D = w([]), Qe = w([]), ke = w([]), C = w(s.page), Fe = w([]);
528
- let se = null, ae = null, ye = 0;
529
- function Ct(e) {
527
+ const O = w([]), Qe = w([]), Fe = w([]), R = w(a.page), ye = w([]);
528
+ let J = null, Q = null, we = 0;
529
+ function Et(e) {
530
530
  let n = -1;
531
531
  for (const t of e) {
532
532
  const l = t?.originalIndex;
533
533
  de(l) && l > n && (n = l);
534
534
  }
535
- ye = n + 1;
535
+ we = n + 1;
536
536
  }
537
- function re(e) {
537
+ function ue(e) {
538
538
  for (const n of e)
539
- !n || typeof n != "object" || n.id && n.originalIndex == null && (n.originalIndex = ye, ye += 1);
539
+ !n || typeof n != "object" || n.id && n.originalIndex == null && (n.originalIndex = we, we += 1);
540
540
  }
541
- const G = /* @__PURE__ */ new Map(), K = [];
541
+ const Z = /* @__PURE__ */ new Map(), ee = [];
542
542
  function de(e) {
543
543
  return typeof e == "number" && Number.isFinite(e);
544
544
  }
545
- function Ht(e, n) {
545
+ function Nt(e, n) {
546
546
  if (!n.length) return e;
547
547
  const t = /* @__PURE__ */ new Set();
548
548
  for (const p of e) {
@@ -555,11 +555,11 @@ const dn = { class: "hidden" }, vn = {
555
555
  x && (t.has(x) || (l.push(p), t.add(x)));
556
556
  }
557
557
  if (!l.length) return e;
558
- const a = l.slice().sort((p, x) => {
558
+ const s = l.slice().sort((p, x) => {
559
559
  const b = de(p.originalIndex) ? p.originalIndex : Number.POSITIVE_INFINITY, y = de(x.originalIndex) ? x.originalIndex : Number.POSITIVE_INFINITY;
560
560
  return b - y;
561
561
  }), h = e.slice();
562
- for (const p of a) {
562
+ for (const p of s) {
563
563
  const x = p.originalIndex;
564
564
  if (!de(x)) {
565
565
  h.push(p);
@@ -578,53 +578,47 @@ const dn = { class: "hidden" }, vn = {
578
578
  if (!e.length) return;
579
579
  Se(e);
580
580
  const n = We();
581
- d.value = Ht(d.value, e), await xt(), Ue(n);
581
+ d.value = Nt(d.value, e), await yt(), Ue(n);
582
582
  }
583
- async function et(e) {
583
+ async function Ct(e) {
584
584
  const t = (Array.isArray(e) ? e : [e]).map(_e).filter(Boolean);
585
585
  if (!t.length) return;
586
586
  const l = [];
587
- for (const a of t) {
588
- const h = G.get(a);
587
+ for (const s of t) {
588
+ const h = Z.get(s);
589
589
  h && l.push(h);
590
590
  }
591
591
  if (l.length) {
592
592
  await Ze(l);
593
- for (const a of l)
594
- a?.id && G.delete(a.id);
593
+ for (const s of l)
594
+ s?.id && Z.delete(s.id);
595
595
  }
596
596
  }
597
- async function tt() {
598
- const e = K.pop();
597
+ async function Ht() {
598
+ const e = ee.pop();
599
599
  if (!e?.length) return;
600
600
  const n = [];
601
601
  for (const t of e) {
602
- const l = G.get(t);
602
+ const l = Z.get(t);
603
603
  l && n.push(l);
604
604
  }
605
605
  if (n.length) {
606
606
  await Ze(n);
607
607
  for (const t of n)
608
- t?.id && G.delete(t.id);
608
+ t?.id && Z.delete(t.id);
609
609
  }
610
610
  }
611
- async function Lt(e) {
612
- return et(e);
613
- }
614
- async function zt() {
615
- return tt();
616
- }
617
- function nt(e) {
611
+ function Lt(e) {
618
612
  const t = (Array.isArray(e) ? e : [e]).map(_e).filter(Boolean);
619
613
  if (!t.length) return;
620
614
  const l = new Set(t);
621
- for (const a of l) G.delete(a);
622
- for (let a = K.length - 1; a >= 0; a -= 1) {
623
- const p = K[a].filter((x) => !l.has(x));
624
- p.length ? K[a] = p : K.splice(a, 1);
615
+ for (const s of l) Z.delete(s);
616
+ for (let s = ee.length - 1; s >= 0; s -= 1) {
617
+ const p = ee[s].filter((x) => !l.has(x));
618
+ p.length ? ee[s] = p : ee.splice(s, 1);
625
619
  }
626
620
  }
627
- const Pe = gt({
621
+ const Pe = mt({
628
622
  enabled: !1,
629
623
  isBackfillActive: !1,
630
624
  isRequestInFlight: !1,
@@ -642,118 +636,137 @@ const dn = { class: "hidden" }, vn = {
642
636
  pagesFetched: 0,
643
637
  itemsFetchedFromNetwork: 0
644
638
  }
645
- }), ot = un({
639
+ }), et = rn({
646
640
  getContent: (e) => Je(e, E),
647
641
  markEnterFromLeft: Se,
648
- buffer: Fe,
642
+ buffer: ye,
649
643
  stats: Pe,
650
- isEnabled: () => s.mode === "backfill",
651
- getPageSize: () => s.pageSize,
652
- getRequestDelayMs: () => s.backfillRequestDelayMs
653
- }), Te = I(() => s.items !== void 0);
654
- J(
655
- () => s.items,
644
+ isEnabled: () => a.mode === "backfill",
645
+ getPageSize: () => a.pageSize,
646
+ getRequestDelayMs: () => a.backfillRequestDelayMs
647
+ }), Te = I(() => a.items !== void 0);
648
+ te(
649
+ () => a.items,
656
650
  (e) => {
657
- Te.value && (ke.value = Array.isArray(e) ? e : []);
651
+ Te.value && (Fe.value = Array.isArray(e) ? e : []);
658
652
  },
659
653
  { immediate: !0 }
660
654
  );
661
655
  const d = I({
662
656
  get() {
663
- return Te.value ? ke.value : Qe.value;
657
+ return Te.value ? Fe.value : Qe.value;
664
658
  },
665
659
  set(e) {
666
- Te.value ? (ke.value = e, i("update:items", e)) : Qe.value = e;
660
+ Te.value ? (Fe.value = e, i("update:items", e)) : Qe.value = e;
667
661
  }
668
662
  });
669
- async function lt(e) {
663
+ async function tt(e) {
670
664
  const n = await Je(e, E);
671
- return re(n.items), Se(n.items), { items: n.items, nextPage: n.nextPage };
665
+ return ue(n.items), Se(n.items), { items: n.items, nextPage: n.nextPage };
672
666
  }
673
667
  function _e(e) {
674
668
  return e ? typeof e == "string" ? e : e?.id : null;
675
669
  }
676
- async function st(e) {
670
+ async function nt(e) {
677
671
  const t = (Array.isArray(e) ? e : [e]).map(_e).filter(Boolean);
678
672
  if (!t.length) return;
679
- const l = new Set(t), a = [];
673
+ const l = new Set(t), s = [];
680
674
  for (const b of l) {
681
675
  const y = he.value.get(b);
682
676
  if (y == null) continue;
683
677
  const z = d.value[y];
684
- z && (G.set(b, z), a.push(b));
678
+ z && (Z.set(b, z), s.push(b));
685
679
  }
686
- a.length && K.push(a);
680
+ s.length && ee.push(s);
687
681
  const h = We(), p = ve.value, x = [];
688
682
  for (const b of l) {
689
683
  const y = he.value.get(b);
690
684
  if (y == null) continue;
691
685
  const z = d.value[y];
692
686
  if (!z) continue;
693
- const me = ue.value[y] ?? { x: 0, y: 0 }, mt = Ie.value[y] ?? p;
687
+ const me = fe.value[y] ?? { x: 0, y: 0 }, dt = ke.value[y] ?? p;
694
688
  x.push({
695
689
  id: b,
696
690
  item: z,
697
691
  fromX: me.x,
698
692
  fromY: me.y,
699
693
  width: p,
700
- height: mt,
694
+ height: dt,
701
695
  leaving: !0
702
696
  });
703
697
  }
704
698
  if (x.length && (Y.value = [...Y.value, ...x]), d.value = d.value.filter((b) => {
705
699
  const y = b?.id;
706
700
  return !y || !l.has(y);
707
- }), await xt(), Ue(h, l), x.length) {
701
+ }), await yt(), Ue(h, l), x.length) {
708
702
  const b = new Set(x.map((y) => y.id));
709
- oe(() => {
703
+ re(() => {
710
704
  Y.value = Y.value.map(
711
705
  (y) => b.has(y.id) ? { ...y, leaving: !1 } : y
712
706
  ), setTimeout(() => {
713
707
  Y.value = Y.value.filter((y) => !b.has(y.id));
714
- }, Ft);
708
+ }, kt);
715
709
  });
716
710
  }
717
711
  }
718
712
  async function Be(e) {
719
- return st(e);
713
+ return nt(e);
714
+ }
715
+ function zt() {
716
+ E += 1, J = null, Q = null, G.value = !1, K.value = !1;
720
717
  }
721
718
  g({
722
- remove: st,
723
- restore: Lt,
724
- undo: zt,
725
- forget: nt,
726
- pagesLoaded: D,
727
- nextPage: C,
728
- // Aliases (kept for now; can be removed if you want strictly short API only).
729
- restoreRemoved: et,
730
- undoLastRemoval: tt,
731
- forgetRemoved: nt,
732
- backfillStats: Pe
719
+ remove: nt,
720
+ restore: Ct,
721
+ undo: Ht,
722
+ forget: Lt,
723
+ loadNextPage: at,
724
+ cancel: zt,
725
+ get pagesLoaded() {
726
+ return O.value;
727
+ },
728
+ set pagesLoaded(e) {
729
+ O.value = e;
730
+ },
731
+ get nextPage() {
732
+ return R.value;
733
+ },
734
+ set nextPage(e) {
735
+ R.value = e;
736
+ },
737
+ get isLoading() {
738
+ return G.value || K.value;
739
+ },
740
+ get hasReachedEnd() {
741
+ return a.mode !== "backfill" ? R.value == null : R.value == null && ye.value.length === 0;
742
+ },
743
+ get backfillStats() {
744
+ return Pe.value;
745
+ }
733
746
  });
734
- function at() {
735
- const e = cn({
747
+ function ot() {
748
+ const e = un({
736
749
  items: d.value,
737
- columnCount: Ae.value,
750
+ columnCount: Re.value,
738
751
  columnWidth: ve.value,
739
- gapX: Z.value,
752
+ gapX: oe.value,
740
753
  gapY: Ce.value,
741
- headerHeight: ee.value,
742
- footerHeight: te.value,
743
- bucketPx: It
754
+ headerHeight: le.value,
755
+ footerHeight: ae.value,
756
+ bucketPx: bt
744
757
  });
745
- ue.value = e.positions, Ie.value = e.heights, $e.value = e.buckets, Ve.value = e.contentHeight, he.value = e.indexById;
758
+ fe.value = e.positions, ke.value = e.heights, $e.value = e.buckets, Ve.value = e.contentHeight, he.value = e.indexById;
746
759
  }
747
- const rt = I(() => Math.max(Ve.value, q.value) + In), Re = I(() => fn({
760
+ const lt = I(() => Math.max(Ve.value, q.value) + Mn), Ae = I(() => cn({
748
761
  itemCount: d.value.length,
749
762
  viewportHeight: q.value,
750
763
  scrollTop: H.value,
751
- overscanPx: s.overscanPx,
752
- bucketPx: It,
764
+ overscanPx: a.overscanPx,
765
+ bucketPx: bt,
753
766
  buckets: $e.value
754
767
  }));
755
- J(
756
- Re,
768
+ te(
769
+ Ae,
757
770
  (e) => {
758
771
  if (!e?.length) return;
759
772
  const n = [];
@@ -761,70 +774,70 @@ const dn = { class: "hidden" }, vn = {
761
774
  const l = d.value[t]?.id;
762
775
  l && U.value.has(l) && (ge.has(l) || (ge.add(l), n.push(l)));
763
776
  }
764
- n.length && (oe(() => {
765
- const t = new Set(ne.value);
777
+ n.length && (re(() => {
778
+ const t = new Set(se.value);
766
779
  for (const l of n) t.add(l);
767
- ne.value = t;
768
- }), Et(() => {
780
+ se.value = t;
781
+ }), At(() => {
769
782
  const t = new Set(U.value);
770
783
  for (const l of n) t.delete(l);
771
784
  U.value = t, setTimeout(() => {
772
- const l = new Set(ne.value);
773
- for (const a of n)
774
- l.delete(a), ge.delete(a);
775
- ne.value = l;
776
- }, kt);
785
+ const l = new Set(se.value);
786
+ for (const s of n)
787
+ l.delete(s), ge.delete(s);
788
+ se.value = l;
789
+ }, It);
777
790
  }));
778
791
  },
779
792
  { flush: "post" }
780
793
  );
781
- async function qt() {
782
- if (se) return se;
783
- if (ce.value || fe.value || s.mode !== "backfill" && C.value == null || s.mode === "backfill" && C.value == null && Fe.value.length === 0)
794
+ async function at() {
795
+ if (J) return J;
796
+ if (G.value || K.value || a.mode !== "backfill" && R.value == null || a.mode === "backfill" && R.value == null && ye.value.length === 0)
784
797
  return;
785
798
  const e = E;
786
799
  let n = null;
787
800
  return n = (async () => {
788
801
  try {
789
- if (fe.value = !0, le.value = "", s.mode === "backfill") {
790
- const a = await ot.loadBackfillBatch(C.value);
802
+ if (K.value = !0, ie.value = "", a.mode === "backfill") {
803
+ const s = await et.loadBackfillBatch(R.value);
791
804
  if (e !== E) return;
792
- a.pages.length && (D.value = [...D.value, ...a.pages]), re(a.batchItems), d.value = [...d.value, ...a.batchItems], C.value = a.nextPage;
805
+ s.pages.length && (O.value = [...O.value, ...s.pages]), ue(s.batchItems), d.value = [...d.value, ...s.batchItems], R.value = s.nextPage;
793
806
  return;
794
807
  }
795
- const t = C.value;
808
+ const t = R.value;
796
809
  if (t == null) return;
797
- const l = await lt(t);
810
+ const l = await tt(t);
798
811
  if (e !== E) return;
799
- D.value = [...D.value, t], re(l.items), d.value = [...d.value, ...l.items], C.value = l.nextPage;
812
+ O.value = [...O.value, t], ue(l.items), d.value = [...d.value, ...l.items], R.value = l.nextPage;
800
813
  } catch (t) {
801
814
  if (e !== E || Ge(t)) return;
802
- le.value = t instanceof Error ? t.message : String(t);
815
+ ie.value = t instanceof Error ? t.message : String(t);
803
816
  } finally {
804
- e === E && (fe.value = !1), se === n && (se = null);
817
+ e === E && (K.value = !1), J === n && (J = null);
805
818
  }
806
- })(), se = n, n;
819
+ })(), J = n, n;
807
820
  }
808
- function Ot() {
821
+ function qt() {
809
822
  const e = _.value;
810
823
  if (!e) return;
811
- H.value = e.scrollTop, q.value = e.clientHeight, e.scrollHeight - (e.scrollTop + e.clientHeight) <= s.prefetchThresholdPx && qt();
824
+ H.value = e.scrollTop, q.value = e.clientHeight, e.scrollHeight - (e.scrollTop + e.clientHeight) <= a.prefetchThresholdPx && at();
812
825
  }
813
- function it() {
826
+ function st() {
814
827
  return _.value;
815
828
  }
816
- function ut(e) {
829
+ function rt(e) {
817
830
  P.value = He(e), q.value = e.clientHeight;
818
831
  }
819
- function Dt() {
820
- typeof ResizeObserver > "u" || (Q = new ResizeObserver(() => {
821
- const e = it();
822
- e && ut(e);
832
+ function Ot() {
833
+ typeof ResizeObserver > "u" || (ne = new ResizeObserver(() => {
834
+ const e = st();
835
+ e && rt(e);
823
836
  }));
824
837
  }
825
- function $t() {
838
+ function Dt() {
826
839
  return {
827
- enabled: s.mode === "backfill",
840
+ enabled: a.mode === "backfill",
828
841
  isBackfillActive: !1,
829
842
  isRequestInFlight: !1,
830
843
  requestPage: null,
@@ -833,8 +846,8 @@ const dn = { class: "hidden" }, vn = {
833
846
  target: 0
834
847
  },
835
848
  cooldownMsRemaining: 0,
836
- cooldownMsTotal: Ne(s.backfillRequestDelayMs),
837
- pageSize: _t(s.pageSize),
849
+ cooldownMsTotal: Ne(a.backfillRequestDelayMs),
850
+ pageSize: Pt(a.pageSize),
838
851
  bufferSize: 0,
839
852
  lastBatch: null,
840
853
  totals: {
@@ -843,22 +856,22 @@ const dn = { class: "hidden" }, vn = {
843
856
  }
844
857
  };
845
858
  }
846
- function ct() {
847
- E += 1, se = null, ae = null, ye = 0, G.clear(), K.length = 0, U.value = /* @__PURE__ */ new Set(), ne.value = /* @__PURE__ */ new Set(), ge.clear(), pe.value = /* @__PURE__ */ new Map(), V.value = /* @__PURE__ */ new Set(), Y.value = [], D.value = [], C.value = null, Fe.value = [], Pe.value = $t(), ce.value = !0, fe.value = !1, le.value = "";
859
+ function it() {
860
+ E += 1, J = null, Q = null, we = 0, Z.clear(), ee.length = 0, U.value = /* @__PURE__ */ new Set(), se.value = /* @__PURE__ */ new Set(), ge.clear(), pe.value = /* @__PURE__ */ new Map(), V.value = /* @__PURE__ */ new Set(), Y.value = [], O.value = [], R.value = null, ye.value = [], Pe.value = Dt(), G.value = !0, K.value = !1, ie.value = "";
848
861
  }
849
- function ft(e) {
850
- ct(), d.value = [], C.value = e;
862
+ function ut(e) {
863
+ it(), d.value = [], R.value = e;
851
864
  }
852
- function Vt(e) {
865
+ function $t(e) {
853
866
  const n = Array.isArray(e) ? e : [e], t = [], l = /* @__PURE__ */ new Set();
854
- for (const a of n) {
855
- if (a == null) continue;
856
- const h = typeof a == "string" ? `s:${a}` : `n:${String(a)}`;
857
- l.has(h) || (l.add(h), t.push(a));
867
+ for (const s of n) {
868
+ if (s == null) continue;
869
+ const h = typeof s == "string" ? `s:${s}` : `n:${String(s)}`;
870
+ l.has(h) || (l.add(h), t.push(s));
858
871
  }
859
872
  return t;
860
873
  }
861
- function Yt(e) {
874
+ function Vt(e) {
862
875
  const n = [];
863
876
  for (const t of e) {
864
877
  if (typeof t == "number" && Number.isFinite(t)) {
@@ -872,99 +885,99 @@ const dn = { class: "hidden" }, vn = {
872
885
  }
873
886
  return n.length ? Math.max(...n) + 1 : null;
874
887
  }
875
- function dt(e) {
876
- ct();
877
- const n = Vt(e);
878
- D.value = n, C.value = Yt(n), ce.value = !1, Ct(d.value), re(d.value);
888
+ function ct(e) {
889
+ it();
890
+ const n = $t(e);
891
+ O.value = n, R.value = typeof a.page == "string" ? a.page : Vt(n), G.value = !1, Et(d.value), ue(d.value);
879
892
  }
880
- async function vt(e) {
881
- if (ae) return ae;
893
+ async function ft(e) {
894
+ if (Q) return Q;
882
895
  const n = E;
883
896
  let t = null;
884
897
  return t = (async () => {
885
898
  try {
886
- if (s.mode === "backfill") {
887
- const l = await ot.loadBackfillBatch(e);
899
+ if (a.mode === "backfill") {
900
+ const l = await et.loadBackfillBatch(e);
888
901
  if (n !== E) return;
889
- D.value = l.pages.length ? l.pages : [e], re(l.batchItems), d.value = l.batchItems, C.value = l.nextPage;
902
+ O.value = l.pages.length ? l.pages : [e], ue(l.batchItems), d.value = l.batchItems, R.value = l.nextPage;
890
903
  } else {
891
- const l = await lt(e);
904
+ const l = await tt(e);
892
905
  if (n !== E) return;
893
- D.value = [e], re(l.items), d.value = l.items, C.value = l.nextPage;
906
+ O.value = [e], ue(l.items), d.value = l.items, R.value = l.nextPage;
894
907
  }
895
908
  } catch (l) {
896
909
  if (n !== E || Ge(l)) return;
897
- le.value = l instanceof Error ? l.message : String(l);
910
+ ie.value = l instanceof Error ? l.message : String(l);
898
911
  } finally {
899
- n === E && (ce.value = !1), ae === t && (ae = null);
912
+ n === E && (G.value = !1), Q === t && (Q = null);
900
913
  }
901
- })(), ae = t, t;
914
+ })(), Q = t, t;
902
915
  }
903
- function Xt() {
904
- const e = it();
905
- e && (ut(e), H.value = e.scrollTop, Q?.observe(e));
916
+ function Yt() {
917
+ const e = st();
918
+ e && (rt(e), H.value = e.scrollTop, ne?.observe(e));
906
919
  }
907
920
  Ee(async () => {
908
- if (Dt(), Xt(), s.restoredPagesLoaded != null) {
909
- dt(s.restoredPagesLoaded);
921
+ if (Ot(), Yt(), a.restoredPages != null) {
922
+ ct(a.restoredPages);
910
923
  return;
911
924
  }
912
- ft(s.page), await vt(s.page);
913
- }), Pt(() => {
914
- Q?.disconnect(), M && (clearTimeout(M), M = null), F && (clearTimeout(F), F = null), B(), N();
915
- }), J(
916
- () => s.page,
925
+ ut(a.page), await ft(a.page);
926
+ }), St(() => {
927
+ ne?.disconnect(), M && (clearTimeout(M), M = null), F && (clearTimeout(F), F = null), B(), C();
928
+ }), te(
929
+ () => a.page,
917
930
  async (e) => {
918
- s.restoredPagesLoaded == null && (ft(e), await vt(e));
931
+ a.restoredPages == null && (ut(e), await ft(e));
919
932
  }
920
- ), J(
921
- () => s.restoredPagesLoaded,
933
+ ), te(
934
+ () => a.restoredPages,
922
935
  (e) => {
923
- e && dt(e);
936
+ e && ct(e);
924
937
  }
925
- ), J(
926
- Z,
938
+ ), te(
939
+ oe,
927
940
  () => {
928
941
  const e = _.value;
929
942
  e && (P.value = He(e));
930
943
  },
931
944
  { immediate: !1 }
932
945
  );
933
- const Ae = I(() => sn(P.value, s.itemWidth)), ve = I(
934
- () => an(P.value, Ae.value, s.itemWidth, Z.value)
946
+ const Re = I(() => ln(P.value, a.itemWidth)), ve = I(
947
+ () => an(P.value, Re.value, a.itemWidth, oe.value)
935
948
  );
936
- J(
937
- [Ae, ve, Z, Ce, ee, te],
949
+ te(
950
+ [Re, ve, oe, Ce, le, ae],
938
951
  () => {
939
- at();
952
+ ot();
940
953
  },
941
954
  { immediate: !0 }
942
- ), J(
955
+ ), te(
943
956
  // Performance note: this component targets very large arrays (e.g. 10k items).
944
957
  // Avoid deep watchers over items; rebuild layout only when the list structure
945
958
  // changes (new array reference or length change). This keeps metadata-only
946
959
  // updates (e.g. reactions) cheap.
947
960
  () => [d.value, d.value.length],
948
- () => at(),
961
+ () => ot(),
949
962
  { immediate: !0 }
950
963
  );
951
- const jt = I(() => [
964
+ const Xt = I(() => [
952
965
  "mt-8 flex min-h-0 flex-1 flex-col rounded-2xl border border-slate-200/70 bg-white/70 p-5 shadow-sm backdrop-blur",
953
966
  f.class
954
967
  ]);
955
- return (e, n) => (k(), S("section", Kt(O.value, { class: jt.value }), [
956
- T("div", dn, [
957
- Jt(e.$slots, "default")
968
+ return (e, n) => (S(), k("section", Gt(D.value, { class: Xt.value }), [
969
+ T("div", fn, [
970
+ Kt(e.$slots, "default")
958
971
  ]),
959
972
  T("div", {
960
973
  ref_key: "scrollViewportRef",
961
974
  ref: _,
962
975
  "data-testid": "items-scroll-container",
963
976
  class: "mt-4 min-h-0 flex-1 overflow-auto",
964
- style: $({ paddingRight: Z.value + "px" }),
965
- onScroll: Ot
977
+ style: $({ paddingRight: oe.value + "px" }),
978
+ onScroll: qt
966
979
  }, [
967
- ce.value ? (k(), S("div", vn, n[0] || (n[0] = [
980
+ G.value ? (S(), k("div", dn, n[0] || (n[0] = [
968
981
  T("div", { class: "inline-flex items-center gap-3 text-sm text-slate-600" }, [
969
982
  T("svg", {
970
983
  class: "h-5 w-5 animate-spin text-slate-500",
@@ -988,107 +1001,107 @@ const dn = { class: "hidden" }, vn = {
988
1001
  ]),
989
1002
  T("span", null, "Loading…")
990
1003
  ], -1)
991
- ]))) : le.value ? (k(), S("p", mn, "Error: " + pt(le.value), 1)) : (k(), S("div", {
1004
+ ]))) : ie.value ? (S(), k("p", vn, "Error: " + ht(ie.value), 1)) : (S(), k("div", {
992
1005
  key: 2,
993
1006
  class: "relative",
994
- style: $({ height: rt.value + "px" })
1007
+ style: $({ height: lt.value + "px" })
995
1008
  }, [
996
- (k(!0), S(yt, null, wt(Re.value, (t) => (k(), S("article", {
1009
+ (S(!0), k(gt, null, pt(Ae.value, (t) => (S(), k("article", {
997
1010
  key: d.value[t].id,
998
1011
  "data-testid": "item-card",
999
1012
  class: "absolute overflow-hidden rounded-xl border border-slate-200/60 bg-white shadow-sm",
1000
1013
  style: $({
1001
1014
  width: ve.value + "px",
1002
- transition: Rt(d.value[t].id),
1003
- transform: At(t)
1015
+ transition: _t(d.value[t].id),
1016
+ transform: Bt(t)
1004
1017
  })
1005
1018
  }, [
1006
- Le.value || ee.value > 0 ? (k(), S("div", {
1019
+ Le.value || le.value > 0 ? (S(), k("div", {
1007
1020
  key: 0,
1008
1021
  "data-testid": "item-header-container",
1009
1022
  class: "w-full",
1010
1023
  style: $(Oe.value)
1011
1024
  }, [
1012
- X(ie(c), {
1013
- "slot-fn": xe.value,
1025
+ X(ce(c), {
1026
+ "slot-fn": be.value,
1014
1027
  "slot-props": { item: d.value[t], remove: () => Be(d.value[t]) }
1015
1028
  }, null, 8, ["slot-fn", "slot-props"])
1016
1029
  ], 4)) : j("", !0),
1017
- T("div", hn, [
1018
- X(bt, {
1030
+ T("div", mn, [
1031
+ X(wt, {
1019
1032
  item: d.value[t],
1020
- onSuccess: A,
1033
+ onSuccess: N,
1021
1034
  onError: W
1022
1035
  }, null, 8, ["item"]),
1023
- qe.value ? (k(), S("div", gn, [
1024
- X(ie(c), {
1025
- "slot-fn": Me.value,
1036
+ qe.value ? (S(), k("div", hn, [
1037
+ X(ce(c), {
1038
+ "slot-fn": Ie.value,
1026
1039
  "slot-props": { item: d.value[t], remove: () => Be(d.value[t]) }
1027
1040
  }, null, 8, ["slot-fn", "slot-props"])
1028
1041
  ])) : j("", !0)
1029
1042
  ]),
1030
- ze.value || te.value > 0 ? (k(), S("div", {
1043
+ ze.value || ae.value > 0 ? (S(), k("div", {
1031
1044
  key: 1,
1032
1045
  "data-testid": "item-footer-container",
1033
1046
  class: "w-full",
1034
1047
  style: $(De.value)
1035
1048
  }, [
1036
- X(ie(c), {
1037
- "slot-fn": be.value,
1049
+ X(ce(c), {
1050
+ "slot-fn": Me.value,
1038
1051
  "slot-props": { item: d.value[t], remove: () => Be(d.value[t]) }
1039
1052
  }, null, 8, ["slot-fn", "slot-props"])
1040
1053
  ], 4)) : j("", !0)
1041
1054
  ], 4))), 128)),
1042
- (k(!0), S(yt, null, wt(Y.value, (t) => (k(), S("article", {
1055
+ (S(!0), k(gt, null, pt(Y.value, (t) => (S(), k("article", {
1043
1056
  key: t.id + ":leaving",
1044
1057
  "data-testid": "item-card-leaving",
1045
1058
  class: "pointer-events-none absolute overflow-hidden rounded-xl border border-slate-200/60 bg-white shadow-sm",
1046
1059
  style: $({
1047
1060
  width: t.width + "px",
1048
- transition: "transform " + Ft + "ms ease-out",
1061
+ transition: "transform " + kt + "ms ease-out",
1049
1062
  transform: t.leaving ? "translate3d(" + t.fromX + "px," + t.fromY + "px,0)" : "translate3d(" + t.fromX + "px," + Ye(t.height) + "px,0)"
1050
1063
  })
1051
1064
  }, [
1052
- Le.value || ee.value > 0 ? (k(), S("div", {
1065
+ Le.value || le.value > 0 ? (S(), k("div", {
1053
1066
  key: 0,
1054
1067
  "data-testid": "item-header-container",
1055
1068
  class: "w-full",
1056
1069
  style: $(Oe.value)
1057
1070
  }, [
1058
- X(ie(c), {
1059
- "slot-fn": xe.value,
1071
+ X(ce(c), {
1072
+ "slot-fn": be.value,
1060
1073
  "slot-props": { item: t.item, remove: () => {
1061
1074
  } }
1062
1075
  }, null, 8, ["slot-fn", "slot-props"])
1063
1076
  ], 4)) : j("", !0),
1064
- T("div", pn, [
1065
- X(bt, {
1077
+ T("div", gn, [
1078
+ X(wt, {
1066
1079
  item: t.item
1067
1080
  }, null, 8, ["item"]),
1068
- qe.value ? (k(), S("div", yn, [
1069
- X(ie(c), {
1070
- "slot-fn": Me.value,
1081
+ qe.value ? (S(), k("div", pn, [
1082
+ X(ce(c), {
1083
+ "slot-fn": Ie.value,
1071
1084
  "slot-props": { item: t.item, remove: () => {
1072
1085
  } }
1073
1086
  }, null, 8, ["slot-fn", "slot-props"])
1074
1087
  ])) : j("", !0)
1075
1088
  ]),
1076
- ze.value || te.value > 0 ? (k(), S("div", {
1089
+ ze.value || ae.value > 0 ? (S(), k("div", {
1077
1090
  key: 1,
1078
1091
  "data-testid": "item-footer-container",
1079
1092
  class: "w-full",
1080
1093
  style: $(De.value)
1081
1094
  }, [
1082
- X(ie(c), {
1083
- "slot-fn": be.value,
1095
+ X(ce(c), {
1096
+ "slot-fn": Me.value,
1084
1097
  "slot-props": { item: t.item, remove: () => {
1085
1098
  } }
1086
1099
  }, null, 8, ["slot-fn", "slot-props"])
1087
1100
  ], 4)) : j("", !0)
1088
1101
  ], 4))), 128))
1089
1102
  ], 4)),
1090
- T("div", wn, [
1091
- fe.value ? (k(), S("span", xn, n[1] || (n[1] = [
1103
+ T("div", yn, [
1104
+ K.value ? (S(), k("span", wn, n[1] || (n[1] = [
1092
1105
  T("svg", {
1093
1106
  class: "h-4 w-4 animate-spin text-slate-500",
1094
1107
  viewBox: "0 0 24 24",
@@ -1110,19 +1123,19 @@ const dn = { class: "hidden" }, vn = {
1110
1123
  })
1111
1124
  ], -1),
1112
1125
  T("span", null, "Loading more…", -1)
1113
- ]))) : C.value == null ? (k(), S("span", bn, "End of list")) : (k(), S("span", Mn, "Scroll to load page " + pt(C.value), 1))
1126
+ ]))) : R.value == null ? (S(), k("span", xn, "End of list")) : (S(), k("span", bn, "Scroll to load page " + ht(R.value), 1))
1114
1127
  ])
1115
1128
  ], 36)
1116
1129
  ], 16));
1117
1130
  }
1118
- }), Pn = we({
1131
+ }), Fn = xe({
1119
1132
  name: "MasonryItem",
1120
1133
  setup(o, { slots: g, attrs: u }) {
1121
- const s = Qt(Tt, null);
1122
- if (!s)
1134
+ const a = Jt(Ft, null);
1135
+ if (!a)
1123
1136
  return () => null;
1124
1137
  const i = u.onPreloaded, f = u.onFailed, c = g.overlay, r = g.default;
1125
- return s({
1138
+ return a({
1126
1139
  header: g.header,
1127
1140
  overlay: c ?? r,
1128
1141
  footer: g.footer,
@@ -1136,14 +1149,14 @@ const dn = { class: "hidden" }, vn = {
1136
1149
  } : void 0
1137
1150
  }), () => null;
1138
1151
  }
1139
- }), _n = {
1152
+ }), Tn = {
1140
1153
  install(o) {
1141
- o.component("Masonry", Fn), o.component("MasonryItem", Pn);
1154
+ o.component("Masonry", Sn), o.component("MasonryItem", Fn);
1142
1155
  }
1143
1156
  };
1144
1157
  export {
1145
- Fn as Masonry,
1146
- Pn as MasonryItem,
1147
- _n as VibePlugin,
1148
- Zt as masonryDefaults
1158
+ Sn as Masonry,
1159
+ Fn as MasonryItem,
1160
+ Tn as VibePlugin,
1161
+ Qt as masonryDefaults
1149
1162
  };