@wyxos/vibe 1.6.3 → 1.6.4

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