@wyxos/vibe 5.0.2 → 5.0.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
@@ -86,7 +86,7 @@ var L = {
86
86
  onClick: n[0] ||= (e) => t.$emit("retryEnd")
87
87
  }, " Check for more ", 8, V)]))])) : o("", !0);
88
88
  }
89
- }), ee = /* @__PURE__ */ d({
89
+ }), U = /* @__PURE__ */ d({
90
90
  __name: "FeedFooter",
91
91
  props: {
92
92
  actions: {},
@@ -142,7 +142,7 @@ var L = {
142
142
  "show-load-more"
143
143
  ]));
144
144
  }
145
- }), te = ["role"], ne = { class: "gallery-status" }, re = /* @__PURE__ */ d({
145
+ }), W = ["role"], ee = { class: "gallery-status" }, te = /* @__PURE__ */ d({
146
146
  __name: "FeedStatus",
147
147
  props: {
148
148
  actions: {},
@@ -156,7 +156,7 @@ var L = {
156
156
  return (n, u) => (b(), s("main", {
157
157
  class: "gallery-shell",
158
158
  role: r.state.error ? "alert" : r.state.isLoading ? "status" : void 0
159
- }, [c("p", ne, [r.state.error ? (b(), s(e, { key: 0 }, [l(" Unable to load media. ")], 64)) : r.state.isLoading ? (b(), s(e, { key: 1 }, [l(" Loading media… ")], 64)) : (b(), s(e, { key: 2 }, [l(" No media found. ")], 64))]), t.feedFooter ? (b(), a(ee, {
159
+ }, [c("p", ee, [r.state.error ? (b(), s(e, { key: 0 }, [l(" Unable to load media. ")], 64)) : r.state.isLoading ? (b(), s(e, { key: 1 }, [l(" Loading media… ")], 64)) : (b(), s(e, { key: 2 }, [l(" No media found. ")], 64))]), t.feedFooter ? (b(), a(U, {
160
160
  key: 0,
161
161
  actions: t.actions,
162
162
  "can-retry-end": t.canRetryEnd,
@@ -178,36 +178,36 @@ var L = {
178
178
  "is-loading",
179
179
  "load-more-locked",
180
180
  "state"
181
- ])) : o("", !0)], 8, te));
181
+ ])) : o("", !0)], 8, W));
182
182
  }
183
183
  });
184
- function U(e) {
184
+ function G(e) {
185
185
  return e.scrollHeight - e.scrollTop - e.clientHeight <= 240;
186
186
  }
187
187
  //#endregion
188
188
  //#region src/core/masonry.ts
189
- function W(e) {
189
+ function K(e) {
190
190
  let t = e.preview.width ?? e.width, n = e.preview.height ?? e.height;
191
191
  return !t || !n || t <= 0 || n <= 0 ? 1 : n / t;
192
192
  }
193
- function ie(e) {
193
+ function ne(e) {
194
194
  return e.reduce((t, n, r) => n < e[t] ? r : t, 0);
195
195
  }
196
- function G(e) {
196
+ function q(e) {
197
197
  return Math.max(0, e.containerHeight) + Math.max(0, e.gap);
198
198
  }
199
- function K(e, t) {
199
+ function re(e, t) {
200
200
  let n = Math.max(0, t.overscan), r = t.scrollTop - n, i = t.scrollTop + Math.max(0, t.viewportHeight) + n;
201
201
  return e.reduce((e, t, n) => (t.y + t.height >= r && t.y <= i && e.push(n), e), []);
202
202
  }
203
- function q(e, t, n) {
203
+ function J(e, t, n) {
204
204
  if (t <= 0 || e.length === 0) return {
205
205
  columns: 0,
206
206
  height: 0,
207
207
  items: []
208
208
  };
209
209
  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) => {
210
- let t = ie(c), n = s * W(e) + i, a = {
210
+ let t = ne(c), n = s * K(e) + i, a = {
211
211
  x: t * (s + r),
212
212
  y: c[t],
213
213
  width: s,
@@ -223,7 +223,7 @@ function q(e, t, n) {
223
223
  }
224
224
  //#endregion
225
225
  //#region src/core/scrollbar.ts
226
- function J(e, t, n) {
226
+ function ie(e, t, n) {
227
227
  return Math.min(n, Math.max(t, e));
228
228
  }
229
229
  function ae({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
@@ -235,23 +235,23 @@ function ae({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize:
235
235
  thumbSize: o,
236
236
  thumbTravel: 0
237
237
  };
238
- let l = J(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
238
+ let l = ie(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
239
239
  return {
240
240
  maximumScrollPosition: c,
241
241
  scrollable: !0,
242
- thumbOffset: u * (J(n, 0, c) / c),
242
+ thumbOffset: u * (ie(n, 0, c) / c),
243
243
  thumbSize: l,
244
244
  thumbTravel: u
245
245
  };
246
246
  }
247
247
  //#endregion
248
248
  //#region src/components/GalleryScrollbar.vue?vue&type=script&setup=true&lang.ts
249
- var Y = ["aria-hidden"], oe = [
249
+ var oe = ["aria-hidden"], se = [
250
250
  "aria-controls",
251
251
  "aria-valuemax",
252
252
  "aria-valuenow",
253
253
  "tabindex"
254
- ], se = 32, X = 40, ce = 120, le = /* @__PURE__ */ d({
254
+ ], ce = 32, Y = 40, le = 120, ue = /* @__PURE__ */ d({
255
255
  __name: "GalleryScrollbar",
256
256
  props: {
257
257
  contentSize: {},
@@ -273,7 +273,7 @@ var Y = ["aria-hidden"], oe = [
273
273
  function k() {
274
274
  g !== null && clearTimeout(g), g = setTimeout(() => {
275
275
  g = null, o.value || (l.value = !1);
276
- }, ce);
276
+ }, le);
277
277
  }
278
278
  function A() {
279
279
  l.value = !0, k();
@@ -282,7 +282,7 @@ var Y = ["aria-hidden"], oe = [
282
282
  let e = t.scrollElement, r = i.value;
283
283
  return !e || !r ? n : ae({
284
284
  contentSize: e.scrollHeight,
285
- minimumThumbSize: se,
285
+ minimumThumbSize: ce,
286
286
  scrollPosition: e.scrollTop,
287
287
  trackSize: r.clientHeight,
288
288
  viewportSize: e.clientHeight
@@ -335,7 +335,7 @@ var Y = ["aria-hidden"], oe = [
335
335
  }
336
336
  function z(e) {
337
337
  if (!E.value) return;
338
- let n = t.scrollElement?.clientHeight ?? 0, r = t.scrollElement?.scrollTop ?? 0, i = e.key === "ArrowUp" ? r - X : e.key === "ArrowDown" ? r + X : e.key === "PageUp" ? r - n : e.key === "PageDown" ? r + n : e.key === "Home" ? 0 : e.key === "End" ? a.value.maximumScrollPosition : null;
338
+ let n = t.scrollElement?.clientHeight ?? 0, r = t.scrollElement?.scrollTop ?? 0, i = e.key === "ArrowUp" ? r - Y : e.key === "ArrowDown" ? r + Y : e.key === "PageUp" ? r - n : e.key === "PageDown" ? r + n : e.key === "Home" ? 0 : e.key === "End" ? a.value.maximumScrollPosition : null;
339
339
  i !== null && (e.preventDefault(), A(), P(i));
340
340
  }
341
341
  function B(e) {
@@ -381,12 +381,12 @@ var Y = ["aria-hidden"], oe = [
381
381
  onPointerdown: I,
382
382
  onPointermove: L,
383
383
  onPointerup: R
384
- }, null, 44, oe)], 42, Y));
384
+ }, null, 44, se)], 42, oe));
385
385
  }
386
- }), ue = (e) => {
386
+ }), de = (e) => {
387
387
  for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
388
388
  return !1;
389
- }, de = (e) => e === "", fe = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), Z = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), pe = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), me = (e) => {
389
+ }, fe = (e) => e === "", X = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), Z = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), pe = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), me = (e) => {
390
390
  let t = pe(e);
391
391
  return t.charAt(0).toUpperCase() + t.slice(1);
392
392
  }, he = {
@@ -405,9 +405,9 @@ var Y = ["aria-hidden"], oe = [
405
405
  width: o,
406
406
  height: o,
407
407
  stroke: s,
408
- "stroke-width": de(n) || de(r) || n === !0 || r === !0 ? Number(i || a || he["stroke-width"]) * 24 / Number(o) : i || a || he["stroke-width"],
409
- class: fe("lucide", c.class, ...e ? [`lucide-${Z(me(e))}-icon`, `lucide-${Z(e)}`] : ["lucide-icon"]),
410
- ...!l.default && !ue(c) && { "aria-hidden": "true" }
408
+ "stroke-width": fe(n) || fe(r) || n === !0 || r === !0 ? Number(i || a || he["stroke-width"]) * 24 / Number(o) : i || a || he["stroke-width"],
409
+ class: X("lucide", c.class, ...e ? [`lucide-${Z(me(e))}-icon`, `lucide-${Z(e)}`] : ["lucide-icon"]),
410
+ ...!l.default && !de(c) && { "aria-hidden": "true" }
411
411
  }, [...t.map((e) => p(...e)), ...l.default ? [l.default()] : []]), _e = (e, t) => (n, { slots: r, attrs: i }) => p(ge, {
412
412
  ...i,
413
413
  ...n,
@@ -741,52 +741,52 @@ var ze = [
741
741
  function S(e = !1, t = "pointer") {
742
742
  e && x("activate", t);
743
743
  }
744
- let C = r(() => M(l.item)), D = r(() => N(l.item, l.mediaIndex)), O = r(() => P(l.item, D.value)), F = r(() => l.mediaSource === "original" ? O.value.src : O.value.preview.src), I = r(() => l.mediaSource === "original" ? O.value.width : O.value.preview.width), L = r(() => l.mediaSource === "original" ? O.value.height : O.value.preview.height), R = w(null), z = w(0), B = w(0), V = w(l.mediaCard?.videoMuted ?? l.layout === "masonry"), H = w(!1), ee = w(1), te = 1, { effectiveMuted: ne, onPlaying: re, playbackAllowed: U } = Re({
744
+ let C = r(() => M(l.item)), D = r(() => N(l.item, l.mediaIndex)), O = r(() => P(l.item, D.value)), F = r(() => l.mediaSource === "original" ? O.value.src : O.value.preview.src), I = r(() => l.mediaSource === "original" ? O.value.width : O.value.preview.width), L = r(() => l.mediaSource === "original" ? O.value.height : O.value.preview.height), R = w(null), z = w(0), B = w(0), V = w(l.mediaCard?.videoMuted ?? l.layout === "masonry"), H = w(!1), U = w(1), W = 1, { effectiveMuted: ee, onPlaying: te, playbackAllowed: G } = Re({
745
745
  active: () => l.active,
746
746
  layout: () => l.layout,
747
747
  videoElement: R,
748
748
  videoIsMuted: V,
749
749
  videoIsPlaying: H
750
- }), W = r(() => l.interactive && !!(l.cardHeader || l.cardFooter));
751
- function ie(e) {
750
+ }), K = r(() => l.interactive && !!(l.cardHeader || l.cardFooter));
751
+ function ne(e) {
752
752
  return e.detail === 0 ? "keyboard" : "pointer";
753
753
  }
754
- function G(e, t) {
754
+ function q(e, t) {
755
755
  let n = C.value.length, r = (e + n) % n;
756
756
  r !== D.value && (y.value = e < D.value ? "previous" : "next", x("mediaChange", r), t && t.detail > 0 && t.currentTarget?.blur());
757
757
  }
758
- function K(e, t, n) {
758
+ function re(e, t, n) {
759
759
  return t === 1 ? e * 16 : t === 2 ? e * n : e;
760
760
  }
761
- function q() {
761
+ function J() {
762
762
  f = 0, p = !1, d !== null && clearTimeout(d), d = null;
763
763
  }
764
- function J() {
765
- d !== null && clearTimeout(d), d = setTimeout(q, Qe);
764
+ function ie() {
765
+ d !== null && clearTimeout(d), d = setTimeout(J, Qe);
766
766
  }
767
767
  function ae(e) {
768
768
  if (C.value.length <= 1) return;
769
- let t = e.currentTarget?.clientWidth || 1, n = K(e.deltaX, e.deltaMode, t);
770
- if (n === 0 || (e.preventDefault(), J(), p) || (f += n, Math.abs(f) < $e)) return;
769
+ let t = e.currentTarget?.clientWidth || 1, n = re(e.deltaX, e.deltaMode, t);
770
+ if (n === 0 || (e.preventDefault(), ie(), p) || (f += n, Math.abs(f) < $e)) return;
771
771
  let r = Math.sign(f);
772
- f = 0, p = !0, G(D.value + r);
772
+ f = 0, p = !0, q(D.value + r);
773
773
  }
774
- function Y(e) {
774
+ function oe(e) {
775
775
  let t = e.touches[0];
776
776
  l.layout !== "reel" || !t || (m = t.clientX, g = t.clientY);
777
777
  }
778
- function oe(e) {
778
+ function se(e) {
779
779
  let t = e.changedTouches[0];
780
780
  if (m === null || g === null || !t) return;
781
781
  let n = m - t.clientX, r = g - t.clientY;
782
- m = null, g = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < Ze || G(D.value + Math.sign(n)));
782
+ m = null, g = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < Ze || q(D.value + Math.sign(n)));
783
783
  }
784
- let se = r(() => Oe(F.value)), X = r(() => l.layout === "reel" && l.stationaryReelControls === !0), ce = r(() => se.value && l.previewState === "ready" && (!X.value || !!(l.active && l.reelControlsTarget))), le = r(() => `${l.item.postId}:${D.value}:${F.value}`);
785
- function ue(e) {
786
- l.layout === "reel" && (e.stopPropagation(), de());
784
+ let ce = r(() => Oe(F.value)), Y = r(() => l.layout === "reel" && l.stationaryReelControls === !0), le = r(() => ce.value && l.previewState === "ready" && (!Y.value || !!(l.active && l.reelControlsTarget))), ue = r(() => `${l.item.postId}:${D.value}:${F.value}`);
785
+ function de(e) {
786
+ l.layout === "reel" && (e.stopPropagation(), fe());
787
787
  }
788
- async function de() {
789
- if (!(!R.value || !U.value)) {
788
+ async function fe() {
789
+ if (!(!R.value || !G.value)) {
790
790
  if (H.value) {
791
791
  R.value.pause();
792
792
  return;
@@ -798,12 +798,12 @@ var ze = [
798
798
  }
799
799
  }
800
800
  }
801
- function fe(e) {
801
+ function X(e) {
802
802
  return Number.isFinite(e) ? Math.max(0, e) : 0;
803
803
  }
804
804
  function Z(e) {
805
805
  let t = e?.currentTarget ?? R.value;
806
- t && (z.value = fe(t.currentTime), B.value = fe(t.duration), U.value && (V.value = t.muted), ee.value = t.volume, t.volume > 0 && (te = t.volume));
806
+ t && (z.value = X(t.currentTime), B.value = X(t.duration), G.value && (V.value = t.muted), U.value = t.volume, t.volume > 0 && (W = t.volume));
807
807
  }
808
808
  function pe(e) {
809
809
  Z(e), x("ready", D.value);
@@ -813,20 +813,20 @@ var ze = [
813
813
  }
814
814
  function he(e) {
815
815
  let t = R.value;
816
- !t || !Number.isFinite(e) || (t.currentTime = Math.min(fe(t.duration), Math.max(0, e)), z.value = t.currentTime);
816
+ !t || !Number.isFinite(e) || (t.currentTime = Math.min(X(t.duration), Math.max(0, e)), z.value = t.currentTime);
817
817
  }
818
818
  function ge(e) {
819
819
  let t = R.value;
820
820
  if (!t || !Number.isFinite(e)) return;
821
821
  let n = Math.min(1, Math.max(0, e));
822
- t.volume = n, t.muted = n === 0, n > 0 && (te = n), Z();
822
+ t.volume = n, t.muted = n === 0, n > 0 && (W = n), Z();
823
823
  }
824
824
  function _e() {
825
825
  let e = R.value;
826
- e && (e.muted && e.volume === 0 && (e.volume = te), e.muted = !e.muted, Z());
826
+ e && (e.muted && e.volume === 0 && (e.volume = W), e.muted = !e.muted, Z());
827
827
  }
828
828
  return v(() => {
829
- q();
829
+ J();
830
830
  }), (r, i) => (b(), s("article", {
831
831
  "data-post-id": e.item.postId,
832
832
  "data-media-index": D.value,
@@ -840,10 +840,10 @@ var ze = [
840
840
  "aria-hidden": e.leaving || void 0,
841
841
  "aria-busy": e.previewState === "loading",
842
842
  inert: e.leaving || void 0,
843
- role: e.interactive && !e.leaving && !W.value ? "button" : void 0,
844
- tabindex: e.interactive && !e.leaving && !W.value ? 0 : void 0,
845
- onClick: i[11] ||= (t) => S(e.interactive && !W.value, ie(t)),
846
- onKeydown: [i[12] ||= A((t) => S(e.interactive && !W.value, "keyboard"), ["enter"]), i[13] ||= A(j((t) => S(e.interactive && !W.value, "keyboard"), ["prevent"]), ["space"])]
843
+ role: e.interactive && !e.leaving && !K.value ? "button" : void 0,
844
+ tabindex: e.interactive && !e.leaving && !K.value ? 0 : void 0,
845
+ onClick: i[11] ||= (t) => S(e.interactive && !K.value, ne(t)),
846
+ onKeydown: [i[12] ||= A((t) => S(e.interactive && !K.value, "keyboard"), ["enter"]), i[13] ||= A(j((t) => S(e.interactive && !K.value, "keyboard"), ["prevent"]), ["space"])]
847
847
  }, [c("div", Be, [
848
848
  e.cardHeader ? (b(), a(ke, {
849
849
  key: 0,
@@ -872,8 +872,8 @@ var ze = [
872
872
  class: h(["media-card-media", { "media-card-media--carousel": e.layout === "reel" && C.value.length > 1 }]),
873
873
  "data-media-direction": y.value,
874
874
  onWheel: ae,
875
- onTouchstartPassive: Y,
876
- onTouchendPassive: oe
875
+ onTouchstartPassive: oe,
876
+ onTouchendPassive: se
877
877
  }, [
878
878
  u(n, { name: `media-slide-${y.value}` }, {
879
879
  default: k(() => [(b(), s("div", {
@@ -886,7 +886,7 @@ var ze = [
886
886
  class: "media-error",
887
887
  role: "img",
888
888
  "aria-label": `${E(Te)(F.value)} ${E(Ee)(F.value)}`
889
- }, [c("strong", Ge, T(E(Te)(F.value)), 1), c("span", null, T(E(Ee)(F.value)), 1)], 8, We)) : o("", !0), se.value ? (b(), s("video", {
889
+ }, [c("strong", Ge, T(E(Te)(F.value)), 1), c("span", null, T(E(Ee)(F.value)), 1)], 8, We)) : o("", !0), ce.value ? (b(), s("video", {
890
890
  key: 2,
891
891
  ref_key: "videoElement",
892
892
  ref: R,
@@ -897,19 +897,19 @@ var ze = [
897
897
  src: F.value,
898
898
  width: I.value ?? void 0,
899
899
  height: L.value ?? void 0,
900
- autoplay: E(U),
900
+ autoplay: E(G),
901
901
  loop: !e.advanceOnMediaEnd,
902
- muted: E(ne),
902
+ muted: E(ee),
903
903
  playsinline: "",
904
904
  preload: e.fetchPriority === "high" ? "auto" : "metadata",
905
905
  onLoadedmetadata: pe,
906
906
  onDurationchange: Z,
907
907
  onTimeupdate: Z,
908
908
  onVolumechange: Z,
909
- onPlaying: i[0] ||= (...e) => E(re) && E(re)(...e),
909
+ onPlaying: i[0] ||= (...e) => E(te) && E(te)(...e),
910
910
  onPause: i[1] ||= (e) => H.value = !1,
911
911
  onEnded: me,
912
- onClick: ue,
912
+ onClick: de,
913
913
  onError: i[2] ||= (e) => r.$emit("error", D.value)
914
914
  }, null, 42, Ke)) : (b(), s("img", {
915
915
  key: 3,
@@ -927,24 +927,24 @@ var ze = [
927
927
  _: 1
928
928
  }, 8, ["name"]),
929
929
  (b(), a(t, {
930
- disabled: !X.value || !e.reelControlsTarget,
930
+ disabled: !Y.value || !e.reelControlsTarget,
931
931
  to: e.reelControlsTarget ?? "body"
932
932
  }, [u(n, {
933
933
  name: "vibe-reel-media-controls",
934
- css: X.value
934
+ css: Y.value
935
935
  }, {
936
- default: k(() => [ce.value ? (b(), a(Le, {
937
- key: le.value,
936
+ default: k(() => [le.value ? (b(), a(Le, {
937
+ key: ue.value,
938
938
  "current-time": z.value,
939
- "data-control-post-id": X.value ? e.item.postId : void 0,
939
+ "data-control-post-id": Y.value ? e.item.postId : void 0,
940
940
  duration: B.value,
941
941
  layout: e.layout,
942
942
  muted: V.value,
943
943
  playing: H.value,
944
- volume: ee.value,
944
+ volume: U.value,
945
945
  onSeek: he,
946
946
  onToggleMute: _e,
947
- onTogglePlayback: de,
947
+ onTogglePlayback: fe,
948
948
  onVolumeChange: ge
949
949
  }, null, 8, [
950
950
  "current-time",
@@ -965,21 +965,21 @@ var ze = [
965
965
  type: "button",
966
966
  class: "media-carousel-control media-carousel-control--previous",
967
967
  "aria-label": `Previous media for post ${e.item.postId}`,
968
- onClick: i[5] ||= j((e) => G(D.value - 1, e), ["stop"]),
968
+ onClick: i[5] ||= j((e) => q(D.value - 1, e), ["stop"]),
969
969
  onKeydown: i[6] ||= j(() => {}, ["stop"])
970
970
  }, [u(E(ve), { size: 20 })], 40, Je), c("button", {
971
971
  type: "button",
972
972
  class: "media-carousel-control media-carousel-control--next",
973
973
  "aria-label": `Next media for post ${e.item.postId}`,
974
- onClick: i[7] ||= j((e) => G(D.value + 1, e), ["stop"]),
974
+ onClick: i[7] ||= j((e) => q(D.value + 1, e), ["stop"]),
975
975
  onKeydown: i[8] ||= j(() => {}, ["stop"])
976
976
  }, [u(E(ye), { size: 20 })], 40, Ye)], 2)) : o("", !0),
977
- W.value ? (b(), s("button", {
977
+ K.value ? (b(), s("button", {
978
978
  key: 1,
979
979
  class: "media-card-activator",
980
980
  type: "button",
981
981
  "aria-label": `Open post ${e.item.postId}`,
982
- onClick: i[9] ||= j((e) => r.$emit("activate", ie(e)), ["stop"]),
982
+ onClick: i[9] ||= j((e) => r.$emit("activate", ne(e)), ["stop"]),
983
983
  onKeydown: i[10] ||= j(() => {}, ["stop"])
984
984
  }, null, 40, Xe)) : o("", !0)
985
985
  ], 42, Ve),
@@ -1042,14 +1042,14 @@ var ze = [
1042
1042
  "retryEnd"
1043
1043
  ],
1044
1044
  setup(t, { expose: n, emit: i }) {
1045
- let o = t, l = i, d = w(null), f = `vibe-masonry-${D()}`, p = w(null), m = w(0), g = w(it), y = w(0), x = w(0), C = w(0), T = null, k = null, A = null, j = r(() => q(o.items, m.value, {
1045
+ let o = t, l = i, d = w(null), f = `vibe-masonry-${D()}`, p = w(null), m = w(0), g = w(it), y = w(0), x = w(0), C = w(0), T = null, k = null, A = null, j = r(() => J(o.items, m.value, {
1046
1046
  additionalHeight: (o.cardHeader?.height ?? 0) + (o.cardFooter?.height ?? 0),
1047
1047
  gap: g.value,
1048
1048
  minColumnWidth: rt
1049
1049
  })), M = r(() => {
1050
1050
  let e = j.value;
1051
1051
  if (o.leavingPostIds.size === 0) return e;
1052
- let t = o.items.filter((e) => !o.leavingPostIds.has(e.postId)), n = q(t, m.value, {
1052
+ let t = o.items.filter((e) => !o.leavingPostIds.has(e.postId)), n = J(t, m.value, {
1053
1053
  additionalHeight: (o.cardHeader?.height ?? 0) + (o.cardFooter?.height ?? 0),
1054
1054
  gap: g.value,
1055
1055
  minColumnWidth: rt
@@ -1062,16 +1062,16 @@ var ze = [
1062
1062
  let e = Math.max(ot, x.value * st), t = {
1063
1063
  scrollTop: y.value - C.value,
1064
1064
  viewportHeight: x.value
1065
- }, n = K(M.value.items, {
1065
+ }, n = re(M.value.items, {
1066
1066
  ...t,
1067
1067
  overscan: e
1068
- }), r = o.leavingPostIds.size === 0 ? [] : K(j.value.items, {
1068
+ }), r = o.leavingPostIds.size === 0 ? [] : re(j.value.items, {
1069
1069
  ...t,
1070
1070
  overscan: e
1071
- }), i = [...new Set([...n, ...r])].sort((e, t) => e - t), a = K(M.value.items, {
1071
+ }), i = [...new Set([...n, ...r])].sort((e, t) => e - t), a = re(M.value.items, {
1072
1072
  ...t,
1073
1073
  overscan: 0
1074
- }), s = o.leavingPostIds.size === 0 ? [] : K(j.value.items, {
1074
+ }), s = o.leavingPostIds.size === 0 ? [] : re(j.value.items, {
1075
1075
  ...t,
1076
1076
  overscan: 0
1077
1077
  }), c = new Set([...a, ...s]);
@@ -1087,7 +1087,7 @@ var ze = [
1087
1087
  function L(e) {
1088
1088
  let t = M.value.items[e], n = o.items[e]?.postId;
1089
1089
  if (!t) return {};
1090
- let r = n !== void 0 && o.enteringPostIds.has(n), i = n !== void 0 && o.leavingPostIds.has(n), a = r || i ? G({
1090
+ let r = n !== void 0 && o.enteringPostIds.has(n), i = n !== void 0 && o.leavingPostIds.has(n), a = r || i ? q({
1091
1091
  containerHeight: j.value.height,
1092
1092
  gap: g.value
1093
1093
  }) : 0, s = n === void 0 ? 0 : i ? o.removalDelays.get(n) ?? 0 : r ? o.entryDelays.get(n) ?? 0 : 0;
@@ -1111,11 +1111,11 @@ var ze = [
1111
1111
  }
1112
1112
  function B(e) {
1113
1113
  let t = e.currentTarget;
1114
- t && (y.value = t.scrollTop, !o.loadMoreLocked && o.infiniteScroll && U(t) && l("loadMore"));
1114
+ t && (y.value = t.scrollTop, !o.loadMoreLocked && o.infiniteScroll && G(t) && l("loadMore"));
1115
1115
  }
1116
1116
  function V() {
1117
1117
  let e = d.value;
1118
- !o.loadMoreLocked && e && U(e) && l("loadMore");
1118
+ !o.loadMoreLocked && e && G(e) && l("loadMore");
1119
1119
  }
1120
1120
  function H() {
1121
1121
  return d.value;
@@ -1189,7 +1189,7 @@ var ze = [
1189
1189
  "onMediaChange",
1190
1190
  "onReady",
1191
1191
  "onError"
1192
- ]))), 128))], 6), u(ee, {
1192
+ ]))), 128))], 6), u(U, {
1193
1193
  actions: t.feedFooterActions,
1194
1194
  "can-retry-end": t.canRetryEnd,
1195
1195
  "feed-footer": t.feedFooter,
@@ -1211,7 +1211,7 @@ var ze = [
1211
1211
  "load-more-locked",
1212
1212
  "show-load-more",
1213
1213
  "state"
1214
- ])], 42, nt), u(le, {
1214
+ ])], 42, nt), u(ue, {
1215
1215
  "content-size": M.value.height,
1216
1216
  "controls-id": f,
1217
1217
  "scroll-element": d.value,
@@ -1318,7 +1318,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1318
1318
  if (!e) return "";
1319
1319
  let t = P(e, z.value);
1320
1320
  return l.mediaSource === "original" ? t.src : t.preview.src;
1321
- }), H = r(() => B.value === "ready" && Oe(V.value)), te = r(() => [
1321
+ }), H = r(() => B.value === "ready" && Oe(V.value)), W = r(() => [
1322
1322
  L.value,
1323
1323
  z.value,
1324
1324
  l.items.length,
@@ -1326,26 +1326,26 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1326
1326
  l.reelAutoAdvance.enabled,
1327
1327
  l.reelAutoAdvance.includePostItems,
1328
1328
  l.reelAutoAdvance.intervalMs
1329
- ].join(":")), ne = r(() => {
1329
+ ].join(":")), ee = r(() => {
1330
1330
  let e = R.value, t = !!(e && l.reelAutoAdvance.includePostItems && z.value < M(e).length - 1), n = l.reelAutoAdvance.intervalMs / 1e3;
1331
1331
  return `Auto advance to the next ${t ? "post item" : "post"} in ${n}s`;
1332
- }), re = r(() => l.reelAutoAdvance.enabled && l.reelForward.status === "idle" && R.value !== void 0 && B.value !== "loading" && !H.value), W = r(() => !l.infiniteScroll || l.items.length <= 1), ie = r(() => 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.");
1333
- function G(e) {
1332
+ }), te = r(() => l.reelAutoAdvance.enabled && l.reelForward.status === "idle" && R.value !== void 0 && B.value !== "loading" && !H.value), K = r(() => !l.infiniteScroll || l.items.length <= 1), ne = r(() => 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.");
1333
+ function q(e) {
1334
1334
  return { gridRow: `${e + 1}` };
1335
1335
  }
1336
- function K(e) {
1336
+ function re(e) {
1337
1337
  let t = D || e.clientHeight;
1338
1338
  return t <= 0 || l.items.length === 0 ? 0 : Math.min(l.items.length - 1, Math.max(0, Math.round(e.scrollTop / t)));
1339
1339
  }
1340
- function q(e) {
1340
+ function J(e) {
1341
1341
  let t = e.currentTarget;
1342
1342
  if (!t) return;
1343
1343
  let n = D || t.clientHeight, r = Math.max(0, l.items.length - 1) * n;
1344
- x.value = l.items.length > 0 && t.scrollTop > r + 1, C.value || (g.value = K(t)), !l.loadMoreLocked && l.infiniteScroll && U(t) && u("loadMore");
1344
+ x.value = l.items.length > 0 && t.scrollTop > r + 1, C.value || (g.value = re(t)), !l.loadMoreLocked && l.infiniteScroll && G(t) && u("loadMore");
1345
1345
  }
1346
- function J() {
1346
+ function ie() {
1347
1347
  let e = d.value;
1348
- e && (x.value = !1, oe(!0), D = e.clientHeight, e.scrollTop = g.value * D, A !== null && cancelAnimationFrame(A), A = requestAnimationFrame(() => {
1348
+ e && (x.value = !1, se(!0), D = e.clientHeight, e.scrollTop = g.value * D, A !== null && cancelAnimationFrame(A), A = requestAnimationFrame(() => {
1349
1349
  e.scrollTop = g.value * e.clientHeight, D = e.clientHeight, A = null;
1350
1350
  }), ae());
1351
1351
  }
@@ -1353,22 +1353,22 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1353
1353
  j !== null && clearTimeout(j), j = setTimeout(() => {
1354
1354
  j = null;
1355
1355
  let e = d.value;
1356
- e && (D = e.clientHeight, e.scrollTop = g.value * D), oe(!1);
1356
+ e && (D = e.clientHeight, e.scrollTop = g.value * D), se(!1);
1357
1357
  }, 120);
1358
1358
  }
1359
- function Y() {
1360
- oe(!0);
1359
+ function oe() {
1360
+ se(!0);
1361
1361
  let e = d.value;
1362
1362
  e && (D = e.clientHeight, e.scrollTop = g.value * D), ae();
1363
1363
  }
1364
- function oe(e) {
1364
+ function se(e) {
1365
1365
  C.value = e, d.value?.toggleAttribute("data-resizing", e);
1366
1366
  }
1367
- function se() {
1367
+ function ce() {
1368
1368
  let e = d.value;
1369
- !l.loadMoreLocked && e && U(e) && u("loadMore");
1369
+ !l.loadMoreLocked && e && G(e) && u("loadMore");
1370
1370
  }
1371
- function X(e) {
1371
+ function Y(e) {
1372
1372
  let t = R.value;
1373
1373
  if (!t) return !1;
1374
1374
  let n = M(t).length;
@@ -1376,30 +1376,34 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1376
1376
  let r = (z.value + e + n) % n;
1377
1377
  return u("mediaChange", t.postId, r), !0;
1378
1378
  }
1379
- function ce(e) {
1379
+ function le(e) {
1380
1380
  let t = g.value + e;
1381
- return !d.value || t < 0 || t >= l.items.length ? !1 : (de(t), !0);
1381
+ return !d.value || t < 0 || t >= l.items.length ? !1 : (X(t), !0);
1382
+ }
1383
+ function ue(e, t) {
1384
+ let n = l.items.findIndex((t) => t.postId === e), r = l.items[n];
1385
+ return !d.value || !r || t < 0 || t > r.items.length ? !1 : ((l.mediaIndices.get(e) ?? 0) !== t && u("mediaChange", e, t), n !== g.value && X(n), !0);
1382
1386
  }
1383
- function le() {
1387
+ function de() {
1384
1388
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1385
1389
  }
1386
- function ue(e) {
1390
+ function fe(e) {
1387
1391
  let t = d.value;
1388
1392
  if (!t) return Promise.resolve();
1389
1393
  let n = e * (D || t.clientHeight);
1390
- return g.value = e, ut(t, n, le());
1394
+ return g.value = e, ut(t, n, de());
1391
1395
  }
1392
- function de(e) {
1393
- ue(e);
1396
+ function X(e) {
1397
+ fe(e);
1394
1398
  }
1395
- async function fe(e) {
1399
+ async function Z(e) {
1396
1400
  let t = l.items.findIndex((t) => t.postId === e);
1397
- return t < 0 || t === g.value ? !1 : (await ue(t), !0);
1401
+ return t < 0 || t === g.value ? !1 : (await fe(t), !0);
1398
1402
  }
1399
- async function Z(e) {
1400
- return X(e) ? (le() || await new Promise((e) => setTimeout(e, _t)), !0) : !1;
1403
+ async function pe(e) {
1404
+ return Y(e) ? (de() || await new Promise((e) => setTimeout(e, _t)), !0) : !1;
1401
1405
  }
1402
- function pe() {
1406
+ function me() {
1403
1407
  if (!l.reelAutoAdvance.enabled) return;
1404
1408
  let e = R.value;
1405
1409
  if (!e) return;
@@ -1412,30 +1416,31 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1412
1416
  l.hasNext && !l.loadMoreLocked && u("loadMore");
1413
1417
  return;
1414
1418
  }
1415
- l.reelAutoAdvance.includePostItems && (l.mediaIndices.get(n.postId) ?? 0) !== 0 && u("mediaChange", n.postId, 0), de(t);
1419
+ l.reelAutoAdvance.includePostItems && (l.mediaIndices.get(n.postId) ?? 0) !== 0 && u("mediaChange", n.postId, 0), X(t);
1416
1420
  }
1417
- function me(e, t) {
1418
- !l.reelAutoAdvance.enabled || e !== L.value || t !== z.value || !H.value || pe();
1421
+ function he(e, t) {
1422
+ !l.reelAutoAdvance.enabled || e !== L.value || t !== z.value || !H.value || me();
1419
1423
  }
1420
1424
  return O(d, (e) => {
1421
- k?.disconnect(), k = null, e && (D = e.clientHeight, !(typeof ResizeObserver > "u") && (k = new ResizeObserver(J), k.observe(e)));
1425
+ k?.disconnect(), k = null, e && (D = e.clientHeight, !(typeof ResizeObserver > "u") && (k = new ResizeObserver(ie), k.observe(e)));
1422
1426
  }), O(() => l.items.length, async (e) => {
1423
1427
  let t = l.initialPostId, n = t == null ? -1 : l.items.findIndex(({ postId: e }) => e === t);
1424
- g.value = n >= 0 ? n : Math.min(g.value, Math.max(0, e - 1)), await m(), J();
1428
+ g.value = n >= 0 ? n : Math.min(g.value, Math.max(0, e - 1)), await m(), ie();
1425
1429
  }), O(L, (e) => {
1426
1430
  e !== void 0 && u("activeChange", e);
1427
1431
  }, { immediate: !0 }), y(() => {
1428
- window.addEventListener("resize", Y), window.addEventListener("orientationchange", Y), p >= 0 && m(J);
1432
+ window.addEventListener("resize", oe), window.addEventListener("orientationchange", oe), p >= 0 && m(ie);
1429
1433
  }), v(() => {
1430
- window.removeEventListener("resize", Y), window.removeEventListener("orientationchange", Y), k?.disconnect(), A !== null && cancelAnimationFrame(A), j !== null && clearTimeout(j);
1434
+ window.removeEventListener("resize", oe), window.removeEventListener("orientationchange", oe), k?.disconnect(), A !== null && cancelAnimationFrame(A), j !== null && clearTimeout(j);
1431
1435
  }), n({
1432
1436
  activeIndex: g,
1433
1437
  activePostId: L,
1434
- changeActiveMedia: X,
1435
- loadIfNearBottom: se,
1436
- moveActivePost: ce,
1437
- transitionActiveMedia: Z,
1438
- transitionActivePost: fe
1438
+ changeActiveMedia: Y,
1439
+ loadIfNearBottom: ce,
1440
+ moveActivePost: le,
1441
+ navigateToItem: ue,
1442
+ transitionActiveMedia: pe,
1443
+ transitionActivePost: Z
1439
1444
  }), (n, r) => (b(), s("main", {
1440
1445
  class: h(["reel-shell", {
1441
1446
  "reel-shell--has-footer": !!t.cardFooter,
@@ -1471,7 +1476,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1471
1476
  class: "gallery-shell reel-feed",
1472
1477
  "data-active-post-id": L.value,
1473
1478
  "data-active-media-index": z.value,
1474
- onScrollPassive: q
1479
+ onScrollPassive: J
1475
1480
  }, [t.reelForward.status === "idle" ? (b(), s("section", {
1476
1481
  key: 1,
1477
1482
  class: "reel-track",
@@ -1486,7 +1491,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1486
1491
  "fetch-priority": e,
1487
1492
  index: r,
1488
1493
  item: n,
1489
- "item-style": G(r),
1494
+ "item-style": q(r),
1490
1495
  "media-card": t.mediaCard,
1491
1496
  layout: "reel",
1492
1497
  "loaded-count": t.items.length,
@@ -1497,7 +1502,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1497
1502
  "stationary-reel-controls": "",
1498
1503
  total: t.total,
1499
1504
  onMediaChange: (e) => u("mediaChange", n.postId, e),
1500
- onEnded: (e) => me(n.postId, e),
1505
+ onEnded: (e) => he(n.postId, e),
1501
1506
  onReady: (e) => u("ready", n.postId, e),
1502
1507
  onError: (e) => u("error", n.postId, e)
1503
1508
  }, null, 8, [
@@ -1523,12 +1528,12 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1523
1528
  class: "reel-forward-status",
1524
1529
  role: t.reelForward.status === "error" ? "alert" : "status",
1525
1530
  "data-status": t.reelForward.status
1526
- }, [c("p", null, T(ie.value), 1), t.reelForward.status === "error" || t.reelForward.status === "end" ? (b(), s("button", {
1531
+ }, [c("p", null, T(ne.value), 1), t.reelForward.status === "error" || t.reelForward.status === "end" ? (b(), s("button", {
1527
1532
  key: 0,
1528
1533
  class: "reel-forward-retry",
1529
1534
  type: "button",
1530
1535
  onClick: r[0] ||= (e) => u("retryForward")
1531
- }, " Retry ")) : o("", !0)], 8, ht)), t.reelForward.status === "idle" ? (b(), a(ee, {
1536
+ }, " Retry ")) : o("", !0)], 8, ht)), t.reelForward.status === "idle" ? (b(), a(U, {
1532
1537
  key: 2,
1533
1538
  actions: t.feedFooterActions,
1534
1539
  "can-retry-end": t.canRetryEnd,
@@ -1537,7 +1542,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1537
1542
  "has-next": t.hasNext,
1538
1543
  "is-loading": t.isLoadingMore,
1539
1544
  "load-more-locked": t.loadMoreLocked,
1540
- "show-load-more": W.value,
1545
+ "show-load-more": K.value,
1541
1546
  state: t.state,
1542
1547
  onLoadMore: r[1] ||= (e) => u("loadMore"),
1543
1548
  onRetryEnd: r[2] ||= (e) => u("retryEnd")
@@ -1579,11 +1584,11 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1579
1584
  "style",
1580
1585
  "total"
1581
1586
  ])) : o("", !0),
1582
- re.value ? (b(), a(ft, {
1583
- key: te.value,
1587
+ te.value ? (b(), a(ft, {
1588
+ key: W.value,
1584
1589
  "duration-ms": t.reelAutoAdvance.intervalMs,
1585
- label: ne.value,
1586
- onComplete: pe
1590
+ label: ee.value,
1591
+ onComplete: me
1587
1592
  }, null, 8, ["duration-ms", "label"])) : o("", !0)
1588
1593
  ], 2));
1589
1594
  }
@@ -1674,19 +1679,22 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1674
1679
  function L(e) {
1675
1680
  return p.value?.moveActivePost(e) ?? !1;
1676
1681
  }
1677
- function R(e) {
1678
- return p.value?.transitionActiveMedia(e) ?? Promise.resolve(!1);
1682
+ function R(e, t) {
1683
+ return p.value?.navigateToItem(e, t) ?? !1;
1679
1684
  }
1680
1685
  function z(e) {
1686
+ return p.value?.transitionActiveMedia(e) ?? Promise.resolve(!1);
1687
+ }
1688
+ function B(e) {
1681
1689
  return p.value?.transitionActivePost(e) ?? Promise.resolve(!1);
1682
1690
  }
1683
- function B(e, t) {
1691
+ function V(e, t) {
1684
1692
  d("error", e, t);
1685
1693
  }
1686
- function V(e, t) {
1694
+ function H(e, t) {
1687
1695
  d("mediaChange", e, t);
1688
1696
  }
1689
- function H(e, t) {
1697
+ function U(e, t) {
1690
1698
  d("ready", e, t);
1691
1699
  }
1692
1700
  return O(() => ({
@@ -1707,8 +1715,9 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1707
1715
  changeActiveMedia: F,
1708
1716
  loadIfNearBottom: I,
1709
1717
  moveActivePost: L,
1710
- transitionActiveMedia: R,
1711
- transitionActivePost: z
1718
+ navigateToItem: R,
1719
+ transitionActiveMedia: z,
1720
+ transitionActivePost: B
1712
1721
  }), (t, r) => (b(), s("section", {
1713
1722
  class: h(["reel-layout", `reel-layout--${e.infoSheetOverlay ? "overlay" : "layout"}`]),
1714
1723
  "data-info-sheet-open": A.value || void 0,
@@ -1741,10 +1750,10 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1741
1750
  state: e.state,
1742
1751
  total: e.total,
1743
1752
  onActiveChange: r[0] ||= (e) => d("activeChange", e),
1744
- onError: B,
1753
+ onError: V,
1745
1754
  onLoadMore: r[1] ||= (e) => d("loadMore"),
1746
- onMediaChange: V,
1747
- onReady: H,
1755
+ onMediaChange: H,
1756
+ onReady: U,
1748
1757
  onRetryEnd: r[2] ||= (e) => d("retryEnd"),
1749
1758
  onRetryForward: r[3] ||= (e) => d("retryForward")
1750
1759
  }, null, 8, [
@@ -1782,7 +1791,66 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1782
1791
  _: 1
1783
1792
  })], 10, yt));
1784
1793
  }
1785
- }), wt = 35, Tt = 420, Et = /* @__PURE__ */ d({
1794
+ }), wt = [];
1795
+ function Tt(e) {
1796
+ return wt.push(e), () => {
1797
+ let t = wt.indexOf(e);
1798
+ t >= 0 && wt.splice(t, 1);
1799
+ };
1800
+ }
1801
+ function Et(e) {
1802
+ if (!e.isActive()) return !1;
1803
+ let t = wt.filter((e) => e.isActive()), n = e.element();
1804
+ return n !== null && t.some((t) => {
1805
+ if (t === e) return !1;
1806
+ let r = t.element();
1807
+ return r !== null && n.contains(r);
1808
+ }) ? !1 : t.filter((e) => {
1809
+ let n = e.element();
1810
+ return n === null || !t.some((t) => {
1811
+ if (t === e) return !1;
1812
+ let r = t.element();
1813
+ return r !== null && n.contains(r);
1814
+ });
1815
+ }).at(-1) === e;
1816
+ }
1817
+ //#endregion
1818
+ //#region src/components/useReelKeyboard.ts
1819
+ function Dt(e) {
1820
+ let t = {
1821
+ element: e.element,
1822
+ isActive: () => e.state.layout === "reel" || e.state.reelOrigin === "masonry"
1823
+ }, n = null;
1824
+ function r(n) {
1825
+ let r = t.isActive();
1826
+ if (n.key === "Escape" && r && !Et(t)) return;
1827
+ if (n.key === "Escape" && e.state.reelOrigin === "masonry") {
1828
+ n.preventDefault(), e.state.reelInfoSheetOverlay && e.state.reelInfoSheet.enabled && e.setReelInfoSheet(!1), e.closeMasonryReel();
1829
+ return;
1830
+ }
1831
+ if (n.key === "Escape" && r && e.state.reelInfoSheet.enabled) {
1832
+ n.preventDefault(), e.setReelInfoSheet(!1);
1833
+ return;
1834
+ }
1835
+ if (n.defaultPrevented || n.altKey || n.ctrlKey || n.metaKey || n.shiftKey || e.isReelLeaving() || !r) return;
1836
+ let i = n.target;
1837
+ if (i instanceof HTMLElement && (i.isContentEditable || [
1838
+ "INPUT",
1839
+ "SELECT",
1840
+ "TEXTAREA"
1841
+ ].includes(i.tagName))) return;
1842
+ let a = n.key === "ArrowLeft" ? -1 : n.key === "ArrowRight" ? 1 : 0;
1843
+ a !== 0 && e.reelRenderer()?.changeActiveMedia?.(a) && n.preventDefault();
1844
+ }
1845
+ y(() => {
1846
+ n = Tt(t), window.addEventListener("keydown", r);
1847
+ }), v(() => {
1848
+ window.removeEventListener("keydown", r), n?.(), n = null;
1849
+ });
1850
+ }
1851
+ //#endregion
1852
+ //#region src/components/VibeSurface.vue?vue&type=script&setup=true&lang.ts
1853
+ var Ot = 35, kt = 420, At = /* @__PURE__ */ d({
1786
1854
  __name: "VibeSurface",
1787
1855
  props: {
1788
1856
  canRetryEnd: { type: Boolean },
@@ -1804,93 +1872,100 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1804
1872
  "retryForward"
1805
1873
  ],
1806
1874
  setup(t, { expose: i, emit: c }) {
1807
- let l = t, d = c, f = w(null), p = w(null), h = w(null), g = w(null), x = w({}), S = w(!1), C = w(/* @__PURE__ */ new Set()), T = w(/* @__PURE__ */ new Map()), E = w(/* @__PURE__ */ new Set()), D = w(/* @__PURE__ */ new Map()), A = w(/* @__PURE__ */ new Map()), j = w(/* @__PURE__ */ new Map()), M = r(() => I(l.state)), P = r(() => l.state.reelMediaSource === "original" ? j.value : A.value), L = new Set(l.state.items.map((e) => e.postId)), R = null, z = null, B = !1;
1875
+ let l = t, d = c, f = w(null), p = w(null), h = w(null), g = w(null), y = w({}), x = w(!1), S = w(/* @__PURE__ */ new Set()), C = w(/* @__PURE__ */ new Map()), T = w(/* @__PURE__ */ new Set()), E = w(/* @__PURE__ */ new Map()), D = w(/* @__PURE__ */ new Map()), A = w(/* @__PURE__ */ new Map()), j = r(() => I(l.state)), P = r(() => l.state.reelMediaSource === "original" ? A.value : D.value), L = new Set(l.state.items.map((e) => e.postId)), R = null, z = null, B = !1;
1808
1876
  function V() {
1809
1877
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1810
1878
  }
1811
1879
  function H() {
1812
1880
  R !== null && cancelAnimationFrame(R), R = requestAnimationFrame(() => {
1813
1881
  R = requestAnimationFrame(() => {
1814
- R = null, C.value = /* @__PURE__ */ new Set();
1882
+ R = null, S.value = /* @__PURE__ */ new Set();
1815
1883
  });
1816
1884
  });
1817
1885
  }
1818
- function ee(e, t, n) {
1886
+ function U(e, t, n) {
1819
1887
  let r = F(e, t);
1820
- A.value.get(r) !== n && (A.value = new Map(A.value).set(r, n));
1888
+ D.value.get(r) !== n && (D.value = new Map(D.value).set(r, n));
1821
1889
  }
1822
- function te(e, t, n) {
1890
+ function W(e, t, n) {
1823
1891
  let r = F(e, t);
1824
- j.value.get(r) !== n && (j.value = new Map(j.value).set(r, n));
1892
+ A.value.get(r) !== n && (A.value = new Map(A.value).set(r, n));
1825
1893
  }
1826
- function ne(e, t) {
1827
- ee(e, t, "error");
1894
+ function ee(e, t) {
1895
+ U(e, t, "error");
1828
1896
  }
1829
- function U(e, t) {
1830
- ee(e, t, "ready");
1897
+ function G(e, t) {
1898
+ U(e, t, "ready");
1831
1899
  }
1832
- function W(e, t) {
1833
- te(e, t, "error");
1900
+ function K(e, t) {
1901
+ W(e, t, "error");
1834
1902
  }
1835
- function ie(e, t) {
1836
- te(e, t, "ready");
1903
+ function ne(e, t) {
1904
+ W(e, t, "ready");
1837
1905
  }
1838
- function G(e, t) {
1906
+ function q(e, t) {
1839
1907
  if (l.state.reelMediaSource === "original") {
1840
- W(e, t);
1908
+ K(e, t);
1841
1909
  return;
1842
1910
  }
1843
- ne(e, t);
1911
+ ee(e, t);
1844
1912
  }
1845
- function K(e, t) {
1913
+ function re(e, t) {
1846
1914
  if (l.state.reelMediaSource === "original") {
1847
- ie(e, t);
1915
+ ne(e, t);
1848
1916
  return;
1849
1917
  }
1850
- U(e, t);
1918
+ G(e, t);
1851
1919
  }
1852
- function q(e, t) {
1920
+ function J(e, t) {
1853
1921
  let n = l.state.items.find((t) => t.postId === e);
1854
1922
  if (!n) return;
1855
1923
  let r = N(n, t);
1856
1924
  (l.state.mediaIndices.get(e) ?? 0) !== r && (l.state.mediaIndices = new Map(l.state.mediaIndices).set(e, r));
1857
1925
  }
1858
- async function J() {
1926
+ async function ie() {
1859
1927
  await m(), (l.state.layout === "reel" || l.state.reelOrigin === "masonry" ? p.value : f.value)?.loadIfNearBottom();
1860
1928
  }
1861
1929
  function ae(e) {
1862
1930
  return l.state.isLoading || l.state.items.length === 0 || l.state.layout !== "reel" && l.state.reelOrigin !== "masonry" ? !1 : p.value?.changeActiveMedia?.(e) ?? !1;
1863
1931
  }
1864
- function Y(e) {
1932
+ function oe(e) {
1865
1933
  return l.state.isLoading || l.state.items.length === 0 || l.state.layout !== "reel" && l.state.reelOrigin !== "masonry" ? !1 : p.value?.moveActivePost?.(e) ?? !1;
1866
1934
  }
1867
- function oe() {
1935
+ function se(e) {
1936
+ if (!(l.state.layout === "reel" || l.state.reelOrigin === "masonry") || l.state.isLoading) return "reel-inactive";
1937
+ let t = l.state.items.find((t) => t.postId === e.postId);
1938
+ if (!t) return "not-found";
1939
+ let n = M(t).findIndex((t) => t.mediaId === e.mediaId);
1940
+ return n < 0 ? "not-found" : p.value?.navigateToItem?.(e.postId, n) ? "navigated" : "reel-inactive";
1941
+ }
1942
+ function ce() {
1868
1943
  return l.state.layout !== "masonry" || l.state.reelOrigin === "masonry" ? null : f.value?.getScrollElement?.() ?? null;
1869
1944
  }
1870
- function se(e, t) {
1871
- z = e, B = t === "keyboard", x.value = ue(e), d("openReel", e), m(() => h.value?.focus());
1945
+ function Y(e, t) {
1946
+ z = e, B = t === "keyboard", y.value = fe(e), d("openReel", e), m(() => h.value?.focus());
1872
1947
  }
1873
- function X(e) {
1948
+ function le(e) {
1874
1949
  let t = g.value?.querySelectorAll(".masonry-feed [data-post-id]") ?? [];
1875
1950
  return Array.from(t).find((t) => t.dataset.postId === String(e)) ?? null;
1876
1951
  }
1877
- function ce(e) {
1952
+ function ue(e) {
1878
1953
  if (l.state.layout !== "masonry" || l.state.reelOrigin !== null || V()) return 0;
1879
- let t = [...new Set(e)], n = t.filter(X);
1954
+ let t = [...new Set(e)], n = t.filter(le);
1880
1955
  if (n.length === 0) return 0;
1881
- let r = new Map(D.value);
1956
+ let r = new Map(E.value);
1882
1957
  return n.forEach((e, t) => {
1883
- r.set(e, t * wt);
1884
- }), C.value = new Set([...C.value].filter((e) => !n.includes(e))), E.value = new Set([...E.value, ...t]), D.value = r, Tt + (n.length - 1) * wt;
1958
+ r.set(e, t * Ot);
1959
+ }), S.value = new Set([...S.value].filter((e) => !n.includes(e))), T.value = new Set([...T.value, ...t]), E.value = r, kt + (n.length - 1) * Ot;
1885
1960
  }
1886
- function le(e, t) {
1887
- let n = X(e), r = n?.querySelector(".media-card-activator") ?? n;
1961
+ function de(e, t) {
1962
+ let n = le(e), r = n?.querySelector(".media-card-activator") ?? n;
1888
1963
  r && (r.classList.toggle("media-card-focus-silent", !t), t || r.addEventListener("blur", () => {
1889
1964
  r.classList.remove("media-card-focus-silent");
1890
1965
  }, { once: !0 }), r?.focus({ preventScroll: !0 }));
1891
1966
  }
1892
- function ue(e) {
1893
- let t = g.value, n = X(e);
1967
+ function fe(e) {
1968
+ let t = g.value, n = le(e);
1894
1969
  if (t === null || n === null) return {};
1895
1970
  let r = t.getBoundingClientRect(), i = n.getBoundingClientRect();
1896
1971
  return {
@@ -1900,53 +1975,41 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1900
1975
  "--vibe-reel-origin-left": `${Math.max(0, i.left - r.left)}px`
1901
1976
  };
1902
1977
  }
1903
- function de() {
1904
- l.state.reelOrigin === "masonry" && (z ??= l.state.activeReelPostId, S.value = !0, d("closeReel"));
1978
+ function X() {
1979
+ l.state.reelOrigin === "masonry" && (z ??= l.state.activeReelPostId, x.value = !0, d("closeReel"));
1905
1980
  }
1906
- function fe() {
1981
+ function Z() {
1907
1982
  let e = z, t = B;
1908
- S.value = !1, z = null, B = !1, x.value = {}, m(() => {
1909
- e !== null && le(e, t);
1983
+ x.value = !1, z = null, B = !1, y.value = {}, m(() => {
1984
+ e !== null && de(e, t);
1910
1985
  });
1911
1986
  }
1912
- function Z(e) {
1913
- let t = l.state.layout === "reel" || l.state.reelOrigin === "masonry";
1914
- if (e.key === "Escape" && l.state.reelOrigin === "masonry") {
1915
- e.preventDefault(), l.state.reelInfoSheetOverlay && l.state.reelInfoSheet.enabled && d("reelInfoSheetChange", !1), de();
1916
- return;
1917
- }
1918
- if (e.key === "Escape" && t && l.state.reelInfoSheet.enabled) {
1919
- e.preventDefault(), d("reelInfoSheetChange", !1);
1920
- return;
1921
- }
1922
- if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || S.value || l.state.layout !== "reel" && l.state.reelOrigin !== "masonry") return;
1923
- let n = e.target;
1924
- if (n instanceof HTMLElement && (n.isContentEditable || [
1925
- "INPUT",
1926
- "SELECT",
1927
- "TEXTAREA"
1928
- ].includes(n.tagName))) return;
1929
- let r = e.key === "ArrowLeft" ? -1 : e.key === "ArrowRight" ? 1 : 0;
1930
- r !== 0 && p.value?.changeActiveMedia?.(r) && e.preventDefault();
1931
- }
1932
- return O(() => l.state.items.map((e) => e.postId), (e) => {
1987
+ return Dt({
1988
+ closeMasonryReel: X,
1989
+ element: () => g.value,
1990
+ isReelLeaving: () => x.value,
1991
+ reelRenderer: () => p.value,
1992
+ setReelInfoSheet: (e) => d("reelInfoSheetChange", e),
1993
+ state: l.state
1994
+ }), O(() => l.state.items.map((e) => e.postId), (e) => {
1933
1995
  let t = e.filter((e) => !L.has(e)), n = new Set(e);
1934
- if (L = new Set(e), E.value = new Set([...E.value].filter((e) => n.has(e))), D.value = new Map([...D.value].filter(([e]) => n.has(e))), t.length === 0 || V()) return;
1996
+ if (L = new Set(e), T.value = new Set([...T.value].filter((e) => n.has(e))), E.value = new Map([...E.value].filter(([e]) => n.has(e))), t.length === 0 || V()) return;
1935
1997
  let r = /* @__PURE__ */ new Map();
1936
1998
  e.forEach((e) => {
1937
- let t = T.value.get(e);
1999
+ let t = C.value.get(e);
1938
2000
  t !== void 0 && r.set(e, t);
1939
2001
  }), t.forEach((e, t) => {
1940
- r.set(e, t * wt);
1941
- }), T.value = r, C.value = new Set([...C.value, ...t]), H();
1942
- }, { flush: "sync" }), y(() => window.addEventListener("keydown", Z)), v(() => {
1943
- window.removeEventListener("keydown", Z), R !== null && cancelAnimationFrame(R);
2002
+ r.set(e, t * Ot);
2003
+ }), C.value = r, S.value = new Set([...S.value, ...t]), H();
2004
+ }, { flush: "sync" }), v(() => {
2005
+ R !== null && cancelAnimationFrame(R);
1944
2006
  }), i({
1945
2007
  changeActiveReelMedia: ae,
1946
- getAutoScrollElement: oe,
1947
- loadIfNearBottom: J,
1948
- moveActiveReelPost: Y,
1949
- startItemRemoval: ce,
2008
+ getAutoScrollElement: ce,
2009
+ loadIfNearBottom: ie,
2010
+ moveActiveReelPost: oe,
2011
+ navigateToReelItem: se,
2012
+ startItemRemoval: ue,
1950
2013
  transitionActiveReelMedia: (e) => p.value?.transitionActiveMedia?.(e) ?? Promise.resolve(!1),
1951
2014
  transitionActiveReelPost: (e) => p.value?.transitionActivePost?.(e) ?? Promise.resolve(!1)
1952
2015
  }), (r, i) => (b(), s("div", {
@@ -1981,14 +2044,14 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1981
2044
  "preview-states": P.value,
1982
2045
  "reel-auto-advance": t.state.reelAutoAdvance,
1983
2046
  "reel-forward": t.state.reelForward,
1984
- state: M.value,
2047
+ state: j.value,
1985
2048
  total: t.state.total,
1986
2049
  onActiveChange: i[0] ||= (e) => d("activeReelChange", e),
1987
2050
  onCloseInfoSheet: i[1] ||= (e) => d("reelInfoSheetChange", !1),
1988
- onError: G,
2051
+ onError: q,
1989
2052
  onLoadMore: i[2] ||= (e) => d("loadMore"),
1990
- onMediaChange: q,
1991
- onReady: K,
2053
+ onMediaChange: J,
2054
+ onReady: re,
1992
2055
  onRetryEnd: i[3] ||= (e) => d("retryEnd"),
1993
2056
  onRetryForward: i[4] ||= (e) => d("retryForward")
1994
2057
  }, null, 8, [
@@ -2017,12 +2080,12 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
2017
2080
  "reel-forward",
2018
2081
  "state",
2019
2082
  "total"
2020
- ])) : t.state.error || t.state.isLoading || t.state.items.length === 0 && t.state.reelForward.status === "idle" ? (b(), a(re, {
2083
+ ])) : t.state.error || t.state.isLoading || t.state.items.length === 0 && t.state.reelForward.status === "idle" ? (b(), a(te, {
2021
2084
  key: 1,
2022
2085
  actions: t.feedFooterActions,
2023
2086
  "can-retry-end": t.canRetryEnd,
2024
2087
  "feed-footer": t.feedFooter,
2025
- state: M.value,
2088
+ state: j.value,
2026
2089
  onLoadMore: i[5] ||= (e) => d("loadMore"),
2027
2090
  onRetryEnd: i[6] ||= (e) => d("retryEnd")
2028
2091
  }, null, 8, [
@@ -2034,10 +2097,10 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
2034
2097
  ref_key: "masonryRenderer",
2035
2098
  ref: f,
2036
2099
  "can-retry-end": t.canRetryEnd,
2037
- "entering-post-ids": C.value,
2038
- "entry-delays": T.value,
2039
- "leaving-post-ids": E.value,
2040
- "removal-delays": D.value,
2100
+ "entering-post-ids": S.value,
2101
+ "entry-delays": C.value,
2102
+ "leaving-post-ids": T.value,
2103
+ "removal-delays": E.value,
2041
2104
  "card-footer": t.cardFooter,
2042
2105
  "card-header": t.cardHeader,
2043
2106
  "feed-footer": t.feedFooter,
@@ -2050,15 +2113,15 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
2050
2113
  "load-more-locked": t.state.loadMoreLocked,
2051
2114
  "media-indices": t.state.mediaIndices,
2052
2115
  "next-page-error": !!t.state.nextPageError,
2053
- "preview-states": A.value,
2054
- suspended: t.state.reelOrigin === "masonry" || S.value,
2055
- state: M.value,
2116
+ "preview-states": D.value,
2117
+ suspended: t.state.reelOrigin === "masonry" || x.value,
2118
+ state: j.value,
2056
2119
  total: t.state.total,
2057
- onActivate: se,
2058
- onError: ne,
2120
+ onActivate: Y,
2121
+ onError: ee,
2059
2122
  onLoadMore: i[7] ||= (e) => d("loadMore"),
2060
- onMediaChange: q,
2061
- onReady: U,
2123
+ onMediaChange: J,
2124
+ onReady: G,
2062
2125
  onRetryEnd: i[8] ||= (e) => d("retryEnd")
2063
2126
  }, null, 8, [
2064
2127
  "can-retry-end",
@@ -2084,7 +2147,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
2084
2147
  "total"
2085
2148
  ]), u(n, {
2086
2149
  name: "vibe-reel-viewer",
2087
- onAfterLeave: fe
2150
+ onAfterLeave: Z
2088
2151
  }, {
2089
2152
  default: k(() => [t.state.reelOrigin === "masonry" ? (b(), s("section", {
2090
2153
  key: 0,
@@ -2095,7 +2158,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
2095
2158
  "aria-label": "Media viewer",
2096
2159
  "aria-modal": "true",
2097
2160
  tabindex: "-1",
2098
- style: _(x.value)
2161
+ style: _(y.value)
2099
2162
  }, [u(Ct, {
2100
2163
  ref_key: "reelRenderer",
2101
2164
  ref: p,
@@ -2120,17 +2183,17 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
2120
2183
  "media-source": "original",
2121
2184
  "next-page-error": !!t.state.nextPageError,
2122
2185
  origin: "masonry",
2123
- "preview-states": j.value,
2186
+ "preview-states": A.value,
2124
2187
  "reel-auto-advance": t.state.reelAutoAdvance,
2125
2188
  "reel-forward": t.state.reelForward,
2126
- state: M.value,
2189
+ state: j.value,
2127
2190
  total: t.state.total,
2128
2191
  onActiveChange: i[9] ||= (e) => d("activeReelChange", e),
2129
2192
  onCloseInfoSheet: i[10] ||= (e) => d("reelInfoSheetChange", !1),
2130
- onError: W,
2193
+ onError: K,
2131
2194
  onLoadMore: i[11] ||= (e) => d("loadMore"),
2132
- onMediaChange: q,
2133
- onReady: ie,
2195
+ onMediaChange: J,
2196
+ onReady: ne,
2134
2197
  onRetryEnd: i[12] ||= (e) => d("retryEnd"),
2135
2198
  onRetryForward: i[13] ||= (e) => d("retryForward")
2136
2199
  }, null, 8, [
@@ -2165,7 +2228,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
2165
2228
  });
2166
2229
  //#endregion
2167
2230
  //#region src/core/page.ts
2168
- function Dt(e) {
2231
+ function jt(e) {
2169
2232
  if (!e || typeof e != "object" || !Array.isArray(e.items)) throw TypeError("Vibe loadPage must resolve to a page with an items array.");
2170
2233
  if (e.next !== null && typeof e.next != "string" && typeof e.next != "number") throw TypeError("Vibe page next must be a string, number, or null.");
2171
2234
  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.");
@@ -2177,32 +2240,32 @@ function Q(e, t) {
2177
2240
  }
2178
2241
  //#endregion
2179
2242
  //#region src/core/requestDelay.ts
2180
- var Ot = 2e3, kt = 1e4, At = 250, jt = {
2243
+ var Mt = 2e3, Nt = 1e4, Pt = 250, Ft = {
2181
2244
  delayRemainingMs: null,
2182
2245
  nextRequestAt: null
2183
2246
  };
2184
- function Mt(e, t) {
2247
+ function It(e, t) {
2185
2248
  return e === void 0 ? t : Math.floor(e);
2186
2249
  }
2187
- function Nt(e, t) {
2250
+ function Lt(e, t) {
2188
2251
  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.`);
2189
2252
  }
2190
- function Pt(e, t = {}) {
2191
- let n = Mt(t.delayStepMs, Ot), r = Mt(t.delayMaxMs, kt);
2253
+ function Rt(e, t = {}) {
2254
+ let n = It(t.delayStepMs, Mt), r = It(t.delayMaxMs, Nt);
2192
2255
  return Math.min(Math.max(0, e) * n, r);
2193
2256
  }
2194
2257
  function $(e) {
2195
- if (e == null || !Number.isFinite(e)) return { ...jt };
2258
+ if (e == null || !Number.isFinite(e)) return { ...Ft };
2196
2259
  let t = Math.max(0, Math.floor(e - Date.now()));
2197
2260
  return t > 0 ? {
2198
2261
  delayRemainingMs: t,
2199
2262
  nextRequestAt: e
2200
- } : { ...jt };
2263
+ } : { ...Ft };
2201
2264
  }
2202
- async function Ft({ delayMs: e, onChange: t, signal: n }) {
2265
+ async function zt({ delayMs: e, onChange: t, signal: n }) {
2203
2266
  if (n.aborted) throw new DOMException("Aborted", "AbortError");
2204
2267
  if (e <= 0) {
2205
- t({ ...jt });
2268
+ t({ ...Ft });
2206
2269
  return;
2207
2270
  }
2208
2271
  let r = Date.now() + e;
@@ -2210,9 +2273,9 @@ async function Ft({ delayMs: e, onChange: t, signal: n }) {
2210
2273
  delayRemainingMs: e,
2211
2274
  nextRequestAt: r
2212
2275
  }), await new Promise((i, a) => {
2213
- let o = !1, s = setInterval(f, At), c = setTimeout(() => u(), e);
2276
+ let o = !1, s = setInterval(f, Pt), c = setTimeout(() => u(), e);
2214
2277
  function l() {
2215
- clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...jt });
2278
+ clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Ft });
2216
2279
  }
2217
2280
  function u(e) {
2218
2281
  o || (o = !0, l(), e ? a(e) : i());
@@ -2227,13 +2290,13 @@ async function Ft({ delayMs: e, onChange: t, signal: n }) {
2227
2290
  n.addEventListener("abort", d, { once: !0 });
2228
2291
  });
2229
2292
  }
2230
- var It = class {
2293
+ var Bt = class {
2231
2294
  interval = null;
2232
2295
  constructor(e) {
2233
2296
  this.onChange = e;
2234
2297
  }
2235
2298
  clear() {
2236
- this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...jt });
2299
+ this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Ft });
2237
2300
  }
2238
2301
  sync(e) {
2239
2302
  this.clear();
@@ -2241,22 +2304,22 @@ var It = class {
2241
2304
  this.onChange(t), t.delayRemainingMs !== null && (this.interval = setInterval(() => {
2242
2305
  let t = $(e);
2243
2306
  this.onChange(t), t.delayRemainingMs === null && this.clear();
2244
- }, At));
2307
+ }, Pt));
2245
2308
  }
2246
2309
  };
2247
- function Lt(e, t = !0) {
2310
+ function Vt(e, t = !0) {
2248
2311
  return e.maxAdditionalPages === "unlimited" ? Infinity : (e.maxAdditionalPages ?? 10) + (t ? 1 : 0);
2249
2312
  }
2250
- function Rt(e) {
2313
+ function Ht(e) {
2251
2314
  return `${typeof e}:${String(e)}`;
2252
2315
  }
2253
- function zt(e, t) {
2316
+ function Ut(e, t) {
2254
2317
  if (!Number.isInteger(e) || e <= 0) throw TypeError(`Vibe ${t} must be a positive integer.`);
2255
2318
  }
2256
- function Bt(e) {
2319
+ function Wt(e) {
2257
2320
  if (!e) return;
2258
- if (zt(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2259
- Nt(e, "frontend autofill");
2321
+ if (Ut(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2322
+ Lt(e, "frontend autofill");
2260
2323
  let t = e.maxAdditionalPages;
2261
2324
  if (t !== void 0 && t !== "unlimited" && (!Number.isInteger(t) || t < 0)) throw TypeError("Vibe autofill maxAdditionalPages must be a non-negative integer or \"unlimited\".");
2262
2325
  return;
@@ -2268,7 +2331,7 @@ function Bt(e) {
2268
2331
  if (t.pageSize !== e.pageSize) throw TypeError("Vibe backend autofill initialSession pageSize must match autofill pageSize.");
2269
2332
  }
2270
2333
  }
2271
- function Vt(e, t, n = !0) {
2334
+ function Gt(e, t, n = !0) {
2272
2335
  if (!e) return {
2273
2336
  cycleId: null,
2274
2337
  delayRemainingMs: null,
@@ -2302,7 +2365,7 @@ function Vt(e, t, n = !0) {
2302
2365
  strategy: e.strategy
2303
2366
  };
2304
2367
  }
2305
- function Ht(e) {
2368
+ function Kt(e) {
2306
2369
  return [
2307
2370
  "cancelling",
2308
2371
  "filling",
@@ -2310,9 +2373,9 @@ function Ht(e) {
2310
2373
  "waiting"
2311
2374
  ].includes(e.status);
2312
2375
  }
2313
- async function Ut(e, t, n) {
2376
+ async function qt(e, t, n) {
2314
2377
  let r = t.autofill;
2315
- if (!Ht(r) || !r.cycleId) return;
2378
+ if (!Kt(r) || !r.cycleId) return;
2316
2379
  let i = {
2317
2380
  cycleId: r.cycleId,
2318
2381
  feedKey: r.feedKey ?? "",
@@ -2325,20 +2388,20 @@ async function Ut(e, t, n) {
2325
2388
  throw r.error = e, r.status = "error", e;
2326
2389
  }
2327
2390
  }
2328
- function Wt(e, t, n) {
2391
+ function Jt(e, t, n) {
2329
2392
  return e?.strategy === "backend" && t.feedKey === e.feedKey && t.sessionId === n.sessionId;
2330
2393
  }
2331
- async function Gt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onCollection: i, onDelayChange: a, onProgress: o, options: s, receivedOffset: c = 0, requestOffset: l = 0, signal: u }) {
2332
- let d = [], f = [...e], p = /* @__PURE__ */ new Set(), m = r ?? Lt(s), h = t, g = t, _ = 0, v;
2394
+ async function Yt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onCollection: i, onDelayChange: a, onProgress: o, options: s, receivedOffset: c = 0, requestOffset: l = 0, signal: u }) {
2395
+ let d = [], f = [...e], p = /* @__PURE__ */ new Set(), m = r ?? Vt(s), h = t, g = t, _ = 0, v;
2333
2396
  for (; _ < m;) {
2334
- let e = Rt(h);
2397
+ let e = Ht(h);
2335
2398
  if (p.has(e)) throw Error("Vibe autofill received a repeated cursor.");
2336
- p.add(e), await Ft({
2337
- delayMs: Pt(l + _, s),
2399
+ p.add(e), await zt({
2400
+ delayMs: Rt(l + _, s),
2338
2401
  onChange: a,
2339
2402
  signal: u
2340
2403
  });
2341
- let t = Dt(await n({
2404
+ let t = jt(await n({
2342
2405
  cursor: h,
2343
2406
  signal: u
2344
2407
  }));
@@ -2381,12 +2444,12 @@ async function Gt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
2381
2444
  }
2382
2445
  //#endregion
2383
2446
  //#region src/core/autofillController.ts
2384
- var Kt = class {
2447
+ var Xt = class {
2385
2448
  collection = null;
2386
2449
  cycle = 0;
2387
2450
  delayCountdown;
2388
2451
  constructor(e) {
2389
- this.context = e, this.delayCountdown = new It((t) => Object.assign(e.state.autofill, t)), this.syncCountdown();
2452
+ this.context = e, this.delayCountdown = new Bt((t) => Object.assign(e.state.autofill, t)), this.syncCountdown();
2390
2453
  }
2391
2454
  beginCycle() {
2392
2455
  let { options: e, state: t } = this.context;
@@ -2394,14 +2457,14 @@ var Kt = class {
2394
2457
  this.clear();
2395
2458
  let n = `vibe-autofill-${Date.now().toString(36)}-${++this.cycle}`;
2396
2459
  return t.autofill = {
2397
- ...Vt(e, void 0, !1),
2460
+ ...Gt(e, void 0, !1),
2398
2461
  cycleId: n,
2399
2462
  status: "filling"
2400
2463
  }, n;
2401
2464
  }
2402
2465
  async cancel() {
2403
2466
  let { cancelRequest: e, options: t, state: n } = this.context;
2404
- await Ut(t, n, e), this.commitCollection();
2467
+ await qt(t, n, e), this.commitCollection();
2405
2468
  }
2406
2469
  captureCollection(e, t) {
2407
2470
  t && (this.collection = e);
@@ -2429,30 +2492,30 @@ var Kt = class {
2429
2492
  requests: r.requests
2430
2493
  }));
2431
2494
  }
2432
- }, qt = 100;
2433
- function Jt(e, t) {
2495
+ }, Zt = 100;
2496
+ function Qt(e, t) {
2434
2497
  if (!Number.isFinite(t) || t <= 0) throw TypeError(`Vibe ${e} must be a positive number.`);
2435
2498
  }
2436
- function Yt(e, t, n) {
2499
+ function $t(e, t, n) {
2437
2500
  return Math.min(n, Math.max(t, e));
2438
2501
  }
2439
- function Xt(e) {
2502
+ function en(e) {
2440
2503
  if (!e) return;
2441
2504
  let t = e.minSpeedPxPerSecond ?? 20, n = e.maxSpeedPxPerSecond ?? 240;
2442
- if (Jt("autoScroll.minSpeedPxPerSecond", t), Jt("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2443
- e.speedPxPerSecond !== void 0 && Jt("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2505
+ if (Qt("autoScroll.minSpeedPxPerSecond", t), Qt("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2506
+ e.speedPxPerSecond !== void 0 && Qt("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2444
2507
  }
2445
- function Zt(e) {
2508
+ function tn(e) {
2446
2509
  let t = e?.minSpeedPxPerSecond ?? 20, n = e?.maxSpeedPxPerSecond ?? 240;
2447
2510
  return {
2448
2511
  enabled: e?.enabled ?? !1,
2449
2512
  maxSpeedPxPerSecond: n,
2450
2513
  minSpeedPxPerSecond: t,
2451
2514
  paused: !1,
2452
- speedPxPerSecond: Yt(e?.speedPxPerSecond ?? 80, t, n)
2515
+ speedPxPerSecond: $t(e?.speedPxPerSecond ?? 80, t, n)
2453
2516
  };
2454
2517
  }
2455
- var Qt = class {
2518
+ var nn = class {
2456
2519
  frame = null;
2457
2520
  lastTimestamp = null;
2458
2521
  mounted = !1;
@@ -2472,9 +2535,9 @@ var Qt = class {
2472
2535
  this.options.state.enabled && (this.options.state.paused = e, this.lastTimestamp = null, e ? this.cancelFrame() : this.schedule());
2473
2536
  }
2474
2537
  setSpeed(e) {
2475
- Jt("auto-scroll speed", e);
2538
+ Qt("auto-scroll speed", e);
2476
2539
  let t = this.options.state;
2477
- t.speedPxPerSecond = Yt(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2540
+ t.speedPxPerSecond = $t(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2478
2541
  }
2479
2542
  tick = (e) => {
2480
2543
  this.frame = null;
@@ -2486,7 +2549,7 @@ var Qt = class {
2486
2549
  return;
2487
2550
  }
2488
2551
  if (this.lastTimestamp !== null) {
2489
- let r = Math.min(qt, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2552
+ let r = Math.min(Zt, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2490
2553
  n.scrollTop = Math.min(i, n.scrollTop + t.speedPxPerSecond * r / 1e3);
2491
2554
  }
2492
2555
  this.lastTimestamp = e, this.schedule();
@@ -2500,7 +2563,7 @@ var Qt = class {
2500
2563
  };
2501
2564
  //#endregion
2502
2565
  //#region src/core/backendAutofill.ts
2503
- async function $t(e, t, n, r) {
2566
+ async function rn(e, t, n, r) {
2504
2567
  let i = await e.onUnderfilled(n);
2505
2568
  if (!r()) return;
2506
2569
  if (!i.sessionId.trim()) throw TypeError("Vibe backend autofill requires a sessionId.");
@@ -2514,19 +2577,19 @@ async function $t(e, t, n, r) {
2514
2577
  status: "waiting"
2515
2578
  });
2516
2579
  }
2517
- function en(e, t) {
2580
+ function an(e, t) {
2518
2581
  ["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);
2519
2582
  }
2520
- function tn(e, t, n) {
2583
+ function on(e, t, n) {
2521
2584
  let r = t.autofill;
2522
- return !Wt(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (en(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);
2585
+ return !Jt(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (an(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);
2523
2586
  }
2524
- function nn(e, t, n) {
2525
- return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Vt(e, n), en(t, n), !0);
2587
+ function sn(e, t, n) {
2588
+ return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Gt(e, n), an(t, n), !0);
2526
2589
  }
2527
2590
  //#endregion
2528
2591
  //#region src/core/initialAutofill.ts
2529
- async function rn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r, options: i, signal: a, state: o }) {
2592
+ async function cn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r, options: i, signal: a, state: o }) {
2530
2593
  let s = i.autofill;
2531
2594
  if (!s) return;
2532
2595
  let c = o.items.length;
@@ -2539,7 +2602,7 @@ async function rn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
2539
2602
  return;
2540
2603
  }
2541
2604
  if (s.strategy === "backend") {
2542
- await $t(s, o, {
2605
+ await rn(s, o, {
2543
2606
  cycleId: e,
2544
2607
  feedKey: s.feedKey,
2545
2608
  items: [...o.items],
@@ -2556,11 +2619,11 @@ async function rn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
2556
2619
  o.autofill.status = "exhausted";
2557
2620
  return;
2558
2621
  }
2559
- let l = await Gt({
2622
+ let l = await Yt({
2560
2623
  existingItems: o.items,
2561
2624
  initialCursor: o.next,
2562
2625
  loadPage: i.loadPage,
2563
- maximumRequests: Lt(s, !1),
2626
+ maximumRequests: Vt(s, !1),
2564
2627
  onCollection: n,
2565
2628
  onDelayChange: (e) => {
2566
2629
  t() && Object.assign(o.autofill, e);
@@ -2582,13 +2645,13 @@ async function rn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
2582
2645
  }
2583
2646
  //#endregion
2584
2647
  //#region src/core/fill.ts
2585
- function an(e) {
2648
+ function ln(e) {
2586
2649
  return "pages" in e ? { pages: e.pages } : { until: "end" };
2587
2650
  }
2588
- function on(e) {
2651
+ function un(e) {
2589
2652
  return `${typeof e}:${String(e)}`;
2590
2653
  }
2591
- function sn(e) {
2654
+ function dn(e) {
2592
2655
  if (!e || typeof e != "object") throw TypeError("Vibe fill target must be an object.");
2593
2656
  if ("pages" in e) {
2594
2657
  if (!Number.isInteger(e.pages) || e.pages <= 0) throw TypeError("Vibe fill pages must be a positive integer.");
@@ -2597,20 +2660,20 @@ function sn(e) {
2597
2660
  if ("until" in e && e.until === "end") return { until: "end" };
2598
2661
  throw TypeError("Vibe fill target must be { pages } or { until: 'end' }.");
2599
2662
  }
2600
- function cn(e) {
2663
+ function fn(e) {
2601
2664
  if (!e) return;
2602
2665
  if (e.strategy === "frontend") {
2603
- Nt(e, "frontend fill");
2666
+ Lt(e, "frontend fill");
2604
2667
  return;
2605
2668
  }
2606
2669
  if (!e.feedKey.trim()) throw TypeError("Vibe backend fill requires a feedKey.");
2607
2670
  let t = e.initialSession;
2608
2671
  if (t) {
2609
2672
  if (t.feedKey !== e.feedKey) throw TypeError("Vibe backend fill initialSession feedKey must match fill feedKey.");
2610
- sn(t.target);
2673
+ dn(t.target);
2611
2674
  }
2612
2675
  }
2613
- function ln(e, t, n = !0) {
2676
+ function pn(e, t, n = !0) {
2614
2677
  let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = $(i?.nextRequestAt);
2615
2678
  return {
2616
2679
  completedPages: i?.completedPages ?? 0,
@@ -2624,10 +2687,10 @@ function ln(e, t, n = !0) {
2624
2687
  sessionId: i?.sessionId ?? null,
2625
2688
  status: i?.status ?? "idle",
2626
2689
  strategy: e?.strategy ?? null,
2627
- target: i ? an(i.target) : null
2690
+ target: i ? ln(i.target) : null
2628
2691
  };
2629
2692
  }
2630
- function un(e) {
2693
+ function mn(e) {
2631
2694
  return [
2632
2695
  "cancelling",
2633
2696
  "filling",
@@ -2635,17 +2698,17 @@ function un(e) {
2635
2698
  "waiting"
2636
2699
  ].includes(e.status);
2637
2700
  }
2638
- async function dn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2701
+ async function hn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2639
2702
  let c = [], l = [...e], u = /* @__PURE__ */ new Set(), d = 0, f = t, p = t, m = 0, h;
2640
2703
  for (; p !== null;) {
2641
- let e = on(f);
2704
+ let e = un(f);
2642
2705
  if (u.has(e)) throw Error("Vibe fill received a repeated cursor.");
2643
- u.add(e), await Ft({
2644
- delayMs: Pt(d, a),
2706
+ u.add(e), await zt({
2707
+ delayMs: Rt(d, a),
2645
2708
  onChange: r,
2646
2709
  signal: o
2647
2710
  });
2648
- let t = Dt(await n({
2711
+ let t = jt(await n({
2649
2712
  cursor: f,
2650
2713
  signal: o
2651
2714
  }));
@@ -2687,7 +2750,7 @@ async function dn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChan
2687
2750
  }
2688
2751
  //#endregion
2689
2752
  //#region src/core/backendFill.ts
2690
- async function fn(e, t, n, r) {
2753
+ async function gn(e, t, n, r) {
2691
2754
  let i = await e.onStart(n);
2692
2755
  if (r()) {
2693
2756
  if (!i.sessionId.trim()) throw TypeError("Vibe backend fill requires a sessionId.");
@@ -2701,22 +2764,22 @@ async function fn(e, t, n, r) {
2701
2764
  });
2702
2765
  }
2703
2766
  }
2704
- function pn(e, t, n) {
2767
+ function _n(e, t, n) {
2705
2768
  return e?.strategy === "backend" && n.feedKey === e.feedKey && n.sessionId === t.fill.sessionId;
2706
2769
  }
2707
- function mn(e) {
2770
+ function vn(e) {
2708
2771
  return Number.isInteger(e.completedPages) && e.completedPages >= 0 && Number.isInteger(e.received) && e.received >= 0 && Number.isInteger(e.sequence) && e.sequence >= 0;
2709
2772
  }
2710
- function hn(e, t) {
2773
+ function yn(e, t) {
2711
2774
  if (!["complete", "exhausted"].includes(t.status)) return !0;
2712
2775
  let n = e.fill.target;
2713
2776
  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;
2714
2777
  }
2715
- function gn(e, t, n) {
2778
+ function bn(e, t, n) {
2716
2779
  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));
2717
2780
  }
2718
- function _n(e, t, n, r) {
2719
- return !pn(e, t, n) || !mn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !hn(t, n) ? !1 : (gn(t, n, r), Object.assign(t.fill, {
2781
+ function xn(e, t, n, r) {
2782
+ return !_n(e, t, n) || !vn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !yn(t, n) ? !1 : (bn(t, n, r), Object.assign(t.fill, {
2720
2783
  ...$(n.status === "waiting" ? n.nextRequestAt : null),
2721
2784
  completedPages: n.completedPages,
2722
2785
  error: n.error ?? null,
@@ -2725,41 +2788,41 @@ function _n(e, t, n, r) {
2725
2788
  status: n.status
2726
2789
  }), !0);
2727
2790
  }
2728
- function vn(e, t, n, r) {
2791
+ function Sn(e, t, n, r) {
2729
2792
  if (e?.strategy !== "backend" || n.feedKey !== e.feedKey) return !1;
2730
2793
  let i = t.fill;
2731
- return t.fill = ln(e, n), !mn(n) || !hn(t, n) ? (t.fill = i, !1) : (gn(t, n, r), !0);
2794
+ return t.fill = pn(e, n), !vn(n) || !yn(t, n) ? (t.fill = i, !1) : (bn(t, n, r), !0);
2732
2795
  }
2733
2796
  //#endregion
2734
2797
  //#region src/core/fillController.ts
2735
- var yn = class {
2798
+ var Cn = class {
2736
2799
  abortController = null;
2737
2800
  cycle = 0;
2738
2801
  delayCountdown;
2739
2802
  requestVersion = 0;
2740
2803
  constructor(e) {
2741
- this.options = e, this.delayCountdown = new It((e) => {
2804
+ this.options = e, this.delayCountdown = new Bt((e) => {
2742
2805
  Object.assign(this.options.state.fill, e);
2743
2806
  }), this.syncBackendCountdown();
2744
2807
  }
2745
2808
  isActive() {
2746
- return un(this.options.state.fill);
2809
+ return mn(this.options.state.fill);
2747
2810
  }
2748
2811
  applyUpdate(e) {
2749
- let t = _n(this.options.fill, this.options.state, e, this.options.onLastCursor);
2812
+ let t = xn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2750
2813
  return t && this.syncBackendCountdown(), t;
2751
2814
  }
2752
2815
  restoreSession(e) {
2753
- let t = vn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2816
+ let t = Sn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2754
2817
  return t && this.syncBackendCountdown(), t;
2755
2818
  }
2756
2819
  async start(e) {
2757
2820
  let t = this.options.fill;
2758
2821
  if (!t) throw Error("Vibe fill is not configured.");
2759
2822
  if (this.isActive()) throw Error("Vibe fill is already active.");
2760
- let n = sn(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2823
+ let n = dn(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2761
2824
  if (this.options.state.fill = {
2762
- ...ln(t, void 0, !1),
2825
+ ...pn(t, void 0, !1),
2763
2826
  cycleId: r,
2764
2827
  status: "filling",
2765
2828
  target: n
@@ -2770,7 +2833,7 @@ var yn = class {
2770
2833
  let i = ++this.requestVersion, a = new AbortController();
2771
2834
  this.abortController = a;
2772
2835
  try {
2773
- t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await fn(t, this.options.state, {
2836
+ t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await gn(t, this.options.state, {
2774
2837
  cycleId: r,
2775
2838
  feedKey: t.feedKey,
2776
2839
  items: [...this.options.state.items],
@@ -2788,7 +2851,7 @@ var yn = class {
2788
2851
  }
2789
2852
  async cancel() {
2790
2853
  let { fill: e, state: t } = this.options;
2791
- if (!un(t.fill) || !t.fill.cycleId) return;
2854
+ if (!mn(t.fill) || !t.fill.cycleId) return;
2792
2855
  let n = {
2793
2856
  cycleId: t.fill.cycleId,
2794
2857
  feedKey: t.fill.feedKey ?? "",
@@ -2802,7 +2865,7 @@ var yn = class {
2802
2865
  }
2803
2866
  }
2804
2867
  reset() {
2805
- this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = ln(this.options.fill, void 0, !1);
2868
+ this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = pn(this.options.fill, void 0, !1);
2806
2869
  }
2807
2870
  destroy() {
2808
2871
  this.abortLocalRequest(), this.delayCountdown.clear();
@@ -2818,7 +2881,7 @@ var yn = class {
2818
2881
  if (!i) throw Error("Vibe frontend fill requires loadPage.");
2819
2882
  let a = this.options.state;
2820
2883
  a.isLoadingMore = !0;
2821
- let o = await dn({
2884
+ let o = await hn({
2822
2885
  existingItems: a.items,
2823
2886
  initialCursor: a.next,
2824
2887
  loadPage: i,
@@ -2845,7 +2908,7 @@ var yn = class {
2845
2908
  };
2846
2909
  //#endregion
2847
2910
  //#region src/core/feedFooter.ts
2848
- function bn(e) {
2911
+ function wn(e) {
2849
2912
  return {
2850
2913
  cancelAutofill: () => e.cancelAutofill(),
2851
2914
  loadMore: () => e.loadNext(),
@@ -2853,45 +2916,45 @@ function bn(e) {
2853
2916
  retryEnd: () => e.retryEnd()
2854
2917
  };
2855
2918
  }
2856
- function xn(e) {
2919
+ function Tn(e) {
2857
2920
  if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
2858
2921
  }
2859
- function Sn(e) {
2860
- e?.intervalMs !== void 0 && xn(e.intervalMs);
2922
+ function En(e) {
2923
+ e?.intervalMs !== void 0 && Tn(e.intervalMs);
2861
2924
  }
2862
- function Cn(e) {
2925
+ function Dn(e) {
2863
2926
  return {
2864
2927
  enabled: e?.enabled ?? !1,
2865
2928
  includePostItems: e?.includePostItems ?? !1,
2866
2929
  intervalMs: e?.intervalMs ?? 5e3
2867
2930
  };
2868
2931
  }
2869
- function wn(e, t) {
2932
+ function On(e, t) {
2870
2933
  if (typeof t == "boolean") {
2871
2934
  e.enabled = t;
2872
2935
  return;
2873
2936
  }
2874
- Sn(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);
2937
+ En(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);
2875
2938
  }
2876
2939
  //#endregion
2877
2940
  //#region src/core/reelInfoSheet.ts
2878
- function Tn(e) {
2941
+ function kn(e) {
2879
2942
  return { enabled: e?.enabled ?? !1 };
2880
2943
  }
2881
- function En(e, t, n) {
2944
+ function An(e, t, n) {
2882
2945
  if (n && !t) throw Error("Vibe cannot enable reelInfoSheet without a configured component.");
2883
2946
  e.enabled = n;
2884
2947
  }
2885
2948
  //#endregion
2886
2949
  //#region src/core/initialRuntimeState.ts
2887
- function Dn(e, t) {
2950
+ function jn(e, t) {
2888
2951
  let n = e.initialPage;
2889
2952
  return {
2890
2953
  activeReelPostId: null,
2891
- autoScroll: Zt(e.autoScroll),
2892
- autofill: Vt(e.autofill),
2954
+ autoScroll: tn(e.autoScroll),
2955
+ autofill: Gt(e.autofill),
2893
2956
  error: null,
2894
- fill: ln(e.fill),
2957
+ fill: pn(e.fill),
2895
2958
  infiniteScroll: e.infiniteScroll ?? !0,
2896
2959
  isLoading: !n,
2897
2960
  isLoadingMore: !1,
@@ -2901,14 +2964,14 @@ function Dn(e, t) {
2901
2964
  mediaIndices: /* @__PURE__ */ new Map(),
2902
2965
  next: n?.next ?? null,
2903
2966
  nextPageError: null,
2904
- reelAutoAdvance: Cn(e.reelAutoAdvance),
2967
+ reelAutoAdvance: Dn(e.reelAutoAdvance),
2905
2968
  reelForward: {
2906
2969
  error: null,
2907
2970
  status: "idle"
2908
2971
  },
2909
2972
  reelForwardIndex: null,
2910
2973
  reelForwardItem: null,
2911
- reelInfoSheet: Tn(e.reelInfoSheet),
2974
+ reelInfoSheet: kn(e.reelInfoSheet),
2912
2975
  reelInfoSheetOverlay: !1,
2913
2976
  reelMediaSource: "original",
2914
2977
  reelOrigin: null,
@@ -2917,26 +2980,26 @@ function Dn(e, t) {
2917
2980
  }
2918
2981
  //#endregion
2919
2982
  //#region src/core/options.ts
2920
- function On(e, t) {
2983
+ function Mn(e, t) {
2921
2984
  if (t) {
2922
2985
  if (!Number.isFinite(t.height) || t.height <= 0) throw TypeError(`Vibe ${e} height must be a positive number.`);
2923
2986
  if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe ${e} background must be "default" or "transparent".`);
2924
2987
  }
2925
2988
  }
2926
- function kn(e, t) {
2989
+ function Nn(e, t) {
2927
2990
  if (t) {
2928
2991
  if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe mediaCard ${e} background must be "default" or "transparent".`);
2929
2992
  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.`);
2930
2993
  }
2931
2994
  }
2932
- function An(e) {
2933
- if (Xt(e.autoScroll), On("cardHeader", e.cardHeader), On("cardFooter", e.cardFooter), kn("header", e.mediaCard?.header), kn("footer", e.mediaCard?.footer), Bt(e.autofill), cn(e.fill), Sn(e.reelAutoAdvance), e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
2995
+ function Pn(e) {
2996
+ if (en(e.autoScroll), Mn("cardHeader", e.cardHeader), Mn("cardFooter", e.cardFooter), Nn("header", e.mediaCard?.header), Nn("footer", e.mediaCard?.footer), Wt(e.autofill), fn(e.fill), En(e.reelAutoAdvance), e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
2934
2997
  if (!e.initialPage && !e.loadPage) throw TypeError("Vibe requires either initialPage or loadPage.");
2935
2998
  if (e.initialPage?.next !== null && !e.loadPage) throw TypeError("Vibe requires loadPage when initialPage has a next cursor.");
2936
2999
  if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
2937
3000
  if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
2938
3001
  }
2939
- function jn(e) {
3002
+ function Fn(e) {
2940
3003
  if (typeof e != "string") return e;
2941
3004
  if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
2942
3005
  let t = document.querySelector(e);
@@ -2945,7 +3008,7 @@ function jn(e) {
2945
3008
  }
2946
3009
  //#endregion
2947
3010
  //#region src/core/activeItemRemoval.ts
2948
- function Mn(e, t, n, r, i) {
3011
+ function In(e, t, n, r, i) {
2949
3012
  let a = new Set(t.map(({ item: e }) => e.postId));
2950
3013
  if (e.activeReelPostId === null || !a.has(e.activeReelPostId)) return;
2951
3014
  let o = e.items[Math.max(n, 0)];
@@ -2958,7 +3021,7 @@ function Mn(e, t, n, r, i) {
2958
3021
  }
2959
3022
  //#endregion
2960
3023
  //#region src/core/exactMediaRemovalController.ts
2961
- function Nn(e, t) {
3024
+ function Ln(e, t) {
2962
3025
  let [n, ...r] = t;
2963
3026
  if (!n) throw Error("Vibe items must contain at least one media asset.");
2964
3027
  return {
@@ -2967,10 +3030,10 @@ function Nn(e, t) {
2967
3030
  items: r
2968
3031
  };
2969
3032
  }
2970
- function Pn(e) {
3033
+ function Rn(e) {
2971
3034
  if (!Number.isInteger(e.mediaIndex) || e.mediaIndex < 0) throw TypeError("Vibe mediaIndex must be a non-negative integer.");
2972
3035
  }
2973
- var Fn = class {
3036
+ var zn = class {
2974
3037
  generation = 0;
2975
3038
  metadata = /* @__PURE__ */ new WeakMap();
2976
3039
  state;
@@ -2978,7 +3041,7 @@ var Fn = class {
2978
3041
  this.options = e, this.state = e.state;
2979
3042
  }
2980
3043
  remove(e) {
2981
- Pn(e);
3044
+ Rn(e);
2982
3045
  let t = this.state.items.findIndex(({ postId: t }) => t === e.postId), n = this.state.items[t];
2983
3046
  if (!n) return null;
2984
3047
  let r = [...M(n)], i = r[e.mediaIndex];
@@ -2995,7 +3058,7 @@ var Fn = class {
2995
3058
  restored: !1
2996
3059
  });
2997
3060
  let o = this.state.mediaIndices.get(n.postId) ?? 0, s = this.isReelOpen() && this.state.activeReelPostId === n.postId, c = s && o === e.mediaIndex;
2998
- return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = Nn(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);
3061
+ return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = Ln(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);
2999
3062
  }
3000
3063
  reset() {
3001
3064
  this.generation += 1;
@@ -3021,7 +3084,7 @@ var Fn = class {
3021
3084
  }
3022
3085
  restoreIntoPost(e, t) {
3023
3086
  let n = this.state.items[e], r = [...M(n)], i = Math.min(t.mediaIndex, r.length);
3024
- if (r.splice(i, 0, t.media), this.state.items[e] = Nn(n, r), this.state.activeReelPostId !== t.postId) return;
3087
+ if (r.splice(i, 0, t.media), this.state.items[e] = Ln(n, r), this.state.activeReelPostId !== t.postId) return;
3025
3088
  let a = this.state.mediaIndices.get(t.postId) ?? 0;
3026
3089
  a >= i && this.state.mediaIndices.set(t.postId, a + 1);
3027
3090
  }
@@ -3034,18 +3097,18 @@ var Fn = class {
3034
3097
  };
3035
3098
  //#endregion
3036
3099
  //#region src/core/itemPlacement.ts
3037
- function In(e, t) {
3100
+ function Bn(e, t) {
3038
3101
  let n = new Set(t);
3039
3102
  return e.flatMap((e, t) => n.has(e.postId) ? [{
3040
3103
  index: t,
3041
3104
  item: e
3042
3105
  }] : []);
3043
3106
  }
3044
- function Ln(e, t) {
3107
+ function Vn(e, t) {
3045
3108
  let n = new Set(t.map(({ item: e }) => e.postId));
3046
3109
  return e.filter((e) => !n.has(e.postId));
3047
3110
  }
3048
- function Rn(e, t) {
3111
+ function Hn(e, t) {
3049
3112
  t.forEach(({ index: e }) => {
3050
3113
  if (!Number.isInteger(e) || e < 0) throw Error("Vibe item restore indexes must be non-negative integers.");
3051
3114
  });
@@ -3056,7 +3119,7 @@ function Rn(e, t) {
3056
3119
  }
3057
3120
  //#endregion
3058
3121
  //#region src/core/itemRemovalController.ts
3059
- var zn = 20, Bn = class {
3122
+ var Un = 20, Wn = class {
3060
3123
  generation = 0;
3061
3124
  historyLimit;
3062
3125
  metadata = /* @__PURE__ */ new WeakMap();
@@ -3065,7 +3128,7 @@ var zn = 20, Bn = class {
3065
3128
  itemOrder;
3066
3129
  stopItemsWatcher;
3067
3130
  constructor(e) {
3068
- this.options = e, this.historyLimit = e.historyLimit ?? zn, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = O(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
3131
+ this.options = e, this.historyLimit = e.historyLimit ?? Un, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = O(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
3069
3132
  }
3070
3133
  destroy() {
3071
3134
  this.reset(), this.stopItemsWatcher();
@@ -3078,7 +3141,7 @@ var zn = 20, Bn = class {
3078
3141
  let i = this.options.startRemoval(r);
3079
3142
  if (i > 0 && await new Promise((e) => setTimeout(e, i)), this.metadata.get(n)?.generation !== this.generation) return n;
3080
3143
  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);
3081
- return this.state.items = Ln(this.state.items, t), this.options.onItemsRemoved(n, t, c), this.record(n), n;
3144
+ return this.state.items = Vn(this.state.items, t), this.options.onItemsRemoved(n, t, c), this.record(n), n;
3082
3145
  }
3083
3146
  reset() {
3084
3147
  this.generation += 1, this.history = [], this.itemOrder = [];
@@ -3089,7 +3152,7 @@ var zn = 20, Bn = class {
3089
3152
  this.restoreRemoval(t);
3090
3153
  return;
3091
3154
  }
3092
- let n = Rn(this.state.items, e);
3155
+ let n = Hn(this.state.items, e);
3093
3156
  this.registerExternalPlacements(e), this.state.items = n;
3094
3157
  }
3095
3158
  restoreRemoval(e) {
@@ -3115,7 +3178,7 @@ var zn = 20, Bn = class {
3115
3178
  }
3116
3179
  collectOrderedPlacements(e) {
3117
3180
  let t = new Map(this.itemOrder.map((e, t) => [e, t]));
3118
- return In(this.state.items, e).map((e) => ({
3181
+ return Bn(this.state.items, e).map((e) => ({
3119
3182
  index: t.get(e.item.postId) ?? e.index,
3120
3183
  item: e.item
3121
3184
  }));
@@ -3146,7 +3209,7 @@ var zn = 20, Bn = class {
3146
3209
  let r = new Map(this.itemOrder.map((e, t) => [e, t]));
3147
3210
  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;
3148
3211
  }
3149
- }, Vn = class {
3212
+ }, Gn = class {
3150
3213
  forward = null;
3151
3214
  forwardPromise = null;
3152
3215
  forwardVersion = 0;
@@ -3224,7 +3287,7 @@ var zn = 20, Bn = class {
3224
3287
  }
3225
3288
  }
3226
3289
  }
3227
- }, Hn = class {
3290
+ }, Kn = class {
3228
3291
  generation = 0;
3229
3292
  pending = Promise.resolve();
3230
3293
  constructor(e) {
@@ -3274,22 +3337,22 @@ var zn = 20, Bn = class {
3274
3337
  };
3275
3338
  //#endregion
3276
3339
  //#region src/core/removalControllers.ts
3277
- function Un(e) {
3278
- let t = new Vn(e), n = new Hn({
3340
+ function qn(e) {
3341
+ let t = new Gn(e), n = new Kn({
3279
3342
  state: e.state,
3280
3343
  transitionMedia: (t) => e.surface()?.transitionActiveReelMedia(t) ?? Promise.resolve(!1),
3281
3344
  transitionPost: (t) => e.surface()?.transitionActiveReelPost(t) ?? Promise.resolve(!1)
3282
3345
  });
3283
3346
  return {
3284
- exactMediaRemoval: new Fn({
3347
+ exactMediaRemoval: new zn({
3285
3348
  onActivate: e.onActivate,
3286
3349
  reelForward: t,
3287
3350
  state: e.state
3288
3351
  }),
3289
- itemRemoval: new Bn({
3352
+ itemRemoval: new Wn({
3290
3353
  historyLimit: e.historyLimit,
3291
3354
  onItemsRemoved: (n, r, i) => {
3292
- Mn(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
3355
+ In(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
3293
3356
  },
3294
3357
  onRemovalRestored: (n) => {
3295
3358
  let r = t.cancel(n);
@@ -3303,17 +3366,17 @@ function Un(e) {
3303
3366
  reelRemoval: n
3304
3367
  };
3305
3368
  }
3306
- var Wn = 1.5;
3307
- function Gn(e) {
3369
+ var Jn = 1.5;
3370
+ function Yn(e) {
3308
3371
  let t = Math.min(e.screenWidth, e.screenHeight);
3309
3372
  if (t > 0 && t < 600) return !0;
3310
- let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * Wn;
3373
+ let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * Jn;
3311
3374
  return !e.hasHover && n > 0 && n < 600 && r;
3312
3375
  }
3313
- function Kn(e) {
3314
- return Gn(e) ? "reel" : "masonry";
3376
+ function Xn(e) {
3377
+ return Yn(e) ? "reel" : "masonry";
3315
3378
  }
3316
- function qn(e) {
3379
+ function Zn(e) {
3317
3380
  let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
3318
3381
  return {
3319
3382
  hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
@@ -3323,15 +3386,15 @@ function qn(e) {
3323
3386
  viewportWidth: n.clientWidth
3324
3387
  };
3325
3388
  }
3326
- function Jn(e) {
3327
- return Gn(qn(e));
3389
+ function Qn(e) {
3390
+ return Yn(Zn(e));
3328
3391
  }
3329
- function Yn(e) {
3330
- return Kn(qn(e));
3392
+ function $n(e) {
3393
+ return Xn(Zn(e));
3331
3394
  }
3332
3395
  //#endregion
3333
3396
  //#region src/core/responsiveLayoutController.ts
3334
- var Xn = class {
3397
+ var er = class {
3335
3398
  layoutMode;
3336
3399
  resizeObserver = null;
3337
3400
  target = null;
@@ -3356,10 +3419,10 @@ var Xn = class {
3356
3419
  }
3357
3420
  handleResponsiveLayout = () => {
3358
3421
  if (!this.target) return;
3359
- let e = Yn(this.target);
3360
- this.state.reelInfoSheetOverlay = Jn(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
3422
+ let e = $n(this.target);
3423
+ this.state.reelInfoSheetOverlay = Qn(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
3361
3424
  };
3362
- }, Zn = class {
3425
+ }, tr = class {
3363
3426
  routedReelPostId = null;
3364
3427
  reelRouteIsActive = !1;
3365
3428
  constructor(e, t) {
@@ -3386,7 +3449,7 @@ var Xn = class {
3386
3449
  let i = this.reelRouteIsActive ? "replace" : "push";
3387
3450
  this.reelRouteIsActive = !0, this.routedReelPostId = e, this.options.router[i](r);
3388
3451
  }
3389
- }, Qn = class {
3452
+ }, nr = class {
3390
3453
  app = null;
3391
3454
  autoScroll;
3392
3455
  autofillController;
@@ -3405,27 +3468,27 @@ var Xn = class {
3405
3468
  lastLoadedCursor = null;
3406
3469
  state;
3407
3470
  constructor(e) {
3408
- this.options = e, An(e);
3471
+ this.options = e, Pn(e);
3409
3472
  let t = e.layout ?? "masonry";
3410
- this.state = x(Dn(e, t)), this.autoScroll = new Qt({
3473
+ this.state = x(jn(e, t)), this.autoScroll = new nn({
3411
3474
  getScrollElement: () => this.surface?.getAutoScrollElement() ?? null,
3412
3475
  state: this.state.autoScroll
3413
- }), this.autofillController = new Kt({
3476
+ }), this.autofillController = new Xt({
3414
3477
  cancelRequest: () => this.cancelRequest(),
3415
3478
  onLastCursor: (e) => {
3416
3479
  this.lastLoadedCursor = e;
3417
3480
  },
3418
3481
  options: e.autofill,
3419
3482
  state: this.state
3420
- }), this.fillController = new yn({
3483
+ }), this.fillController = new Cn({
3421
3484
  fill: e.fill,
3422
3485
  loadPage: e.loadPage,
3423
3486
  onLastCursor: (e) => {
3424
3487
  this.lastLoadedCursor = e;
3425
3488
  },
3426
3489
  state: this.state
3427
- }), this.routing = new Zn(e.routing, this.state);
3428
- let n = Un({
3490
+ }), this.routing = new tr(e.routing, this.state);
3491
+ let n = qn({
3429
3492
  historyLimit: e.removalHistoryLimit,
3430
3493
  loadNext: () => this.loadNext(),
3431
3494
  onActivate: (e) => this.setActiveReelPost(e),
@@ -3433,20 +3496,20 @@ var Xn = class {
3433
3496
  state: this.state,
3434
3497
  surface: () => this.surface
3435
3498
  });
3436
- this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new Xn(t, this.state, () => {
3499
+ this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new er(t, this.state, () => {
3437
3500
  this.routing.syncFeed();
3438
3501
  }), this.startStateNotifications();
3439
3502
  }
3440
3503
  async mount() {
3441
3504
  if (this.app) throw Error("Vibe is already mounted.");
3442
3505
  this.startStateNotifications();
3443
- let e = jn(this.options.target);
3444
- this.responsiveLayout.mount(e), this.app = i(Et, {
3506
+ let e = Fn(this.options.target);
3507
+ this.responsiveLayout.mount(e), this.app = i(At, {
3445
3508
  canRetryEnd: !!this.options.loadPage,
3446
3509
  cardFooter: this.options.cardFooter,
3447
3510
  cardHeader: this.options.cardHeader,
3448
3511
  feedFooter: this.options.feedFooter,
3449
- feedFooterActions: bn(this),
3512
+ feedFooterActions: wn(this),
3450
3513
  mediaCard: this.options.mediaCard,
3451
3514
  reelInfoSheet: this.options.reelInfoSheet,
3452
3515
  state: this.state,
@@ -3509,6 +3572,9 @@ var Xn = class {
3509
3572
  previousReelPost() {
3510
3573
  return this.surface?.moveActiveReelPost(-1) ?? !1;
3511
3574
  }
3575
+ navigateToReelItem(e) {
3576
+ return this.surface?.navigateToReelItem(e) ?? "reel-inactive";
3577
+ }
3512
3578
  pauseAutoScroll() {
3513
3579
  this.autoScroll.setPaused(!0);
3514
3580
  }
@@ -3522,7 +3588,7 @@ var Xn = class {
3522
3588
  this.autoScroll.setSpeed(e);
3523
3589
  }
3524
3590
  applyAutofillUpdate(e) {
3525
- let t = tn(this.options.autofill, this.state, e);
3591
+ let t = on(this.options.autofill, this.state, e);
3526
3592
  return t && this.autofillController.syncCountdown(), t;
3527
3593
  }
3528
3594
  cancelAutofill() {
@@ -3535,11 +3601,11 @@ var Xn = class {
3535
3601
  return this.fillController.cancel();
3536
3602
  }
3537
3603
  async fill(e) {
3538
- if (this.pendingRequest || Ht(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
3604
+ if (this.pendingRequest || Kt(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
3539
3605
  await this.fillController.start(e);
3540
3606
  }
3541
3607
  restoreAutofillSession(e) {
3542
- let t = nn(this.options.autofill, this.state, e);
3608
+ let t = sn(this.options.autofill, this.state, e);
3543
3609
  return t && this.autofillController.syncCountdown(), t;
3544
3610
  }
3545
3611
  restoreFillSession(e) {
@@ -3547,7 +3613,7 @@ var Xn = class {
3547
3613
  }
3548
3614
  async loadNext() {
3549
3615
  if (this.pendingRequest) return this.pendingRequest;
3550
- if (!this.state.loadMoreLocked && !(Ht(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);
3616
+ if (!this.state.loadMoreLocked && !(Kt(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);
3551
3617
  }
3552
3618
  async refresh() {
3553
3619
  return this.replaceFeed(this.state.next ?? this.lastLoadedCursor, "refresh");
@@ -3557,11 +3623,11 @@ var Xn = class {
3557
3623
  }
3558
3624
  async replaceFeed(e, t) {
3559
3625
  if (!this.options.loadPage) throw Error(`Vibe cannot ${t} without loadPage.`);
3560
- return Ht(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Vt(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);
3626
+ return Kt(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Gt(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);
3561
3627
  }
3562
3628
  async retryEnd() {
3563
3629
  if (this.pendingRequest) return this.pendingRequest;
3564
- if (!this.state.loadMoreLocked && !(Ht(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);
3630
+ if (!this.state.loadMoreLocked && !(Kt(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);
3565
3631
  }
3566
3632
  setInfiniteScroll(e) {
3567
3633
  this.state.infiniteScroll = e, e && m(() => this.surface?.loadIfNearBottom());
@@ -3570,10 +3636,10 @@ var Xn = class {
3570
3636
  this.state.loadMoreLocked !== e && (this.state.loadMoreLocked = e, !e && this.state.infiniteScroll && m(() => this.surface?.loadIfNearBottom()));
3571
3637
  }
3572
3638
  setReelAutoAdvance(e) {
3573
- wn(this.state.reelAutoAdvance, e);
3639
+ On(this.state.reelAutoAdvance, e);
3574
3640
  }
3575
3641
  setReelInfoSheet(e) {
3576
- En(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
3642
+ An(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
3577
3643
  }
3578
3644
  setLayout(e) {
3579
3645
  this.responsiveLayout.setLayout(e);
@@ -3597,7 +3663,7 @@ var Xn = class {
3597
3663
  this.abortController = i;
3598
3664
  try {
3599
3665
  if (a?.strategy === "frontend") {
3600
- let o = await Gt({
3666
+ let o = await Yt({
3601
3667
  existingItems: t ? this.state.items : [],
3602
3668
  initialCursor: e,
3603
3669
  loadPage: n,
@@ -3620,7 +3686,7 @@ var Xn = class {
3620
3686
  }), this.autofillController.clearCollection();
3621
3687
  return;
3622
3688
  }
3623
- let c = Dt(await n({
3689
+ let c = jt(await n({
3624
3690
  cursor: e,
3625
3691
  signal: i.signal
3626
3692
  }));
@@ -3635,7 +3701,7 @@ var Xn = class {
3635
3701
  this.state.autofill.status = "complete";
3636
3702
  return;
3637
3703
  }
3638
- await $t(a, this.state, {
3704
+ await rn(a, this.state, {
3639
3705
  cycleId: o,
3640
3706
  feedKey: a.feedKey,
3641
3707
  items: u.slice(l.length),
@@ -3663,7 +3729,7 @@ var Xn = class {
3663
3729
  startInitialAutofill() {
3664
3730
  let e = ++this.requestVersion, t = new AbortController(), n = this.autofillController.beginCycle();
3665
3731
  this.abortController = t, this.state.isLoadingMore = !0;
3666
- let r = rn({
3732
+ let r = cn({
3667
3733
  cycleId: n,
3668
3734
  isCurrent: () => e === this.requestVersion,
3669
3735
  onCollection: (t) => this.autofillController.captureCollection(t, e === this.requestVersion),
@@ -3688,8 +3754,8 @@ var Xn = class {
3688
3754
  }));
3689
3755
  }
3690
3756
  };
3691
- function $n(e) {
3692
- return new Qn(e);
3757
+ function rr(e) {
3758
+ return new nr(e);
3693
3759
  }
3694
3760
  //#endregion
3695
- export { $n as createVibe };
3761
+ export { rr as createVibe };