@wyxos/vibe 4.5.2 → 4.5.3

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
@@ -85,7 +85,7 @@ var I = {
85
85
  onClick: n[0] ||= (e) => t.$emit("retryEnd")
86
86
  }, " Check for more ", 8, B)]))])) : a("", !0);
87
87
  }
88
- }), ee = /* @__PURE__ */ u({
88
+ }), H = /* @__PURE__ */ u({
89
89
  __name: "FeedFooter",
90
90
  props: {
91
91
  actions: {},
@@ -136,7 +136,7 @@ var I = {
136
136
  "load-more-locked"
137
137
  ]));
138
138
  }
139
- }), H = ["role"], U = { class: "gallery-status" }, te = /* @__PURE__ */ u({
139
+ }), U = ["role"], W = { class: "gallery-status" }, ee = /* @__PURE__ */ u({
140
140
  __name: "FeedStatus",
141
141
  props: {
142
142
  actions: {},
@@ -150,7 +150,7 @@ var I = {
150
150
  return (n, u) => (y(), o("main", {
151
151
  class: "gallery-shell",
152
152
  role: r.state.error ? "alert" : r.state.isLoading ? "status" : void 0
153
- }, [s("p", U, [r.state.error ? (y(), o(e, { key: 0 }, [c(" Unable to load media. ")], 64)) : r.state.isLoading ? (y(), o(e, { key: 1 }, [c(" Loading media… ")], 64)) : (y(), o(e, { key: 2 }, [c(" No media found. ")], 64))]), t.feedFooter ? (y(), i(ee, {
153
+ }, [s("p", W, [r.state.error ? (y(), o(e, { key: 0 }, [c(" Unable to load media. ")], 64)) : r.state.isLoading ? (y(), o(e, { key: 1 }, [c(" Loading media… ")], 64)) : (y(), o(e, { key: 2 }, [c(" No media found. ")], 64))]), t.feedFooter ? (y(), i(H, {
154
154
  key: 0,
155
155
  actions: t.actions,
156
156
  "can-retry-end": t.canRetryEnd,
@@ -171,36 +171,36 @@ var I = {
171
171
  "is-loading",
172
172
  "load-more-locked",
173
173
  "state"
174
- ])) : a("", !0)], 8, H));
174
+ ])) : a("", !0)], 8, U));
175
175
  }
176
176
  });
177
- function W(e) {
177
+ function G(e) {
178
178
  return e.scrollHeight - e.scrollTop - e.clientHeight <= 240;
179
179
  }
180
180
  //#endregion
181
181
  //#region src/core/masonry.ts
182
- function ne(e) {
182
+ function te(e) {
183
183
  let t = e.preview.width ?? e.width, n = e.preview.height ?? e.height;
184
184
  return !t || !n || t <= 0 || n <= 0 ? 1 : n / t;
185
185
  }
186
- function re(e) {
186
+ function ne(e) {
187
187
  return e.reduce((t, n, r) => n < e[t] ? r : t, 0);
188
188
  }
189
- function ie(e) {
189
+ function re(e) {
190
190
  return Math.max(0, e.containerHeight) + Math.max(0, e.gap);
191
191
  }
192
- function G(e, t) {
192
+ function K(e, t) {
193
193
  let n = Math.max(0, t.overscan), r = t.scrollTop - n, i = t.scrollTop + Math.max(0, t.viewportHeight) + n;
194
194
  return e.reduce((e, t, n) => (t.y + t.height >= r && t.y <= i && e.push(n), e), []);
195
195
  }
196
- function K(e, t, n) {
196
+ function q(e, t, n) {
197
197
  if (t <= 0 || e.length === 0) return {
198
198
  columns: 0,
199
199
  height: 0,
200
200
  items: []
201
201
  };
202
202
  let r = Math.max(0, n.gap), i = Number.isFinite(n.additionalHeight) ? Math.max(0, n.additionalHeight ?? 0) : 0, a = Math.max(1, n.minColumnWidth), o = Math.max(1, Math.floor((t + r) / (a + r))), s = (t - r * (o - 1)) / o, c = Array.from({ length: o }, () => 0), l = e.map((e) => {
203
- let t = re(c), n = s * ne(e) + i, a = {
203
+ let t = ne(c), n = s * te(e) + i, a = {
204
204
  x: t * (s + r),
205
205
  y: c[t],
206
206
  width: s,
@@ -216,10 +216,10 @@ function K(e, t, n) {
216
216
  }
217
217
  //#endregion
218
218
  //#region src/core/scrollbar.ts
219
- function q(e, t, n) {
219
+ function J(e, t, n) {
220
220
  return Math.min(n, Math.max(t, e));
221
221
  }
222
- function J({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
222
+ function Y({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
223
223
  let a = Math.max(0, e), o = Math.max(0, r), s = Math.max(0, i), c = Math.max(0, a - s);
224
224
  if (!(c > 0 && o > 0)) return {
225
225
  maximumScrollPosition: c,
@@ -228,23 +228,23 @@ function J({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize:
228
228
  thumbSize: o,
229
229
  thumbTravel: 0
230
230
  };
231
- let l = q(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
231
+ let l = J(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
232
232
  return {
233
233
  maximumScrollPosition: c,
234
234
  scrollable: !0,
235
- thumbOffset: u * (q(n, 0, c) / c),
235
+ thumbOffset: u * (J(n, 0, c) / c),
236
236
  thumbSize: l,
237
237
  thumbTravel: u
238
238
  };
239
239
  }
240
240
  //#endregion
241
241
  //#region src/components/GalleryScrollbar.vue?vue&type=script&setup=true&lang.ts
242
- var ae = ["aria-hidden"], oe = [
242
+ var ie = ["aria-hidden"], ae = [
243
243
  "aria-controls",
244
244
  "aria-valuemax",
245
245
  "aria-valuenow",
246
246
  "tabindex"
247
- ], Y = 32, X = 40, Z = 120, se = /* @__PURE__ */ u({
247
+ ], oe = 32, X = 40, Z = 120, se = /* @__PURE__ */ u({
248
248
  __name: "GalleryScrollbar",
249
249
  props: {
250
250
  contentSize: {},
@@ -273,9 +273,9 @@ var ae = ["aria-hidden"], oe = [
273
273
  }
274
274
  function j() {
275
275
  let e = t.scrollElement, n = i.value;
276
- return !e || !n ? r : J({
276
+ return !e || !n ? r : Y({
277
277
  contentSize: e.scrollHeight,
278
- minimumThumbSize: Y,
278
+ minimumThumbSize: oe,
279
279
  scrollPosition: e.scrollTop,
280
280
  trackSize: n.clientHeight,
281
281
  viewportSize: e.clientHeight
@@ -374,7 +374,7 @@ var ae = ["aria-hidden"], oe = [
374
374
  onPointerdown: I,
375
375
  onPointermove: L,
376
376
  onPointerup: R
377
- }, null, 44, oe)], 42, ae));
377
+ }, null, 44, ae)], 42, ie));
378
378
  }
379
379
  }), ce = (e) => {
380
380
  for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
@@ -693,45 +693,45 @@ var Oe = /* @__PURE__ */ u({
693
693
  function x(e = !1, t = "pointer") {
694
694
  e && b("activate", t);
695
695
  }
696
- let S = n(() => j(c.item)), E = n(() => M(c.item, c.mediaIndex)), D = n(() => N(c.item, E.value)), P = n(() => c.mediaSource === "original" ? D.value.src : D.value.preview.src), F = n(() => c.mediaSource === "original" ? D.value.width : D.value.preview.width), I = n(() => c.mediaSource === "original" ? D.value.height : D.value.preview.height), L = C(null), R = C(0), z = C(0), B = C(!0), V = C(!1), ee = C(1), H = 1, U = n(() => c.interactive && !!(c.cardHeader || c.cardFooter));
697
- function te(e) {
696
+ let S = n(() => j(c.item)), E = n(() => M(c.item, c.mediaIndex)), D = n(() => N(c.item, E.value)), P = n(() => c.mediaSource === "original" ? D.value.src : D.value.preview.src), F = n(() => c.mediaSource === "original" ? D.value.width : D.value.preview.width), I = n(() => c.mediaSource === "original" ? D.value.height : D.value.preview.height), L = C(null), R = C(0), z = C(0), B = C(!0), V = C(!1), H = C(1), U = 1, W = n(() => c.interactive && !!(c.cardHeader || c.cardFooter));
697
+ function ee(e) {
698
698
  return e.detail === 0 ? "keyboard" : "pointer";
699
699
  }
700
- function W(e, t) {
700
+ function G(e, t) {
701
701
  let n = S.value.length, r = (e + n) % n;
702
702
  r !== E.value && (v.value = e < E.value ? "previous" : "next", b("mediaChange", r), t && t.detail > 0 && t.currentTarget?.blur());
703
703
  }
704
- function ne(e, t, n) {
704
+ function te(e, t, n) {
705
705
  return t === 1 ? e * 16 : t === 2 ? e * n : e;
706
706
  }
707
- function re() {
707
+ function ne() {
708
708
  d = 0, f = !1, u !== null && clearTimeout(u), u = null;
709
709
  }
710
- function ie() {
711
- u !== null && clearTimeout(u), u = setTimeout(re, Xe);
710
+ function re() {
711
+ u !== null && clearTimeout(u), u = setTimeout(ne, Xe);
712
712
  }
713
- function G(e) {
713
+ function K(e) {
714
714
  if (S.value.length <= 1) return;
715
- let t = e.currentTarget?.clientWidth || 1, n = ne(e.deltaX, e.deltaMode, t);
716
- if (n === 0 || (e.preventDefault(), ie(), f) || (d += n, Math.abs(d) < Ze)) return;
715
+ let t = e.currentTarget?.clientWidth || 1, n = te(e.deltaX, e.deltaMode, t);
716
+ if (n === 0 || (e.preventDefault(), re(), f) || (d += n, Math.abs(d) < Ze)) return;
717
717
  let r = Math.sign(d);
718
- d = 0, f = !0, W(E.value + r);
718
+ d = 0, f = !0, G(E.value + r);
719
719
  }
720
- function K(e) {
720
+ function q(e) {
721
721
  let t = e.touches[0];
722
722
  c.layout !== "reel" || !t || (p = t.clientX, h = t.clientY);
723
723
  }
724
- function q(e) {
724
+ function J(e) {
725
725
  let t = e.changedTouches[0];
726
726
  if (p === null || h === null || !t) return;
727
727
  let n = p - t.clientX, r = h - t.clientY;
728
- p = null, h = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < Ye || W(E.value + Math.sign(n)));
728
+ p = null, h = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < Ye || G(E.value + Math.sign(n)));
729
729
  }
730
- let J = n(() => De(P.value));
731
- function ae(e) {
732
- c.layout === "reel" && (e.stopPropagation(), oe());
730
+ let Y = n(() => De(P.value));
731
+ function ie(e) {
732
+ c.layout === "reel" && (e.stopPropagation(), ae());
733
733
  }
734
- async function oe() {
734
+ async function ae() {
735
735
  if (L.value) {
736
736
  if (V.value) {
737
737
  L.value.pause();
@@ -744,12 +744,12 @@ var Oe = /* @__PURE__ */ u({
744
744
  }
745
745
  }
746
746
  }
747
- function Y(e) {
747
+ function oe(e) {
748
748
  return Number.isFinite(e) ? Math.max(0, e) : 0;
749
749
  }
750
750
  function X(e) {
751
751
  let t = e?.currentTarget ?? L.value;
752
- t && (R.value = Y(t.currentTime), z.value = Y(t.duration), B.value = t.muted, ee.value = t.volume, t.volume > 0 && (H = t.volume));
752
+ t && (R.value = oe(t.currentTime), z.value = oe(t.duration), B.value = t.muted, H.value = t.volume, t.volume > 0 && (U = t.volume));
753
753
  }
754
754
  function Z(e) {
755
755
  X(e), b("ready", E.value);
@@ -759,20 +759,20 @@ var Oe = /* @__PURE__ */ u({
759
759
  }
760
760
  function ce(e) {
761
761
  let t = L.value;
762
- !t || !Number.isFinite(e) || (t.currentTime = Math.min(Y(t.duration), Math.max(0, e)), R.value = t.currentTime);
762
+ !t || !Number.isFinite(e) || (t.currentTime = Math.min(oe(t.duration), Math.max(0, e)), R.value = t.currentTime);
763
763
  }
764
764
  function le(e) {
765
765
  let t = L.value;
766
766
  if (!t || !Number.isFinite(e)) return;
767
767
  let n = Math.min(1, Math.max(0, e));
768
- t.volume = n, t.muted = n === 0, n > 0 && (H = n), X();
768
+ t.volume = n, t.muted = n === 0, n > 0 && (U = n), X();
769
769
  }
770
770
  function ue() {
771
771
  let e = L.value;
772
- e && (e.muted && e.volume === 0 && (e.volume = H), e.muted = !e.muted, X());
772
+ e && (e.muted && e.volume === 0 && (e.volume = U), e.muted = !e.muted, X());
773
773
  }
774
774
  return _(() => {
775
- re();
775
+ ne();
776
776
  }), (n, r) => (y(), o("article", {
777
777
  "data-post-id": e.item.postId,
778
778
  "data-media-index": E.value,
@@ -786,10 +786,10 @@ var Oe = /* @__PURE__ */ u({
786
786
  "aria-hidden": e.leaving || void 0,
787
787
  "aria-busy": e.previewState === "loading",
788
788
  inert: e.leaving || void 0,
789
- role: e.interactive && !e.leaving && !U.value ? "button" : void 0,
790
- tabindex: e.interactive && !e.leaving && !U.value ? 0 : void 0,
791
- onClick: r[11] ||= (t) => x(e.interactive && !U.value, te(t)),
792
- onKeydown: [r[12] ||= k((t) => x(e.interactive && !U.value, "keyboard"), ["enter"]), r[13] ||= k(A((t) => x(e.interactive && !U.value, "keyboard"), ["prevent"]), ["space"])]
789
+ role: e.interactive && !e.leaving && !W.value ? "button" : void 0,
790
+ tabindex: e.interactive && !e.leaving && !W.value ? 0 : void 0,
791
+ onClick: r[11] ||= (t) => x(e.interactive && !W.value, ee(t)),
792
+ onKeydown: [r[12] ||= k((t) => x(e.interactive && !W.value, "keyboard"), ["enter"]), r[13] ||= k(A((t) => x(e.interactive && !W.value, "keyboard"), ["prevent"]), ["space"])]
793
793
  }, [s("div", Re, [
794
794
  e.cardHeader ? (y(), i(Oe, {
795
795
  key: 0,
@@ -817,13 +817,13 @@ var Oe = /* @__PURE__ */ u({
817
817
  s("div", {
818
818
  class: m(["media-card-media", { "media-card-media--carousel": e.layout === "reel" && S.value.length > 1 }]),
819
819
  "data-media-direction": v.value,
820
- onWheel: G,
821
- onTouchstartPassive: K,
822
- onTouchendPassive: q
820
+ onWheel: K,
821
+ onTouchstartPassive: q,
822
+ onTouchendPassive: J
823
823
  }, [
824
824
  l(t, { name: `media-slide-${v.value}` }, {
825
825
  default: O(() => [(y(), o("div", {
826
- key: `${e.item.postId}:${E.value}:${e.mediaSource ?? "preview"}`,
826
+ key: `${e.item.postId}:${D.value.src}:${e.mediaSource ?? "preview"}`,
827
827
  class: "media-card-frame",
828
828
  "data-media-index": E.value
829
829
  }, [e.previewState === "loading" ? (y(), o("div", Ve, [...r[14] ||= [s("span", { class: "media-loading-shimmer" }, null, -1)]])) : e.previewState === "error" ? (y(), o("div", {
@@ -832,7 +832,7 @@ var Oe = /* @__PURE__ */ u({
832
832
  class: "media-error",
833
833
  role: "img",
834
834
  "aria-label": `${T(we)(P.value)} ${T(Te)(P.value)}`
835
- }, [s("strong", Ue, w(T(we)(P.value)), 1), s("span", null, w(T(Te)(P.value)), 1)], 8, He)) : a("", !0), J.value ? (y(), o("video", {
835
+ }, [s("strong", Ue, w(T(we)(P.value)), 1), s("span", null, w(T(Te)(P.value)), 1)], 8, He)) : a("", !0), Y.value ? (y(), o("video", {
836
836
  key: 2,
837
837
  ref_key: "videoElement",
838
838
  ref: L,
@@ -855,7 +855,7 @@ var Oe = /* @__PURE__ */ u({
855
855
  onPlaying: r[0] ||= (e) => V.value = !0,
856
856
  onPause: r[1] ||= (e) => V.value = !1,
857
857
  onEnded: se,
858
- onClick: ae,
858
+ onClick: ie,
859
859
  onError: r[2] ||= (e) => n.$emit("error", E.value)
860
860
  }, null, 42, We)) : (y(), o("img", {
861
861
  key: 3,
@@ -872,17 +872,17 @@ var Oe = /* @__PURE__ */ u({
872
872
  }, null, 42, Ge))], 8, Be))]),
873
873
  _: 1
874
874
  }, 8, ["name"]),
875
- J.value && e.previewState === "ready" ? (y(), i(Ie, {
875
+ Y.value && e.previewState === "ready" ? (y(), i(Ie, {
876
876
  key: 0,
877
877
  "current-time": R.value,
878
878
  duration: z.value,
879
879
  layout: e.layout,
880
880
  muted: B.value,
881
881
  playing: V.value,
882
- volume: ee.value,
882
+ volume: H.value,
883
883
  onSeek: ce,
884
884
  onToggleMute: ue,
885
- onTogglePlayback: oe,
885
+ onTogglePlayback: ae,
886
886
  onVolumeChange: le
887
887
  }, null, 8, [
888
888
  "current-time",
@@ -900,21 +900,21 @@ var Oe = /* @__PURE__ */ u({
900
900
  type: "button",
901
901
  class: "media-carousel-control media-carousel-control--previous",
902
902
  "aria-label": `Previous media for post ${e.item.postId}`,
903
- onClick: r[5] ||= A((e) => W(E.value - 1, e), ["stop"]),
903
+ onClick: r[5] ||= A((e) => G(E.value - 1, e), ["stop"]),
904
904
  onKeydown: r[6] ||= A(() => {}, ["stop"])
905
905
  }, [l(T(_e), { size: 20 })], 40, Ke), s("button", {
906
906
  type: "button",
907
907
  class: "media-carousel-control media-carousel-control--next",
908
908
  "aria-label": `Next media for post ${e.item.postId}`,
909
- onClick: r[7] ||= A((e) => W(E.value + 1, e), ["stop"]),
909
+ onClick: r[7] ||= A((e) => G(E.value + 1, e), ["stop"]),
910
910
  onKeydown: r[8] ||= A(() => {}, ["stop"])
911
911
  }, [l(T(ve), { size: 20 })], 40, qe)], 2)) : a("", !0),
912
- U.value ? (y(), o("button", {
912
+ W.value ? (y(), o("button", {
913
913
  key: 2,
914
914
  class: "media-card-activator",
915
915
  type: "button",
916
916
  "aria-label": `Open post ${e.item.postId}`,
917
- onClick: r[9] ||= A((e) => n.$emit("activate", te(e)), ["stop"]),
917
+ onClick: r[9] ||= A((e) => n.$emit("activate", ee(e)), ["stop"]),
918
918
  onKeydown: r[10] ||= A(() => {}, ["stop"])
919
919
  }, null, 40, Je)) : a("", !0)
920
920
  ], 42, ze),
@@ -977,14 +977,14 @@ var Oe = /* @__PURE__ */ u({
977
977
  "retryEnd"
978
978
  ],
979
979
  setup(t, { expose: r, emit: a }) {
980
- let c = t, u = a, d = C(null), f = `vibe-masonry-${E()}`, p = C(null), h = C(0), v = C(nt), b = C(0), S = C(0), w = C(0), O = null, k = null, A = null, j = n(() => K(c.items, h.value, {
980
+ let c = t, u = a, d = C(null), f = `vibe-masonry-${E()}`, p = C(null), h = C(0), v = C(nt), b = C(0), S = C(0), w = C(0), O = null, k = null, A = null, j = n(() => q(c.items, h.value, {
981
981
  additionalHeight: (c.cardHeader?.height ?? 0) + (c.cardFooter?.height ?? 0),
982
982
  gap: v.value,
983
983
  minColumnWidth: tt
984
984
  })), M = n(() => {
985
985
  let e = j.value;
986
986
  if (c.leavingPostIds.size === 0) return e;
987
- let t = c.items.filter((e) => !c.leavingPostIds.has(e.postId)), n = K(t, h.value, {
987
+ let t = c.items.filter((e) => !c.leavingPostIds.has(e.postId)), n = q(t, h.value, {
988
988
  additionalHeight: (c.cardHeader?.height ?? 0) + (c.cardFooter?.height ?? 0),
989
989
  gap: v.value,
990
990
  minColumnWidth: tt
@@ -997,16 +997,16 @@ var Oe = /* @__PURE__ */ u({
997
997
  let e = Math.max(it, S.value * at), t = {
998
998
  scrollTop: b.value - w.value,
999
999
  viewportHeight: S.value
1000
- }, n = G(M.value.items, {
1000
+ }, n = K(M.value.items, {
1001
1001
  ...t,
1002
1002
  overscan: e
1003
- }), r = c.leavingPostIds.size === 0 ? [] : G(j.value.items, {
1003
+ }), r = c.leavingPostIds.size === 0 ? [] : K(j.value.items, {
1004
1004
  ...t,
1005
1005
  overscan: e
1006
- }), i = [...new Set([...n, ...r])].sort((e, t) => e - t), a = G(M.value.items, {
1006
+ }), i = [...new Set([...n, ...r])].sort((e, t) => e - t), a = K(M.value.items, {
1007
1007
  ...t,
1008
1008
  overscan: 0
1009
- }), o = c.leavingPostIds.size === 0 ? [] : G(j.value.items, {
1009
+ }), o = c.leavingPostIds.size === 0 ? [] : K(j.value.items, {
1010
1010
  ...t,
1011
1011
  overscan: 0
1012
1012
  }), s = new Set([...a, ...o]);
@@ -1022,7 +1022,7 @@ var Oe = /* @__PURE__ */ u({
1022
1022
  function I(e) {
1023
1023
  let t = M.value.items[e], n = c.items[e]?.postId;
1024
1024
  if (!t) return {};
1025
- let r = n !== void 0 && c.enteringPostIds.has(n), i = n !== void 0 && c.leavingPostIds.has(n), a = r || i ? ie({
1025
+ let r = n !== void 0 && c.enteringPostIds.has(n), i = n !== void 0 && c.leavingPostIds.has(n), a = r || i ? re({
1026
1026
  containerHeight: j.value.height,
1027
1027
  gap: v.value
1028
1028
  }) : 0, o = n === void 0 ? 0 : i ? c.removalDelays.get(n) ?? 0 : r ? c.entryDelays.get(n) ?? 0 : 0;
@@ -1046,11 +1046,11 @@ var Oe = /* @__PURE__ */ u({
1046
1046
  }
1047
1047
  function z(e) {
1048
1048
  let t = e.currentTarget;
1049
- t && (b.value = t.scrollTop, !c.loadMoreLocked && c.infiniteScroll && W(t) && u("loadMore"));
1049
+ t && (b.value = t.scrollTop, !c.loadMoreLocked && c.infiniteScroll && G(t) && u("loadMore"));
1050
1050
  }
1051
1051
  function B() {
1052
1052
  let e = d.value;
1053
- !c.loadMoreLocked && e && W(e) && u("loadMore");
1053
+ !c.loadMoreLocked && e && G(e) && u("loadMore");
1054
1054
  }
1055
1055
  function V() {
1056
1056
  return d.value;
@@ -1124,7 +1124,7 @@ var Oe = /* @__PURE__ */ u({
1124
1124
  "onMediaChange",
1125
1125
  "onReady",
1126
1126
  "onError"
1127
- ]))), 128))], 6), l(ee, {
1127
+ ]))), 128))], 6), l(H, {
1128
1128
  actions: t.feedFooterActions,
1129
1129
  "can-retry-end": t.canRetryEnd,
1130
1130
  "feed-footer": t.feedFooter,
@@ -1155,7 +1155,28 @@ var Oe = /* @__PURE__ */ u({
1155
1155
  "suspended"
1156
1156
  ])]));
1157
1157
  }
1158
- }), st = ["aria-label"], ct = /* @__PURE__ */ u({
1158
+ }), st = 300;
1159
+ function ct(e, t, n) {
1160
+ let r = e.scrollTop;
1161
+ if (n || Math.abs(r - t) <= 1) return e.scrollTop = t, Promise.resolve();
1162
+ e.setAttribute("data-transitioning", "");
1163
+ let i = performance.now(), a = 0;
1164
+ return new Promise((n) => {
1165
+ let o = (s) => {
1166
+ a += 1;
1167
+ let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c / st), u = 1 - (1 - l) ** 3;
1168
+ if (e.scrollTop = r + (t - r) * u, l < 1) {
1169
+ requestAnimationFrame(o);
1170
+ return;
1171
+ }
1172
+ e.removeAttribute("data-transitioning"), e.scrollTop = t, n();
1173
+ };
1174
+ requestAnimationFrame(o);
1175
+ });
1176
+ }
1177
+ //#endregion
1178
+ //#region src/components/ReelAutoAdvanceProgress.vue?vue&type=script&setup=true&lang.ts
1179
+ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
1159
1180
  __name: "ReelAutoAdvanceProgress",
1160
1181
  props: {
1161
1182
  durationMs: {},
@@ -1173,9 +1194,9 @@ var Oe = /* @__PURE__ */ u({
1173
1194
  class: "reel-auto-advance-progress",
1174
1195
  style: g(a.value),
1175
1196
  onAnimationend: n[0] ||= (e) => i("complete")
1176
- }, null, 36)], 8, st));
1197
+ }, null, 36)], 8, lt));
1177
1198
  }
1178
- }), lt = ["data-active-post-id", "data-active-media-index"], ut = ["role", "data-status"], dt = 2, ft = /* @__PURE__ */ u({
1199
+ }), dt = ["data-active-post-id", "data-active-media-index"], ft = ["role", "data-status"], pt = 2, mt = 300, ht = /* @__PURE__ */ u({
1179
1200
  __name: "ReelFeed",
1180
1201
  props: {
1181
1202
  initialPostId: {},
@@ -1213,7 +1234,7 @@ var Oe = /* @__PURE__ */ u({
1213
1234
  ],
1214
1235
  setup(t, { expose: r, emit: c }) {
1215
1236
  let l = t, u = c, d = C(null), f = l.initialPostId === null || l.initialPostId === void 0 ? -1 : l.items.findIndex((e) => e.postId === l.initialPostId), h = C(Math.max(0, f)), b = C(!1), S = 0, E = null, O = null, k = null, A = n(() => ({ gridTemplateRows: `repeat(${l.items.length}, 100cqh)` })), M = n(() => {
1216
- let e = Math.max(0, h.value - dt), t = Math.min(l.items.length - 1, h.value + dt);
1237
+ let e = Math.max(0, h.value - pt), t = Math.min(l.items.length - 1, h.value + pt);
1217
1238
  return l.items.slice(e, t + 1).map((t, n) => ({
1218
1239
  fetchPriority: e + n === h.value ? "high" : "low",
1219
1240
  index: e + n,
@@ -1238,47 +1259,47 @@ var Oe = /* @__PURE__ */ u({
1238
1259
  l.reelAutoAdvance.enabled,
1239
1260
  l.reelAutoAdvance.includePostItems,
1240
1261
  l.reelAutoAdvance.intervalMs
1241
- ].join(":")), H = n(() => {
1262
+ ].join(":")), U = n(() => {
1242
1263
  let e = I.value, t = !!(e && l.reelAutoAdvance.includePostItems && L.value < j(e).length - 1), n = l.reelAutoAdvance.intervalMs / 1e3;
1243
1264
  return `Auto advance to the next ${t ? "post item" : "post"} in ${n}s`;
1244
- }), U = n(() => l.reelAutoAdvance.enabled && l.reelForward.status === "idle" && I.value !== void 0 && R.value !== "loading" && !B.value), te = n(() => l.reelForward.status === "loading" ? "Loading the next media…" : l.reelForward.status === "error" ? "Unable to load the next media." : "You reached the end of this feed.");
1245
- function ne(e) {
1265
+ }), W = n(() => l.reelAutoAdvance.enabled && l.reelForward.status === "idle" && I.value !== void 0 && R.value !== "loading" && !B.value), ee = n(() => l.reelForward.status === "loading" ? "Loading the next media…" : l.reelForward.status === "error" ? "Unable to load the next media." : "You reached the end of this feed.");
1266
+ function te(e) {
1246
1267
  return { gridRow: `${e + 1}` };
1247
1268
  }
1248
- function re(e) {
1269
+ function ne(e) {
1249
1270
  let t = S || e.clientHeight;
1250
1271
  return t <= 0 || l.items.length === 0 ? 0 : Math.min(l.items.length - 1, Math.max(0, Math.round(e.scrollTop / t)));
1251
1272
  }
1252
- function ie(e) {
1273
+ function re(e) {
1253
1274
  let t = e.currentTarget;
1254
- t && (b.value || (h.value = re(t)), !l.loadMoreLocked && l.infiniteScroll && W(t) && u("loadMore"));
1275
+ t && (b.value || (h.value = ne(t)), !l.loadMoreLocked && l.infiniteScroll && G(t) && u("loadMore"));
1255
1276
  }
1256
- function G() {
1277
+ function K() {
1257
1278
  let e = d.value;
1258
- e && (J(!0), S = e.clientHeight, e.scrollTop = h.value * S, O !== null && cancelAnimationFrame(O), O = requestAnimationFrame(() => {
1279
+ e && (Y(!0), S = e.clientHeight, e.scrollTop = h.value * S, O !== null && cancelAnimationFrame(O), O = requestAnimationFrame(() => {
1259
1280
  e.scrollTop = h.value * e.clientHeight, S = e.clientHeight, O = null;
1260
- }), K());
1281
+ }), q());
1261
1282
  }
1262
- function K() {
1283
+ function q() {
1263
1284
  k !== null && clearTimeout(k), k = setTimeout(() => {
1264
1285
  k = null;
1265
1286
  let e = d.value;
1266
- e && (S = e.clientHeight, e.scrollTop = h.value * S), J(!1);
1287
+ e && (S = e.clientHeight, e.scrollTop = h.value * S), Y(!1);
1267
1288
  }, 120);
1268
1289
  }
1269
- function q() {
1270
- J(!0);
1290
+ function J() {
1291
+ Y(!0);
1271
1292
  let e = d.value;
1272
- e && (S = e.clientHeight, e.scrollTop = h.value * S), K();
1293
+ e && (S = e.clientHeight, e.scrollTop = h.value * S), q();
1273
1294
  }
1274
- function J(e) {
1295
+ function Y(e) {
1275
1296
  b.value = e, d.value?.toggleAttribute("data-resizing", e);
1276
1297
  }
1277
- function ae() {
1298
+ function ie() {
1278
1299
  let e = d.value;
1279
- !l.loadMoreLocked && e && W(e) && u("loadMore");
1300
+ !l.loadMoreLocked && e && G(e) && u("loadMore");
1280
1301
  }
1281
- function oe(e) {
1302
+ function ae(e) {
1282
1303
  let t = I.value;
1283
1304
  if (!t) return !1;
1284
1305
  let n = j(t).length;
@@ -1286,27 +1307,30 @@ var Oe = /* @__PURE__ */ u({
1286
1307
  let r = (L.value + e + n) % n;
1287
1308
  return u("mediaChange", t.postId, r), !0;
1288
1309
  }
1289
- function Y(e) {
1310
+ function oe(e) {
1290
1311
  let t = h.value + e;
1291
- return !d.value || t < 0 || t >= l.items.length ? !1 : (Z(t), !0);
1312
+ return !d.value || t < 0 || t >= l.items.length ? !1 : (se(t), !0);
1292
1313
  }
1293
1314
  function X() {
1294
1315
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1295
1316
  }
1296
1317
  function Z(e) {
1297
1318
  let t = d.value;
1298
- if (!t) return;
1319
+ if (!t) return Promise.resolve();
1299
1320
  let n = e * (S || t.clientHeight);
1300
- if (h.value = e, !X() && typeof t.scrollTo == "function") {
1301
- t.scrollTo({
1302
- behavior: "smooth",
1303
- top: n
1304
- });
1305
- return;
1306
- }
1307
- t.scrollTop = n;
1321
+ return h.value = e, ct(t, n, X());
1308
1322
  }
1309
- function se() {
1323
+ function se(e) {
1324
+ Z(e);
1325
+ }
1326
+ async function ce(e) {
1327
+ let t = l.items.findIndex((t) => t.postId === e);
1328
+ return t < 0 || t === h.value ? !1 : (await Z(t), !0);
1329
+ }
1330
+ async function le(e) {
1331
+ return ae(e) ? (X() || await new Promise((e) => setTimeout(e, mt)), !0) : !1;
1332
+ }
1333
+ function ue() {
1310
1334
  if (!l.reelAutoAdvance.enabled) return;
1311
1335
  let e = I.value;
1312
1336
  if (!e) return;
@@ -1319,28 +1343,30 @@ var Oe = /* @__PURE__ */ u({
1319
1343
  l.hasNext && !l.loadMoreLocked && u("loadMore");
1320
1344
  return;
1321
1345
  }
1322
- l.reelAutoAdvance.includePostItems && (l.mediaIndices.get(n.postId) ?? 0) !== 0 && u("mediaChange", n.postId, 0), Z(t);
1346
+ l.reelAutoAdvance.includePostItems && (l.mediaIndices.get(n.postId) ?? 0) !== 0 && u("mediaChange", n.postId, 0), se(t);
1323
1347
  }
1324
- function ce(e, t) {
1325
- !l.reelAutoAdvance.enabled || e !== F.value || t !== L.value || !B.value || se();
1348
+ function de(e, t) {
1349
+ !l.reelAutoAdvance.enabled || e !== F.value || t !== L.value || !B.value || ue();
1326
1350
  }
1327
1351
  return D(d, (e) => {
1328
- E?.disconnect(), E = null, e && (S = e.clientHeight, !(typeof ResizeObserver > "u") && (E = new ResizeObserver(G), E.observe(e)));
1352
+ E?.disconnect(), E = null, e && (S = e.clientHeight, !(typeof ResizeObserver > "u") && (E = new ResizeObserver(K), E.observe(e)));
1329
1353
  }), D([() => l.items.length, () => l.initialPostId], async ([e, t]) => {
1330
1354
  let n = t == null ? -1 : l.items.findIndex(({ postId: e }) => e === t);
1331
- h.value = n >= 0 ? n : Math.min(h.value, Math.max(0, e - 1)), await p(), G();
1355
+ h.value = n >= 0 ? n : Math.min(h.value, Math.max(0, e - 1)), await p(), K();
1332
1356
  }), D(F, (e) => {
1333
1357
  e !== void 0 && u("activeChange", e);
1334
1358
  }, { immediate: !0 }), v(() => {
1335
- window.addEventListener("resize", q), window.addEventListener("orientationchange", q), f >= 0 && p(G);
1359
+ window.addEventListener("resize", J), window.addEventListener("orientationchange", J), f >= 0 && p(K);
1336
1360
  }), _(() => {
1337
- window.removeEventListener("resize", q), window.removeEventListener("orientationchange", q), E?.disconnect(), O !== null && cancelAnimationFrame(O), k !== null && clearTimeout(k);
1361
+ window.removeEventListener("resize", J), window.removeEventListener("orientationchange", J), E?.disconnect(), O !== null && cancelAnimationFrame(O), k !== null && clearTimeout(k);
1338
1362
  }), r({
1339
1363
  activeIndex: h,
1340
1364
  activePostId: F,
1341
- changeActiveMedia: oe,
1342
- loadIfNearBottom: ae,
1343
- moveActivePost: Y
1365
+ changeActiveMedia: ae,
1366
+ loadIfNearBottom: ie,
1367
+ moveActivePost: oe,
1368
+ transitionActiveMedia: le,
1369
+ transitionActivePost: ce
1344
1370
  }), (n, r) => (y(), o("main", {
1345
1371
  class: m(["reel-shell", {
1346
1372
  "reel-shell--has-footer": !!t.cardFooter,
@@ -1376,7 +1402,7 @@ var Oe = /* @__PURE__ */ u({
1376
1402
  class: "gallery-shell reel-feed",
1377
1403
  "data-active-post-id": F.value,
1378
1404
  "data-active-media-index": L.value,
1379
- onScrollPassive: ie
1405
+ onScrollPassive: re
1380
1406
  }, [t.reelForward.status === "idle" ? (y(), o("section", {
1381
1407
  key: 1,
1382
1408
  class: "reel-track",
@@ -1390,7 +1416,7 @@ var Oe = /* @__PURE__ */ u({
1390
1416
  "fetch-priority": e,
1391
1417
  index: r,
1392
1418
  item: n,
1393
- "item-style": ne(r),
1419
+ "item-style": te(r),
1394
1420
  "media-card": t.mediaCard,
1395
1421
  layout: "reel",
1396
1422
  "loaded-count": t.items.length,
@@ -1399,7 +1425,7 @@ var Oe = /* @__PURE__ */ u({
1399
1425
  "preview-state": t.previewStates.get(T(P)(n.postId, t.mediaIndices.get(n.postId) ?? 0)) ?? "loading",
1400
1426
  total: t.total,
1401
1427
  onMediaChange: (e) => u("mediaChange", n.postId, e),
1402
- onEnded: (e) => ce(n.postId, e),
1428
+ onEnded: (e) => de(n.postId, e),
1403
1429
  onReady: (e) => u("ready", n.postId, e),
1404
1430
  onError: (e) => u("error", n.postId, e)
1405
1431
  }, null, 8, [
@@ -1423,12 +1449,12 @@ var Oe = /* @__PURE__ */ u({
1423
1449
  class: "reel-forward-status",
1424
1450
  role: t.reelForward.status === "error" ? "alert" : "status",
1425
1451
  "data-status": t.reelForward.status
1426
- }, [s("p", null, w(te.value), 1), t.reelForward.status === "error" || t.reelForward.status === "end" ? (y(), o("button", {
1452
+ }, [s("p", null, w(ee.value), 1), t.reelForward.status === "error" || t.reelForward.status === "end" ? (y(), o("button", {
1427
1453
  key: 0,
1428
1454
  class: "reel-forward-retry",
1429
1455
  type: "button",
1430
1456
  onClick: r[0] ||= (e) => u("retryForward")
1431
- }, " Retry ")) : a("", !0)], 8, ut)), t.reelForward.status === "idle" ? (y(), i(ee, {
1457
+ }, " Retry ")) : a("", !0)], 8, ft)), t.reelForward.status === "idle" ? (y(), i(H, {
1432
1458
  key: 2,
1433
1459
  actions: t.feedFooterActions,
1434
1460
  "can-retry-end": t.canRetryEnd,
@@ -1449,7 +1475,7 @@ var Oe = /* @__PURE__ */ u({
1449
1475
  "is-loading",
1450
1476
  "load-more-locked",
1451
1477
  "state"
1452
- ])) : a("", !0)], 40, lt),
1478
+ ])) : a("", !0)], 40, dt),
1453
1479
  t.cardFooter && I.value && t.reelForward.status === "idle" ? (y(), i(Oe, {
1454
1480
  key: 1,
1455
1481
  index: h.value,
@@ -1472,24 +1498,24 @@ var Oe = /* @__PURE__ */ u({
1472
1498
  "style",
1473
1499
  "total"
1474
1500
  ])) : a("", !0),
1475
- U.value ? (y(), i(ct, {
1501
+ W.value ? (y(), i(ut, {
1476
1502
  key: V.value,
1477
1503
  "duration-ms": t.reelAutoAdvance.intervalMs,
1478
- label: H.value,
1479
- onComplete: se
1504
+ label: U.value,
1505
+ onComplete: ue
1480
1506
  }, null, 8, ["duration-ms", "label"])) : a("", !0)
1481
1507
  ], 2));
1482
1508
  }
1483
- }), pt = ["data-info-sheet-open", "data-info-sheet-mode"], mt = ["aria-hidden", "inert"], ht = {
1509
+ }), gt = ["data-info-sheet-open", "data-info-sheet-mode"], _t = ["aria-hidden", "inert"], vt = {
1484
1510
  key: 0,
1485
1511
  class: "reel-info-sheet-layer",
1486
1512
  "data-test": "reel-info-sheet"
1487
- }, gt = [
1513
+ }, yt = [
1488
1514
  "role",
1489
1515
  "aria-modal",
1490
1516
  "tabindex",
1491
1517
  "data-active-post-id"
1492
- ], _t = /* @__PURE__ */ u({
1518
+ ], bt = /* @__PURE__ */ u({
1493
1519
  __name: "ReelLayout",
1494
1520
  props: {
1495
1521
  forwardIndex: { default: null },
@@ -1567,13 +1593,19 @@ var Oe = /* @__PURE__ */ u({
1567
1593
  function L(e) {
1568
1594
  return g.value?.moveActivePost(e) ?? !1;
1569
1595
  }
1570
- function R(e, t) {
1596
+ function R(e) {
1597
+ return g.value?.transitionActiveMedia(e) ?? Promise.resolve(!1);
1598
+ }
1599
+ function z(e) {
1600
+ return g.value?.transitionActivePost(e) ?? Promise.resolve(!1);
1601
+ }
1602
+ function B(e, t) {
1571
1603
  f("error", e, t);
1572
1604
  }
1573
- function z(e, t) {
1605
+ function V(e, t) {
1574
1606
  f("mediaChange", e, t);
1575
1607
  }
1576
- function B(e, t) {
1608
+ function H(e, t) {
1577
1609
  f("ready", e, t);
1578
1610
  }
1579
1611
  return D(() => ({
@@ -1593,7 +1625,9 @@ var Oe = /* @__PURE__ */ u({
1593
1625
  }), r({
1594
1626
  changeActiveMedia: F,
1595
1627
  loadIfNearBottom: I,
1596
- moveActivePost: L
1628
+ moveActivePost: L,
1629
+ transitionActiveMedia: R,
1630
+ transitionActivePost: z
1597
1631
  }), (n, r) => (y(), o("section", {
1598
1632
  class: m(["reel-layout", `reel-layout--${e.infoSheetOverlay ? "overlay" : "layout"}`]),
1599
1633
  "data-info-sheet-open": A.value || void 0,
@@ -1602,7 +1636,7 @@ var Oe = /* @__PURE__ */ u({
1602
1636
  class: "reel-layout-main",
1603
1637
  "aria-hidden": e.infoSheetOverlay && A.value || void 0,
1604
1638
  inert: e.infoSheetOverlay && A.value || void 0
1605
- }, [l(ft, {
1639
+ }, [l(ht, {
1606
1640
  ref_key: "reelFeed",
1607
1641
  ref: g,
1608
1642
  "can-retry-end": e.canRetryEnd,
@@ -1626,10 +1660,10 @@ var Oe = /* @__PURE__ */ u({
1626
1660
  state: e.state,
1627
1661
  total: e.total,
1628
1662
  onActiveChange: r[0] ||= (e) => f("activeChange", e),
1629
- onError: R,
1663
+ onError: B,
1630
1664
  onLoadMore: r[1] ||= (e) => f("loadMore"),
1631
- onMediaChange: z,
1632
- onReady: B,
1665
+ onMediaChange: V,
1666
+ onReady: H,
1633
1667
  onRetryEnd: r[2] ||= (e) => f("retryEnd"),
1634
1668
  onRetryForward: r[3] ||= (e) => f("retryForward")
1635
1669
  }, null, 8, [
@@ -1653,8 +1687,8 @@ var Oe = /* @__PURE__ */ u({
1653
1687
  "reel-forward",
1654
1688
  "state",
1655
1689
  "total"
1656
- ])], 8, mt), l(t, { name: "vibe-info-sheet" }, {
1657
- default: O(() => [A.value && e.infoSheet && M.value ? (y(), o("div", ht, [s("aside", {
1690
+ ])], 8, _t), l(t, { name: "vibe-info-sheet" }, {
1691
+ default: O(() => [A.value && e.infoSheet && M.value ? (y(), o("div", vt, [s("aside", {
1658
1692
  ref_key: "sheetElement",
1659
1693
  ref: v,
1660
1694
  class: "reel-info-sheet",
@@ -1663,11 +1697,11 @@ var Oe = /* @__PURE__ */ u({
1663
1697
  "aria-modal": e.infoSheetOverlay ? "true" : void 0,
1664
1698
  tabindex: e.infoSheetOverlay ? -1 : void 0,
1665
1699
  "data-active-post-id": T.value?.postId
1666
- }, [(y(), i(S(e.infoSheet.component), h(d(M.value)), null, 16))], 8, gt)])) : a("", !0)]),
1700
+ }, [(y(), i(S(e.infoSheet.component), h(d(M.value)), null, 16))], 8, yt)])) : a("", !0)]),
1667
1701
  _: 1
1668
- })], 10, pt));
1702
+ })], 10, gt));
1669
1703
  }
1670
- }), vt = 35, yt = 420, bt = /* @__PURE__ */ u({
1704
+ }), xt = 35, St = 420, Ct = /* @__PURE__ */ u({
1671
1705
  __name: "VibeSurface",
1672
1706
  props: {
1673
1707
  canRetryEnd: { type: Boolean },
@@ -1693,63 +1727,63 @@ var Oe = /* @__PURE__ */ u({
1693
1727
  function V() {
1694
1728
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1695
1729
  }
1696
- function ee() {
1730
+ function H() {
1697
1731
  R !== null && cancelAnimationFrame(R), R = requestAnimationFrame(() => {
1698
1732
  R = requestAnimationFrame(() => {
1699
1733
  R = null, w.value = /* @__PURE__ */ new Set();
1700
1734
  });
1701
1735
  });
1702
1736
  }
1703
- function H(e, t, n) {
1737
+ function U(e, t, n) {
1704
1738
  let r = P(e, t);
1705
1739
  A.value.get(r) !== n && (A.value = new Map(A.value).set(r, n));
1706
1740
  }
1707
- function U(e, t, n) {
1741
+ function W(e, t, n) {
1708
1742
  let r = P(e, t);
1709
1743
  j.value.get(r) !== n && (j.value = new Map(j.value).set(r, n));
1710
1744
  }
1711
- function W(e, t) {
1712
- H(e, t, "error");
1745
+ function G(e, t) {
1746
+ U(e, t, "error");
1747
+ }
1748
+ function te(e, t) {
1749
+ U(e, t, "ready");
1713
1750
  }
1714
1751
  function ne(e, t) {
1715
- H(e, t, "ready");
1752
+ W(e, t, "error");
1716
1753
  }
1717
1754
  function re(e, t) {
1718
- U(e, t, "error");
1755
+ W(e, t, "ready");
1719
1756
  }
1720
- function ie(e, t) {
1721
- U(e, t, "ready");
1722
- }
1723
- function G(e, t) {
1757
+ function K(e, t) {
1724
1758
  if (u.state.reelMediaSource === "original") {
1725
- re(e, t);
1759
+ ne(e, t);
1726
1760
  return;
1727
1761
  }
1728
- W(e, t);
1762
+ G(e, t);
1729
1763
  }
1730
- function K(e, t) {
1764
+ function q(e, t) {
1731
1765
  if (u.state.reelMediaSource === "original") {
1732
- ie(e, t);
1766
+ re(e, t);
1733
1767
  return;
1734
1768
  }
1735
- ne(e, t);
1769
+ te(e, t);
1736
1770
  }
1737
- function q(e, t) {
1771
+ function J(e, t) {
1738
1772
  let n = u.state.items.find((t) => t.postId === e);
1739
1773
  if (!n) return;
1740
1774
  let r = M(n, t);
1741
1775
  (u.state.mediaIndices.get(e) ?? 0) !== r && (u.state.mediaIndices = new Map(u.state.mediaIndices).set(e, r));
1742
1776
  }
1743
- async function J() {
1777
+ async function Y() {
1744
1778
  await p(), (u.state.layout === "reel" || u.state.reelOrigin === "masonry" ? m.value : f.value)?.loadIfNearBottom();
1745
1779
  }
1746
- function ae(e) {
1780
+ function ie(e) {
1747
1781
  return u.state.isLoading || u.state.items.length === 0 || u.state.layout !== "reel" && u.state.reelOrigin !== "masonry" ? !1 : m.value?.changeActiveMedia?.(e) ?? !1;
1748
1782
  }
1749
- function oe(e) {
1783
+ function ae(e) {
1750
1784
  return u.state.isLoading || u.state.items.length === 0 || u.state.layout !== "reel" && u.state.reelOrigin !== "masonry" ? !1 : m.value?.moveActivePost?.(e) ?? !1;
1751
1785
  }
1752
- function Y() {
1786
+ function oe() {
1753
1787
  return u.state.layout !== "masonry" || u.state.reelOrigin === "masonry" ? null : f.value?.getScrollElement?.() ?? null;
1754
1788
  }
1755
1789
  function X(e, t) {
@@ -1765,8 +1799,8 @@ var Oe = /* @__PURE__ */ u({
1765
1799
  if (n.length === 0) return 0;
1766
1800
  let r = new Map(k.value);
1767
1801
  return n.forEach((e, t) => {
1768
- r.set(e, t * vt);
1769
- }), w.value = new Set([...w.value].filter((e) => !n.includes(e))), E.value = new Set([...E.value, ...t]), k.value = r, yt + (n.length - 1) * vt;
1802
+ r.set(e, t * xt);
1803
+ }), w.value = new Set([...w.value].filter((e) => !n.includes(e))), E.value = new Set([...E.value, ...t]), k.value = r, St + (n.length - 1) * xt;
1770
1804
  }
1771
1805
  function ce(e, t) {
1772
1806
  let n = Z(e), r = n?.querySelector(".media-card-activator") ?? n;
@@ -1822,21 +1856,23 @@ var Oe = /* @__PURE__ */ u({
1822
1856
  let t = T.value.get(e);
1823
1857
  t !== void 0 && r.set(e, t);
1824
1858
  }), t.forEach((e, t) => {
1825
- r.set(e, t * vt);
1826
- }), T.value = r, w.value = new Set([...w.value, ...t]), ee();
1859
+ r.set(e, t * xt);
1860
+ }), T.value = r, w.value = new Set([...w.value, ...t]), H();
1827
1861
  }, { flush: "sync" }), v(() => window.addEventListener("keydown", fe)), _(() => {
1828
1862
  window.removeEventListener("keydown", fe), R !== null && cancelAnimationFrame(R);
1829
1863
  }), s({
1830
- changeActiveReelMedia: ae,
1831
- getAutoScrollElement: Y,
1832
- loadIfNearBottom: J,
1833
- moveActiveReelPost: oe,
1834
- startItemRemoval: se
1864
+ changeActiveReelMedia: ie,
1865
+ getAutoScrollElement: oe,
1866
+ loadIfNearBottom: Y,
1867
+ moveActiveReelPost: ae,
1868
+ startItemRemoval: se,
1869
+ transitionActiveReelMedia: (e) => m.value?.transitionActiveMedia?.(e) ?? Promise.resolve(!1),
1870
+ transitionActiveReelPost: (e) => m.value?.transitionActivePost?.(e) ?? Promise.resolve(!1)
1835
1871
  }), (n, s) => (y(), o("div", {
1836
1872
  ref_key: "surfaceElement",
1837
1873
  ref: b,
1838
1874
  class: "vibe-surface"
1839
- }, [r.state.layout === "reel" && (r.state.items.length > 0 || r.state.reelForward.status !== "idle") ? (y(), i(_t, {
1875
+ }, [r.state.layout === "reel" && (r.state.items.length > 0 || r.state.reelForward.status !== "idle") ? (y(), i(bt, {
1840
1876
  key: 0,
1841
1877
  ref_key: "reelRenderer",
1842
1878
  ref: m,
@@ -1868,10 +1904,10 @@ var Oe = /* @__PURE__ */ u({
1868
1904
  total: r.state.total,
1869
1905
  onActiveChange: s[0] ||= (e) => d("activeReelChange", e),
1870
1906
  onCloseInfoSheet: s[1] ||= (e) => d("reelInfoSheetChange", !1),
1871
- onError: G,
1907
+ onError: K,
1872
1908
  onLoadMore: s[2] ||= (e) => d("loadMore"),
1873
- onMediaChange: q,
1874
- onReady: K,
1909
+ onMediaChange: J,
1910
+ onReady: q,
1875
1911
  onRetryEnd: s[3] ||= (e) => d("retryEnd"),
1876
1912
  onRetryForward: s[4] ||= (e) => d("retryForward")
1877
1913
  }, null, 8, [
@@ -1900,7 +1936,7 @@ var Oe = /* @__PURE__ */ u({
1900
1936
  "reel-forward",
1901
1937
  "state",
1902
1938
  "total"
1903
- ])) : r.state.error || r.state.isLoading || r.state.items.length === 0 && r.state.reelForward.status === "idle" ? (y(), i(te, {
1939
+ ])) : r.state.error || r.state.isLoading || r.state.items.length === 0 && r.state.reelForward.status === "idle" ? (y(), i(ee, {
1904
1940
  key: 1,
1905
1941
  actions: r.feedFooterActions,
1906
1942
  "can-retry-end": r.canRetryEnd,
@@ -1938,10 +1974,10 @@ var Oe = /* @__PURE__ */ u({
1938
1974
  state: N.value,
1939
1975
  total: r.state.total,
1940
1976
  onActivate: X,
1941
- onError: W,
1977
+ onError: G,
1942
1978
  onLoadMore: s[7] ||= (e) => d("loadMore"),
1943
- onMediaChange: q,
1944
- onReady: ne,
1979
+ onMediaChange: J,
1980
+ onReady: te,
1945
1981
  onRetryEnd: s[8] ||= (e) => d("retryEnd")
1946
1982
  }, null, 8, [
1947
1983
  "can-retry-end",
@@ -1979,7 +2015,7 @@ var Oe = /* @__PURE__ */ u({
1979
2015
  "aria-modal": "true",
1980
2016
  tabindex: "-1",
1981
2017
  style: g(x.value)
1982
- }, [l(_t, {
2018
+ }, [l(bt, {
1983
2019
  ref_key: "reelRenderer",
1984
2020
  ref: m,
1985
2021
  "can-retry-end": r.canRetryEnd,
@@ -2010,10 +2046,10 @@ var Oe = /* @__PURE__ */ u({
2010
2046
  total: r.state.total,
2011
2047
  onActiveChange: s[9] ||= (e) => d("activeReelChange", e),
2012
2048
  onCloseInfoSheet: s[10] ||= (e) => d("reelInfoSheetChange", !1),
2013
- onError: re,
2049
+ onError: ne,
2014
2050
  onLoadMore: s[11] ||= (e) => d("loadMore"),
2015
- onMediaChange: q,
2016
- onReady: ie,
2051
+ onMediaChange: J,
2052
+ onReady: re,
2017
2053
  onRetryEnd: s[12] ||= (e) => d("retryEnd"),
2018
2054
  onRetryForward: s[13] ||= (e) => d("retryForward")
2019
2055
  }, null, 8, [
@@ -2048,7 +2084,7 @@ var Oe = /* @__PURE__ */ u({
2048
2084
  });
2049
2085
  //#endregion
2050
2086
  //#region src/core/page.ts
2051
- function xt(e) {
2087
+ function wt(e) {
2052
2088
  if (!e || typeof e != "object" || !Array.isArray(e.items)) throw TypeError("Vibe loadPage must resolve to a page with an items array.");
2053
2089
  if (e.next !== null && typeof e.next != "string" && typeof e.next != "number") throw TypeError("Vibe page next must be a string, number, or null.");
2054
2090
  if (e.total !== void 0 && (!Number.isFinite(e.total) || e.total < 0)) throw TypeError("Vibe page total must be a non-negative number when provided.");
@@ -2060,32 +2096,32 @@ function Q(e, t) {
2060
2096
  }
2061
2097
  //#endregion
2062
2098
  //#region src/core/requestDelay.ts
2063
- var St = 2e3, Ct = 1e4, wt = 250, Tt = {
2099
+ var Tt = 2e3, Et = 1e4, Dt = 250, Ot = {
2064
2100
  delayRemainingMs: null,
2065
2101
  nextRequestAt: null
2066
2102
  };
2067
- function Et(e, t) {
2103
+ function kt(e, t) {
2068
2104
  return e === void 0 ? t : Math.floor(e);
2069
2105
  }
2070
- function Dt(e, t) {
2106
+ function At(e, t) {
2071
2107
  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.`);
2072
2108
  }
2073
- function Ot(e, t = {}) {
2074
- let n = Et(t.delayStepMs, St), r = Et(t.delayMaxMs, Ct);
2109
+ function jt(e, t = {}) {
2110
+ let n = kt(t.delayStepMs, Tt), r = kt(t.delayMaxMs, Et);
2075
2111
  return Math.min(Math.max(0, e) * n, r);
2076
2112
  }
2077
2113
  function $(e) {
2078
- if (e == null || !Number.isFinite(e)) return { ...Tt };
2114
+ if (e == null || !Number.isFinite(e)) return { ...Ot };
2079
2115
  let t = Math.max(0, Math.floor(e - Date.now()));
2080
2116
  return t > 0 ? {
2081
2117
  delayRemainingMs: t,
2082
2118
  nextRequestAt: e
2083
- } : { ...Tt };
2119
+ } : { ...Ot };
2084
2120
  }
2085
- async function kt({ delayMs: e, onChange: t, signal: n }) {
2121
+ async function Mt({ delayMs: e, onChange: t, signal: n }) {
2086
2122
  if (n.aborted) throw new DOMException("Aborted", "AbortError");
2087
2123
  if (e <= 0) {
2088
- t({ ...Tt });
2124
+ t({ ...Ot });
2089
2125
  return;
2090
2126
  }
2091
2127
  let r = Date.now() + e;
@@ -2093,9 +2129,9 @@ async function kt({ delayMs: e, onChange: t, signal: n }) {
2093
2129
  delayRemainingMs: e,
2094
2130
  nextRequestAt: r
2095
2131
  }), await new Promise((i, a) => {
2096
- let o = !1, s = setInterval(f, wt), c = setTimeout(() => u(), e);
2132
+ let o = !1, s = setInterval(f, Dt), c = setTimeout(() => u(), e);
2097
2133
  function l() {
2098
- clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Tt });
2134
+ clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Ot });
2099
2135
  }
2100
2136
  function u(e) {
2101
2137
  o || (o = !0, l(), e ? a(e) : i());
@@ -2110,13 +2146,13 @@ async function kt({ delayMs: e, onChange: t, signal: n }) {
2110
2146
  n.addEventListener("abort", d, { once: !0 });
2111
2147
  });
2112
2148
  }
2113
- var At = class {
2149
+ var Nt = class {
2114
2150
  interval = null;
2115
2151
  constructor(e) {
2116
2152
  this.onChange = e;
2117
2153
  }
2118
2154
  clear() {
2119
- this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Tt });
2155
+ this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Ot });
2120
2156
  }
2121
2157
  sync(e) {
2122
2158
  this.clear();
@@ -2124,22 +2160,22 @@ var At = class {
2124
2160
  this.onChange(t), t.delayRemainingMs !== null && (this.interval = setInterval(() => {
2125
2161
  let t = $(e);
2126
2162
  this.onChange(t), t.delayRemainingMs === null && this.clear();
2127
- }, wt));
2163
+ }, Dt));
2128
2164
  }
2129
2165
  };
2130
- function jt(e, t = !0) {
2166
+ function Pt(e, t = !0) {
2131
2167
  return e.maxAdditionalPages === "unlimited" ? Infinity : (e.maxAdditionalPages ?? 10) + (t ? 1 : 0);
2132
2168
  }
2133
- function Mt(e) {
2169
+ function Ft(e) {
2134
2170
  return `${typeof e}:${String(e)}`;
2135
2171
  }
2136
- function Nt(e, t) {
2172
+ function It(e, t) {
2137
2173
  if (!Number.isInteger(e) || e <= 0) throw TypeError(`Vibe ${t} must be a positive integer.`);
2138
2174
  }
2139
- function Pt(e) {
2175
+ function Lt(e) {
2140
2176
  if (!e) return;
2141
- if (Nt(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2142
- Dt(e, "frontend autofill");
2177
+ if (It(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2178
+ At(e, "frontend autofill");
2143
2179
  let t = e.maxAdditionalPages;
2144
2180
  if (t !== void 0 && t !== "unlimited" && (!Number.isInteger(t) || t < 0)) throw TypeError("Vibe autofill maxAdditionalPages must be a non-negative integer or \"unlimited\".");
2145
2181
  return;
@@ -2151,7 +2187,7 @@ function Pt(e) {
2151
2187
  if (t.pageSize !== e.pageSize) throw TypeError("Vibe backend autofill initialSession pageSize must match autofill pageSize.");
2152
2188
  }
2153
2189
  }
2154
- function Ft(e, t, n = !0) {
2190
+ function Rt(e, t, n = !0) {
2155
2191
  if (!e) return {
2156
2192
  cycleId: null,
2157
2193
  delayRemainingMs: null,
@@ -2185,7 +2221,7 @@ function Ft(e, t, n = !0) {
2185
2221
  strategy: e.strategy
2186
2222
  };
2187
2223
  }
2188
- function It(e) {
2224
+ function zt(e) {
2189
2225
  return [
2190
2226
  "cancelling",
2191
2227
  "filling",
@@ -2193,9 +2229,9 @@ function It(e) {
2193
2229
  "waiting"
2194
2230
  ].includes(e.status);
2195
2231
  }
2196
- async function Lt(e, t, n) {
2232
+ async function Bt(e, t, n) {
2197
2233
  let r = t.autofill;
2198
- if (!It(r) || !r.cycleId) return;
2234
+ if (!zt(r) || !r.cycleId) return;
2199
2235
  let i = {
2200
2236
  cycleId: r.cycleId,
2201
2237
  feedKey: r.feedKey ?? "",
@@ -2208,20 +2244,20 @@ async function Lt(e, t, n) {
2208
2244
  throw r.error = e, r.status = "error", e;
2209
2245
  }
2210
2246
  }
2211
- function Rt(e, t, n) {
2247
+ function Vt(e, t, n) {
2212
2248
  return e?.strategy === "backend" && t.feedKey === e.feedKey && t.sessionId === n.sessionId;
2213
2249
  }
2214
- async function zt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onDelayChange: i, onProgress: a, options: o, receivedOffset: s = 0, requestOffset: c = 0, signal: l }) {
2215
- let u = [], d = [...e], f = /* @__PURE__ */ new Set(), p = r ?? jt(o), m = t, h = t, g = 0, _;
2250
+ async function Ht({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onDelayChange: i, onProgress: a, options: o, receivedOffset: s = 0, requestOffset: c = 0, signal: l }) {
2251
+ let u = [], d = [...e], f = /* @__PURE__ */ new Set(), p = r ?? Pt(o), m = t, h = t, g = 0, _;
2216
2252
  for (; g < p;) {
2217
- let e = Mt(m);
2253
+ let e = Ft(m);
2218
2254
  if (f.has(e)) throw Error("Vibe autofill received a repeated cursor.");
2219
- f.add(e), await kt({
2220
- delayMs: Ot(c + g, o),
2255
+ f.add(e), await Mt({
2256
+ delayMs: jt(c + g, o),
2221
2257
  onChange: i,
2222
2258
  signal: l
2223
2259
  });
2224
- let t = xt(await n({
2260
+ let t = wt(await n({
2225
2261
  cursor: m,
2226
2262
  signal: l
2227
2263
  }));
@@ -2261,30 +2297,30 @@ async function zt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
2261
2297
  total: _
2262
2298
  };
2263
2299
  }
2264
- var Bt = 100;
2265
- function Vt(e, t) {
2300
+ var Ut = 100;
2301
+ function Wt(e, t) {
2266
2302
  if (!Number.isFinite(t) || t <= 0) throw TypeError(`Vibe ${e} must be a positive number.`);
2267
2303
  }
2268
- function Ht(e, t, n) {
2304
+ function Gt(e, t, n) {
2269
2305
  return Math.min(n, Math.max(t, e));
2270
2306
  }
2271
- function Ut(e) {
2307
+ function Kt(e) {
2272
2308
  if (!e) return;
2273
2309
  let t = e.minSpeedPxPerSecond ?? 20, n = e.maxSpeedPxPerSecond ?? 240;
2274
- if (Vt("autoScroll.minSpeedPxPerSecond", t), Vt("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2275
- e.speedPxPerSecond !== void 0 && Vt("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2310
+ if (Wt("autoScroll.minSpeedPxPerSecond", t), Wt("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2311
+ e.speedPxPerSecond !== void 0 && Wt("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2276
2312
  }
2277
- function Wt(e) {
2313
+ function qt(e) {
2278
2314
  let t = e?.minSpeedPxPerSecond ?? 20, n = e?.maxSpeedPxPerSecond ?? 240;
2279
2315
  return {
2280
2316
  enabled: e?.enabled ?? !1,
2281
2317
  maxSpeedPxPerSecond: n,
2282
2318
  minSpeedPxPerSecond: t,
2283
2319
  paused: !1,
2284
- speedPxPerSecond: Ht(e?.speedPxPerSecond ?? 80, t, n)
2320
+ speedPxPerSecond: Gt(e?.speedPxPerSecond ?? 80, t, n)
2285
2321
  };
2286
2322
  }
2287
- var Gt = class {
2323
+ var Jt = class {
2288
2324
  frame = null;
2289
2325
  lastTimestamp = null;
2290
2326
  mounted = !1;
@@ -2304,9 +2340,9 @@ var Gt = class {
2304
2340
  this.options.state.enabled && (this.options.state.paused = e, this.lastTimestamp = null, e ? this.cancelFrame() : this.schedule());
2305
2341
  }
2306
2342
  setSpeed(e) {
2307
- Vt("auto-scroll speed", e);
2343
+ Wt("auto-scroll speed", e);
2308
2344
  let t = this.options.state;
2309
- t.speedPxPerSecond = Ht(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2345
+ t.speedPxPerSecond = Gt(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2310
2346
  }
2311
2347
  tick = (e) => {
2312
2348
  this.frame = null;
@@ -2318,7 +2354,7 @@ var Gt = class {
2318
2354
  return;
2319
2355
  }
2320
2356
  if (this.lastTimestamp !== null) {
2321
- let r = Math.min(Bt, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2357
+ let r = Math.min(Ut, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2322
2358
  n.scrollTop = Math.min(i, n.scrollTop + t.speedPxPerSecond * r / 1e3);
2323
2359
  }
2324
2360
  this.lastTimestamp = e, this.schedule();
@@ -2332,7 +2368,7 @@ var Gt = class {
2332
2368
  };
2333
2369
  //#endregion
2334
2370
  //#region src/core/backendAutofill.ts
2335
- async function Kt(e, t, n, r) {
2371
+ async function Yt(e, t, n, r) {
2336
2372
  let i = await e.onUnderfilled(n);
2337
2373
  if (!r()) return;
2338
2374
  if (!i.sessionId.trim()) throw TypeError("Vibe backend autofill requires a sessionId.");
@@ -2346,19 +2382,19 @@ async function Kt(e, t, n, r) {
2346
2382
  status: "waiting"
2347
2383
  });
2348
2384
  }
2349
- function qt(e, t) {
2385
+ function Xt(e, t) {
2350
2386
  ["complete", "exhausted"].includes(t.status) && t.items && (e.items = Q(e.items, t.items)), t.next !== void 0 && (e.next = t.next), t.total !== void 0 && (e.total = t.total);
2351
2387
  }
2352
- function Jt(e, t, n) {
2388
+ function Zt(e, t, n) {
2353
2389
  let r = t.autofill;
2354
- return !Rt(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (qt(t, n), Object.assign(r, $(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);
2390
+ return !Vt(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (Xt(t, n), Object.assign(r, $(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);
2355
2391
  }
2356
- function Yt(e, t, n) {
2357
- return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Ft(e, n), qt(t, n), !0);
2392
+ function Qt(e, t, n) {
2393
+ return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Rt(e, n), Xt(t, n), !0);
2358
2394
  }
2359
2395
  //#endregion
2360
2396
  //#region src/core/initialAutofill.ts
2361
- async function Xt({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signal: i, state: a }) {
2397
+ async function $t({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signal: i, state: a }) {
2362
2398
  let o = r.autofill;
2363
2399
  if (!o) return;
2364
2400
  let s = a.items.length;
@@ -2371,7 +2407,7 @@ async function Xt({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
2371
2407
  return;
2372
2408
  }
2373
2409
  if (o.strategy === "backend") {
2374
- await Kt(o, a, {
2410
+ await Yt(o, a, {
2375
2411
  cycleId: e,
2376
2412
  feedKey: o.feedKey,
2377
2413
  items: [...a.items],
@@ -2388,11 +2424,11 @@ async function Xt({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
2388
2424
  a.autofill.status = "exhausted";
2389
2425
  return;
2390
2426
  }
2391
- let c = await zt({
2427
+ let c = await Ht({
2392
2428
  existingItems: a.items,
2393
2429
  initialCursor: a.next,
2394
2430
  loadPage: r.loadPage,
2395
- maximumRequests: jt(o, !1),
2431
+ maximumRequests: Pt(o, !1),
2396
2432
  onDelayChange: (e) => {
2397
2433
  t() && Object.assign(a.autofill, e);
2398
2434
  },
@@ -2413,13 +2449,13 @@ async function Xt({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
2413
2449
  }
2414
2450
  //#endregion
2415
2451
  //#region src/core/fill.ts
2416
- function Zt(e) {
2452
+ function en(e) {
2417
2453
  return "pages" in e ? { pages: e.pages } : { until: "end" };
2418
2454
  }
2419
- function Qt(e) {
2455
+ function tn(e) {
2420
2456
  return `${typeof e}:${String(e)}`;
2421
2457
  }
2422
- function $t(e) {
2458
+ function nn(e) {
2423
2459
  if (!e || typeof e != "object") throw TypeError("Vibe fill target must be an object.");
2424
2460
  if ("pages" in e) {
2425
2461
  if (!Number.isInteger(e.pages) || e.pages <= 0) throw TypeError("Vibe fill pages must be a positive integer.");
@@ -2428,20 +2464,20 @@ function $t(e) {
2428
2464
  if ("until" in e && e.until === "end") return { until: "end" };
2429
2465
  throw TypeError("Vibe fill target must be { pages } or { until: 'end' }.");
2430
2466
  }
2431
- function en(e) {
2467
+ function rn(e) {
2432
2468
  if (!e) return;
2433
2469
  if (e.strategy === "frontend") {
2434
- Dt(e, "frontend fill");
2470
+ At(e, "frontend fill");
2435
2471
  return;
2436
2472
  }
2437
2473
  if (!e.feedKey.trim()) throw TypeError("Vibe backend fill requires a feedKey.");
2438
2474
  let t = e.initialSession;
2439
2475
  if (t) {
2440
2476
  if (t.feedKey !== e.feedKey) throw TypeError("Vibe backend fill initialSession feedKey must match fill feedKey.");
2441
- $t(t.target);
2477
+ nn(t.target);
2442
2478
  }
2443
2479
  }
2444
- function tn(e, t, n = !0) {
2480
+ function an(e, t, n = !0) {
2445
2481
  let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = $(i?.nextRequestAt);
2446
2482
  return {
2447
2483
  completedPages: i?.completedPages ?? 0,
@@ -2455,10 +2491,10 @@ function tn(e, t, n = !0) {
2455
2491
  sessionId: i?.sessionId ?? null,
2456
2492
  status: i?.status ?? "idle",
2457
2493
  strategy: e?.strategy ?? null,
2458
- target: i ? Zt(i.target) : null
2494
+ target: i ? en(i.target) : null
2459
2495
  };
2460
2496
  }
2461
- function nn(e) {
2497
+ function on(e) {
2462
2498
  return [
2463
2499
  "cancelling",
2464
2500
  "filling",
@@ -2466,17 +2502,17 @@ function nn(e) {
2466
2502
  "waiting"
2467
2503
  ].includes(e.status);
2468
2504
  }
2469
- async function rn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2505
+ async function sn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2470
2506
  let c = [], l = [...e], u = /* @__PURE__ */ new Set(), d = 0, f = t, p = t, m = 0, h;
2471
2507
  for (; p !== null;) {
2472
- let e = Qt(f);
2508
+ let e = tn(f);
2473
2509
  if (u.has(e)) throw Error("Vibe fill received a repeated cursor.");
2474
- u.add(e), await kt({
2475
- delayMs: Ot(d, a),
2510
+ u.add(e), await Mt({
2511
+ delayMs: jt(d, a),
2476
2512
  onChange: r,
2477
2513
  signal: o
2478
2514
  });
2479
- let t = xt(await n({
2515
+ let t = wt(await n({
2480
2516
  cursor: f,
2481
2517
  signal: o
2482
2518
  }));
@@ -2518,7 +2554,7 @@ async function rn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChan
2518
2554
  }
2519
2555
  //#endregion
2520
2556
  //#region src/core/backendFill.ts
2521
- async function an(e, t, n, r) {
2557
+ async function cn(e, t, n, r) {
2522
2558
  let i = await e.onStart(n);
2523
2559
  if (r()) {
2524
2560
  if (!i.sessionId.trim()) throw TypeError("Vibe backend fill requires a sessionId.");
@@ -2532,22 +2568,22 @@ async function an(e, t, n, r) {
2532
2568
  });
2533
2569
  }
2534
2570
  }
2535
- function on(e, t, n) {
2571
+ function ln(e, t, n) {
2536
2572
  return e?.strategy === "backend" && n.feedKey === e.feedKey && n.sessionId === t.fill.sessionId;
2537
2573
  }
2538
- function sn(e) {
2574
+ function un(e) {
2539
2575
  return Number.isInteger(e.completedPages) && e.completedPages >= 0 && Number.isInteger(e.received) && e.received >= 0 && Number.isInteger(e.sequence) && e.sequence >= 0;
2540
2576
  }
2541
- function cn(e, t) {
2577
+ function dn(e, t) {
2542
2578
  if (!["complete", "exhausted"].includes(t.status)) return !0;
2543
2579
  let n = e.fill.target;
2544
2580
  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;
2545
2581
  }
2546
- function ln(e, t, n) {
2582
+ function fn(e, t, n) {
2547
2583
  t.total !== void 0 && (e.total = t.total), ["complete", "exhausted"].includes(t.status) && (e.items = Q(e.items, t.items ?? []), e.next = t.next ?? null, n(t.lastCursor ?? null));
2548
2584
  }
2549
- function un(e, t, n, r) {
2550
- return !on(e, t, n) || !sn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !cn(t, n) ? !1 : (ln(t, n, r), Object.assign(t.fill, {
2585
+ function pn(e, t, n, r) {
2586
+ return !ln(e, t, n) || !un(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !dn(t, n) ? !1 : (fn(t, n, r), Object.assign(t.fill, {
2551
2587
  ...$(n.status === "waiting" ? n.nextRequestAt : null),
2552
2588
  completedPages: n.completedPages,
2553
2589
  error: n.error ?? null,
@@ -2556,41 +2592,41 @@ function un(e, t, n, r) {
2556
2592
  status: n.status
2557
2593
  }), !0);
2558
2594
  }
2559
- function dn(e, t, n, r) {
2595
+ function mn(e, t, n, r) {
2560
2596
  if (e?.strategy !== "backend" || n.feedKey !== e.feedKey) return !1;
2561
2597
  let i = t.fill;
2562
- return t.fill = tn(e, n), !sn(n) || !cn(t, n) ? (t.fill = i, !1) : (ln(t, n, r), !0);
2598
+ return t.fill = an(e, n), !un(n) || !dn(t, n) ? (t.fill = i, !1) : (fn(t, n, r), !0);
2563
2599
  }
2564
2600
  //#endregion
2565
2601
  //#region src/core/fillController.ts
2566
- var fn = class {
2602
+ var hn = class {
2567
2603
  abortController = null;
2568
2604
  cycle = 0;
2569
2605
  delayCountdown;
2570
2606
  requestVersion = 0;
2571
2607
  constructor(e) {
2572
- this.options = e, this.delayCountdown = new At((e) => {
2608
+ this.options = e, this.delayCountdown = new Nt((e) => {
2573
2609
  Object.assign(this.options.state.fill, e);
2574
2610
  }), this.syncBackendCountdown();
2575
2611
  }
2576
2612
  isActive() {
2577
- return nn(this.options.state.fill);
2613
+ return on(this.options.state.fill);
2578
2614
  }
2579
2615
  applyUpdate(e) {
2580
- let t = un(this.options.fill, this.options.state, e, this.options.onLastCursor);
2616
+ let t = pn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2581
2617
  return t && this.syncBackendCountdown(), t;
2582
2618
  }
2583
2619
  restoreSession(e) {
2584
- let t = dn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2620
+ let t = mn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2585
2621
  return t && this.syncBackendCountdown(), t;
2586
2622
  }
2587
2623
  async start(e) {
2588
2624
  let t = this.options.fill;
2589
2625
  if (!t) throw Error("Vibe fill is not configured.");
2590
2626
  if (this.isActive()) throw Error("Vibe fill is already active.");
2591
- let n = $t(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2627
+ let n = nn(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2592
2628
  if (this.options.state.fill = {
2593
- ...tn(t, void 0, !1),
2629
+ ...an(t, void 0, !1),
2594
2630
  cycleId: r,
2595
2631
  status: "filling",
2596
2632
  target: n
@@ -2601,7 +2637,7 @@ var fn = class {
2601
2637
  let i = ++this.requestVersion, a = new AbortController();
2602
2638
  this.abortController = a;
2603
2639
  try {
2604
- t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await an(t, this.options.state, {
2640
+ t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await cn(t, this.options.state, {
2605
2641
  cycleId: r,
2606
2642
  feedKey: t.feedKey,
2607
2643
  items: [...this.options.state.items],
@@ -2619,7 +2655,7 @@ var fn = class {
2619
2655
  }
2620
2656
  async cancel() {
2621
2657
  let { fill: e, state: t } = this.options;
2622
- if (!nn(t.fill) || !t.fill.cycleId) return;
2658
+ if (!on(t.fill) || !t.fill.cycleId) return;
2623
2659
  let n = {
2624
2660
  cycleId: t.fill.cycleId,
2625
2661
  feedKey: t.fill.feedKey ?? "",
@@ -2633,7 +2669,7 @@ var fn = class {
2633
2669
  }
2634
2670
  }
2635
2671
  reset() {
2636
- this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = tn(this.options.fill, void 0, !1);
2672
+ this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = an(this.options.fill, void 0, !1);
2637
2673
  }
2638
2674
  destroy() {
2639
2675
  this.abortLocalRequest(), this.delayCountdown.clear();
@@ -2649,7 +2685,7 @@ var fn = class {
2649
2685
  if (!i) throw Error("Vibe frontend fill requires loadPage.");
2650
2686
  let a = this.options.state;
2651
2687
  a.isLoadingMore = !0;
2652
- let o = await rn({
2688
+ let o = await sn({
2653
2689
  existingItems: a.items,
2654
2690
  initialCursor: a.next,
2655
2691
  loadPage: i,
@@ -2676,7 +2712,7 @@ var fn = class {
2676
2712
  };
2677
2713
  //#endregion
2678
2714
  //#region src/core/feedFooter.ts
2679
- function pn(e) {
2715
+ function gn(e) {
2680
2716
  return {
2681
2717
  cancelAutofill: () => e.cancelAutofill(),
2682
2718
  loadMore: () => e.loadNext(),
@@ -2684,45 +2720,45 @@ function pn(e) {
2684
2720
  retryEnd: () => e.retryEnd()
2685
2721
  };
2686
2722
  }
2687
- function mn(e) {
2723
+ function _n(e) {
2688
2724
  if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
2689
2725
  }
2690
- function hn(e) {
2691
- e?.intervalMs !== void 0 && mn(e.intervalMs);
2726
+ function vn(e) {
2727
+ e?.intervalMs !== void 0 && _n(e.intervalMs);
2692
2728
  }
2693
- function gn(e) {
2729
+ function yn(e) {
2694
2730
  return {
2695
2731
  enabled: e?.enabled ?? !1,
2696
2732
  includePostItems: e?.includePostItems ?? !1,
2697
2733
  intervalMs: e?.intervalMs ?? 5e3
2698
2734
  };
2699
2735
  }
2700
- function _n(e, t) {
2736
+ function bn(e, t) {
2701
2737
  if (typeof t == "boolean") {
2702
2738
  e.enabled = t;
2703
2739
  return;
2704
2740
  }
2705
- hn(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);
2741
+ vn(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);
2706
2742
  }
2707
2743
  //#endregion
2708
2744
  //#region src/core/reelInfoSheet.ts
2709
- function vn(e) {
2745
+ function xn(e) {
2710
2746
  return { enabled: e?.enabled ?? !1 };
2711
2747
  }
2712
- function yn(e, t, n) {
2748
+ function Sn(e, t, n) {
2713
2749
  if (n && !t) throw Error("Vibe cannot enable reelInfoSheet without a configured component.");
2714
2750
  e.enabled = n;
2715
2751
  }
2716
2752
  //#endregion
2717
2753
  //#region src/core/initialRuntimeState.ts
2718
- function bn(e, t) {
2754
+ function Cn(e, t) {
2719
2755
  let n = e.initialPage;
2720
2756
  return {
2721
2757
  activeReelPostId: null,
2722
- autoScroll: Wt(e.autoScroll),
2723
- autofill: Ft(e.autofill),
2758
+ autoScroll: qt(e.autoScroll),
2759
+ autofill: Rt(e.autofill),
2724
2760
  error: null,
2725
- fill: tn(e.fill),
2761
+ fill: an(e.fill),
2726
2762
  infiniteScroll: e.infiniteScroll ?? !0,
2727
2763
  isLoading: !n,
2728
2764
  isLoadingMore: !1,
@@ -2732,14 +2768,14 @@ function bn(e, t) {
2732
2768
  mediaIndices: /* @__PURE__ */ new Map(),
2733
2769
  next: n?.next ?? null,
2734
2770
  nextPageError: null,
2735
- reelAutoAdvance: gn(e.reelAutoAdvance),
2771
+ reelAutoAdvance: yn(e.reelAutoAdvance),
2736
2772
  reelForward: {
2737
2773
  error: null,
2738
2774
  status: "idle"
2739
2775
  },
2740
2776
  reelForwardIndex: null,
2741
2777
  reelForwardItem: null,
2742
- reelInfoSheet: vn(e.reelInfoSheet),
2778
+ reelInfoSheet: xn(e.reelInfoSheet),
2743
2779
  reelInfoSheetOverlay: !1,
2744
2780
  reelMediaSource: "original",
2745
2781
  reelOrigin: null,
@@ -2748,26 +2784,26 @@ function bn(e, t) {
2748
2784
  }
2749
2785
  //#endregion
2750
2786
  //#region src/core/options.ts
2751
- function xn(e, t) {
2787
+ function wn(e, t) {
2752
2788
  if (t) {
2753
2789
  if (!Number.isFinite(t.height) || t.height <= 0) throw TypeError(`Vibe ${e} height must be a positive number.`);
2754
2790
  if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe ${e} background must be "default" or "transparent".`);
2755
2791
  }
2756
2792
  }
2757
- function Sn(e, t) {
2793
+ function Tn(e, t) {
2758
2794
  if (t) {
2759
2795
  if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe mediaCard ${e} background must be "default" or "transparent".`);
2760
2796
  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.`);
2761
2797
  }
2762
2798
  }
2763
- function Cn(e) {
2764
- if (Ut(e.autoScroll), xn("cardHeader", e.cardHeader), xn("cardFooter", e.cardFooter), Sn("header", e.mediaCard?.header), Sn("footer", e.mediaCard?.footer), Pt(e.autofill), en(e.fill), hn(e.reelAutoAdvance), e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
2799
+ function En(e) {
2800
+ if (Kt(e.autoScroll), wn("cardHeader", e.cardHeader), wn("cardFooter", e.cardFooter), Tn("header", e.mediaCard?.header), Tn("footer", e.mediaCard?.footer), Lt(e.autofill), rn(e.fill), vn(e.reelAutoAdvance), e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
2765
2801
  if (!e.initialPage && !e.loadPage) throw TypeError("Vibe requires either initialPage or loadPage.");
2766
2802
  if (e.initialPage?.next !== null && !e.loadPage) throw TypeError("Vibe requires loadPage when initialPage has a next cursor.");
2767
2803
  if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
2768
2804
  if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
2769
2805
  }
2770
- function wn(e) {
2806
+ function Dn(e) {
2771
2807
  if (typeof e != "string") return e;
2772
2808
  if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
2773
2809
  let t = document.querySelector(e);
@@ -2776,7 +2812,7 @@ function wn(e) {
2776
2812
  }
2777
2813
  //#endregion
2778
2814
  //#region src/core/activeItemRemoval.ts
2779
- function Tn(e, t, n, r, i) {
2815
+ function On(e, t, n, r, i) {
2780
2816
  let a = new Set(t.map(({ item: e }) => e.postId));
2781
2817
  if (e.activeReelPostId === null || !a.has(e.activeReelPostId)) return;
2782
2818
  let o = e.items[Math.max(n, 0)];
@@ -2789,7 +2825,7 @@ function Tn(e, t, n, r, i) {
2789
2825
  }
2790
2826
  //#endregion
2791
2827
  //#region src/core/exactMediaRemovalController.ts
2792
- function En(e, t) {
2828
+ function kn(e, t) {
2793
2829
  let [n, ...r] = t;
2794
2830
  if (!n) throw Error("Vibe items must contain at least one media asset.");
2795
2831
  return {
@@ -2798,10 +2834,10 @@ function En(e, t) {
2798
2834
  items: r
2799
2835
  };
2800
2836
  }
2801
- function Dn(e) {
2837
+ function An(e) {
2802
2838
  if (!Number.isInteger(e.mediaIndex) || e.mediaIndex < 0) throw TypeError("Vibe mediaIndex must be a non-negative integer.");
2803
2839
  }
2804
- var On = class {
2840
+ var jn = class {
2805
2841
  generation = 0;
2806
2842
  metadata = /* @__PURE__ */ new WeakMap();
2807
2843
  state;
@@ -2809,7 +2845,7 @@ var On = class {
2809
2845
  this.options = e, this.state = e.state;
2810
2846
  }
2811
2847
  remove(e) {
2812
- Dn(e);
2848
+ An(e);
2813
2849
  let t = this.state.items.findIndex(({ postId: t }) => t === e.postId), n = this.state.items[t];
2814
2850
  if (!n) return null;
2815
2851
  let r = [...j(n)], i = r[e.mediaIndex];
@@ -2826,7 +2862,7 @@ var On = class {
2826
2862
  restored: !1
2827
2863
  });
2828
2864
  let o = this.state.mediaIndices.get(n.postId) ?? 0, s = this.isReelOpen() && this.state.activeReelPostId === n.postId, c = s && o === e.mediaIndex;
2829
- return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = En(n, r), this.updateMediaIndexAfterRemoval(n.postId, e.mediaIndex, c), a) : (this.state.items.splice(t, 1), this.state.mediaIndices.delete(n.postId), s && this.advanceFromRemovedPost(a, n), a);
2865
+ return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = kn(n, r), this.updateMediaIndexAfterRemoval(n.postId, e.mediaIndex, c), a) : (this.state.items.splice(t, 1), this.state.mediaIndices.delete(n.postId), s && this.advanceFromRemovedPost(a, n), a);
2830
2866
  }
2831
2867
  reset() {
2832
2868
  this.generation += 1;
@@ -2852,7 +2888,7 @@ var On = class {
2852
2888
  }
2853
2889
  restoreIntoPost(e, t) {
2854
2890
  let n = this.state.items[e], r = [...j(n)], i = Math.min(t.mediaIndex, r.length);
2855
- if (r.splice(i, 0, t.media), this.state.items[e] = En(n, r), this.state.activeReelPostId !== t.postId) return;
2891
+ if (r.splice(i, 0, t.media), this.state.items[e] = kn(n, r), this.state.activeReelPostId !== t.postId) return;
2856
2892
  let a = this.state.mediaIndices.get(t.postId) ?? 0;
2857
2893
  a >= i && this.state.mediaIndices.set(t.postId, a + 1);
2858
2894
  }
@@ -2865,18 +2901,18 @@ var On = class {
2865
2901
  };
2866
2902
  //#endregion
2867
2903
  //#region src/core/itemPlacement.ts
2868
- function kn(e, t) {
2904
+ function Mn(e, t) {
2869
2905
  let n = new Set(t);
2870
2906
  return e.flatMap((e, t) => n.has(e.postId) ? [{
2871
2907
  index: t,
2872
2908
  item: e
2873
2909
  }] : []);
2874
2910
  }
2875
- function An(e, t) {
2911
+ function Nn(e, t) {
2876
2912
  let n = new Set(t.map(({ item: e }) => e.postId));
2877
2913
  return e.filter((e) => !n.has(e.postId));
2878
2914
  }
2879
- function jn(e, t) {
2915
+ function Pn(e, t) {
2880
2916
  t.forEach(({ index: e }) => {
2881
2917
  if (!Number.isInteger(e) || e < 0) throw Error("Vibe item restore indexes must be non-negative integers.");
2882
2918
  });
@@ -2887,7 +2923,7 @@ function jn(e, t) {
2887
2923
  }
2888
2924
  //#endregion
2889
2925
  //#region src/core/itemRemovalController.ts
2890
- var Mn = 20, Nn = class {
2926
+ var Fn = 20, In = class {
2891
2927
  generation = 0;
2892
2928
  historyLimit;
2893
2929
  metadata = /* @__PURE__ */ new WeakMap();
@@ -2896,7 +2932,7 @@ var Mn = 20, Nn = class {
2896
2932
  itemOrder;
2897
2933
  stopItemsWatcher;
2898
2934
  constructor(e) {
2899
- this.options = e, this.historyLimit = e.historyLimit ?? Mn, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = D(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
2935
+ this.options = e, this.historyLimit = e.historyLimit ?? Fn, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = D(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
2900
2936
  }
2901
2937
  destroy() {
2902
2938
  this.reset(), this.stopItemsWatcher();
@@ -2904,10 +2940,12 @@ var Mn = 20, Nn = class {
2904
2940
  async remove(e) {
2905
2941
  let t = this.collectOrderedPlacements(e), n = this.createRemoval(t);
2906
2942
  if (t.length === 0) return n;
2907
- let r = t.map(({ item: e }) => e.postId), i = this.options.startRemoval(r);
2943
+ let r = t.map(({ item: e }) => e.postId);
2944
+ if (await this.options.prepareRemoval(r), this.metadata.get(n)?.generation !== this.generation) return n;
2945
+ let i = this.options.startRemoval(r);
2908
2946
  if (i > 0 && await new Promise((e) => setTimeout(e, i)), this.metadata.get(n)?.generation !== this.generation) return n;
2909
2947
  let a = this.state.items.findIndex((e) => e.postId === this.state.activeReelPostId), o = new Set(t.map(({ item: e }) => e.postId)), s = a < 0 ? 0 : this.state.items.slice(0, a).filter(({ postId: e }) => o.has(e)).length, c = Math.max(a - s, 0);
2910
- return this.state.items = An(this.state.items, t), this.options.onItemsRemoved(n, t, c), this.record(n), n;
2948
+ return this.state.items = Nn(this.state.items, t), this.options.onItemsRemoved(n, t, c), this.record(n), n;
2911
2949
  }
2912
2950
  reset() {
2913
2951
  this.generation += 1, this.history = [], this.itemOrder = [];
@@ -2918,7 +2956,7 @@ var Mn = 20, Nn = class {
2918
2956
  this.restoreRemoval(t);
2919
2957
  return;
2920
2958
  }
2921
- let n = jn(this.state.items, e);
2959
+ let n = Pn(this.state.items, e);
2922
2960
  this.registerExternalPlacements(e), this.state.items = n;
2923
2961
  }
2924
2962
  restoreRemoval(e) {
@@ -2944,7 +2982,7 @@ var Mn = 20, Nn = class {
2944
2982
  }
2945
2983
  collectOrderedPlacements(e) {
2946
2984
  let t = new Map(this.itemOrder.map((e, t) => [e, t]));
2947
- return kn(this.state.items, e).map((e) => ({
2985
+ return Mn(this.state.items, e).map((e) => ({
2948
2986
  index: t.get(e.item.postId) ?? e.index,
2949
2987
  item: e.item
2950
2988
  }));
@@ -2975,7 +3013,7 @@ var Mn = 20, Nn = class {
2975
3013
  let r = new Map(this.itemOrder.map((e, t) => [e, t]));
2976
3014
  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;
2977
3015
  }
2978
- }, Pn = class {
3016
+ }, Ln = class {
2979
3017
  forward = null;
2980
3018
  forwardPromise = null;
2981
3019
  forwardVersion = 0;
@@ -3053,43 +3091,96 @@ var Mn = 20, Nn = class {
3053
3091
  }
3054
3092
  }
3055
3093
  }
3094
+ }, Rn = class {
3095
+ generation = 0;
3096
+ pending = Promise.resolve();
3097
+ constructor(e) {
3098
+ this.options = e;
3099
+ }
3100
+ prepareItems(e) {
3101
+ return this.serialize(() => this.preparePosts(e));
3102
+ }
3103
+ prepareMedia(e) {
3104
+ return this.serialize(async () => {
3105
+ let { state: t } = this.options;
3106
+ if (!this.isReelActive() || t.activeReelPostId !== e.postId) return;
3107
+ let n = t.items.find(({ postId: t }) => t === e.postId);
3108
+ if (!n) return;
3109
+ let r = t.mediaIndices.get(e.postId) ?? 0;
3110
+ if (e.mediaIndex === r) {
3111
+ if (j(n).length > 1) {
3112
+ await this.options.transitionMedia(1);
3113
+ return;
3114
+ }
3115
+ await this.preparePosts([e.postId]);
3116
+ }
3117
+ });
3118
+ }
3119
+ reset() {
3120
+ this.generation += 1, this.pending = Promise.resolve();
3121
+ }
3122
+ async preparePosts(e) {
3123
+ let { state: t } = this.options, n = t.activeReelPostId, r = new Set(e);
3124
+ if (!this.isReelActive() || n === null || !r.has(n)) return;
3125
+ let i = this.generation, a = t.items.findIndex(({ postId: e }) => e === n);
3126
+ if (a < 0) return;
3127
+ let o = this.nextSurvivor(a, r);
3128
+ o && i === this.generation && t.activeReelPostId === n && await this.options.transitionPost(o.postId);
3129
+ }
3130
+ isReelActive() {
3131
+ let { state: e } = this.options;
3132
+ return e.layout === "reel" || e.reelOrigin === "masonry";
3133
+ }
3134
+ nextSurvivor(e, t) {
3135
+ if (!(e < 0)) return this.options.state.items.slice(e + 1).find(({ postId: e }) => !t.has(e));
3136
+ }
3137
+ serialize(e) {
3138
+ let t = this.pending.then(e, e);
3139
+ return this.pending = t.catch(() => void 0), t;
3140
+ }
3056
3141
  };
3057
3142
  //#endregion
3058
3143
  //#region src/core/removalControllers.ts
3059
- function Fn(e) {
3060
- let t = new Pn(e);
3144
+ function zn(e) {
3145
+ let t = new Ln(e), n = new Rn({
3146
+ state: e.state,
3147
+ transitionMedia: (t) => e.surface()?.transitionActiveReelMedia(t) ?? Promise.resolve(!1),
3148
+ transitionPost: (t) => e.surface()?.transitionActiveReelPost(t) ?? Promise.resolve(!1)
3149
+ });
3061
3150
  return {
3062
- exactMediaRemoval: new On({
3151
+ exactMediaRemoval: new jn({
3063
3152
  onActivate: e.onActivate,
3064
3153
  reelForward: t,
3065
3154
  state: e.state
3066
3155
  }),
3067
- itemRemoval: new Nn({
3156
+ itemRemoval: new In({
3068
3157
  historyLimit: e.historyLimit,
3069
3158
  onItemsRemoved: (n, r, i) => {
3070
- Tn(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
3159
+ On(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
3071
3160
  },
3072
3161
  onRemovalRestored: (n) => {
3073
3162
  let r = t.cancel(n);
3074
3163
  r && e.onActivate(r.postId);
3075
3164
  },
3076
- startRemoval: e.startRemoval,
3165
+ prepareRemoval: (e) => n.prepareItems(e),
3166
+ startRemoval: (t) => e.surface()?.startItemRemoval(t) ?? 0,
3077
3167
  state: e.state
3078
3168
  }),
3079
- reelForward: t
3169
+ reelForward: t,
3170
+ reelRemoval: n
3080
3171
  };
3081
3172
  }
3082
- var In = 1.5;
3083
- function Ln(e) {
3173
+ var Bn = 1.5;
3174
+ function Vn(e) {
3084
3175
  let t = Math.min(e.screenWidth, e.screenHeight);
3085
3176
  if (t > 0 && t < 600) return !0;
3086
- let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * In;
3177
+ let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * Bn;
3087
3178
  return !e.hasHover && n > 0 && n < 600 && r;
3088
3179
  }
3089
- function Rn(e) {
3090
- return Ln(e) ? "reel" : "masonry";
3180
+ function Hn(e) {
3181
+ return Vn(e) ? "reel" : "masonry";
3091
3182
  }
3092
- function zn(e) {
3183
+ function Un(e) {
3093
3184
  let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
3094
3185
  return {
3095
3186
  hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
@@ -3099,15 +3190,15 @@ function zn(e) {
3099
3190
  viewportWidth: n.clientWidth
3100
3191
  };
3101
3192
  }
3102
- function Bn(e) {
3103
- return Ln(zn(e));
3193
+ function Wn(e) {
3194
+ return Vn(Un(e));
3104
3195
  }
3105
- function Vn(e) {
3106
- return Rn(zn(e));
3196
+ function Gn(e) {
3197
+ return Hn(Un(e));
3107
3198
  }
3108
3199
  //#endregion
3109
3200
  //#region src/core/responsiveLayoutController.ts
3110
- var Hn = class {
3201
+ var Kn = class {
3111
3202
  layoutMode;
3112
3203
  resizeObserver = null;
3113
3204
  target = null;
@@ -3132,10 +3223,10 @@ var Hn = class {
3132
3223
  }
3133
3224
  handleResponsiveLayout = () => {
3134
3225
  if (!this.target) return;
3135
- let e = Vn(this.target);
3136
- this.state.reelInfoSheetOverlay = Bn(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
3226
+ let e = Gn(this.target);
3227
+ this.state.reelInfoSheetOverlay = Wn(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
3137
3228
  };
3138
- }, Un = class {
3229
+ }, qn = class {
3139
3230
  routedReelPostId = null;
3140
3231
  reelRouteIsActive = !1;
3141
3232
  constructor(e, t) {
@@ -3162,7 +3253,7 @@ var Hn = class {
3162
3253
  let i = this.reelRouteIsActive ? "replace" : "push";
3163
3254
  this.reelRouteIsActive = !0, this.routedReelPostId = e, this.options.router[i](r);
3164
3255
  }
3165
- }, Wn = class {
3256
+ }, Jn = class {
3166
3257
  app = null;
3167
3258
  autoScroll;
3168
3259
  autofillDelayCountdown;
@@ -3176,46 +3267,47 @@ var Hn = class {
3176
3267
  exactMediaRemoval;
3177
3268
  itemRemoval;
3178
3269
  reelForward;
3270
+ reelRemoval;
3179
3271
  surface = null;
3180
3272
  stopStateWatcher = null;
3181
3273
  lastLoadedCursor = null;
3182
3274
  state;
3183
3275
  constructor(e) {
3184
- this.options = e, Cn(e);
3276
+ this.options = e, En(e);
3185
3277
  let t = e.layout ?? "masonry";
3186
- this.state = b(bn(e, t)), this.autoScroll = new Gt({
3278
+ this.state = b(Cn(e, t)), this.autoScroll = new Jt({
3187
3279
  getScrollElement: () => this.surface?.getAutoScrollElement() ?? null,
3188
3280
  state: this.state.autoScroll
3189
- }), this.autofillDelayCountdown = new At((e) => Object.assign(this.state.autofill, e)), this.syncAutofillCountdown(), this.fillController = new fn({
3281
+ }), this.autofillDelayCountdown = new Nt((e) => Object.assign(this.state.autofill, e)), this.syncAutofillCountdown(), this.fillController = new hn({
3190
3282
  fill: e.fill,
3191
3283
  loadPage: e.loadPage,
3192
3284
  onLastCursor: (e) => {
3193
3285
  this.lastLoadedCursor = e;
3194
3286
  },
3195
3287
  state: this.state
3196
- }), this.routing = new Un(e.routing, this.state);
3197
- let n = Fn({
3288
+ }), this.routing = new qn(e.routing, this.state);
3289
+ let n = zn({
3198
3290
  historyLimit: e.removalHistoryLimit,
3199
3291
  loadNext: () => this.loadNext(),
3200
3292
  onActivate: (e) => this.setActiveReelPost(e),
3201
3293
  retryEnd: () => this.retryEnd(),
3202
- startRemoval: (e) => this.surface?.startItemRemoval(e) ?? 0,
3203
- state: this.state
3294
+ state: this.state,
3295
+ surface: () => this.surface
3204
3296
  });
3205
- this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.responsiveLayout = new Hn(t, this.state, () => {
3297
+ this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new Kn(t, this.state, () => {
3206
3298
  this.routing.syncFeed();
3207
3299
  }), this.startStateNotifications();
3208
3300
  }
3209
3301
  async mount() {
3210
3302
  if (this.app) throw Error("Vibe is already mounted.");
3211
3303
  this.startStateNotifications();
3212
- let e = wn(this.options.target);
3213
- this.responsiveLayout.mount(e), this.app = r(bt, {
3304
+ let e = Dn(this.options.target);
3305
+ this.responsiveLayout.mount(e), this.app = r(Ct, {
3214
3306
  canRetryEnd: !!this.options.loadPage,
3215
3307
  cardFooter: this.options.cardFooter,
3216
3308
  cardHeader: this.options.cardHeader,
3217
3309
  feedFooter: this.options.feedFooter,
3218
- feedFooterActions: pn(this),
3310
+ feedFooterActions: gn(this),
3219
3311
  mediaCard: this.options.mediaCard,
3220
3312
  reelInfoSheet: this.options.reelInfoSheet,
3221
3313
  state: this.state,
@@ -3237,7 +3329,7 @@ var Hn = class {
3237
3329
  }), this.surface = this.app.mount(e), this.autoScroll.mount(), this.options.initialPage ? this.options.autofill && this.state.autofill.status === "idle" && !this.fillController.isActive() && await this.startInitialAutofill() : await this.reload();
3238
3330
  }
3239
3331
  destroy() {
3240
- this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.reelForward.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.destroy(), this.responsiveLayout.destroy(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null;
3332
+ this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.destroy(), this.responsiveLayout.destroy(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null;
3241
3333
  }
3242
3334
  getState() {
3243
3335
  return F(this.state);
@@ -3245,6 +3337,9 @@ var Hn = class {
3245
3337
  removeMedia(e) {
3246
3338
  return this.exactMediaRemoval.remove(e);
3247
3339
  }
3340
+ removeMediaAnimated(e) {
3341
+ return this.reelRemoval.prepareMedia(e).then(() => this.exactMediaRemoval.remove(e));
3342
+ }
3248
3343
  removeItems(e) {
3249
3344
  return this.itemRemoval.remove(e);
3250
3345
  }
@@ -3288,11 +3383,11 @@ var Hn = class {
3288
3383
  this.autoScroll.setSpeed(e);
3289
3384
  }
3290
3385
  applyAutofillUpdate(e) {
3291
- let t = Jt(this.options.autofill, this.state, e);
3386
+ let t = Zt(this.options.autofill, this.state, e);
3292
3387
  return t && this.syncAutofillCountdown(), t;
3293
3388
  }
3294
3389
  async cancelAutofill() {
3295
- await Lt(this.options.autofill, this.state, () => this.cancelRequest());
3390
+ await Bt(this.options.autofill, this.state, () => this.cancelRequest());
3296
3391
  }
3297
3392
  applyFillUpdate(e) {
3298
3393
  return this.fillController.applyUpdate(e);
@@ -3301,11 +3396,11 @@ var Hn = class {
3301
3396
  return this.fillController.cancel();
3302
3397
  }
3303
3398
  async fill(e) {
3304
- if (this.pendingRequest || It(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
3399
+ if (this.pendingRequest || zt(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
3305
3400
  await this.fillController.start(e);
3306
3401
  }
3307
3402
  restoreAutofillSession(e) {
3308
- let t = Yt(this.options.autofill, this.state, e);
3403
+ let t = Qt(this.options.autofill, this.state, e);
3309
3404
  return t && this.syncAutofillCountdown(), t;
3310
3405
  }
3311
3406
  restoreFillSession(e) {
@@ -3313,7 +3408,7 @@ var Hn = class {
3313
3408
  }
3314
3409
  async loadNext() {
3315
3410
  if (this.pendingRequest) return this.pendingRequest;
3316
- if (!this.state.loadMoreLocked && !(It(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.state.next, !0);
3411
+ if (!this.state.loadMoreLocked && !(zt(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.state.next, !0);
3317
3412
  }
3318
3413
  async refresh() {
3319
3414
  return this.replaceFeed(this.state.next ?? this.lastLoadedCursor, "refresh");
@@ -3323,11 +3418,11 @@ var Hn = class {
3323
3418
  }
3324
3419
  async replaceFeed(e, t) {
3325
3420
  if (!this.options.loadPage) throw Error(`Vibe cannot ${t} without loadPage.`);
3326
- return It(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Ft(this.options.autofill, void 0, !1), this.fillController.reset(), this.reelForward.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.reset(), this.state.error = null, this.state.isLoading = !0, this.state.items = [], this.state.next = null, this.state.nextPageError = null, this.state.total = null, this.startRequest(e, !1);
3421
+ return zt(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Rt(this.options.autofill, void 0, !1), this.fillController.reset(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.reset(), this.state.error = null, this.state.isLoading = !0, this.state.items = [], this.state.next = null, this.state.nextPageError = null, this.state.total = null, this.startRequest(e, !1);
3327
3422
  }
3328
3423
  async retryEnd() {
3329
3424
  if (this.pendingRequest) return this.pendingRequest;
3330
- if (!this.state.loadMoreLocked && !(It(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);
3425
+ if (!this.state.loadMoreLocked && !(zt(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);
3331
3426
  }
3332
3427
  setInfiniteScroll(e) {
3333
3428
  this.state.infiniteScroll = e, e && p(() => this.surface?.loadIfNearBottom());
@@ -3336,10 +3431,10 @@ var Hn = class {
3336
3431
  this.state.loadMoreLocked !== e && (this.state.loadMoreLocked = e, !e && this.state.infiniteScroll && p(() => this.surface?.loadIfNearBottom()));
3337
3432
  }
3338
3433
  setReelAutoAdvance(e) {
3339
- _n(this.state.reelAutoAdvance, e);
3434
+ bn(this.state.reelAutoAdvance, e);
3340
3435
  }
3341
3436
  setReelInfoSheet(e) {
3342
- yn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
3437
+ Sn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
3343
3438
  }
3344
3439
  setLayout(e) {
3345
3440
  this.responsiveLayout.setLayout(e);
@@ -3363,7 +3458,7 @@ var Hn = class {
3363
3458
  this.abortController = i;
3364
3459
  try {
3365
3460
  if (a?.strategy === "frontend") {
3366
- let o = await zt({
3461
+ let o = await Ht({
3367
3462
  existingItems: t ? this.state.items : [],
3368
3463
  initialCursor: e,
3369
3464
  loadPage: n,
@@ -3385,7 +3480,7 @@ var Hn = class {
3385
3480
  });
3386
3481
  return;
3387
3482
  }
3388
- let c = xt(await n({
3483
+ let c = wt(await n({
3389
3484
  cursor: e,
3390
3485
  signal: i.signal
3391
3486
  }));
@@ -3400,7 +3495,7 @@ var Hn = class {
3400
3495
  this.state.autofill.status = "complete";
3401
3496
  return;
3402
3497
  }
3403
- await Kt(a, this.state, {
3498
+ await Yt(a, this.state, {
3404
3499
  cycleId: o,
3405
3500
  feedKey: a.feedKey,
3406
3501
  items: u.slice(l.length),
@@ -3425,7 +3520,7 @@ var Hn = class {
3425
3520
  this.autofillDelayCountdown.clear();
3426
3521
  let t = `vibe-autofill-${Date.now().toString(36)}-${++this.autofillCycle}`;
3427
3522
  return this.state.autofill = {
3428
- ...Ft(e, void 0, !1),
3523
+ ...Rt(e, void 0, !1),
3429
3524
  cycleId: t,
3430
3525
  status: "filling"
3431
3526
  }, t;
@@ -3443,7 +3538,7 @@ var Hn = class {
3443
3538
  startInitialAutofill() {
3444
3539
  let e = ++this.requestVersion, t = new AbortController(), n = this.beginAutofillCycle();
3445
3540
  this.abortController = t, this.state.isLoadingMore = !0;
3446
- let r = Xt({
3541
+ let r = $t({
3447
3542
  cycleId: n,
3448
3543
  isCurrent: () => e === this.requestVersion,
3449
3544
  onLastCursor: (e) => {
@@ -3467,8 +3562,8 @@ var Hn = class {
3467
3562
  }));
3468
3563
  }
3469
3564
  };
3470
- function Gn(e) {
3471
- return new Wn(e);
3565
+ function Yn(e) {
3566
+ return new Jn(e);
3472
3567
  }
3473
3568
  //#endregion
3474
- export { Gn as createVibe };
3569
+ export { Yn as createVibe };