@wyxos/vibe 1.6.6 → 1.6.8

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.
package/lib/index.js CHANGED
@@ -1,23 +1,23 @@
1
- import { nextTick as Q, defineComponent as Le, ref as L, onMounted as He, watch as Ne, createElementBlock as q, openBlock as V, renderSlot as $e, createElementVNode as O, createCommentVNode as oe, withModifiers as ze, toDisplayString as de, computed as se, onUnmounted as Re, normalizeClass as we, normalizeStyle as Ce, createVNode as Me, TransitionGroup as _e, withCtx as qe, Fragment as Ve, renderList as Ge, mergeProps as Te, unref as Ue } from "vue";
2
- let ue = null;
1
+ import { nextTick as Z, defineComponent as Le, ref as E, computed as ee, onMounted as Se, onUnmounted as Ne, watch as He, createElementBlock as B, openBlock as D, renderSlot as $e, createElementVNode as k, createCommentVNode as X, normalizeClass as se, toDisplayString as ie, withModifiers as ze, normalizeStyle as Re, createVNode as Te, TransitionGroup as _e, withCtx as Ce, Fragment as qe, renderList as Ve, mergeProps as Ge, unref as Ue } from "vue";
2
+ let fe = null;
3
3
  function Xe() {
4
- if (ue != null) return ue;
4
+ if (fe != null) return fe;
5
5
  const e = document.createElement("div");
6
6
  e.style.visibility = "hidden", e.style.overflow = "scroll", e.style.msOverflowStyle = "scrollbar", e.style.width = "100px", e.style.height = "100px", document.body.appendChild(e);
7
7
  const o = document.createElement("div");
8
8
  o.style.width = "100%", e.appendChild(o);
9
9
  const l = e.offsetWidth - o.offsetWidth;
10
- return document.body.removeChild(e), ue = l, l;
10
+ return document.body.removeChild(e), fe = l, l;
11
11
  }
12
12
  function Ye(e, o, l, s = {}) {
13
13
  const {
14
- gutterX: h = 0,
15
- gutterY: v = 0,
14
+ gutterX: T = 0,
15
+ gutterY: m = 0,
16
16
  header: a = 0,
17
17
  footer: n = 0,
18
- paddingLeft: d = 0,
19
- paddingRight: u = 0,
20
- sizes: c = {
18
+ paddingLeft: y = 0,
19
+ paddingRight: c = 0,
20
+ sizes: v = {
21
21
  base: 1,
22
22
  sm: 2,
23
23
  md: 3,
@@ -27,93 +27,93 @@ function Ye(e, o, l, s = {}) {
27
27
  },
28
28
  placement: b = "masonry"
29
29
  } = s;
30
- let m = 0, x = 0;
30
+ let f = 0, x = 0;
31
31
  try {
32
32
  if (o && o.nodeType === 1 && typeof window < "u" && window.getComputedStyle) {
33
- const w = window.getComputedStyle(o);
34
- m = parseFloat(w.paddingLeft) || 0, x = parseFloat(w.paddingRight) || 0;
33
+ const M = window.getComputedStyle(o);
34
+ f = parseFloat(M.paddingLeft) || 0, x = parseFloat(M.paddingRight) || 0;
35
35
  }
36
36
  } catch {
37
37
  }
38
- const F = (d || 0) + m, _ = (u || 0) + x, H = o.offsetWidth - o.clientWidth, M = H > 0 ? H + 2 : Xe() + 2, P = o.offsetWidth - M - F - _, U = h * (l - 1), S = Math.floor((P - U) / l), T = e.map((w) => {
39
- const N = w.width, I = w.height;
40
- return Math.round(S * I / N) + n + a;
38
+ const $ = (y || 0) + f, z = (c || 0) + x, N = o.offsetWidth - o.clientWidth, i = N > 0 ? N + 2 : Xe() + 2, d = o.offsetWidth - i - $ - z, L = T * (l - 1), I = Math.floor((d - L) / l), P = e.map((M) => {
39
+ const W = M.width, H = M.height;
40
+ return Math.round(I * H / W) + n + a;
41
41
  });
42
42
  if (b === "sequential-balanced") {
43
- const w = T.length;
44
- if (w === 0) return [];
45
- const N = (p, k, B) => p + (k > 0 ? v : 0) + B;
46
- let I = Math.max(...T), D = T.reduce((p, k) => p + k, 0) + v * Math.max(0, w - 1);
47
- const Z = (p) => {
48
- let k = 1, B = 0, z = 0;
49
- for (let $ = 0; $ < w; $++) {
50
- const G = T[$], R = N(B, z, G);
51
- if (R <= p)
52
- B = R, z++;
53
- else if (k++, B = G, z = 1, G > p || k > l) return !1;
43
+ const M = P.length;
44
+ if (M === 0) return [];
45
+ const W = (w, A, R) => w + (A > 0 ? m : 0) + R;
46
+ let H = Math.max(...P), _ = P.reduce((w, A) => w + A, 0) + m * Math.max(0, M - 1);
47
+ const te = (w) => {
48
+ let A = 1, R = 0, q = 0;
49
+ for (let j = 0; j < M; j++) {
50
+ const U = P[j], V = W(R, q, U);
51
+ if (V <= w)
52
+ R = V, q++;
53
+ else if (A++, R = U, q = 1, U > w || A > l) return !1;
54
54
  }
55
- return k <= l;
55
+ return A <= l;
56
56
  };
57
- for (; I < D; ) {
58
- const p = Math.floor((I + D) / 2);
59
- Z(p) ? D = p : I = p + 1;
60
- }
61
- const ee = D, X = new Array(l).fill(0);
62
- let te = l - 1, Y = 0, J = 0;
63
- for (let p = w - 1; p >= 0; p--) {
64
- const k = T[p], B = p < te;
65
- !(N(Y, J, k) <= ee) || B ? (X[te] = p + 1, te--, Y = k, J = 1) : (Y = N(Y, J, k), J++);
66
- }
67
- X[0] = 0;
68
- const j = [], ae = new Array(l).fill(0);
69
- for (let p = 0; p < l; p++) {
70
- const k = X[p], B = p + 1 < l ? X[p + 1] : w, z = p * (S + h);
71
- for (let $ = k; $ < B; $++) {
72
- const R = {
73
- ...e[$],
74
- columnWidth: S,
57
+ for (; H < _; ) {
58
+ const w = Math.floor((H + _) / 2);
59
+ te(w) ? _ = w : H = w + 1;
60
+ }
61
+ const ae = _, Y = new Array(l).fill(0);
62
+ let ne = l - 1, J = 0, K = 0;
63
+ for (let w = M - 1; w >= 0; w--) {
64
+ const A = P[w], R = w < ne;
65
+ !(W(J, K, A) <= ae) || R ? (Y[ne] = w + 1, ne--, J = A, K = 1) : (J = W(J, K, A), K++);
66
+ }
67
+ Y[0] = 0;
68
+ const C = [], re = new Array(l).fill(0);
69
+ for (let w = 0; w < l; w++) {
70
+ const A = Y[w], R = w + 1 < l ? Y[w + 1] : M, q = w * (I + T);
71
+ for (let j = A; j < R; j++) {
72
+ const V = {
73
+ ...e[j],
74
+ columnWidth: I,
75
75
  imageHeight: 0,
76
76
  columnHeight: 0,
77
77
  left: 0,
78
78
  top: 0
79
79
  };
80
- R.imageHeight = T[$] - (n + a), R.columnHeight = T[$], R.left = z, R.top = ae[p], ae[p] += R.columnHeight + ($ + 1 < B ? v : 0), j.push(R);
80
+ V.imageHeight = P[j] - (n + a), V.columnHeight = P[j], V.left = q, V.top = re[w], re[w] += V.columnHeight + (j + 1 < R ? m : 0), C.push(V);
81
81
  }
82
82
  }
83
- return j;
83
+ return C;
84
84
  }
85
- const y = new Array(l).fill(0), W = [];
86
- for (let w = 0; w < e.length; w++) {
87
- const N = e[w], I = {
88
- ...N,
85
+ const h = new Array(l).fill(0), S = [];
86
+ for (let M = 0; M < e.length; M++) {
87
+ const W = e[M], H = {
88
+ ...W,
89
89
  columnWidth: 0,
90
90
  imageHeight: 0,
91
91
  columnHeight: 0,
92
92
  left: 0,
93
93
  top: 0
94
- }, D = y.indexOf(Math.min(...y)), Z = N.width, ee = N.height;
95
- I.columnWidth = S, I.left = D * (S + h), I.imageHeight = Math.round(S * ee / Z), I.columnHeight = I.imageHeight + n + a, I.top = y[D], y[D] += I.columnHeight + v, W.push(I);
94
+ }, _ = h.indexOf(Math.min(...h)), te = W.width, ae = W.height;
95
+ H.columnWidth = I, H.left = _ * (I + T), H.imageHeight = Math.round(I * ae / te), H.columnHeight = H.imageHeight + n + a, H.top = h[_], h[_] += H.columnHeight + m, S.push(H);
96
96
  }
97
- return W;
97
+ return S;
98
98
  }
99
- var Je = typeof global == "object" && global && global.Object === Object && global, Ke = typeof self == "object" && self && self.Object === Object && self, Ae = Je || Ke || Function("return this")(), ie = Ae.Symbol, We = Object.prototype, Qe = We.hasOwnProperty, Ze = We.toString, re = ie ? ie.toStringTag : void 0;
99
+ var Je = typeof global == "object" && global && global.Object === Object && global, Ke = typeof self == "object" && self && self.Object === Object && self, Ae = Je || Ke || Function("return this")(), ce = Ae.Symbol, Fe = Object.prototype, Qe = Fe.hasOwnProperty, Ze = Fe.toString, le = ce ? ce.toStringTag : void 0;
100
100
  function et(e) {
101
- var o = Qe.call(e, re), l = e[re];
101
+ var o = Qe.call(e, le), l = e[le];
102
102
  try {
103
- e[re] = void 0;
103
+ e[le] = void 0;
104
104
  var s = !0;
105
105
  } catch {
106
106
  }
107
- var h = Ze.call(e);
108
- return s && (o ? e[re] = l : delete e[re]), h;
107
+ var T = Ze.call(e);
108
+ return s && (o ? e[le] = l : delete e[le]), T;
109
109
  }
110
110
  var tt = Object.prototype, at = tt.toString;
111
111
  function nt(e) {
112
112
  return at.call(e);
113
113
  }
114
- var rt = "[object Null]", ot = "[object Undefined]", Ie = ie ? ie.toStringTag : void 0;
114
+ var rt = "[object Null]", ot = "[object Undefined]", Me = ce ? ce.toStringTag : void 0;
115
115
  function lt(e) {
116
- return e == null ? e === void 0 ? ot : rt : Ie && Ie in Object(e) ? et(e) : nt(e);
116
+ return e == null ? e === void 0 ? ot : rt : Me && Me in Object(e) ? et(e) : nt(e);
117
117
  }
118
118
  function st(e) {
119
119
  return e != null && typeof e == "object";
@@ -129,87 +129,87 @@ function ft(e) {
129
129
  return o;
130
130
  }
131
131
  var dt = /^\s+/;
132
- function gt(e) {
132
+ function vt(e) {
133
133
  return e && e.slice(0, ft(e) + 1).replace(dt, "");
134
134
  }
135
- function ge(e) {
135
+ function me(e) {
136
136
  var o = typeof e;
137
137
  return e != null && (o == "object" || o == "function");
138
138
  }
139
- var Pe = NaN, mt = /^[-+]0x[0-9a-f]+$/i, vt = /^0b[01]+$/i, pt = /^0o[0-7]+$/i, ht = parseInt;
140
- function Se(e) {
139
+ var Ie = NaN, mt = /^[-+]0x[0-9a-f]+$/i, gt = /^0b[01]+$/i, pt = /^0o[0-7]+$/i, yt = parseInt;
140
+ function Pe(e) {
141
141
  if (typeof e == "number")
142
142
  return e;
143
143
  if (ut(e))
144
- return Pe;
145
- if (ge(e)) {
144
+ return Ie;
145
+ if (me(e)) {
146
146
  var o = typeof e.valueOf == "function" ? e.valueOf() : e;
147
- e = ge(o) ? o + "" : o;
147
+ e = me(o) ? o + "" : o;
148
148
  }
149
149
  if (typeof e != "string")
150
150
  return e === 0 ? e : +e;
151
- e = gt(e);
152
- var l = vt.test(e);
153
- return l || pt.test(e) ? ht(e.slice(2), l ? 2 : 8) : mt.test(e) ? Pe : +e;
151
+ e = vt(e);
152
+ var l = gt.test(e);
153
+ return l || pt.test(e) ? yt(e.slice(2), l ? 2 : 8) : mt.test(e) ? Ie : +e;
154
154
  }
155
- var ce = function() {
155
+ var de = function() {
156
156
  return Ae.Date.now();
157
- }, yt = "Expected a function", bt = Math.max, xt = Math.min;
157
+ }, ht = "Expected a function", bt = Math.max, xt = Math.min;
158
158
  function ke(e, o, l) {
159
- var s, h, v, a, n, d, u = 0, c = !1, b = !1, m = !0;
159
+ var s, T, m, a, n, y, c = 0, v = !1, b = !1, f = !0;
160
160
  if (typeof e != "function")
161
- throw new TypeError(yt);
162
- o = Se(o) || 0, ge(l) && (c = !!l.leading, b = "maxWait" in l, v = b ? bt(Se(l.maxWait) || 0, o) : v, m = "trailing" in l ? !!l.trailing : m);
163
- function x(y) {
164
- var W = s, w = h;
165
- return s = h = void 0, u = y, a = e.apply(w, W), a;
161
+ throw new TypeError(ht);
162
+ o = Pe(o) || 0, me(l) && (v = !!l.leading, b = "maxWait" in l, m = b ? bt(Pe(l.maxWait) || 0, o) : m, f = "trailing" in l ? !!l.trailing : f);
163
+ function x(h) {
164
+ var S = s, M = T;
165
+ return s = T = void 0, c = h, a = e.apply(M, S), a;
166
166
  }
167
- function F(y) {
168
- return u = y, n = setTimeout(M, o), c ? x(y) : a;
167
+ function $(h) {
168
+ return c = h, n = setTimeout(i, o), v ? x(h) : a;
169
169
  }
170
- function _(y) {
171
- var W = y - d, w = y - u, N = o - W;
172
- return b ? xt(N, v - w) : N;
170
+ function z(h) {
171
+ var S = h - y, M = h - c, W = o - S;
172
+ return b ? xt(W, m - M) : W;
173
173
  }
174
- function H(y) {
175
- var W = y - d, w = y - u;
176
- return d === void 0 || W >= o || W < 0 || b && w >= v;
174
+ function N(h) {
175
+ var S = h - y, M = h - c;
176
+ return y === void 0 || S >= o || S < 0 || b && M >= m;
177
177
  }
178
- function M() {
179
- var y = ce();
180
- if (H(y))
181
- return P(y);
182
- n = setTimeout(M, _(y));
178
+ function i() {
179
+ var h = de();
180
+ if (N(h))
181
+ return d(h);
182
+ n = setTimeout(i, z(h));
183
183
  }
184
- function P(y) {
185
- return n = void 0, m && s ? x(y) : (s = h = void 0, a);
184
+ function d(h) {
185
+ return n = void 0, f && s ? x(h) : (s = T = void 0, a);
186
186
  }
187
- function U() {
188
- n !== void 0 && clearTimeout(n), u = 0, s = d = h = n = void 0;
187
+ function L() {
188
+ n !== void 0 && clearTimeout(n), c = 0, s = y = T = n = void 0;
189
189
  }
190
- function S() {
191
- return n === void 0 ? a : P(ce());
190
+ function I() {
191
+ return n === void 0 ? a : d(de());
192
192
  }
193
- function T() {
194
- var y = ce(), W = H(y);
195
- if (s = arguments, h = this, d = y, W) {
193
+ function P() {
194
+ var h = de(), S = N(h);
195
+ if (s = arguments, T = this, y = h, S) {
196
196
  if (n === void 0)
197
- return F(d);
197
+ return $(y);
198
198
  if (b)
199
- return clearTimeout(n), n = setTimeout(M, o), x(d);
199
+ return clearTimeout(n), n = setTimeout(i, o), x(y);
200
200
  }
201
- return n === void 0 && (n = setTimeout(M, o)), a;
201
+ return n === void 0 && (n = setTimeout(i, o)), a;
202
202
  }
203
- return T.cancel = U, T.flush = S, T;
203
+ return P.cancel = L, P.flush = I, P;
204
204
  }
205
- function fe(e) {
205
+ function ve(e) {
206
206
  const o = window.innerWidth, l = e.sizes;
207
207
  return o >= 1536 && l["2xl"] ? l["2xl"] : o >= 1280 && l.xl ? l.xl : o >= 1024 && l.lg ? l.lg : o >= 768 && l.md ? l.md : o >= 640 && l.sm ? l.sm : l.base;
208
208
  }
209
209
  function wt(e) {
210
210
  return e.reduce((l, s) => Math.max(l, s.top + s.columnHeight), 0) + 500;
211
211
  }
212
- function Mt(e) {
212
+ function Tt(e) {
213
213
  return {
214
214
  transform: `translate3d(${e.left}px, ${e.top}px, 0)`,
215
215
  top: "0px",
@@ -218,72 +218,72 @@ function Mt(e) {
218
218
  height: `${e.columnHeight}px`
219
219
  };
220
220
  }
221
- function Tt(e, o = 0) {
221
+ function Mt(e, o = 0) {
222
222
  return {
223
- style: Mt(e),
223
+ style: Tt(e),
224
224
  "data-top": e.top,
225
225
  "data-left": e.left,
226
226
  "data-id": `${e.page}-${e.id}`,
227
227
  "data-index": o
228
228
  };
229
229
  }
230
- function me(e, o) {
230
+ function ge(e, o) {
231
231
  if (!e.length || o <= 0)
232
232
  return new Array(Math.max(1, o)).fill(0);
233
- const s = Array.from(new Set(e.map((a) => a.left))).sort((a, n) => a - n).slice(0, o), h = /* @__PURE__ */ new Map();
234
- for (let a = 0; a < s.length; a++) h.set(s[a], a);
235
- const v = new Array(s.length).fill(0);
233
+ const s = Array.from(new Set(e.map((a) => a.left))).sort((a, n) => a - n).slice(0, o), T = /* @__PURE__ */ new Map();
234
+ for (let a = 0; a < s.length; a++) T.set(s[a], a);
235
+ const m = new Array(s.length).fill(0);
236
236
  for (const a of e) {
237
- const n = h.get(a.left);
238
- n != null && (v[n] = Math.max(v[n], a.top + a.columnHeight));
237
+ const n = T.get(a.left);
238
+ n != null && (m[n] = Math.max(m[n], a.top + a.columnHeight));
239
239
  }
240
- for (; v.length < o; ) v.push(0);
241
- return v;
240
+ for (; m.length < o; ) m.push(0);
241
+ return m;
242
242
  }
243
243
  function It(e, o) {
244
244
  function l(a, n) {
245
- const d = parseInt(a.dataset.left || "0", 10), u = parseInt(a.dataset.top || "0", 10), c = parseInt(a.dataset.index || "0", 10), b = Math.min(c * 20, 160), m = a.style.getPropertyValue("--masonry-opacity-delay");
245
+ const y = parseInt(a.dataset.left || "0", 10), c = parseInt(a.dataset.top || "0", 10), v = parseInt(a.dataset.index || "0", 10), b = Math.min(v * 20, 160), f = a.style.getPropertyValue("--masonry-opacity-delay");
246
246
  a.style.setProperty("--masonry-opacity-delay", `${b}ms`), requestAnimationFrame(() => {
247
- a.style.opacity = "1", a.style.transform = `translate3d(${d}px, ${u}px, 0) scale(1)`;
247
+ a.style.opacity = "1", a.style.transform = `translate3d(${y}px, ${c}px, 0) scale(1)`;
248
248
  const x = () => {
249
- m ? a.style.setProperty("--masonry-opacity-delay", m) : a.style.removeProperty("--masonry-opacity-delay"), a.removeEventListener("transitionend", x), n();
249
+ f ? a.style.setProperty("--masonry-opacity-delay", f) : a.style.removeProperty("--masonry-opacity-delay"), a.removeEventListener("transitionend", x), n();
250
250
  };
251
251
  a.addEventListener("transitionend", x);
252
252
  });
253
253
  }
254
254
  function s(a) {
255
- const n = parseInt(a.dataset.left || "0", 10), d = parseInt(a.dataset.top || "0", 10);
256
- a.style.opacity = "0", a.style.transform = `translate3d(${n}px, ${d + 10}px, 0) scale(0.985)`;
255
+ const n = parseInt(a.dataset.left || "0", 10), y = parseInt(a.dataset.top || "0", 10);
256
+ a.style.opacity = "0", a.style.transform = `translate3d(${n}px, ${y + 10}px, 0) scale(0.985)`;
257
257
  }
258
- function h(a) {
259
- const n = parseInt(a.dataset.left || "0", 10), d = parseInt(a.dataset.top || "0", 10);
260
- a.style.transition = "none", a.style.opacity = "1", a.style.transform = `translate3d(${n}px, ${d}px, 0) scale(1)`, a.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
258
+ function T(a) {
259
+ const n = parseInt(a.dataset.left || "0", 10), y = parseInt(a.dataset.top || "0", 10);
260
+ a.style.transition = "none", a.style.opacity = "1", a.style.transform = `translate3d(${n}px, ${y}px, 0) scale(1)`, a.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
261
261
  a.style.transition = "";
262
262
  });
263
263
  }
264
- function v(a, n) {
265
- const d = parseInt(a.dataset.left || "0", 10), u = parseInt(a.dataset.top || "0", 10), c = typeof (o == null ? void 0 : o.leaveDurationMs) == "number" ? o.leaveDurationMs : NaN;
266
- let b = Number.isFinite(c) && c > 0 ? c : NaN;
264
+ function m(a, n) {
265
+ const y = parseInt(a.dataset.left || "0", 10), c = parseInt(a.dataset.top || "0", 10), v = typeof (o == null ? void 0 : o.leaveDurationMs) == "number" ? o.leaveDurationMs : NaN;
266
+ let b = Number.isFinite(v) && v > 0 ? v : NaN;
267
267
  if (!Number.isFinite(b)) {
268
- const M = getComputedStyle(a).getPropertyValue("--masonry-leave-duration") || "", P = parseFloat(M);
269
- b = Number.isFinite(P) && P > 0 ? P : 200;
270
- }
271
- const m = a.style.transitionDuration, x = () => {
272
- a.removeEventListener("transitionend", F), clearTimeout(_), a.style.transitionDuration = m || "";
273
- }, F = (H) => {
274
- (!H || H.target === a) && (x(), n());
275
- }, _ = setTimeout(() => {
268
+ const i = getComputedStyle(a).getPropertyValue("--masonry-leave-duration") || "", d = parseFloat(i);
269
+ b = Number.isFinite(d) && d > 0 ? d : 200;
270
+ }
271
+ const f = a.style.transitionDuration, x = () => {
272
+ a.removeEventListener("transitionend", $), clearTimeout(z), a.style.transitionDuration = f || "";
273
+ }, $ = (N) => {
274
+ (!N || N.target === a) && (x(), n());
275
+ }, z = setTimeout(() => {
276
276
  x(), n();
277
277
  }, b + 100);
278
278
  requestAnimationFrame(() => {
279
- a.style.transitionDuration = `${b}ms`, a.style.opacity = "0", a.style.transform = `translate3d(${d}px, ${u + 10}px, 0) scale(0.985)`, a.addEventListener("transitionend", F);
279
+ a.style.transitionDuration = `${b}ms`, a.style.opacity = "0", a.style.transform = `translate3d(${y}px, ${c + 10}px, 0) scale(0.985)`, a.addEventListener("transitionend", $);
280
280
  });
281
281
  }
282
282
  return {
283
283
  onEnter: l,
284
284
  onBeforeEnter: s,
285
- onBeforeLeave: h,
286
- onLeave: v
285
+ onBeforeLeave: T,
286
+ onLeave: m
287
287
  };
288
288
  }
289
289
  function Pt({
@@ -291,21 +291,21 @@ function Pt({
291
291
  masonry: o,
292
292
  columns: l,
293
293
  containerHeight: s,
294
- isLoading: h,
295
- pageSize: v,
294
+ isLoading: T,
295
+ pageSize: m,
296
296
  refreshLayout: a,
297
297
  setItemsRaw: n,
298
- loadNext: d,
299
- loadThresholdPx: u
298
+ loadNext: y,
299
+ loadThresholdPx: c
300
300
  }) {
301
- let c = 0;
302
- async function b(m) {
301
+ let v = 0;
302
+ async function b(f) {
303
303
  if (!e.value) return;
304
- const x = m ?? me(o.value, l.value), F = x.length ? Math.max(...x) : 0, _ = e.value.scrollTop + e.value.clientHeight, H = e.value.scrollTop > c + 1;
305
- c = e.value.scrollTop;
306
- const M = typeof u == "number" ? u : 200, P = M >= 0 ? Math.max(0, F - M) : Math.max(0, F + M);
307
- if (_ >= P && H && !h.value) {
308
- await d(), await Q();
304
+ const x = f ?? ge(o.value, l.value), $ = x.length ? Math.max(...x) : 0, z = e.value.scrollTop + e.value.clientHeight, N = e.value.scrollTop > v + 1;
305
+ v = e.value.scrollTop;
306
+ const i = typeof c == "number" ? c : 200, d = i >= 0 ? Math.max(0, $ - i) : Math.max(0, $ + i);
307
+ if (z >= d && N && !T.value) {
308
+ await y(), await Z();
309
309
  return;
310
310
  }
311
311
  }
@@ -313,101 +313,220 @@ function Pt({
313
313
  handleScroll: b
314
314
  };
315
315
  }
316
- const St = { class: "relative w-full h-full group" }, kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-all duration-300 bg-white relative" }, Et = {
316
+ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-all duration-300 bg-white relative" }, Et = {
317
317
  key: 0,
318
- class: "absolute inset-0 flex items-center justify-center bg-slate-100"
318
+ class: "absolute inset-0 flex flex-col items-center justify-center bg-slate-100 text-slate-400 text-sm p-4 text-center"
319
319
  }, Lt = {
320
320
  key: 1,
321
+ class: "relative w-full h-full"
322
+ }, St = ["src"], Nt = ["src"], Ht = {
323
+ key: 2,
324
+ class: "absolute inset-0 bg-slate-100 flex items-center justify-center"
325
+ }, $t = { class: "flex flex-col items-center justify-center gap-2 text-slate-400" }, At = { class: "w-12 h-12 rounded-full bg-white/80 backdrop-blur-sm flex items-center justify-center shadow-sm" }, Ft = { class: "text-xs font-medium uppercase" }, Wt = {
326
+ key: 3,
327
+ class: "absolute bottom-2 left-1/2 transform -translate-x-1/2 flex items-center justify-center"
328
+ }, jt = {
329
+ key: 4,
321
330
  class: "absolute inset-0 flex flex-col items-center justify-center bg-slate-50 text-slate-400 text-sm p-4 text-center"
322
- }, Ht = ["src"], Nt = { class: "absolute bottom-0 left-0 right-0 p-3 opacity-0 group-hover:opacity-100 transform translate-y-2 group-hover:translate-y-0 transition-all duration-300 delay-75" }, $t = { class: "text-white text-xs font-medium truncate drop-shadow-md" }, ve = /* @__PURE__ */ Le({
331
+ }, Ot = ["title"], Bt = { class: "absolute bottom-0 left-0 right-0 p-3 opacity-0 group-hover:opacity-100 transform translate-y-2 group-hover:translate-y-0 transition-all duration-300 delay-75 pointer-events-none" }, Dt = { class: "text-white text-xs font-medium truncate drop-shadow-md" }, pe = /* @__PURE__ */ Le({
323
332
  __name: "MasonryItem",
324
333
  props: {
325
334
  item: {},
326
- remove: { type: Function }
335
+ remove: {},
336
+ type: { default: void 0 },
337
+ notFound: { type: Boolean, default: void 0 }
327
338
  },
328
339
  setup(e) {
329
- const o = e, l = L(!1), s = L(!1), h = L(null);
330
- function v(a) {
331
- return new Promise((n, d) => {
332
- if (!a) {
333
- d(new Error("No image source provided"));
340
+ const o = e, l = E(!1), s = E(!1), T = E(null), m = E(!1), a = E(!1), n = E(null), y = E(!1), c = E(!1), v = E(null);
341
+ let b = null;
342
+ const f = ee(() => {
343
+ var i;
344
+ return o.type ?? ((i = o.item) == null ? void 0 : i.type) ?? "image";
345
+ }), x = ee(() => {
346
+ var i;
347
+ return o.notFound ?? ((i = o.item) == null ? void 0 : i.notFound) ?? !1;
348
+ });
349
+ function $(i) {
350
+ return new Promise((d, L) => {
351
+ if (!i) {
352
+ L(new Error("No image source provided"));
334
353
  return;
335
354
  }
336
- const u = new Image(), c = Date.now(), b = 300;
337
- u.onload = () => {
338
- const m = Date.now() - c, x = Math.max(0, b - m);
355
+ const I = new Image(), P = Date.now(), h = 300;
356
+ I.onload = () => {
357
+ const S = Date.now() - P, M = Math.max(0, h - S);
339
358
  setTimeout(() => {
340
- l.value = !0, s.value = !1, n();
341
- }, x);
342
- }, u.onerror = () => {
343
- s.value = !0, l.value = !1, d(new Error("Failed to load image"));
344
- }, u.src = a;
359
+ l.value = !0, s.value = !1, c.value = !1, d();
360
+ }, M);
361
+ }, I.onerror = () => {
362
+ s.value = !0, l.value = !1, c.value = !1, L(new Error("Failed to load image"));
363
+ }, I.src = i;
345
364
  });
346
365
  }
347
- return He(async () => {
348
- var n, d;
349
- console.log("[MasonryItem] Component mounted", (n = o.item) == null ? void 0 : n.id);
350
- const a = (d = o.item) == null ? void 0 : d.src;
351
- if (a) {
352
- h.value = a, l.value = !1, s.value = !1;
353
- try {
354
- await v(a);
355
- } catch {
366
+ function z(i) {
367
+ return new Promise((d, L) => {
368
+ if (!i) {
369
+ L(new Error("No video source provided"));
370
+ return;
356
371
  }
357
- }
358
- }), Ne(
359
- () => {
360
- var a;
361
- return (a = o.item) == null ? void 0 : a.src;
362
- },
363
- async (a) => {
364
- if (a && a !== h.value) {
365
- l.value = !1, s.value = !1, h.value = a;
372
+ const I = document.createElement("video"), P = Date.now(), h = 300;
373
+ I.preload = "metadata", I.muted = !0, I.onloadedmetadata = () => {
374
+ const S = Date.now() - P, M = Math.max(0, h - S);
375
+ setTimeout(() => {
376
+ m.value = !0, a.value = !1, c.value = !1, d();
377
+ }, M);
378
+ }, I.onerror = () => {
379
+ a.value = !0, m.value = !1, c.value = !1, L(new Error("Failed to load video"));
380
+ }, I.src = i;
381
+ });
382
+ }
383
+ async function N() {
384
+ var d;
385
+ if (!y.value || c.value || x.value || f.value === "video" && m.value || f.value === "image" && l.value)
386
+ return;
387
+ const i = (d = o.item) == null ? void 0 : d.src;
388
+ if (i)
389
+ if (c.value = !0, f.value === "video") {
390
+ n.value = i, m.value = !1, a.value = !1;
391
+ try {
392
+ await z(i);
393
+ } catch {
394
+ }
395
+ } else {
396
+ T.value = i, l.value = !1, s.value = !1;
366
397
  try {
367
- await v(a);
398
+ await $(i);
368
399
  } catch {
369
400
  }
370
401
  }
402
+ }
403
+ return Se(() => {
404
+ v.value && (b = new IntersectionObserver(
405
+ (i) => {
406
+ i.forEach((d) => {
407
+ d.isIntersecting && d.intersectionRatio >= 1 ? y.value || (y.value = !0, N()) : d.isIntersecting;
408
+ });
409
+ },
410
+ {
411
+ // Only trigger when item is 100% visible (full height in view)
412
+ threshold: [1]
413
+ }
414
+ ), b.observe(v.value));
415
+ }), Ne(() => {
416
+ b && (b.disconnect(), b = null);
417
+ }), He(
418
+ () => {
419
+ var i;
420
+ return (i = o.item) == null ? void 0 : i.src;
421
+ },
422
+ async (i) => {
423
+ if (!(!i || x.value)) {
424
+ if (f.value === "video") {
425
+ if (i !== n.value && (m.value = !1, a.value = !1, n.value = i, y.value)) {
426
+ c.value = !0;
427
+ try {
428
+ await z(i);
429
+ } catch {
430
+ }
431
+ }
432
+ } else if (i !== T.value && (l.value = !1, s.value = !1, T.value = i, y.value)) {
433
+ c.value = !0;
434
+ try {
435
+ await $(i);
436
+ } catch {
437
+ }
438
+ }
439
+ }
371
440
  }
372
- ), (a, n) => (V(), q("div", St, [
373
- $e(a.$slots, "default", {
374
- item: a.item,
375
- remove: a.remove,
441
+ ), (i, d) => (D(), B("div", {
442
+ ref_key: "containerRef",
443
+ ref: v,
444
+ class: "relative w-full h-full group"
445
+ }, [
446
+ $e(i.$slots, "default", {
447
+ item: i.item,
448
+ remove: i.remove,
376
449
  imageLoaded: l.value,
377
- imageError: s.value
450
+ imageError: s.value,
451
+ videoLoaded: m.value,
452
+ videoError: a.value,
453
+ showNotFound: x.value,
454
+ isLoading: c.value,
455
+ mediaType: f.value
378
456
  }, () => [
379
- O("div", kt, [
380
- !l.value && !s.value ? (V(), q("div", Et, n[1] || (n[1] = [
381
- O("div", { class: "animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500" }, null, -1)
382
- ]))) : oe("", !0),
383
- s.value ? (V(), q("div", Lt, n[2] || (n[2] = [
384
- O("i", { class: "fas fa-image text-2xl mb-2 opacity-50" }, null, -1),
385
- O("span", null, "Failed to load image", -1)
386
- ]))) : oe("", !0),
387
- l.value && h.value ? (V(), q("img", {
457
+ k("div", kt, [
458
+ x.value ? (D(), B("div", Et, d[4] || (d[4] = [
459
+ k("i", { class: "fas fa-search text-3xl mb-3 opacity-50" }, null, -1),
460
+ k("span", { class: "font-medium" }, "Not Found", -1),
461
+ k("span", { class: "text-xs mt-1 opacity-75" }, "This item could not be located", -1)
462
+ ]))) : (D(), B("div", Lt, [
463
+ f.value === "image" && l.value && T.value ? (D(), B("img", {
464
+ key: 0,
465
+ src: T.value,
466
+ class: "w-full h-full object-cover transition-transform duration-500 group-hover:scale-105",
467
+ loading: "lazy",
468
+ decoding: "async",
469
+ alt: ""
470
+ }, null, 8, St)) : X("", !0),
471
+ f.value === "video" && m.value && n.value ? (D(), B("video", {
472
+ key: 1,
473
+ src: n.value,
474
+ class: "w-full h-full object-cover transition-transform duration-500 group-hover:scale-105",
475
+ muted: "",
476
+ loop: "",
477
+ playsinline: "",
478
+ onMouseenter: d[0] || (d[0] = (L) => L.target.play()),
479
+ onMouseleave: d[1] || (d[1] = (L) => L.target.pause()),
480
+ onError: d[2] || (d[2] = (L) => a.value = !0)
481
+ }, null, 40, Nt)) : X("", !0),
482
+ !l.value && !m.value && !s.value && !a.value ? (D(), B("div", Ht, [
483
+ k("div", $t, [
484
+ k("div", At, [
485
+ k("i", {
486
+ class: se(f.value === "video" ? "fas fa-video text-xl" : "fas fa-image text-xl")
487
+ }, null, 2)
488
+ ]),
489
+ k("span", Ft, ie(f.value), 1)
490
+ ])
491
+ ])) : X("", !0),
492
+ c.value ? (D(), B("div", Wt, d[5] || (d[5] = [
493
+ k("div", { class: "bg-white/90 backdrop-blur-sm rounded-full px-3 py-1.5 shadow-sm" }, [
494
+ k("div", { class: "animate-spin rounded-full h-4 w-4 border-b-2 border-blue-500" })
495
+ ], -1)
496
+ ]))) : X("", !0),
497
+ f.value === "image" && s.value || f.value === "video" && a.value ? (D(), B("div", jt, [
498
+ k("i", {
499
+ class: se(f.value === "video" ? "fas fa-video text-2xl mb-2 opacity-50" : "fas fa-image text-2xl mb-2 opacity-50")
500
+ }, null, 2),
501
+ k("span", null, "Failed to load " + ie(f.value), 1)
502
+ ])) : X("", !0)
503
+ ])),
504
+ !x.value && (l.value || m.value || c.value) ? (D(), B("div", {
388
505
  key: 2,
389
- src: h.value,
390
- class: "w-full h-full object-cover transition-transform duration-500 group-hover:scale-105",
391
- loading: "lazy",
392
- decoding: "async"
393
- }, null, 8, Ht)) : oe("", !0),
394
- n[4] || (n[4] = O("div", { class: "absolute inset-0 bg-gradient-to-t from-black/50 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300" }, null, -1)),
395
- a.remove ? (V(), q("button", {
506
+ class: "absolute top-2 left-2 w-7 h-7 flex items-center justify-center bg-black/60 backdrop-blur-sm text-white rounded-full shadow-sm opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none",
507
+ title: f.value === "video" ? "Video" : "Image"
508
+ }, [
509
+ k("i", {
510
+ class: se(f.value === "video" ? "fas fa-video text-xs" : "fas fa-image text-xs")
511
+ }, null, 2)
512
+ ], 8, Ot)) : X("", !0),
513
+ d[7] || (d[7] = k("div", { class: "absolute inset-0 bg-gradient-to-t from-black/50 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none" }, null, -1)),
514
+ i.remove ? (D(), B("button", {
396
515
  key: 3,
397
- class: "absolute top-2 right-2 w-8 h-8 flex items-center justify-center bg-white/90 backdrop-blur-sm text-slate-700 rounded-full shadow-sm opacity-0 group-hover:opacity-100 transform translate-y-2 group-hover:translate-y-0 transition-all duration-300 hover:bg-red-500 hover:text-white cursor-pointer",
398
- onClick: n[0] || (n[0] = ze((d) => a.remove(a.item), ["stop"])),
516
+ class: "absolute top-2 right-2 w-8 h-8 flex items-center justify-center bg-white/90 backdrop-blur-sm text-slate-700 rounded-full shadow-sm opacity-0 group-hover:opacity-100 transform translate-y-2 group-hover:translate-y-0 transition-all duration-300 hover:bg-red-500 hover:text-white cursor-pointer z-10",
517
+ onClick: d[3] || (d[3] = ze((L) => i.remove(i.item), ["stop"])),
399
518
  "aria-label": "Remove item"
400
- }, n[3] || (n[3] = [
401
- O("i", { class: "fas fa-times text-sm" }, null, -1)
402
- ]))) : oe("", !0),
403
- O("div", Nt, [
404
- O("p", $t, "Item #" + de(String(a.item.id).split("-")[0]), 1)
519
+ }, d[6] || (d[6] = [
520
+ k("i", { class: "fas fa-times text-sm" }, null, -1)
521
+ ]))) : X("", !0),
522
+ k("div", Bt, [
523
+ k("p", Dt, "Item #" + ie(String(i.item.id).split("-")[0]), 1)
405
524
  ])
406
525
  ])
407
526
  ])
408
- ]));
527
+ ], 512));
409
528
  }
410
- }), At = /* @__PURE__ */ Le({
529
+ }), zt = /* @__PURE__ */ Le({
411
530
  __name: "Masonry",
412
531
  props: {
413
532
  getNextPage: {
@@ -508,7 +627,7 @@ const St = { class: "relative w-full h-full group" }, kt = { class: "w-full h-fu
508
627
  "remove-all:complete"
509
628
  ],
510
629
  setup(e, { expose: o, emit: l }) {
511
- const s = e, h = {
630
+ const s = e, T = {
512
631
  sizes: { base: 1, sm: 2, md: 3, lg: 4, xl: 5, "2xl": 6 },
513
632
  gutterX: 10,
514
633
  gutterY: 10,
@@ -517,41 +636,41 @@ const St = { class: "relative w-full h-full group" }, kt = { class: "w-full h-fu
517
636
  paddingLeft: 0,
518
637
  paddingRight: 0,
519
638
  placement: "masonry"
520
- }, v = se(() => {
639
+ }, m = ee(() => {
521
640
  var t;
522
641
  return {
523
- ...h,
642
+ ...T,
524
643
  ...s.layout,
525
644
  sizes: {
526
- ...h.sizes,
645
+ ...T.sizes,
527
646
  ...((t = s.layout) == null ? void 0 : t.sizes) || {}
528
647
  }
529
648
  };
530
- }), a = l, n = se({
649
+ }), a = l, n = ee({
531
650
  get: () => s.items,
532
651
  set: (t) => a("update:items", t)
533
- }), d = L(7), u = L(null), c = L([]), b = L(null), m = L(!1), x = L(0), F = L(/* @__PURE__ */ new Set());
534
- function _(t) {
652
+ }), y = E(7), c = E(null), v = E([]), b = E(null), f = E(!1), x = E(0), $ = E(/* @__PURE__ */ new Set());
653
+ function z(t) {
535
654
  return typeof t == "number" && Number.isFinite(t) && t > 0;
536
655
  }
537
- function H(t, r) {
656
+ function N(t, r) {
538
657
  try {
539
658
  if (!Array.isArray(t) || t.length === 0) return;
540
- const i = t.filter((g) => !_(g == null ? void 0 : g.width) || !_(g == null ? void 0 : g.height));
541
- if (i.length === 0) return;
542
- const f = [];
543
- for (const g of i) {
544
- const A = (g == null ? void 0 : g.id) ?? `idx:${t.indexOf(g)}`;
545
- F.value.has(A) || (F.value.add(A), f.push(A));
659
+ const u = t.filter((p) => !z(p == null ? void 0 : p.width) || !z(p == null ? void 0 : p.height));
660
+ if (u.length === 0) return;
661
+ const g = [];
662
+ for (const p of u) {
663
+ const O = (p == null ? void 0 : p.id) ?? `idx:${t.indexOf(p)}`;
664
+ $.value.has(O) || ($.value.add(O), g.push(O));
546
665
  }
547
- if (f.length > 0) {
548
- const g = f.slice(0, 10);
666
+ if (g.length > 0) {
667
+ const p = g.slice(0, 10);
549
668
  console.warn(
550
669
  "[Masonry] Items missing width/height detected:",
551
670
  {
552
671
  context: r,
553
- count: f.length,
554
- sampleIds: g,
672
+ count: g.length,
673
+ sampleIds: p,
555
674
  hint: "Ensure each item has positive width and height. Consider providing fallbacks (e.g., 512x512) at the data layer."
556
675
  }
557
676
  );
@@ -559,364 +678,367 @@ const St = { class: "relative w-full h-full group" }, kt = { class: "w-full h-fu
559
678
  } catch {
560
679
  }
561
680
  }
562
- const M = L(0), P = L(0), U = s.virtualBufferPx, S = L(!1), T = L({
681
+ const i = E(0), d = E(0), L = s.virtualBufferPx, I = E(!1), P = E({
563
682
  distanceToTrigger: 0,
564
683
  isNearTrigger: !1
565
- }), y = (t) => {
566
- if (!u.value) return;
567
- const { scrollTop: r, clientHeight: i } = u.value, f = r + i, g = t ?? me(n.value, d.value), A = g.length ? Math.max(...g) : 0, C = typeof s.loadThresholdPx == "number" ? s.loadThresholdPx : 200, K = C >= 0 ? Math.max(0, A - C) : Math.max(0, A + C), xe = Math.max(0, K - f), je = xe <= 100;
568
- T.value = {
569
- distanceToTrigger: Math.round(xe),
570
- isNearTrigger: je
684
+ }), h = (t) => {
685
+ if (!c.value) return;
686
+ const { scrollTop: r, clientHeight: u } = c.value, g = r + u, p = t ?? ge(n.value, y.value), O = p.length ? Math.max(...p) : 0, G = typeof s.loadThresholdPx == "number" ? s.loadThresholdPx : 200, Q = G >= 0 ? Math.max(0, O - G) : Math.max(0, O + G), we = Math.max(0, Q - g), De = we <= 100;
687
+ P.value = {
688
+ distanceToTrigger: Math.round(we),
689
+ isNearTrigger: De
571
690
  };
572
- }, { onEnter: W, onBeforeEnter: w, onBeforeLeave: N, onLeave: I } = It(n, { leaveDurationMs: s.leaveDurationMs });
573
- function D(t, r) {
574
- if (S.value) {
575
- const i = parseInt(t.dataset.left || "0", 10), f = parseInt(t.dataset.top || "0", 10);
576
- t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${i}px, ${f}px, 0) scale(1)`, t.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
691
+ }, { onEnter: S, onBeforeEnter: M, onBeforeLeave: W, onLeave: H } = It(n, { leaveDurationMs: s.leaveDurationMs });
692
+ function _(t, r) {
693
+ if (I.value) {
694
+ const u = parseInt(t.dataset.left || "0", 10), g = parseInt(t.dataset.top || "0", 10);
695
+ t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${u}px, ${g}px, 0) scale(1)`, t.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
577
696
  t.style.transition = "", r();
578
697
  });
579
698
  } else
580
- W(t, r);
699
+ S(t, r);
581
700
  }
582
- function Z(t) {
583
- if (S.value) {
584
- const r = parseInt(t.dataset.left || "0", 10), i = parseInt(t.dataset.top || "0", 10);
585
- t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${r}px, ${i}px, 0) scale(1)`, t.style.removeProperty("--masonry-opacity-delay");
701
+ function te(t) {
702
+ if (I.value) {
703
+ const r = parseInt(t.dataset.left || "0", 10), u = parseInt(t.dataset.top || "0", 10);
704
+ t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${r}px, ${u}px, 0) scale(1)`, t.style.removeProperty("--masonry-opacity-delay");
586
705
  } else
587
- w(t);
706
+ M(t);
588
707
  }
589
- function ee(t) {
590
- S.value || N(t);
708
+ function ae(t) {
709
+ I.value || W(t);
591
710
  }
592
- function X(t, r) {
593
- S.value ? r() : I(t, r);
711
+ function Y(t, r) {
712
+ I.value ? r() : H(t, r);
594
713
  }
595
- const te = se(() => {
596
- const t = M.value - U, r = M.value + P.value + U, i = n.value;
597
- return !i || i.length === 0 ? [] : i.filter((f) => {
598
- const g = f.top;
599
- return f.top + f.columnHeight >= t && g <= r;
714
+ const ne = ee(() => {
715
+ const t = i.value - L, r = i.value + d.value + L, u = n.value;
716
+ return !u || u.length === 0 ? [] : u.filter((g) => {
717
+ const p = g.top;
718
+ return g.top + g.columnHeight >= t && p <= r;
600
719
  });
601
- }), { handleScroll: Y } = Pt({
602
- container: u,
720
+ }), { handleScroll: J } = Pt({
721
+ container: c,
603
722
  masonry: n,
604
- columns: d,
723
+ columns: y,
605
724
  containerHeight: x,
606
- isLoading: m,
725
+ isLoading: f,
607
726
  pageSize: s.pageSize,
608
- refreshLayout: j,
727
+ refreshLayout: C,
609
728
  setItemsRaw: (t) => {
610
729
  n.value = t;
611
730
  },
612
- loadNext: z,
731
+ loadNext: q,
613
732
  loadThresholdPx: s.loadThresholdPx
614
733
  });
615
734
  o({
616
- isLoading: m,
617
- refreshLayout: j,
735
+ isLoading: f,
736
+ refreshLayout: C,
618
737
  containerHeight: x,
619
- remove: G,
620
- removeMany: R,
621
- removeAll: Be,
622
- loadNext: z,
623
- loadPage: B,
624
- refreshCurrentPage: $,
738
+ remove: U,
739
+ removeMany: V,
740
+ removeAll: We,
741
+ loadNext: q,
742
+ loadPage: R,
743
+ refreshCurrentPage: j,
625
744
  reset: Oe,
626
- init: De,
627
- paginationHistory: c,
745
+ init: Be,
746
+ paginationHistory: v,
628
747
  cancelLoad: he,
629
- scrollToTop: pe,
630
- totalItems: se(() => n.value.length)
748
+ scrollToTop: ye,
749
+ totalItems: ee(() => n.value.length)
631
750
  });
632
- function J(t) {
751
+ function K(t) {
633
752
  const r = wt(t);
634
- let i = 0;
635
- if (u.value) {
636
- const { scrollTop: f, clientHeight: g } = u.value;
637
- i = f + g + 100;
753
+ let u = 0;
754
+ if (c.value) {
755
+ const { scrollTop: g, clientHeight: p } = c.value;
756
+ u = g + p + 100;
638
757
  }
639
- x.value = Math.max(r, i);
640
- }
641
- function j(t) {
642
- if (!u.value) return;
643
- H(t, "refreshLayout");
644
- const r = t.map((f, g) => ({
645
- ...f,
646
- originalIndex: f.originalIndex ?? g
647
- })), i = Ye(r, u.value, d.value, v.value);
648
- J(i), n.value = i;
649
- }
650
- function ae(t, r) {
651
- return new Promise((i) => {
652
- const f = Math.max(0, t | 0), g = Date.now();
653
- r(f, f);
654
- const A = setInterval(() => {
655
- if (E.value) {
656
- clearInterval(A), i();
758
+ x.value = Math.max(r, u);
759
+ }
760
+ function C(t) {
761
+ if (!c.value) return;
762
+ N(t, "refreshLayout");
763
+ const r = t.map((g, p) => ({
764
+ ...g,
765
+ originalIndex: g.originalIndex ?? p
766
+ })), u = Ye(r, c.value, y.value, m.value);
767
+ K(u), n.value = u;
768
+ }
769
+ function re(t, r) {
770
+ return new Promise((u) => {
771
+ const g = Math.max(0, t | 0), p = Date.now();
772
+ r(g, g);
773
+ const O = setInterval(() => {
774
+ if (F.value) {
775
+ clearInterval(O), u();
657
776
  return;
658
777
  }
659
- const C = Date.now() - g, K = Math.max(0, f - C);
660
- r(K, f), K <= 0 && (clearInterval(A), i());
778
+ const G = Date.now() - p, Q = Math.max(0, g - G);
779
+ r(Q, g), Q <= 0 && (clearInterval(O), u());
661
780
  }, 100);
662
781
  });
663
782
  }
664
- async function p(t) {
783
+ async function w(t) {
665
784
  try {
666
- const r = await k(() => s.getNextPage(t));
667
- return j([...n.value, ...r.items]), r;
785
+ const r = await A(() => s.getNextPage(t));
786
+ return C([...n.value, ...r.items]), r;
668
787
  } catch (r) {
669
788
  throw console.error("Error in getContent:", r), r;
670
789
  }
671
790
  }
672
- async function k(t) {
791
+ async function A(t) {
673
792
  let r = 0;
674
- const i = s.retryMaxAttempts;
675
- let f = s.retryInitialDelayMs;
793
+ const u = s.retryMaxAttempts;
794
+ let g = s.retryInitialDelayMs;
676
795
  for (; ; )
677
796
  try {
678
- const g = await t();
679
- return r > 0 && a("retry:stop", { attempt: r, success: !0 }), g;
680
- } catch (g) {
681
- if (r++, r > i)
682
- throw a("retry:stop", { attempt: r - 1, success: !1 }), g;
683
- a("retry:start", { attempt: r, max: i, totalMs: f }), await ae(f, (A, C) => {
684
- a("retry:tick", { attempt: r, remainingMs: A, totalMs: C });
685
- }), f += s.retryBackoffStepMs;
797
+ const p = await t();
798
+ return r > 0 && a("retry:stop", { attempt: r, success: !0 }), p;
799
+ } catch (p) {
800
+ if (r++, r > u)
801
+ throw a("retry:stop", { attempt: r - 1, success: !1 }), p;
802
+ a("retry:start", { attempt: r, max: u, totalMs: g }), await re(g, (O, G) => {
803
+ a("retry:tick", { attempt: r, remainingMs: O, totalMs: G });
804
+ }), g += s.retryBackoffStepMs;
686
805
  }
687
806
  }
688
- async function B(t) {
689
- if (!m.value) {
690
- E.value = !1, m.value = !0;
807
+ async function R(t) {
808
+ if (!f.value) {
809
+ F.value = !1, f.value = !0;
691
810
  try {
692
811
  const r = n.value.length;
693
- if (E.value) return;
694
- const i = await p(t);
695
- return E.value ? void 0 : (b.value = t, c.value.push(i.nextPage), await ne(r), i);
812
+ if (F.value) return;
813
+ const u = await w(t);
814
+ return F.value ? void 0 : (b.value = t, v.value.push(u.nextPage), await oe(r), u);
696
815
  } catch (r) {
697
816
  throw console.error("Error loading page:", r), r;
698
817
  } finally {
699
- m.value = !1;
818
+ f.value = !1;
700
819
  }
701
820
  }
702
821
  }
703
- async function z() {
704
- if (!m.value) {
705
- E.value = !1, m.value = !0;
822
+ async function q() {
823
+ if (!f.value) {
824
+ F.value = !1, f.value = !0;
706
825
  try {
707
826
  const t = n.value.length;
708
- if (E.value) return;
709
- const r = c.value[c.value.length - 1], i = await p(r);
710
- return E.value ? void 0 : (b.value = r, c.value.push(i.nextPage), await ne(t), i);
827
+ if (F.value) return;
828
+ const r = v.value[v.value.length - 1], u = await w(r);
829
+ return F.value ? void 0 : (b.value = r, v.value.push(u.nextPage), await oe(t), u);
711
830
  } catch (t) {
712
831
  throw console.error("Error loading next page:", t), t;
713
832
  } finally {
714
- m.value = !1;
833
+ f.value = !1;
715
834
  }
716
835
  }
717
836
  }
718
- async function $() {
719
- if (console.log("[Masonry] refreshCurrentPage called, isLoading:", m.value, "currentPage:", b.value), !m.value) {
720
- E.value = !1, m.value = !0;
837
+ async function j() {
838
+ if (console.log("[Masonry] refreshCurrentPage called, isLoading:", f.value, "currentPage:", b.value), !f.value) {
839
+ F.value = !1, f.value = !0;
721
840
  try {
722
841
  const t = b.value;
723
842
  if (console.log("[Masonry] pageToRefresh:", t), t == null) {
724
- console.warn("[Masonry] No current page to refresh - currentPage:", b.value, "paginationHistory:", c.value);
843
+ console.warn("[Masonry] No current page to refresh - currentPage:", b.value, "paginationHistory:", v.value);
725
844
  return;
726
845
  }
727
- n.value = [], x.value = 0, c.value = [t], await Q();
728
- const r = await p(t);
729
- if (E.value) return;
730
- b.value = t, c.value.push(r.nextPage);
731
- const i = n.value.length;
732
- return await ne(i), r;
846
+ n.value = [], x.value = 0, v.value = [t], await Z();
847
+ const r = await w(t);
848
+ if (F.value) return;
849
+ b.value = t, v.value.push(r.nextPage);
850
+ const u = n.value.length;
851
+ return await oe(u), r;
733
852
  } catch (t) {
734
853
  throw console.error("[Masonry] Error refreshing current page:", t), t;
735
854
  } finally {
736
- m.value = !1;
855
+ f.value = !1;
737
856
  }
738
857
  }
739
858
  }
740
- async function G(t) {
741
- const r = n.value.filter((i) => i.id !== t.id);
742
- if (n.value = r, await Q(), console.log("[Masonry] remove - next.length:", r.length, "paginationHistory.length:", c.value.length), r.length === 0 && c.value.length > 0) {
859
+ async function U(t) {
860
+ const r = n.value.filter((u) => u.id !== t.id);
861
+ if (n.value = r, await Z(), console.log("[Masonry] remove - next.length:", r.length, "paginationHistory.length:", v.value.length), r.length === 0 && v.value.length > 0) {
743
862
  if (s.autoRefreshOnEmpty)
744
- console.log("[Masonry] All items removed, calling refreshCurrentPage"), await $();
863
+ console.log("[Masonry] All items removed, calling refreshCurrentPage"), await j();
745
864
  else {
746
865
  console.log("[Masonry] All items removed, calling loadNext and forcing backfill");
747
866
  try {
748
- await z(), await ne(0, !0);
867
+ await q(), await oe(0, !0);
749
868
  } catch {
750
869
  }
751
870
  }
752
871
  return;
753
872
  }
754
- await new Promise((i) => requestAnimationFrame(() => i())), requestAnimationFrame(() => {
755
- j(r);
873
+ await new Promise((u) => requestAnimationFrame(() => u())), requestAnimationFrame(() => {
874
+ C(r);
756
875
  });
757
876
  }
758
- async function R(t) {
877
+ async function V(t) {
759
878
  if (!t || t.length === 0) return;
760
- const r = new Set(t.map((f) => f.id)), i = n.value.filter((f) => !r.has(f.id));
761
- if (n.value = i, await Q(), i.length === 0 && c.value.length > 0) {
879
+ const r = new Set(t.map((g) => g.id)), u = n.value.filter((g) => !r.has(g.id));
880
+ if (n.value = u, await Z(), u.length === 0 && v.value.length > 0) {
762
881
  if (s.autoRefreshOnEmpty)
763
- await $();
882
+ await j();
764
883
  else
765
884
  try {
766
- await z(), await ne(0, !0);
885
+ await q(), await oe(0, !0);
767
886
  } catch {
768
887
  }
769
888
  return;
770
889
  }
771
- await new Promise((f) => requestAnimationFrame(() => f())), requestAnimationFrame(() => {
772
- j(i);
890
+ await new Promise((g) => requestAnimationFrame(() => g())), requestAnimationFrame(() => {
891
+ C(u);
773
892
  });
774
893
  }
775
- function pe(t) {
776
- u.value && u.value.scrollTo({
894
+ function ye(t) {
895
+ c.value && c.value.scrollTo({
777
896
  top: 0,
778
897
  behavior: (t == null ? void 0 : t.behavior) ?? "smooth",
779
898
  ...t
780
899
  });
781
900
  }
782
- async function Be() {
783
- pe({ behavior: "smooth" }), n.value = [], x.value = 0, await Q(), a("remove-all:complete");
901
+ async function We() {
902
+ ye({ behavior: "smooth" }), n.value = [], x.value = 0, await Z(), a("remove-all:complete");
784
903
  }
785
- function Fe() {
786
- d.value = fe(v.value), j(n.value), u.value && (M.value = u.value.scrollTop, P.value = u.value.clientHeight);
904
+ function je() {
905
+ y.value = ve(m.value), C(n.value), c.value && (i.value = c.value.scrollTop, d.value = c.value.clientHeight);
787
906
  }
788
- let le = !1;
789
- const E = L(!1);
790
- async function ne(t, r = !1) {
791
- if (!r && !s.backfillEnabled || le || E.value) return;
792
- const i = (t || 0) + (s.pageSize || 0);
793
- if (!(!s.pageSize || s.pageSize <= 0 || c.value[c.value.length - 1] == null) && !(n.value.length >= i)) {
794
- le = !0;
907
+ let ue = !1;
908
+ const F = E(!1);
909
+ async function oe(t, r = !1) {
910
+ if (!r && !s.backfillEnabled || ue || F.value) return;
911
+ const u = (t || 0) + (s.pageSize || 0);
912
+ if (!(!s.pageSize || s.pageSize <= 0 || v.value[v.value.length - 1] == null) && !(n.value.length >= u)) {
913
+ ue = !0;
795
914
  try {
796
- let g = 0;
797
- for (a("backfill:start", { target: i, fetched: n.value.length, calls: g }); n.value.length < i && g < s.backfillMaxCalls && c.value[c.value.length - 1] != null && !E.value && (await ae(s.backfillDelayMs, (C, K) => {
915
+ let p = 0;
916
+ for (a("backfill:start", { target: u, fetched: n.value.length, calls: p }); n.value.length < u && p < s.backfillMaxCalls && v.value[v.value.length - 1] != null && !F.value && (await re(s.backfillDelayMs, (G, Q) => {
798
917
  a("backfill:tick", {
799
918
  fetched: n.value.length,
800
- target: i,
801
- calls: g,
802
- remainingMs: C,
803
- totalMs: K
919
+ target: u,
920
+ calls: p,
921
+ remainingMs: G,
922
+ totalMs: Q
804
923
  });
805
- }), !E.value); ) {
806
- const A = c.value[c.value.length - 1];
924
+ }), !F.value); ) {
925
+ const O = v.value[v.value.length - 1];
807
926
  try {
808
- m.value = !0;
809
- const C = await p(A);
810
- if (E.value) break;
811
- c.value.push(C.nextPage);
927
+ f.value = !0;
928
+ const G = await w(O);
929
+ if (F.value) break;
930
+ v.value.push(G.nextPage);
812
931
  } finally {
813
- m.value = !1;
932
+ f.value = !1;
814
933
  }
815
- g++;
934
+ p++;
816
935
  }
817
- a("backfill:stop", { fetched: n.value.length, calls: g });
936
+ a("backfill:stop", { fetched: n.value.length, calls: p });
818
937
  } finally {
819
- le = !1;
938
+ ue = !1;
820
939
  }
821
940
  }
822
941
  }
823
942
  function he() {
824
- E.value = !0, m.value = !1, le = !1;
943
+ F.value = !0, f.value = !1, ue = !1;
825
944
  }
826
945
  function Oe() {
827
- he(), E.value = !1, u.value && u.value.scrollTo({
946
+ he(), F.value = !1, c.value && c.value.scrollTo({
828
947
  top: 0,
829
948
  behavior: "smooth"
830
- }), n.value = [], x.value = 0, b.value = s.loadAtPage, c.value = [s.loadAtPage], T.value = {
949
+ }), n.value = [], x.value = 0, b.value = s.loadAtPage, v.value = [s.loadAtPage], P.value = {
831
950
  distanceToTrigger: 0,
832
951
  isNearTrigger: !1
833
952
  };
834
953
  }
835
- const ye = ke(async () => {
836
- u.value && (M.value = u.value.scrollTop, P.value = u.value.clientHeight), S.value = !0, await Q(), await new Promise((r) => requestAnimationFrame(() => r())), S.value = !1;
837
- const t = me(n.value, d.value);
838
- Y(t), y(t);
839
- }, 200), be = ke(Fe, 200);
840
- function De(t, r, i) {
841
- b.value = r, c.value = [r], c.value.push(i), H(t, "init"), j([...n.value, ...t]), y();
954
+ const be = ke(async () => {
955
+ c.value && (i.value = c.value.scrollTop, d.value = c.value.clientHeight), I.value = !0, await Z(), await new Promise((r) => requestAnimationFrame(() => r())), I.value = !1;
956
+ const t = ge(n.value, y.value);
957
+ J(t), h(t);
958
+ }, 200), xe = ke(je, 200);
959
+ function Be(t, r, u) {
960
+ b.value = r, v.value = [r], v.value.push(u), N(t, "init"), C([...n.value, ...t]), h();
842
961
  }
843
- return Ne(
844
- v,
962
+ return He(
963
+ m,
845
964
  () => {
846
- u.value && (d.value = fe(v.value), j(n.value));
965
+ c.value && (y.value = ve(m.value), C(n.value));
847
966
  },
848
967
  { deep: !0 }
849
- ), He(async () => {
968
+ ), Se(async () => {
850
969
  var t;
851
970
  try {
852
- d.value = fe(v.value), u.value && (M.value = u.value.scrollTop, P.value = u.value.clientHeight);
971
+ y.value = ve(m.value), c.value && (i.value = c.value.scrollTop, d.value = c.value.clientHeight);
853
972
  const r = s.loadAtPage;
854
- c.value = [r], s.skipInitialLoad || await B(c.value[0]), y();
973
+ v.value = [r], s.skipInitialLoad || await R(v.value[0]), h();
855
974
  } catch (r) {
856
- console.error("Error during component initialization:", r), m.value = !1;
975
+ console.error("Error during component initialization:", r), f.value = !1;
857
976
  }
858
- (t = u.value) == null || t.addEventListener("scroll", ye, { passive: !0 }), window.addEventListener("resize", be);
859
- }), Re(() => {
977
+ (t = c.value) == null || t.addEventListener("scroll", be, { passive: !0 }), window.addEventListener("resize", xe);
978
+ }), Ne(() => {
860
979
  var t;
861
- (t = u.value) == null || t.removeEventListener("scroll", ye), window.removeEventListener("resize", be);
862
- }), (t, r) => (V(), q("div", {
863
- class: we(["overflow-auto w-full flex-1 masonry-container", { "force-motion": s.forceMotion }]),
980
+ (t = c.value) == null || t.removeEventListener("scroll", be), window.removeEventListener("resize", xe);
981
+ }), (t, r) => (D(), B("div", {
982
+ class: se(["overflow-auto w-full flex-1 masonry-container", { "force-motion": s.forceMotion }]),
864
983
  ref_key: "container",
865
- ref: u
984
+ ref: c
866
985
  }, [
867
- O("div", {
986
+ k("div", {
868
987
  class: "relative",
869
- style: Ce({ height: `${x.value}px`, "--masonry-duration": `${e.transitionDurationMs}ms`, "--masonry-leave-duration": `${e.leaveDurationMs}ms`, "--masonry-ease": e.transitionEasing })
988
+ style: Re({ height: `${x.value}px`, "--masonry-duration": `${e.transitionDurationMs}ms`, "--masonry-leave-duration": `${e.leaveDurationMs}ms`, "--masonry-ease": e.transitionEasing })
870
989
  }, [
871
- Me(_e, {
990
+ Te(_e, {
872
991
  name: "masonry",
873
992
  css: !1,
874
- onEnter: D,
875
- onBeforeEnter: Z,
876
- onLeave: X,
877
- onBeforeLeave: ee
993
+ onEnter: _,
994
+ onBeforeEnter: te,
995
+ onLeave: Y,
996
+ onBeforeLeave: ae
878
997
  }, {
879
- default: qe(() => [
880
- (V(!0), q(Ve, null, Ge(te.value, (i, f) => (V(), q("div", Te({
881
- key: `${i.page}-${i.id}`,
998
+ default: Ce(() => [
999
+ (D(!0), B(qe, null, Ve(ne.value, (u, g) => (D(), B("div", Ge({
1000
+ key: `${u.page}-${u.id}`,
882
1001
  class: "absolute masonry-item",
883
1002
  ref_for: !0
884
- }, Ue(Tt)(i, f), {
885
- style: { paddingTop: `${v.value.header}px`, paddingBottom: `${v.value.footer}px` }
1003
+ }, Ue(Mt)(u, g), {
1004
+ style: { paddingTop: `${m.value.header}px`, paddingBottom: `${m.value.footer}px` }
886
1005
  }), [
887
- $e(t.$slots, "item", Te({ ref_for: !0 }, { item: i, remove: G }), () => [
888
- Me(ve, {
889
- item: i,
890
- remove: G
1006
+ $e(t.$slots, "default", {
1007
+ item: u,
1008
+ remove: U
1009
+ }, () => [
1010
+ Te(pe, {
1011
+ item: u,
1012
+ remove: U
891
1013
  }, null, 8, ["item"])
892
1014
  ], !0)
893
1015
  ], 16))), 128))
894
1016
  ]),
895
1017
  _: 3
896
1018
  }),
897
- x.value > 0 ? (V(), q("div", {
1019
+ x.value > 0 ? (D(), B("div", {
898
1020
  key: 0,
899
- class: we(["fixed bottom-4 right-4 bg-gray-800 text-white text-xs rounded-full px-3 py-1.5 shadow-lg z-10 transition-opacity duration-300", { "opacity-50 hover:opacity-100": !T.value.isNearTrigger, "opacity-100": T.value.isNearTrigger }])
1021
+ class: se(["fixed bottom-4 right-4 bg-gray-800 text-white text-xs rounded-full px-3 py-1.5 shadow-lg z-10 transition-opacity duration-300", { "opacity-50 hover:opacity-100": !P.value.isNearTrigger, "opacity-100": P.value.isNearTrigger }])
900
1022
  }, [
901
- O("span", null, de(n.value.length) + " items", 1),
902
- r[0] || (r[0] = O("span", { class: "mx-2" }, "|", -1)),
903
- O("span", null, de(T.value.distanceToTrigger) + "px to load", 1)
904
- ], 2)) : oe("", !0)
1023
+ k("span", null, ie(n.value.length) + " items", 1),
1024
+ r[0] || (r[0] = k("span", { class: "mx-2" }, "|", -1)),
1025
+ k("span", null, ie(P.value.distanceToTrigger) + "px to load", 1)
1026
+ ], 2)) : X("", !0)
905
1027
  ], 4)
906
1028
  ], 2));
907
1029
  }
908
- }), Wt = (e, o) => {
1030
+ }), Rt = (e, o) => {
909
1031
  const l = e.__vccOpts || e;
910
- for (const [s, h] of o)
911
- l[s] = h;
1032
+ for (const [s, T] of o)
1033
+ l[s] = T;
912
1034
  return l;
913
- }, Ee = /* @__PURE__ */ Wt(At, [["__scopeId", "data-v-08b0e6d9"]]), Ft = {
1035
+ }, Ee = /* @__PURE__ */ Rt(zt, [["__scopeId", "data-v-110c3294"]]), Ct = {
914
1036
  install(e) {
915
- e.component("WyxosMasonry", Ee), e.component("WMasonry", Ee), e.component("WyxosMasonryItem", ve), e.component("WMasonryItem", ve);
1037
+ e.component("WyxosMasonry", Ee), e.component("WMasonry", Ee), e.component("WyxosMasonryItem", pe), e.component("WMasonryItem", pe);
916
1038
  }
917
1039
  };
918
1040
  export {
919
1041
  Ee as Masonry,
920
- ve as MasonryItem,
921
- Ft as default
1042
+ pe as MasonryItem,
1043
+ Ct as default
922
1044
  };