@wyxos/vibe 1.4.1 → 1.5.0

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,23 @@
1
- import { nextTick as X, defineComponent as gt, computed as et, ref as B, onMounted as pt, onUnmounted as mt, createElementBlock as Y, openBlock as J, normalizeClass as nt, createElementVNode as C, normalizeStyle as ht, createVNode as yt, createCommentVNode as vt, TransitionGroup as bt, unref as q, withCtx as xt, Fragment as wt, renderList as Tt, mergeProps as at, renderSlot as Mt, toDisplayString as rt } from "vue";
2
- function It() {
3
- const t = document.createElement("div");
4
- t.style.visibility = "hidden", t.style.overflow = "scroll", t.style.msOverflowStyle = "scrollbar", t.style.width = "100px", t.style.height = "100px", document.body.appendChild(t);
5
- const a = document.createElement("div");
6
- a.style.width = "100%", t.appendChild(a);
7
- const o = t.offsetWidth - a.offsetWidth;
8
- return document.body.removeChild(t), o;
1
+ import { nextTick as ee, defineComponent as Ne, computed as ae, ref as j, onMounted as $e, onUnmounted as Ae, createElementBlock as re, openBlock as oe, normalizeClass as he, createElementVNode as V, normalizeStyle as We, createVNode as Be, createCommentVNode as ze, TransitionGroup as Fe, withCtx as Oe, Fragment as De, renderList as je, mergeProps as me, unref as Re, renderSlot as _e, toDisplayString as ve } from "vue";
2
+ let se = null;
3
+ function Ce() {
4
+ if (se != null) return se;
5
+ const e = document.createElement("div");
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
+ const o = document.createElement("div");
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
11
  }
10
- function St(t, a, o, l = {}) {
12
+ function qe(e, o, i, s = {}) {
11
13
  const {
12
- gutterX: b = 0,
13
- gutterY: r = 0,
14
- header: d = 0,
15
- footer: i = 0,
16
- paddingLeft: w = 0,
17
- paddingRight: m = 0,
18
- sizes: h = {
14
+ gutterX: m = 0,
15
+ gutterY: v = 0,
16
+ header: n = 0,
17
+ footer: r = 0,
18
+ paddingLeft: y = 0,
19
+ paddingRight: c = 0,
20
+ sizes: f = {
19
21
  base: 1,
20
22
  sm: 2,
21
23
  md: 3,
@@ -23,295 +25,295 @@ function St(t, a, o, l = {}) {
23
25
  xl: 5,
24
26
  "2xl": 6
25
27
  },
26
- placement: g = "masonry"
27
- } = l;
28
- let x = 0, E = 0;
28
+ placement: d = "masonry"
29
+ } = s;
30
+ let x = 0, w = 0;
29
31
  try {
30
- if (a && a.nodeType === 1 && typeof window < "u" && window.getComputedStyle) {
31
- const u = window.getComputedStyle(a);
32
- x = parseFloat(u.paddingLeft) || 0, E = parseFloat(u.paddingRight) || 0;
32
+ if (o && o.nodeType === 1 && typeof window < "u" && window.getComputedStyle) {
33
+ const b = window.getComputedStyle(o);
34
+ x = parseFloat(b.paddingLeft) || 0, w = parseFloat(b.paddingRight) || 0;
33
35
  }
34
36
  } catch {
35
37
  }
36
- const W = (w || 0) + x, O = (m || 0) + E, M = a.offsetWidth - a.clientWidth, T = M > 0 ? M + 2 : It() + 2, L = a.offsetWidth - T - W - O, $ = b * (o - 1), I = Math.floor((L - $) / o), p = t.map((u) => {
37
- const k = u.width, H = u.height;
38
- return Math.round(I * H / k) + i + d;
38
+ const W = (y || 0) + x, R = (c || 0) + w, T = o.offsetWidth - o.clientWidth, M = T > 0 ? T + 2 : Ce() + 2, N = o.offsetWidth - M - W - R, F = m * (i - 1), H = Math.floor((N - F) / i), k = e.map((b) => {
39
+ const L = b.width, S = b.height;
40
+ return Math.round(H * S / L) + r + n;
39
41
  });
40
- if (g === "sequential-balanced") {
41
- const u = p.length;
42
- if (u === 0) return [];
43
- const k = (e, n, c) => e + (n > 0 ? r : 0) + c;
44
- let H = Math.max(...p), N = p.reduce((e, n) => e + n, 0) + r * Math.max(0, u - 1);
45
- const R = (e) => {
46
- let n = 1, c = 0, f = 0;
47
- for (let y = 0; y < u; y++) {
48
- const P = p[y], S = k(c, f, P);
49
- if (S <= e)
50
- c = S, f++;
51
- else if (n++, c = P, f = 1, P > e || n > o) return !1;
42
+ if (d === "sequential-balanced") {
43
+ const b = k.length;
44
+ if (b === 0) return [];
45
+ const L = (p, I, A) => p + (I > 0 ? v : 0) + A;
46
+ let S = Math.max(...k), O = k.reduce((p, I) => p + I, 0) + v * Math.max(0, b - 1);
47
+ const Y = (p) => {
48
+ let I = 1, A = 0, _ = 0;
49
+ for (let z = 0; z < b; z++) {
50
+ const q = k[z], D = L(A, _, q);
51
+ if (D <= p)
52
+ A = D, _++;
53
+ else if (I++, A = q, _ = 1, q > p || I > i) return !1;
52
54
  }
53
- return n <= o;
55
+ return I <= i;
54
56
  };
55
- for (; H < N; ) {
56
- const e = Math.floor((H + N) / 2);
57
- R(e) ? N = e : H = e + 1;
57
+ for (; S < O; ) {
58
+ const p = Math.floor((S + O) / 2);
59
+ Y(p) ? O = p : S = p + 1;
58
60
  }
59
- const _ = N, A = new Array(o).fill(0);
60
- let z = o - 1, D = 0, j = 0;
61
- for (let e = u - 1; e >= 0; e--) {
62
- const n = p[e], c = e < z;
63
- !(k(D, j, n) <= _) || c ? (A[z] = e + 1, z--, D = n, j = 1) : (D = k(D, j, n), j++);
61
+ const J = O, G = new Array(i).fill(0);
62
+ let K = i - 1, U = 0, B = 0;
63
+ for (let p = b - 1; p >= 0; p--) {
64
+ const I = k[p], A = p < K;
65
+ !(L(U, B, I) <= J) || A ? (G[K] = p + 1, K--, U = I, B = 1) : (U = L(U, B, I), B++);
64
66
  }
65
- A[0] = 0;
66
- const V = [], U = new Array(o).fill(0);
67
- for (let e = 0; e < o; e++) {
68
- const n = A[e], c = e + 1 < o ? A[e + 1] : u, f = e * (I + b);
69
- for (let y = n; y < c; y++) {
70
- const S = { ...t[y], columnWidth: I, imageHeight: 0, columnHeight: 0, left: 0, top: 0 }, F = p[y] - (i + d);
71
- S.imageHeight = F, S.columnHeight = p[y], S.left = f, S.top = U[e], U[e] += S.columnHeight + (y + 1 < c ? r : 0), V.push(S);
67
+ G[0] = 0;
68
+ const Q = [], X = new Array(i).fill(0);
69
+ for (let p = 0; p < i; p++) {
70
+ const I = G[p], A = p + 1 < i ? G[p + 1] : b, _ = p * (H + m);
71
+ for (let z = I; z < A; z++) {
72
+ const D = {
73
+ ...e[z],
74
+ columnWidth: H,
75
+ imageHeight: 0,
76
+ columnHeight: 0,
77
+ left: 0,
78
+ top: 0
79
+ };
80
+ D.imageHeight = k[z] - (r + n), D.columnHeight = k[z], D.left = _, D.top = X[p], X[p] += D.columnHeight + (z + 1 < A ? v : 0), Q.push(D);
72
81
  }
73
82
  }
74
- return V;
83
+ return Q;
75
84
  }
76
- const s = new Array(o).fill(0), v = [];
77
- for (let u = 0; u < t.length; u++) {
78
- const k = t[u], H = { ...k, columnWidth: 0, imageHeight: 0, columnHeight: 0, left: 0, top: 0 }, N = s.indexOf(Math.min(...s)), R = k.width, _ = k.height;
79
- H.columnWidth = I, H.left = N * (I + b), H.imageHeight = Math.round(I * _ / R), H.columnHeight = H.imageHeight + i + d, H.top = s[N], s[N] += H.columnHeight + r, v.push(H);
85
+ const h = new Array(i).fill(0), $ = [];
86
+ for (let b = 0; b < e.length; b++) {
87
+ const L = e[b], S = {
88
+ ...L,
89
+ columnWidth: 0,
90
+ imageHeight: 0,
91
+ columnHeight: 0,
92
+ left: 0,
93
+ top: 0
94
+ }, O = h.indexOf(Math.min(...h)), Y = L.width, J = L.height;
95
+ S.columnWidth = H, S.left = O * (H + m), S.imageHeight = Math.round(H * J / Y), S.columnHeight = S.imageHeight + r + n, S.top = h[O], h[O] += S.columnHeight + v, $.push(S);
80
96
  }
81
- return v;
97
+ return $;
82
98
  }
83
- var kt = typeof global == "object" && global && global.Object === Object && global, Ht = typeof self == "object" && self && self.Object === Object && self, ft = kt || Ht || Function("return this")(), K = ft.Symbol, dt = Object.prototype, Et = dt.hasOwnProperty, Pt = dt.toString, G = K ? K.toStringTag : void 0;
84
- function Lt(t) {
85
- var a = Et.call(t, G), o = t[G];
99
+ var Ve = typeof global == "object" && global && global.Object === Object && global, Ge = typeof self == "object" && self && self.Object === Object && self, Ie = Ve || Ge || Function("return this")(), ie = Ie.Symbol, Pe = Object.prototype, Ue = Pe.hasOwnProperty, Xe = Pe.toString, Z = ie ? ie.toStringTag : void 0;
100
+ function Ye(e) {
101
+ var o = Ue.call(e, Z), i = e[Z];
86
102
  try {
87
- t[G] = void 0;
88
- var l = !0;
103
+ e[Z] = void 0;
104
+ var s = !0;
89
105
  } catch {
90
106
  }
91
- var b = Pt.call(t);
92
- return l && (a ? t[G] = o : delete t[G]), b;
107
+ var m = Xe.call(e);
108
+ return s && (o ? e[Z] = i : delete e[Z]), m;
93
109
  }
94
- var $t = Object.prototype, Nt = $t.toString;
95
- function Wt(t) {
96
- return Nt.call(t);
110
+ var Je = Object.prototype, Ke = Je.toString;
111
+ function Qe(e) {
112
+ return Ke.call(e);
97
113
  }
98
- var Ot = "[object Null]", At = "[object Undefined]", ot = K ? K.toStringTag : void 0;
99
- function jt(t) {
100
- return t == null ? t === void 0 ? At : Ot : ot && ot in Object(t) ? Lt(t) : Wt(t);
114
+ var Ze = "[object Null]", et = "[object Undefined]", be = ie ? ie.toStringTag : void 0;
115
+ function tt(e) {
116
+ return e == null ? e === void 0 ? et : Ze : be && be in Object(e) ? Ye(e) : Qe(e);
101
117
  }
102
- function Bt(t) {
103
- return t != null && typeof t == "object";
118
+ function nt(e) {
119
+ return e != null && typeof e == "object";
104
120
  }
105
- var Ct = "[object Symbol]";
106
- function zt(t) {
107
- return typeof t == "symbol" || Bt(t) && jt(t) == Ct;
121
+ var at = "[object Symbol]";
122
+ function rt(e) {
123
+ return typeof e == "symbol" || nt(e) && tt(e) == at;
108
124
  }
109
- var Dt = /\s/;
110
- function Ft(t) {
111
- for (var a = t.length; a-- && Dt.test(t.charAt(a)); )
125
+ var ot = /\s/;
126
+ function it(e) {
127
+ for (var o = e.length; o-- && ot.test(e.charAt(o)); )
112
128
  ;
113
- return a;
129
+ return o;
114
130
  }
115
- var Rt = /^\s+/;
116
- function _t(t) {
117
- return t && t.slice(0, Ft(t) + 1).replace(Rt, "");
131
+ var st = /^\s+/;
132
+ function lt(e) {
133
+ return e && e.slice(0, it(e) + 1).replace(st, "");
118
134
  }
119
- function Z(t) {
120
- var a = typeof t;
121
- return t != null && (a == "object" || a == "function");
135
+ function ce(e) {
136
+ var o = typeof e;
137
+ return e != null && (o == "object" || o == "function");
122
138
  }
123
- var it = NaN, Vt = /^[-+]0x[0-9a-f]+$/i, qt = /^0b[01]+$/i, Gt = /^0o[0-7]+$/i, Xt = parseInt;
124
- function st(t) {
125
- if (typeof t == "number")
126
- return t;
127
- if (zt(t))
128
- return it;
129
- if (Z(t)) {
130
- var a = typeof t.valueOf == "function" ? t.valueOf() : t;
131
- t = Z(a) ? a + "" : a;
139
+ var xe = NaN, ct = /^[-+]0x[0-9a-f]+$/i, ut = /^0b[01]+$/i, ft = /^0o[0-7]+$/i, dt = parseInt;
140
+ function we(e) {
141
+ if (typeof e == "number")
142
+ return e;
143
+ if (rt(e))
144
+ return xe;
145
+ if (ce(e)) {
146
+ var o = typeof e.valueOf == "function" ? e.valueOf() : e;
147
+ e = ce(o) ? o + "" : o;
132
148
  }
133
- if (typeof t != "string")
134
- return t === 0 ? t : +t;
135
- t = _t(t);
136
- var o = qt.test(t);
137
- return o || Gt.test(t) ? Xt(t.slice(2), o ? 2 : 8) : Vt.test(t) ? it : +t;
149
+ if (typeof e != "string")
150
+ return e === 0 ? e : +e;
151
+ e = lt(e);
152
+ var i = ut.test(e);
153
+ return i || ft.test(e) ? dt(e.slice(2), i ? 2 : 8) : ct.test(e) ? xe : +e;
138
154
  }
139
- var Q = function() {
140
- return ft.Date.now();
141
- }, Ut = "Expected a function", Yt = Math.max, Jt = Math.min;
142
- function lt(t, a, o) {
143
- var l, b, r, d, i, w, m = 0, h = !1, g = !1, x = !0;
144
- if (typeof t != "function")
145
- throw new TypeError(Ut);
146
- a = st(a) || 0, Z(o) && (h = !!o.leading, g = "maxWait" in o, r = g ? Yt(st(o.maxWait) || 0, a) : r, x = "trailing" in o ? !!o.trailing : x);
147
- function E(s) {
148
- var v = l, u = b;
149
- return l = b = void 0, m = s, d = t.apply(u, v), d;
155
+ var le = function() {
156
+ return Ie.Date.now();
157
+ }, gt = "Expected a function", pt = Math.max, yt = Math.min;
158
+ function Te(e, o, i) {
159
+ var s, m, v, n, r, y, c = 0, f = !1, d = !1, x = !0;
160
+ if (typeof e != "function")
161
+ throw new TypeError(gt);
162
+ o = we(o) || 0, ce(i) && (f = !!i.leading, d = "maxWait" in i, v = d ? pt(we(i.maxWait) || 0, o) : v, x = "trailing" in i ? !!i.trailing : x);
163
+ function w(h) {
164
+ var $ = s, b = m;
165
+ return s = m = void 0, c = h, n = e.apply(b, $), n;
150
166
  }
151
- function W(s) {
152
- return m = s, i = setTimeout(T, a), h ? E(s) : d;
167
+ function W(h) {
168
+ return c = h, r = setTimeout(M, o), f ? w(h) : n;
153
169
  }
154
- function O(s) {
155
- var v = s - w, u = s - m, k = a - v;
156
- return g ? Jt(k, r - u) : k;
170
+ function R(h) {
171
+ var $ = h - y, b = h - c, L = o - $;
172
+ return d ? yt(L, v - b) : L;
157
173
  }
158
- function M(s) {
159
- var v = s - w, u = s - m;
160
- return w === void 0 || v >= a || v < 0 || g && u >= r;
174
+ function T(h) {
175
+ var $ = h - y, b = h - c;
176
+ return y === void 0 || $ >= o || $ < 0 || d && b >= v;
161
177
  }
162
- function T() {
163
- var s = Q();
164
- if (M(s))
165
- return L(s);
166
- i = setTimeout(T, O(s));
178
+ function M() {
179
+ var h = le();
180
+ if (T(h))
181
+ return N(h);
182
+ r = setTimeout(M, R(h));
167
183
  }
168
- function L(s) {
169
- return i = void 0, x && l ? E(s) : (l = b = void 0, d);
184
+ function N(h) {
185
+ return r = void 0, x && s ? w(h) : (s = m = void 0, n);
170
186
  }
171
- function $() {
172
- i !== void 0 && clearTimeout(i), m = 0, l = w = b = i = void 0;
187
+ function F() {
188
+ r !== void 0 && clearTimeout(r), c = 0, s = y = m = r = void 0;
173
189
  }
174
- function I() {
175
- return i === void 0 ? d : L(Q());
190
+ function H() {
191
+ return r === void 0 ? n : N(le());
176
192
  }
177
- function p() {
178
- var s = Q(), v = M(s);
179
- if (l = arguments, b = this, w = s, v) {
180
- if (i === void 0)
181
- return W(w);
182
- if (g)
183
- return clearTimeout(i), i = setTimeout(T, a), E(w);
193
+ function k() {
194
+ var h = le(), $ = T(h);
195
+ if (s = arguments, m = this, y = h, $) {
196
+ if (r === void 0)
197
+ return W(y);
198
+ if (d)
199
+ return clearTimeout(r), r = setTimeout(M, o), w(y);
184
200
  }
185
- return i === void 0 && (i = setTimeout(T, a)), d;
201
+ return r === void 0 && (r = setTimeout(M, o)), n;
186
202
  }
187
- return p.cancel = $, p.flush = I, p;
203
+ return k.cancel = F, k.flush = H, k;
188
204
  }
189
- function ct(t) {
190
- const a = window.innerWidth, o = t.sizes;
191
- return a >= 1536 && o["2xl"] ? o["2xl"] : a >= 1280 && o.xl ? o.xl : a >= 1024 && o.lg ? o.lg : a >= 768 && o.md ? o.md : a >= 640 && o.sm ? o.sm : o.base;
205
+ function Me(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;
192
208
  }
193
- function Kt(t) {
194
- return t.reduce((o, l) => Math.max(o, l.top + l.columnHeight), 0) + 500;
209
+ function ht(e) {
210
+ return e.reduce((i, s) => Math.max(i, s.top + s.columnHeight), 0) + 500;
195
211
  }
196
- function Qt(t) {
212
+ function mt(e) {
197
213
  return {
198
- transform: `translate3d(${t.left}px, ${t.top}px, 0)`,
214
+ transform: `translate3d(${e.left}px, ${e.top}px, 0)`,
199
215
  top: "0px",
200
216
  left: "0px",
201
- width: `${t.columnWidth}px`,
202
- height: `${t.columnHeight}px`
217
+ width: `${e.columnWidth}px`,
218
+ height: `${e.columnHeight}px`
203
219
  };
204
220
  }
205
- function Zt(t, a = 0) {
221
+ function vt(e, o = 0) {
206
222
  return {
207
- style: Qt(t),
208
- "data-top": t.top,
209
- "data-left": t.left,
210
- "data-id": `${t.page}-${t.id}`,
211
- "data-index": a
223
+ style: mt(e),
224
+ "data-top": e.top,
225
+ "data-left": e.left,
226
+ "data-id": `${e.page}-${e.id}`,
227
+ "data-index": o
212
228
  };
213
229
  }
214
- function tt(t, a) {
215
- const o = new Array(a).fill(0);
216
- for (let l = 0; l < t.length; l++) {
217
- const b = t[l], r = l % a;
218
- o[r] = Math.max(o[r], b.top + b.columnHeight);
230
+ function ue(e, o) {
231
+ if (!e.length || o <= 0)
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), m = /* @__PURE__ */ new Map();
234
+ for (let n = 0; n < s.length; n++) m.set(s[n], n);
235
+ const v = new Array(s.length).fill(0);
236
+ for (const n of e) {
237
+ const r = m.get(n.left);
238
+ r != null && (v[r] = Math.max(v[r], n.top + n.columnHeight));
219
239
  }
220
- return o;
240
+ for (; v.length < o; ) v.push(0);
241
+ return v;
221
242
  }
222
- function te(t) {
223
- function a(r, d) {
224
- const i = parseInt(r.dataset.left || "0", 10), w = parseInt(r.dataset.top || "0", 10), m = parseInt(r.dataset.index || "0", 10), h = Math.min(m * 20, 160), g = r.style.getPropertyValue("--masonry-opacity-delay");
225
- r.style.setProperty("--masonry-opacity-delay", `${h}ms`), requestAnimationFrame(() => {
226
- r.style.opacity = "1", r.style.transform = `translate3d(${i}px, ${w}px, 0) scale(1)`;
227
- const x = () => {
228
- g ? r.style.setProperty("--masonry-opacity-delay", g) : r.style.removeProperty("--masonry-opacity-delay"), r.removeEventListener("transitionend", x), d();
243
+ function bt(e, o) {
244
+ function i(n, r) {
245
+ const y = parseInt(n.dataset.left || "0", 10), c = parseInt(n.dataset.top || "0", 10), f = parseInt(n.dataset.index || "0", 10), d = Math.min(f * 20, 160), x = n.style.getPropertyValue("--masonry-opacity-delay");
246
+ n.style.setProperty("--masonry-opacity-delay", `${d}ms`), requestAnimationFrame(() => {
247
+ n.style.opacity = "1", n.style.transform = `translate3d(${y}px, ${c}px, 0) scale(1)`;
248
+ const w = () => {
249
+ x ? n.style.setProperty("--masonry-opacity-delay", x) : n.style.removeProperty("--masonry-opacity-delay"), n.removeEventListener("transitionend", w), r();
229
250
  };
230
- r.addEventListener("transitionend", x);
251
+ n.addEventListener("transitionend", w);
231
252
  });
232
253
  }
233
- function o(r) {
234
- const d = parseInt(r.dataset.left || "0", 10), i = parseInt(r.dataset.top || "0", 10);
235
- r.style.opacity = "0", r.style.transform = `translate3d(${d}px, ${i + 10}px, 0) scale(0.985)`;
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)`;
236
257
  }
237
- function l(r) {
238
- const d = parseInt(r.dataset.left || "0", 10), i = parseInt(r.dataset.top || "0", 10);
239
- r.style.transition = "none", r.style.opacity = "1", r.style.transform = `translate3d(${d}px, ${i}px, 0) scale(1)`, r.style.removeProperty("--masonry-opacity-delay"), r.offsetWidth, r.style.transition = "";
258
+ function m(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 = "";
262
+ });
240
263
  }
241
- function b(r, d) {
242
- const i = parseInt(r.dataset.left || "0", 10), w = parseInt(r.dataset.top || "0", 10), h = getComputedStyle(r).getPropertyValue("--masonry-leave-duration") || "", g = parseFloat(h), x = Number.isFinite(g) && g > 0 ? g : 200, E = r.style.transitionDuration, W = () => {
243
- r.removeEventListener("transitionend", O), clearTimeout(M), r.style.transitionDuration = E || "";
244
- }, O = (T) => {
245
- (!T || T.target === r) && (W(), d());
246
- }, M = setTimeout(() => {
247
- W(), d();
248
- }, x + 100);
264
+ function v(n, r) {
265
+ const y = parseInt(n.dataset.left || "0", 10), c = parseInt(n.dataset.top || "0", 10), f = typeof (o == null ? void 0 : o.leaveDurationMs) == "number" ? o.leaveDurationMs : NaN;
266
+ let d = Number.isFinite(f) && f > 0 ? f : NaN;
267
+ if (!Number.isFinite(d)) {
268
+ const M = getComputedStyle(n).getPropertyValue("--masonry-leave-duration") || "", N = parseFloat(M);
269
+ d = Number.isFinite(N) && N > 0 ? N : 200;
270
+ }
271
+ const x = n.style.transitionDuration, w = () => {
272
+ n.removeEventListener("transitionend", W), clearTimeout(R), n.style.transitionDuration = x || "";
273
+ }, W = (T) => {
274
+ (!T || T.target === n) && (w(), r());
275
+ }, R = setTimeout(() => {
276
+ w(), r();
277
+ }, d + 100);
249
278
  requestAnimationFrame(() => {
250
- r.style.transitionDuration = `${x}ms`, r.style.opacity = "0", r.style.transform = `translate3d(${i}px, ${w + 10}px, 0) scale(0.985)`, r.addEventListener("transitionend", O);
279
+ n.style.transitionDuration = `${d}ms`, n.style.opacity = "0", n.style.transform = `translate3d(${y}px, ${c + 10}px, 0) scale(0.985)`, n.addEventListener("transitionend", W);
251
280
  });
252
281
  }
253
282
  return {
254
- onEnter: a,
255
- onBeforeEnter: o,
256
- onBeforeLeave: l,
257
- onLeave: b
283
+ onEnter: i,
284
+ onBeforeEnter: s,
285
+ onBeforeLeave: m,
286
+ onLeave: v
258
287
  };
259
288
  }
260
- function ee({
261
- container: t,
262
- masonry: a,
263
- columns: o,
264
- containerHeight: l,
265
- isLoading: b,
266
- maxItems: r,
267
- pageSize: d,
268
- refreshLayout: i,
269
- setItemsRaw: w,
270
- loadNext: m,
271
- leaveEstimateMs: h
289
+ function xt({
290
+ container: e,
291
+ masonry: o,
292
+ columns: i,
293
+ containerHeight: s,
294
+ isLoading: m,
295
+ pageSize: v,
296
+ refreshLayout: n,
297
+ setItemsRaw: r,
298
+ loadNext: y,
299
+ loadThresholdPx: c
272
300
  }) {
273
- let g = !1, x = 0;
274
- async function E() {
275
- if (!t.value) return;
276
- const { scrollTop: M, clientHeight: T } = t.value, L = M + T, $ = M > x + 1;
277
- x = M;
278
- const I = tt(a.value, o.value), s = Math.max(...I) + 300 < L - 1, v = M + T >= l.value - 1;
279
- if ((s || v) && $ && !b.value && !g)
280
- try {
281
- a.value.length > r && await W(I), await m(), await X();
282
- } catch (u) {
283
- console.error("Error in scroll handler:", u);
284
- }
285
- }
286
- async function W(M) {
287
- if (!a.value.length || a.value.length <= d) return;
288
- const T = a.value.reduce((s, v) => {
289
- const u = v.page;
290
- return s[u] || (s[u] = []), s[u].push(v), s;
291
- }, {}), L = Object.keys(T).sort((s, v) => parseInt(s) - parseInt(v));
292
- if (L.length === 0) return;
293
- let $ = 0;
294
- const I = [];
295
- for (const s of L)
296
- if (I.push(s), $ += T[s].length, $ >= d) break;
297
- const p = a.value.filter((s) => !I.includes(String(s.page)));
298
- p.length !== a.value.length && (g = !0, w(p), await X(), await new Promise((s) => requestAnimationFrame(() => s())), i(p), await X(), await O(), g = !1);
299
- }
300
- async function O() {
301
- if (!t.value) return;
302
- const { scrollTop: M, clientHeight: T } = t.value, L = M + T * 0.4, $ = tt(a.value, o.value), I = $.indexOf(Math.max(...$)), p = a.value.filter((u, k) => k % o.value === I);
303
- if (p.length === 0) return;
304
- let s = p[0];
305
- for (const u of p)
306
- u.top <= L && u.top >= s.top && (s = u);
307
- const v = Math.max(0, s.top - T * 0.4);
308
- Math.abs(v - M) > 4 && t.value.scrollTo({ top: v, behavior: "auto" });
301
+ let f = 0;
302
+ async function d(x) {
303
+ if (!e.value) return;
304
+ const w = x ?? ue(o.value, i.value), W = w.length ? Math.max(...w) : 0, R = e.value.scrollTop + e.value.clientHeight, T = e.value.scrollTop > f + 1;
305
+ f = e.value.scrollTop;
306
+ const M = typeof c == "number" ? c : 200, N = M >= 0 ? Math.max(0, W - M) : Math.max(0, W + M);
307
+ if (R >= N && T && !m.value) {
308
+ await y(), await ee();
309
+ return;
310
+ }
309
311
  }
310
312
  return {
311
- handleScroll: E
313
+ handleScroll: d
312
314
  };
313
315
  }
314
- const ne = ["src"], ae = ["onClick"], re = /* @__PURE__ */ gt({
316
+ const wt = ["src"], Tt = ["onClick"], Mt = /* @__PURE__ */ Ne({
315
317
  __name: "Masonry",
316
318
  props: {
317
319
  getNextPage: {
@@ -334,16 +336,12 @@ const ne = ["src"], ae = ["onClick"], re = /* @__PURE__ */ gt({
334
336
  type: String,
335
337
  default: "page",
336
338
  // or 'cursor'
337
- validator: (t) => ["page", "cursor"].includes(t)
339
+ validator: (e) => ["page", "cursor"].includes(e)
338
340
  },
339
341
  skipInitialLoad: {
340
342
  type: Boolean,
341
343
  default: !1
342
344
  },
343
- maxItems: {
344
- type: Number,
345
- default: 100
346
- },
347
345
  pageSize: {
348
346
  type: Number,
349
347
  default: 40
@@ -391,6 +389,14 @@ const ne = ["src"], ae = ["onClick"], re = /* @__PURE__ */ gt({
391
389
  forceMotion: {
392
390
  type: Boolean,
393
391
  default: !1
392
+ },
393
+ virtualBufferPx: {
394
+ type: Number,
395
+ default: 600
396
+ },
397
+ loadThresholdPx: {
398
+ type: Number,
399
+ default: 200
394
400
  }
395
401
  },
396
402
  emits: [
@@ -400,10 +406,11 @@ const ne = ["src"], ae = ["onClick"], re = /* @__PURE__ */ gt({
400
406
  "backfill:stop",
401
407
  "retry:start",
402
408
  "retry:tick",
403
- "retry:stop"
409
+ "retry:stop",
410
+ "remove-all:complete"
404
411
  ],
405
- setup(t, { expose: a, emit: o }) {
406
- const l = t, b = {
412
+ setup(e, { expose: o, emit: i }) {
413
+ const s = e, m = {
407
414
  sizes: { base: 1, sm: 2, md: 3, lg: 4, xl: 5, "2xl": 6 },
408
415
  gutterX: 10,
409
416
  gutterY: 10,
@@ -412,273 +419,357 @@ const ne = ["src"], ae = ["onClick"], re = /* @__PURE__ */ gt({
412
419
  paddingLeft: 0,
413
420
  paddingRight: 0,
414
421
  placement: "masonry"
415
- }, r = et(() => {
416
- var e;
422
+ }, v = ae(() => {
423
+ var t;
417
424
  return {
418
- ...b,
419
- ...l.layout,
425
+ ...m,
426
+ ...s.layout,
420
427
  sizes: {
421
- ...b.sizes,
422
- ...((e = l.layout) == null ? void 0 : e.sizes) || {}
428
+ ...m.sizes,
429
+ ...((t = s.layout) == null ? void 0 : t.sizes) || {}
423
430
  }
424
431
  };
425
- }), d = o, i = et({
426
- get: () => l.items,
427
- set: (e) => d("update:items", e)
428
- }), w = B(7), m = B(null), h = B([]);
429
- B(null);
430
- const g = B(!1), x = B(0), E = B({
432
+ }), n = i, r = ae({
433
+ get: () => s.items,
434
+ set: (t) => n("update:items", t)
435
+ }), y = j(7), c = j(null), f = j([]), d = j(!1), x = j(0), w = j(/* @__PURE__ */ new Set());
436
+ function W(t) {
437
+ return typeof t == "number" && Number.isFinite(t) && t > 0;
438
+ }
439
+ function R(t, a) {
440
+ try {
441
+ if (!Array.isArray(t) || t.length === 0) return;
442
+ const l = t.filter((g) => !W(g == null ? void 0 : g.width) || !W(g == null ? void 0 : g.height));
443
+ if (l.length === 0) return;
444
+ const u = [];
445
+ for (const g of l) {
446
+ const P = (g == null ? void 0 : g.id) ?? `idx:${t.indexOf(g)}`;
447
+ w.value.has(P) || (w.value.add(P), u.push(P));
448
+ }
449
+ if (u.length > 0) {
450
+ const g = u.slice(0, 10);
451
+ console.warn(
452
+ "[Masonry] Items missing width/height detected:",
453
+ {
454
+ context: a,
455
+ count: u.length,
456
+ sampleIds: g,
457
+ hint: "Ensure each item has positive width and height. Consider providing fallbacks (e.g., 512x512) at the data layer."
458
+ }
459
+ );
460
+ }
461
+ } catch {
462
+ }
463
+ }
464
+ const T = j(0), M = j(0), N = s.virtualBufferPx, F = j(!1), H = j({
431
465
  distanceToTrigger: 0,
432
466
  isNearTrigger: !1
433
- }), W = () => {
434
- if (!m.value) return;
435
- const { scrollTop: e, clientHeight: n } = m.value, c = e + n, f = tt(i.value, w.value), P = Math.max(...f) + 300, S = Math.max(0, P - c), F = S <= 100;
436
- E.value = {
437
- distanceToTrigger: Math.round(S),
438
- isNearTrigger: F
467
+ }), k = (t) => {
468
+ if (!c.value) return;
469
+ const { scrollTop: a, clientHeight: l } = c.value, u = a + l, g = t ?? ue(r.value, y.value), P = g.length ? Math.max(...g) : 0, C = typeof s.loadThresholdPx == "number" ? s.loadThresholdPx : 200, ne = C >= 0 ? Math.max(0, P - C) : Math.max(0, P + C), ye = Math.max(0, ne - u), Ee = ye <= 100;
470
+ H.value = {
471
+ distanceToTrigger: Math.round(ye),
472
+ isNearTrigger: Ee
439
473
  };
440
- }, { onEnter: O, onBeforeEnter: M, onBeforeLeave: T, onLeave: L } = te(), { handleScroll: $ } = ee({
441
- container: m,
442
- masonry: i,
443
- columns: w,
474
+ }, { onEnter: h, onBeforeEnter: $, onBeforeLeave: b, onLeave: L } = bt(r, { leaveDurationMs: s.leaveDurationMs });
475
+ function S(t, a) {
476
+ if (F.value) {
477
+ const l = parseInt(t.dataset.left || "0", 10), u = parseInt(t.dataset.top || "0", 10);
478
+ t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${l}px, ${u}px, 0) scale(1)`, t.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
479
+ t.style.transition = "", a();
480
+ });
481
+ } else
482
+ h(t, a);
483
+ }
484
+ function O(t) {
485
+ if (F.value) {
486
+ const a = parseInt(t.dataset.left || "0", 10), l = parseInt(t.dataset.top || "0", 10);
487
+ 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");
488
+ } else
489
+ $(t);
490
+ }
491
+ function Y(t) {
492
+ F.value || b(t);
493
+ }
494
+ function J(t, a) {
495
+ F.value ? a() : L(t, a);
496
+ }
497
+ const G = ae(() => {
498
+ const t = T.value - N, a = T.value + M.value + N, l = r.value;
499
+ return !l || l.length === 0 ? [] : l.filter((u) => {
500
+ const g = u.top;
501
+ return u.top + u.columnHeight >= t && g <= a;
502
+ });
503
+ }), { handleScroll: K } = xt({
504
+ container: c,
505
+ masonry: r,
506
+ columns: y,
444
507
  containerHeight: x,
445
- isLoading: g,
446
- maxItems: l.maxItems,
447
- pageSize: l.pageSize,
448
- refreshLayout: p,
449
- setItemsRaw: (e) => {
450
- i.value = e;
508
+ isLoading: d,
509
+ pageSize: s.pageSize,
510
+ refreshLayout: B,
511
+ setItemsRaw: (t) => {
512
+ r.value = t;
451
513
  },
452
- loadNext: H,
453
- leaveEstimateMs: l.leaveDurationMs
514
+ loadNext: A,
515
+ loadThresholdPx: s.loadThresholdPx
454
516
  });
455
- a({
456
- isLoading: g,
457
- refreshLayout: p,
517
+ o({
518
+ isLoading: d,
519
+ refreshLayout: B,
458
520
  containerHeight: x,
459
- remove: N,
460
- removeMany: R,
461
- loadNext: H,
462
- loadPage: k,
463
- reset: D,
464
- init: U,
465
- paginationHistory: h
521
+ remove: _,
522
+ removeMany: z,
523
+ removeAll: D,
524
+ loadNext: A,
525
+ loadPage: I,
526
+ reset: He,
527
+ init: Le,
528
+ paginationHistory: f,
529
+ cancelLoad: de,
530
+ scrollToTop: q,
531
+ totalItems: ae(() => r.value.length)
466
532
  });
467
- function I(e) {
468
- const n = Kt(e);
469
- let c = 0;
470
- if (m.value) {
471
- const { scrollTop: f, clientHeight: y } = m.value;
472
- c = f + y + 100;
533
+ function U(t) {
534
+ const a = ht(t);
535
+ let l = 0;
536
+ if (c.value) {
537
+ const { scrollTop: u, clientHeight: g } = c.value;
538
+ l = u + g + 100;
473
539
  }
474
- x.value = Math.max(n, c);
540
+ x.value = Math.max(a, l);
475
541
  }
476
- function p(e) {
477
- if (!m.value) return;
478
- const n = St(e, m.value, w.value, r.value);
479
- I(n), i.value = n;
542
+ function B(t) {
543
+ if (!c.value) return;
544
+ R(t, "refreshLayout");
545
+ const a = qe(t, c.value, y.value, v.value);
546
+ U(a), r.value = a;
480
547
  }
481
- function s(e, n) {
482
- return new Promise((c) => {
483
- const f = Math.max(0, e | 0), y = Date.now();
484
- n(f, f);
548
+ function Q(t, a) {
549
+ return new Promise((l) => {
550
+ const u = Math.max(0, t | 0), g = Date.now();
551
+ a(u, u);
485
552
  const P = setInterval(() => {
486
- const S = Date.now() - y, F = Math.max(0, f - S);
487
- n(F, f), F <= 0 && (clearInterval(P), c());
553
+ if (E.value) {
554
+ clearInterval(P), l();
555
+ return;
556
+ }
557
+ const C = Date.now() - g, ne = Math.max(0, u - C);
558
+ a(ne, u), ne <= 0 && (clearInterval(P), l());
488
559
  }, 100);
489
560
  });
490
561
  }
491
- async function v(e) {
562
+ async function X(t) {
492
563
  try {
493
- const n = await u(() => l.getNextPage(e));
494
- return p([...i.value, ...n.items]), n;
495
- } catch (n) {
496
- throw console.error("Error in getContent:", n), n;
564
+ const a = await p(() => s.getNextPage(t));
565
+ return B([...r.value, ...a.items]), a;
566
+ } catch (a) {
567
+ throw console.error("Error in getContent:", a), a;
497
568
  }
498
569
  }
499
- async function u(e) {
500
- let n = 0;
501
- const c = l.retryMaxAttempts;
502
- let f = l.retryInitialDelayMs;
570
+ async function p(t) {
571
+ let a = 0;
572
+ const l = s.retryMaxAttempts;
573
+ let u = s.retryInitialDelayMs;
503
574
  for (; ; )
504
575
  try {
505
- const y = await e();
506
- return n > 0 && d("retry:stop", { attempt: n, success: !0 }), y;
507
- } catch (y) {
508
- if (n++, n > c)
509
- throw d("retry:stop", { attempt: n - 1, success: !1 }), y;
510
- d("retry:start", { attempt: n, max: c, totalMs: f }), await s(f, (P, S) => {
511
- d("retry:tick", { attempt: n, remainingMs: P, totalMs: S });
512
- }), f += l.retryBackoffStepMs;
576
+ const g = await t();
577
+ return a > 0 && n("retry:stop", { attempt: a, success: !0 }), g;
578
+ } catch (g) {
579
+ if (a++, a > l)
580
+ throw n("retry:stop", { attempt: a - 1, success: !1 }), g;
581
+ n("retry:start", { attempt: a, max: l, totalMs: u }), await Q(u, (P, C) => {
582
+ n("retry:tick", { attempt: a, remainingMs: P, totalMs: C });
583
+ }), u += s.retryBackoffStepMs;
513
584
  }
514
585
  }
515
- async function k(e) {
516
- if (!g.value) {
517
- g.value = !0;
586
+ async function I(t) {
587
+ if (!(d.value || E.value)) {
588
+ d.value = !0, E.value = !1;
518
589
  try {
519
- const n = i.value.length, c = await v(e);
520
- return h.value.push(c.nextPage), await z(n), c;
521
- } catch (n) {
522
- throw console.error("Error loading page:", n), n;
590
+ const a = r.value.length;
591
+ if (E.value) return;
592
+ const l = await X(t);
593
+ return E.value ? void 0 : (f.value.push(l.nextPage), await fe(a), l);
594
+ } catch (a) {
595
+ throw console.error("Error loading page:", a), a;
523
596
  } finally {
524
- g.value = !1;
597
+ d.value = !1;
525
598
  }
526
599
  }
527
600
  }
528
- async function H() {
529
- if (!g.value) {
530
- g.value = !0;
601
+ async function A() {
602
+ if (!(d.value || E.value)) {
603
+ d.value = !0, E.value = !1;
531
604
  try {
532
- const e = i.value.length, n = h.value[h.value.length - 1], c = await v(n);
533
- return h.value.push(c.nextPage), await z(e), c;
534
- } catch (e) {
535
- throw console.error("Error loading next page:", e), e;
605
+ const t = r.value.length;
606
+ if (E.value) return;
607
+ const a = f.value[f.value.length - 1], l = await X(a);
608
+ return E.value ? void 0 : (f.value.push(l.nextPage), await fe(t), l);
609
+ } catch (t) {
610
+ throw console.error("Error loading next page:", t), t;
536
611
  } finally {
537
- g.value = !1;
612
+ d.value = !1;
538
613
  }
539
614
  }
540
615
  }
541
- async function N(e) {
542
- var c;
543
- const n = i.value.filter((f) => f.id !== e.id);
544
- i.value = n, await X(), (c = m.value) == null || c.offsetHeight, requestAnimationFrame(() => {
545
- p(n);
616
+ async function _(t) {
617
+ const a = r.value.filter((l) => l.id !== t.id);
618
+ r.value = a, await ee(), await new Promise((l) => requestAnimationFrame(() => l())), requestAnimationFrame(() => {
619
+ B(a);
546
620
  });
547
621
  }
548
- async function R(e) {
549
- var f;
550
- if (!e || e.length === 0) return;
551
- const n = new Set(e.map((y) => y.id)), c = i.value.filter((y) => !n.has(y.id));
552
- i.value = c, await X(), (f = m.value) == null || f.offsetHeight, requestAnimationFrame(() => {
553
- p(c);
622
+ async function z(t) {
623
+ if (!t || t.length === 0) return;
624
+ const a = new Set(t.map((u) => u.id)), l = r.value.filter((u) => !a.has(u.id));
625
+ r.value = l, await ee(), await new Promise((u) => requestAnimationFrame(() => u())), requestAnimationFrame(() => {
626
+ B(l);
554
627
  });
555
628
  }
556
- function _() {
557
- w.value = ct(r.value), p(i.value);
629
+ function q(t) {
630
+ c.value && c.value.scrollTo({
631
+ top: 0,
632
+ behavior: (t == null ? void 0 : t.behavior) ?? "smooth",
633
+ ...t
634
+ });
558
635
  }
559
- let A = !1;
560
- async function z(e) {
561
- if (!l.backfillEnabled || A) return;
562
- const n = (e || 0) + (l.pageSize || 0);
563
- if (!(!l.pageSize || l.pageSize <= 0 || h.value[h.value.length - 1] == null) && !(i.value.length >= n)) {
564
- A = !0;
636
+ async function D() {
637
+ q({ behavior: "smooth" }), r.value = [], x.value = 0, await ee(), n("remove-all:complete");
638
+ }
639
+ function ke() {
640
+ y.value = Me(v.value), B(r.value), c.value && (T.value = c.value.scrollTop, M.value = c.value.clientHeight);
641
+ }
642
+ let te = !1;
643
+ const E = j(!1);
644
+ async function fe(t) {
645
+ if (!s.backfillEnabled || te || E.value) return;
646
+ const a = (t || 0) + (s.pageSize || 0);
647
+ if (!(!s.pageSize || s.pageSize <= 0 || f.value[f.value.length - 1] == null) && !(r.value.length >= a)) {
648
+ te = !0;
565
649
  try {
566
- let f = 0;
567
- for (d("backfill:start", { target: n, fetched: i.value.length, calls: f }); i.value.length < n && f < l.backfillMaxCalls && h.value[h.value.length - 1] != null; ) {
568
- await s(l.backfillDelayMs, (P, S) => {
569
- d("backfill:tick", {
570
- fetched: i.value.length,
571
- target: n,
572
- calls: f,
573
- remainingMs: P,
574
- totalMs: S
575
- });
650
+ let u = 0;
651
+ for (n("backfill:start", { target: a, fetched: r.value.length, calls: u }); r.value.length < a && u < s.backfillMaxCalls && f.value[f.value.length - 1] != null && !E.value && (await Q(s.backfillDelayMs, (P, C) => {
652
+ n("backfill:tick", {
653
+ fetched: r.value.length,
654
+ target: a,
655
+ calls: u,
656
+ remainingMs: P,
657
+ totalMs: C
576
658
  });
577
- const y = h.value[h.value.length - 1];
659
+ }), !E.value); ) {
660
+ const g = f.value[f.value.length - 1];
578
661
  try {
579
- g.value = !0;
580
- const P = await v(y);
581
- h.value.push(P.nextPage);
662
+ d.value = !0;
663
+ const P = await X(g);
664
+ if (E.value) break;
665
+ f.value.push(P.nextPage);
582
666
  } finally {
583
- g.value = !1;
667
+ d.value = !1;
584
668
  }
585
- f++;
669
+ u++;
586
670
  }
587
- d("backfill:stop", { fetched: i.value.length, calls: f });
671
+ n("backfill:stop", { fetched: r.value.length, calls: u });
588
672
  } finally {
589
- A = !1;
673
+ te = !1;
590
674
  }
591
675
  }
592
676
  }
593
- function D() {
594
- m.value && m.value.scrollTo({
677
+ function de() {
678
+ E.value = !0, d.value = !1, te = !1;
679
+ }
680
+ function He() {
681
+ de(), c.value && c.value.scrollTo({
595
682
  top: 0,
596
683
  behavior: "smooth"
597
- }), i.value = [], x.value = 0, h.value = [l.loadAtPage], E.value = {
684
+ }), r.value = [], x.value = 0, f.value = [s.loadAtPage], H.value = {
598
685
  distanceToTrigger: 0,
599
686
  isNearTrigger: !1
600
687
  };
601
688
  }
602
- const j = lt(() => {
603
- $(), W();
604
- }, 200), V = lt(_, 200);
605
- function U(e, n, c) {
606
- h.value = [n], h.value.push(c), p([...i.value, ...e]), W();
689
+ const ge = Te(async () => {
690
+ c.value && (T.value = c.value.scrollTop, M.value = c.value.clientHeight), F.value = !0, await ee(), await new Promise((a) => requestAnimationFrame(() => a())), F.value = !1;
691
+ const t = ue(r.value, y.value);
692
+ K(t), k(t);
693
+ }, 200), pe = Te(ke, 200);
694
+ function Le(t, a, l) {
695
+ f.value = [a], f.value.push(l), R(t, "init"), B([...r.value, ...t]), k();
607
696
  }
608
- return pt(async () => {
609
- var e;
697
+ return $e(async () => {
698
+ var t;
610
699
  try {
611
- w.value = ct(r.value);
612
- const n = l.loadAtPage;
613
- h.value = [n], l.skipInitialLoad || await k(h.value[0]), W();
614
- } catch (n) {
615
- console.error("Error during component initialization:", n), g.value = !1;
700
+ y.value = Me(v.value), c.value && (T.value = c.value.scrollTop, M.value = c.value.clientHeight);
701
+ const a = s.loadAtPage;
702
+ f.value = [a], s.skipInitialLoad || await I(f.value[0]), k();
703
+ } catch (a) {
704
+ console.error("Error during component initialization:", a), d.value = !1;
616
705
  }
617
- (e = m.value) == null || e.addEventListener("scroll", j), window.addEventListener("resize", V);
618
- }), mt(() => {
619
- var e;
620
- (e = m.value) == null || e.removeEventListener("scroll", j), window.removeEventListener("resize", V);
621
- }), (e, n) => (J(), Y("div", {
622
- class: nt(["overflow-auto w-full flex-1 masonry-container", { "force-motion": l.forceMotion }]),
706
+ (t = c.value) == null || t.addEventListener("scroll", ge, { passive: !0 }), window.addEventListener("resize", pe);
707
+ }), Ae(() => {
708
+ var t;
709
+ (t = c.value) == null || t.removeEventListener("scroll", ge), window.removeEventListener("resize", pe);
710
+ }), (t, a) => (oe(), re("div", {
711
+ class: he(["overflow-auto w-full flex-1 masonry-container", { "force-motion": s.forceMotion }]),
623
712
  ref_key: "container",
624
- ref: m
713
+ ref: c
625
714
  }, [
626
- C("div", {
715
+ V("div", {
627
716
  class: "relative",
628
- style: ht({ height: `${x.value}px`, "--masonry-duration": `${t.transitionDurationMs}ms`, "--masonry-leave-duration": `${t.leaveDurationMs}ms`, "--masonry-ease": t.transitionEasing })
717
+ style: We({ height: `${x.value}px`, "--masonry-duration": `${e.transitionDurationMs}ms`, "--masonry-leave-duration": `${e.leaveDurationMs}ms`, "--masonry-ease": e.transitionEasing })
629
718
  }, [
630
- yt(bt, {
719
+ Be(Fe, {
631
720
  name: "masonry",
632
721
  css: !1,
633
- onEnter: q(O),
634
- onBeforeEnter: q(M),
635
- onLeave: q(L),
636
- onBeforeLeave: q(T)
722
+ onEnter: S,
723
+ onBeforeEnter: O,
724
+ onLeave: J,
725
+ onBeforeLeave: Y
637
726
  }, {
638
- default: xt(() => [
639
- (J(!0), Y(wt, null, Tt(i.value, (c, f) => (J(), Y("div", at({
640
- key: `${c.page}-${c.id}`,
727
+ default: Oe(() => [
728
+ (oe(!0), re(De, null, je(G.value, (l, u) => (oe(), re("div", me({
729
+ key: `${l.page}-${l.id}`,
641
730
  class: "absolute masonry-item",
642
731
  ref_for: !0
643
- }, q(Zt)(c, f)), [
644
- Mt(e.$slots, "item", at({ ref_for: !0 }, { item: c, remove: N }), () => [
645
- C("img", {
646
- src: c.src,
647
- class: "w-full"
648
- }, null, 8, ne),
649
- C("button", {
732
+ }, Re(vt)(l, u)), [
733
+ _e(t.$slots, "item", me({ ref_for: !0 }, { item: l, remove: _ }), () => [
734
+ V("img", {
735
+ src: l.src,
736
+ class: "w-full",
737
+ loading: "lazy",
738
+ decoding: "async"
739
+ }, null, 8, wt),
740
+ V("button", {
650
741
  class: "absolute bottom-0 right-0 bg-red-500 text-white p-2 rounded cursor-pointer",
651
- onClick: (y) => N(c)
652
- }, n[0] || (n[0] = [
653
- C("i", { class: "fas fa-trash" }, null, -1)
654
- ]), 8, ae)
742
+ onClick: (g) => _(l)
743
+ }, a[0] || (a[0] = [
744
+ V("i", { class: "fas fa-trash" }, null, -1)
745
+ ]), 8, Tt)
655
746
  ], !0)
656
747
  ], 16))), 128))
657
748
  ]),
658
749
  _: 3
659
- }, 8, ["onEnter", "onBeforeEnter", "onLeave", "onBeforeLeave"]),
660
- x.value > 0 ? (J(), Y("div", {
750
+ }),
751
+ x.value > 0 ? (oe(), re("div", {
661
752
  key: 0,
662
- class: nt(["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": !E.value.isNearTrigger, "opacity-100": E.value.isNearTrigger }])
753
+ class: he(["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": !H.value.isNearTrigger, "opacity-100": H.value.isNearTrigger }])
663
754
  }, [
664
- C("span", null, rt(i.value.length) + " items", 1),
665
- n[1] || (n[1] = C("span", { class: "mx-2" }, "|", -1)),
666
- C("span", null, rt(E.value.distanceToTrigger) + "px to load", 1)
667
- ], 2)) : vt("", !0)
755
+ V("span", null, ve(r.value.length) + " items", 1),
756
+ a[1] || (a[1] = V("span", { class: "mx-2" }, "|", -1)),
757
+ V("span", null, ve(H.value.distanceToTrigger) + "px to load", 1)
758
+ ], 2)) : ze("", !0)
668
759
  ], 4)
669
760
  ], 2));
670
761
  }
671
- }), oe = (t, a) => {
672
- const o = t.__vccOpts || t;
673
- for (const [l, b] of a)
674
- o[l] = b;
675
- return o;
676
- }, ut = /* @__PURE__ */ oe(re, [["__scopeId", "data-v-a75cd886"]]), se = {
677
- install(t) {
678
- t.component("WyxosMasonry", ut), t.component("WMasonry", ut);
762
+ }), St = (e, o) => {
763
+ const i = e.__vccOpts || e;
764
+ for (const [s, m] of o)
765
+ i[s] = m;
766
+ return i;
767
+ }, Se = /* @__PURE__ */ St(Mt, [["__scopeId", "data-v-b855ca99"]]), Pt = {
768
+ install(e) {
769
+ e.component("WyxosMasonry", Se), e.component("WMasonry", Se);
679
770
  }
680
771
  };
681
772
  export {
682
- ut as Masonry,
683
- se as default
773
+ Se as Masonry,
774
+ Pt as default
684
775
  };