@wyxos/vibe 4.2.1 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -138,7 +138,7 @@ var I = {
138
138
  "load-more-locked"
139
139
  ]));
140
140
  }
141
- }), W = ["role"], ee = { class: "gallery-status" }, G = /* @__PURE__ */ u({
141
+ }), W = ["role"], ee = { class: "gallery-status" }, te = /* @__PURE__ */ u({
142
142
  __name: "FeedStatus",
143
143
  props: {
144
144
  actions: {},
@@ -178,33 +178,33 @@ var I = {
178
178
  ])) : a("", !0)], 8, W));
179
179
  }
180
180
  });
181
- function K(e) {
181
+ function G(e) {
182
182
  return e.scrollHeight - e.scrollTop - e.clientHeight <= 240;
183
183
  }
184
184
  //#endregion
185
185
  //#region src/core/masonry.ts
186
- function te(e) {
186
+ function ne(e) {
187
187
  let t = e.preview.width ?? e.width, n = e.preview.height ?? e.height;
188
188
  return !t || !n || t <= 0 || n <= 0 ? 1 : n / t;
189
189
  }
190
- function ne(e) {
190
+ function K(e) {
191
191
  return e.reduce((t, n, r) => n < e[t] ? r : t, 0);
192
192
  }
193
- function re(e) {
193
+ function q(e) {
194
194
  return Math.max(0, e.containerHeight) + Math.max(0, e.gap);
195
195
  }
196
- function q(e, t) {
196
+ function J(e, t) {
197
197
  let n = Math.max(0, t.overscan), r = t.scrollTop - n, i = t.scrollTop + Math.max(0, t.viewportHeight) + n;
198
198
  return e.reduce((e, t, n) => (t.y + t.height >= r && t.y <= i && e.push(n), e), []);
199
199
  }
200
- function J(e, t, n) {
200
+ function Y(e, t, n) {
201
201
  if (t <= 0 || e.length === 0) return {
202
202
  columns: 0,
203
203
  height: 0,
204
204
  items: []
205
205
  };
206
206
  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) => {
207
- let t = ne(c), n = s * te(e) + i, a = {
207
+ let t = K(c), n = s * ne(e) + i, a = {
208
208
  x: t * (s + r),
209
209
  y: c[t],
210
210
  width: s,
@@ -220,10 +220,10 @@ function J(e, t, n) {
220
220
  }
221
221
  //#endregion
222
222
  //#region src/core/scrollbar.ts
223
- function Y(e, t, n) {
223
+ function X(e, t, n) {
224
224
  return Math.min(n, Math.max(t, e));
225
225
  }
226
- function ie({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
226
+ function re({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
227
227
  let a = Math.max(0, e), o = Math.max(0, r), s = Math.max(0, i), c = Math.max(0, a - s);
228
228
  if (!(c > 0 && o > 0)) return {
229
229
  maximumScrollPosition: c,
@@ -232,18 +232,18 @@ function ie({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize:
232
232
  thumbSize: o,
233
233
  thumbTravel: 0
234
234
  };
235
- let l = Y(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
235
+ let l = X(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
236
236
  return {
237
237
  maximumScrollPosition: c,
238
238
  scrollable: !0,
239
- thumbOffset: u * (Y(n, 0, c) / c),
239
+ thumbOffset: u * (X(n, 0, c) / c),
240
240
  thumbSize: l,
241
241
  thumbTravel: u
242
242
  };
243
243
  }
244
244
  //#endregion
245
245
  //#region src/components/GalleryScrollbar.vue?vue&type=script&setup=true&lang.ts
246
- var ae = ["aria-hidden"], X = [
246
+ var ie = ["aria-hidden"], ae = [
247
247
  "aria-controls",
248
248
  "aria-valuemax",
249
249
  "aria-valuenow",
@@ -277,7 +277,7 @@ var ae = ["aria-hidden"], X = [
277
277
  }
278
278
  function j() {
279
279
  let e = t.scrollElement, n = i.value;
280
- return !e || !n ? r : ie({
280
+ return !e || !n ? r : re({
281
281
  contentSize: e.scrollHeight,
282
282
  minimumThumbSize: Z,
283
283
  scrollPosition: e.scrollTop,
@@ -378,7 +378,7 @@ var ae = ["aria-hidden"], X = [
378
378
  onPointerdown: I,
379
379
  onPointermove: L,
380
380
  onPointerup: R
381
- }, null, 44, X)], 42, ae));
381
+ }, null, 44, ae)], 42, ie));
382
382
  }
383
383
  }), le = (e) => {
384
384
  for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
@@ -637,7 +637,9 @@ var ke = /* @__PURE__ */ u({
637
637
  }), Re = [
638
638
  "data-post-id",
639
639
  "data-media-index",
640
+ "aria-hidden",
640
641
  "aria-busy",
642
+ "inert",
641
643
  "role",
642
644
  "tabindex"
643
645
  ], ze = { class: "media-card-content" }, Be = ["data-media-direction"], Ve = ["data-media-index"], He = {
@@ -669,6 +671,7 @@ var ke = /* @__PURE__ */ u({
669
671
  item: {},
670
672
  itemStyle: {},
671
673
  interactive: { type: Boolean },
674
+ leaving: { type: Boolean },
672
675
  layout: {},
673
676
  loadedCount: {},
674
677
  mediaIndex: {},
@@ -692,41 +695,41 @@ var ke = /* @__PURE__ */ u({
692
695
  function ee(e) {
693
696
  return e.detail === 0 ? "keyboard" : "pointer";
694
697
  }
695
- function G(e, t) {
698
+ function te(e, t) {
696
699
  let n = S.value.length, r = (e + n) % n;
697
700
  r !== E.value && (v.value = e < E.value ? "previous" : "next", b("mediaChange", r), t && t.detail > 0 && t.currentTarget?.blur());
698
701
  }
699
- function K(e, t, n) {
702
+ function G(e, t, n) {
700
703
  return t === 1 ? e * 16 : t === 2 ? e * n : e;
701
704
  }
702
- function te() {
705
+ function ne() {
703
706
  d = 0, f = !1, u !== null && clearTimeout(u), u = null;
704
707
  }
705
- function ne() {
706
- u !== null && clearTimeout(u), u = setTimeout(te, Ze);
708
+ function K() {
709
+ u !== null && clearTimeout(u), u = setTimeout(ne, Ze);
707
710
  }
708
- function re(e) {
711
+ function q(e) {
709
712
  if (S.value.length <= 1) return;
710
- let t = e.currentTarget?.clientWidth || 1, n = K(e.deltaX, e.deltaMode, t);
711
- if (n === 0 || (e.preventDefault(), ne(), f) || (d += n, Math.abs(d) < Qe)) return;
713
+ let t = e.currentTarget?.clientWidth || 1, n = G(e.deltaX, e.deltaMode, t);
714
+ if (n === 0 || (e.preventDefault(), K(), f) || (d += n, Math.abs(d) < Qe)) return;
712
715
  let r = Math.sign(d);
713
- d = 0, f = !0, G(E.value + r);
716
+ d = 0, f = !0, te(E.value + r);
714
717
  }
715
- function q(e) {
718
+ function J(e) {
716
719
  let t = e.touches[0];
717
720
  c.layout !== "reel" || !t || (p = t.clientX, h = t.clientY);
718
721
  }
719
- function J(e) {
722
+ function Y(e) {
720
723
  let t = e.changedTouches[0];
721
724
  if (p === null || h === null || !t) return;
722
725
  let n = p - t.clientX, r = h - t.clientY;
723
- p = null, h = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < Xe || G(E.value + Math.sign(n)));
726
+ p = null, h = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < Xe || te(E.value + Math.sign(n)));
724
727
  }
725
- let Y = n(() => Oe(P.value));
726
- function ie(e) {
727
- c.layout === "reel" && (e.stopPropagation(), ae());
728
+ let X = n(() => Oe(P.value));
729
+ function re(e) {
730
+ c.layout === "reel" && (e.stopPropagation(), ie());
728
731
  }
729
- async function ae() {
732
+ async function ie() {
730
733
  if (L.value) {
731
734
  if (V.value) {
732
735
  L.value.pause();
@@ -739,12 +742,12 @@ var ke = /* @__PURE__ */ u({
739
742
  }
740
743
  }
741
744
  }
742
- function X(e) {
745
+ function ae(e) {
743
746
  return Number.isFinite(e) ? Math.max(0, e) : 0;
744
747
  }
745
748
  function Z(e) {
746
749
  let t = e?.currentTarget ?? L.value;
747
- t && (R.value = X(t.currentTime), z.value = X(t.duration), B.value = t.muted, H.value = t.volume, t.volume > 0 && (U = t.volume));
750
+ t && (R.value = ae(t.currentTime), z.value = ae(t.duration), B.value = t.muted, H.value = t.volume, t.volume > 0 && (U = t.volume));
748
751
  }
749
752
  function oe(e) {
750
753
  Z(e), b("ready", E.value);
@@ -754,7 +757,7 @@ var ke = /* @__PURE__ */ u({
754
757
  }
755
758
  function ce(e) {
756
759
  let t = L.value;
757
- !t || !Number.isFinite(e) || (t.currentTime = Math.min(X(t.duration), Math.max(0, e)), R.value = t.currentTime);
760
+ !t || !Number.isFinite(e) || (t.currentTime = Math.min(ae(t.duration), Math.max(0, e)), R.value = t.currentTime);
758
761
  }
759
762
  function le(e) {
760
763
  let t = L.value;
@@ -767,19 +770,22 @@ var ke = /* @__PURE__ */ u({
767
770
  e && (e.muted && e.volume === 0 && (e.volume = U), e.muted = !e.muted, Z());
768
771
  }
769
772
  return _(() => {
770
- te();
773
+ ne();
771
774
  }), (n, r) => (y(), o("article", {
772
775
  "data-post-id": e.item.postId,
773
776
  "data-media-index": E.value,
774
777
  class: m(["media-card", {
775
778
  "media-card--entering": e.entering,
779
+ "media-card--leaving": e.leaving,
776
780
  "media-card--error": e.previewState === "error",
777
781
  "media-card--transparent-chrome": e.cardHeader?.background === "transparent" || e.cardFooter?.background === "transparent"
778
782
  }]),
779
783
  style: g(e.itemStyle),
784
+ "aria-hidden": e.leaving || void 0,
780
785
  "aria-busy": e.previewState === "loading",
781
- role: e.interactive && !W.value ? "button" : void 0,
782
- tabindex: e.interactive && !W.value ? 0 : void 0,
786
+ inert: e.leaving || void 0,
787
+ role: e.interactive && !e.leaving && !W.value ? "button" : void 0,
788
+ tabindex: e.interactive && !e.leaving && !W.value ? 0 : void 0,
783
789
  onClick: r[11] ||= (t) => x(e.interactive && !W.value, ee(t)),
784
790
  onKeydown: [r[12] ||= k((t) => x(e.interactive && !W.value, "keyboard"), ["enter"]), r[13] ||= k(A((t) => x(e.interactive && !W.value, "keyboard"), ["prevent"]), ["space"])]
785
791
  }, [s("div", ze, [
@@ -807,9 +813,9 @@ var ke = /* @__PURE__ */ u({
807
813
  s("div", {
808
814
  class: m(["media-card-media", { "media-card-media--carousel": e.layout === "reel" && S.value.length > 1 }]),
809
815
  "data-media-direction": v.value,
810
- onWheel: re,
811
- onTouchstartPassive: q,
812
- onTouchendPassive: J
816
+ onWheel: q,
817
+ onTouchstartPassive: J,
818
+ onTouchendPassive: Y
813
819
  }, [
814
820
  l(t, { name: `media-slide-${v.value}` }, {
815
821
  default: O(() => [(y(), o("div", {
@@ -822,7 +828,7 @@ var ke = /* @__PURE__ */ u({
822
828
  class: "media-error",
823
829
  role: "img",
824
830
  "aria-label": `${T(Te)(P.value)} ${T(Ee)(P.value)}`
825
- }, [s("strong", We, w(T(Te)(P.value)), 1), s("span", null, w(T(Ee)(P.value)), 1)], 8, Ue)) : a("", !0), Y.value ? (y(), o("video", {
831
+ }, [s("strong", We, w(T(Te)(P.value)), 1), s("span", null, w(T(Ee)(P.value)), 1)], 8, Ue)) : a("", !0), X.value ? (y(), o("video", {
826
832
  key: 2,
827
833
  ref_key: "videoElement",
828
834
  ref: L,
@@ -845,7 +851,7 @@ var ke = /* @__PURE__ */ u({
845
851
  onPlaying: r[0] ||= (e) => V.value = !0,
846
852
  onPause: r[1] ||= (e) => V.value = !1,
847
853
  onEnded: se,
848
- onClick: ie,
854
+ onClick: re,
849
855
  onError: r[2] ||= (e) => n.$emit("error", E.value)
850
856
  }, null, 42, Ge)) : (y(), o("img", {
851
857
  key: 3,
@@ -862,7 +868,7 @@ var ke = /* @__PURE__ */ u({
862
868
  }, null, 42, Ke))], 8, Ve))]),
863
869
  _: 1
864
870
  }, 8, ["name"]),
865
- Y.value && e.previewState === "ready" ? (y(), i(Le, {
871
+ X.value && e.previewState === "ready" ? (y(), i(Le, {
866
872
  key: 0,
867
873
  "current-time": R.value,
868
874
  duration: z.value,
@@ -872,7 +878,7 @@ var ke = /* @__PURE__ */ u({
872
878
  volume: H.value,
873
879
  onSeek: ce,
874
880
  onToggleMute: ue,
875
- onTogglePlayback: ae,
881
+ onTogglePlayback: ie,
876
882
  onVolumeChange: le
877
883
  }, null, 8, [
878
884
  "current-time",
@@ -890,13 +896,13 @@ var ke = /* @__PURE__ */ u({
890
896
  type: "button",
891
897
  class: "media-carousel-control media-carousel-control--previous",
892
898
  "aria-label": `Previous media for post ${e.item.postId}`,
893
- onClick: r[5] ||= A((e) => G(E.value - 1, e), ["stop"]),
899
+ onClick: r[5] ||= A((e) => te(E.value - 1, e), ["stop"]),
894
900
  onKeydown: r[6] ||= A(() => {}, ["stop"])
895
901
  }, [l(T(ve), { size: 20 })], 40, qe), s("button", {
896
902
  type: "button",
897
903
  class: "media-carousel-control media-carousel-control--next",
898
904
  "aria-label": `Next media for post ${e.item.postId}`,
899
- onClick: r[7] ||= A((e) => G(E.value + 1, e), ["stop"]),
905
+ onClick: r[7] ||= A((e) => te(E.value + 1, e), ["stop"]),
900
906
  onKeydown: r[8] ||= A(() => {}, ["stop"])
901
907
  }, [l(T(ye), { size: 20 })], 40, Je)], 2)) : a("", !0),
902
908
  W.value ? (y(), o("button", {
@@ -936,6 +942,8 @@ var ke = /* @__PURE__ */ u({
936
942
  props: {
937
943
  enteringPostIds: {},
938
944
  entryDelays: {},
945
+ leavingPostIds: { default: () => /* @__PURE__ */ new Set() },
946
+ removalDelays: { default: () => /* @__PURE__ */ new Map() },
939
947
  suspended: { type: Boolean },
940
948
  canRetryEnd: { type: Boolean },
941
949
  cardFooter: {},
@@ -962,82 +970,98 @@ var ke = /* @__PURE__ */ u({
962
970
  "retryEnd"
963
971
  ],
964
972
  setup(t, { expose: r, emit: a }) {
965
- let c = t, u = a, d = C(null), f = `vibe-masonry-${E()}`, p = C(null), h = C(0), v = C(rt), b = C(0), S = C(0), w = C(0), O = null, k = null, A = null, j = n(() => J(c.items, h.value, {
973
+ let c = t, u = a, d = C(null), f = `vibe-masonry-${E()}`, p = C(null), h = C(0), v = C(rt), b = C(0), S = C(0), w = C(0), O = null, k = null, A = null, j = n(() => Y(c.items, h.value, {
966
974
  additionalHeight: (c.cardHeader?.height ?? 0) + (c.cardFooter?.height ?? 0),
967
975
  gap: v.value,
968
976
  minColumnWidth: nt
969
- })), M = n(() => ({ height: `${j.value.height}px` })), N = n(() => {
977
+ })), M = n(() => {
978
+ let e = j.value;
979
+ if (c.leavingPostIds.size === 0) return e;
980
+ let t = c.items.filter((e) => !c.leavingPostIds.has(e.postId)), n = Y(t, h.value, {
981
+ additionalHeight: (c.cardHeader?.height ?? 0) + (c.cardFooter?.height ?? 0),
982
+ gap: v.value,
983
+ minColumnWidth: nt
984
+ }), r = new Map(t.map((e, t) => [e.postId, n.items[t]]));
985
+ return {
986
+ ...n,
987
+ items: c.items.map((t, n) => c.leavingPostIds.has(t.postId) ? e.items[n] : r.get(t.postId) ?? e.items[n])
988
+ };
989
+ }), N = n(() => ({ height: `${c.leavingPostIds.size === 0 ? M.value.height : j.value.height}px` })), F = n(() => {
970
990
  let e = Math.max(at, S.value * ot), t = {
971
991
  scrollTop: b.value - w.value,
972
992
  viewportHeight: S.value
973
- }, n = q(j.value.items, {
993
+ }, n = J(M.value.items, {
994
+ ...t,
995
+ overscan: e
996
+ }), r = c.leavingPostIds.size === 0 ? [] : J(j.value.items, {
974
997
  ...t,
975
998
  overscan: e
976
- }), r = new Set(q(j.value.items, {
999
+ }), i = [...new Set([...n, ...r])].sort((e, t) => e - t), a = J(M.value.items, {
977
1000
  ...t,
978
1001
  overscan: 0
979
- }));
980
- return n.flatMap((e) => {
1002
+ }), o = c.leavingPostIds.size === 0 ? [] : J(j.value.items, {
1003
+ ...t,
1004
+ overscan: 0
1005
+ }), s = new Set([...a, ...o]);
1006
+ return i.flatMap((e) => {
981
1007
  let t = c.items[e];
982
1008
  return t ? [{
983
- fetchPriority: r.has(e) ? "high" : "low",
1009
+ fetchPriority: s.has(e) ? "high" : "low",
984
1010
  index: e,
985
1011
  item: t
986
1012
  }] : [];
987
1013
  });
988
1014
  });
989
- function F(e) {
990
- let t = j.value.items[e], n = c.items[e]?.postId;
1015
+ function I(e) {
1016
+ let t = M.value.items[e], n = c.items[e]?.postId;
991
1017
  if (!t) return {};
992
- let r = n !== void 0 && c.enteringPostIds.has(n) ? re({
1018
+ let r = n !== void 0 && c.enteringPostIds.has(n), i = n !== void 0 && c.leavingPostIds.has(n), a = r || i ? q({
993
1019
  containerHeight: j.value.height,
994
1020
  gap: v.value
995
- }) : 0;
1021
+ }) : 0, o = n === void 0 ? 0 : i ? c.removalDelays.get(n) ?? 0 : r ? c.entryDelays.get(n) ?? 0 : 0;
996
1022
  return {
997
- "--masonry-entry-delay": `${n === void 0 ? 0 : c.entryDelays.get(n) ?? 0}ms`,
998
- top: `${t.y}px`,
999
- left: `${t.x}px`,
1023
+ "--masonry-entry-delay": `${o}ms`,
1000
1024
  width: `${t.width}px`,
1001
1025
  height: `${t.height}px`,
1002
- transform: `translate3d(0, ${r}px, 0)`
1026
+ transform: `translate3d(${t.x}px, ${t.y + a}px, 0)`
1003
1027
  };
1004
1028
  }
1005
- function I() {
1029
+ function L() {
1006
1030
  let e = d.value;
1007
1031
  if (!e) return;
1008
1032
  b.value = e.scrollTop, S.value = e.clientHeight;
1009
1033
  let t = p.value;
1010
1034
  t && (w.value = t.getBoundingClientRect().top - e.getBoundingClientRect().top + e.scrollTop);
1011
1035
  }
1012
- function L(e) {
1036
+ function R(e) {
1013
1037
  let t = e.ownerDocument.documentElement.clientWidth;
1014
- h.value = e.clientWidth, v.value = Math.min(it, Math.max(rt, t * .0075)), I();
1038
+ h.value = e.clientWidth, v.value = Math.min(it, Math.max(rt, t * .0075)), L();
1015
1039
  }
1016
- function R(e) {
1040
+ function z(e) {
1017
1041
  let t = e.currentTarget;
1018
- t && (b.value = t.scrollTop, !c.loadMoreLocked && c.infiniteScroll && K(t) && u("loadMore"));
1042
+ t && (b.value = t.scrollTop, !c.loadMoreLocked && c.infiniteScroll && G(t) && u("loadMore"));
1019
1043
  }
1020
- function z() {
1044
+ function B() {
1021
1045
  let e = d.value;
1022
- !c.loadMoreLocked && e && K(e) && u("loadMore");
1046
+ !c.loadMoreLocked && e && G(e) && u("loadMore");
1023
1047
  }
1024
- function B() {
1048
+ function V() {
1025
1049
  return d.value;
1026
1050
  }
1027
1051
  return D(p, (e) => {
1028
- O?.disconnect(), O = null, A !== null && cancelAnimationFrame(A), e && (L(e), !(typeof ResizeObserver > "u") && (O = new ResizeObserver(([t]) => {
1052
+ O?.disconnect(), O = null, A !== null && cancelAnimationFrame(A), e && (R(e), !(typeof ResizeObserver > "u") && (O = new ResizeObserver(([t]) => {
1029
1053
  let n = t?.contentRect.width ?? e.clientWidth;
1030
1054
  Math.abs(n - h.value) < .5 || (A = requestAnimationFrame(() => {
1031
- A = null, L(e);
1055
+ A = null, R(e);
1032
1056
  }));
1033
1057
  }), O.observe(e)));
1034
1058
  }), D(d, (e) => {
1035
- k?.disconnect(), k = null, e && (I(), !(typeof ResizeObserver > "u") && (k = new ResizeObserver(I), k.observe(e)));
1059
+ k?.disconnect(), k = null, e && (L(), !(typeof ResizeObserver > "u") && (k = new ResizeObserver(L), k.observe(e)));
1036
1060
  }), _(() => {
1037
1061
  O?.disconnect(), k?.disconnect(), A !== null && cancelAnimationFrame(A);
1038
1062
  }), r({
1039
- getScrollElement: B,
1040
- loadIfNearBottom: z
1063
+ getScrollElement: V,
1064
+ loadIfNearBottom: B
1041
1065
  }), (n, r) => (y(), o("div", et, [s("main", {
1042
1066
  id: f,
1043
1067
  ref_key: "galleryElement",
@@ -1046,23 +1070,24 @@ var ke = /* @__PURE__ */ u({
1046
1070
  "data-layout-mode": "masonry",
1047
1071
  "aria-hidden": t.suspended || void 0,
1048
1072
  inert: t.suspended || void 0,
1049
- onScrollPassive: R
1073
+ onScrollPassive: z
1050
1074
  }, [s("section", {
1051
1075
  ref_key: "masonryElement",
1052
1076
  ref: p,
1053
1077
  class: m(["masonry", { "masonry--ready": h.value > 0 }]),
1054
- style: g(M.value),
1078
+ style: g(N.value),
1055
1079
  "aria-label": "Media gallery"
1056
- }, [(y(!0), o(e, null, x(N.value, ({ fetchPriority: e, item: n, index: r }) => (y(), i($e, {
1080
+ }, [(y(!0), o(e, null, x(F.value, ({ fetchPriority: e, item: n, index: r }) => (y(), i($e, {
1057
1081
  key: n.postId,
1058
1082
  class: "masonry-item",
1059
1083
  entering: t.enteringPostIds.has(n.postId),
1084
+ leaving: t.leavingPostIds.has(n.postId),
1060
1085
  "fetch-priority": e,
1061
1086
  "card-footer": t.cardFooter,
1062
1087
  "card-header": t.cardHeader,
1063
1088
  index: r,
1064
1089
  item: n,
1065
- "item-style": F(r),
1090
+ "item-style": I(r),
1066
1091
  interactive: "",
1067
1092
  layout: "masonry",
1068
1093
  "loaded-count": t.items.length,
@@ -1075,6 +1100,7 @@ var ke = /* @__PURE__ */ u({
1075
1100
  onError: (e) => u("error", n.postId, e)
1076
1101
  }, null, 8, [
1077
1102
  "entering",
1103
+ "leaving",
1078
1104
  "fetch-priority",
1079
1105
  "card-footer",
1080
1106
  "card-header",
@@ -1112,7 +1138,7 @@ var ke = /* @__PURE__ */ u({
1112
1138
  "load-more-locked",
1113
1139
  "state"
1114
1140
  ])], 42, tt), l(ce, {
1115
- "content-size": j.value.height,
1141
+ "content-size": M.value.height,
1116
1142
  "controls-id": f,
1117
1143
  "scroll-element": d.value,
1118
1144
  suspended: t.suspended
@@ -1206,40 +1232,40 @@ var ke = /* @__PURE__ */ u({
1206
1232
  function ee(e) {
1207
1233
  return { gridRow: `${e + 1}` };
1208
1234
  }
1209
- function G(e) {
1235
+ function te(e) {
1210
1236
  let t = w || e.clientHeight;
1211
1237
  return t <= 0 || u.items.length === 0 ? 0 : Math.min(u.items.length - 1, Math.max(0, Math.round(e.scrollTop / t)));
1212
1238
  }
1213
- function te(e) {
1239
+ function ne(e) {
1214
1240
  let t = e.currentTarget;
1215
- t && (S.value || (b.value = G(t)), !u.loadMoreLocked && u.infiniteScroll && K(t) && d("loadMore"));
1241
+ t && (S.value || (b.value = te(t)), !u.loadMoreLocked && u.infiniteScroll && G(t) && d("loadMore"));
1216
1242
  }
1217
- function ne() {
1243
+ function K() {
1218
1244
  let e = f.value;
1219
- e && (J(!0), w = e.clientHeight, e.scrollTop = b.value * w, O !== null && cancelAnimationFrame(O), O = requestAnimationFrame(() => {
1245
+ e && (Y(!0), w = e.clientHeight, e.scrollTop = b.value * w, O !== null && cancelAnimationFrame(O), O = requestAnimationFrame(() => {
1220
1246
  e.scrollTop = b.value * e.clientHeight, w = e.clientHeight, O = null;
1221
- }), re());
1247
+ }), q());
1222
1248
  }
1223
- function re() {
1249
+ function q() {
1224
1250
  k !== null && clearTimeout(k), k = setTimeout(() => {
1225
1251
  k = null;
1226
1252
  let e = f.value;
1227
- e && (w = e.clientHeight, e.scrollTop = b.value * w), J(!1);
1253
+ e && (w = e.clientHeight, e.scrollTop = b.value * w), Y(!1);
1228
1254
  }, 120);
1229
1255
  }
1230
- function q() {
1231
- J(!0);
1256
+ function J() {
1257
+ Y(!0);
1232
1258
  let e = f.value;
1233
- e && (w = e.clientHeight, e.scrollTop = b.value * w), re();
1259
+ e && (w = e.clientHeight, e.scrollTop = b.value * w), q();
1234
1260
  }
1235
- function J(e) {
1261
+ function Y(e) {
1236
1262
  S.value = e, f.value?.toggleAttribute("data-resizing", e);
1237
1263
  }
1238
- function Y() {
1264
+ function X() {
1239
1265
  let e = f.value;
1240
- !u.loadMoreLocked && e && K(e) && d("loadMore");
1266
+ !u.loadMoreLocked && e && G(e) && d("loadMore");
1241
1267
  }
1242
- function ie(e) {
1268
+ function re(e) {
1243
1269
  let t = I.value;
1244
1270
  if (!t) return !1;
1245
1271
  let n = j(t).length;
@@ -1247,18 +1273,18 @@ var ke = /* @__PURE__ */ u({
1247
1273
  let r = (L.value + e + n) % n;
1248
1274
  return d("mediaChange", t.postId, r), !0;
1249
1275
  }
1250
- function ae(e) {
1276
+ function ie(e) {
1251
1277
  let t = b.value + e;
1252
1278
  return !f.value || t < 0 || t >= u.items.length ? !1 : (Z(t), !0);
1253
1279
  }
1254
- function X() {
1280
+ function ae() {
1255
1281
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1256
1282
  }
1257
1283
  function Z(e) {
1258
1284
  let t = f.value;
1259
1285
  if (!t) return;
1260
1286
  let n = e * (w || t.clientHeight);
1261
- if (b.value = e, !X() && typeof t.scrollTo == "function") {
1287
+ if (b.value = e, !ae() && typeof t.scrollTo == "function") {
1262
1288
  t.scrollTo({
1263
1289
  behavior: "smooth",
1264
1290
  top: n
@@ -1286,21 +1312,21 @@ var ke = /* @__PURE__ */ u({
1286
1312
  !u.reelAutoAdvance.enabled || e !== F.value || t !== L.value || !B.value || oe();
1287
1313
  }
1288
1314
  return D(f, (e) => {
1289
- E?.disconnect(), E = null, e && (w = e.clientHeight, !(typeof ResizeObserver > "u") && (E = new ResizeObserver(ne), E.observe(e)));
1315
+ E?.disconnect(), E = null, e && (w = e.clientHeight, !(typeof ResizeObserver > "u") && (E = new ResizeObserver(K), E.observe(e)));
1290
1316
  }), D(() => u.items.length, async (e) => {
1291
- b.value = Math.min(b.value, Math.max(0, e - 1)), await p(), ne();
1317
+ b.value = Math.min(b.value, Math.max(0, e - 1)), await p(), K();
1292
1318
  }), D(F, (e) => {
1293
1319
  e !== void 0 && d("activeChange", e);
1294
1320
  }, { immediate: !0 }), v(() => {
1295
- window.addEventListener("resize", q), window.addEventListener("orientationchange", q), h >= 0 && p(ne);
1321
+ window.addEventListener("resize", J), window.addEventListener("orientationchange", J), h >= 0 && p(K);
1296
1322
  }), _(() => {
1297
- window.removeEventListener("resize", q), window.removeEventListener("orientationchange", q), E?.disconnect(), O !== null && cancelAnimationFrame(O), k !== null && clearTimeout(k);
1323
+ window.removeEventListener("resize", J), window.removeEventListener("orientationchange", J), E?.disconnect(), O !== null && cancelAnimationFrame(O), k !== null && clearTimeout(k);
1298
1324
  }), r({
1299
1325
  activeIndex: b,
1300
1326
  activePostId: F,
1301
- changeActiveMedia: ie,
1302
- loadIfNearBottom: Y,
1303
- moveActivePost: ae
1327
+ changeActiveMedia: re,
1328
+ loadIfNearBottom: X,
1329
+ moveActivePost: ie
1304
1330
  }), (n, r) => (y(), o("main", {
1305
1331
  class: m(["reel-shell", {
1306
1332
  "reel-shell--has-footer": !!t.cardFooter,
@@ -1334,7 +1360,7 @@ var ke = /* @__PURE__ */ u({
1334
1360
  class: "gallery-shell reel-feed",
1335
1361
  "data-active-post-id": F.value,
1336
1362
  "data-active-media-index": L.value,
1337
- onScrollPassive: te
1363
+ onScrollPassive: ne
1338
1364
  }, [s("section", {
1339
1365
  class: "reel-track",
1340
1366
  style: g(A.value),
@@ -1598,7 +1624,7 @@ var ke = /* @__PURE__ */ u({
1598
1624
  _: 1
1599
1625
  })], 10, pt));
1600
1626
  }
1601
- }), vt = 35, yt = /* @__PURE__ */ u({
1627
+ }), vt = 35, yt = 420, bt = /* @__PURE__ */ u({
1602
1628
  __name: "VibeSurface",
1603
1629
  props: {
1604
1630
  canRetryEnd: { type: Boolean },
@@ -1618,84 +1644,93 @@ var ke = /* @__PURE__ */ u({
1618
1644
  "retryEnd"
1619
1645
  ],
1620
1646
  setup(r, { expose: s, emit: c }) {
1621
- let u = r, d = c, f = C(null), m = C(null), h = C(null), b = C(null), x = C({}), S = C(!1), w = C(/* @__PURE__ */ new Set()), T = C(/* @__PURE__ */ new Map()), E = C(/* @__PURE__ */ new Map()), k = C(/* @__PURE__ */ new Map()), A = C(/* @__PURE__ */ new Map()), j = n(() => F(u.state)), N = n(() => u.state.reelMediaSource === "original" ? A.value : k.value), I = new Set(u.state.items.map((e) => e.postId)), L = null, R = null, z = !1;
1622
- function B() {
1647
+ let u = r, d = c, f = C(null), m = C(null), h = C(null), b = C(null), x = C({}), S = C(!1), w = C(/* @__PURE__ */ new Set()), T = C(/* @__PURE__ */ new Map()), E = C(/* @__PURE__ */ new Set()), k = C(/* @__PURE__ */ new Map()), A = C(/* @__PURE__ */ new Map()), j = C(/* @__PURE__ */ new Map()), N = C(/* @__PURE__ */ new Map()), I = n(() => F(u.state)), L = n(() => u.state.reelMediaSource === "original" ? N.value : j.value), R = new Set(u.state.items.map((e) => e.postId)), z = null, B = null, V = !1;
1648
+ function H() {
1623
1649
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1624
1650
  }
1625
- function V() {
1626
- L !== null && cancelAnimationFrame(L), L = requestAnimationFrame(() => {
1627
- L = requestAnimationFrame(() => {
1628
- L = null, w.value = /* @__PURE__ */ new Set();
1651
+ function U() {
1652
+ z !== null && cancelAnimationFrame(z), z = requestAnimationFrame(() => {
1653
+ z = requestAnimationFrame(() => {
1654
+ z = null, w.value = /* @__PURE__ */ new Set();
1629
1655
  });
1630
1656
  });
1631
1657
  }
1632
- function H(e, t, n) {
1658
+ function W(e, t, n) {
1633
1659
  let r = P(e, t);
1634
- k.value.get(r) !== n && (k.value = new Map(k.value).set(r, n));
1660
+ j.value.get(r) !== n && (j.value = new Map(j.value).set(r, n));
1635
1661
  }
1636
- function U(e, t, n) {
1662
+ function ee(e, t, n) {
1637
1663
  let r = P(e, t);
1638
- A.value.get(r) !== n && (A.value = new Map(A.value).set(r, n));
1664
+ N.value.get(r) !== n && (N.value = new Map(N.value).set(r, n));
1639
1665
  }
1640
- function W(e, t) {
1641
- H(e, t, "error");
1666
+ function G(e, t) {
1667
+ W(e, t, "error");
1642
1668
  }
1643
- function ee(e, t) {
1644
- H(e, t, "ready");
1669
+ function ne(e, t) {
1670
+ W(e, t, "ready");
1645
1671
  }
1646
1672
  function K(e, t) {
1647
- U(e, t, "error");
1673
+ ee(e, t, "error");
1648
1674
  }
1649
- function te(e, t) {
1650
- U(e, t, "ready");
1675
+ function q(e, t) {
1676
+ ee(e, t, "ready");
1651
1677
  }
1652
- function ne(e, t) {
1678
+ function J(e, t) {
1653
1679
  if (u.state.reelMediaSource === "original") {
1654
1680
  K(e, t);
1655
1681
  return;
1656
1682
  }
1657
- W(e, t);
1683
+ G(e, t);
1658
1684
  }
1659
- function re(e, t) {
1685
+ function Y(e, t) {
1660
1686
  if (u.state.reelMediaSource === "original") {
1661
- te(e, t);
1687
+ q(e, t);
1662
1688
  return;
1663
1689
  }
1664
- ee(e, t);
1690
+ ne(e, t);
1665
1691
  }
1666
- function q(e, t) {
1692
+ function X(e, t) {
1667
1693
  let n = u.state.items.find((t) => t.postId === e);
1668
1694
  if (!n) return;
1669
1695
  let r = M(n, t);
1670
- (E.value.get(e) ?? 0) !== r && (E.value = new Map(E.value).set(e, r));
1696
+ (A.value.get(e) ?? 0) !== r && (A.value = new Map(A.value).set(e, r));
1671
1697
  }
1672
- async function J() {
1698
+ async function re() {
1673
1699
  await p(), (u.state.layout === "reel" || u.state.reelOrigin === "masonry" ? m.value : f.value)?.loadIfNearBottom();
1674
1700
  }
1675
- function Y(e) {
1701
+ function ie(e) {
1676
1702
  return u.state.isLoading || u.state.items.length === 0 || u.state.layout !== "reel" && u.state.reelOrigin !== "masonry" ? !1 : m.value?.changeActiveMedia?.(e) ?? !1;
1677
1703
  }
1678
- function ie(e) {
1704
+ function ae(e) {
1679
1705
  return u.state.isLoading || u.state.items.length === 0 || u.state.layout !== "reel" && u.state.reelOrigin !== "masonry" ? !1 : m.value?.moveActivePost?.(e) ?? !1;
1680
1706
  }
1681
- function ae() {
1707
+ function Z() {
1682
1708
  return u.state.layout !== "masonry" || u.state.reelOrigin === "masonry" ? null : f.value?.getScrollElement?.() ?? null;
1683
1709
  }
1684
- function X(e, t) {
1685
- R = e, z = t === "keyboard", x.value = se(e), d("openReel", e), p(() => h.value?.focus());
1710
+ function oe(e, t) {
1711
+ B = e, V = t === "keyboard", x.value = ue(e), d("openReel", e), p(() => h.value?.focus());
1686
1712
  }
1687
- function Z(e) {
1713
+ function se(e) {
1688
1714
  let t = b.value?.querySelectorAll(".masonry-feed [data-post-id]") ?? [];
1689
1715
  return Array.from(t).find((t) => t.dataset.postId === String(e)) ?? null;
1690
1716
  }
1691
- function oe(e, t) {
1692
- let n = Z(e), r = n?.querySelector(".media-card-activator") ?? n;
1717
+ function ce(e) {
1718
+ if (u.state.layout !== "masonry" || u.state.reelOrigin !== null || H()) return 0;
1719
+ let t = [...new Set(e)], n = t.filter(se);
1720
+ if (n.length === 0) return 0;
1721
+ let r = new Map(k.value);
1722
+ return n.forEach((e, t) => {
1723
+ r.set(e, t * vt);
1724
+ }), w.value = new Set([...w.value].filter((e) => !n.includes(e))), E.value = new Set([...E.value, ...t]), k.value = r, yt + (n.length - 1) * vt;
1725
+ }
1726
+ function le(e, t) {
1727
+ let n = se(e), r = n?.querySelector(".media-card-activator") ?? n;
1693
1728
  r && (r.classList.toggle("media-card-focus-silent", !t), t || r.addEventListener("blur", () => {
1694
1729
  r.classList.remove("media-card-focus-silent");
1695
1730
  }, { once: !0 }), r?.focus({ preventScroll: !0 }));
1696
1731
  }
1697
- function se(e) {
1698
- let t = b.value, n = Z(e);
1732
+ function ue(e) {
1733
+ let t = b.value, n = se(e);
1699
1734
  if (t === null || n === null) return {};
1700
1735
  let r = t.getBoundingClientRect(), i = n.getBoundingClientRect();
1701
1736
  return {
@@ -1705,19 +1740,19 @@ var ke = /* @__PURE__ */ u({
1705
1740
  "--vibe-reel-origin-left": `${Math.max(0, i.left - r.left)}px`
1706
1741
  };
1707
1742
  }
1708
- function ce() {
1709
- u.state.reelOrigin === "masonry" && (R ??= u.state.activeReelPostId, S.value = !0, d("closeReel"));
1743
+ function de() {
1744
+ u.state.reelOrigin === "masonry" && (B ??= u.state.activeReelPostId, S.value = !0, d("closeReel"));
1710
1745
  }
1711
- function le() {
1712
- let e = R, t = z;
1713
- S.value = !1, R = null, z = !1, x.value = {}, p(() => {
1714
- e !== null && oe(e, t);
1746
+ function fe() {
1747
+ let e = B, t = V;
1748
+ S.value = !1, B = null, V = !1, x.value = {}, p(() => {
1749
+ e !== null && le(e, t);
1715
1750
  });
1716
1751
  }
1717
- function ue(e) {
1752
+ function pe(e) {
1718
1753
  let t = u.state.layout === "reel" || u.state.reelOrigin === "masonry";
1719
1754
  if (e.key === "Escape" && u.state.reelOrigin === "masonry") {
1720
- e.preventDefault(), ce();
1755
+ e.preventDefault(), de();
1721
1756
  return;
1722
1757
  }
1723
1758
  if (e.key === "Escape" && t && u.state.reelInfoSheet.enabled) {
@@ -1735,32 +1770,33 @@ var ke = /* @__PURE__ */ u({
1735
1770
  r !== 0 && m.value?.changeActiveMedia?.(r) && e.preventDefault();
1736
1771
  }
1737
1772
  return D(() => u.state.items.map((e) => e.postId), (e) => {
1738
- let t = e.filter((e) => !I.has(e));
1739
- if (I = new Set(e), t.length === 0 || B()) return;
1740
- let n = /* @__PURE__ */ new Map();
1773
+ let t = e.filter((e) => !R.has(e)), n = new Set(e);
1774
+ if (R = new Set(e), E.value = new Set([...E.value].filter((e) => n.has(e))), k.value = new Map([...k.value].filter(([e]) => n.has(e))), t.length === 0 || H()) return;
1775
+ let r = /* @__PURE__ */ new Map();
1741
1776
  e.forEach((e) => {
1742
1777
  let t = T.value.get(e);
1743
- t !== void 0 && n.set(e, t);
1778
+ t !== void 0 && r.set(e, t);
1744
1779
  }), t.forEach((e, t) => {
1745
- n.set(e, t * vt);
1746
- }), T.value = n, w.value = new Set([...w.value, ...t]), V();
1747
- }, { flush: "sync" }), v(() => window.addEventListener("keydown", ue)), _(() => {
1748
- window.removeEventListener("keydown", ue), L !== null && cancelAnimationFrame(L);
1780
+ r.set(e, t * vt);
1781
+ }), T.value = r, w.value = new Set([...w.value, ...t]), U();
1782
+ }, { flush: "sync" }), v(() => window.addEventListener("keydown", pe)), _(() => {
1783
+ window.removeEventListener("keydown", pe), z !== null && cancelAnimationFrame(z);
1749
1784
  }), s({
1750
- changeActiveReelMedia: Y,
1751
- getAutoScrollElement: ae,
1752
- loadIfNearBottom: J,
1753
- moveActiveReelPost: ie
1785
+ changeActiveReelMedia: ie,
1786
+ getAutoScrollElement: Z,
1787
+ loadIfNearBottom: re,
1788
+ moveActiveReelPost: ae,
1789
+ startItemRemoval: ce
1754
1790
  }), (n, s) => (y(), o("div", {
1755
1791
  ref_key: "surfaceElement",
1756
1792
  ref: b,
1757
1793
  class: "vibe-surface"
1758
- }, [r.state.error || r.state.isLoading || r.state.items.length === 0 ? (y(), i(G, {
1794
+ }, [r.state.error || r.state.isLoading || r.state.items.length === 0 ? (y(), i(te, {
1759
1795
  key: 0,
1760
1796
  actions: r.feedFooterActions,
1761
1797
  "can-retry-end": r.canRetryEnd,
1762
1798
  "feed-footer": r.feedFooter,
1763
- state: j.value,
1799
+ state: I.value,
1764
1800
  onLoadMore: s[0] ||= (e) => d("loadMore"),
1765
1801
  onRetryEnd: s[1] ||= (e) => d("retryEnd")
1766
1802
  }, null, 8, [
@@ -1783,23 +1819,23 @@ var ke = /* @__PURE__ */ u({
1783
1819
  items: r.state.items,
1784
1820
  "load-more-locked": r.state.loadMoreLocked,
1785
1821
  "media-source": r.state.reelMediaSource,
1786
- "media-indices": E.value,
1822
+ "media-indices": A.value,
1787
1823
  "initial-post-id": r.state.activeReelPostId,
1788
1824
  "info-sheet": r.reelInfoSheet,
1789
1825
  "info-sheet-enabled": r.state.reelInfoSheet.enabled,
1790
1826
  "info-sheet-overlay": r.state.reelInfoSheetOverlay,
1791
1827
  "next-page-error": !!r.state.nextPageError,
1792
1828
  origin: "reel",
1793
- "preview-states": N.value,
1829
+ "preview-states": L.value,
1794
1830
  "reel-auto-advance": r.state.reelAutoAdvance,
1795
- state: j.value,
1831
+ state: I.value,
1796
1832
  total: r.state.total,
1797
1833
  onActiveChange: s[2] ||= (e) => d("activeReelChange", e),
1798
1834
  onCloseInfoSheet: s[3] ||= (e) => d("reelInfoSheetChange", !1),
1799
- onError: ne,
1835
+ onError: J,
1800
1836
  onLoadMore: s[4] ||= (e) => d("loadMore"),
1801
- onMediaChange: q,
1802
- onReady: re,
1837
+ onMediaChange: X,
1838
+ onReady: Y,
1803
1839
  onRetryEnd: s[5] ||= (e) => d("retryEnd")
1804
1840
  }, null, 8, [
1805
1841
  "can-retry-end",
@@ -1829,6 +1865,8 @@ var ke = /* @__PURE__ */ u({
1829
1865
  "can-retry-end": r.canRetryEnd,
1830
1866
  "entering-post-ids": w.value,
1831
1867
  "entry-delays": T.value,
1868
+ "leaving-post-ids": E.value,
1869
+ "removal-delays": k.value,
1832
1870
  "card-footer": r.cardFooter,
1833
1871
  "card-header": r.cardHeader,
1834
1872
  "feed-footer": r.feedFooter,
@@ -1838,22 +1876,24 @@ var ke = /* @__PURE__ */ u({
1838
1876
  "is-loading-more": r.state.isLoadingMore,
1839
1877
  items: r.state.items,
1840
1878
  "load-more-locked": r.state.loadMoreLocked,
1841
- "media-indices": E.value,
1879
+ "media-indices": A.value,
1842
1880
  "next-page-error": !!r.state.nextPageError,
1843
- "preview-states": k.value,
1881
+ "preview-states": j.value,
1844
1882
  suspended: r.state.reelOrigin === "masonry" || S.value,
1845
- state: j.value,
1883
+ state: I.value,
1846
1884
  total: r.state.total,
1847
- onActivate: X,
1848
- onError: W,
1885
+ onActivate: oe,
1886
+ onError: G,
1849
1887
  onLoadMore: s[6] ||= (e) => d("loadMore"),
1850
- onMediaChange: q,
1851
- onReady: ee,
1888
+ onMediaChange: X,
1889
+ onReady: ne,
1852
1890
  onRetryEnd: s[7] ||= (e) => d("retryEnd")
1853
1891
  }, null, 8, [
1854
1892
  "can-retry-end",
1855
1893
  "entering-post-ids",
1856
1894
  "entry-delays",
1895
+ "leaving-post-ids",
1896
+ "removal-delays",
1857
1897
  "card-footer",
1858
1898
  "card-header",
1859
1899
  "feed-footer",
@@ -1871,7 +1911,7 @@ var ke = /* @__PURE__ */ u({
1871
1911
  "total"
1872
1912
  ]), l(t, {
1873
1913
  name: "vibe-reel-viewer",
1874
- onAfterLeave: le
1914
+ onAfterLeave: fe
1875
1915
  }, {
1876
1916
  default: O(() => [r.state.reelOrigin === "masonry" ? (y(), o("section", {
1877
1917
  key: 0,
@@ -1900,20 +1940,20 @@ var ke = /* @__PURE__ */ u({
1900
1940
  "is-loading-more": r.state.isLoadingMore,
1901
1941
  items: r.state.items,
1902
1942
  "load-more-locked": r.state.loadMoreLocked,
1903
- "media-indices": E.value,
1943
+ "media-indices": A.value,
1904
1944
  "media-source": "original",
1905
1945
  "next-page-error": !!r.state.nextPageError,
1906
1946
  origin: "masonry",
1907
- "preview-states": A.value,
1947
+ "preview-states": N.value,
1908
1948
  "reel-auto-advance": r.state.reelAutoAdvance,
1909
- state: j.value,
1949
+ state: I.value,
1910
1950
  total: r.state.total,
1911
1951
  onActiveChange: s[8] ||= (e) => d("activeReelChange", e),
1912
1952
  onCloseInfoSheet: s[9] ||= (e) => d("reelInfoSheetChange", !1),
1913
1953
  onError: K,
1914
1954
  onLoadMore: s[10] ||= (e) => d("loadMore"),
1915
- onMediaChange: q,
1916
- onReady: te,
1955
+ onMediaChange: X,
1956
+ onReady: q,
1917
1957
  onRetryEnd: s[11] ||= (e) => d("retryEnd")
1918
1958
  }, null, 8, [
1919
1959
  "can-retry-end",
@@ -1943,7 +1983,7 @@ var ke = /* @__PURE__ */ u({
1943
1983
  });
1944
1984
  //#endregion
1945
1985
  //#region src/core/page.ts
1946
- function bt(e) {
1986
+ function xt(e) {
1947
1987
  if (!e || typeof e != "object" || !Array.isArray(e.items)) throw TypeError("Vibe loadPage must resolve to a page with an items array.");
1948
1988
  if (e.next !== null && typeof e.next != "string" && typeof e.next != "number") throw TypeError("Vibe page next must be a string, number, or null.");
1949
1989
  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.");
@@ -1955,32 +1995,32 @@ function Q(e, t) {
1955
1995
  }
1956
1996
  //#endregion
1957
1997
  //#region src/core/requestDelay.ts
1958
- var xt = 2e3, St = 1e4, Ct = 250, wt = {
1998
+ var St = 2e3, Ct = 1e4, wt = 250, Tt = {
1959
1999
  delayRemainingMs: null,
1960
2000
  nextRequestAt: null
1961
2001
  };
1962
- function Tt(e, t) {
2002
+ function Et(e, t) {
1963
2003
  return e === void 0 ? t : Math.floor(e);
1964
2004
  }
1965
- function Et(e, t) {
2005
+ function Dt(e, t) {
1966
2006
  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.`);
1967
2007
  }
1968
- function Dt(e, t = {}) {
1969
- let n = Tt(t.delayStepMs, xt), r = Tt(t.delayMaxMs, St);
2008
+ function Ot(e, t = {}) {
2009
+ let n = Et(t.delayStepMs, St), r = Et(t.delayMaxMs, Ct);
1970
2010
  return Math.min(Math.max(0, e) * n, r);
1971
2011
  }
1972
2012
  function $(e) {
1973
- if (e == null || !Number.isFinite(e)) return { ...wt };
2013
+ if (e == null || !Number.isFinite(e)) return { ...Tt };
1974
2014
  let t = Math.max(0, Math.floor(e - Date.now()));
1975
2015
  return t > 0 ? {
1976
2016
  delayRemainingMs: t,
1977
2017
  nextRequestAt: e
1978
- } : { ...wt };
2018
+ } : { ...Tt };
1979
2019
  }
1980
- async function Ot({ delayMs: e, onChange: t, signal: n }) {
2020
+ async function kt({ delayMs: e, onChange: t, signal: n }) {
1981
2021
  if (n.aborted) throw new DOMException("Aborted", "AbortError");
1982
2022
  if (e <= 0) {
1983
- t({ ...wt });
2023
+ t({ ...Tt });
1984
2024
  return;
1985
2025
  }
1986
2026
  let r = Date.now() + e;
@@ -1988,9 +2028,9 @@ async function Ot({ delayMs: e, onChange: t, signal: n }) {
1988
2028
  delayRemainingMs: e,
1989
2029
  nextRequestAt: r
1990
2030
  }), await new Promise((i, a) => {
1991
- let o = !1, s = setInterval(f, Ct), c = setTimeout(() => u(), e);
2031
+ let o = !1, s = setInterval(f, wt), c = setTimeout(() => u(), e);
1992
2032
  function l() {
1993
- clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...wt });
2033
+ clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Tt });
1994
2034
  }
1995
2035
  function u(e) {
1996
2036
  o || (o = !0, l(), e ? a(e) : i());
@@ -2005,13 +2045,13 @@ async function Ot({ delayMs: e, onChange: t, signal: n }) {
2005
2045
  n.addEventListener("abort", d, { once: !0 });
2006
2046
  });
2007
2047
  }
2008
- var kt = class {
2048
+ var At = class {
2009
2049
  interval = null;
2010
2050
  constructor(e) {
2011
2051
  this.onChange = e;
2012
2052
  }
2013
2053
  clear() {
2014
- this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...wt });
2054
+ this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Tt });
2015
2055
  }
2016
2056
  sync(e) {
2017
2057
  this.clear();
@@ -2019,22 +2059,22 @@ var kt = class {
2019
2059
  this.onChange(t), t.delayRemainingMs !== null && (this.interval = setInterval(() => {
2020
2060
  let t = $(e);
2021
2061
  this.onChange(t), t.delayRemainingMs === null && this.clear();
2022
- }, Ct));
2062
+ }, wt));
2023
2063
  }
2024
2064
  };
2025
- function At(e, t = !0) {
2065
+ function jt(e, t = !0) {
2026
2066
  return e.maxAdditionalPages === "unlimited" ? Infinity : (e.maxAdditionalPages ?? 10) + (t ? 1 : 0);
2027
2067
  }
2028
- function jt(e) {
2068
+ function Mt(e) {
2029
2069
  return `${typeof e}:${String(e)}`;
2030
2070
  }
2031
- function Mt(e, t) {
2071
+ function Nt(e, t) {
2032
2072
  if (!Number.isInteger(e) || e <= 0) throw TypeError(`Vibe ${t} must be a positive integer.`);
2033
2073
  }
2034
- function Nt(e) {
2074
+ function Pt(e) {
2035
2075
  if (!e) return;
2036
- if (Mt(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2037
- Et(e, "frontend autofill");
2076
+ if (Nt(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2077
+ Dt(e, "frontend autofill");
2038
2078
  let t = e.maxAdditionalPages;
2039
2079
  if (t !== void 0 && t !== "unlimited" && (!Number.isInteger(t) || t < 0)) throw TypeError("Vibe autofill maxAdditionalPages must be a non-negative integer or \"unlimited\".");
2040
2080
  return;
@@ -2046,7 +2086,7 @@ function Nt(e) {
2046
2086
  if (t.pageSize !== e.pageSize) throw TypeError("Vibe backend autofill initialSession pageSize must match autofill pageSize.");
2047
2087
  }
2048
2088
  }
2049
- function Pt(e, t, n = !0) {
2089
+ function Ft(e, t, n = !0) {
2050
2090
  if (!e) return {
2051
2091
  cycleId: null,
2052
2092
  delayRemainingMs: null,
@@ -2080,7 +2120,7 @@ function Pt(e, t, n = !0) {
2080
2120
  strategy: e.strategy
2081
2121
  };
2082
2122
  }
2083
- function Ft(e) {
2123
+ function It(e) {
2084
2124
  return [
2085
2125
  "cancelling",
2086
2126
  "filling",
@@ -2088,9 +2128,9 @@ function Ft(e) {
2088
2128
  "waiting"
2089
2129
  ].includes(e.status);
2090
2130
  }
2091
- async function It(e, t, n) {
2131
+ async function Lt(e, t, n) {
2092
2132
  let r = t.autofill;
2093
- if (!Ft(r) || !r.cycleId) return;
2133
+ if (!It(r) || !r.cycleId) return;
2094
2134
  let i = {
2095
2135
  cycleId: r.cycleId,
2096
2136
  feedKey: r.feedKey ?? "",
@@ -2103,20 +2143,20 @@ async function It(e, t, n) {
2103
2143
  throw r.error = e, r.status = "error", e;
2104
2144
  }
2105
2145
  }
2106
- function Lt(e, t, n) {
2146
+ function Rt(e, t, n) {
2107
2147
  return e?.strategy === "backend" && t.feedKey === e.feedKey && t.sessionId === n.sessionId;
2108
2148
  }
2109
- async function Rt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onDelayChange: i, onProgress: a, options: o, receivedOffset: s = 0, requestOffset: c = 0, signal: l }) {
2110
- let u = [], d = [...e], f = /* @__PURE__ */ new Set(), p = r ?? At(o), m = t, h = t, g = 0, _;
2149
+ async function zt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onDelayChange: i, onProgress: a, options: o, receivedOffset: s = 0, requestOffset: c = 0, signal: l }) {
2150
+ let u = [], d = [...e], f = /* @__PURE__ */ new Set(), p = r ?? jt(o), m = t, h = t, g = 0, _;
2111
2151
  for (; g < p;) {
2112
- let e = jt(m);
2152
+ let e = Mt(m);
2113
2153
  if (f.has(e)) throw Error("Vibe autofill received a repeated cursor.");
2114
- f.add(e), await Ot({
2115
- delayMs: Dt(c + g, o),
2154
+ f.add(e), await kt({
2155
+ delayMs: Ot(c + g, o),
2116
2156
  onChange: i,
2117
2157
  signal: l
2118
2158
  });
2119
- let t = bt(await n({
2159
+ let t = xt(await n({
2120
2160
  cursor: m,
2121
2161
  signal: l
2122
2162
  }));
@@ -2156,30 +2196,30 @@ async function Rt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
2156
2196
  total: _
2157
2197
  };
2158
2198
  }
2159
- var zt = 100;
2160
- function Bt(e, t) {
2199
+ var Bt = 100;
2200
+ function Vt(e, t) {
2161
2201
  if (!Number.isFinite(t) || t <= 0) throw TypeError(`Vibe ${e} must be a positive number.`);
2162
2202
  }
2163
- function Vt(e, t, n) {
2203
+ function Ht(e, t, n) {
2164
2204
  return Math.min(n, Math.max(t, e));
2165
2205
  }
2166
- function Ht(e) {
2206
+ function Ut(e) {
2167
2207
  if (!e) return;
2168
2208
  let t = e.minSpeedPxPerSecond ?? 20, n = e.maxSpeedPxPerSecond ?? 240;
2169
- if (Bt("autoScroll.minSpeedPxPerSecond", t), Bt("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2170
- e.speedPxPerSecond !== void 0 && Bt("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2209
+ if (Vt("autoScroll.minSpeedPxPerSecond", t), Vt("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2210
+ e.speedPxPerSecond !== void 0 && Vt("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2171
2211
  }
2172
- function Ut(e) {
2212
+ function Wt(e) {
2173
2213
  let t = e?.minSpeedPxPerSecond ?? 20, n = e?.maxSpeedPxPerSecond ?? 240;
2174
2214
  return {
2175
2215
  enabled: e?.enabled ?? !1,
2176
2216
  maxSpeedPxPerSecond: n,
2177
2217
  minSpeedPxPerSecond: t,
2178
2218
  paused: !1,
2179
- speedPxPerSecond: Vt(e?.speedPxPerSecond ?? 80, t, n)
2219
+ speedPxPerSecond: Ht(e?.speedPxPerSecond ?? 80, t, n)
2180
2220
  };
2181
2221
  }
2182
- var Wt = class {
2222
+ var Gt = class {
2183
2223
  frame = null;
2184
2224
  lastTimestamp = null;
2185
2225
  mounted = !1;
@@ -2199,9 +2239,9 @@ var Wt = class {
2199
2239
  this.options.state.enabled && (this.options.state.paused = e, this.lastTimestamp = null, e ? this.cancelFrame() : this.schedule());
2200
2240
  }
2201
2241
  setSpeed(e) {
2202
- Bt("auto-scroll speed", e);
2242
+ Vt("auto-scroll speed", e);
2203
2243
  let t = this.options.state;
2204
- t.speedPxPerSecond = Vt(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2244
+ t.speedPxPerSecond = Ht(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2205
2245
  }
2206
2246
  tick = (e) => {
2207
2247
  this.frame = null;
@@ -2213,7 +2253,7 @@ var Wt = class {
2213
2253
  return;
2214
2254
  }
2215
2255
  if (this.lastTimestamp !== null) {
2216
- let r = Math.min(zt, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2256
+ let r = Math.min(Bt, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2217
2257
  n.scrollTop = Math.min(i, n.scrollTop + t.speedPxPerSecond * r / 1e3);
2218
2258
  }
2219
2259
  this.lastTimestamp = e, this.schedule();
@@ -2227,7 +2267,7 @@ var Wt = class {
2227
2267
  };
2228
2268
  //#endregion
2229
2269
  //#region src/core/backendAutofill.ts
2230
- async function Gt(e, t, n, r) {
2270
+ async function Kt(e, t, n, r) {
2231
2271
  let i = await e.onUnderfilled(n);
2232
2272
  if (!r()) return;
2233
2273
  if (!i.sessionId.trim()) throw TypeError("Vibe backend autofill requires a sessionId.");
@@ -2241,45 +2281,19 @@ async function Gt(e, t, n, r) {
2241
2281
  status: "waiting"
2242
2282
  });
2243
2283
  }
2244
- function Kt(e, t) {
2284
+ function qt(e, t) {
2245
2285
  ["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);
2246
2286
  }
2247
- function qt(e, t, n) {
2248
- let r = t.autofill;
2249
- return !Lt(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (Kt(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);
2250
- }
2251
2287
  function Jt(e, t, n) {
2252
- return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Pt(e, n), Kt(t, n), !0);
2253
- }
2254
- var Yt = 1.5;
2255
- function Xt(e) {
2256
- let t = Math.min(e.screenWidth, e.screenHeight);
2257
- if (t > 0 && t < 600) return !0;
2258
- let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * Yt;
2259
- return !e.hasHover && n > 0 && n < 600 && r;
2260
- }
2261
- function Zt(e) {
2262
- return Xt(e) ? "reel" : "masonry";
2263
- }
2264
- function Qt(e) {
2265
- let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
2266
- return {
2267
- hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
2268
- screenHeight: t?.screen.height ?? 0,
2269
- screenWidth: t?.screen.width ?? 0,
2270
- viewportHeight: n.clientHeight,
2271
- viewportWidth: n.clientWidth
2272
- };
2273
- }
2274
- function $t(e) {
2275
- return Xt(Qt(e));
2288
+ let r = t.autofill;
2289
+ return !Rt(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (qt(t, n), Object.assign(r, $(n.status === "waiting" ? n.nextRequestAt : null)), r.error = n.error ?? null, r.missing = Math.max(0, (r.pageSize ?? 0) - n.received), r.received = n.received, n.requests !== void 0 && (r.requests = n.requests), r.sequence = n.sequence, r.status = n.status, !0);
2276
2290
  }
2277
- function en(e) {
2278
- return Zt(Qt(e));
2291
+ function Yt(e, t, n) {
2292
+ return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Ft(e, n), qt(t, n), !0);
2279
2293
  }
2280
2294
  //#endregion
2281
2295
  //#region src/core/initialAutofill.ts
2282
- async function tn({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signal: i, state: a }) {
2296
+ async function Xt({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signal: i, state: a }) {
2283
2297
  let o = r.autofill;
2284
2298
  if (!o) return;
2285
2299
  let s = a.items.length;
@@ -2292,7 +2306,7 @@ async function tn({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
2292
2306
  return;
2293
2307
  }
2294
2308
  if (o.strategy === "backend") {
2295
- await Gt(o, a, {
2309
+ await Kt(o, a, {
2296
2310
  cycleId: e,
2297
2311
  feedKey: o.feedKey,
2298
2312
  items: [...a.items],
@@ -2309,11 +2323,11 @@ async function tn({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
2309
2323
  a.autofill.status = "exhausted";
2310
2324
  return;
2311
2325
  }
2312
- let c = await Rt({
2326
+ let c = await zt({
2313
2327
  existingItems: a.items,
2314
2328
  initialCursor: a.next,
2315
2329
  loadPage: r.loadPage,
2316
- maximumRequests: At(o, !1),
2330
+ maximumRequests: jt(o, !1),
2317
2331
  onDelayChange: (e) => {
2318
2332
  t() && Object.assign(a.autofill, e);
2319
2333
  },
@@ -2334,13 +2348,13 @@ async function tn({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
2334
2348
  }
2335
2349
  //#endregion
2336
2350
  //#region src/core/fill.ts
2337
- function nn(e) {
2351
+ function Zt(e) {
2338
2352
  return "pages" in e ? { pages: e.pages } : { until: "end" };
2339
2353
  }
2340
- function rn(e) {
2354
+ function Qt(e) {
2341
2355
  return `${typeof e}:${String(e)}`;
2342
2356
  }
2343
- function an(e) {
2357
+ function $t(e) {
2344
2358
  if (!e || typeof e != "object") throw TypeError("Vibe fill target must be an object.");
2345
2359
  if ("pages" in e) {
2346
2360
  if (!Number.isInteger(e.pages) || e.pages <= 0) throw TypeError("Vibe fill pages must be a positive integer.");
@@ -2349,20 +2363,20 @@ function an(e) {
2349
2363
  if ("until" in e && e.until === "end") return { until: "end" };
2350
2364
  throw TypeError("Vibe fill target must be { pages } or { until: 'end' }.");
2351
2365
  }
2352
- function on(e) {
2366
+ function en(e) {
2353
2367
  if (!e) return;
2354
2368
  if (e.strategy === "frontend") {
2355
- Et(e, "frontend fill");
2369
+ Dt(e, "frontend fill");
2356
2370
  return;
2357
2371
  }
2358
2372
  if (!e.feedKey.trim()) throw TypeError("Vibe backend fill requires a feedKey.");
2359
2373
  let t = e.initialSession;
2360
2374
  if (t) {
2361
2375
  if (t.feedKey !== e.feedKey) throw TypeError("Vibe backend fill initialSession feedKey must match fill feedKey.");
2362
- an(t.target);
2376
+ $t(t.target);
2363
2377
  }
2364
2378
  }
2365
- function sn(e, t, n = !0) {
2379
+ function tn(e, t, n = !0) {
2366
2380
  let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = $(i?.nextRequestAt);
2367
2381
  return {
2368
2382
  completedPages: i?.completedPages ?? 0,
@@ -2376,10 +2390,10 @@ function sn(e, t, n = !0) {
2376
2390
  sessionId: i?.sessionId ?? null,
2377
2391
  status: i?.status ?? "idle",
2378
2392
  strategy: e?.strategy ?? null,
2379
- target: i ? nn(i.target) : null
2393
+ target: i ? Zt(i.target) : null
2380
2394
  };
2381
2395
  }
2382
- function cn(e) {
2396
+ function nn(e) {
2383
2397
  return [
2384
2398
  "cancelling",
2385
2399
  "filling",
@@ -2387,17 +2401,17 @@ function cn(e) {
2387
2401
  "waiting"
2388
2402
  ].includes(e.status);
2389
2403
  }
2390
- async function ln({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2404
+ async function rn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2391
2405
  let c = [], l = [...e], u = /* @__PURE__ */ new Set(), d = 0, f = t, p = t, m = 0, h;
2392
2406
  for (; p !== null;) {
2393
- let e = rn(f);
2407
+ let e = Qt(f);
2394
2408
  if (u.has(e)) throw Error("Vibe fill received a repeated cursor.");
2395
- u.add(e), await Ot({
2396
- delayMs: Dt(d, a),
2409
+ u.add(e), await kt({
2410
+ delayMs: Ot(d, a),
2397
2411
  onChange: r,
2398
2412
  signal: o
2399
2413
  });
2400
- let t = bt(await n({
2414
+ let t = xt(await n({
2401
2415
  cursor: f,
2402
2416
  signal: o
2403
2417
  }));
@@ -2439,7 +2453,7 @@ async function ln({ existingItems: e, initialCursor: t, loadPage: n, onDelayChan
2439
2453
  }
2440
2454
  //#endregion
2441
2455
  //#region src/core/backendFill.ts
2442
- async function un(e, t, n, r) {
2456
+ async function an(e, t, n, r) {
2443
2457
  let i = await e.onStart(n);
2444
2458
  if (r()) {
2445
2459
  if (!i.sessionId.trim()) throw TypeError("Vibe backend fill requires a sessionId.");
@@ -2453,22 +2467,22 @@ async function un(e, t, n, r) {
2453
2467
  });
2454
2468
  }
2455
2469
  }
2456
- function dn(e, t, n) {
2470
+ function on(e, t, n) {
2457
2471
  return e?.strategy === "backend" && n.feedKey === e.feedKey && n.sessionId === t.fill.sessionId;
2458
2472
  }
2459
- function fn(e) {
2473
+ function sn(e) {
2460
2474
  return Number.isInteger(e.completedPages) && e.completedPages >= 0 && Number.isInteger(e.received) && e.received >= 0 && Number.isInteger(e.sequence) && e.sequence >= 0;
2461
2475
  }
2462
- function pn(e, t) {
2476
+ function cn(e, t) {
2463
2477
  if (!["complete", "exhausted"].includes(t.status)) return !0;
2464
2478
  let n = e.fill.target;
2465
2479
  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;
2466
2480
  }
2467
- function mn(e, t, n) {
2481
+ function ln(e, t, n) {
2468
2482
  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));
2469
2483
  }
2470
- function hn(e, t, n, r) {
2471
- return !dn(e, t, n) || !fn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !pn(t, n) ? !1 : (mn(t, n, r), Object.assign(t.fill, {
2484
+ function un(e, t, n, r) {
2485
+ return !on(e, t, n) || !sn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !cn(t, n) ? !1 : (ln(t, n, r), Object.assign(t.fill, {
2472
2486
  ...$(n.status === "waiting" ? n.nextRequestAt : null),
2473
2487
  completedPages: n.completedPages,
2474
2488
  error: n.error ?? null,
@@ -2477,41 +2491,41 @@ function hn(e, t, n, r) {
2477
2491
  status: n.status
2478
2492
  }), !0);
2479
2493
  }
2480
- function gn(e, t, n, r) {
2494
+ function dn(e, t, n, r) {
2481
2495
  if (e?.strategy !== "backend" || n.feedKey !== e.feedKey) return !1;
2482
2496
  let i = t.fill;
2483
- return t.fill = sn(e, n), !fn(n) || !pn(t, n) ? (t.fill = i, !1) : (mn(t, n, r), !0);
2497
+ return t.fill = tn(e, n), !sn(n) || !cn(t, n) ? (t.fill = i, !1) : (ln(t, n, r), !0);
2484
2498
  }
2485
2499
  //#endregion
2486
2500
  //#region src/core/fillController.ts
2487
- var _n = class {
2501
+ var fn = class {
2488
2502
  abortController = null;
2489
2503
  cycle = 0;
2490
2504
  delayCountdown;
2491
2505
  requestVersion = 0;
2492
2506
  constructor(e) {
2493
- this.options = e, this.delayCountdown = new kt((e) => {
2507
+ this.options = e, this.delayCountdown = new At((e) => {
2494
2508
  Object.assign(this.options.state.fill, e);
2495
2509
  }), this.syncBackendCountdown();
2496
2510
  }
2497
2511
  isActive() {
2498
- return cn(this.options.state.fill);
2512
+ return nn(this.options.state.fill);
2499
2513
  }
2500
2514
  applyUpdate(e) {
2501
- let t = hn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2515
+ let t = un(this.options.fill, this.options.state, e, this.options.onLastCursor);
2502
2516
  return t && this.syncBackendCountdown(), t;
2503
2517
  }
2504
2518
  restoreSession(e) {
2505
- let t = gn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2519
+ let t = dn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2506
2520
  return t && this.syncBackendCountdown(), t;
2507
2521
  }
2508
2522
  async start(e) {
2509
2523
  let t = this.options.fill;
2510
2524
  if (!t) throw Error("Vibe fill is not configured.");
2511
2525
  if (this.isActive()) throw Error("Vibe fill is already active.");
2512
- let n = an(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2526
+ let n = $t(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2513
2527
  if (this.options.state.fill = {
2514
- ...sn(t, void 0, !1),
2528
+ ...tn(t, void 0, !1),
2515
2529
  cycleId: r,
2516
2530
  status: "filling",
2517
2531
  target: n
@@ -2522,7 +2536,7 @@ var _n = class {
2522
2536
  let i = ++this.requestVersion, a = new AbortController();
2523
2537
  this.abortController = a;
2524
2538
  try {
2525
- t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await un(t, this.options.state, {
2539
+ t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await an(t, this.options.state, {
2526
2540
  cycleId: r,
2527
2541
  feedKey: t.feedKey,
2528
2542
  items: [...this.options.state.items],
@@ -2540,7 +2554,7 @@ var _n = class {
2540
2554
  }
2541
2555
  async cancel() {
2542
2556
  let { fill: e, state: t } = this.options;
2543
- if (!cn(t.fill) || !t.fill.cycleId) return;
2557
+ if (!nn(t.fill) || !t.fill.cycleId) return;
2544
2558
  let n = {
2545
2559
  cycleId: t.fill.cycleId,
2546
2560
  feedKey: t.fill.feedKey ?? "",
@@ -2554,7 +2568,7 @@ var _n = class {
2554
2568
  }
2555
2569
  }
2556
2570
  reset() {
2557
- this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = sn(this.options.fill, void 0, !1);
2571
+ this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = tn(this.options.fill, void 0, !1);
2558
2572
  }
2559
2573
  destroy() {
2560
2574
  this.abortLocalRequest(), this.delayCountdown.clear();
@@ -2570,7 +2584,7 @@ var _n = class {
2570
2584
  if (!i) throw Error("Vibe frontend fill requires loadPage.");
2571
2585
  let a = this.options.state;
2572
2586
  a.isLoadingMore = !0;
2573
- let o = await ln({
2587
+ let o = await rn({
2574
2588
  existingItems: a.items,
2575
2589
  initialCursor: a.next,
2576
2590
  loadPage: i,
@@ -2597,7 +2611,7 @@ var _n = class {
2597
2611
  };
2598
2612
  //#endregion
2599
2613
  //#region src/core/feedFooter.ts
2600
- function vn(e) {
2614
+ function pn(e) {
2601
2615
  return {
2602
2616
  cancelAutofill: () => e.cancelAutofill(),
2603
2617
  loadMore: () => e.loadNext(),
@@ -2605,45 +2619,45 @@ function vn(e) {
2605
2619
  retryEnd: () => e.retryEnd()
2606
2620
  };
2607
2621
  }
2608
- function yn(e) {
2622
+ function mn(e) {
2609
2623
  if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
2610
2624
  }
2611
- function bn(e) {
2612
- e?.intervalMs !== void 0 && yn(e.intervalMs);
2625
+ function hn(e) {
2626
+ e?.intervalMs !== void 0 && mn(e.intervalMs);
2613
2627
  }
2614
- function xn(e) {
2628
+ function gn(e) {
2615
2629
  return {
2616
2630
  enabled: e?.enabled ?? !1,
2617
2631
  includePostItems: e?.includePostItems ?? !1,
2618
2632
  intervalMs: e?.intervalMs ?? 5e3
2619
2633
  };
2620
2634
  }
2621
- function Sn(e, t) {
2635
+ function _n(e, t) {
2622
2636
  if (typeof t == "boolean") {
2623
2637
  e.enabled = t;
2624
2638
  return;
2625
2639
  }
2626
- bn(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);
2640
+ hn(t), t.enabled !== void 0 && (e.enabled = t.enabled), t.includePostItems !== void 0 && (e.includePostItems = t.includePostItems), t.intervalMs !== void 0 && (e.intervalMs = t.intervalMs);
2627
2641
  }
2628
2642
  //#endregion
2629
2643
  //#region src/core/reelInfoSheet.ts
2630
- function Cn(e) {
2644
+ function vn(e) {
2631
2645
  return { enabled: e?.enabled ?? !1 };
2632
2646
  }
2633
- function wn(e, t, n) {
2647
+ function yn(e, t, n) {
2634
2648
  if (n && !t) throw Error("Vibe cannot enable reelInfoSheet without a configured component.");
2635
2649
  e.enabled = n;
2636
2650
  }
2637
2651
  //#endregion
2638
2652
  //#region src/core/initialRuntimeState.ts
2639
- function Tn(e, t) {
2653
+ function bn(e, t) {
2640
2654
  let n = e.initialPage;
2641
2655
  return {
2642
2656
  activeReelPostId: null,
2643
- autoScroll: Ut(e.autoScroll),
2644
- autofill: Pt(e.autofill),
2657
+ autoScroll: Wt(e.autoScroll),
2658
+ autofill: Ft(e.autofill),
2645
2659
  error: null,
2646
- fill: sn(e.fill),
2660
+ fill: tn(e.fill),
2647
2661
  infiniteScroll: e.infiniteScroll ?? !0,
2648
2662
  isLoading: !n,
2649
2663
  isLoadingMore: !1,
@@ -2652,8 +2666,8 @@ function Tn(e, t) {
2652
2666
  loadMoreLocked: !1,
2653
2667
  next: n?.next ?? null,
2654
2668
  nextPageError: null,
2655
- reelAutoAdvance: xn(e.reelAutoAdvance),
2656
- reelInfoSheet: Cn(e.reelInfoSheet),
2669
+ reelAutoAdvance: gn(e.reelAutoAdvance),
2670
+ reelInfoSheet: vn(e.reelInfoSheet),
2657
2671
  reelInfoSheetOverlay: !1,
2658
2672
  reelMediaSource: "original",
2659
2673
  reelOrigin: null,
@@ -2661,6 +2675,116 @@ function Tn(e, t) {
2661
2675
  };
2662
2676
  }
2663
2677
  //#endregion
2678
+ //#region src/core/itemPlacement.ts
2679
+ function xn(e, t) {
2680
+ let n = new Set(t);
2681
+ return e.flatMap((e, t) => n.has(e.postId) ? [{
2682
+ index: t,
2683
+ item: e
2684
+ }] : []);
2685
+ }
2686
+ function Sn(e, t) {
2687
+ let n = new Set(t.map(({ item: e }) => e.postId));
2688
+ return e.filter((e) => !n.has(e.postId));
2689
+ }
2690
+ function Cn(e, t) {
2691
+ t.forEach(({ index: e }) => {
2692
+ if (!Number.isInteger(e) || e < 0) throw Error("Vibe item restore indexes must be non-negative integers.");
2693
+ });
2694
+ let n = [...e], r = new Set(e.map((e) => e.postId));
2695
+ return [...t].sort((e, t) => e.index - t.index).forEach(({ index: e, item: t }) => {
2696
+ r.has(t.postId) || (n.splice(Math.min(e, n.length), 0, t), r.add(t.postId));
2697
+ }), n;
2698
+ }
2699
+ //#endregion
2700
+ //#region src/core/itemRemovalController.ts
2701
+ var wn = 20, Tn = class {
2702
+ generation = 0;
2703
+ historyLimit;
2704
+ metadata = /* @__PURE__ */ new WeakMap();
2705
+ state;
2706
+ history = [];
2707
+ itemOrder;
2708
+ stopItemsWatcher;
2709
+ constructor(e) {
2710
+ this.options = e, this.historyLimit = e.historyLimit ?? wn, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = D(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
2711
+ }
2712
+ destroy() {
2713
+ this.reset(), this.stopItemsWatcher();
2714
+ }
2715
+ async remove(e) {
2716
+ let t = this.collectOrderedPlacements(e), n = this.createRemoval(t);
2717
+ if (t.length === 0) return n;
2718
+ let r = t.map(({ item: e }) => e.postId), i = this.options.startRemoval(r);
2719
+ if (i > 0 && await new Promise((e) => setTimeout(e, i)), this.metadata.get(n)?.generation !== this.generation) return n;
2720
+ let a = this.state.items.findIndex((e) => e.postId === this.state.activeReelPostId);
2721
+ return this.state.items = Sn(this.state.items, t), this.options.onItemsRemoved(t, a), this.record(n), n;
2722
+ }
2723
+ reset() {
2724
+ this.generation += 1, this.history = [], this.itemOrder = [];
2725
+ }
2726
+ restoreItems(e) {
2727
+ let t = e;
2728
+ if (this.metadata.has(t)) {
2729
+ this.restoreRemoval(t);
2730
+ return;
2731
+ }
2732
+ let n = Cn(this.state.items, e);
2733
+ this.registerExternalPlacements(e), this.state.items = n;
2734
+ }
2735
+ restoreRemoval(e) {
2736
+ let t = this.metadata.get(e);
2737
+ if (!t) throw TypeError("Vibe removal does not belong to this instance.");
2738
+ return t.generation !== this.generation || t.restored ? !1 : (t.restored = !0, this.removeFromHistory(e), this.restoreOrderedPlacements(e));
2739
+ }
2740
+ undoLast() {
2741
+ for (; this.history.length > 0;) {
2742
+ let e = this.history.pop();
2743
+ if (this.restoreRemoval(e)) return e;
2744
+ }
2745
+ return null;
2746
+ }
2747
+ appendUnknownItems(e) {
2748
+ let t = new Set(this.itemOrder);
2749
+ e.forEach(({ postId: e }) => {
2750
+ t.has(e) || (this.itemOrder.push(e), t.add(e));
2751
+ });
2752
+ }
2753
+ collectOrderedPlacements(e) {
2754
+ let t = new Map(this.itemOrder.map((e, t) => [e, t]));
2755
+ return xn(this.state.items, e).map((e) => ({
2756
+ index: t.get(e.item.postId) ?? e.index,
2757
+ item: e.item
2758
+ }));
2759
+ }
2760
+ createRemoval(e) {
2761
+ let t = Object.freeze(e.map((e) => Object.freeze({ ...e })));
2762
+ return this.metadata.set(t, {
2763
+ generation: this.generation,
2764
+ restored: e.length === 0
2765
+ }), t;
2766
+ }
2767
+ record(e) {
2768
+ this.historyLimit !== 0 && (this.history.push(e), this.history.length > this.historyLimit && this.history.shift());
2769
+ }
2770
+ registerExternalPlacements(e) {
2771
+ let t = new Set(this.itemOrder);
2772
+ [...e].sort((e, t) => e.index - t.index).forEach(({ index: e, item: n }) => {
2773
+ t.has(n.postId) || (this.itemOrder.splice(Math.min(e, this.itemOrder.length), 0, n.postId), t.add(n.postId));
2774
+ });
2775
+ }
2776
+ removeFromHistory(e) {
2777
+ let t = this.history.indexOf(e);
2778
+ t >= 0 && this.history.splice(t, 1);
2779
+ }
2780
+ restoreOrderedPlacements(e) {
2781
+ let t = new Set(this.state.items.map(({ postId: e }) => e)), n = e.map(({ item: e }) => e).filter(({ postId: e }) => !t.has(e));
2782
+ if (n.length === 0) return !1;
2783
+ let r = new Map(this.itemOrder.map((e, t) => [e, t]));
2784
+ 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;
2785
+ }
2786
+ };
2787
+ //#endregion
2664
2788
  //#region src/core/options.ts
2665
2789
  function En(e, t) {
2666
2790
  if (t) {
@@ -2669,7 +2793,8 @@ function En(e, t) {
2669
2793
  }
2670
2794
  }
2671
2795
  function Dn(e) {
2672
- if (Ht(e.autoScroll), En("cardHeader", e.cardHeader), En("cardFooter", e.cardFooter), Nt(e.autofill), on(e.fill), bn(e.reelAutoAdvance), !e.initialPage && !e.loadPage) throw TypeError("Vibe requires either initialPage or loadPage.");
2796
+ if (Ut(e.autoScroll), En("cardHeader", e.cardHeader), En("cardFooter", e.cardFooter), Pt(e.autofill), en(e.fill), hn(e.reelAutoAdvance), e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
2797
+ if (!e.initialPage && !e.loadPage) throw TypeError("Vibe requires either initialPage or loadPage.");
2673
2798
  if (e.initialPage?.next !== null && !e.loadPage) throw TypeError("Vibe requires loadPage when initialPage has a next cursor.");
2674
2799
  if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
2675
2800
  if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
@@ -2681,9 +2806,63 @@ function On(e) {
2681
2806
  if (!t) throw Error(`Vibe target not found: ${e}`);
2682
2807
  return t;
2683
2808
  }
2809
+ var kn = 1.5;
2810
+ function An(e) {
2811
+ let t = Math.min(e.screenWidth, e.screenHeight);
2812
+ if (t > 0 && t < 600) return !0;
2813
+ let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * kn;
2814
+ return !e.hasHover && n > 0 && n < 600 && r;
2815
+ }
2816
+ function jn(e) {
2817
+ return An(e) ? "reel" : "masonry";
2818
+ }
2819
+ function Mn(e) {
2820
+ let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
2821
+ return {
2822
+ hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
2823
+ screenHeight: t?.screen.height ?? 0,
2824
+ screenWidth: t?.screen.width ?? 0,
2825
+ viewportHeight: n.clientHeight,
2826
+ viewportWidth: n.clientWidth
2827
+ };
2828
+ }
2829
+ function Nn(e) {
2830
+ return An(Mn(e));
2831
+ }
2832
+ function Pn(e) {
2833
+ return jn(Mn(e));
2834
+ }
2684
2835
  //#endregion
2685
- //#region src/core/vibeRouting.ts
2686
- var kn = class {
2836
+ //#region src/core/responsiveLayoutController.ts
2837
+ var Fn = class {
2838
+ layoutMode;
2839
+ resizeObserver = null;
2840
+ target = null;
2841
+ constructor(e, t, n) {
2842
+ this.state = t, this.onFeedLayout = n, this.layoutMode = e;
2843
+ }
2844
+ mount(e) {
2845
+ this.target = e, this.handleResponsiveLayout();
2846
+ let t = e.ownerDocument.defaultView;
2847
+ t?.addEventListener("resize", this.handleResponsiveLayout);
2848
+ let n = t?.ResizeObserver ?? globalThis.ResizeObserver;
2849
+ n !== void 0 && (this.resizeObserver = new n(this.handleResponsiveLayout), this.resizeObserver.observe(e));
2850
+ }
2851
+ destroy() {
2852
+ this.target?.ownerDocument.defaultView?.removeEventListener("resize", this.handleResponsiveLayout), this.resizeObserver?.disconnect(), this.resizeObserver = null, this.target = null;
2853
+ }
2854
+ setLayout(e) {
2855
+ e !== this.layoutMode && (this.layoutMode = e, e === "responsive" ? this.handleResponsiveLayout() : this.applyLayout(e));
2856
+ }
2857
+ applyLayout(e) {
2858
+ e !== this.state.layout && (e === "masonry" && (this.state.activeReelPostId = null, this.onFeedLayout()), this.state.reelOrigin = null, this.state.layout = e);
2859
+ }
2860
+ handleResponsiveLayout = () => {
2861
+ if (!this.target) return;
2862
+ let e = Pn(this.target);
2863
+ this.state.reelInfoSheetOverlay = Nn(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
2864
+ };
2865
+ }, In = class {
2687
2866
  routedReelPostId = null;
2688
2867
  reelRouteIsActive = !1;
2689
2868
  constructor(e, t) {
@@ -2710,7 +2889,7 @@ var kn = class {
2710
2889
  let i = this.reelRouteIsActive ? "replace" : "push";
2711
2890
  this.reelRouteIsActive = !0, this.routedReelPostId = e, this.options.router[i](r);
2712
2891
  }
2713
- }, An = class {
2892
+ }, Ln = class {
2714
2893
  app = null;
2715
2894
  autoScroll;
2716
2895
  autofillDelayCountdown;
@@ -2718,38 +2897,48 @@ var kn = class {
2718
2897
  abortController = null;
2719
2898
  pendingRequest = null;
2720
2899
  requestVersion = 0;
2721
- resizeObserver = null;
2900
+ responsiveLayout;
2722
2901
  routing;
2723
2902
  fillController;
2903
+ itemRemoval;
2724
2904
  surface = null;
2725
2905
  stopStateWatcher = null;
2726
- target = null;
2727
- layoutMode;
2728
2906
  lastLoadedCursor = null;
2729
2907
  state;
2730
2908
  constructor(e) {
2731
- this.options = e, Dn(e), this.layoutMode = e.layout ?? "masonry", this.state = b(Tn(e, this.layoutMode)), this.autoScroll = new Wt({
2909
+ this.options = e, Dn(e);
2910
+ let t = e.layout ?? "masonry";
2911
+ this.state = b(bn(e, t)), this.autoScroll = new Gt({
2732
2912
  getScrollElement: () => this.surface?.getAutoScrollElement() ?? null,
2733
2913
  state: this.state.autoScroll
2734
- }), this.autofillDelayCountdown = new kt((e) => Object.assign(this.state.autofill, e)), this.syncAutofillCountdown(), this.fillController = new _n({
2914
+ }), this.autofillDelayCountdown = new At((e) => Object.assign(this.state.autofill, e)), this.syncAutofillCountdown(), this.fillController = new fn({
2735
2915
  fill: e.fill,
2736
2916
  loadPage: e.loadPage,
2737
2917
  onLastCursor: (e) => {
2738
2918
  this.lastLoadedCursor = e;
2739
2919
  },
2740
2920
  state: this.state
2741
- }), this.routing = new kn(e.routing, this.state), this.startStateNotifications();
2921
+ }), this.routing = new In(e.routing, this.state), this.itemRemoval = new Tn({
2922
+ historyLimit: e.removalHistoryLimit,
2923
+ onItemsRemoved: (e, t) => {
2924
+ this.restoreActiveItemAfterRemoval(e, t);
2925
+ },
2926
+ startRemoval: (e) => this.surface?.startItemRemoval(e) ?? 0,
2927
+ state: this.state
2928
+ }), this.responsiveLayout = new Fn(t, this.state, () => {
2929
+ this.routing.syncFeed();
2930
+ }), this.startStateNotifications();
2742
2931
  }
2743
2932
  async mount() {
2744
2933
  if (this.app) throw Error("Vibe is already mounted.");
2745
2934
  this.startStateNotifications();
2746
2935
  let e = On(this.options.target);
2747
- this.target = e, this.startResponsiveLayout(), this.app = r(yt, {
2936
+ this.responsiveLayout.mount(e), this.app = r(bt, {
2748
2937
  canRetryEnd: !!this.options.loadPage,
2749
2938
  cardFooter: this.options.cardFooter,
2750
2939
  cardHeader: this.options.cardHeader,
2751
2940
  feedFooter: this.options.feedFooter,
2752
- feedFooterActions: vn(this),
2941
+ feedFooterActions: pn(this),
2753
2942
  reelInfoSheet: this.options.reelInfoSheet,
2754
2943
  state: this.state,
2755
2944
  onActiveReelChange: (e) => this.setActiveReelPost(e),
@@ -2765,11 +2954,23 @@ var kn = class {
2765
2954
  }), this.surface = this.app.mount(e), this.autoScroll.mount(), this.options.initialPage ? this.options.autofill && this.state.autofill.status === "idle" && !this.fillController.isActive() && await this.startInitialAutofill() : await this.reload();
2766
2955
  }
2767
2956
  destroy() {
2768
- this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.stopResponsiveLayout(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null, this.target = null;
2957
+ this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.itemRemoval.destroy(), this.responsiveLayout.destroy(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null;
2769
2958
  }
2770
2959
  getState() {
2771
2960
  return F(this.state);
2772
2961
  }
2962
+ removeItems(e) {
2963
+ return this.itemRemoval.remove(e);
2964
+ }
2965
+ restoreItems(e) {
2966
+ this.itemRemoval.restoreItems(e);
2967
+ }
2968
+ restoreRemoval(e) {
2969
+ return this.itemRemoval.restoreRemoval(e);
2970
+ }
2971
+ undoLastRemoval() {
2972
+ return this.itemRemoval.undoLast();
2973
+ }
2773
2974
  nextReelMediaItem() {
2774
2975
  return this.surface?.changeActiveReelMedia(1) ?? !1;
2775
2976
  }
@@ -2795,11 +2996,11 @@ var kn = class {
2795
2996
  this.autoScroll.setSpeed(e);
2796
2997
  }
2797
2998
  applyAutofillUpdate(e) {
2798
- let t = qt(this.options.autofill, this.state, e);
2999
+ let t = Jt(this.options.autofill, this.state, e);
2799
3000
  return t && this.syncAutofillCountdown(), t;
2800
3001
  }
2801
3002
  async cancelAutofill() {
2802
- await It(this.options.autofill, this.state, () => this.cancelRequest());
3003
+ await Lt(this.options.autofill, this.state, () => this.cancelRequest());
2803
3004
  }
2804
3005
  applyFillUpdate(e) {
2805
3006
  return this.fillController.applyUpdate(e);
@@ -2808,11 +3009,11 @@ var kn = class {
2808
3009
  return this.fillController.cancel();
2809
3010
  }
2810
3011
  async fill(e) {
2811
- if (this.pendingRequest || Ft(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
3012
+ if (this.pendingRequest || It(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
2812
3013
  await this.fillController.start(e);
2813
3014
  }
2814
3015
  restoreAutofillSession(e) {
2815
- let t = Jt(this.options.autofill, this.state, e);
3016
+ let t = Yt(this.options.autofill, this.state, e);
2816
3017
  return t && this.syncAutofillCountdown(), t;
2817
3018
  }
2818
3019
  restoreFillSession(e) {
@@ -2820,15 +3021,15 @@ var kn = class {
2820
3021
  }
2821
3022
  async loadNext() {
2822
3023
  if (this.pendingRequest) return this.pendingRequest;
2823
- if (!this.state.loadMoreLocked && !(Ft(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);
3024
+ if (!this.state.loadMoreLocked && !(It(this.state.autofill) || this.fillController.isActive()) && !(this.state.next === null || !this.options.loadPage)) return this.state.isLoadingMore = !0, this.state.nextPageError = null, this.startRequest(this.state.next, !0);
2824
3025
  }
2825
3026
  async reload() {
2826
3027
  if (!this.options.loadPage) throw Error("Vibe cannot reload without loadPage.");
2827
- return Ft(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Pt(this.options.autofill, void 0, !1), this.fillController.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(null, !1);
3028
+ return It(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Ft(this.options.autofill, void 0, !1), this.fillController.reset(), this.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(null, !1);
2828
3029
  }
2829
3030
  async retryEnd() {
2830
3031
  if (this.pendingRequest) return this.pendingRequest;
2831
- if (!this.state.loadMoreLocked && !(Ft(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);
3032
+ if (!this.state.loadMoreLocked && !(It(this.state.autofill) || this.fillController.isActive()) && !(this.state.next !== null || !this.options.loadPage)) return this.state.isLoadingMore = !0, this.state.nextPageError = null, this.startRequest(this.lastLoadedCursor, !0);
2832
3033
  }
2833
3034
  setInfiniteScroll(e) {
2834
3035
  this.state.infiniteScroll = e, e && p(() => this.surface?.loadIfNearBottom());
@@ -2837,36 +3038,27 @@ var kn = class {
2837
3038
  this.state.loadMoreLocked !== e && (this.state.loadMoreLocked = e, !e && this.state.infiniteScroll && p(() => this.surface?.loadIfNearBottom()));
2838
3039
  }
2839
3040
  setReelAutoAdvance(e) {
2840
- Sn(this.state.reelAutoAdvance, e);
3041
+ _n(this.state.reelAutoAdvance, e);
2841
3042
  }
2842
3043
  setReelInfoSheet(e) {
2843
- wn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
3044
+ yn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
2844
3045
  }
2845
3046
  setLayout(e) {
2846
- e !== this.layoutMode && (this.layoutMode = e, e === "responsive" ? this.handleResponsiveLayout() : this.applyLayout(e));
2847
- }
2848
- applyLayout(e) {
2849
- e !== this.state.layout && (e === "masonry" && (this.state.activeReelPostId = null, this.routing.syncFeed()), this.state.reelOrigin = null, this.state.layout = e);
2850
- }
2851
- handleResponsiveLayout = () => {
2852
- if (!this.target) return;
2853
- let e = en(this.target);
2854
- this.state.reelInfoSheetOverlay = $t(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
2855
- };
2856
- startResponsiveLayout() {
2857
- if (!this.target) return;
2858
- this.handleResponsiveLayout();
2859
- let e = this.target.ownerDocument.defaultView;
2860
- e?.addEventListener("resize", this.handleResponsiveLayout);
2861
- let t = e?.ResizeObserver ?? globalThis.ResizeObserver;
2862
- t !== void 0 && (this.resizeObserver = new t(this.handleResponsiveLayout), this.resizeObserver.observe(this.target));
2863
- }
2864
- stopResponsiveLayout() {
2865
- this.target?.ownerDocument.defaultView?.removeEventListener("resize", this.handleResponsiveLayout), this.resizeObserver?.disconnect(), this.resizeObserver = null;
3047
+ this.responsiveLayout.setLayout(e);
2866
3048
  }
2867
3049
  closeMasonryReel() {
2868
3050
  this.state.reelOrigin === "masonry" && (this.state.activeReelPostId = null, this.state.reelOrigin = null, this.routing.syncFeed());
2869
3051
  }
3052
+ restoreActiveItemAfterRemoval(e, t) {
3053
+ let n = new Set(e.map(({ item: e }) => e.postId));
3054
+ if (this.state.activeReelPostId === null || !n.has(this.state.activeReelPostId)) return;
3055
+ if (this.state.reelOrigin === "masonry") {
3056
+ this.closeMasonryReel();
3057
+ return;
3058
+ }
3059
+ let r = this.state.items[Math.min(Math.max(t, 0), this.state.items.length - 1)];
3060
+ this.state.activeReelPostId = r?.postId ?? null, r ? this.routing.syncReel(r.postId) : this.routing.syncFeed();
3061
+ }
2870
3062
  openMasonryReel(e) {
2871
3063
  this.state.layout === "masonry" && this.state.items.some((t) => t.postId === e) && (this.state.activeReelPostId = e, this.state.reelOrigin = "masonry", this.routing.syncReel(e));
2872
3064
  }
@@ -2883,7 +3075,7 @@ var kn = class {
2883
3075
  this.abortController = i;
2884
3076
  try {
2885
3077
  if (a?.strategy === "frontend") {
2886
- let o = await Rt({
3078
+ let o = await zt({
2887
3079
  existingItems: t ? this.state.items : [],
2888
3080
  initialCursor: e,
2889
3081
  loadPage: n,
@@ -2905,7 +3097,7 @@ var kn = class {
2905
3097
  });
2906
3098
  return;
2907
3099
  }
2908
- let c = bt(await n({
3100
+ let c = xt(await n({
2909
3101
  cursor: e,
2910
3102
  signal: i.signal
2911
3103
  }));
@@ -2920,7 +3112,7 @@ var kn = class {
2920
3112
  this.state.autofill.status = "complete";
2921
3113
  return;
2922
3114
  }
2923
- await Gt(a, this.state, {
3115
+ await Kt(a, this.state, {
2924
3116
  cycleId: o,
2925
3117
  feedKey: a.feedKey,
2926
3118
  items: u.slice(l.length),
@@ -2945,7 +3137,7 @@ var kn = class {
2945
3137
  this.autofillDelayCountdown.clear();
2946
3138
  let t = `vibe-autofill-${Date.now().toString(36)}-${++this.autofillCycle}`;
2947
3139
  return this.state.autofill = {
2948
- ...Pt(e, void 0, !1),
3140
+ ...Ft(e, void 0, !1),
2949
3141
  cycleId: t,
2950
3142
  status: "filling"
2951
3143
  }, t;
@@ -2963,7 +3155,7 @@ var kn = class {
2963
3155
  startInitialAutofill() {
2964
3156
  let e = ++this.requestVersion, t = new AbortController(), n = this.beginAutofillCycle();
2965
3157
  this.abortController = t, this.state.isLoadingMore = !0;
2966
- let r = tn({
3158
+ let r = Xt({
2967
3159
  cycleId: n,
2968
3160
  isCurrent: () => e === this.requestVersion,
2969
3161
  onLastCursor: (e) => {
@@ -2987,8 +3179,8 @@ var kn = class {
2987
3179
  }));
2988
3180
  }
2989
3181
  };
2990
- function jn(e) {
2991
- return new An(e);
3182
+ function Rn(e) {
3183
+ return new Ln(e);
2992
3184
  }
2993
3185
  //#endregion
2994
- export { jn as createVibe };
3186
+ export { Rn as createVibe };