@wyxos/vibe 5.13.4 → 5.14.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
@@ -74,7 +74,10 @@ function G(e, t) {
74
74
  function K(e) {
75
75
  return r(() => Object.freeze([...e.items]));
76
76
  }
77
- function q(e, t = [...e.items]) {
77
+ function q(e, t, n) {
78
+ return n(J(e, t.value)), O(() => J(e, t.value), n, { flush: "post" });
79
+ }
80
+ function J(e, t = [...e.items]) {
78
81
  return {
79
82
  activeReelPostId: e.activeReelPostId,
80
83
  autoScroll: { ...e.autoScroll },
@@ -104,17 +107,17 @@ function q(e, t = [...e.items]) {
104
107
  }
105
108
  //#endregion
106
109
  //#region src/components/GalleryFooter.vue?vue&type=script&setup=true&lang.ts
107
- var J = {
110
+ var Y = {
108
111
  key: 0,
109
112
  class: "gallery-footer"
110
- }, Y = {
113
+ }, ee = {
111
114
  key: 0,
112
115
  class: "load-more-status",
113
116
  role: "status"
114
- }, ee = ["disabled"], te = {
117
+ }, te = ["disabled"], ne = {
115
118
  key: 2,
116
119
  class: "end-feed"
117
- }, ne = ["disabled"], re = /* @__PURE__ */ d({
120
+ }, re = ["disabled"], ie = /* @__PURE__ */ d({
118
121
  __name: "GalleryFooter",
119
122
  props: {
120
123
  canRetryEnd: { type: Boolean },
@@ -130,14 +133,14 @@ var J = {
130
133
  function i() {
131
134
  n.loadMoreLocked || (n.hasNext ? r("loadMore") : r("retryEnd"));
132
135
  }
133
- return (t, n) => e.isLoading || e.hasError || e.hasNext && e.showLoadMore || !e.hasNext && e.canRetryEnd ? (b(), s("footer", J, [e.isLoading ? (b(), s("p", Y, " Loading more… ")) : e.hasError || e.hasNext && e.showLoadMore ? (b(), s("button", {
136
+ return (t, n) => e.isLoading || e.hasError || e.hasNext && e.showLoadMore || !e.hasNext && e.canRetryEnd ? (b(), s("footer", Y, [e.isLoading ? (b(), s("p", ee, " Loading more… ")) : e.hasError || e.hasNext && e.showLoadMore ? (b(), s("button", {
134
137
  key: 1,
135
138
  "data-test": "load-more",
136
139
  class: "load-more-button",
137
140
  type: "button",
138
141
  disabled: e.loadMoreLocked,
139
142
  onClick: i
140
- }, T(e.hasError ? "Try again" : e.loadMoreLocked ? "Loading paused" : "Load more"), 9, ee)) : (b(), s("div", te, [n[1] ||= c("p", {
143
+ }, T(e.hasError ? "Try again" : e.loadMoreLocked ? "Loading paused" : "Load more"), 9, te)) : (b(), s("div", ne, [n[1] ||= c("p", {
141
144
  class: "end-feed-message",
142
145
  role: "status"
143
146
  }, " You've reached the end. ", -1), c("button", {
@@ -146,9 +149,9 @@ var J = {
146
149
  type: "button",
147
150
  disabled: e.loadMoreLocked,
148
151
  onClick: n[0] ||= (e) => t.$emit("retryEnd")
149
- }, " Check for more ", 8, ne)]))])) : o("", !0);
152
+ }, " Check for more ", 8, re)]))])) : o("", !0);
150
153
  }
151
- }), ie = /* @__PURE__ */ d({
154
+ }), ae = /* @__PURE__ */ d({
152
155
  __name: "FeedFooter",
153
156
  props: {
154
157
  actions: {},
@@ -185,7 +188,7 @@ var J = {
185
188
  "can-retry-end",
186
189
  "show-load-more",
187
190
  "state"
188
- ])) : (b(), a(re, {
191
+ ])) : (b(), a(ie, {
189
192
  key: 1,
190
193
  "can-retry-end": e.canRetryEnd,
191
194
  "has-error": e.hasError,
@@ -204,7 +207,7 @@ var J = {
204
207
  "show-load-more"
205
208
  ]));
206
209
  }
207
- }), ae = ["role"], oe = { class: "gallery-status" }, se = /* @__PURE__ */ d({
210
+ }), oe = ["role"], se = { class: "gallery-status" }, X = /* @__PURE__ */ d({
208
211
  __name: "FeedStatus",
209
212
  props: {
210
213
  actions: {},
@@ -218,7 +221,7 @@ var J = {
218
221
  return (n, u) => (b(), s("main", {
219
222
  class: "gallery-shell",
220
223
  role: r.state.error ? "alert" : r.state.isLoading || r.state.isLoadingMore ? "status" : void 0
221
- }, [c("p", oe, [r.state.error ? (b(), s(e, { key: 0 }, [l(" Unable to load media. ")], 64)) : r.state.isLoading || r.state.isLoadingMore ? (b(), s(e, { key: 1 }, [l(" Loading media… ")], 64)) : (b(), s(e, { key: 2 }, [l(" No media found. ")], 64))]), t.feedFooter ? (b(), a(ie, {
224
+ }, [c("p", se, [r.state.error ? (b(), s(e, { key: 0 }, [l(" Unable to load media. ")], 64)) : r.state.isLoading || r.state.isLoadingMore ? (b(), s(e, { key: 1 }, [l(" Loading media… ")], 64)) : (b(), s(e, { key: 2 }, [l(" No media found. ")], 64))]), t.feedFooter ? (b(), a(ae, {
222
225
  key: 0,
223
226
  actions: t.actions,
224
227
  "can-retry-end": t.canRetryEnd,
@@ -240,7 +243,7 @@ var J = {
240
243
  "is-loading",
241
244
  "load-more-locked",
242
245
  "state"
243
- ])) : o("", !0)], 8, ae));
246
+ ])) : o("", !0)], 8, oe));
244
247
  }
245
248
  });
246
249
  function ce(e) {
@@ -248,29 +251,29 @@ function ce(e) {
248
251
  }
249
252
  //#endregion
250
253
  //#region src/core/masonry.ts
251
- function X(e) {
254
+ function Z(e) {
252
255
  let t = e.preview?.width ?? e.width, n = e.preview?.height ?? e.height;
253
256
  return !t || !n || t <= 0 || n <= 0 ? 1 : n / t;
254
257
  }
255
- function Z(e) {
258
+ function le(e) {
256
259
  return e.reduce((t, n, r) => n < e[t] ? r : t, 0);
257
260
  }
258
- function le(e) {
261
+ function ue(e) {
259
262
  return Math.max(0, e.containerHeight) + Math.max(0, e.gap);
260
263
  }
261
- var ue = .8, de = .5;
262
- function fe(e, t, n) {
264
+ var de = .8, fe = .5;
265
+ function Q(e, t, n) {
263
266
  let r = Math.max(0, n.viewportHeight);
264
267
  if (r === 0) return [];
265
268
  let i = n.scrollTop, a = i + r;
266
269
  return t.filter((t) => {
267
270
  let n = e[t];
268
271
  if (!n || n.height <= 0) return !1;
269
- let o = Math.max(0, Math.min(n.y + n.height, a) - Math.max(n.y, i)), s = n.height <= r ? n.height : r * ue;
270
- return o + de >= s;
272
+ let o = Math.max(0, Math.min(n.y + n.height, a) - Math.max(n.y, i)), s = n.height <= r ? n.height : r * de;
273
+ return o + fe >= s;
271
274
  });
272
275
  }
273
- function Q(e, t) {
276
+ function pe(e, t) {
274
277
  if (e <= 0) return null;
275
278
  let n = Math.max(0, t.gap), r = Number.isFinite(t.additionalHeight) ? Math.max(0, t.additionalHeight ?? 0) : 0, i = Math.max(1, t.minColumnWidth), a = Math.max(1, Math.floor((e + n) / (i + n)));
276
279
  return {
@@ -280,8 +283,8 @@ function Q(e, t) {
280
283
  itemWidth: (e - n * (a - 1)) / a
281
284
  };
282
285
  }
283
- function pe(e, t, n) {
284
- let r = Z(t), i = n.itemWidth * X(e) + n.additionalHeight, a = {
286
+ function me(e, t, n) {
287
+ let r = le(t), i = n.itemWidth * Z(e) + n.additionalHeight, a = {
285
288
  x: r * (n.itemWidth + n.gap),
286
289
  y: t[r],
287
290
  width: n.itemWidth,
@@ -289,48 +292,48 @@ function pe(e, t, n) {
289
292
  };
290
293
  return t[r] += i + n.gap, a;
291
294
  }
292
- function me(e, t) {
295
+ function he(e, t) {
293
296
  let n = Array.from({ length: t.columns }, () => 0), r = t.itemWidth + t.gap;
294
297
  return e.forEach((e) => {
295
298
  let i = r === 0 ? 0 : Math.round(e.x / r);
296
299
  i < 0 || i >= t.columns || (n[i] = Math.max(n[i], e.y + e.height + t.gap));
297
300
  }), n;
298
301
  }
299
- function he(e, t) {
302
+ function ge(e, t) {
300
303
  return e.length === 0 ? 0 : Math.max(0, Math.max(...e) - t);
301
304
  }
302
- function ge(e, t, n) {
303
- let r = Q(t, n);
305
+ function _e(e, t, n) {
306
+ let r = pe(t, n);
304
307
  if (!r || e.length === 0) return {
305
308
  columns: 0,
306
309
  height: 0,
307
310
  items: []
308
311
  };
309
- let i = Array.from({ length: r.columns }, () => 0), a = e.map((e) => pe(e, i, r));
312
+ let i = Array.from({ length: r.columns }, () => 0), a = e.map((e) => me(e, i, r));
310
313
  return {
311
314
  columns: r.columns,
312
- height: he(i, r.gap),
315
+ height: ge(i, r.gap),
313
316
  items: a
314
317
  };
315
318
  }
316
- function _e(e, t, n, r, i, a) {
317
- let o = Q(t, n);
319
+ function ve(e, t, n, r, i, a) {
320
+ let o = pe(t, n);
318
321
  if (!o || e.length === 0) return {
319
322
  columns: 0,
320
323
  height: 0,
321
324
  items: []
322
325
  };
323
- if (r.columns !== o.columns || i > 0 && r.items.length < i) return ge(e, t, n);
324
- let s = Math.max(0, i), c = a?.untilIndex ?? e.length, l = a?.untilBottom, u = a?.throughIndex ?? s, d = s === 0 ? [] : r.items.slice(0, s), f = s === 0 ? Array.from({ length: o.columns }, () => 0) : me(d, o);
325
- for (let t = s; t < e.length && t < c && !(l !== void 0 && t > s && t > u && f.every((e) => e >= l)); t += 1) d.push(pe(e[t], f, o));
326
+ if (r.columns !== o.columns || i > 0 && r.items.length < i) return _e(e, t, n);
327
+ let s = Math.max(0, i), c = a?.untilIndex ?? e.length, l = a?.untilBottom, u = a?.throughIndex ?? s, d = s === 0 ? [] : r.items.slice(0, s), f = s === 0 ? Array.from({ length: o.columns }, () => 0) : he(d, o);
328
+ for (let t = s; t < e.length && t < c && !(l !== void 0 && t > s && t > u && f.every((e) => e >= l)); t += 1) d.push(me(e[t], f, o));
326
329
  return {
327
330
  columns: o.columns,
328
- height: he(f, o.gap),
331
+ height: ge(f, o.gap),
329
332
  items: d
330
333
  };
331
334
  }
332
- function ve(e, t, n, r, i, a) {
333
- let o = Q(t, n);
335
+ function ye(e, t, n, r, i, a) {
336
+ let o = pe(t, n);
334
337
  if (!o || e.length === 0) return {
335
338
  columns: 0,
336
339
  fromIndex: 0,
@@ -339,7 +342,7 @@ function ve(e, t, n, r, i, a) {
339
342
  retainedIndices: []
340
343
  };
341
344
  if (r.items.length !== e.length || r.columns !== o.columns) {
342
- let a = e.map((e, t) => t).filter((e) => !i(e)), o = ge(a.map((t) => e[t]), t, n), s = e.map((e, t) => r.items[t] ?? {
345
+ let a = e.map((e, t) => t).filter((e) => !i(e)), o = _e(a.map((t) => e[t]), t, n), s = e.map((e, t) => r.items[t] ?? {
343
346
  height: 0,
344
347
  width: 0,
345
348
  x: 0,
@@ -364,10 +367,10 @@ function ve(e, t, n, r, i, a) {
364
367
  };
365
368
  let c = r.items.slice(), l = [];
366
369
  for (let e = 0; e < s; e += 1) l.push(e);
367
- let u = a?.untilBottom, d = a?.throughIndex ?? s, f = me(c.slice(0, s), o);
370
+ let u = a?.untilBottom, d = a?.throughIndex ?? s, f = he(c.slice(0, s), o);
368
371
  for (let t = s; t < e.length; t += 1) if (!i(t)) {
369
372
  if (u !== void 0 && l.length > s && t > d && f.every((e) => e >= u)) break;
370
- c[t] = pe(e[t], f, o), l.push(t);
373
+ c[t] = me(e[t], f, o), l.push(t);
371
374
  }
372
375
  let p = new Set(l);
373
376
  for (let t = s; t < e.length; t += 1) i(t) || p.has(t) || (c[t] = {
@@ -379,17 +382,17 @@ function ve(e, t, n, r, i, a) {
379
382
  return {
380
383
  columns: o.columns,
381
384
  fromIndex: s,
382
- height: he(f, o.gap),
385
+ height: ge(f, o.gap),
383
386
  items: c,
384
387
  retainedIndices: l
385
388
  };
386
389
  }
387
390
  //#endregion
388
391
  //#region src/core/masonryViewportIndex.ts
389
- function ye(e) {
392
+ function be(e) {
390
393
  return { columns: [...e.entries()].sort(([e], [t]) => e - t).map(([, e]) => e.sort((e, t) => e.top - t.top || e.index - t.index)) };
391
394
  }
392
- function be(e, t, n) {
395
+ function xe(e, t, n) {
393
396
  let r = e.get(t.x) ?? [];
394
397
  r.push({
395
398
  bottom: t.y + t.height,
@@ -397,14 +400,14 @@ function be(e, t, n) {
397
400
  top: t.y
398
401
  }), e.set(t.x, r);
399
402
  }
400
- function xe(e, t) {
403
+ function Se(e, t) {
401
404
  let n = /* @__PURE__ */ new Map();
402
405
  return e.forEach((e, r) => {
403
- be(n, e, t?.[r] ?? r);
404
- }), ye(n);
406
+ xe(n, e, t?.[r] ?? r);
407
+ }), be(n);
405
408
  }
406
- function Se(e, t, n, r) {
407
- if (n <= 0) return xe(e, r);
409
+ function Ce(e, t, n, r) {
410
+ if (n <= 0) return Se(e, r);
408
411
  let i = /* @__PURE__ */ new Map();
409
412
  t.columns.forEach((t) => {
410
413
  t.forEach((t) => {
@@ -415,11 +418,11 @@ function Se(e, t, n, r) {
415
418
  a.push(t), i.set(r.x, a);
416
419
  });
417
420
  });
418
- for (let t = n; t < e.length; t += 1) be(i, e[t], r?.[t] ?? t);
419
- return ye(i);
421
+ for (let t = n; t < e.length; t += 1) xe(i, e[t], r?.[t] ?? t);
422
+ return be(i);
420
423
  }
421
- function Ce(e, t, n, r) {
422
- if (r <= 0) return xe(t.map((t) => e[t]), t);
424
+ function we(e, t, n, r) {
425
+ if (r <= 0) return Se(t.map((t) => e[t]), t);
423
426
  let i = /* @__PURE__ */ new Map();
424
427
  return n.columns.forEach((t) => {
425
428
  t.forEach((t) => {
@@ -430,10 +433,10 @@ function Ce(e, t, n, r) {
430
433
  a.push(t), i.set(n.x, a);
431
434
  });
432
435
  }), t.forEach((t) => {
433
- t < r || be(i, e[t], t);
434
- }), ye(i);
436
+ t < r || xe(i, e[t], t);
437
+ }), be(i);
435
438
  }
436
- function we(e, t) {
439
+ function Te(e, t) {
437
440
  let n = 0, r = 0, i = e.length;
438
441
  for (; r < i;) {
439
442
  let a = Math.floor((r + i) / 2);
@@ -444,10 +447,10 @@ function we(e, t) {
444
447
  inspected: n
445
448
  };
446
449
  }
447
- function Te(e, t) {
450
+ function Ee(e, t) {
448
451
  let n = Math.max(0, t.overscan), r = t.scrollTop - n, i = t.scrollTop + Math.max(0, t.viewportHeight) + n, a = [], o = 0;
449
452
  return e.columns.forEach((e) => {
450
- let t = we(e, r);
453
+ let t = Te(e, r);
451
454
  o += t.inspected;
452
455
  for (let n = t.index; n < e.length; n += 1) {
453
456
  let t = e[n];
@@ -459,14 +462,14 @@ function Te(e, t) {
459
462
  inspected: o
460
463
  };
461
464
  }
462
- function Ee(e) {
465
+ function De(e) {
463
466
  return e?.minColumnWidth ?? 240;
464
467
  }
465
- function De(e, t) {
468
+ function Oe(e, t) {
466
469
  let n = e?.overscan?.minimumPx ?? 800, r = e?.overscan?.viewportMultiplier ?? 1.5, i = Math.max(n, t * r), a = e?.overscan?.maximumPx;
467
470
  return a === void 0 ? i : Math.min(i, a);
468
471
  }
469
- function Oe(e) {
472
+ function ke(e) {
470
473
  if (e?.minColumnWidth !== void 0 && (!Number.isFinite(e.minColumnWidth) || e.minColumnWidth <= 0)) throw TypeError("Vibe masonry minColumnWidth must be a positive number.");
471
474
  let t = e?.overscan;
472
475
  if (t) {
@@ -480,10 +483,10 @@ function Oe(e) {
480
483
  }
481
484
  //#endregion
482
485
  //#region src/core/scrollbar.ts
483
- function ke(e, t, n) {
486
+ function Ae(e, t, n) {
484
487
  return Math.min(n, Math.max(t, e));
485
488
  }
486
- function Ae({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
489
+ function je({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
487
490
  let a = Math.max(0, e), o = Math.max(0, r), s = Math.max(0, i), c = Math.max(0, a - s);
488
491
  if (!(c > 0 && o > 0)) return {
489
492
  maximumScrollPosition: c,
@@ -492,23 +495,23 @@ function Ae({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize:
492
495
  thumbSize: o,
493
496
  thumbTravel: 0
494
497
  };
495
- let l = ke(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
498
+ let l = Ae(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
496
499
  return {
497
500
  maximumScrollPosition: c,
498
501
  scrollable: !0,
499
- thumbOffset: u * (ke(n, 0, c) / c),
502
+ thumbOffset: u * (Ae(n, 0, c) / c),
500
503
  thumbSize: l,
501
504
  thumbTravel: u
502
505
  };
503
506
  }
504
507
  //#endregion
505
508
  //#region src/components/GalleryScrollbar.vue?vue&type=script&setup=true&lang.ts
506
- var je = ["aria-hidden"], Me = [
509
+ var Me = ["aria-hidden"], Ne = [
507
510
  "aria-controls",
508
511
  "aria-valuemax",
509
512
  "aria-valuenow",
510
513
  "tabindex"
511
- ], Ne = 32, Pe = 40, Fe = 120, Ie = /* @__PURE__ */ d({
514
+ ], Pe = 32, Fe = 40, Ie = 120, Le = /* @__PURE__ */ d({
512
515
  __name: "GalleryScrollbar",
513
516
  props: {
514
517
  contentSize: {},
@@ -530,16 +533,16 @@ var je = ["aria-hidden"], Me = [
530
533
  function k() {
531
534
  g !== null && clearTimeout(g), g = setTimeout(() => {
532
535
  g = null, o.value || (l.value = !1);
533
- }, Fe);
536
+ }, Ie);
534
537
  }
535
538
  function A() {
536
539
  l.value = !0, k();
537
540
  }
538
541
  function j() {
539
542
  let e = t.scrollElement, r = i.value;
540
- return !e || !r ? n : Ae({
543
+ return !e || !r ? n : je({
541
544
  contentSize: e.scrollHeight,
542
- minimumThumbSize: Ne,
545
+ minimumThumbSize: Pe,
543
546
  scrollPosition: e.scrollTop,
544
547
  trackSize: r.clientHeight,
545
548
  viewportSize: e.clientHeight
@@ -592,7 +595,7 @@ var je = ["aria-hidden"], Me = [
592
595
  }
593
596
  function z(e) {
594
597
  if (!E.value) return;
595
- let n = t.scrollElement?.clientHeight ?? 0, r = t.scrollElement?.scrollTop ?? 0, i = e.key === "ArrowUp" ? r - Pe : e.key === "ArrowDown" ? r + Pe : e.key === "PageUp" ? r - n : e.key === "PageDown" ? r + n : e.key === "Home" ? 0 : e.key === "End" ? a.value.maximumScrollPosition : null;
598
+ let n = t.scrollElement?.clientHeight ?? 0, r = t.scrollElement?.scrollTop ?? 0, i = e.key === "ArrowUp" ? r - Fe : e.key === "ArrowDown" ? r + Fe : e.key === "PageUp" ? r - n : e.key === "PageDown" ? r + n : e.key === "Home" ? 0 : e.key === "End" ? a.value.maximumScrollPosition : null;
596
599
  i !== null && (e.preventDefault(), A(), P(i));
597
600
  }
598
601
  function B(e) {
@@ -638,15 +641,15 @@ var je = ["aria-hidden"], Me = [
638
641
  onPointerdown: I,
639
642
  onPointermove: L,
640
643
  onPointerup: R
641
- }, null, 44, Me)], 42, je));
644
+ }, null, 44, Ne)], 42, Me));
642
645
  }
643
- }), Le = (e) => {
646
+ }), Re = (e) => {
644
647
  for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
645
648
  return !1;
646
- }, Re = (e) => e === "", ze = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), Be = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), Ve = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), He = (e) => {
647
- let t = Ve(e);
649
+ }, ze = (e) => e === "", Be = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), Ve = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), He = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), Ue = (e) => {
650
+ let t = He(e);
648
651
  return t.charAt(0).toUpperCase() + t.slice(1);
649
- }, Ue = {
652
+ }, We = {
650
653
  xmlns: "http://www.w3.org/2000/svg",
651
654
  width: 24,
652
655
  height: 24,
@@ -656,27 +659,27 @@ var je = ["aria-hidden"], Me = [
656
659
  "stroke-width": 2,
657
660
  "stroke-linecap": "round",
658
661
  "stroke-linejoin": "round"
659
- }, We = ({ name: e, iconNode: t, absoluteStrokeWidth: n, "absolute-stroke-width": r, strokeWidth: i, "stroke-width": a, size: o = Ue.width, color: s = Ue.stroke, ...c }, { slots: l }) => p("svg", {
660
- ...Ue,
662
+ }, Ge = ({ name: e, iconNode: t, absoluteStrokeWidth: n, "absolute-stroke-width": r, strokeWidth: i, "stroke-width": a, size: o = We.width, color: s = We.stroke, ...c }, { slots: l }) => p("svg", {
663
+ ...We,
661
664
  ...c,
662
665
  width: o,
663
666
  height: o,
664
667
  stroke: s,
665
- "stroke-width": Re(n) || Re(r) || n === !0 || r === !0 ? Number(i || a || Ue["stroke-width"]) * 24 / Number(o) : i || a || Ue["stroke-width"],
666
- class: ze("lucide", c.class, ...e ? [`lucide-${Be(He(e))}-icon`, `lucide-${Be(e)}`] : ["lucide-icon"]),
667
- ...!l.default && !Le(c) && { "aria-hidden": "true" }
668
- }, [...t.map((e) => p(...e)), ...l.default ? [l.default()] : []]), Ge = (e, t) => (n, { slots: r, attrs: i }) => p(We, {
668
+ "stroke-width": ze(n) || ze(r) || n === !0 || r === !0 ? Number(i || a || We["stroke-width"]) * 24 / Number(o) : i || a || We["stroke-width"],
669
+ class: Be("lucide", c.class, ...e ? [`lucide-${Ve(Ue(e))}-icon`, `lucide-${Ve(e)}`] : ["lucide-icon"]),
670
+ ...!l.default && !Re(c) && { "aria-hidden": "true" }
671
+ }, [...t.map((e) => p(...e)), ...l.default ? [l.default()] : []]), Ke = (e, t) => (n, { slots: r, attrs: i }) => p(Ge, {
669
672
  ...i,
670
673
  ...n,
671
674
  iconNode: t,
672
675
  name: e
673
- }, r), Ke = Ge("chevron-left", [["path", {
676
+ }, r), qe = Ke("chevron-left", [["path", {
674
677
  d: "m15 18-6-6 6-6",
675
678
  key: "1wnfg3"
676
- }]]), qe = Ge("chevron-right", [["path", {
679
+ }]]), Je = Ke("chevron-right", [["path", {
677
680
  d: "m9 18 6-6-6-6",
678
681
  key: "mthhwq"
679
- }]]), Je = Ge("disc-3", [
682
+ }]]), Ye = Ke("disc-3", [
680
683
  ["circle", {
681
684
  cx: "12",
682
685
  cy: "12",
@@ -697,7 +700,7 @@ var je = ["aria-hidden"], Me = [
697
700
  d: "M18 12c0 1.7-.7 3.2-1.8 4.2",
698
701
  key: "1eah9h"
699
702
  }]
700
- ]), Ye = Ge("pause", [["rect", {
703
+ ]), Xe = Ke("pause", [["rect", {
701
704
  x: "14",
702
705
  y: "3",
703
706
  width: "5",
@@ -711,10 +714,10 @@ var je = ["aria-hidden"], Me = [
711
714
  height: "18",
712
715
  rx: "1",
713
716
  key: "1wsw3u"
714
- }]]), Xe = Ge("play", [["path", {
717
+ }]]), Ze = Ke("play", [["path", {
715
718
  d: "M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",
716
719
  key: "10ikf1"
717
- }]]), Ze = Ge("volume-2", [
720
+ }]]), Qe = Ke("volume-2", [
718
721
  ["path", {
719
722
  d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",
720
723
  key: "uqj9uw"
@@ -727,7 +730,7 @@ var je = ["aria-hidden"], Me = [
727
730
  d: "M19.364 18.364a9 9 0 0 0 0-12.728",
728
731
  key: "ijwkga"
729
732
  }]
730
- ]), Qe = Ge("volume-x", [
733
+ ]), $e = Ke("volume-x", [
731
734
  ["path", {
732
735
  d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",
733
736
  key: "uqj9uw"
@@ -746,22 +749,22 @@ var je = ["aria-hidden"], Me = [
746
749
  y2: "15",
747
750
  key: "5ykzw1"
748
751
  }]
749
- ]), $e = {
752
+ ]), et = {
750
753
  401: "Authentication required",
751
754
  403: "Access forbidden",
752
755
  404: "Preview not found",
753
756
  419: "Session expired",
754
757
  500: "Server error"
755
758
  };
756
- function et(e) {
759
+ function tt(e) {
757
760
  return e.match(/\/demo-errors\/(401|403|404|419|500)\//)?.[1] ?? "Error";
758
761
  }
759
- function tt(e) {
760
- return $e[et(e)] ?? "Preview unavailable";
762
+ function nt(e) {
763
+ return et[tt(e)] ?? "Preview unavailable";
761
764
  }
762
765
  //#endregion
763
766
  //#region src/components/CardRegion.vue
764
- var nt = /* @__PURE__ */ d({
767
+ var rt = /* @__PURE__ */ d({
765
768
  __name: "CardRegion",
766
769
  props: {
767
770
  index: {},
@@ -808,7 +811,7 @@ var nt = /* @__PURE__ */ d({
808
811
  "total"
809
812
  ]))], 38));
810
813
  }
811
- }), rt = ["aria-busy", "aria-label"], it = { class: "media-error-code" }, at = ["disabled"], ot = /* @__PURE__ */ d({
814
+ }), it = ["aria-busy", "aria-label"], at = { class: "media-error-code" }, ot = ["disabled"], st = /* @__PURE__ */ d({
812
815
  __name: "MediaError",
813
816
  props: {
814
817
  component: {},
@@ -843,7 +846,7 @@ var nt = /* @__PURE__ */ d({
843
846
  "retrying",
844
847
  "status"
845
848
  ]))], 32)) : (b(), s(e, { key: 1 }, [
846
- c("strong", it, T(t.status), 1),
849
+ c("strong", at, T(t.status), 1),
847
850
  c("span", null, T(t.label), 1),
848
851
  c("button", {
849
852
  "data-test": "media-retry",
@@ -852,26 +855,26 @@ var nt = /* @__PURE__ */ d({
852
855
  disabled: t.retrying,
853
856
  onClick: j(o, ["stop"]),
854
857
  onKeydown: r[2] ||= j(() => {}, ["stop"])
855
- }, T(t.retrying ? "Retrying…" : "Retry"), 41, at)
856
- ], 64))], 8, rt));
858
+ }, T(t.retrying ? "Retrying…" : "Retry"), 41, ot)
859
+ ], 64))], 8, it));
857
860
  }
858
- }), st = ["aria-label"], ct = [
861
+ }), ct = ["aria-label"], lt = [
859
862
  "max",
860
863
  "value",
861
864
  "aria-label",
862
865
  "aria-valuetext",
863
866
  "disabled"
864
- ], lt = {
867
+ ], ut = {
865
868
  key: 0,
866
869
  class: "media-controls-row"
867
- }, ut = ["aria-label", "title"], dt = { class: "media-controls-audio" }, ft = ["aria-label", "title"], pt = [
870
+ }, dt = ["aria-label", "title"], ft = { class: "media-controls-audio" }, pt = ["aria-label", "title"], mt = [
868
871
  "value",
869
872
  "aria-label",
870
873
  "aria-valuetext"
871
- ], mt = {
874
+ ], ht = {
872
875
  class: "media-control-time",
873
876
  "aria-live": "off"
874
- }, ht = /* @__PURE__ */ d({
877
+ }, gt = /* @__PURE__ */ d({
875
878
  __name: "MediaControls",
876
879
  props: {
877
880
  currentTime: {},
@@ -921,35 +924,35 @@ var nt = /* @__PURE__ */ d({
921
924
  "aria-valuetext": `${u(g.value)} of ${u(f.value)}`,
922
925
  disabled: f.value <= 0,
923
926
  onInput: n[0] ||= (e) => i("seek", d(e))
924
- }, null, 44, ct), e.layout === "reel" ? (b(), s("div", lt, [
927
+ }, null, 44, lt), e.layout === "reel" ? (b(), s("div", ut, [
925
928
  c("button", {
926
929
  type: "button",
927
930
  class: "media-control-button media-control-playback",
928
931
  "aria-label": e.playing ? `Pause ${p.value}` : `Play ${p.value}`,
929
932
  title: e.playing ? "Pause" : "Play",
930
933
  onClick: n[1] ||= (e) => i("togglePlayback")
931
- }, [e.playing ? (b(), a(E(Ye), {
934
+ }, [e.playing ? (b(), a(E(Xe), {
932
935
  key: 0,
933
936
  size: 18,
934
937
  fill: "currentColor"
935
- })) : (b(), a(E(Xe), {
938
+ })) : (b(), a(E(Ze), {
936
939
  key: 1,
937
940
  size: 18,
938
941
  fill: "currentColor"
939
- }))], 8, ut),
940
- c("div", dt, [c("button", {
942
+ }))], 8, dt),
943
+ c("div", ft, [c("button", {
941
944
  type: "button",
942
945
  class: "media-control-button",
943
946
  "aria-label": e.muted ? `Unmute ${p.value}` : `Mute ${p.value}`,
944
947
  title: e.muted ? "Unmute" : "Mute",
945
948
  onClick: n[2] ||= (e) => i("toggleMute")
946
- }, [e.muted || e.volume === 0 ? (b(), a(E(Qe), {
949
+ }, [e.muted || e.volume === 0 ? (b(), a(E($e), {
947
950
  key: 0,
948
951
  size: 18
949
- })) : (b(), a(E(Ze), {
952
+ })) : (b(), a(E(Qe), {
950
953
  key: 1,
951
954
  size: 18
952
- }))], 8, ft), c("input", {
955
+ }))], 8, pt), c("input", {
953
956
  class: "media-control-range media-control-volume",
954
957
  type: "range",
955
958
  min: "0",
@@ -960,15 +963,15 @@ var nt = /* @__PURE__ */ d({
960
963
  "aria-label": `${m.value} volume`,
961
964
  "aria-valuetext": `${Math.round(e.volume * 100)} percent`,
962
965
  onInput: n[3] ||= (e) => i("volumeChange", d(e))
963
- }, null, 44, pt)]),
964
- c("output", mt, T(u(g.value)) + " / " + T(u(f.value)), 1)
965
- ])) : o("", !0)], 42, st));
966
+ }, null, 44, mt)]),
967
+ c("output", ht, T(u(g.value)) + " / " + T(u(f.value)), 1)
968
+ ])) : o("", !0)], 42, ct));
966
969
  }
967
- }), gt = {
970
+ }), _t = {
968
971
  key: 0,
969
972
  class: "media-card-overlay-host",
970
973
  "data-test": "media-card-overlay"
971
- }, _t = /* @__PURE__ */ d({
974
+ }, vt = /* @__PURE__ */ d({
972
975
  __name: "MediaContextOverlay",
973
976
  props: {
974
977
  item: {},
@@ -978,7 +981,7 @@ var nt = /* @__PURE__ */ d({
978
981
  mediaSource: {}
979
982
  },
980
983
  setup(e) {
981
- return (t, n) => e.mediaCard?.overlay?.component ? (b(), s("div", gt, [(b(), a(C(e.mediaCard.overlay.component), {
984
+ return (t, n) => e.mediaCard?.overlay?.component ? (b(), s("div", _t, [(b(), a(C(e.mediaCard.overlay.component), {
982
985
  item: e.item,
983
986
  "media-index": e.mediaIndex,
984
987
  "media-item": e.mediaItem,
@@ -990,8 +993,8 @@ var nt = /* @__PURE__ */ d({
990
993
  "media-source"
991
994
  ]))])) : o("", !0);
992
995
  }
993
- }), vt = 40, yt = 160, bt = 24;
994
- function xt(e) {
996
+ }), yt = 40, bt = 160, xt = 24;
997
+ function St(e) {
995
998
  let t = w("next"), n = null, r = 0, i = !1, a = null, o = null;
996
999
  function s(n, r) {
997
1000
  let i = H(e.item()).length, a = (n + i) % i;
@@ -1001,7 +1004,7 @@ function xt(e) {
1001
1004
  r = 0, i = !1, n !== null && clearTimeout(n), n = null;
1002
1005
  }
1003
1006
  function l() {
1004
- n !== null && clearTimeout(n), n = setTimeout(c, yt);
1007
+ n !== null && clearTimeout(n), n = setTimeout(c, bt);
1005
1008
  }
1006
1009
  function u(e, t, n) {
1007
1010
  return t === 1 ? e * 16 : t === 2 ? e * n : e;
@@ -1009,7 +1012,7 @@ function xt(e) {
1009
1012
  function d(t) {
1010
1013
  if (H(e.item()).length <= 1) return;
1011
1014
  let n = t.currentTarget, a = u(t.deltaX, t.deltaMode, n?.clientWidth || 1);
1012
- if (a === 0 || (t.preventDefault(), l(), i) || (r += a, Math.abs(r) < bt)) return;
1015
+ if (a === 0 || (t.preventDefault(), l(), i) || (r += a, Math.abs(r) < xt)) return;
1013
1016
  let o = Math.sign(r);
1014
1017
  r = 0, i = !0, s(e.mediaIndex() + o);
1015
1018
  }
@@ -1021,7 +1024,7 @@ function xt(e) {
1021
1024
  let n = t.changedTouches[0];
1022
1025
  if (a === null || o === null || !n) return;
1023
1026
  let r = a - n.clientX, i = o - n.clientY;
1024
- a = null, o = null, !(Math.abs(r) <= Math.abs(i)) && (Math.abs(r) < vt || s(e.mediaIndex() + Math.sign(r)));
1027
+ a = null, o = null, !(Math.abs(r) <= Math.abs(i)) && (Math.abs(r) < yt || s(e.mediaIndex() + Math.sign(r)));
1025
1028
  }
1026
1029
  return v(c), {
1027
1030
  change: s,
@@ -1031,11 +1034,11 @@ function xt(e) {
1031
1034
  onWheel: d
1032
1035
  };
1033
1036
  }
1034
- var St = /* @__PURE__ */ new Map(), Ct = [], wt = 0, Tt = 0;
1035
- function Et(e, t) {
1037
+ var Ct = /* @__PURE__ */ new Map(), wt = [], Tt = 0, Et = 0;
1038
+ function Dt(e, t) {
1036
1039
  return `${t ? "timed" : "image"}:${e}`;
1037
1040
  }
1038
- function Dt(e, t, n) {
1041
+ function Ot(e, t, n) {
1039
1042
  let r = H(e);
1040
1043
  if (r.length < 2) return [];
1041
1044
  let i = U(e, t), a = [];
@@ -1049,7 +1052,7 @@ function Dt(e, t, n) {
1049
1052
  if (!t) return [];
1050
1053
  let i = I(t.type, t.src) === "audio" ? B(t) : z(t, n);
1051
1054
  if (!i) return [];
1052
- let a = L(i.type, i.src), s = Et(i.src, a);
1055
+ let a = L(i.type, i.src), s = Dt(i.src, a);
1053
1056
  return o.has(s) ? [] : (o.add(s), [{
1054
1057
  key: s,
1055
1058
  src: i.src,
@@ -1057,22 +1060,22 @@ function Dt(e, t, n) {
1057
1060
  }]);
1058
1061
  });
1059
1062
  }
1060
- function Ot(e) {
1063
+ function kt(e) {
1061
1064
  let t = e.element;
1062
1065
  e.element = null, t && (t instanceof HTMLVideoElement ? (t.pause(), t.removeAttribute("src"), t.load()) : t.removeAttribute("src"));
1063
1066
  }
1064
- function kt(e) {
1065
- St.delete(e.key);
1066
- let t = Ct.indexOf(e);
1067
- t >= 0 && Ct.splice(t, 1), e.cancel?.(), e.cancel = null, Ot(e);
1068
- }
1069
1067
  function At(e) {
1070
- e.state = "loading", wt += 1, e.timed && (Tt += 1);
1068
+ Ct.delete(e.key);
1069
+ let t = wt.indexOf(e);
1070
+ t >= 0 && wt.splice(t, 1), e.cancel?.(), e.cancel = null, kt(e);
1071
+ }
1072
+ function jt(e) {
1073
+ e.state = "loading", Tt += 1, e.timed && (Et += 1);
1071
1074
  let t = !1, n = () => void 0, r = (r) => {
1072
- t || (t = !0, n(), --wt, e.timed && --Tt, e.cancel = null, e.state = r, r === "failed" && Ot(e), e.refs === 0 && kt(e), jt());
1075
+ t || (t = !0, n(), --Tt, e.timed && --Et, e.cancel = null, e.state = r, r === "failed" && kt(e), e.refs === 0 && At(e), Mt());
1073
1076
  };
1074
1077
  if (e.cancel = () => {
1075
- t || (t = !0, n(), --wt, e.timed && --Tt, Ot(e), jt());
1078
+ t || (t = !0, n(), --Tt, e.timed && --Et, kt(e), Mt());
1076
1079
  }, e.timed) {
1077
1080
  let t = document.createElement("video"), i = () => r("ready"), a = () => r("failed");
1078
1081
  n = () => {
@@ -1091,38 +1094,38 @@ function At(e) {
1091
1094
  i.removeEventListener("load", a), i.removeEventListener("error", o);
1092
1095
  }, i.addEventListener("load", a, { once: !0 }), i.addEventListener("error", o, { once: !0 }), i.decoding = "async", i.fetchPriority = "low", i.src = e.src, e.element = i;
1093
1096
  }
1094
- function jt() {
1095
- for (; wt < 6;) {
1096
- let e = Ct.findIndex((e) => e.refs > 0 && e.state === "queued" && (!e.timed || Tt < 2));
1097
+ function Mt() {
1098
+ for (; Tt < 6;) {
1099
+ let e = wt.findIndex((e) => e.refs > 0 && e.state === "queued" && (!e.timed || Et < 2));
1097
1100
  if (e < 0) return;
1098
- let [t] = Ct.splice(e, 1);
1099
- t && At(t);
1101
+ let [t] = wt.splice(e, 1);
1102
+ t && jt(t);
1100
1103
  }
1101
1104
  }
1102
- function Mt(e) {
1103
- let t = St.get(e.key);
1105
+ function Nt(e) {
1106
+ let t = Ct.get(e.key);
1104
1107
  t || (t = {
1105
1108
  ...e,
1106
1109
  cancel: null,
1107
1110
  element: null,
1108
1111
  refs: 0,
1109
1112
  state: "queued"
1110
- }, St.set(t.key, t), Ct.push(t)), t.refs += 1, jt();
1113
+ }, Ct.set(t.key, t), wt.push(t)), t.refs += 1, Mt();
1111
1114
  let n = !1;
1112
1115
  return () => {
1113
- n || (n = !0, --t.refs, t.refs === 0 && kt(t));
1116
+ n || (n = !0, --t.refs, t.refs === 0 && At(t));
1114
1117
  };
1115
1118
  }
1116
1119
  //#endregion
1117
1120
  //#region src/components/useVisiblePostPreload.ts
1118
- function Nt(e) {
1119
- let t = r(() => e.layout() === "masonry" && e.inViewport() && e.mediaReady() && e.mediaCard()?.feedPreload === "visible-post"), n = r(() => t.value ? Dt(e.item(), e.mediaIndex(), e.mediaSource()) : []), i = /* @__PURE__ */ new Map();
1121
+ function Pt(e) {
1122
+ let t = r(() => e.layout() === "masonry" && e.inViewport() && e.mediaReady() && e.mediaCard()?.feedPreload === "visible-post"), n = r(() => t.value ? Ot(e.item(), e.mediaIndex(), e.mediaSource()) : []), i = /* @__PURE__ */ new Map();
1120
1123
  function a() {
1121
1124
  let e = new Map(n.value.map((e) => [e.key, e]));
1122
1125
  i.forEach((t, n) => {
1123
1126
  e.has(n) || (t(), i.delete(n));
1124
1127
  }), n.value.forEach((e) => {
1125
- i.has(e.key) || i.set(e.key, Mt(e));
1128
+ i.has(e.key) || i.set(e.key, Nt(e));
1126
1129
  });
1127
1130
  }
1128
1131
  O(() => n.value.map(({ key: e }) => e).join("\n"), a, { immediate: !0 }), v(() => {
@@ -1131,7 +1134,7 @@ function Nt(e) {
1131
1134
  }
1132
1135
  //#endregion
1133
1136
  //#region src/components/useMediaLoading.ts
1134
- function Pt(e) {
1137
+ function Ft(e) {
1135
1138
  let t = r(() => L(e.mediaType(), e.mediaSource())), n = r(() => e.layout() === "masonry" && e.fetchPriority() === "low" ? "lazy" : "eager"), i = r(() => e.layout() === "reel" && !e.active() ? "none" : e.fetchPriority() === "high" ? "auto" : e.layout() === "masonry" ? "none" : "metadata");
1136
1139
  return O(i, (t, n) => {
1137
1140
  n !== "none" || t === "none" || m(() => e.mediaElement.value?.load());
@@ -1143,7 +1146,7 @@ function Pt(e) {
1143
1146
  }
1144
1147
  //#endregion
1145
1148
  //#region src/components/useMediaReadiness.ts
1146
- function Ft(e) {
1149
+ function It(e) {
1147
1150
  let t = w(null), n = w(null), i = w(0), a = w(0), o = w(!0), s = w(!1), c = w(!1), l = null, u = !1, d = r(() => c.value || s.value ? "error" : o.value ? "loading" : e.previewState());
1148
1151
  function f() {
1149
1152
  l !== null && clearTimeout(l), l = null;
@@ -1201,30 +1204,30 @@ function Ft(e) {
1201
1204
  }
1202
1205
  //#endregion
1203
1206
  //#region src/core/reelAudio.ts
1204
- var It = {
1207
+ var Lt = {
1205
1208
  lastAudibleVolume: 1,
1206
1209
  muted: !1,
1207
1210
  volume: 1
1208
1211
  };
1209
- function Lt(e, t) {
1212
+ function Rt(e, t) {
1210
1213
  return typeof e == "number" && Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : t;
1211
1214
  }
1212
- function Rt(e, t = It) {
1213
- let n = Lt(e?.volume, t.volume), r = Lt(e?.lastAudibleVolume, n > 0 ? n : t.lastAudibleVolume);
1215
+ function zt(e, t = Lt) {
1216
+ let n = Rt(e?.volume, t.volume), r = Rt(e?.lastAudibleVolume, n > 0 ? n : t.lastAudibleVolume);
1214
1217
  return {
1215
- lastAudibleVolume: r > 0 ? r : It.lastAudibleVolume,
1218
+ lastAudibleVolume: r > 0 ? r : Lt.lastAudibleVolume,
1216
1219
  muted: typeof e?.muted == "boolean" ? e.muted : n === 0 || t.muted,
1217
1220
  volume: n
1218
1221
  };
1219
1222
  }
1220
1223
  //#endregion
1221
1224
  //#region src/components/useMediaCardAudio.ts
1222
- function zt(e) {
1223
- let t = Rt(e.reelAudioState()), n = e.layout() === "reel" && e.reelAudioState(), r = w(n ? t.muted : e.mediaCard()?.videoMuted ?? e.layout() === "masonry"), i = w(n ? t.volume : 1), a = n ? t.lastAudibleVolume : 1;
1225
+ function Bt(e) {
1226
+ let t = zt(e.reelAudioState()), n = e.layout() === "reel" && e.reelAudioState(), r = w(n ? t.muted : e.mediaCard()?.videoMuted ?? e.layout() === "masonry"), i = w(n ? t.volume : 1), a = n ? t.lastAudibleVolume : 1;
1224
1227
  function o() {
1225
1228
  let t = e.mediaElement.value, n = e.reelAudioState();
1226
1229
  if (!t || e.layout() !== "reel" || !n) return;
1227
- let o = Rt(n);
1230
+ let o = zt(n);
1228
1231
  a = o.lastAudibleVolume, i.value = o.volume, r.value = o.muted, t.volume = o.volume, t.muted = e.active() === !1 ? !0 : o.muted;
1229
1232
  }
1230
1233
  function s(e, t) {
@@ -1232,7 +1235,7 @@ function zt(e) {
1232
1235
  }
1233
1236
  function c(t) {
1234
1237
  if (e.layout() !== "reel") return;
1235
- let n = Rt({
1238
+ let n = zt({
1236
1239
  lastAudibleVolume: a,
1237
1240
  muted: t.muted,
1238
1241
  volume: t.volume
@@ -1267,7 +1270,7 @@ function zt(e) {
1267
1270
  }
1268
1271
  //#endregion
1269
1272
  //#region src/components/useReelVideoActivity.ts
1270
- function Bt(e) {
1273
+ function Vt(e) {
1271
1274
  let t = r(() => e.layout() === "reel" ? e.active() === !0 : e.inViewport()), n = r(() => t.value ? e.mediaIsMuted.value : !0);
1272
1275
  function i() {
1273
1276
  if (!t.value) {
@@ -1301,18 +1304,18 @@ function Bt(e) {
1301
1304
  }
1302
1305
  //#endregion
1303
1306
  //#region src/components/useTimedMediaCard.ts
1304
- function Vt(e) {
1307
+ function Ht(e) {
1305
1308
  return Number.isFinite(e) ? Math.max(0, e) : 0;
1306
1309
  }
1307
- function Ht(e) {
1308
- let t = w(0), n = w(0), r = w(!1), { apply: i, setVolume: a, sync: o, toggleMute: s, videoIsMuted: c, videoVolume: l } = zt({
1310
+ function Ut(e) {
1311
+ let t = w(0), n = w(0), r = w(!1), { apply: i, setVolume: a, sync: o, toggleMute: s, videoIsMuted: c, videoVolume: l } = Bt({
1309
1312
  active: e.active,
1310
1313
  layout: e.layout,
1311
1314
  mediaCard: e.mediaCard,
1312
1315
  mediaElement: e.mediaElement,
1313
1316
  onChange: e.onAudioChange,
1314
1317
  reelAudioState: e.reelAudioState
1315
- }), { effectiveMuted: u, onPlaying: d, playbackAllowed: f } = Bt({
1318
+ }), { effectiveMuted: u, onPlaying: d, playbackAllowed: f } = Vt({
1316
1319
  active: e.active,
1317
1320
  inViewport: e.inViewport,
1318
1321
  layout: e.layout,
@@ -1322,7 +1325,7 @@ function Ht(e) {
1322
1325
  });
1323
1326
  function p(r) {
1324
1327
  let i = r?.currentTarget ?? e.mediaElement.value;
1325
- i && (t.value = Vt(i.currentTime), n.value = Vt(i.duration), o(i, f.value));
1328
+ i && (t.value = Ht(i.currentTime), n.value = Ht(i.duration), o(i, f.value));
1326
1329
  }
1327
1330
  function m(t) {
1328
1331
  i(), p(t), e.onReady(t);
@@ -1332,7 +1335,7 @@ function Ht(e) {
1332
1335
  }
1333
1336
  function g(n) {
1334
1337
  let r = e.mediaElement.value;
1335
- !r || !Number.isFinite(n) || (r.currentTime = Math.min(Vt(r.duration), Math.max(0, n)), t.value = r.currentTime);
1338
+ !r || !Number.isFinite(n) || (r.currentTime = Math.min(Ht(r.duration), Math.max(0, n)), t.value = r.currentTime);
1336
1339
  }
1337
1340
  async function _() {
1338
1341
  let t = e.mediaElement.value;
@@ -1370,7 +1373,7 @@ function Ht(e) {
1370
1373
  }
1371
1374
  //#endregion
1372
1375
  //#region src/components/MediaCard.vue?vue&type=script&setup=true&lang.ts
1373
- var Ut = [
1376
+ var Wt = [
1374
1377
  "data-post-id",
1375
1378
  "data-media-index",
1376
1379
  "aria-hidden",
@@ -1378,29 +1381,29 @@ var Ut = [
1378
1381
  "inert",
1379
1382
  "role",
1380
1383
  "tabindex"
1381
- ], Wt = { class: "media-card-content" }, Gt = ["data-media-direction"], Kt = ["data-media-index"], qt = {
1384
+ ], Gt = { class: "media-card-content" }, Kt = ["data-media-direction"], qt = ["data-media-index"], Jt = {
1382
1385
  key: 0,
1383
1386
  "data-test": "media-loading",
1384
1387
  class: "media-loading",
1385
1388
  "aria-hidden": "true"
1386
- }, Jt = [
1389
+ }, Yt = [
1387
1390
  "data-source-generation",
1388
1391
  "src",
1389
1392
  "autoplay",
1390
1393
  "loop",
1391
1394
  "muted",
1392
1395
  "preload"
1393
- ], Yt = ["aria-label", "disabled"], Xt = [
1396
+ ], Xt = ["aria-label", "disabled"], Zt = [
1394
1397
  "src",
1395
1398
  "width",
1396
1399
  "height",
1397
1400
  "fetchpriority",
1398
1401
  "loading"
1399
- ], Zt = {
1402
+ ], Qt = {
1400
1403
  key: 1,
1401
1404
  class: "media-audio-fallback",
1402
1405
  "aria-hidden": "true"
1403
- }, Qt = [
1406
+ }, $t = [
1404
1407
  "data-source-generation",
1405
1408
  "src",
1406
1409
  "width",
@@ -1409,14 +1412,14 @@ var Ut = [
1409
1412
  "loop",
1410
1413
  "muted",
1411
1414
  "preload"
1412
- ], $t = [
1415
+ ], en = [
1413
1416
  "data-source-generation",
1414
1417
  "src",
1415
1418
  "width",
1416
1419
  "height",
1417
1420
  "fetchpriority",
1418
1421
  "loading"
1419
- ], en = ["aria-label"], tn = ["aria-label"], nn = ["aria-label"], rn = /* @__PURE__ */ d({
1422
+ ], tn = ["aria-label"], nn = ["aria-label"], rn = ["aria-label"], an = /* @__PURE__ */ d({
1420
1423
  __name: "MediaCard",
1421
1424
  props: {
1422
1425
  active: { type: Boolean },
@@ -1455,14 +1458,14 @@ var Ut = [
1455
1458
  function f(e = !1, t = "pointer") {
1456
1459
  e && d("activate", t);
1457
1460
  }
1458
- let p = r(() => H(l.item)), g = r(() => U(l.item, l.mediaIndex)), v = r(() => W(l.item, g.value)), y = r(() => z(v.value, l.mediaSource ?? "preview")), x = r(() => I(v.value.type, v.value.src)), S = r(() => x.value === "audio"), C = r(() => V(v.value, l.mediaSource ?? "preview")), T = r(() => S.value ? C.value : y.value), D = r(() => T.value.src), M = r(() => I(T.value.type, T.value.src)), N = r(() => y.value.width), P = r(() => y.value.height), F = r(() => B(v.value)), L = w(!1), R = r(() => L.value ? null : F.value), { effectivePreviewState: G, failSourceAttempt: K, imageElement: q, markSourceReady: J, noteSourceActivity: Y, retrySource: ee, retrying: te, sourceGeneration: ne, mediaElement: re } = Ft({
1461
+ let p = r(() => H(l.item)), g = r(() => U(l.item, l.mediaIndex)), v = r(() => W(l.item, g.value)), y = r(() => z(v.value, l.mediaSource ?? "preview")), x = r(() => I(v.value.type, v.value.src)), S = r(() => x.value === "audio"), C = r(() => V(v.value, l.mediaSource ?? "preview")), T = r(() => S.value ? C.value : y.value), D = r(() => T.value.src), M = r(() => I(T.value.type, T.value.src)), N = r(() => y.value.width), P = r(() => y.value.height), F = r(() => B(v.value)), L = w(!1), R = r(() => L.value ? null : F.value), { effectivePreviewState: G, failSourceAttempt: K, imageElement: q, markSourceReady: J, noteSourceActivity: Y, retrySource: ee, retrying: te, sourceGeneration: ne, mediaElement: re } = It({
1459
1462
  identity: () => `${l.item.postId}:${g.value}:${l.mediaSource ?? "preview"}:${D.value}:${M.value ?? ""}`,
1460
1463
  mediaIndex: () => g.value,
1461
1464
  onError: (e) => d("error", e),
1462
1465
  onReady: (e) => d("ready", e),
1463
1466
  previewState: () => l.previewState
1464
1467
  });
1465
- Nt({
1468
+ Pt({
1466
1469
  inViewport: () => l.inViewport === !0,
1467
1470
  item: () => l.item,
1468
1471
  layout: () => l.layout,
@@ -1471,7 +1474,7 @@ var Ut = [
1471
1474
  mediaReady: () => G.value === "ready",
1472
1475
  mediaSource: () => l.mediaSource ?? "preview"
1473
1476
  });
1474
- let { currentTime: ie, duration: ae, effectiveMuted: oe, isMuted: se, isPlaying: ce, onEnded: X, onLoadedMetadata: Z, onPlaying: le, playbackAllowed: ue, seek: de, setVolume: fe, sync: Q, toggleMute: pe, togglePlayback: me, volume: he } = Ht({
1477
+ let { currentTime: ie, duration: ae, effectiveMuted: oe, isMuted: se, isPlaying: X, onEnded: ce, onLoadedMetadata: Z, onPlaying: le, playbackAllowed: ue, seek: de, setVolume: fe, sync: Q, toggleMute: pe, togglePlayback: me, volume: he } = Ut({
1475
1478
  active: () => l.active,
1476
1479
  inViewport: () => l.inViewport === !0,
1477
1480
  layout: () => l.layout,
@@ -1485,12 +1488,12 @@ var Ut = [
1485
1488
  function _e(e) {
1486
1489
  return e.detail === 0 ? "keyboard" : "pointer";
1487
1490
  }
1488
- let { change: ve, direction: ye, onTouchEnd: be, onTouchStart: xe, onWheel: Se } = xt({
1491
+ let { change: ve, direction: ye, onTouchEnd: be, onTouchStart: xe, onWheel: Se } = St({
1489
1492
  item: () => l.item,
1490
1493
  layout: () => l.layout,
1491
1494
  mediaIndex: () => g.value,
1492
1495
  onChange: (e) => d("mediaChange", e)
1493
- }), { imageLoading: Ce, mediaIsTimed: we, timedMediaPreload: Te } = Pt({
1496
+ }), { imageLoading: Ce, mediaIsTimed: we, timedMediaPreload: Te } = Ft({
1494
1497
  active: () => l.active,
1495
1498
  fetchPriority: () => l.fetchPriority,
1496
1499
  layout: () => l.layout,
@@ -1529,8 +1532,8 @@ var Ut = [
1529
1532
  tabindex: e.interactive && !e.leaving && !ge.value ? 0 : void 0,
1530
1533
  onClick: i[34] ||= (t) => f(e.interactive && !ge.value, _e(t)),
1531
1534
  onKeydown: [i[35] ||= A((t) => f(e.interactive && !ge.value, "keyboard"), ["enter"]), i[36] ||= A(j((t) => f(e.interactive && !ge.value, "keyboard"), ["prevent"]), ["space"])]
1532
- }, [c("div", Wt, [
1533
- e.cardHeader ? (b(), a(nt, {
1535
+ }, [c("div", Gt, [
1536
+ e.cardHeader ? (b(), a(rt, {
1534
1537
  key: 0,
1535
1538
  index: e.index,
1536
1539
  item: e.item,
@@ -1569,12 +1572,12 @@ var Ut = [
1569
1572
  class: "media-card-frame",
1570
1573
  "data-media-index": g.value
1571
1574
  }, [
1572
- E(G) === "loading" ? (b(), s("div", qt, [...i[37] ||= [c("span", { class: "media-loading-shimmer" }, null, -1)]])) : E(G) === "error" ? (b(), a(ot, {
1575
+ E(G) === "loading" ? (b(), s("div", Jt, [...i[37] ||= [c("span", { class: "media-loading-shimmer" }, null, -1)]])) : E(G) === "error" ? (b(), a(st, {
1573
1576
  key: 1,
1574
1577
  component: e.mediaCard?.error?.component,
1575
- label: E(tt)(D.value),
1578
+ label: E(nt)(D.value),
1576
1579
  retrying: E(te),
1577
- status: E(et)(D.value),
1580
+ status: E(tt)(D.value),
1578
1581
  onRetry: E(ee)
1579
1582
  }, null, 8, [
1580
1583
  "component",
@@ -1602,15 +1605,15 @@ var Ut = [
1602
1605
  onTimeupdate: i[5] ||= (...e) => E(Q) && E(Q)(...e),
1603
1606
  onVolumechange: i[6] ||= (...e) => E(Q) && E(Q)(...e),
1604
1607
  onPlaying: i[7] ||= (...e) => E(le) && E(le)(...e),
1605
- onPause: i[8] ||= (e) => ce.value = !1,
1606
- onEnded: i[9] ||= (...e) => E(X) && E(X)(...e),
1608
+ onPause: i[8] ||= (e) => X.value = !1,
1609
+ onEnded: i[9] ||= (...e) => E(ce) && E(ce)(...e),
1607
1610
  onError: i[10] ||= (...e) => E(K) && E(K)(...e)
1608
- }, null, 40, Jt)) : o("", !0),
1611
+ }, null, 40, Yt)) : o("", !0),
1609
1612
  S.value ? (b(), s("button", {
1610
1613
  key: 3,
1611
1614
  type: "button",
1612
1615
  class: h(["media-audio-artwork media-preview", { "media-preview--ready": E(G) === "ready" }]),
1613
- "aria-label": e.layout === "reel" ? E(ce) ? "Pause audio" : "Play audio" : "Audio",
1616
+ "aria-label": e.layout === "reel" ? E(X) ? "Pause audio" : "Play audio" : "Audio",
1614
1617
  disabled: e.layout !== "reel",
1615
1618
  onClick: ke
1616
1619
  }, [R.value ? (b(), s("img", {
@@ -1625,10 +1628,10 @@ var Ut = [
1625
1628
  loading: E(Ce),
1626
1629
  onLoad: i[11] ||= (t) => e.layout === "masonry" && E(J)(t),
1627
1630
  onError: Ae
1628
- }, null, 40, Xt)) : (b(), s("span", Zt, [u(E(Je), {
1631
+ }, null, 40, Zt)) : (b(), s("span", Qt, [u(E(Ye), {
1629
1632
  size: 64,
1630
1633
  "stroke-width": 1.5
1631
- })]))], 10, Yt)) : E(we) ? (b(), s("video", {
1634
+ })]))], 10, Xt)) : E(we) ? (b(), s("video", {
1632
1635
  key: 4,
1633
1636
  ref_key: "mediaElement",
1634
1637
  ref: re,
@@ -1653,11 +1656,11 @@ var Ut = [
1653
1656
  onTimeupdate: i[17] ||= (...e) => E(Q) && E(Q)(...e),
1654
1657
  onVolumechange: i[18] ||= (...e) => E(Q) && E(Q)(...e),
1655
1658
  onPlaying: i[19] ||= (...e) => E(le) && E(le)(...e),
1656
- onPause: i[20] ||= (e) => ce.value = !1,
1657
- onEnded: i[21] ||= (...e) => E(X) && E(X)(...e),
1659
+ onPause: i[20] ||= (e) => X.value = !1,
1660
+ onEnded: i[21] ||= (...e) => E(ce) && E(ce)(...e),
1658
1661
  onClick: ke,
1659
1662
  onError: i[22] ||= (...e) => E(K) && E(K)(...e)
1660
- }, null, 42, Qt)) : S.value ? o("", !0) : (b(), s("img", {
1663
+ }, null, 42, $t)) : S.value ? o("", !0) : (b(), s("img", {
1661
1664
  key: 5,
1662
1665
  ref_key: "imageElement",
1663
1666
  ref: q,
@@ -1672,11 +1675,11 @@ var Ut = [
1672
1675
  loading: E(Ce),
1673
1676
  onLoad: i[23] ||= (...e) => E(J) && E(J)(...e),
1674
1677
  onError: i[24] ||= (...e) => E(K) && E(K)(...e)
1675
- }, null, 42, $t))
1676
- ], 8, Kt))]),
1678
+ }, null, 42, en))
1679
+ ], 8, qt))]),
1677
1680
  _: 1
1678
1681
  }, 8, ["css", "name"]),
1679
- u(_t, {
1682
+ u(vt, {
1680
1683
  item: e.item,
1681
1684
  "media-card": e.mediaCard,
1682
1685
  "media-index": g.value,
@@ -1696,7 +1699,7 @@ var Ut = [
1696
1699
  name: "vibe-reel-media-controls",
1697
1700
  css: Ee.value
1698
1701
  }, {
1699
- default: k(() => [De.value ? (b(), a(ht, {
1702
+ default: k(() => [De.value ? (b(), a(gt, {
1700
1703
  key: Oe.value,
1701
1704
  "current-time": E(ie),
1702
1705
  "data-control-post-id": Ee.value ? e.item.postId : void 0,
@@ -1704,7 +1707,7 @@ var Ut = [
1704
1707
  layout: e.layout,
1705
1708
  "media-type": S.value ? "audio" : "video",
1706
1709
  muted: E(se),
1707
- playing: E(ce),
1710
+ playing: E(X),
1708
1711
  volume: E(he),
1709
1712
  onSeek: E(de),
1710
1713
  onToggleMute: E(pe),
@@ -1736,13 +1739,13 @@ var Ut = [
1736
1739
  "aria-label": `Previous media for post ${e.item.postId}`,
1737
1740
  onClick: i[25] ||= j((e) => E(ve)(g.value - 1, e), ["stop"]),
1738
1741
  onKeydown: i[26] ||= j(() => {}, ["stop"])
1739
- }, [u(E(Ke), { size: 20 })], 40, en), c("button", {
1742
+ }, [u(E(qe), { size: 20 })], 40, tn), c("button", {
1740
1743
  type: "button",
1741
1744
  class: "media-carousel-control media-carousel-control--next",
1742
1745
  "aria-label": `Next media for post ${e.item.postId}`,
1743
1746
  onClick: i[27] ||= j((e) => E(ve)(g.value + 1, e), ["stop"]),
1744
1747
  onKeydown: i[28] ||= j(() => {}, ["stop"])
1745
- }, [u(E(qe), { size: 20 })], 40, tn)], 2)) : o("", !0),
1748
+ }, [u(E(Je), { size: 20 })], 40, nn)], 2)) : o("", !0),
1746
1749
  ge.value ? (b(), s("button", {
1747
1750
  key: 1,
1748
1751
  class: "media-card-activator",
@@ -1750,9 +1753,9 @@ var Ut = [
1750
1753
  "aria-label": `Open post ${e.item.postId}`,
1751
1754
  onClick: i[29] ||= j((e) => r.$emit("activate", _e(e)), ["stop"]),
1752
1755
  onKeydown: i[30] ||= j(() => {}, ["stop"])
1753
- }, null, 40, nn)) : o("", !0)
1754
- ], 42, Gt),
1755
- e.cardFooter ? (b(), a(nt, {
1756
+ }, null, 40, rn)) : o("", !0)
1757
+ ], 42, Kt),
1758
+ e.cardFooter ? (b(), a(rt, {
1756
1759
  key: 1,
1757
1760
  index: e.index,
1758
1761
  item: e.item,
@@ -1775,12 +1778,12 @@ var Ut = [
1775
1778
  "style",
1776
1779
  "total"
1777
1780
  ])) : o("", !0)
1778
- ])], 46, Ut));
1781
+ ])], 46, Wt));
1779
1782
  }
1780
1783
  });
1781
1784
  //#endregion
1782
1785
  //#region src/components/useMasonryMediaVisibility.ts
1783
- function an(e) {
1786
+ function on(e) {
1784
1787
  function t(t) {
1785
1788
  return t.flatMap((t) => {
1786
1789
  let n = e.items()[t];
@@ -1809,14 +1812,14 @@ function an(e) {
1809
1812
  }
1810
1813
  //#endregion
1811
1814
  //#region src/components/useSettledMasonryFeedLayout.ts
1812
- var on = 1500;
1813
- function sn(e) {
1815
+ var sn = 1500;
1816
+ function cn(e) {
1814
1817
  let t = w(0), n = 0, i = null, a = 0, o = 0, s = null, c = 0, l = null, u = null, d = 0;
1815
1818
  function f() {
1816
1819
  s !== null && (cancelAnimationFrame(s), s = null);
1817
1820
  }
1818
1821
  function p(e, t, n, r) {
1819
- return i = e, l = t.slice(), u = Se(e.items, u ?? xe(r.items), n), c = e.items.length < t.length ? Math.max(c, r.height, e.height) : 0, e.items.length < t.length && e.items.length > n && m(), e;
1822
+ return i = e, l = t.slice(), u = Ce(e.items, u ?? Se(r.items), n), c = e.items.length < t.length ? Math.max(c, r.height, e.height) : 0, e.items.length < t.length && e.items.length > n && m(), e;
1820
1823
  }
1821
1824
  function m() {
1822
1825
  s === null && (s = requestAnimationFrame(() => {
@@ -1824,13 +1827,13 @@ function sn(e) {
1824
1827
  let n = e.items(), r = i;
1825
1828
  if (!r || r.items.length >= n.length) return;
1826
1829
  let a = r.items.length;
1827
- p(_e(n, e.width.value, {
1830
+ p(ve(n, e.width.value, {
1828
1831
  additionalHeight: e.additionalHeight.value,
1829
1832
  gap: e.gap.value,
1830
1833
  minColumnWidth: e.minColumnWidth.value
1831
1834
  }, r, a, {
1832
1835
  throughIndex: e.packThroughIndex(),
1833
- untilIndex: a + on
1836
+ untilIndex: a + sn
1834
1837
  }), n, a, r), t.value += 1;
1835
1838
  }));
1836
1839
  }
@@ -1844,22 +1847,22 @@ function sn(e) {
1844
1847
  if (g && l && d === s && a === h.gap && n === h.additionalHeight && o === h.minColumnWidth) {
1845
1848
  let t = 0, n = l, i = Math.min(n.length, r.length);
1846
1849
  for (; t < i && n[t] === r[t];) t += 1;
1847
- return t === r.length && t === n.length ? (g.items.length > 0 && g.items.length < r.length && m(), g) : (f(), p(_e(r, s, h, g, t, {
1850
+ return t === r.length && t === n.length ? (g.items.length > 0 && g.items.length < r.length && m(), g) : (f(), p(ve(r, s, h, g, t, {
1848
1851
  throughIndex: e.packThroughIndex(),
1849
1852
  untilBottom: e.packUntilBottom()
1850
1853
  }), r, t, g));
1851
1854
  }
1852
1855
  f();
1853
- let _ = ge(r, s, h);
1854
- return i = _, l = r.slice(), d = s, a = h.gap, n = h.additionalHeight, o = h.minColumnWidth, u = xe(_.items), c = 0, _;
1855
- }), g = r(() => (h.value, u ?? xe(h.value.items)));
1856
+ let _ = _e(r, s, h);
1857
+ return i = _, l = r.slice(), d = s, a = h.gap, n = h.additionalHeight, o = h.minColumnWidth, u = Se(_.items), c = 0, _;
1858
+ }), g = r(() => (h.value, u ?? Se(h.value.items)));
1856
1859
  return v(f), {
1857
1860
  ensurePackedThrough(n) {
1858
1861
  let r = e.items(), a = i;
1859
1862
  if (!a || a.items.length >= r.length || a.height >= n) return;
1860
1863
  f();
1861
1864
  let o = a.items.length;
1862
- p(_e(r, e.width.value, {
1865
+ p(ve(r, e.width.value, {
1863
1866
  additionalHeight: e.additionalHeight.value,
1864
1867
  gap: e.gap.value,
1865
1868
  minColumnWidth: e.minColumnWidth.value
@@ -1875,10 +1878,10 @@ function sn(e) {
1875
1878
  }
1876
1879
  //#endregion
1877
1880
  //#region src/components/MasonryFeed.vue?vue&type=script&setup=true&lang.ts
1878
- var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
1881
+ var ln = { class: "masonry-feed-shell" }, un = ["aria-hidden", "inert"], dn = {
1879
1882
  key: 0,
1880
1883
  class: "masonry-feed-status-overlay"
1881
- }, dn = 6, fn = 12, pn = 250, mn = /* @__PURE__ */ d({
1884
+ }, fn = 6, pn = 12, mn = 250, hn = /* @__PURE__ */ d({
1882
1885
  __name: "MasonryFeed",
1883
1886
  props: {
1884
1887
  enteringPostIds: {},
@@ -1916,13 +1919,13 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
1916
1919
  "visible"
1917
1920
  ],
1918
1921
  setup(t, { expose: n, emit: i }) {
1919
- let l = 0, d = t, f = i, p = w(null), m = `vibe-masonry-${D()}`, g = w(null), y = w(0), x = w(dn), C = w(0), T = w(0), k = w(0), A = w([]), j = w([]), M = w([]), N = 0, P = null, F = null, I = null, L = null, R = r(() => ({
1922
+ let l = 0, d = t, f = i, p = w(null), m = `vibe-masonry-${D()}`, g = w(null), y = w(0), x = w(fn), C = w(0), T = w(0), k = w(0), A = w([]), j = w([]), M = w([]), N = 0, P = null, F = null, I = null, L = null, R = r(() => ({
1920
1923
  additionalHeight: (d.cardHeader?.height ?? 0) + (d.cardFooter?.height ?? 0),
1921
1924
  gap: x.value,
1922
- minColumnWidth: Ee(d.masonry)
1925
+ minColumnWidth: De(d.masonry)
1923
1926
  })), z = [];
1924
1927
  function B() {
1925
- let e = N - k.value + C.value + De(d.masonry, C.value), t = M.value.reduce((e, t) => {
1928
+ let e = N - k.value + C.value + Oe(d.masonry, C.value), t = M.value.reduce((e, t) => {
1926
1929
  let n = z[t];
1927
1930
  return n ? Math.max(e, n.y + n.height) : e;
1928
1931
  }, 0);
@@ -1931,7 +1934,7 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
1931
1934
  function V() {
1932
1935
  return M.value.reduce((e, t) => Math.max(e, t), -1);
1933
1936
  }
1934
- let H = sn({
1937
+ let H = cn({
1935
1938
  additionalHeight: r(() => R.value.additionalHeight),
1936
1939
  gap: x,
1937
1940
  items: () => d.items,
@@ -1939,7 +1942,7 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
1939
1942
  packThroughIndex: V,
1940
1943
  packUntilBottom: B,
1941
1944
  width: y
1942
- }), U = H.layout, W = H.viewportIndex, K = r(() => d.leavingPostIds.size === 0 ? null : ve(d.items, y.value, R.value, U.value, (e) => d.leavingPostIds.has(d.items[e].postId), {
1945
+ }), U = H.layout, W = H.viewportIndex, K = r(() => d.leavingPostIds.size === 0 ? null : ye(d.items, y.value, R.value, U.value, (e) => d.leavingPostIds.has(d.items[e].postId), {
1943
1946
  throughIndex: V(),
1944
1947
  untilBottom: B()
1945
1948
  })), q = r(() => {
@@ -1951,7 +1954,7 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
1951
1954
  } : U.value;
1952
1955
  }), J = r(() => {
1953
1956
  let e = K.value;
1954
- return e ? Ce(e.items, e.retainedIndices, W.value, e.fromIndex) : null;
1957
+ return e ? we(e.items, e.retainedIndices, W.value, e.fromIndex) : null;
1955
1958
  }), Y = r(() => (U.value, Math.max(T.value, H.reservedHeight(), d.leavingPostIds.size === 0 ? q.value.height : U.value.height))), ee = r(() => ({ height: `${Y.value}px` })), te = r(() => !d.infiniteScroll || C.value > 0 && k.value + q.value.height <= C.value + 1), ne = r(() => new Set(j.value)), re = r(() => M.value.flatMap((e) => {
1956
1959
  let t = d.items[e], n = q.value.items[e];
1957
1960
  return !t || !n || n.width <= 0 || n.height <= 0 ? [] : [{
@@ -1960,7 +1963,7 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
1960
1963
  item: t
1961
1964
  }];
1962
1965
  }));
1963
- function ae(e, t) {
1966
+ function ie(e, t) {
1964
1967
  return [...new Set([...e, ...t])].sort((e, t) => e - t);
1965
1968
  }
1966
1969
  function oe(e, t) {
@@ -1970,11 +1973,11 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
1970
1973
  let t = {
1971
1974
  scrollTop: N - k.value,
1972
1975
  viewportHeight: C.value
1973
- }, n = J.value, r = Te(n ?? W.value, {
1976
+ }, n = J.value, r = Ee(n ?? W.value, {
1974
1977
  ...t,
1975
1978
  overscan: e
1976
1979
  }).indices;
1977
- return ae(r, d.leavingPostIds.size === 0 ? [] : Te(W.value, {
1980
+ return ie(r, d.leavingPostIds.size === 0 ? [] : Ee(W.value, {
1978
1981
  ...t,
1979
1982
  overscan: e
1980
1983
  }).indices.filter((e) => {
@@ -1983,9 +1986,9 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
1983
1986
  }));
1984
1987
  }
1985
1988
  function X() {
1986
- let e = se(0), t = se(De(d.masonry, C.value));
1989
+ let e = se(0), t = se(Oe(d.masonry, C.value));
1987
1990
  oe(j.value, e) || (j.value = e);
1988
- let n = fe(q.value.items, e.filter((e) => {
1991
+ let n = Q(q.value.items, e.filter((e) => {
1989
1992
  let t = d.items[e];
1990
1993
  return t && !d.leavingPostIds.has(t.postId);
1991
1994
  }), {
@@ -2002,7 +2005,7 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
2002
2005
  });
2003
2006
  L !== null && (L = e);
2004
2007
  }
2005
- an({
2008
+ on({
2006
2009
  fullyVisibleIndices: () => A.value,
2007
2010
  items: () => d.items,
2008
2011
  mediaIndices: () => d.mediaIndices,
@@ -2011,10 +2014,10 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
2011
2014
  previewStates: () => d.previewStates,
2012
2015
  visibleIndices: () => j.value
2013
2016
  });
2014
- function ue(e) {
2017
+ function le(e) {
2015
2018
  let t = q.value.items[e], n = d.items[e]?.postId;
2016
2019
  if (!t || t.width <= 0 || t.height <= 0) return {};
2017
- let r = n !== void 0 && d.enteringPostIds.has(n), i = n !== void 0 && d.leavingPostIds.has(n), a = r || i ? le({
2020
+ let r = n !== void 0 && d.enteringPostIds.has(n), i = n !== void 0 && d.leavingPostIds.has(n), a = r || i ? ue({
2018
2021
  containerHeight: Math.max(T.value, U.value.height),
2019
2022
  gap: x.value
2020
2023
  }) : 0, o = n === void 0 ? 0 : i ? d.removalDelays.get(n) ?? 0 : r ? d.entryDelays.get(n) ?? 0 : 0;
@@ -2034,9 +2037,9 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
2034
2037
  let r = g.value;
2035
2038
  r && (k.value = r.getBoundingClientRect().top - e.getBoundingClientRect().top + e.scrollTop, X());
2036
2039
  }
2037
- function Q(e) {
2040
+ function fe(e) {
2038
2041
  let t = e.ownerDocument.documentElement.clientWidth;
2039
- y.value = e.clientWidth, x.value = Math.min(fn, Math.max(dn, t * .0075)), de();
2042
+ y.value = e.clientWidth, x.value = Math.min(pn, Math.max(fn, t * .0075)), de();
2040
2043
  }
2041
2044
  function pe(e) {
2042
2045
  let t = e.currentTarget;
@@ -2047,16 +2050,16 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
2047
2050
  Date.now() >= l && !d.loadMoreLocked && e && ce(e) && f("loadMore");
2048
2051
  }
2049
2052
  O(() => d.items.length, (e, t) => {
2050
- e > 0 && e < t && (l = Date.now() + pn);
2053
+ e > 0 && e < t && (l = Date.now() + mn);
2051
2054
  });
2052
2055
  function he() {
2053
2056
  return p.value;
2054
2057
  }
2055
2058
  return O(g, (e) => {
2056
- P?.disconnect(), P = null, I !== null && cancelAnimationFrame(I), e && (Q(e), !(typeof ResizeObserver > "u") && (P = new ResizeObserver(([t]) => {
2059
+ P?.disconnect(), P = null, I !== null && cancelAnimationFrame(I), e && (fe(e), !(typeof ResizeObserver > "u") && (P = new ResizeObserver(([t]) => {
2057
2060
  let n = t?.contentRect.width ?? e.clientWidth;
2058
2061
  Math.abs(n - y.value) < .5 || (I = requestAnimationFrame(() => {
2059
- I = null, Q(e);
2062
+ I = null, fe(e);
2060
2063
  }));
2061
2064
  }), P.observe(e)));
2062
2065
  }), O(p, (e) => {
@@ -2072,7 +2075,7 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
2072
2075
  }), n({
2073
2076
  getScrollElement: he,
2074
2077
  loadIfNearBottom: me
2075
- }), (n, r) => (b(), s("div", cn, [
2078
+ }), (n, r) => (b(), s("div", ln, [
2076
2079
  c("main", {
2077
2080
  id: m,
2078
2081
  ref_key: "galleryElement",
@@ -2088,7 +2091,7 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
2088
2091
  class: h(["masonry", { "masonry--ready": y.value > 0 }]),
2089
2092
  style: _(ee.value),
2090
2093
  "aria-label": "Media gallery"
2091
- }, [(b(!0), s(e, null, S(re.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(rn, {
2094
+ }, [(b(!0), s(e, null, S(re.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(an, {
2092
2095
  key: n.postId,
2093
2096
  class: "masonry-item",
2094
2097
  entering: t.enteringPostIds.has(n.postId),
@@ -2100,7 +2103,7 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
2100
2103
  "in-viewport": ne.value.has(r),
2101
2104
  index: r,
2102
2105
  item: n,
2103
- "item-style": ue(r),
2106
+ "item-style": le(r),
2104
2107
  interactive: "",
2105
2108
  layout: "masonry",
2106
2109
  "loaded-count": t.items.length,
@@ -2130,8 +2133,8 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
2130
2133
  "onMediaChange",
2131
2134
  "onReady",
2132
2135
  "onError"
2133
- ]))), 128))], 6)], 42, ln),
2134
- t.feedFooter || t.isLoadingMore || t.nextPageError || t.hasNext && te.value || !t.hasNext && t.canRetryEnd ? (b(), s("div", un, [u(ie, {
2136
+ ]))), 128))], 6)], 42, un),
2137
+ t.feedFooter || t.isLoadingMore || t.nextPageError || t.hasNext && te.value || !t.hasNext && t.canRetryEnd ? (b(), s("div", dn, [u(ae, {
2135
2138
  actions: t.feedFooterActions,
2136
2139
  "can-retry-end": t.canRetryEnd,
2137
2140
  "feed-footer": t.feedFooter,
@@ -2154,7 +2157,7 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
2154
2157
  "show-load-more",
2155
2158
  "state"
2156
2159
  ])])) : o("", !0),
2157
- u(Ie, {
2160
+ u(Le, {
2158
2161
  "content-size": q.value.height,
2159
2162
  "controls-id": m,
2160
2163
  "scroll-element": p.value,
@@ -2166,8 +2169,8 @@ var cn = { class: "masonry-feed-shell" }, ln = ["aria-hidden", "inert"], un = {
2166
2169
  ])
2167
2170
  ]));
2168
2171
  }
2169
- }), hn = 300;
2170
- function gn(e, t, n) {
2172
+ }), gn = 300;
2173
+ function _n(e, t, n) {
2171
2174
  let r = e.scrollTop;
2172
2175
  if (n || Math.abs(r - t) <= 1) return e.scrollTop = t, Promise.resolve();
2173
2176
  e.setAttribute("data-transitioning", "");
@@ -2175,7 +2178,7 @@ function gn(e, t, n) {
2175
2178
  return new Promise((n) => {
2176
2179
  let o = (s) => {
2177
2180
  a += 1;
2178
- let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c / hn), u = 1 - (1 - l) ** 3;
2181
+ let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c / gn), u = 1 - (1 - l) ** 3;
2179
2182
  if (e.scrollTop = r + (t - r) * u, l < 1) {
2180
2183
  requestAnimationFrame(o);
2181
2184
  return;
@@ -2187,7 +2190,7 @@ function gn(e, t, n) {
2187
2190
  }
2188
2191
  //#endregion
2189
2192
  //#region src/components/ReelAutoAdvanceProgress.vue?vue&type=script&setup=true&lang.ts
2190
- var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2193
+ var vn = ["aria-label"], yn = /* @__PURE__ */ d({
2191
2194
  __name: "ReelAutoAdvanceProgress",
2192
2195
  props: {
2193
2196
  durationMs: {},
@@ -2205,9 +2208,9 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2205
2208
  class: "reel-auto-advance-progress",
2206
2209
  style: _(a.value),
2207
2210
  onAnimationend: n[0] ||= (e) => i("complete")
2208
- }, null, 36)], 8, _n));
2211
+ }, null, 36)], 8, vn));
2209
2212
  }
2210
- }), yn = { class: "reel-viewport" }, bn = ["data-active-post-id", "data-active-media-index"], xn = ["role", "data-status"], Sn = ["disabled"], Cn = 300, wn = 250, Tn = /* @__PURE__ */ d({
2213
+ }), bn = { class: "reel-viewport" }, xn = ["data-active-post-id", "data-active-media-index"], Sn = ["role", "data-status"], Cn = ["disabled"], wn = 300, Tn = 250, En = /* @__PURE__ */ d({
2211
2214
  __name: "ReelFeed",
2212
2215
  props: {
2213
2216
  initialPostId: {},
@@ -2274,7 +2277,7 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2274
2277
  function re(e) {
2275
2278
  return { gridRow: `${e + 1}` };
2276
2279
  }
2277
- function ae(e) {
2280
+ function ie(e) {
2278
2281
  let t = k || e.clientHeight;
2279
2282
  return t <= 0 || u.items.length === 0 ? 0 : Math.min(u.items.length - 1, Math.max(0, Math.round(e.scrollTop / t)));
2280
2283
  }
@@ -2282,7 +2285,7 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2282
2285
  let t = e.currentTarget;
2283
2286
  if (!t) return;
2284
2287
  let n = k || t.clientHeight, r = Math.max(0, u.items.length - 1) * n;
2285
- C.value = u.items.length > 0 && t.scrollTop > r + 1, D.value || (x.value = ae(t)), Date.now() >= l && !u.loadMoreLocked && u.infiniteScroll && ce(t) && d("loadMore");
2288
+ C.value = u.items.length > 0 && t.scrollTop > r + 1, D.value || (x.value = ie(t)), Date.now() >= l && !u.loadMoreLocked && u.infiniteScroll && ce(t) && d("loadMore");
2286
2289
  }
2287
2290
  function se() {
2288
2291
  let e = f.value;
@@ -2310,7 +2313,7 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2310
2313
  Date.now() >= l && !u.loadMoreLocked && e && ce(e) && d("loadMore");
2311
2314
  }
2312
2315
  O(() => u.items.length, (e, t) => {
2313
- e > 0 && e < t && (l = Date.now() + wn);
2316
+ e > 0 && e < t && (l = Date.now() + Tn);
2314
2317
  });
2315
2318
  function de(e) {
2316
2319
  let t = I.value;
@@ -2335,7 +2338,7 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2335
2338
  let t = f.value;
2336
2339
  if (!t) return Promise.resolve();
2337
2340
  let n = e * (k || t.clientHeight);
2338
- return x.value = e, gn(t, n, pe());
2341
+ return x.value = e, _n(t, n, pe());
2339
2342
  }
2340
2343
  function he(e) {
2341
2344
  me(e);
@@ -2345,7 +2348,7 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2345
2348
  return t < 0 || t === x.value ? !1 : (await me(t), !0);
2346
2349
  }
2347
2350
  async function _e(e) {
2348
- return de(e) ? (pe() || await new Promise((e) => setTimeout(e, Cn)), !0) : !1;
2351
+ return de(e) ? (pe() || await new Promise((e) => setTimeout(e, wn)), !0) : !1;
2349
2352
  }
2350
2353
  function ve() {
2351
2354
  if (!u.reelAutoAdvance.enabled) return;
@@ -2392,7 +2395,7 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2392
2395
  }]),
2393
2396
  "data-layout-mode": "reel"
2394
2397
  }, [
2395
- t.cardHeader && I.value && t.reelForward.status === "idle" ? (b(), a(nt, {
2398
+ t.cardHeader && I.value && t.reelForward.status === "idle" ? (b(), a(rt, {
2396
2399
  key: 0,
2397
2400
  index: x.value,
2398
2401
  item: I.value,
@@ -2414,7 +2417,7 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2414
2417
  "style",
2415
2418
  "total"
2416
2419
  ])) : o("", !0),
2417
- c("div", yn, [c("div", {
2420
+ c("div", bn, [c("div", {
2418
2421
  ref_key: "galleryElement",
2419
2422
  ref: f,
2420
2423
  class: "gallery-shell reel-feed",
@@ -2426,7 +2429,7 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2426
2429
  class: "reel-track",
2427
2430
  style: _(N.value),
2428
2431
  "aria-label": "Media gallery"
2429
- }, [(b(!0), s(e, null, S(P.value, ({ fetchPriority: e, item: n, index: i }) => (b(), a(rn, {
2432
+ }, [(b(!0), s(e, null, S(P.value, ({ fetchPriority: e, item: n, index: i }) => (b(), a(an, {
2430
2433
  key: n.postId,
2431
2434
  active: i === x.value && !C.value,
2432
2435
  "advance-on-media-end": u.reelAutoAdvance.enabled && i === x.value,
@@ -2481,7 +2484,7 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2481
2484
  type: "button",
2482
2485
  disabled: t.loadMoreLocked,
2483
2486
  onClick: r[0] ||= (e) => d("retryForward")
2484
- }, T(te.value ? "Load more" : "Retry"), 9, Sn)) : o("", !0)], 8, xn)), t.reelForward.status === "idle" ? (b(), a(ie, {
2487
+ }, T(te.value ? "Load more" : "Retry"), 9, Cn)) : o("", !0)], 8, Sn)), t.reelForward.status === "idle" ? (b(), a(ae, {
2485
2488
  key: 2,
2486
2489
  actions: t.feedFooterActions,
2487
2490
  "can-retry-end": t.canRetryEnd,
@@ -2504,13 +2507,13 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2504
2507
  "load-more-locked",
2505
2508
  "show-load-more",
2506
2509
  "state"
2507
- ])) : o("", !0)], 40, bn), c("div", {
2510
+ ])) : o("", !0)], 40, xn), c("div", {
2508
2511
  ref_key: "reelControlsElement",
2509
2512
  ref: p,
2510
2513
  class: "reel-media-controls-host",
2511
2514
  "data-test": "reel-media-controls-host"
2512
2515
  }, null, 512)]),
2513
- t.cardFooter && I.value && t.reelForward.status === "idle" ? (b(), a(nt, {
2516
+ t.cardFooter && I.value && t.reelForward.status === "idle" ? (b(), a(rt, {
2514
2517
  key: 1,
2515
2518
  index: x.value,
2516
2519
  item: I.value,
@@ -2532,7 +2535,7 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2532
2535
  "style",
2533
2536
  "total"
2534
2537
  ])) : o("", !0),
2535
- Y.value ? (b(), a(vn, {
2538
+ Y.value ? (b(), a(yn, {
2536
2539
  key: q.value,
2537
2540
  "duration-ms": t.reelAutoAdvance.intervalMs,
2538
2541
  label: J.value,
@@ -2540,16 +2543,16 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2540
2543
  }, null, 8, ["duration-ms", "label"])) : o("", !0)
2541
2544
  ], 2));
2542
2545
  }
2543
- }), En = ["data-info-sheet-open", "data-info-sheet-mode"], Dn = ["aria-hidden", "inert"], On = {
2546
+ }), Dn = ["data-info-sheet-open", "data-info-sheet-mode"], On = ["aria-hidden", "inert"], kn = {
2544
2547
  key: 0,
2545
2548
  class: "reel-info-sheet-layer",
2546
2549
  "data-test": "reel-info-sheet"
2547
- }, kn = [
2550
+ }, An = [
2548
2551
  "role",
2549
2552
  "aria-modal",
2550
2553
  "tabindex",
2551
2554
  "data-active-post-id"
2552
- ], An = /* @__PURE__ */ d({
2555
+ ], jn = /* @__PURE__ */ d({
2553
2556
  __name: "ReelLayout",
2554
2557
  props: {
2555
2558
  forwardIndex: { default: null },
@@ -2676,7 +2679,7 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2676
2679
  class: "reel-layout-main",
2677
2680
  "aria-hidden": e.infoSheetOverlay && A.value || void 0,
2678
2681
  inert: e.infoSheetOverlay && A.value || void 0
2679
- }, [u(Tn, {
2682
+ }, [u(En, {
2680
2683
  ref_key: "reelFeed",
2681
2684
  ref: p,
2682
2685
  "can-retry-end": e.canRetryEnd,
@@ -2730,8 +2733,8 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2730
2733
  "reel-forward",
2731
2734
  "state",
2732
2735
  "total"
2733
- ])], 8, Dn), u(n, { name: "vibe-info-sheet" }, {
2734
- default: k(() => [A.value && e.infoSheet && j.value ? (b(), s("div", On, [c("aside", {
2736
+ ])], 8, On), u(n, { name: "vibe-info-sheet" }, {
2737
+ default: k(() => [A.value && e.infoSheet && j.value ? (b(), s("div", kn, [c("aside", {
2735
2738
  ref_key: "sheetElement",
2736
2739
  ref: _,
2737
2740
  class: "reel-info-sheet",
@@ -2740,14 +2743,14 @@ var _n = ["aria-label"], vn = /* @__PURE__ */ d({
2740
2743
  "aria-modal": e.infoSheetOverlay ? "true" : void 0,
2741
2744
  tabindex: e.infoSheetOverlay ? -1 : void 0,
2742
2745
  "data-active-post-id": T.value?.postId
2743
- }, [(b(), a(C(e.infoSheet.component), g(f(j.value)), null, 16))], 8, kn)])) : o("", !0)]),
2746
+ }, [(b(), a(C(e.infoSheet.component), g(f(j.value)), null, 16))], 8, An)])) : o("", !0)]),
2744
2747
  _: 1
2745
- })], 10, En));
2748
+ })], 10, Dn));
2746
2749
  }
2747
2750
  });
2748
2751
  //#endregion
2749
2752
  //#region src/core/mediaLifecycle.ts
2750
- function jn(e, t, n, r, i) {
2753
+ function Mn(e, t, n, r, i) {
2751
2754
  let a = e.items.findIndex((e) => e.postId === t), o = e.items[a];
2752
2755
  if (!o) return null;
2753
2756
  let s = U(o, n), c = W(o, s);
@@ -2763,7 +2766,7 @@ function jn(e, t, n, r, i) {
2763
2766
  postIndex: a
2764
2767
  };
2765
2768
  }
2766
- function Mn(e, t) {
2769
+ function Nn(e, t) {
2767
2770
  O(() => {
2768
2771
  let t = e.layout === "reel" || e.reelOrigin === "masonry" ? e.activeReelPostId : null;
2769
2772
  return {
@@ -2773,13 +2776,13 @@ function Mn(e, t) {
2773
2776
  };
2774
2777
  }, (n, r) => {
2775
2778
  if (n.postId === null || n.postId === r?.postId && n.mediaIndex === r.mediaIndex && n.origin === r.origin) return;
2776
- let i = jn(e, n.postId, n.mediaIndex, "reel", n.origin);
2779
+ let i = Mn(e, n.postId, n.mediaIndex, "reel", n.origin);
2777
2780
  i && t(i);
2778
2781
  }, { flush: "sync" });
2779
2782
  }
2780
2783
  //#endregion
2781
2784
  //#region src/components/useMediaLifecycle.ts
2782
- function Nn(e, t) {
2785
+ function Pn(e, t) {
2783
2786
  let n = /* @__PURE__ */ new Set(), i = w(/* @__PURE__ */ new Map()), a = w(/* @__PURE__ */ new Map()), o = w(/* @__PURE__ */ new Map()), s = () => e.reelMediaSource === "preview" ? i : e.reelMediaSource === "mobile" ? o : a, c = r(() => s().value), l = /* @__PURE__ */ new Set();
2784
2787
  function u() {
2785
2788
  n.clear(), l.clear(), i.value = /* @__PURE__ */ new Map(), a.value = /* @__PURE__ */ new Map(), o.value = /* @__PURE__ */ new Map();
@@ -2789,7 +2792,7 @@ function Nn(e, t) {
2789
2792
  e.value.get(i) !== r && (e.value = new Map(e.value).set(i, r));
2790
2793
  }
2791
2794
  function f(t, n, r, i) {
2792
- return jn(e, t, n, r, i);
2795
+ return Mn(e, t, n, r, i);
2793
2796
  }
2794
2797
  function p(e, n, r, i) {
2795
2798
  let a = f(e, n, r, i);
@@ -2822,7 +2825,7 @@ function Nn(e, t) {
2822
2825
  function b(e, t) {
2823
2826
  y(e, t, "masonry", null);
2824
2827
  }
2825
- return Mn(e, t.reelChange), O(() => {
2828
+ return Nn(e, t.reelChange), O(() => {
2826
2829
  let t = e.layout === "reel" || e.reelOrigin === "masonry" ? e.activeReelPostId : null, n = t === null ? 0 : e.mediaIndices.get(t) ?? 0;
2827
2830
  return {
2828
2831
  mediaIndex: n,
@@ -2847,16 +2850,16 @@ function Nn(e, t) {
2847
2850
  }
2848
2851
  //#endregion
2849
2852
  //#region src/core/reelEscapeStack.ts
2850
- var Pn = [];
2851
- function Fn(e) {
2852
- return Pn.push(e), () => {
2853
- let t = Pn.indexOf(e);
2854
- t >= 0 && Pn.splice(t, 1);
2853
+ var Fn = [];
2854
+ function In(e) {
2855
+ return Fn.push(e), () => {
2856
+ let t = Fn.indexOf(e);
2857
+ t >= 0 && Fn.splice(t, 1);
2855
2858
  };
2856
2859
  }
2857
- function In(e) {
2860
+ function Ln(e) {
2858
2861
  if (!e.isActive()) return !1;
2859
- let t = Pn.filter((e) => e.isActive()), n = e.element();
2862
+ let t = Fn.filter((e) => e.isActive()), n = e.element();
2860
2863
  return n !== null && t.some((t) => {
2861
2864
  if (t === e) return !1;
2862
2865
  let r = t.element();
@@ -2872,14 +2875,14 @@ function In(e) {
2872
2875
  }
2873
2876
  //#endregion
2874
2877
  //#region src/components/useReelKeyboard.ts
2875
- function Ln(e) {
2878
+ function Rn(e) {
2876
2879
  let t = {
2877
2880
  element: e.element,
2878
2881
  isActive: () => e.state.layout === "reel" || e.state.reelOrigin === "masonry"
2879
2882
  }, n = null;
2880
2883
  function r(n) {
2881
2884
  let r = t.isActive();
2882
- if (n.key === "Escape" && r && !In(t)) return;
2885
+ if (n.key === "Escape" && r && !Ln(t)) return;
2883
2886
  if (n.key === "Escape" && e.state.reelOrigin === "masonry") {
2884
2887
  n.preventDefault(), e.state.reelInfoSheetOverlay && e.state.reelInfoSheet.enabled && e.setReelInfoSheet(!1), e.closeMasonryReel();
2885
2888
  return;
@@ -2899,14 +2902,14 @@ function Ln(e) {
2899
2902
  a !== 0 && e.reelRenderer()?.changeActiveMedia?.(a) && n.preventDefault();
2900
2903
  }
2901
2904
  y(() => {
2902
- n = Fn(t), window.addEventListener("keydown", r);
2905
+ n = In(t), window.addEventListener("keydown", r);
2903
2906
  }), v(() => {
2904
2907
  window.removeEventListener("keydown", r), n?.(), n = null;
2905
2908
  });
2906
2909
  }
2907
2910
  //#endregion
2908
2911
  //#region src/components/VibeSurface.vue?vue&type=script&setup=true&lang.ts
2909
- var Rn = 35, zn = 420, Bn = /* @__PURE__ */ d({
2912
+ var zn = 35, Bn = 420, Vn = /* @__PURE__ */ d({
2910
2913
  __name: "VibeSurface",
2911
2914
  props: {
2912
2915
  canRetryEnd: { type: Boolean },
@@ -2935,7 +2938,7 @@ var Rn = 35, zn = 420, Bn = /* @__PURE__ */ d({
2935
2938
  "retryForward"
2936
2939
  ],
2937
2940
  setup(t, { expose: i, emit: c }) {
2938
- let l = t, d = c, f = w(null), p = w(null), h = w(null), g = w(null), _ = w(!1), y = w(/* @__PURE__ */ new Set()), x = w(/* @__PURE__ */ new Map()), S = w(/* @__PURE__ */ new Set()), C = w(/* @__PURE__ */ new Map()), T = r(() => Object.freeze([...l.state.items])), D = r(() => q(l.state, T.value)), { markMasonryFullyVisible: A, markMasonryVisible: j, markPreviewError: M, markPreviewReady: N, markReelError: P, markReelReady: F, originalStates: I, previewStates: L, reelStates: R, resetMediaLifecycle: z } = Nn(l.state, {
2941
+ let l = t, d = c, f = w(null), p = w(null), h = w(null), g = w(null), _ = w(!1), y = w(/* @__PURE__ */ new Set()), x = w(/* @__PURE__ */ new Map()), S = w(/* @__PURE__ */ new Set()), C = w(/* @__PURE__ */ new Map()), T = r(() => Object.freeze([...l.state.items])), D = r(() => J(l.state, T.value)), { markMasonryFullyVisible: A, markMasonryVisible: j, markPreviewError: M, markPreviewReady: N, markReelError: P, markReelReady: F, originalStates: I, previewStates: L, reelStates: R, resetMediaLifecycle: z } = Pn(l.state, {
2939
2942
  fullyVisible: (e) => d("mediaFullyVisible", e),
2940
2943
  ready: (e) => d("mediaReady", e),
2941
2944
  reelChange: (e) => d("reelMediaChange", e),
@@ -2944,7 +2947,7 @@ var Rn = 35, zn = 420, Bn = /* @__PURE__ */ d({
2944
2947
  function K() {
2945
2948
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
2946
2949
  }
2947
- function J() {
2950
+ function q() {
2948
2951
  V !== null && cancelAnimationFrame(V), V = requestAnimationFrame(() => {
2949
2952
  V = requestAnimationFrame(() => {
2950
2953
  V = null, y.value = /* @__PURE__ */ new Set();
@@ -2983,32 +2986,45 @@ var Rn = 35, zn = 420, Bn = /* @__PURE__ */ d({
2983
2986
  let t = g.value?.querySelectorAll(".masonry-feed [data-post-id]") ?? [];
2984
2987
  return Array.from(t).find((t) => t.dataset.postId === String(e)) ?? null;
2985
2988
  }
2986
- function ce(e, t) {
2989
+ function se(e, t) {
2987
2990
  if (l.state.layout !== "masonry" || l.state.reelOrigin !== null || K()) return 0;
2988
- let n = [...new Set(e)], r = n.filter(oe);
2989
- if (r.length === 0) return 0;
2990
- let i = new Map(C.value), a = t?.staggerMs ?? Rn;
2991
- return r.forEach((e, t) => {
2992
- i.set(e, t * a);
2993
- }), y.value = new Set([...y.value].filter((e) => !r.includes(e))), S.value = new Set([...S.value, ...n]), C.value = i, zn + (r.length - 1) * a;
2991
+ let n = [...new Set(e)], r = new Set(Array.from(g.value?.querySelectorAll(".masonry-feed [data-post-id]") ?? [], (e) => e.dataset.postId)), i = n.filter((e) => r.has(String(e)));
2992
+ if (i.length === 0) return 0;
2993
+ let a = new Map(C.value), o = t?.staggerMs ?? zn;
2994
+ return i.forEach((e, t) => {
2995
+ a.set(e, t * o);
2996
+ }), y.value = new Set([...y.value].filter((e) => !i.includes(e))), S.value = new Set([...S.value, ...n]), C.value = a, Bn + (i.length - 1) * o;
2997
+ }
2998
+ function ce() {
2999
+ S.value = /* @__PURE__ */ new Set(), C.value = /* @__PURE__ */ new Map();
2994
3000
  }
2995
- function X(e, t) {
3001
+ async function Z(e, t) {
3002
+ if (t.aborted || se(e, { staggerMs: 0 }) === 0 || (await m(), t.aborted)) return;
3003
+ let n = g.value?.querySelectorAll(".masonry-feed .media-card--leaving") ?? [], r = Array.from(n).flatMap((e) => (getComputedStyle(e).opacity, e.getAnimations?.().filter((e) => e.effect?.getTiming().iterations !== Infinity) ?? []));
3004
+ await new Promise((e) => {
3005
+ let n = () => {
3006
+ t.removeEventListener("abort", n), e();
3007
+ };
3008
+ t.addEventListener("abort", n, { once: !0 }), t.aborted ? n() : Promise.allSettled(r.map((e) => e.finished)).then(n);
3009
+ });
3010
+ }
3011
+ function le(e, t) {
2996
3012
  let n = oe(e), r = n?.querySelector(".media-card-activator") ?? n;
2997
3013
  r && (r.classList.toggle("media-card-focus-silent", !t), t || r.addEventListener("blur", () => {
2998
3014
  r.classList.remove("media-card-focus-silent");
2999
3015
  }, { once: !0 }), r?.focus({ preventScroll: !0 }));
3000
3016
  }
3001
- function Z() {
3017
+ function ue() {
3002
3018
  l.state.reelOrigin === "masonry" && (W ??= l.state.activeReelPostId, _.value = !0, d("closeReel"));
3003
3019
  }
3004
- function le() {
3020
+ function de() {
3005
3021
  let e = W, t = G;
3006
3022
  _.value = !1, W = null, G = !1, m(() => {
3007
- e !== null && X(e, t);
3023
+ e !== null && le(e, t);
3008
3024
  });
3009
3025
  }
3010
- return Ln({
3011
- closeMasonryReel: Z,
3026
+ return Rn({
3027
+ closeMasonryReel: ue,
3012
3028
  element: () => g.value,
3013
3029
  isReelLeaving: () => _.value,
3014
3030
  reelRenderer: () => p.value,
@@ -3025,25 +3041,27 @@ var Rn = 35, zn = 420, Bn = /* @__PURE__ */ d({
3025
3041
  let t = x.value.get(e);
3026
3042
  t !== void 0 && i.set(e, t);
3027
3043
  }), n.forEach((e, t) => {
3028
- i.set(e, t * Rn);
3029
- }), x.value = i, y.value = new Set([...y.value, ...n]), J();
3044
+ i.set(e, t * zn);
3045
+ }), x.value = i, y.value = new Set([...y.value, ...n]), q();
3030
3046
  }, { flush: "sync" }), v(() => {
3031
3047
  V !== null && cancelAnimationFrame(V);
3032
3048
  }), i({
3049
+ animateItemRemoval: Z,
3050
+ cancelItemRemoval: ce,
3033
3051
  changeActiveReelMedia: te,
3034
3052
  getAutoScrollElement: ie,
3035
3053
  loadIfNearBottom: ee,
3036
3054
  moveActiveReelPost: ne,
3037
3055
  navigateToReelItem: re,
3038
3056
  resetMediaLifecycle: z,
3039
- startItemRemoval: ce,
3057
+ startItemRemoval: se,
3040
3058
  transitionActiveReelMedia: (e) => p.value?.transitionActiveMedia?.(e) ?? Promise.resolve(!1),
3041
3059
  transitionActiveReelPost: (e) => p.value?.transitionActivePost?.(e) ?? Promise.resolve(!1)
3042
3060
  }), (r, i) => (b(), s("div", {
3043
3061
  ref_key: "surfaceElement",
3044
3062
  ref: g,
3045
3063
  class: "vibe-surface"
3046
- }, [t.state.layout === "reel" && (t.state.items.length > 0 || t.state.reelForward.status !== "idle") ? (b(), a(An, {
3064
+ }, [t.state.layout === "reel" && (t.state.items.length > 0 || t.state.reelForward.status !== "idle") ? (b(), a(jn, {
3047
3065
  key: 0,
3048
3066
  ref_key: "reelRenderer",
3049
3067
  ref: p,
@@ -3083,7 +3101,7 @@ var Rn = 35, zn = 420, Bn = /* @__PURE__ */ d({
3083
3101
  onRetryEnd: i[3] ||= (e) => d("retryEnd"),
3084
3102
  onRetryForward: i[4] ||= (e) => d("retryForward"),
3085
3103
  onReelAudioChange: i[5] ||= (e) => d("reelAudioChange", e)
3086
- }, null, 8, /* @__PURE__ */ "can-retry-end.has-next.card-footer.card-header.feed-footer.feed-footer-actions.forward-index.forward-item.media-card.infinite-scroll.is-loading-more.items.load-more-locked.media-source.media-indices.initial-post-id.info-sheet.info-sheet-enabled.info-sheet-overlay.next-page-error.preview-states.reel-auto-advance.reel-audio-state.reel-forward.state.total.onError.onReady".split("."))) : t.state.error || t.state.isLoading || t.state.items.length === 0 && t.state.reelForward.status === "idle" ? (b(), a(se, {
3104
+ }, null, 8, /* @__PURE__ */ "can-retry-end.has-next.card-footer.card-header.feed-footer.feed-footer-actions.forward-index.forward-item.media-card.infinite-scroll.is-loading-more.items.load-more-locked.media-source.media-indices.initial-post-id.info-sheet.info-sheet-enabled.info-sheet-overlay.next-page-error.preview-states.reel-auto-advance.reel-audio-state.reel-forward.state.total.onError.onReady".split("."))) : t.state.error || t.state.isLoading || t.state.items.length === 0 && t.state.reelForward.status === "idle" ? (b(), a(X, {
3087
3105
  key: 1,
3088
3106
  actions: t.feedFooterActions,
3089
3107
  "can-retry-end": t.canRetryEnd,
@@ -3096,7 +3114,7 @@ var Rn = 35, zn = 420, Bn = /* @__PURE__ */ d({
3096
3114
  "can-retry-end",
3097
3115
  "feed-footer",
3098
3116
  "state"
3099
- ])) : (b(), s(e, { key: 2 }, [u(mn, {
3117
+ ])) : (b(), s(e, { key: 2 }, [u(hn, {
3100
3118
  ref_key: "masonryRenderer",
3101
3119
  ref: f,
3102
3120
  "can-retry-end": t.canRetryEnd,
@@ -3131,7 +3149,7 @@ var Rn = 35, zn = 420, Bn = /* @__PURE__ */ d({
3131
3149
  onVisible: E(j)
3132
3150
  }, null, 8, /* @__PURE__ */ "can-retry-end.entering-post-ids.entry-delays.leaving-post-ids.removal-delays.card-footer.card-header.feed-footer.feed-footer-actions.media-card.masonry.has-next.infinite-scroll.is-loading-more.items.load-more-locked.media-indices.next-page-error.preview-states.suspended.state.total.onError.onFullyVisible.onReady.onVisible".split(".")), u(n, {
3133
3151
  name: "vibe-reel-viewer",
3134
- onAfterLeave: le
3152
+ onAfterLeave: de
3135
3153
  }, {
3136
3154
  default: k(() => [t.state.reelOrigin === "masonry" ? (b(), s("section", {
3137
3155
  key: 0,
@@ -3142,7 +3160,7 @@ var Rn = 35, zn = 420, Bn = /* @__PURE__ */ d({
3142
3160
  "aria-label": "Media viewer",
3143
3161
  "aria-modal": "true",
3144
3162
  tabindex: "-1"
3145
- }, [u(An, {
3163
+ }, [u(jn, {
3146
3164
  ref_key: "reelRenderer",
3147
3165
  ref: p,
3148
3166
  "can-retry-end": t.canRetryEnd,
@@ -3188,7 +3206,7 @@ var Rn = 35, zn = 420, Bn = /* @__PURE__ */ d({
3188
3206
  });
3189
3207
  //#endregion
3190
3208
  //#region src/core/page.ts
3191
- function Vn(e) {
3209
+ function Hn(e) {
3192
3210
  if (!e || typeof e != "object" || !Array.isArray(e.items)) throw TypeError("Vibe loadPage must resolve to a page with an items array.");
3193
3211
  if (e.current !== void 0 && e.current !== null && typeof e.current != "string" && typeof e.current != "number") throw TypeError("Vibe page current must be a string, number, null, or undefined.");
3194
3212
  if (e.next !== null && typeof e.next != "string" && typeof e.next != "number") throw TypeError("Vibe page next must be a string, number, or null.");
@@ -3199,22 +3217,22 @@ function $(e, t) {
3199
3217
  let n = new Set(e.map((e) => e.postId));
3200
3218
  return [...e, ...t.filter((e) => n.has(e.postId) ? !1 : (n.add(e.postId), !0))];
3201
3219
  }
3202
- function Hn(e) {
3220
+ function Un(e) {
3203
3221
  return `${typeof e}:${String(e)}`;
3204
3222
  }
3205
- function Un(e) {
3206
- return e.mediaId === void 0 ? `source:${e.src}\u0000${e.preview?.src ?? ""}` : `id:${Hn(e.mediaId)}`;
3223
+ function Wn(e) {
3224
+ return e.mediaId === void 0 ? `source:${e.src}\u0000${e.preview?.src ?? ""}` : `id:${Un(e.mediaId)}`;
3207
3225
  }
3208
- function Wn(e, t) {
3209
- let n = [...e], r = new Map(e.map((e, t) => [Hn(e.postId), t]));
3226
+ function Gn(e, t) {
3227
+ let n = [...e], r = new Map(e.map((e, t) => [Un(e.postId), t]));
3210
3228
  return t.forEach((e) => {
3211
- let t = Hn(e.postId), i = r.get(t);
3229
+ let t = Un(e.postId), i = r.get(t);
3212
3230
  if (i === void 0) {
3213
3231
  r.set(t, n.length), n.push(e);
3214
3232
  return;
3215
3233
  }
3216
- let a = n[i], o = new Set([a, ...a.items].map(Un)), s = [e, ...e.items].filter((e) => {
3217
- let t = Un(e);
3234
+ let a = n[i], o = new Set([a, ...a.items].map(Wn)), s = [e, ...e.items].filter((e) => {
3235
+ let t = Wn(e);
3218
3236
  return o.has(t) ? !1 : (o.add(t), !0);
3219
3237
  });
3220
3238
  s.length > 0 && (n[i] = {
@@ -3223,14 +3241,14 @@ function Wn(e, t) {
3223
3241
  });
3224
3242
  }), n;
3225
3243
  }
3226
- function Gn(e) {
3244
+ function Kn(e) {
3227
3245
  return Object.prototype.hasOwnProperty.call(e, "current") ? e.current ?? null : e.next;
3228
3246
  }
3229
3247
  //#endregion
3230
3248
  //#region src/core/appendPage.ts
3231
- function Kn(e, t, n, r) {
3232
- let i = Vn(e), a = n.filterItems(i.items), o = Gn(i);
3233
- t.items = Wn(t.items, a), t.next = i.next, i.total !== void 0 && (t.total = i.total), r(o), n.recordPages([{
3249
+ function qn(e, t, n, r) {
3250
+ let i = Hn(e), a = n.filterItems(i.items), o = Kn(i);
3251
+ t.items = Gn(t.items, a), t.next = i.next, i.total !== void 0 && (t.total = i.total), r(o), n.recordPages([{
3234
3252
  contributionIds: a.map(({ postId: e }) => e),
3235
3253
  cursor: o,
3236
3254
  next: i.next,
@@ -3239,32 +3257,32 @@ function Kn(e, t, n, r) {
3239
3257
  }
3240
3258
  //#endregion
3241
3259
  //#region src/core/requestDelay.ts
3242
- var qn = 2e3, Jn = 1e4, Yn = 250, Xn = {
3260
+ var Jn = 2e3, Yn = 1e4, Xn = 250, Zn = {
3243
3261
  delayRemainingMs: null,
3244
3262
  nextRequestAt: null
3245
3263
  };
3246
- function Zn(e, t) {
3264
+ function Qn(e, t) {
3247
3265
  return e === void 0 ? t : Math.floor(e);
3248
3266
  }
3249
- function Qn(e, t) {
3267
+ function $n(e, t) {
3250
3268
  for (let [n, r] of [["delayStepMs", e.delayStepMs], ["delayMaxMs", e.delayMaxMs]]) if (r !== void 0 && (!Number.isFinite(r) || r < 0)) throw TypeError(`Vibe ${t} ${n} must be a non-negative number.`);
3251
3269
  }
3252
- function $n(e, t = {}) {
3253
- let n = Zn(t.delayStepMs, qn), r = Zn(t.delayMaxMs, Jn);
3270
+ function er(e, t = {}) {
3271
+ let n = Qn(t.delayStepMs, Jn), r = Qn(t.delayMaxMs, Yn);
3254
3272
  return Math.min(Math.max(0, e) * n, r);
3255
3273
  }
3256
- function er(e) {
3257
- if (e == null || !Number.isFinite(e)) return { ...Xn };
3274
+ function tr(e) {
3275
+ if (e == null || !Number.isFinite(e)) return { ...Zn };
3258
3276
  let t = Math.max(0, Math.floor(e - Date.now()));
3259
3277
  return t > 0 ? {
3260
3278
  delayRemainingMs: t,
3261
3279
  nextRequestAt: e
3262
- } : { ...Xn };
3280
+ } : { ...Zn };
3263
3281
  }
3264
- async function tr({ delayMs: e, onChange: t, signal: n }) {
3282
+ async function nr({ delayMs: e, onChange: t, signal: n }) {
3265
3283
  if (n.aborted) throw new DOMException("Aborted", "AbortError");
3266
3284
  if (e <= 0) {
3267
- t({ ...Xn });
3285
+ t({ ...Zn });
3268
3286
  return;
3269
3287
  }
3270
3288
  let r = Date.now() + e;
@@ -3272,9 +3290,9 @@ async function tr({ delayMs: e, onChange: t, signal: n }) {
3272
3290
  delayRemainingMs: e,
3273
3291
  nextRequestAt: r
3274
3292
  }), await new Promise((i, a) => {
3275
- let o = !1, s = setInterval(f, Yn), c = setTimeout(() => u(), e);
3293
+ let o = !1, s = setInterval(f, Xn), c = setTimeout(() => u(), e);
3276
3294
  function l() {
3277
- clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Xn });
3295
+ clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Zn });
3278
3296
  }
3279
3297
  function u(e) {
3280
3298
  o || (o = !0, l(), e ? a(e) : i());
@@ -3283,42 +3301,42 @@ async function tr({ delayMs: e, onChange: t, signal: n }) {
3283
3301
  u(new DOMException("Aborted", "AbortError"));
3284
3302
  }
3285
3303
  function f() {
3286
- let e = er(r);
3304
+ let e = tr(r);
3287
3305
  t(e), e.delayRemainingMs === null && u();
3288
3306
  }
3289
3307
  n.addEventListener("abort", d, { once: !0 });
3290
3308
  });
3291
3309
  }
3292
- var nr = class {
3310
+ var rr = class {
3293
3311
  interval = null;
3294
3312
  constructor(e) {
3295
3313
  this.onChange = e;
3296
3314
  }
3297
3315
  clear() {
3298
- this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Xn });
3316
+ this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Zn });
3299
3317
  }
3300
3318
  sync(e) {
3301
3319
  this.clear();
3302
- let t = er(e);
3320
+ let t = tr(e);
3303
3321
  this.onChange(t), t.delayRemainingMs !== null && (this.interval = setInterval(() => {
3304
- let t = er(e);
3322
+ let t = tr(e);
3305
3323
  this.onChange(t), t.delayRemainingMs === null && this.clear();
3306
- }, Yn));
3324
+ }, Xn));
3307
3325
  }
3308
3326
  };
3309
- function rr(e, t = !0) {
3327
+ function ir(e, t = !0) {
3310
3328
  return e.maxAdditionalPages === "unlimited" ? Infinity : (e.maxAdditionalPages ?? 10) + (t ? 1 : 0);
3311
3329
  }
3312
- function ir(e) {
3330
+ function ar(e) {
3313
3331
  return `${typeof e}:${String(e)}`;
3314
3332
  }
3315
- function ar(e, t) {
3333
+ function or(e, t) {
3316
3334
  if (!Number.isInteger(e) || e <= 0) throw TypeError(`Vibe ${t} must be a positive integer.`);
3317
3335
  }
3318
- function or(e) {
3336
+ function sr(e) {
3319
3337
  if (!e) return;
3320
- if (ar(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
3321
- Qn(e, "frontend autofill");
3338
+ if (or(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
3339
+ $n(e, "frontend autofill");
3322
3340
  let t = e.maxAdditionalPages;
3323
3341
  if (t !== void 0 && t !== "unlimited" && (!Number.isInteger(t) || t < 0)) throw TypeError("Vibe autofill maxAdditionalPages must be a non-negative integer or \"unlimited\".");
3324
3342
  return;
@@ -3330,7 +3348,7 @@ function or(e) {
3330
3348
  if (t.pageSize !== e.pageSize) throw TypeError("Vibe backend autofill initialSession pageSize must match autofill pageSize.");
3331
3349
  }
3332
3350
  }
3333
- function sr(e, t, n = !0) {
3351
+ function cr(e, t, n = !0) {
3334
3352
  if (!e) return {
3335
3353
  cycleId: null,
3336
3354
  delayRemainingMs: null,
@@ -3347,7 +3365,7 @@ function sr(e, t, n = !0) {
3347
3365
  status: "idle",
3348
3366
  strategy: null
3349
3367
  };
3350
- let r = e.strategy === "backend" ? t ?? (n ? e.initialSession : void 0) : void 0, i = r?.received ?? 0, a = er(r?.nextRequestAt);
3368
+ let r = e.strategy === "backend" ? t ?? (n ? e.initialSession : void 0) : void 0, i = r?.received ?? 0, a = tr(r?.nextRequestAt);
3351
3369
  return {
3352
3370
  cycleId: r?.cycleId ?? null,
3353
3371
  ...a,
@@ -3364,7 +3382,7 @@ function sr(e, t, n = !0) {
3364
3382
  strategy: e.strategy
3365
3383
  };
3366
3384
  }
3367
- function cr(e) {
3385
+ function lr(e) {
3368
3386
  return [
3369
3387
  "cancelling",
3370
3388
  "filling",
@@ -3372,9 +3390,9 @@ function cr(e) {
3372
3390
  "waiting"
3373
3391
  ].includes(e.status);
3374
3392
  }
3375
- async function lr(e, t, n) {
3393
+ async function ur(e, t, n) {
3376
3394
  let r = t.autofill;
3377
- if (!cr(r) || !r.cycleId) return;
3395
+ if (!lr(r) || !r.cycleId) return;
3378
3396
  let i = {
3379
3397
  cycleId: r.cycleId,
3380
3398
  feedKey: r.feedKey ?? "",
@@ -3387,16 +3405,16 @@ async function lr(e, t, n) {
3387
3405
  throw r.error = e, r.status = "error", e;
3388
3406
  }
3389
3407
  }
3390
- function ur(e, t, n) {
3408
+ function dr(e, t, n) {
3391
3409
  return e?.strategy === "backend" && t.feedKey === e.feedKey && t.sessionId === n.sessionId;
3392
3410
  }
3393
- async function dr({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onCollection: i, onDelayChange: a, onProgress: o, options: s, receivedOffset: c = 0, requestOffset: l = 0, shouldPause: u = () => !1, signal: d }) {
3394
- let f = [], p = [...e], m = /* @__PURE__ */ new Set(), h = r ?? rr(s), g = t, _ = t, v = t, y = 0, b = [], x;
3411
+ async function fr({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onCollection: i, onDelayChange: a, onProgress: o, options: s, receivedOffset: c = 0, requestOffset: l = 0, shouldPause: u = () => !1, signal: d }) {
3412
+ let f = [], p = [...e], m = /* @__PURE__ */ new Set(), h = r ?? ir(s), g = t, _ = t, v = t, y = 0, b = [], x;
3395
3413
  for (; y < h;) {
3396
- let e = ir(g);
3414
+ let e = ar(g);
3397
3415
  if (m.has(e)) throw Error("Vibe autofill received a repeated cursor.");
3398
- if (m.add(e), await tr({
3399
- delayMs: $n(l + y, s),
3416
+ if (m.add(e), await nr({
3417
+ delayMs: er(l + y, s),
3400
3418
  onChange: a,
3401
3419
  signal: d
3402
3420
  }), y > 0 && u()) return {
@@ -3410,7 +3428,7 @@ async function dr({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
3410
3428
  status: "paused",
3411
3429
  total: x
3412
3430
  };
3413
- let t = Vn(await n({
3431
+ let t = Hn(await n({
3414
3432
  cursor: g,
3415
3433
  signal: d
3416
3434
  }));
@@ -3467,12 +3485,12 @@ async function dr({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
3467
3485
  }
3468
3486
  //#endregion
3469
3487
  //#region src/core/autofillController.ts
3470
- var fr = class {
3488
+ var pr = class {
3471
3489
  collection = null;
3472
3490
  cycle = 0;
3473
3491
  delayCountdown;
3474
3492
  constructor(e) {
3475
- this.context = e, this.delayCountdown = new nr((t) => Object.assign(e.state.autofill, t)), this.syncCountdown();
3493
+ this.context = e, this.delayCountdown = new rr((t) => Object.assign(e.state.autofill, t)), this.syncCountdown();
3476
3494
  }
3477
3495
  beginCycle() {
3478
3496
  let { options: e, state: t } = this.context;
@@ -3480,14 +3498,14 @@ var fr = class {
3480
3498
  this.clear();
3481
3499
  let n = `vibe-autofill-${Date.now().toString(36)}-${++this.cycle}`;
3482
3500
  return t.autofill = {
3483
- ...sr(e, void 0, !1),
3501
+ ...cr(e, void 0, !1),
3484
3502
  cycleId: n,
3485
3503
  status: "filling"
3486
3504
  }, n;
3487
3505
  }
3488
3506
  async cancel() {
3489
3507
  let { cancelRequest: e, options: t, state: n } = this.context;
3490
- await lr(t, n, e), this.commitCollection();
3508
+ await ur(t, n, e), this.commitCollection();
3491
3509
  }
3492
3510
  captureCollection(e, t) {
3493
3511
  t && (this.collection = e);
@@ -3515,30 +3533,30 @@ var fr = class {
3515
3533
  requests: r.requests
3516
3534
  }), !0) : !1;
3517
3535
  }
3518
- }, pr = 100;
3519
- function mr(e, t) {
3536
+ }, mr = 100;
3537
+ function hr(e, t) {
3520
3538
  if (!Number.isFinite(t) || t <= 0) throw TypeError(`Vibe ${e} must be a positive number.`);
3521
3539
  }
3522
- function hr(e, t, n) {
3540
+ function gr(e, t, n) {
3523
3541
  return Math.min(n, Math.max(t, e));
3524
3542
  }
3525
- function gr(e) {
3543
+ function _r(e) {
3526
3544
  if (!e) return;
3527
3545
  let t = e.minSpeedPxPerSecond ?? 20, n = e.maxSpeedPxPerSecond ?? 240;
3528
- if (mr("autoScroll.minSpeedPxPerSecond", t), mr("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
3529
- e.speedPxPerSecond !== void 0 && mr("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
3546
+ if (hr("autoScroll.minSpeedPxPerSecond", t), hr("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
3547
+ e.speedPxPerSecond !== void 0 && hr("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
3530
3548
  }
3531
- function _r(e) {
3549
+ function vr(e) {
3532
3550
  let t = e?.minSpeedPxPerSecond ?? 20, n = e?.maxSpeedPxPerSecond ?? 240;
3533
3551
  return {
3534
3552
  enabled: e?.enabled ?? !1,
3535
3553
  maxSpeedPxPerSecond: n,
3536
3554
  minSpeedPxPerSecond: t,
3537
3555
  paused: !1,
3538
- speedPxPerSecond: hr(e?.speedPxPerSecond ?? 80, t, n)
3556
+ speedPxPerSecond: gr(e?.speedPxPerSecond ?? 80, t, n)
3539
3557
  };
3540
3558
  }
3541
- var vr = class {
3559
+ var yr = class {
3542
3560
  frame = null;
3543
3561
  lastTimestamp = null;
3544
3562
  mounted = !1;
@@ -3558,9 +3576,9 @@ var vr = class {
3558
3576
  this.options.state.enabled && (this.options.state.paused = e, this.lastTimestamp = null, e ? this.cancelFrame() : this.schedule());
3559
3577
  }
3560
3578
  setSpeed(e) {
3561
- mr("auto-scroll speed", e);
3579
+ hr("auto-scroll speed", e);
3562
3580
  let t = this.options.state;
3563
- t.speedPxPerSecond = hr(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
3581
+ t.speedPxPerSecond = gr(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
3564
3582
  }
3565
3583
  tick = (e) => {
3566
3584
  this.frame = null;
@@ -3572,7 +3590,7 @@ var vr = class {
3572
3590
  return;
3573
3591
  }
3574
3592
  if (this.lastTimestamp !== null) {
3575
- let r = Math.min(pr, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
3593
+ let r = Math.min(mr, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
3576
3594
  n.scrollTop = Math.min(i, n.scrollTop + t.speedPxPerSecond * r / 1e3);
3577
3595
  }
3578
3596
  this.lastTimestamp = e, this.schedule();
@@ -3586,13 +3604,13 @@ var vr = class {
3586
3604
  };
3587
3605
  //#endregion
3588
3606
  //#region src/core/backendAutofill.ts
3589
- async function yr(e, t, n, r) {
3607
+ async function br(e, t, n, r) {
3590
3608
  let i = await e.onUnderfilled(n);
3591
3609
  if (!r()) return;
3592
3610
  if (!i.sessionId.trim()) throw TypeError("Vibe backend autofill requires a sessionId.");
3593
3611
  let a = Math.max(n.received, i.received ?? n.received);
3594
3612
  Object.assign(t.autofill, {
3595
- ...er(i.nextRequestAt),
3613
+ ...tr(i.nextRequestAt),
3596
3614
  missing: Math.max(0, e.pageSize - a),
3597
3615
  received: a,
3598
3616
  sequence: i.sequence ?? 0,
@@ -3600,19 +3618,19 @@ async function yr(e, t, n, r) {
3600
3618
  status: "waiting"
3601
3619
  });
3602
3620
  }
3603
- function br(e, t) {
3621
+ function xr(e, t) {
3604
3622
  ["complete", "exhausted"].includes(t.status) && t.items && (e.items = $(e.items, t.items)), t.next !== void 0 && (e.next = t.next), t.total !== void 0 && (e.total = t.total);
3605
3623
  }
3606
- function xr(e, t, n) {
3624
+ function Sr(e, t, n) {
3607
3625
  let r = t.autofill;
3608
- return !ur(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (br(t, n), Object.assign(r, er(n.status === "waiting" ? n.nextRequestAt : null)), r.error = n.error ?? null, r.missing = Math.max(0, (r.pageSize ?? 0) - n.received), r.received = n.received, n.requests !== void 0 && (r.requests = n.requests), r.sequence = n.sequence, r.status = n.status, !0);
3626
+ return !dr(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (xr(t, n), Object.assign(r, tr(n.status === "waiting" ? n.nextRequestAt : null)), r.error = n.error ?? null, r.missing = Math.max(0, (r.pageSize ?? 0) - n.received), r.received = n.received, n.requests !== void 0 && (r.requests = n.requests), r.sequence = n.sequence, r.status = n.status, !0);
3609
3627
  }
3610
- function Sr(e, t, n) {
3611
- return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = sr(e, n), br(t, n), !0);
3628
+ function Cr(e, t, n) {
3629
+ return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = cr(e, n), xr(t, n), !0);
3612
3630
  }
3613
3631
  //#endregion
3614
3632
  //#region src/core/backlogRestore.ts
3615
- async function Cr(e, t, n) {
3633
+ async function wr(e, t, n) {
3616
3634
  if (!e) return;
3617
3635
  let r = new AbortController();
3618
3636
  n(r);
@@ -3627,7 +3645,7 @@ async function Cr(e, t, n) {
3627
3645
  }
3628
3646
  //#endregion
3629
3647
  //#region src/core/initialAutofill.ts
3630
- async function wr({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r, onPages: i, options: a, signal: o, state: s }) {
3648
+ async function Tr({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r, onPages: i, options: a, signal: o, state: s }) {
3631
3649
  let c = a.autofill;
3632
3650
  if (!c) return;
3633
3651
  let l = s.items.length;
@@ -3640,7 +3658,7 @@ async function wr({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
3640
3658
  return;
3641
3659
  }
3642
3660
  if (c.strategy === "backend") {
3643
- await yr(c, s, {
3661
+ await br(c, s, {
3644
3662
  cycleId: e,
3645
3663
  feedKey: c.feedKey,
3646
3664
  items: [...s.items],
@@ -3657,11 +3675,11 @@ async function wr({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
3657
3675
  s.autofill.status = "exhausted";
3658
3676
  return;
3659
3677
  }
3660
- let u = await dr({
3678
+ let u = await fr({
3661
3679
  existingItems: s.items,
3662
3680
  initialCursor: s.next,
3663
3681
  loadPage: a.loadPage,
3664
- maximumRequests: rr(c, !1),
3682
+ maximumRequests: ir(c, !1),
3665
3683
  onCollection: n,
3666
3684
  onDelayChange: (e) => {
3667
3685
  t() && Object.assign(s.autofill, e);
@@ -3684,13 +3702,13 @@ async function wr({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
3684
3702
  }
3685
3703
  //#endregion
3686
3704
  //#region src/core/fill.ts
3687
- function Tr(e) {
3705
+ function Er(e) {
3688
3706
  return "items" in e ? { items: e.items } : "pages" in e ? { pages: e.pages } : { until: "end" };
3689
3707
  }
3690
- function Er(e) {
3708
+ function Dr(e) {
3691
3709
  return `${typeof e}:${String(e)}`;
3692
3710
  }
3693
- function Dr(e) {
3711
+ function Or(e) {
3694
3712
  if (!e || typeof e != "object") throw TypeError("Vibe fill target must be an object.");
3695
3713
  if ("pages" in e) {
3696
3714
  if (!Number.isInteger(e.pages) || e.pages <= 0) throw TypeError("Vibe fill pages must be a positive integer.");
@@ -3703,21 +3721,21 @@ function Dr(e) {
3703
3721
  if ("until" in e && e.until === "end") return { until: "end" };
3704
3722
  throw TypeError("Vibe fill target must be { items }, { pages }, or { until: 'end' }.");
3705
3723
  }
3706
- function Or(e) {
3724
+ function kr(e) {
3707
3725
  if (!e) return;
3708
3726
  if (e.strategy === "frontend") {
3709
- Qn(e, "frontend fill");
3727
+ $n(e, "frontend fill");
3710
3728
  return;
3711
3729
  }
3712
3730
  if (!e.feedKey.trim()) throw TypeError("Vibe backend fill requires a feedKey.");
3713
3731
  let t = e.initialSession;
3714
3732
  if (t) {
3715
3733
  if (t.feedKey !== e.feedKey) throw TypeError("Vibe backend fill initialSession feedKey must match fill feedKey.");
3716
- Dr(t.target);
3734
+ Or(t.target);
3717
3735
  }
3718
3736
  }
3719
- function kr(e, t, n = !0) {
3720
- let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = er(i?.nextRequestAt);
3737
+ function Ar(e, t, n = !0) {
3738
+ let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = tr(i?.nextRequestAt);
3721
3739
  return {
3722
3740
  completedPages: i?.completedPages ?? 0,
3723
3741
  cycleId: i?.cycleId ?? null,
@@ -3730,10 +3748,10 @@ function kr(e, t, n = !0) {
3730
3748
  sessionId: i?.sessionId ?? null,
3731
3749
  status: i?.status ?? "idle",
3732
3750
  strategy: e?.strategy ?? null,
3733
- target: i ? Tr(i.target) : null
3751
+ target: i ? Er(i.target) : null
3734
3752
  };
3735
3753
  }
3736
- function Ar(e) {
3754
+ function jr(e) {
3737
3755
  return [
3738
3756
  "cancelling",
3739
3757
  "filling",
@@ -3741,7 +3759,7 @@ function Ar(e) {
3741
3759
  "waiting"
3742
3760
  ].includes(e.status);
3743
3761
  }
3744
- async function jr({ existingItems: e, initialCursor: t, loadPage: n, onCollection: r = () => void 0, onDelayChange: i, onProgress: a, options: o, shouldPause: s = () => !1, signal: c, target: l }) {
3762
+ async function Mr({ existingItems: e, initialCursor: t, loadPage: n, onCollection: r = () => void 0, onDelayChange: i, onProgress: a, options: o, shouldPause: s = () => !1, signal: c, target: l }) {
3745
3763
  let u = [], d = [], f = [...e], p = /* @__PURE__ */ new Set(), m = 0, h = t, g = t, _ = t, v = 0, y;
3746
3764
  if ("items" in l && f.length >= l.items) return {
3747
3765
  completedPages: m,
@@ -3753,10 +3771,10 @@ async function jr({ existingItems: e, initialCursor: t, loadPage: n, onCollectio
3753
3771
  status: "complete"
3754
3772
  };
3755
3773
  for (; _ !== null;) {
3756
- let e = Er(h);
3774
+ let e = Dr(h);
3757
3775
  if (p.has(e)) throw Error("Vibe fill received a repeated cursor.");
3758
- if (p.add(e), await tr({
3759
- delayMs: $n(m, o),
3776
+ if (p.add(e), await nr({
3777
+ delayMs: er(m, o),
3760
3778
  onChange: i,
3761
3779
  signal: c
3762
3780
  }), m > 0 && s()) return {
@@ -3769,7 +3787,7 @@ async function jr({ existingItems: e, initialCursor: t, loadPage: n, onCollectio
3769
3787
  status: "paused",
3770
3788
  total: y
3771
3789
  };
3772
- let t = Vn(await n({
3790
+ let t = Hn(await n({
3773
3791
  cursor: h,
3774
3792
  signal: c
3775
3793
  }));
@@ -3837,12 +3855,12 @@ async function jr({ existingItems: e, initialCursor: t, loadPage: n, onCollectio
3837
3855
  }
3838
3856
  //#endregion
3839
3857
  //#region src/core/backendFill.ts
3840
- async function Mr(e, t, n, r) {
3858
+ async function Nr(e, t, n, r) {
3841
3859
  let i = await e.onStart(n);
3842
3860
  if (r()) {
3843
3861
  if (!i.sessionId.trim()) throw TypeError("Vibe backend fill requires a sessionId.");
3844
3862
  Object.assign(t.fill, {
3845
- ...er(i.nextRequestAt),
3863
+ ...tr(i.nextRequestAt),
3846
3864
  completedPages: i.completedPages ?? 0,
3847
3865
  received: i.received ?? 0,
3848
3866
  sequence: i.sequence ?? 0,
@@ -3851,23 +3869,23 @@ async function Mr(e, t, n, r) {
3851
3869
  });
3852
3870
  }
3853
3871
  }
3854
- function Nr(e, t, n) {
3872
+ function Pr(e, t, n) {
3855
3873
  return e?.strategy === "backend" && n.feedKey === e.feedKey && n.sessionId === t.fill.sessionId;
3856
3874
  }
3857
- function Pr(e) {
3875
+ function Fr(e) {
3858
3876
  return Number.isInteger(e.completedPages) && e.completedPages >= 0 && Number.isInteger(e.received) && e.received >= 0 && Number.isInteger(e.sequence) && e.sequence >= 0;
3859
3877
  }
3860
- function Fr(e, t) {
3878
+ function Ir(e, t) {
3861
3879
  if (!["complete", "exhausted"].includes(t.status)) return !0;
3862
3880
  let n = e.fill.target;
3863
3881
  return !n || !Array.isArray(t.items) || t.next === void 0 || t.lastCursor === void 0 ? !1 : t.status === "exhausted" ? "pages" in n && t.completedPages < n.pages && t.next === null : "pages" in n ? t.completedPages === n.pages : t.next === null;
3864
3882
  }
3865
- function Ir(e, t, n) {
3883
+ function Lr(e, t, n) {
3866
3884
  t.total !== void 0 && (e.total = t.total), ["complete", "exhausted"].includes(t.status) && (e.items = $(e.items, t.items ?? []), e.next = t.next ?? null, n(t.lastCursor ?? null));
3867
3885
  }
3868
- function Lr(e, t, n, r) {
3869
- return !Nr(e, t, n) || !Pr(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !Fr(t, n) ? !1 : (Ir(t, n, r), Object.assign(t.fill, {
3870
- ...er(n.status === "waiting" ? n.nextRequestAt : null),
3886
+ function Rr(e, t, n, r) {
3887
+ return !Pr(e, t, n) || !Fr(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !Ir(t, n) ? !1 : (Lr(t, n, r), Object.assign(t.fill, {
3888
+ ...tr(n.status === "waiting" ? n.nextRequestAt : null),
3871
3889
  completedPages: n.completedPages,
3872
3890
  error: n.error ?? null,
3873
3891
  received: n.received,
@@ -3875,45 +3893,45 @@ function Lr(e, t, n, r) {
3875
3893
  status: n.status
3876
3894
  }), !0);
3877
3895
  }
3878
- function Rr(e, t, n, r) {
3896
+ function zr(e, t, n, r) {
3879
3897
  if (e?.strategy !== "backend" || n.feedKey !== e.feedKey) return !1;
3880
3898
  let i = t.fill;
3881
- return t.fill = kr(e, n), !Pr(n) || !Fr(t, n) ? (t.fill = i, !1) : (Ir(t, n, r), !0);
3899
+ return t.fill = Ar(e, n), !Fr(n) || !Ir(t, n) ? (t.fill = i, !1) : (Lr(t, n, r), !0);
3882
3900
  }
3883
3901
  //#endregion
3884
3902
  //#region src/core/fillController.ts
3885
- var zr = class {
3903
+ var Br = class {
3886
3904
  abortController = null;
3887
3905
  cycle = 0;
3888
3906
  delayCountdown;
3889
3907
  requestVersion = 0;
3890
3908
  collection = null;
3891
3909
  constructor(e) {
3892
- this.options = e, this.delayCountdown = new nr((e) => {
3910
+ this.options = e, this.delayCountdown = new rr((e) => {
3893
3911
  Object.assign(this.options.state.fill, e);
3894
3912
  }), this.syncBackendCountdown();
3895
3913
  }
3896
3914
  isActive() {
3897
- return Ar(this.options.state.fill);
3915
+ return jr(this.options.state.fill);
3898
3916
  }
3899
3917
  applyUpdate(e) {
3900
- let t = Lr(this.options.fill, this.options.state, e, this.options.onLastCursor);
3918
+ let t = Rr(this.options.fill, this.options.state, e, this.options.onLastCursor);
3901
3919
  return t && this.syncBackendCountdown(), t;
3902
3920
  }
3903
3921
  restoreSession(e) {
3904
- let t = Rr(this.options.fill, this.options.state, e, this.options.onLastCursor);
3922
+ let t = zr(this.options.fill, this.options.state, e, this.options.onLastCursor);
3905
3923
  return t && this.syncBackendCountdown(), t;
3906
3924
  }
3907
3925
  async start(e, t = {}) {
3908
3926
  let n = this.options.fill;
3909
3927
  if (!n) throw Error("Vibe fill is not configured.");
3910
3928
  if (this.isActive()) throw Error("Vibe fill is already active.");
3911
- let r = Dr(e), i = Dr(t.target ?? r), a = t.progressOffset ?? {
3929
+ let r = Or(e), i = Or(t.target ?? r), a = t.progressOffset ?? {
3912
3930
  completedPages: 0,
3913
3931
  received: 0
3914
3932
  }, o = t.cycleId ?? `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
3915
3933
  if (this.options.state.fill = {
3916
- ...kr(n, void 0, !1),
3934
+ ...Ar(n, void 0, !1),
3917
3935
  completedPages: a.completedPages,
3918
3936
  cycleId: o,
3919
3937
  received: a.received,
@@ -3926,7 +3944,7 @@ var zr = class {
3926
3944
  let s = ++this.requestVersion, c = new AbortController();
3927
3945
  this.abortController = c;
3928
3946
  try {
3929
- n.strategy === "frontend" ? await this.startFrontend(n, r, c, s, t.prepareFrontend !== !1, a) : (await Mr(n, this.options.state, {
3947
+ n.strategy === "frontend" ? await this.startFrontend(n, r, c, s, t.prepareFrontend !== !1, a) : (await Nr(n, this.options.state, {
3930
3948
  cycleId: o,
3931
3949
  feedKey: n.feedKey,
3932
3950
  items: [...this.options.state.items],
@@ -3944,7 +3962,7 @@ var zr = class {
3944
3962
  }
3945
3963
  async cancel() {
3946
3964
  let { fill: e, state: t } = this.options;
3947
- if (!Ar(t.fill) || !t.fill.cycleId) return;
3965
+ if (!jr(t.fill) || !t.fill.cycleId) return;
3948
3966
  let n = {
3949
3967
  cycleId: t.fill.cycleId,
3950
3968
  feedKey: t.fill.feedKey ?? "",
@@ -3988,7 +4006,7 @@ var zr = class {
3988
4006
  });
3989
4007
  }
3990
4008
  reset() {
3991
- this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = kr(this.options.fill, void 0, !1), this.collection = null;
4009
+ this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = Ar(this.options.fill, void 0, !1), this.collection = null;
3992
4010
  }
3993
4011
  destroy() {
3994
4012
  this.abortLocalRequest(), this.delayCountdown.clear();
@@ -4023,7 +4041,7 @@ var zr = class {
4023
4041
  s.fill.status = "until" in t ? "complete" : "exhausted";
4024
4042
  return;
4025
4043
  }
4026
- let c = await jr({
4044
+ let c = await Mr({
4027
4045
  existingItems: s.items,
4028
4046
  initialCursor: s.next,
4029
4047
  loadPage: o,
@@ -4071,7 +4089,7 @@ var zr = class {
4071
4089
  };
4072
4090
  //#endregion
4073
4091
  //#region src/core/fillReconciliation.ts
4074
- async function Br({ controller: e, isCurrent: t, loadPage: n, onDelayChange: r, pauseWhenManual: i = !1, setLastCursor: a, signal: o, state: s }) {
4092
+ async function Vr({ controller: e, isCurrent: t, loadPage: n, onDelayChange: r, pauseWhenManual: i = !1, setLastCursor: a, signal: o, state: s }) {
4075
4093
  if (!e.needsReconciliation(s.items)) return "skipped";
4076
4094
  let c = await e.reconcile({
4077
4095
  existingItems: s.items,
@@ -4084,7 +4102,7 @@ async function Br({ controller: e, isCurrent: t, loadPage: n, onDelayChange: r,
4084
4102
  }
4085
4103
  //#endregion
4086
4104
  //#region src/core/feedFooter.ts
4087
- function Vr(e) {
4105
+ function Hr(e) {
4088
4106
  return {
4089
4107
  cancelAutofill: () => e.cancelAutofill(),
4090
4108
  loadMore: () => e.loadNext(),
@@ -4096,46 +4114,46 @@ function Vr(e) {
4096
4114
  retryFill: () => e.retryFill()
4097
4115
  };
4098
4116
  }
4099
- function Hr(e) {
4100
- if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
4101
- }
4102
4117
  function Ur(e) {
4103
- e?.intervalMs !== void 0 && Hr(e.intervalMs);
4118
+ if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
4104
4119
  }
4105
4120
  function Wr(e) {
4121
+ e?.intervalMs !== void 0 && Ur(e.intervalMs);
4122
+ }
4123
+ function Gr(e) {
4106
4124
  return {
4107
4125
  enabled: e?.enabled ?? !1,
4108
4126
  includePostItems: e?.includePostItems ?? !1,
4109
4127
  intervalMs: e?.intervalMs ?? 5e3
4110
4128
  };
4111
4129
  }
4112
- function Gr(e, t) {
4130
+ function Kr(e, t) {
4113
4131
  if (typeof t == "boolean") {
4114
4132
  e.enabled = t;
4115
4133
  return;
4116
4134
  }
4117
- Ur(t), t.enabled !== void 0 && (e.enabled = t.enabled), t.includePostItems !== void 0 && (e.includePostItems = t.includePostItems), t.intervalMs !== void 0 && (e.intervalMs = t.intervalMs);
4135
+ Wr(t), t.enabled !== void 0 && (e.enabled = t.enabled), t.includePostItems !== void 0 && (e.includePostItems = t.includePostItems), t.intervalMs !== void 0 && (e.intervalMs = t.intervalMs);
4118
4136
  }
4119
4137
  //#endregion
4120
4138
  //#region src/core/reelInfoSheet.ts
4121
- function Kr(e) {
4139
+ function qr(e) {
4122
4140
  return { enabled: e?.enabled ?? !1 };
4123
4141
  }
4124
- function qr(e, t, n) {
4142
+ function Jr(e, t, n) {
4125
4143
  if (n && !t) throw Error("Vibe cannot enable reelInfoSheet without a configured component.");
4126
4144
  e.enabled = n;
4127
4145
  }
4128
4146
  //#endregion
4129
4147
  //#region src/core/initialRuntimeState.ts
4130
- function Jr(e, t) {
4148
+ function Yr(e, t) {
4131
4149
  let n = e.initialPage;
4132
4150
  return {
4133
4151
  activeReelPostId: null,
4134
- autoScroll: _r(e.autoScroll),
4135
- autofill: sr(e.autofill),
4152
+ autoScroll: vr(e.autoScroll),
4153
+ autofill: cr(e.autofill),
4136
4154
  current: n?.current ?? null,
4137
4155
  error: null,
4138
- fill: kr(e.fill),
4156
+ fill: Ar(e.fill),
4139
4157
  infiniteScroll: e.infiniteScroll ?? !0,
4140
4158
  isLoading: !n,
4141
4159
  isLoadingMore: !1,
@@ -4146,14 +4164,14 @@ function Jr(e, t) {
4146
4164
  next: n?.next ?? null,
4147
4165
  nextPageError: null,
4148
4166
  phoneMode: !1,
4149
- reelAutoAdvance: Wr(e.reelAutoAdvance),
4167
+ reelAutoAdvance: Gr(e.reelAutoAdvance),
4150
4168
  reelForward: {
4151
4169
  error: null,
4152
4170
  status: "idle"
4153
4171
  },
4154
4172
  reelForwardIndex: null,
4155
4173
  reelForwardItem: null,
4156
- reelInfoSheet: Kr(e.reelInfoSheet),
4174
+ reelInfoSheet: qr(e.reelInfoSheet),
4157
4175
  reelInfoSheetOverlay: !1,
4158
4176
  reelMediaSource: "original",
4159
4177
  reelOrigin: null,
@@ -4162,21 +4180,21 @@ function Jr(e, t) {
4162
4180
  }
4163
4181
  //#endregion
4164
4182
  //#region src/core/options.ts
4165
- function Yr(e, t) {
4183
+ function Xr(e, t) {
4166
4184
  if (t) {
4167
4185
  if (!Number.isFinite(t.height) || t.height <= 0) throw TypeError(`Vibe ${e} height must be a positive number.`);
4168
4186
  if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe ${e} background must be "default" or "transparent".`);
4169
4187
  }
4170
4188
  }
4171
- function Xr(e, t) {
4189
+ function Zr(e, t) {
4172
4190
  if (t) {
4173
4191
  if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe mediaCard ${e} background must be "default" or "transparent".`);
4174
4192
  for (let [n, r] of [["paddingX", t.paddingX], ["paddingY", t.paddingY]]) if (r !== void 0 && (!Number.isFinite(r) || r < 0)) throw TypeError(`Vibe mediaCard ${e} ${n} must be a non-negative number.`);
4175
4193
  }
4176
4194
  }
4177
- function Zr(e) {
4178
- if (gr(e.autoScroll), Yr("cardHeader", e.cardHeader), Yr("cardFooter", e.cardFooter), Xr("header", e.mediaCard?.header), Xr("footer", e.mediaCard?.footer), e.mediaCard?.feedPreload !== void 0 && e.mediaCard.feedPreload !== "none" && e.mediaCard.feedPreload !== "visible-post") throw TypeError("Vibe mediaCard feedPreload must be \"none\" or \"visible-post\".");
4179
- if (or(e.autofill), Or(e.fill), Oe(e.masonry), Ur(e.reelAutoAdvance), e.removalReconciliation) {
4195
+ function Qr(e) {
4196
+ if (_r(e.autoScroll), Xr("cardHeader", e.cardHeader), Xr("cardFooter", e.cardFooter), Zr("header", e.mediaCard?.header), Zr("footer", e.mediaCard?.footer), e.mediaCard?.feedPreload !== void 0 && e.mediaCard.feedPreload !== "none" && e.mediaCard.feedPreload !== "visible-post") throw TypeError("Vibe mediaCard feedPreload must be \"none\" or \"visible-post\".");
4197
+ if (sr(e.autofill), kr(e.fill), ke(e.masonry), Wr(e.reelAutoAdvance), e.removalReconciliation) {
4180
4198
  if (!Number.isInteger(e.removalReconciliation.pageSize) || e.removalReconciliation.pageSize <= 0) throw TypeError("Vibe removalReconciliation pageSize must be a positive integer.");
4181
4199
  let t = e.removalReconciliation.maxReplayPages ?? 5;
4182
4200
  if (!Number.isInteger(t) || t <= 0) throw TypeError("Vibe removalReconciliation maxReplayPages must be a positive integer.");
@@ -4191,7 +4209,7 @@ function Zr(e) {
4191
4209
  if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
4192
4210
  if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
4193
4211
  }
4194
- function Qr(e) {
4212
+ function $r(e) {
4195
4213
  if (typeof e != "string") return e;
4196
4214
  if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
4197
4215
  let t = document.querySelector(e);
@@ -4200,7 +4218,7 @@ function Qr(e) {
4200
4218
  }
4201
4219
  //#endregion
4202
4220
  //#region src/core/pageRequest.ts
4203
- async function $r({ append: e, autofillController: t, cursor: n, isCurrent: r, loadPage: i, onLastCursor: a, onPages: o, options: s, signal: c, state: l }) {
4221
+ async function ei({ append: e, autofillController: t, cursor: n, isCurrent: r, loadPage: i, onLastCursor: a, onPages: o, options: s, signal: c, state: l }) {
4204
4222
  let u = s.autofill, d = e && u?.strategy === "frontend" && (l.autofill.status === "paused" || l.autofill.status === "error"), f = d ? {
4205
4223
  received: l.autofill.received,
4206
4224
  requests: l.autofill.requests
@@ -4212,11 +4230,11 @@ async function $r({ append: e, autofillController: t, cursor: n, isCurrent: r, l
4212
4230
  let m = !1;
4213
4231
  try {
4214
4232
  if (u?.strategy === "frontend") {
4215
- let s = await dr({
4233
+ let s = await fr({
4216
4234
  existingItems: e ? l.items : [],
4217
4235
  initialCursor: n,
4218
4236
  loadPage: i,
4219
- maximumRequests: f ? Math.max(0, rr(u) - f.requests) : void 0,
4237
+ maximumRequests: f ? Math.max(0, ir(u) - f.requests) : void 0,
4220
4238
  onCollection: (e) => t.captureCollection(e, r()),
4221
4239
  onDelayChange: (e) => {
4222
4240
  r() && Object.assign(l.autofill, e);
@@ -4239,7 +4257,7 @@ async function $r({ append: e, autofillController: t, cursor: n, isCurrent: r, l
4239
4257
  }), o(s.pages), t.clearCollection();
4240
4258
  return;
4241
4259
  }
4242
- let s = Vn(await i({
4260
+ let s = Hn(await i({
4243
4261
  cursor: n,
4244
4262
  signal: c
4245
4263
  }));
@@ -4259,7 +4277,7 @@ async function $r({ append: e, autofillController: t, cursor: n, isCurrent: r, l
4259
4277
  l.autofill.status = "complete";
4260
4278
  return;
4261
4279
  }
4262
- await yr(u, l, {
4280
+ await br(u, l, {
4263
4281
  cycleId: p,
4264
4282
  feedKey: u.feedKey,
4265
4283
  items: h.slice(d.length),
@@ -4280,17 +4298,76 @@ async function $r({ append: e, autofillController: t, cursor: n, isCurrent: r, l
4280
4298
  }
4281
4299
  }
4282
4300
  //#endregion
4301
+ //#region src/core/pageReplacement.ts
4302
+ var ti = class {
4303
+ controller = null;
4304
+ constructor(e) {
4305
+ this.options = e;
4306
+ }
4307
+ isActive() {
4308
+ return this.controller !== null;
4309
+ }
4310
+ cancel() {
4311
+ this.controller?.abort(), this.controller = null, this.options.surface()?.cancelItemRemoval();
4312
+ }
4313
+ async replace(e, t) {
4314
+ let n = Hn(e);
4315
+ this.cancel();
4316
+ let r = new AbortController();
4317
+ this.controller = r;
4318
+ try {
4319
+ if (await this.options.prepare(), r.signal.aborted) return;
4320
+ let e = this.options.state, i = new Map(e.items.map((e) => [String(e.postId), e])), a = [], o = /* @__PURE__ */ new Set();
4321
+ for (let e of n.items) {
4322
+ let t = String(e.postId);
4323
+ o.has(t) || (o.add(t), a.push({
4324
+ ...e,
4325
+ postId: i.get(t)?.postId ?? e.postId
4326
+ }));
4327
+ }
4328
+ let s = e.items.filter((e) => !o.has(String(e.postId))).map((e) => e.postId);
4329
+ if (await this.options.surface()?.animateItemRemoval(s, r.signal), r.signal.aborted) return;
4330
+ if (t?.resetScroll) {
4331
+ let e = this.options.surface()?.getAutoScrollElement();
4332
+ e && (e.scrollTop = 0);
4333
+ }
4334
+ e.mediaIndices = new Map(a.map((t) => [t.postId, U(t, e.mediaIndices.get(t.postId) ?? 0)])), e.activeReelPostId !== null && !o.has(String(e.activeReelPostId)) && (e.activeReelPostId = null, e.reelOrigin = null), e.items = a, e.next = n.next, e.total = n.total ?? null, e.error = null, e.nextPageError = null, this.options.commit({
4335
+ ...n,
4336
+ items: a
4337
+ });
4338
+ } finally {
4339
+ this.controller === r && (this.controller = null, this.options.surface()?.cancelItemRemoval());
4340
+ }
4341
+ }
4342
+ };
4343
+ //#endregion
4344
+ //#region src/core/loadingLock.ts
4345
+ function ni(e, t, n) {
4346
+ if (e.loadMoreLocked !== t && (e.loadMoreLocked = t, !t)) {
4347
+ if (e.fill.status === "paused" && e.fill.target) {
4348
+ n.resumeFill();
4349
+ return;
4350
+ }
4351
+ if (e.autofill.status === "paused" || n.hasPendingSession()) {
4352
+ let e = n.getPending();
4353
+ e ? e.finally(() => {
4354
+ n.loadNext();
4355
+ }) : n.loadNext();
4356
+ } else e.infiniteScroll && m(n.loadIfNearBottom);
4357
+ }
4358
+ }
4359
+ //#endregion
4283
4360
  //#region src/core/removalReconciliationController.ts
4284
- function ei(e) {
4361
+ function ri(e) {
4285
4362
  return `${typeof e}:${String(e)}`;
4286
4363
  }
4287
- function ti(e) {
4364
+ function ii(e) {
4288
4365
  return `${typeof e}:${String(e)}`;
4289
4366
  }
4290
- function ni(e) {
4367
+ function ai(e) {
4291
4368
  return e.map(({ postId: e }) => e);
4292
4369
  }
4293
- var ri = class {
4370
+ var oi = class {
4294
4371
  delay;
4295
4372
  enabled;
4296
4373
  maxReplayPages;
@@ -4309,7 +4386,7 @@ var ri = class {
4309
4386
  e.status === "complete" && (this.pages = [...this.pages.slice(0, e.replaceFrom), ...e.pages].slice(-this.maxReplayPages), this.pending = null);
4310
4387
  }
4311
4388
  filterItems(e) {
4312
- return this.tombstones.size === 0 ? [...e] : e.filter(({ postId: e }) => !this.tombstones.has(ei(e)));
4389
+ return this.tombstones.size === 0 ? [...e] : e.filter(({ postId: e }) => !this.tombstones.has(ri(e)));
4313
4390
  }
4314
4391
  needsReconciliation(e) {
4315
4392
  return this.pending !== null || this.findUnderfilledPage(e) >= 0;
@@ -4322,45 +4399,45 @@ var ri = class {
4322
4399
  }
4323
4400
  recordInitialPage(e) {
4324
4401
  e && this.recordPages([{
4325
- contributionIds: ni(e.items),
4326
- cursor: Gn(e),
4402
+ contributionIds: ai(e.items),
4403
+ cursor: Kn(e),
4327
4404
  next: e.next,
4328
- returnedIds: ni(e.items)
4405
+ returnedIds: ai(e.items)
4329
4406
  }]);
4330
4407
  }
4331
4408
  remove(e) {
4332
- e.forEach((e) => this.tombstones.add(ei(e)));
4409
+ e.forEach((e) => this.tombstones.add(ri(e)));
4333
4410
  }
4334
4411
  reset() {
4335
4412
  this.pages = [], this.pending = null, this.tombstones.clear();
4336
4413
  }
4337
4414
  restore(e) {
4338
- e.forEach((e) => this.tombstones.delete(ei(e)));
4415
+ e.forEach((e) => this.tombstones.delete(ri(e)));
4339
4416
  }
4340
4417
  async reconcile({ existingItems: e, loadPage: t, onDelayChange: n = () => void 0, shouldPause: r = () => !1, signal: i }) {
4341
4418
  let a = this.pending ?? this.createSession(e);
4342
4419
  for (this.pending = a; a.remainingRequests > 0;) {
4343
- let e = ti(a.cursor);
4420
+ let e = ii(a.cursor);
4344
4421
  if (a.seenCursors.has(e)) throw Error("Vibe removal reconciliation received a repeated cursor.");
4345
- if (await tr({
4346
- delayMs: $n(a.pages.length, this.delay),
4422
+ if (await nr({
4423
+ delayMs: er(a.pages.length, this.delay),
4347
4424
  onChange: n,
4348
4425
  signal: i
4349
4426
  }), a.pages.length > 0 && r()) return this.result(a, "paused");
4350
- let o = Vn(await t({
4427
+ let o = Hn(await t({
4351
4428
  cursor: a.cursor,
4352
4429
  signal: i
4353
4430
  }));
4354
4431
  a.seenCursors.add(e);
4355
4432
  let s = this.filterItems(o.items), c = [];
4356
4433
  if (s.forEach((e) => {
4357
- let t = ei(e.postId);
4434
+ let t = ri(e.postId);
4358
4435
  a.attributed.has(t) || (a.attributed.add(t), c.push(e.postId)), a.appended.has(t) || (a.appended.add(t), a.items.push(e));
4359
4436
  }), a.pages.push({
4360
4437
  contributionIds: c,
4361
4438
  cursor: a.cursor,
4362
4439
  next: o.next,
4363
- returnedIds: ni(s)
4440
+ returnedIds: ai(s)
4364
4441
  }), a.lastCursor = a.cursor, a.next = o.next, --a.remainingRequests, o.total !== void 0 && (a.total = o.total), a.next === null ? a.remainingRequests = 0 : a.cursor = a.next, a.remainingRequests > 0 && r()) return this.result(a, "paused");
4365
4442
  }
4366
4443
  return this.result(a, "complete");
@@ -4368,9 +4445,9 @@ var ri = class {
4368
4445
  createSession(e) {
4369
4446
  let t = this.findUnderfilledPage(e), n = t < 0 ? [] : this.pages.slice(t), r = n[0];
4370
4447
  if (!r) throw Error("Vibe has no underfilled provider page to reconcile.");
4371
- let i = new Set(n.flatMap(({ contributionIds: e }) => e.map(ei))), a = new Set(e.map(({ postId: e }) => ei(e)).filter((e) => !i.has(e)));
4448
+ let i = new Set(n.flatMap(({ contributionIds: e }) => e.map(ri))), a = new Set(e.map(({ postId: e }) => ri(e)).filter((e) => !i.has(e)));
4372
4449
  return {
4373
- appended: new Set(e.map(({ postId: e }) => ei(e))),
4450
+ appended: new Set(e.map(({ postId: e }) => ri(e))),
4374
4451
  attributed: new Set(a),
4375
4452
  cursor: r.cursor,
4376
4453
  items: [],
@@ -4395,11 +4472,11 @@ var ri = class {
4395
4472
  }
4396
4473
  findUnderfilledPage(e) {
4397
4474
  if (!this.enabled || this.pages.length === 0) return -1;
4398
- let t = new Set(e.map(({ postId: e }) => ei(e)));
4399
- return this.pages.findIndex(({ contributionIds: e }) => e.filter((e) => t.has(ei(e))).length < this.pageSize);
4475
+ let t = new Set(e.map(({ postId: e }) => ri(e)));
4476
+ return this.pages.findIndex(({ contributionIds: e }) => e.filter((e) => t.has(ri(e))).length < this.pageSize);
4400
4477
  }
4401
4478
  recordPage(e) {
4402
- let t = ti(e.cursor), n = this.pages.findIndex(({ cursor: e }) => ti(e) === t);
4479
+ let t = ii(e.cursor), n = this.pages.findIndex(({ cursor: e }) => ii(e) === t);
4403
4480
  n >= 0 && (this.pages = this.pages.slice(0, n)), this.pages.push({
4404
4481
  ...e,
4405
4482
  contributionIds: [...e.contributionIds],
@@ -4409,7 +4486,7 @@ var ri = class {
4409
4486
  };
4410
4487
  //#endregion
4411
4488
  //#region src/core/activeItemRemoval.ts
4412
- function ii(e, t, n, r, i) {
4489
+ function si(e, t, n, r, i) {
4413
4490
  let a = new Set(t.map(({ item: e }) => e.postId));
4414
4491
  if (e.activeReelPostId === null || !a.has(e.activeReelPostId)) return;
4415
4492
  let o = e.items[Math.max(n, 0)];
@@ -4422,7 +4499,7 @@ function ii(e, t, n, r, i) {
4422
4499
  }
4423
4500
  //#endregion
4424
4501
  //#region src/core/exactMediaRemovalController.ts
4425
- function ai(e, t) {
4502
+ function ci(e, t) {
4426
4503
  let [n, ...r] = t;
4427
4504
  if (!n) throw Error("Vibe items must contain at least one media asset.");
4428
4505
  return {
@@ -4431,10 +4508,10 @@ function ai(e, t) {
4431
4508
  items: r
4432
4509
  };
4433
4510
  }
4434
- function oi(e) {
4511
+ function li(e) {
4435
4512
  if (!Number.isInteger(e.mediaIndex) || e.mediaIndex < 0) throw TypeError("Vibe mediaIndex must be a non-negative integer.");
4436
4513
  }
4437
- var si = class {
4514
+ var ui = class {
4438
4515
  generation = 0;
4439
4516
  metadata = /* @__PURE__ */ new WeakMap();
4440
4517
  state;
@@ -4442,7 +4519,7 @@ var si = class {
4442
4519
  this.options = e, this.state = e.state;
4443
4520
  }
4444
4521
  remove(e) {
4445
- oi(e);
4522
+ li(e);
4446
4523
  let t = this.state.items.findIndex(({ postId: t }) => t === e.postId), n = this.state.items[t];
4447
4524
  if (!n) return null;
4448
4525
  let r = [...H(n)], i = r[e.mediaIndex];
@@ -4459,7 +4536,7 @@ var si = class {
4459
4536
  restored: !1
4460
4537
  });
4461
4538
  let o = this.state.mediaIndices.get(n.postId) ?? 0, s = this.isReelOpen() && this.state.activeReelPostId === n.postId, c = s && o === e.mediaIndex;
4462
- return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = ai(n, r), this.updateMediaIndexAfterRemoval(n.postId, e.mediaIndex, c), a) : (this.state.items.splice(t, 1), this.options.onPostRemoved(n.postId), this.state.mediaIndices.delete(n.postId), s && this.advanceFromRemovedPost(a, n), a);
4539
+ return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = ci(n, r), this.updateMediaIndexAfterRemoval(n.postId, e.mediaIndex, c), a) : (this.state.items.splice(t, 1), this.options.onPostRemoved(n.postId), this.state.mediaIndices.delete(n.postId), s && this.advanceFromRemovedPost(a, n), a);
4463
4540
  }
4464
4541
  reset() {
4465
4542
  this.generation += 1;
@@ -4485,7 +4562,7 @@ var si = class {
4485
4562
  }
4486
4563
  restoreIntoPost(e, t) {
4487
4564
  let n = this.state.items[e], r = [...H(n)], i = Math.min(t.mediaIndex, r.length);
4488
- if (r.splice(i, 0, t.media), this.state.items[e] = ai(n, r), this.state.activeReelPostId !== t.postId) return;
4565
+ if (r.splice(i, 0, t.media), this.state.items[e] = ci(n, r), this.state.activeReelPostId !== t.postId) return;
4489
4566
  let a = this.state.mediaIndices.get(t.postId) ?? 0;
4490
4567
  a >= i && this.state.mediaIndices.set(t.postId, a + 1);
4491
4568
  }
@@ -4498,18 +4575,18 @@ var si = class {
4498
4575
  };
4499
4576
  //#endregion
4500
4577
  //#region src/core/itemPlacement.ts
4501
- function ci(e, t) {
4578
+ function di(e, t) {
4502
4579
  let n = new Set(t);
4503
4580
  return e.flatMap((e, t) => n.has(e.postId) ? [{
4504
4581
  index: t,
4505
4582
  item: e
4506
4583
  }] : []);
4507
4584
  }
4508
- function li(e, t) {
4585
+ function fi(e, t) {
4509
4586
  let n = new Set(t.map(({ item: e }) => e.postId));
4510
4587
  return e.filter((e) => !n.has(e.postId));
4511
4588
  }
4512
- function ui(e, t) {
4589
+ function pi(e, t) {
4513
4590
  t.forEach(({ index: e }) => {
4514
4591
  if (!Number.isInteger(e) || e < 0) throw Error("Vibe item restore indexes must be non-negative integers.");
4515
4592
  });
@@ -4520,7 +4597,7 @@ function ui(e, t) {
4520
4597
  }
4521
4598
  //#endregion
4522
4599
  //#region src/core/itemRemovalController.ts
4523
- var di = 20, fi = class {
4600
+ var mi = 20, hi = class {
4524
4601
  generation = 0;
4525
4602
  historyLimit;
4526
4603
  metadata = /* @__PURE__ */ new WeakMap();
@@ -4529,7 +4606,7 @@ var di = 20, fi = class {
4529
4606
  itemOrder;
4530
4607
  stopItemsWatcher;
4531
4608
  constructor(e) {
4532
- this.options = e, this.historyLimit = e.historyLimit ?? di, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = O(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
4609
+ this.options = e, this.historyLimit = e.historyLimit ?? mi, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = O(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
4533
4610
  }
4534
4611
  destroy() {
4535
4612
  this.reset(), this.stopItemsWatcher();
@@ -4543,7 +4620,7 @@ var di = 20, fi = class {
4543
4620
  let a = this.options.startRemoval(i, t);
4544
4621
  if (a > 0 && await new Promise((e) => setTimeout(e, a)), this.metadata.get(r)?.generation !== this.generation) return r;
4545
4622
  let o = this.state.items.findIndex((e) => e.postId === this.state.activeReelPostId), s = new Set(n.map(({ item: e }) => e.postId)), c = o < 0 ? 0 : this.state.items.slice(0, o).filter(({ postId: e }) => s.has(e)).length, l = Math.max(o - c, 0);
4546
- return this.state.items = li(this.state.items, n), this.options.onItemsRemoved(r, n, l), this.record(r), r;
4623
+ return this.state.items = fi(this.state.items, n), this.options.onItemsRemoved(r, n, l), this.record(r), r;
4547
4624
  }
4548
4625
  reset() {
4549
4626
  this.generation += 1, this.history = [], this.itemOrder = [];
@@ -4554,7 +4631,7 @@ var di = 20, fi = class {
4554
4631
  this.restoreRemoval(t);
4555
4632
  return;
4556
4633
  }
4557
- let n = new Set(this.state.items.map(({ postId: e }) => e)), r = e.filter(({ item: e }) => n.has(e.postId) ? !1 : (n.add(e.postId), !0)), i = ui(this.state.items, r);
4634
+ let n = new Set(this.state.items.map(({ postId: e }) => e)), r = e.filter(({ item: e }) => n.has(e.postId) ? !1 : (n.add(e.postId), !0)), i = pi(this.state.items, r);
4558
4635
  this.registerExternalPlacements(r), this.state.items = i, r.length > 0 && this.options.onRemovalRestored(r);
4559
4636
  }
4560
4637
  restoreRemoval(e) {
@@ -4580,7 +4657,7 @@ var di = 20, fi = class {
4580
4657
  }
4581
4658
  collectOrderedPlacements(e) {
4582
4659
  let t = new Map(this.itemOrder.map((e, t) => [e, t]));
4583
- return ci(this.state.items, e).map((e) => ({
4660
+ return di(this.state.items, e).map((e) => ({
4584
4661
  index: t.get(e.item.postId) ?? e.index,
4585
4662
  item: e.item
4586
4663
  }));
@@ -4611,7 +4688,7 @@ var di = 20, fi = class {
4611
4688
  let r = new Map(this.itemOrder.map((e, t) => [e, t]));
4612
4689
  return this.state.items = [...this.state.items, ...n].sort((e, t) => (r.get(e.postId) ?? 2 ** 53 - 1) - (r.get(t.postId) ?? 2 ** 53 - 1)), !0;
4613
4690
  }
4614
- }, pi = class {
4691
+ }, gi = class {
4615
4692
  forward = null;
4616
4693
  forwardPromise = null;
4617
4694
  forwardVersion = 0;
@@ -4707,7 +4784,7 @@ var di = 20, fi = class {
4707
4784
  }
4708
4785
  }
4709
4786
  }
4710
- }, mi = class {
4787
+ }, _i = class {
4711
4788
  generation = 0;
4712
4789
  pending = Promise.resolve();
4713
4790
  constructor(e) {
@@ -4757,24 +4834,24 @@ var di = 20, fi = class {
4757
4834
  };
4758
4835
  //#endregion
4759
4836
  //#region src/core/removalControllers.ts
4760
- function hi(e) {
4761
- let t = new pi(e), n = new mi({
4837
+ function vi(e) {
4838
+ let t = new gi(e), n = new _i({
4762
4839
  state: e.state,
4763
4840
  transitionMedia: (t) => e.surface()?.transitionActiveReelMedia(t) ?? Promise.resolve(!1),
4764
4841
  transitionPost: (t) => e.surface()?.transitionActiveReelPost(t) ?? Promise.resolve(!1)
4765
4842
  });
4766
4843
  return {
4767
- exactMediaRemoval: new si({
4844
+ exactMediaRemoval: new ui({
4768
4845
  onActivate: e.onActivate,
4769
4846
  onPostRemoved: (t) => e.onItemsRemoved([t]),
4770
4847
  onPostRestored: (t) => e.onItemsRestored([t]),
4771
4848
  reelForward: t,
4772
4849
  state: e.state
4773
4850
  }),
4774
- itemRemoval: new fi({
4851
+ itemRemoval: new hi({
4775
4852
  historyLimit: e.historyLimit,
4776
4853
  onItemsRemoved: (n, r, i) => {
4777
- e.onItemsRemoved(r.map(({ item: e }) => e.postId)), ii(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
4854
+ e.onItemsRemoved(r.map(({ item: e }) => e.postId)), si(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
4778
4855
  },
4779
4856
  onRemovalRestored: (n) => {
4780
4857
  e.onItemsRestored(n.map(({ item: e }) => e.postId));
@@ -4789,17 +4866,17 @@ function hi(e) {
4789
4866
  reelRemoval: n
4790
4867
  };
4791
4868
  }
4792
- var gi = 1.5;
4793
- function _i(e) {
4869
+ var yi = 1.5;
4870
+ function bi(e) {
4794
4871
  let t = Math.min(e.screenWidth, e.screenHeight);
4795
4872
  if (t > 0 && t < 600) return !0;
4796
- let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * gi;
4873
+ let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * yi;
4797
4874
  return !e.hasHover && n > 0 && n < 600 && r;
4798
4875
  }
4799
- function vi(e) {
4800
- return _i(e) ? "reel" : "masonry";
4876
+ function xi(e) {
4877
+ return bi(e) ? "reel" : "masonry";
4801
4878
  }
4802
- function yi(e) {
4879
+ function Si(e) {
4803
4880
  let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
4804
4881
  return {
4805
4882
  hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
@@ -4809,15 +4886,15 @@ function yi(e) {
4809
4886
  viewportWidth: n.clientWidth
4810
4887
  };
4811
4888
  }
4812
- function bi(e) {
4813
- return _i(yi(e));
4889
+ function Ci(e) {
4890
+ return bi(Si(e));
4814
4891
  }
4815
- function xi(e) {
4816
- return vi(yi(e));
4892
+ function wi(e) {
4893
+ return xi(Si(e));
4817
4894
  }
4818
4895
  //#endregion
4819
4896
  //#region src/core/responsiveLayoutController.ts
4820
- var Si = class {
4897
+ var Ti = class {
4821
4898
  layoutMode;
4822
4899
  resizeObserver = null;
4823
4900
  target = null;
@@ -4842,13 +4919,13 @@ var Si = class {
4842
4919
  }
4843
4920
  handleResponsiveLayout = () => {
4844
4921
  if (!this.target) return;
4845
- let e = xi(this.target);
4846
- this.state.phoneMode = bi(this.target), this.state.reelInfoSheetOverlay = this.state.phoneMode, this.state.reelMediaSource = this.state.phoneMode ? "mobile" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
4922
+ let e = wi(this.target);
4923
+ this.state.phoneMode = Ci(this.target), this.state.reelInfoSheetOverlay = this.state.phoneMode, this.state.reelMediaSource = this.state.phoneMode ? "mobile" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
4847
4924
  };
4848
- }, Ci = class {
4925
+ }, Ei = class {
4849
4926
  state;
4850
4927
  constructor(e) {
4851
- this.options = e, this.state = x(Rt({
4928
+ this.options = e, this.state = x(zt({
4852
4929
  ...e.initialReelAudioState,
4853
4930
  muted: e.initialReelAudioState?.muted ?? e.mediaCard?.videoMuted ?? !1
4854
4931
  }));
@@ -4857,9 +4934,9 @@ var Si = class {
4857
4934
  return { ...this.state };
4858
4935
  }
4859
4936
  set(e, t = !1) {
4860
- Object.assign(this.state, Rt(e, this.state)), t && this.options.onReelAudioStateChange?.(this.get());
4937
+ Object.assign(this.state, zt(e, this.state)), t && this.options.onReelAudioStateChange?.(this.get());
4861
4938
  }
4862
- }, wi = class {
4939
+ }, Di = class {
4863
4940
  routedReelPostId = null;
4864
4941
  reelRouteIsActive = !1;
4865
4942
  constructor(e, t) {
@@ -4889,30 +4966,30 @@ var Si = class {
4889
4966
  };
4890
4967
  //#endregion
4891
4968
  //#region src/core/updateItems.ts
4892
- function Ti(e) {
4969
+ function Oi(e) {
4893
4970
  return String(e);
4894
4971
  }
4895
- function Ei(e, t) {
4972
+ function ki(e, t) {
4896
4973
  let n = H(t).length;
4897
4974
  (e.mediaIndices.get(t.postId) ?? 0) >= n && e.mediaIndices.set(t.postId, Math.max(0, n - 1));
4898
4975
  }
4899
- function Di(e, t) {
4976
+ function Ai(e, t) {
4900
4977
  let n = /* @__PURE__ */ new Map();
4901
- if (t.forEach((e) => n.set(Ti(e.postId), e)), n.size === 0) return [];
4978
+ if (t.forEach((e) => n.set(Oi(e.postId), e)), n.size === 0) return [];
4902
4979
  let r = [], i = e.items.map((t) => {
4903
- let i = n.get(Ti(t.postId));
4980
+ let i = n.get(Oi(t.postId));
4904
4981
  if (!i) return t;
4905
4982
  let a = {
4906
4983
  ...i,
4907
4984
  postId: t.postId
4908
4985
  };
4909
- return Ei(e, a), e.reelForwardItem && Ti(e.reelForwardItem.postId) === Ti(t.postId) && (e.reelForwardItem = a), r.push(t.postId), a;
4986
+ return ki(e, a), e.reelForwardItem && Oi(e.reelForwardItem.postId) === Oi(t.postId) && (e.reelForwardItem = a), r.push(t.postId), a;
4910
4987
  });
4911
4988
  return r.length > 0 && (e.items = i), r;
4912
4989
  }
4913
4990
  //#endregion
4914
4991
  //#region src/core/createVibe.ts
4915
- var Oi = class {
4992
+ var ji = class {
4916
4993
  app = null;
4917
4994
  autoScroll;
4918
4995
  autofillController;
@@ -4934,25 +5011,26 @@ var Oi = class {
4934
5011
  notificationItems;
4935
5012
  reelAudio;
4936
5013
  state;
5014
+ pageReplacement;
4937
5015
  constructor(e) {
4938
- this.options = e, Zr(e);
5016
+ this.options = e, Qr(e);
4939
5017
  let t = e.layout ?? "masonry";
4940
- this.state = x(Jr(e, t)), this.reelAudio = new Ci(e), this.lastLoadedCursor = e.initialPage ? Gn(e.initialPage) : null, this.notificationItems = K(this.state), this.autoScroll = new vr({
5018
+ this.state = x(Yr(e, t)), this.reelAudio = new Ei(e), this.lastLoadedCursor = e.initialPage ? Kn(e.initialPage) : null, this.notificationItems = K(this.state), this.autoScroll = new yr({
4941
5019
  getScrollElement: () => this.surface?.getAutoScrollElement() ?? null,
4942
5020
  state: this.state.autoScroll
4943
- }), this.autofillController = new fr({
4944
- cancelRequest: () => this.cancelRequest(),
5021
+ }), this.autofillController = new pr({
5022
+ cancelRequest: () => this.cancelRequest(!this.pageReplacement?.isActive()),
4945
5023
  onLastCursor: (e) => this.setCurrentCursor(e),
4946
5024
  onPages: (e) => this.removalReconciliation.recordPages(e),
4947
5025
  options: e.autofill,
4948
5026
  state: this.state
4949
- }), this.removalReconciliation = new ri(e), this.removalReconciliation.recordInitialPage(e.initialPage), this.fillController = new zr({
5027
+ }), this.removalReconciliation = new oi(e), this.removalReconciliation.recordInitialPage(e.initialPage), this.fillController = new Br({
4950
5028
  fill: e.fill,
4951
5029
  loadPage: e.loadPage ? (e) => this.loadFilteredPage(e) : void 0,
4952
5030
  needsFrontendPreparation: () => this.removalReconciliation.needsReconciliation(this.state.items),
4953
5031
  onLastCursor: (e) => this.setCurrentCursor(e),
4954
5032
  onPages: (e) => this.removalReconciliation.recordPages(e),
4955
- prepareFrontend: ({ isCurrent: t, onDelayChange: n, signal: r }) => Br({
5033
+ prepareFrontend: ({ isCurrent: t, onDelayChange: n, signal: r }) => Vr({
4956
5034
  controller: this.removalReconciliation,
4957
5035
  isCurrent: t,
4958
5036
  loadPage: e.loadPage,
@@ -4962,8 +5040,8 @@ var Oi = class {
4962
5040
  state: this.state
4963
5041
  }),
4964
5042
  state: this.state
4965
- }), this.routing = new wi(e.routing, this.state);
4966
- let n = hi({
5043
+ }), this.routing = new Di(e.routing, this.state);
5044
+ let n = vi({
4967
5045
  historyLimit: e.removalHistoryLimit,
4968
5046
  onActivate: (e) => this.setActiveReelPost(e),
4969
5047
  onCloseReel: () => this.closeMasonryReel(),
@@ -4973,20 +5051,29 @@ var Oi = class {
4973
5051
  state: this.state,
4974
5052
  surface: () => this.surface
4975
5053
  });
4976
- this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new Si(t, this.state, () => {
5054
+ this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.pageReplacement = new ti({
5055
+ state: this.state,
5056
+ surface: () => this.surface,
5057
+ prepare: async () => {
5058
+ this.cancelRequest(!1), lr(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill();
5059
+ },
5060
+ commit: (e) => {
5061
+ this.resetFeedVisit(), this.setCurrentCursor(Kn(e)), this.removalReconciliation.recordInitialPage(e), this.state.reelOrigin === null && this.routing.syncFeed();
5062
+ }
5063
+ }), this.responsiveLayout = new Ti(t, this.state, () => {
4977
5064
  this.routing.syncFeed();
4978
5065
  }), this.startStateNotifications();
4979
5066
  }
4980
5067
  async mount() {
4981
5068
  if (this.app) throw Error("Vibe is already mounted.");
4982
5069
  this.startStateNotifications();
4983
- let e = Qr(this.options.target);
4984
- this.responsiveLayout.mount(e), this.app = i(Bn, {
5070
+ let e = $r(this.options.target);
5071
+ this.responsiveLayout.mount(e), this.app = i(Vn, {
4985
5072
  canRetryEnd: !!this.options.loadPage,
4986
5073
  cardFooter: this.options.cardFooter,
4987
5074
  cardHeader: this.options.cardHeader,
4988
5075
  feedFooter: this.options.feedFooter,
4989
- feedFooterActions: Vr(this),
5076
+ feedFooterActions: Hr(this),
4990
5077
  mediaCard: this.options.mediaCard,
4991
5078
  masonry: this.options.masonry,
4992
5079
  onMediaFullyVisible: this.options.onMediaFullyVisible,
@@ -5012,7 +5099,7 @@ var Oi = class {
5012
5099
  onRetryForward: () => {
5013
5100
  this.retryReelForward();
5014
5101
  }
5015
- }), this.surface = this.app.mount(e), this.autoScroll.mount(), await Cr(this.options.restoreBacklog, (e) => this.appendPage(e), (e) => {
5102
+ }), this.surface = this.app.mount(e), this.autoScroll.mount(), await wr(this.options.restoreBacklog, (e) => this.appendPage(e), (e) => {
5016
5103
  this.restoreController = e;
5017
5104
  }), !this.options.initialPage && this.state.items.length === 0 ? await this.reload() : this.options.autofill && this.state.autofill.status === "idle" && !this.fillController.isActive() && !this.state.loadMoreLocked && await this.startInitialAutofill();
5018
5105
  }
@@ -5020,7 +5107,7 @@ var Oi = class {
5020
5107
  this.restoreController?.abort(), this.restoreController = null, this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.destroy(), this.removalReconciliation.reset(), this.responsiveLayout.destroy(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null;
5021
5108
  }
5022
5109
  getState() {
5023
- return q(this.state);
5110
+ return J(this.state);
5024
5111
  }
5025
5112
  getReelAudioState() {
5026
5113
  return this.reelAudio.get();
@@ -5047,7 +5134,7 @@ var Oi = class {
5047
5134
  return this.itemRemoval.restoreRemoval(e);
5048
5135
  }
5049
5136
  updateItems(e) {
5050
- return Di(this.state, e);
5137
+ return Ai(this.state, e);
5051
5138
  }
5052
5139
  retryReelForward() {
5053
5140
  return this.reelForward.retry();
@@ -5086,22 +5173,21 @@ var Oi = class {
5086
5173
  this.autoScroll.setSpeed(e);
5087
5174
  }
5088
5175
  applyAutofillUpdate(e) {
5089
- let t = xr(this.options.autofill, this.state, e);
5176
+ let t = Sr(this.options.autofill, this.state, e);
5090
5177
  return t && this.autofillController.syncCountdown(), t;
5091
5178
  }
5092
5179
  cancelAutofill() {
5093
5180
  return this.autofillController.cancel();
5094
5181
  }
5095
5182
  async cancelLoading() {
5096
- if (this.state.loadMoreLocked = !1, this.fillController.isActive()) {
5183
+ if (this.state.loadMoreLocked = !1, this.cancelRequest(), this.fillController.isActive()) {
5097
5184
  await this.cancelFill();
5098
5185
  return;
5099
5186
  }
5100
- if (cr(this.state.autofill)) {
5187
+ if (lr(this.state.autofill)) {
5101
5188
  await this.cancelAutofill();
5102
5189
  return;
5103
5190
  }
5104
- this.cancelRequest();
5105
5191
  }
5106
5192
  applyFillUpdate(e) {
5107
5193
  return this.fillController.applyUpdate(e);
@@ -5110,13 +5196,13 @@ var Oi = class {
5110
5196
  return this.fillController.cancel();
5111
5197
  }
5112
5198
  async fill(e) {
5113
- if (!this.state.loadMoreLocked) {
5114
- if (this.pendingRequest || cr(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
5199
+ if (!(this.state.loadMoreLocked || this.pageReplacement.isActive())) {
5200
+ if (this.pendingRequest || lr(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
5115
5201
  await this.fillController.start(e);
5116
5202
  }
5117
5203
  }
5118
5204
  restoreAutofillSession(e) {
5119
- let t = Sr(this.options.autofill, this.state, e);
5205
+ let t = Cr(this.options.autofill, this.state, e);
5120
5206
  return t && this.autofillController.syncCountdown(), t;
5121
5207
  }
5122
5208
  restoreFillSession(e) {
@@ -5126,18 +5212,19 @@ var Oi = class {
5126
5212
  return this.startLoadMore(() => this.loadNextSequence());
5127
5213
  }
5128
5214
  appendPage(e) {
5129
- Kn(e, this.state, this.removalReconciliation, (e) => this.setCurrentCursor(e));
5215
+ qn(e, this.state, this.removalReconciliation, (e) => this.setCurrentCursor(e));
5130
5216
  }
5131
5217
  replenishAfterRemoval(e = !0) {
5132
5218
  return this.startLoadMore(() => this.replenishAfterRemovalSequence(e));
5133
5219
  }
5134
5220
  async startLoadMore(e) {
5221
+ if (this.pageReplacement.isActive()) return;
5135
5222
  if (this.pendingRequest) return this.pendingRequest;
5136
- if (this.state.loadMoreLocked || cr(this.state.autofill) || this.fillController.isActive() || !this.options.loadPage || this.state.next === null && !this.removalReconciliation.needsReconciliation(this.state.items)) return;
5223
+ if (this.state.loadMoreLocked || lr(this.state.autofill) || this.fillController.isActive() || !this.options.loadPage || this.state.next === null && !this.removalReconciliation.needsReconciliation(this.state.items)) return;
5137
5224
  this.state.isLoadingMore = !0, this.state.nextPageError = null;
5138
5225
  let t = e();
5139
5226
  return this.pendingRequest = t, t.finally(() => {
5140
- this.pendingRequest === t && (this.pendingRequest = null), this.state.isLoadingMore = !1;
5227
+ this.pendingRequest === t && (this.pendingRequest = null, this.state.isLoadingMore = !1);
5141
5228
  });
5142
5229
  }
5143
5230
  async refresh() {
@@ -5146,14 +5233,20 @@ var Oi = class {
5146
5233
  async reload() {
5147
5234
  return this.replaceFeed(null, "reload");
5148
5235
  }
5236
+ replacePage(e, t) {
5237
+ return this.pageReplacement.replace(e, t);
5238
+ }
5149
5239
  async replaceFeed(e, t) {
5150
5240
  if (!this.options.loadPage) throw Error(`Vibe cannot ${t} without loadPage.`);
5151
- return cr(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = sr(this.options.autofill, void 0, !1), this.fillController.reset(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.reset(), this.removalReconciliation.reset(), this.surface?.resetMediaLifecycle(), this.state.error = null, this.state.current = null, this.state.isLoading = !0, this.state.items = [], this.state.next = null, this.state.nextPageError = null, this.state.total = null, this.startRequest(e, !1);
5241
+ return lr(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.resetFeedVisit(), this.surface?.resetMediaLifecycle(), this.state.error = null, this.state.current = null, this.state.isLoading = !0, this.state.items = [], this.state.next = null, this.state.nextPageError = null, this.state.total = null, this.startRequest(e, !1);
5242
+ }
5243
+ resetFeedVisit() {
5244
+ this.state.autofill = cr(this.options.autofill, void 0, !1), this.fillController.reset(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.reset(), this.removalReconciliation.reset();
5152
5245
  }
5153
5246
  async loadFilteredPage(e) {
5154
5247
  let t = this.options.loadPage;
5155
5248
  if (!t) throw Error("Vibe cannot load a page without loadPage.");
5156
- let n = Vn(await t(e));
5249
+ let n = Hn(await t(e));
5157
5250
  return {
5158
5251
  ...n,
5159
5252
  items: this.removalReconciliation.filterItems(n.items)
@@ -5173,7 +5266,7 @@ var Oi = class {
5173
5266
  let n = ++this.requestVersion, r = new AbortController();
5174
5267
  this.abortController = r;
5175
5268
  try {
5176
- let i = await Br({
5269
+ let i = await Vr({
5177
5270
  controller: this.removalReconciliation,
5178
5271
  isCurrent: () => n === this.requestVersion,
5179
5272
  loadPage: t,
@@ -5191,35 +5284,32 @@ var Oi = class {
5191
5284
  }
5192
5285
  }
5193
5286
  async retryEnd() {
5194
- if (this.pendingRequest) return this.pendingRequest;
5195
- if (!this.state.loadMoreLocked && !(cr(this.state.autofill) || this.fillController.isActive()) && !(this.state.next !== null || !this.options.loadPage)) return this.state.isLoadingMore = !0, this.state.nextPageError = null, this.startRequest(this.lastLoadedCursor, !0);
5287
+ if (!this.pageReplacement.isActive()) {
5288
+ if (this.pendingRequest) return this.pendingRequest;
5289
+ if (!this.state.loadMoreLocked && !(lr(this.state.autofill) || this.fillController.isActive()) && !(this.state.next !== null || !this.options.loadPage)) return this.state.isLoadingMore = !0, this.state.nextPageError = null, this.startRequest(this.lastLoadedCursor, !0);
5290
+ }
5196
5291
  }
5197
5292
  setInfiniteScroll(e) {
5198
5293
  this.state.infiniteScroll = e, e && m(() => this.surface?.loadIfNearBottom());
5199
5294
  }
5200
5295
  setLoadMoreLocked(e) {
5201
- if (this.state.loadMoreLocked !== e && (this.state.loadMoreLocked = e, !e)) {
5202
- if (this.state.fill.status === "paused" && this.state.fill.target) {
5203
- this.fillController.resume(this.removalReconciliation.hasPendingSession());
5204
- return;
5205
- }
5206
- if (this.state.autofill.status === "paused" || this.removalReconciliation.hasPendingSession()) {
5207
- let e = this.pendingRequest;
5208
- e ? e.finally(() => {
5209
- this.loadNext();
5210
- }) : this.loadNext();
5211
- } else this.state.infiniteScroll && m(() => this.surface?.loadIfNearBottom());
5212
- }
5296
+ ni(this.state, e, {
5297
+ getPending: () => this.pendingRequest,
5298
+ hasPendingSession: () => this.removalReconciliation.hasPendingSession(),
5299
+ loadNext: () => this.loadNext(),
5300
+ resumeFill: () => this.fillController.resume(this.removalReconciliation.hasPendingSession()),
5301
+ loadIfNearBottom: () => this.surface?.loadIfNearBottom()
5302
+ });
5213
5303
  }
5214
5304
  setTotal(e) {
5215
5305
  if (e !== null && (!Number.isInteger(e) || e < 0)) throw TypeError("Vibe total must be a non-negative integer or null.");
5216
5306
  this.state.total = e;
5217
5307
  }
5218
5308
  setReelAutoAdvance(e) {
5219
- Gr(this.state.reelAutoAdvance, e);
5309
+ Kr(this.state.reelAutoAdvance, e);
5220
5310
  }
5221
5311
  setReelInfoSheet(e) {
5222
- qr(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
5312
+ Jr(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
5223
5313
  }
5224
5314
  setLayout(e) {
5225
5315
  this.responsiveLayout.setLayout(e);
@@ -5233,13 +5323,13 @@ var Oi = class {
5233
5323
  setActiveReelPost(e) {
5234
5324
  this.state.layout !== "reel" && this.state.reelOrigin !== "masonry" || (this.state.activeReelPostId = e, this.routing.syncReel(e));
5235
5325
  }
5236
- cancelRequest() {
5237
- this.autofillController.clearCountdown(), this.requestVersion += 1, this.abortController?.abort(), this.abortController = null, this.pendingRequest = null, this.state.isLoading = !1, this.state.isLoadingMore = !1;
5326
+ cancelRequest(e = !0) {
5327
+ e && this.pageReplacement.cancel(), this.autofillController.clearCountdown(), this.requestVersion += 1, this.abortController?.abort(), this.abortController = null, this.pendingRequest = null, this.state.isLoading = !1, this.state.isLoadingMore = !1;
5238
5328
  }
5239
5329
  async fetchPage(e, t) {
5240
5330
  if (!this.options.loadPage) return;
5241
5331
  let n = ++this.requestVersion, r = new AbortController();
5242
- this.abortController = r, await $r({
5332
+ this.abortController = r, await ei({
5243
5333
  append: t,
5244
5334
  autofillController: this.autofillController,
5245
5335
  cursor: e,
@@ -5261,7 +5351,7 @@ var Oi = class {
5261
5351
  startInitialAutofill() {
5262
5352
  let e = ++this.requestVersion, t = new AbortController(), n = this.autofillController.beginCycle();
5263
5353
  this.abortController = t, this.state.isLoadingMore = !0;
5264
- let r = wr({
5354
+ let r = Tr({
5265
5355
  cycleId: n,
5266
5356
  isCurrent: () => e === this.requestVersion,
5267
5357
  onCollection: (t) => this.autofillController.captureCollection(t, e === this.requestVersion),
@@ -5279,11 +5369,11 @@ var Oi = class {
5279
5369
  }
5280
5370
  startStateNotifications() {
5281
5371
  let e = this.options.onStateChange;
5282
- !e || this.stopStateWatcher || (e(q(this.state, this.notificationItems.value)), this.stopStateWatcher = O(() => q(this.state, this.notificationItems.value), (t) => e(t), { flush: "post" }));
5372
+ !e || this.stopStateWatcher || (this.stopStateWatcher = q(this.state, this.notificationItems, e));
5283
5373
  }
5284
5374
  setCurrentCursor(e) {
5285
- this.lastLoadedCursor = e, this.state.current = e;
5375
+ this.lastLoadedCursor = this.state.current = e;
5286
5376
  }
5287
- }, ki = (e) => new Oi(e);
5377
+ }, Mi = (e) => new ji(e);
5288
5378
  //#endregion
5289
- export { ki as createVibe };
5379
+ export { Mi as createVibe };