@hadoku/watchparty-ui 0.45.29 → 0.45.31

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.
@@ -1,14 +1,14 @@
1
1
  import { jsx as d, jsxs as _, Fragment as Se } from "react/jsx-runtime";
2
- import Ke, { useState as $, useRef as P, useEffect as L, useCallback as U, useMemo as Ee, Component as qr, useContext as Pn, createContext as Bn, useId as Yr, useEffectEvent as fe } from "react";
3
- import { k as Xr, M as Zr, m as es, f as ts, a as ns, C as dt, g as Jt, i as rs, S as ss, r as vt, d as E, e as ee, b as as, u as x, A as pt, c as is, h as tt, j as Dn, n as On, D as it, w as C, l as os, o as cs, s as Hn, p as Un, q as jn, t as ls, L as ds, v as us, x as fs, y as Qt, z as hs, B as ps, E as ms, F as gs, G as Gn, H as qt, I as Wn, J as Kn, K as bs, N as ys, O as Ce, P as un, T as Tt, Q as vs, R as Vn, U as Ss, V as ws, W as zn, X as Y, Y as xs, Z as Jn, _ as Qn, $ as Xe, a0 as Es, a1 as Ms, a2 as ks, a3 as _s, a4 as As, a5 as fn, a6 as ze, a7 as Ts, a8 as hn, a9 as Is, aa as Cs, ab as pn, ac as Rs, ad as Fs, ae as Ns, af as Ls, ag as $s, ah as mn, ai as gn, aj as Ps, ak as qn, al as bn, am as Bs, an as gt, ao as Ds, ap as Os, aq as Hs, ar as Us, as as js, at as Gs, au as Ws, av as Ks, aw as Vs, ax as zs } from "./index-CXl-xAUD.js";
2
+ import Ve, { useState as $, useRef as P, useEffect as L, useCallback as U, useMemo as Ee, Component as Xr, useContext as Bn, createContext as On, useId as Zr, useEffectEvent as fe } from "react";
3
+ import { k as es, M as ts, m as ns, f as rs, a as ss, C as dt, g as Jt, i as as, S as is, r as vt, d as E, e as ee, b as os, u as x, A as pt, c as cs, h as tt, j as Hn, n as Un, D as it, w as C, l as ls, o as ds, s as jn, p as Gn, q as Wn, t as us, L as fs, v as hs, x as ps, y as Qt, z as ms, B as gs, E as bs, F as ys, G as Vn, H as qt, I as Kn, J as zn, K as vs, N as Ss, O as Ce, P as un, T as Tt, Q as ws, R as Jn, U as xs, V as Es, W as Qn, X as Y, Y as Ms, Z as qn, _ as Yn, $ as Xe, a0 as ks, a1 as _s, a2 as As, a3 as Ts, a4 as Is, a5 as fn, a6 as ze, a7 as Cs, a8 as hn, a9 as Rs, aa as Fs, ab as pn, ac as Ns, ad as Ls, ae as $s, af as Ps, ag as Ds, ah as mn, ai as gn, aj as Bs, ak as Xn, al as bn, am as Os, an as gt, ao as Hs, ap as Us, aq as js, ar as Gs, as as Ws, at as Vs, au as Ks, av as zs, aw as Js, ax as Qs } from "./index-ByvPQ_Xq.js";
4
4
  import { createPortal as wt } from "react-dom";
5
- import { Icon as ut, THEMES as Js, useHadokuThemeOptional as Qs } from "@wolffm/themes";
6
- import { HadokuThemePicker as qs, ConnectedSettings as Ys } from "@wolffm/task-ui-components";
7
- import { createRoot as Xs } from "react-dom/client";
8
- function Zs(t) {
5
+ import { Icon as ut, THEMES as qs, useHadokuThemeOptional as Ys } from "@wolffm/themes";
6
+ import { HadokuThemePicker as Xs, ConnectedSettings as Zs } from "@wolffm/task-ui-components";
7
+ import { createRoot as ea } from "react-dom/client";
8
+ function ta(t) {
9
9
  return t.kind === "file";
10
10
  }
11
- class Yn extends Error {
11
+ class Zn extends Error {
12
12
  constructor(e) {
13
13
  super(e), this.name = "ChatImageUploadError";
14
14
  }
@@ -33,42 +33,42 @@ function yt(t) {
33
33
  return "Image upload failed";
34
34
  }
35
35
  }
36
- function ea(t) {
37
- return t instanceof dt ? yt(t.reason) : t instanceof Yn ? t.message : "Image upload failed";
36
+ function na(t) {
37
+ return t instanceof dt ? yt(t.reason) : t instanceof Zn ? t.message : "Image upload failed";
38
38
  }
39
- function ta(t) {
39
+ function ra(t) {
40
40
  const e = t.type.toLowerCase().split(";")[0].trim();
41
- return e && Xr(e) !== "image" ? yt("unsupported-type") : t.size > Zr.image ? yt("too-large") : t.size === 0 ? yt("invalid") : null;
41
+ return e && es(e) !== "image" ? yt("unsupported-type") : t.size > ts.image ? yt("too-large") : t.size === 0 ? yt("invalid") : null;
42
42
  }
43
- function na(t) {
44
- return ts(t);
43
+ function sa(t) {
44
+ return rs(t);
45
45
  }
46
- function ra(t) {
47
- return ns(t);
46
+ function aa(t) {
47
+ return ss(t);
48
48
  }
49
- async function sa(t) {
50
- const e = await es(t);
49
+ async function ia(t) {
50
+ const e = await ns(t);
51
51
  return { w: e?.width ?? 0, h: e?.height ?? 0 };
52
52
  }
53
- async function aa(t, e = {}) {
53
+ async function oa(t, e = {}) {
54
54
  const n = await Jt().upload(t, { signal: e.signal });
55
- if (!rs(n.key))
56
- throw new Yn("Image upload returned an unusable key");
55
+ if (!as(n.key))
56
+ throw new Zn("Image upload returned an unusable key");
57
57
  return { key: n.key, deduplicated: n.deduplicated === !0 };
58
58
  }
59
- async function ia(t, e = {}) {
59
+ async function ca(t, e = {}) {
60
60
  const n = [];
61
61
  for (const r of t) {
62
62
  if (r.kind === "remote") {
63
63
  n.push({ key: r.key, w: r.w, h: r.h, ...r.title ? { title: r.title } : {} });
64
64
  continue;
65
65
  }
66
- const { key: s } = await aa(r.file, e);
66
+ const { key: s } = await oa(r.file, e);
67
67
  n.push({ key: s, w: r.w, h: r.h });
68
68
  }
69
69
  return n;
70
70
  }
71
- function oa(t) {
71
+ function la(t) {
72
72
  return {
73
73
  error: t instanceof Error ? t.message : String(t),
74
74
  name: t instanceof Error ? t.name : typeof t,
@@ -76,14 +76,14 @@ function oa(t) {
76
76
  status: t instanceof dt ? t.status : void 0
77
77
  };
78
78
  }
79
- function ca(t) {
79
+ function da(t) {
80
80
  const e = P(t);
81
81
  return L(() => {
82
82
  e.current = t;
83
83
  }), [e, `${t.cdnBase}|${t.uploadPath}`];
84
84
  }
85
- function la(t, e, n, r = {}) {
86
- const { limit: s, debounceMs: i = ss } = r, [a, l] = ca(t), [o, c] = $([]), [u, f] = $(null), [p, v] = $(!1), [g, h] = $(null), [y, w] = $(0), A = P(null);
85
+ function ua(t, e, n, r = {}) {
86
+ const { limit: s, debounceMs: i = is } = r, [a, l] = da(t), [o, c] = $([]), [u, f] = $(null), [p, v] = $(!1), [g, h] = $(null), [y, w] = $(0), A = P(null);
87
87
  L(() => {
88
88
  w(0), f(null);
89
89
  }, [n, e]), L(() => {
@@ -127,19 +127,19 @@ function la(t, e, n, r = {}) {
127
127
  }, [p, u]);
128
128
  return { items: o, loading: p, error: g, hasMore: u !== null, loadMore: F };
129
129
  }
130
- const Gt = 240, je = 8, da = 28, Xn = 240;
131
- function ua(t, e, n) {
130
+ const Gt = 240, je = 8, fa = 28, er = 240;
131
+ function ha(t, e, n) {
132
132
  let r = e.left - Gt - je;
133
133
  r < je && (r = e.right + je), r = Math.min(r, n.width - Gt - je), r = Math.max(je, r);
134
- const s = Xn + da;
134
+ const s = er + fa;
135
135
  let i = t.top + t.height / 2 - s / 2;
136
136
  return i = Math.min(i, n.height - s - je), i = Math.max(je, i), { left: r, top: i };
137
137
  }
138
- const Zn = "/dataplatform/api/memes", fa = 120;
139
- function ha({ onClose: t, onPick: e, onUnavailable: n }) {
140
- const [r, s] = $(""), i = P(null), a = P(null), l = Jt(), { items: o, loading: c, error: u, hasMore: f, loadMore: p } = la(
138
+ const tr = "/dataplatform/api/memes", pa = 120;
139
+ function ma({ onClose: t, onPick: e, onUnavailable: n }) {
140
+ const [r, s] = $(""), i = P(null), a = P(null), l = Jt(), { items: o, loading: c, error: u, hasMore: f, loadMore: p } = ua(
141
141
  l,
142
- Zn,
142
+ tr,
143
143
  r.trim()
144
144
  ), v = u?.reason ?? null, g = Ee(() => {
145
145
  const b = /* @__PURE__ */ new Set();
@@ -150,16 +150,16 @@ function ha({ onClose: t, onPick: e, onUnavailable: n }) {
150
150
  A(), y(null);
151
151
  }, [A]), k = typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(hover: hover)").matches, m = U(
152
152
  (b, S, I = !1) => {
153
- const D = i.current;
154
- if (!D) return;
153
+ const B = i.current;
154
+ if (!B) return;
155
155
  const H = () => y({
156
156
  item: b,
157
- ...ua(S.getBoundingClientRect(), D.getBoundingClientRect(), {
157
+ ...ha(S.getBoundingClientRect(), B.getBoundingClientRect(), {
158
158
  width: window.innerWidth,
159
159
  height: window.innerHeight
160
160
  })
161
161
  });
162
- A(), I ? H() : w.current = window.setTimeout(H, fa);
162
+ A(), I ? H() : w.current = window.setTimeout(H, pa);
163
163
  },
164
164
  [A]
165
165
  );
@@ -288,7 +288,7 @@ function ha({ onClose: t, onPick: e, onUnavailable: n }) {
288
288
  src: vt(h.item.key) ?? void 0,
289
289
  alt: "",
290
290
  className: "block w-full rounded bg-bg object-contain",
291
- style: { height: "auto", maxHeight: Xn }
291
+ style: { height: "auto", maxHeight: er }
292
292
  }
293
293
  ),
294
294
  h.item.title && /* One line. A long title must not change the box height, because
@@ -301,23 +301,23 @@ function ha({ onClose: t, onPick: e, onUnavailable: n }) {
301
301
  }
302
302
  );
303
303
  }
304
- function er({ open: t, ...e }) {
305
- return t ? /* @__PURE__ */ d(ha, { ...e }) : null;
304
+ function nr({ open: t, ...e }) {
305
+ return t ? /* @__PURE__ */ d(ma, { ...e }) : null;
306
306
  }
307
- function pa(t) {
307
+ function ga(t) {
308
308
  return typeof t == "object" && t !== null && typeof t.mount == "function";
309
309
  }
310
- function ma(t) {
310
+ function ba(t) {
311
311
  if (typeof t != "object" || t === null)
312
312
  return !1;
313
313
  const e = t;
314
314
  return typeof e.unmount == "function" && typeof e.update == "function" && (e.mountSettings === void 0 || typeof e.mountSettings == "function");
315
315
  }
316
316
  const Wt = "watchparty:open-media-drawer";
317
- function tr(t) {
317
+ function rr(t) {
318
318
  E("navigation", `Select Media clicked (${t})`), window.dispatchEvent(new CustomEvent(Wt));
319
319
  }
320
- class nr extends qr {
320
+ class sr extends Xr {
321
321
  state = { hasError: !1 };
322
322
  static getDerivedStateFromError() {
323
323
  return { hasError: !0 };
@@ -354,42 +354,42 @@ function Yt(t) {
354
354
  function Xt(t) {
355
355
  return t.isLeader ? Yt(t) ? t.gameOverlay && !t.isFullscreen ? "room-corner" : "control-bar" : "chat-toolbar" : "none";
356
356
  }
357
- function rr(t) {
357
+ function ar(t) {
358
358
  return t.hasMedia ? t.gameOverlay && !t.isFullscreen ? "room-corner" : "control-bar" : "none";
359
359
  }
360
- function sr(t, e) {
360
+ function ir(t, e) {
361
361
  if (e) {
362
362
  for (const n of Object.values(t))
363
363
  if (n.author === e && n.avatarUrl) return n.avatarUrl;
364
364
  }
365
365
  }
366
- const ga = Bn(!0);
367
- function ar() {
368
- const t = Pn(ga);
366
+ const ya = On(!0);
367
+ function or() {
368
+ const t = Bn(ya);
369
369
  L(() => {
370
- t && as();
370
+ t && os();
371
371
  }, [t]);
372
372
  }
373
- function ba(t, e) {
373
+ function va(t, e) {
374
374
  if (!e) return "";
375
375
  for (const n of Object.values(t))
376
376
  if (n.author === e && n.cosmetics) return JSON.stringify(n.cosmetics);
377
377
  return "";
378
378
  }
379
- function ir(t) {
380
- const e = x((n) => ba(n.roster, t));
379
+ function cr(t) {
380
+ const e = x((n) => va(n.roster, t));
381
381
  return Ee(() => e ? JSON.parse(e) : void 0, [e]);
382
382
  }
383
- function or(t) {
383
+ function lr(t) {
384
384
  return t ? { "--hc-base": t } : {};
385
385
  }
386
- const ft = Ke.memo(
386
+ const ft = Ve.memo(
387
387
  function({ html: e, as: n = "span", className: r, style: s }) {
388
- return Ke.createElement(n, { className: r, style: s, dangerouslySetInnerHTML: { __html: e } });
388
+ return Ve.createElement(n, { className: r, style: s, dangerouslySetInnerHTML: { __html: e } });
389
389
  },
390
390
  (t, e) => t.html === e.html && t.as === e.as && t.className === e.className && JSON.stringify(t.style) === JSON.stringify(e.style)
391
391
  );
392
- function ya(t, e) {
392
+ function Sa(t, e) {
393
393
  L(() => {
394
394
  const n = t.current;
395
395
  if (!n || !e || typeof IntersectionObserver > "u") return;
@@ -401,7 +401,7 @@ function ya(t, e) {
401
401
  };
402
402
  }, [t, e]);
403
403
  }
404
- function cr({ sprite: t, url: e, alt: n, worn: r }) {
404
+ function dr({ sprite: t, url: e, alt: n, worn: r }) {
405
405
  return /* @__PURE__ */ _("span", { className: "hc-av", style: { "--hc-sz": "32px" }, children: [
406
406
  /* @__PURE__ */ d("span", { className: "hc-pic", children: /* @__PURE__ */ d(
407
407
  pt,
@@ -413,24 +413,24 @@ function cr({ sprite: t, url: e, alt: n, worn: r }) {
413
413
  fallback: /* @__PURE__ */ d("span", { className: "inline-block w-8 h-8 bg-bg-alt/50 rounded-full flex-shrink-0" })
414
414
  }
415
415
  ) }),
416
- r?.overlay && /* @__PURE__ */ d(ft, { html: is(r), style: { display: "contents" } })
416
+ r?.overlay && /* @__PURE__ */ d(ft, { html: cs(r), style: { display: "contents" } })
417
417
  ] });
418
418
  }
419
- function va(t) {
419
+ function wa(t) {
420
420
  return !(t.button !== 0 || t.ctrlKey || t.metaKey || t.shiftKey || t.altKey);
421
421
  }
422
- const Sa = Bn(null);
423
- function wa() {
424
- return Pn(Sa);
422
+ const xa = On(null);
423
+ function Ea() {
424
+ return Bn(xa);
425
425
  }
426
- function xa({ src: t, title: e, onClose: n }) {
426
+ function Ma({ src: t, title: e, onClose: n }) {
427
427
  L(() => {
428
428
  const i = (a) => {
429
429
  a.key === "Escape" && (a.stopPropagation(), n());
430
430
  };
431
431
  return document.addEventListener("keydown", i, !0), () => document.removeEventListener("keydown", i, !0);
432
432
  }, [n]);
433
- const r = wa(), s = typeof document > "u" ? null : document.fullscreenElement ?? r ?? document.body;
433
+ const r = Ea(), s = typeof document > "u" ? null : document.fullscreenElement ?? r ?? document.body;
434
434
  return s ? wt(
435
435
  /* @__PURE__ */ _(
436
436
  "div",
@@ -469,11 +469,11 @@ function xa({ src: t, title: e, onClose: n }) {
469
469
  s
470
470
  ) : null;
471
471
  }
472
- const It = 240, Ea = 320;
473
- function Ma({ image: t }) {
472
+ const It = 240, ka = 320;
473
+ function _a({ image: t }) {
474
474
  const [e, n] = $(!1), r = vt(t.key);
475
475
  if (!r) return null;
476
- const s = t.w > 0 && t.h > 0, i = s ? Math.min(1, Ea / t.w, It / t.h) : 1;
476
+ const s = t.w > 0 && t.h > 0, i = s ? Math.min(1, ka / t.w, It / t.h) : 1;
477
477
  return /* @__PURE__ */ _(Se, { children: [
478
478
  /* @__PURE__ */ d(
479
479
  "a",
@@ -484,7 +484,7 @@ function Ma({ image: t }) {
484
484
  className: "block max-w-full cursor-zoom-in",
485
485
  "data-testid": "chat-image",
486
486
  onClick: (a) => {
487
- va(a) && (a.preventDefault(), n(!0));
487
+ wa(a) && (a.preventDefault(), n(!0));
488
488
  },
489
489
  children: /* @__PURE__ */ d(
490
490
  "img",
@@ -502,7 +502,7 @@ function Ma({ image: t }) {
502
502
  }
503
503
  ),
504
504
  e && /* @__PURE__ */ d(
505
- xa,
505
+ Ma,
506
506
  {
507
507
  src: r,
508
508
  title: t.title,
@@ -511,20 +511,20 @@ function Ma({ image: t }) {
511
511
  )
512
512
  ] });
513
513
  }
514
- function lr({ images: t }) {
515
- return t?.length ? /* @__PURE__ */ d("div", { className: "flex flex-wrap gap-1 mt-1", "data-testid": "chat-images", children: t.map((e, n) => /* @__PURE__ */ d(Ma, { image: e }, `${e.key}-${n}`)) }) : null;
514
+ function ur({ images: t }) {
515
+ return t?.length ? /* @__PURE__ */ d("div", { className: "flex flex-wrap gap-1 mt-1", "data-testid": "chat-images", children: t.map((e, n) => /* @__PURE__ */ d(_a, { image: e }, `${e.key}-${n}`)) }) : null;
516
516
  }
517
- function ka(t, e) {
517
+ function Aa(t, e) {
518
518
  return t.author && e.author ? t.author === e.author : !!e.clientId && t.clientId === e.clientId;
519
519
  }
520
520
  function Ct(t) {
521
521
  return new Date(t).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
522
522
  }
523
- const _a = Ke.memo(function({ message: e }) {
524
- const n = x((u) => u.me.clientId), r = x((u) => u.me.clientId ? u.roster[u.me.clientId]?.author : void 0), s = ka(e, { clientId: n, author: r }), i = x((u) => sr(u.roster, e.author)), a = tt(e.sprite, i), l = ir(e.isSystem ? void 0 : e.author), o = P(null);
525
- ya(o, !!l);
523
+ const Ta = Ve.memo(function({ message: e }) {
524
+ const n = x((u) => u.me.clientId), r = x((u) => u.me.clientId ? u.roster[u.me.clientId]?.author : void 0), s = Aa(e, { clientId: n, author: r }), i = x((u) => ir(u.roster, e.author)), a = tt(e.sprite, i), l = cr(e.isSystem ? void 0 : e.author), o = P(null);
525
+ Sa(o, !!l);
526
526
  const [c] = $(
527
- () => e.live && e.text ? Dn(e.text, l) : null
527
+ () => e.live && e.text ? Hn(e.text, l) : null
528
528
  );
529
529
  return e.isSystem && e.systemType === "recap" ? /* @__PURE__ */ d("div", { className: "px-2 py-1.5", children: /* @__PURE__ */ _("div", { className: "border-l-2 border-border-light pl-2.5 py-0.5", children: [
530
530
  /* @__PURE__ */ _("div", { className: "text-[10px] uppercase tracking-wide text-text-muted mb-0.5", children: [
@@ -535,18 +535,18 @@ const _a = Ke.memo(function({ message: e }) {
535
535
  ] }) }) : e.isSystem ? /* @__PURE__ */ _("div", { className: "px-2 py-0.5 text-[11px] text-text-muted italic text-center leading-tight", children: [
536
536
  e.text,
537
537
  /* @__PURE__ */ d("span", { className: "ml-1 text-[10px] opacity-50", children: Ct(e.ts) })
538
- ] }) : /* @__PURE__ */ _("div", { ref: o, style: or(a), className: `flex items-start gap-2 px-2 py-1 hover:bg-bg-card/20 ${s ? "bg-bg-card/30" : ""}`, children: [
539
- /* @__PURE__ */ d(cr, { sprite: e.sprite, url: i, alt: e.name, worn: l }),
538
+ ] }) : /* @__PURE__ */ _("div", { ref: o, style: lr(a), className: `flex items-start gap-2 px-2 py-1 hover:bg-bg-card/20 ${s ? "bg-bg-card/30" : ""}`, children: [
539
+ /* @__PURE__ */ d(dr, { sprite: e.sprite, url: i, alt: e.name, worn: l }),
540
540
  /* @__PURE__ */ _("div", { className: "flex-1 min-w-0 -mt-0.5", children: [
541
- l ? /* @__PURE__ */ d(ft, { html: On(e.name, l), className: "text-[13px]", style: { color: a } }) : /* @__PURE__ */ d("span", { className: "font-medium text-[13px]", style: { color: a }, children: e.name }),
541
+ l ? /* @__PURE__ */ d(ft, { html: Un(e.name, l), className: "text-[13px]", style: { color: a } }) : /* @__PURE__ */ d("span", { className: "font-medium text-[13px]", style: { color: a }, children: e.name }),
542
542
  /* @__PURE__ */ d("span", { className: "text-[10px] text-text-muted opacity-60 ml-1.5", children: Ct(e.ts) }),
543
543
  e.text && (c ? /* @__PURE__ */ d(ft, { as: "p", html: c, className: "text-[13px] text-text break-words leading-snug m-0" }) : /* @__PURE__ */ d("p", { className: "text-[13px] text-text break-words leading-snug m-0", children: e.text })),
544
- /* @__PURE__ */ d(lr, { images: e.images })
544
+ /* @__PURE__ */ d(ur, { images: e.images })
545
545
  ] })
546
546
  ] });
547
547
  });
548
- function Aa() {
549
- ar();
548
+ function Ia() {
549
+ or();
550
550
  const t = x((s) => s.chat), e = P(null), n = P(!1), r = U(() => {
551
551
  const s = e.current;
552
552
  if (!s) return;
@@ -564,13 +564,13 @@ function Aa() {
564
564
  className: "flex-1 overflow-y-auto overflow-x-hidden chat-messages",
565
565
  children: t.length === 0 ? /* @__PURE__ */ d("div", { className: "p-4 text-xs text-text-muted text-center", children: "No messages yet. Be the first to say something!" }) : /* @__PURE__ */ d(Se, { children: t.map((s, i) => {
566
566
  const a = i > 0 ? t[i - 1] : null, l = a && s.ts - a.ts > 1440 * 60 * 1e3;
567
- return /* @__PURE__ */ _(Ke.Fragment, { children: [
567
+ return /* @__PURE__ */ _(Ve.Fragment, { children: [
568
568
  l && /* @__PURE__ */ _("div", { className: "flex items-center gap-2 px-4 py-2 my-1", children: [
569
569
  /* @__PURE__ */ d("div", { className: "flex-1 h-px bg-border" }),
570
570
  /* @__PURE__ */ d("span", { className: "text-[10px] text-text-muted whitespace-nowrap", children: new Date(s.ts).toLocaleDateString([], { weekday: "short", month: "short", day: "numeric" }) }),
571
571
  /* @__PURE__ */ d("div", { className: "flex-1 h-px bg-border" })
572
572
  ] }),
573
- /* @__PURE__ */ d(_a, { message: s })
573
+ /* @__PURE__ */ d(Ta, { message: s })
574
574
  ] }, s.id);
575
575
  }) })
576
576
  }
@@ -597,12 +597,12 @@ const Zt = [
597
597
  scope: "local"
598
598
  }
599
599
  ], et = "/";
600
- function Ta(t) {
600
+ function Ca(t) {
601
601
  if (!t.startsWith(et)) return null;
602
602
  const e = t.slice(et.length);
603
603
  return /\s/.test(e) ? null : e.toLowerCase();
604
604
  }
605
- function Ia(t, e = Zt) {
605
+ function Ra(t, e = Zt) {
606
606
  const n = t.toLowerCase();
607
607
  if (!n) return [...e].sort((s, i) => s.name.localeCompare(i.name));
608
608
  const r = [];
@@ -612,23 +612,23 @@ function Ia(t, e = Zt) {
612
612
  }
613
613
  return r.sort((s, i) => s.rank - i.rank || s.cmd.name.localeCompare(i.cmd.name)).map((s) => s.cmd);
614
614
  }
615
- function Ca(t) {
615
+ function Fa(t) {
616
616
  return `${et}${t.name} `;
617
617
  }
618
618
  function Rt(t, e) {
619
619
  return e <= 0 ? 0 : (t % e + e) % e;
620
620
  }
621
- function Ra(t, e = Zt) {
621
+ function Na(t, e = Zt) {
622
622
  const n = t.trim();
623
623
  if (!n) return null;
624
624
  if (!n.startsWith(et)) return { kind: "chat", text: n };
625
625
  const r = n.slice(et.length), s = r.search(/\s/), i = (s === -1 ? r : r.slice(0, s)).toLowerCase(), a = s === -1 ? "" : r.slice(s).trim(), l = e.find((o) => o.name.toLowerCase() === i);
626
626
  return l ? { kind: "command", command: l, args: a } : { kind: "chat", text: n };
627
627
  }
628
- function Fa(t, e) {
628
+ function La(t, e) {
629
629
  return t.requiresMedia && !e.hasMedia ? `${et}${t.name} needs an episode loaded.` : null;
630
630
  }
631
- function Na({
631
+ function $a({
632
632
  commands: t,
633
633
  activeIndex: e,
634
634
  hasMedia: n,
@@ -670,7 +670,7 @@ function Na({
670
670
  }
671
671
  );
672
672
  }
673
- function dr({
673
+ function fr({
674
674
  pending: t,
675
675
  uploading: e,
676
676
  onRemove: n
@@ -697,24 +697,24 @@ function dr({
697
697
  )
698
698
  ] }, r.id)) }) : null;
699
699
  }
700
- function ur() {
700
+ function hr() {
701
701
  const [t, e] = $([]), [n, r] = $(!1), s = x((h) => h.pushToast), i = P(/* @__PURE__ */ new Set());
702
702
  L(() => () => {
703
703
  for (const h of i.current) URL.revokeObjectURL(h);
704
704
  i.current.clear();
705
705
  }, []);
706
706
  const a = U((h) => {
707
- Zs(h) && (URL.revokeObjectURL(h.previewUrl), i.current.delete(h.previewUrl));
707
+ ta(h) && (URL.revokeObjectURL(h.previewUrl), i.current.delete(h.previewUrl));
708
708
  }, []), l = U(async (h) => {
709
709
  if (!h.length) return;
710
710
  const y = [];
711
711
  for (const w of h) {
712
- const A = ta(w);
712
+ const A = ra(w);
713
713
  if (A) {
714
714
  s("error", A);
715
715
  continue;
716
716
  }
717
- const { w: F, h: k } = await sa(w), m = URL.createObjectURL(w);
717
+ const { w: F, h: k } = await ia(w), m = URL.createObjectURL(w);
718
718
  i.current.add(m), y.push({
719
719
  kind: "file",
720
720
  id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
@@ -749,7 +749,7 @@ function ur() {
749
749
  w: h.width ?? 0,
750
750
  h: h.height ?? 0,
751
751
  title: h.title || void 0
752
- }]), Jt().catalogue(Zn).recordUse(h.key));
752
+ }]), Jt().catalogue(tr).recordUse(h.key));
753
753
  }, [s]), c = U((h) => {
754
754
  e((y) => {
755
755
  const w = y.find((A) => A.id === h);
@@ -761,10 +761,10 @@ function ur() {
761
761
  return [];
762
762
  });
763
763
  }, [a]), f = U((h) => {
764
- const y = na(h.clipboardData);
764
+ const y = sa(h.clipboardData);
765
765
  y.length && (h.preventDefault(), l(y));
766
766
  }, [l]), p = U((h) => {
767
- const y = ra(h.dataTransfer);
767
+ const y = aa(h.dataTransfer);
768
768
  y.length && (h.preventDefault(), l(y));
769
769
  }, [l]), v = U((h) => {
770
770
  h.dataTransfer?.types?.includes("Files") && h.preventDefault();
@@ -772,9 +772,9 @@ function ur() {
772
772
  if (!t.length) return [];
773
773
  r(!0);
774
774
  try {
775
- return await ia(t);
775
+ return await ca(t);
776
776
  } catch (h) {
777
- return C("chat", "Image upload failed", oa(h)), s("error", ea(h)), null;
777
+ return C("chat", "Image upload failed", la(h)), s("error", na(h)), null;
778
778
  } finally {
779
779
  r(!1);
780
780
  }
@@ -792,16 +792,16 @@ function ur() {
792
792
  onDragOver: v
793
793
  };
794
794
  }
795
- const yn = jn, La = Un;
796
- function $a({ commands: t = Zt }) {
797
- const [e, n] = $(""), [r, s] = $(!1), [i, a] = $({ q: null, i: 0 }), [l, o] = $(!1), c = P(null), u = Yr(), [f, p] = $(!1), [v, g] = $(!1), h = ur(), y = x((N) => N.snapshot.mediaId), w = x((N) => N.pushToast), A = x((N) => N.setTierlistOpen), F = !!y, k = Ta(e), m = Ee(
798
- () => k === null ? [] : Ia(k, t),
795
+ const yn = Wn, Pa = Gn;
796
+ function Da({ commands: t = Zt }) {
797
+ const [e, n] = $(""), [r, s] = $(!1), [i, a] = $({ q: null, i: 0 }), [l, o] = $(!1), c = P(null), u = Zr(), [f, p] = $(!1), [v, g] = $(!1), h = hr(), y = x((N) => N.snapshot.mediaId), w = x((N) => N.pushToast), A = x((N) => N.setTierlistOpen), F = !!y, k = Ca(e), m = Ee(
798
+ () => k === null ? [] : Ra(k, t),
799
799
  [k, t]
800
800
  ), T = k !== null && !l && m.length > 0, R = i.q === k ? Rt(i.i, m.length) : 0, b = U(
801
801
  (N) => a({ q: k, i: N }),
802
802
  [k]
803
803
  ), S = U((N, O) => {
804
- const Q = Fa(N, { hasMedia: F });
804
+ const Q = La(N, { hasMedia: F });
805
805
  if (Q) {
806
806
  w("info", Q);
807
807
  return;
@@ -811,19 +811,19 @@ function $a({ commands: t = Zt }) {
811
811
  w("info", t.map((W) => W.usage).join(" "));
812
812
  break;
813
813
  case "recap":
814
- cs();
814
+ ds();
815
815
  break;
816
816
  case "tierlist":
817
- os(), A(!0);
817
+ ls(), A(!0);
818
818
  break;
819
819
  default:
820
820
  w("info", `${N.usage} is not implemented yet.`);
821
821
  }
822
822
  }, [F, w, t, A]), I = U((N) => {
823
- n(Ca(N)), o(!1), c.current?.focus();
824
- }, []), D = U(async (N) => {
823
+ n(Fa(N)), o(!1), c.current?.focus();
824
+ }, []), B = U(async (N) => {
825
825
  if (N.preventDefault(), r || h.uploading) return;
826
- const O = Ra(e, t);
826
+ const O = Na(e, t);
827
827
  if (!O && !h.pending.length) return;
828
828
  if (O?.kind === "command" && h.pending.length) {
829
829
  w("info", "Send images on their own, not with a command.");
@@ -834,7 +834,7 @@ function $a({ commands: t = Zt }) {
834
834
  return;
835
835
  }
836
836
  const Q = await h.uploadPending();
837
- Q !== null && (Hn(O?.text ?? "", Q), n(""), h.clear(), s(!0), setTimeout(() => s(!1), La), !document.hidden && document.hasFocus() && c.current?.focus());
837
+ Q !== null && (jn(O?.text ?? "", Q), n(""), h.clear(), s(!0), setTimeout(() => s(!1), Pa), !document.hidden && document.hasFocus() && c.current?.focus());
838
838
  }, [e, r, S, h, w, t]), H = U((N) => {
839
839
  if (N.key === "Escape" && T) {
840
840
  N.preventDefault(), o(!0);
@@ -862,22 +862,22 @@ function $a({ commands: t = Zt }) {
862
862
  };
863
863
  return window.addEventListener("watchparty:focus-chat-input", N), () => window.removeEventListener("watchparty:focus-chat-input", N);
864
864
  }, []);
865
- const j = yn - e.length, V = j <= 100, X = T ? m[R] : void 0;
865
+ const j = yn - e.length, K = j <= 100, X = T ? m[R] : void 0;
866
866
  return /* @__PURE__ */ _(
867
867
  "form",
868
868
  {
869
869
  onSubmit: (N) => {
870
- D(N);
870
+ B(N);
871
871
  },
872
872
  onPaste: h.onPaste,
873
873
  onDrop: h.onDrop,
874
874
  onDragOver: h.onDragOver,
875
875
  className: "p-2 border-t border-border",
876
876
  children: [
877
- /* @__PURE__ */ d(dr, { pending: h.pending, uploading: h.uploading, onRemove: h.remove }),
877
+ /* @__PURE__ */ d(fr, { pending: h.pending, uploading: h.uploading, onRemove: h.remove }),
878
878
  /* @__PURE__ */ _("div", { className: "relative", children: [
879
879
  T && /* @__PURE__ */ d(
880
- Na,
880
+ $a,
881
881
  {
882
882
  commands: m,
883
883
  activeIndex: R,
@@ -888,7 +888,7 @@ function $a({ commands: t = Zt }) {
888
888
  }
889
889
  ),
890
890
  /* @__PURE__ */ d(
891
- er,
891
+ nr,
892
892
  {
893
893
  open: f,
894
894
  onClose: () => p(!1),
@@ -917,10 +917,10 @@ function $a({ commands: t = Zt }) {
917
917
  "aria-controls": T ? u : void 0,
918
918
  "aria-activedescendant": X ? `${u}-opt-${X.name}` : void 0,
919
919
  "aria-autocomplete": "list",
920
- className: `w-full bg-bg-card border border-border-light rounded px-3 py-1.5 text-sm focus:outline-none focus:border-text-muted ${V ? "pr-12" : ""}`
920
+ className: `w-full bg-bg-card border border-border-light rounded px-3 py-1.5 text-sm focus:outline-none focus:border-text-muted ${K ? "pr-12" : ""}`
921
921
  }
922
922
  ),
923
- /* @__PURE__ */ d("span", { className: `absolute right-2 top-1/2 -translate-y-1/2 text-[10px] ${j <= 50 ? j <= 0 ? "bg-danger-bg text-on-danger-bg px-1 rounded" : "bg-primary-bg text-on-primary-bg px-1 rounded" : "text-text-muted"}`, children: V && j })
923
+ /* @__PURE__ */ d("span", { className: `absolute right-2 top-1/2 -translate-y-1/2 text-[10px] ${j <= 50 ? j <= 0 ? "bg-danger-bg text-on-danger-bg px-1 rounded" : "bg-primary-bg text-on-primary-bg px-1 rounded" : "text-text-muted"}`, children: K && j })
924
924
  ] }),
925
925
  !v && /* @__PURE__ */ d(
926
926
  "button",
@@ -941,11 +941,11 @@ function $a({ commands: t = Zt }) {
941
941
  }
942
942
  );
943
943
  }
944
- function Pa() {
944
+ function Ba() {
945
945
  const t = x((n) => n.roster), e = Object.values(t);
946
- return e.length ? /* @__PURE__ */ d("div", { className: "flex flex-col gap-1", children: e.map((n) => /* @__PURE__ */ d(Ba, { u: n }, n.clientId)) }) : /* @__PURE__ */ d("div", { className: "text-xs text-text-muted", children: "No users online" });
946
+ return e.length ? /* @__PURE__ */ d("div", { className: "flex flex-col gap-1", children: e.map((n) => /* @__PURE__ */ d(Oa, { u: n }, n.clientId)) }) : /* @__PURE__ */ d("div", { className: "text-xs text-text-muted", children: "No users online" });
947
947
  }
948
- function Ba({ u: t }) {
948
+ function Oa({ u: t }) {
949
949
  const e = tt(t.sprite, t.avatarUrl);
950
950
  return /* @__PURE__ */ _("div", { className: "flex items-center gap-2 py-0.5", children: [
951
951
  /* @__PURE__ */ d(
@@ -962,7 +962,7 @@ function Ba({ u: t }) {
962
962
  t.isLeader && /* @__PURE__ */ d("span", { className: "ml-auto px-1.5 py-0.5 rounded text-[9px] font-medium bg-success/20 text-success", children: "Leader" })
963
963
  ] });
964
964
  }
965
- function Da() {
965
+ function Ha() {
966
966
  const t = x((s) => Object.keys(s.roster).length), [e, n] = $(!1), r = P(null);
967
967
  return L(() => {
968
968
  if (!e) return;
@@ -990,20 +990,20 @@ function Da() {
990
990
  t,
991
991
  " online"
992
992
  ] }),
993
- /* @__PURE__ */ d(Pa, {})
993
+ /* @__PURE__ */ d(Ba, {})
994
994
  ] })
995
995
  ] });
996
996
  }
997
- function Oa({ leaderId: t, clientId: e, keyType: n }) {
997
+ function Ua({ leaderId: t, clientId: e, keyType: n }) {
998
998
  return t !== null ? t === e : n === "leader";
999
999
  }
1000
- const Ha = /-[0-9a-fA-F]{16}$/;
1001
- function Ua(t) {
1002
- return t && Ha.test(t) ? "leader" : null;
1003
- }
1004
- const ja = /\/room\/([^/]+)\/?$/;
1000
+ const ja = /-[0-9a-fA-F]{16}$/;
1005
1001
  function Ga(t) {
1006
- const e = t ? ja.exec(t) : null;
1002
+ return t && ja.test(t) ? "leader" : null;
1003
+ }
1004
+ const Wa = /\/room\/([^/]+)\/?$/;
1005
+ function Va(t) {
1006
+ const e = t ? Wa.exec(t) : null;
1007
1007
  if (!e) return null;
1008
1008
  try {
1009
1009
  return decodeURIComponent(e[1]);
@@ -1011,39 +1011,39 @@ function Ga(t) {
1011
1011
  return e[1];
1012
1012
  }
1013
1013
  }
1014
- function Wa(t, e) {
1015
- return t && e?.roomKey === t ? e.type : Ua(t);
1014
+ function Ka(t, e) {
1015
+ return t && e?.roomKey === t ? e.type : Ga(t);
1016
1016
  }
1017
1017
  function nt() {
1018
1018
  return x((t) => !!t.snapshot.leaderId && t.snapshot.leaderId === t.me.clientId);
1019
1019
  }
1020
1020
  function Et() {
1021
- const t = x((n) => n.activeGameId), e = ls();
1021
+ const t = x((n) => n.activeGameId), e = us();
1022
1022
  return t ? e.find((n) => n.id === t) ?? null : null;
1023
1023
  }
1024
1024
  function en() {
1025
- return x((t) => Oa({
1025
+ return x((t) => Ua({
1026
1026
  leaderId: t.snapshot.leaderId,
1027
1027
  clientId: t.me.clientId,
1028
- keyType: Wa(Ga(globalThis.location?.pathname), t.roomKeyType)
1028
+ keyType: Ka(Va(globalThis.location?.pathname), t.roomKeyType)
1029
1029
  }));
1030
1030
  }
1031
- function fr() {
1031
+ function pr() {
1032
1032
  return x((t) => t.readiness);
1033
1033
  }
1034
- function Ka() {
1034
+ function za() {
1035
1035
  return x((t) => t.snapshot);
1036
1036
  }
1037
- const Va = 3e4;
1038
- function hr() {
1039
- const t = fr(), [e, n] = $(!1), [r, s] = $({ mediaId: t.mediaId, ready: t.ready });
1037
+ const Ja = 3e4;
1038
+ function mr() {
1039
+ const t = pr(), [e, n] = $(!1), [r, s] = $({ mediaId: t.mediaId, ready: t.ready });
1040
1040
  return (r.mediaId !== t.mediaId || r.ready !== t.ready) && (s({ mediaId: t.mediaId, ready: t.ready }), n(!1)), L(() => {
1041
1041
  if (t.ready) return;
1042
- const i = setTimeout(() => n(!0), Va);
1042
+ const i = setTimeout(() => n(!0), Ja);
1043
1043
  return () => clearTimeout(i);
1044
1044
  }, [t.mediaId, t.ready]), e;
1045
1045
  }
1046
- function za({ draw: t }) {
1046
+ function Qa({ draw: t }) {
1047
1047
  const e = P(null);
1048
1048
  return L(() => {
1049
1049
  const n = e.current;
@@ -1051,8 +1051,8 @@ function za({ draw: t }) {
1051
1051
  return t(n) ?? void 0;
1052
1052
  }, [t]), /* @__PURE__ */ d("div", { ref: e, "data-testid": "game-settings" });
1053
1053
  }
1054
- const Ja = Qt(() => import("./AdminPanel-CqJPu1ee.js")), Qa = Qt(() => import("./PlaylistPanel-Ck8PUq7r.js"));
1055
- function qa() {
1054
+ const qa = Qt(() => import("./AdminPanel-D3hirjtp.js")), Ya = Qt(() => import("./PlaylistPanel-DBl44brn.js"));
1055
+ function Xa() {
1056
1056
  const t = x((p) => p.chatCollapsed), e = xt(), n = x((p) => p.sidebarTab), r = x((p) => p.setSidebarTab), s = x((p) => p.healthSnapshot?.clients.length ?? 0), i = x((p) => !!p.playlist), a = nt(), l = en(), o = x((p) => p.gameSettings), c = x((p) => p.snapshot.mediaId), u = Et() !== null;
1057
1057
  if (Yt({ hasMedia: !!c, chatCollapsed: t, isFullscreen: e }))
1058
1058
  return null;
@@ -1060,14 +1060,14 @@ function qa() {
1060
1060
  return /* @__PURE__ */ _("aside", { className: "w-80 self-stretch border-l border-border flex flex-col bg-bg relative z-10", children: [
1061
1061
  /* @__PURE__ */ _("div", { className: "chat-toolbar relative flex items-center gap-1 px-2 py-1.5 border-b border-border", children: [
1062
1062
  /* @__PURE__ */ d(
1063
- ds,
1063
+ fs,
1064
1064
  {
1065
1065
  to: "/",
1066
1066
  className: "p-1.5 rounded text-text-secondary hover:text-white hover:bg-bg-alt transition-colors cursor-pointer",
1067
1067
  title: "Home",
1068
1068
  "aria-label": "Home",
1069
1069
  onClick: () => {
1070
- E("navigation", "Home button clicked (chat toolbar)"), us();
1070
+ E("navigation", "Home button clicked (chat toolbar)"), hs();
1071
1071
  },
1072
1072
  children: /* @__PURE__ */ d("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" }) })
1073
1073
  }
@@ -1075,18 +1075,18 @@ function qa() {
1075
1075
  Xt({ isLeader: l, hasMedia: !!c, chatCollapsed: t, isFullscreen: e, gameOverlay: u }) === "chat-toolbar" && /* @__PURE__ */ d(
1076
1076
  "button",
1077
1077
  {
1078
- onClick: () => tr("chat toolbar"),
1078
+ onClick: () => rr("chat toolbar"),
1079
1079
  className: "p-1.5 rounded text-text-secondary hover:text-white hover:bg-bg-alt transition-colors cursor-pointer",
1080
1080
  title: "Select Media",
1081
1081
  "aria-label": "Select Media",
1082
1082
  children: /* @__PURE__ */ d("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M7 4v16M17 4v16M3 8h4m10 0h4M3 12h18M3 16h4m10 0h4M4 4h16a1 1 0 011 1v14a1 1 0 01-1 1H4a1 1 0 01-1-1V5a1 1 0 011-1z" }) })
1083
1083
  }
1084
1084
  ),
1085
- /* @__PURE__ */ d(qs, {}),
1086
- /* @__PURE__ */ d(Ys, { onNameChange: (p) => {
1087
- p && x.getState().me.clientId && fs(p);
1088
- }, children: o ? /* @__PURE__ */ d(za, { draw: o }) : null }),
1089
- /* @__PURE__ */ d(Da, {})
1085
+ /* @__PURE__ */ d(Xs, {}),
1086
+ /* @__PURE__ */ d(Zs, { onNameChange: (p) => {
1087
+ p && x.getState().me.clientId && ps(p);
1088
+ }, children: o ? /* @__PURE__ */ d(Qa, { draw: o }) : null }),
1089
+ /* @__PURE__ */ d(Ha, {})
1090
1090
  ] }),
1091
1091
  (a || i) && /* @__PURE__ */ _("div", { className: "flex border-b border-border shrink-0", children: [
1092
1092
  /* @__PURE__ */ d(
@@ -1117,30 +1117,30 @@ function qa() {
1117
1117
  }
1118
1118
  )
1119
1119
  ] }),
1120
- f === "health" ? /* @__PURE__ */ d(Ke.Suspense, { fallback: /* @__PURE__ */ d("div", { className: "p-4 text-xs text-text-muted", children: "Loading..." }), children: /* @__PURE__ */ d(Ja, {}) }) : f === "playlist" ? /* @__PURE__ */ d(Ke.Suspense, { fallback: /* @__PURE__ */ d("div", { className: "p-4 text-xs text-text-muted", children: "Loading..." }), children: /* @__PURE__ */ d(Qa, {}) }) : /* @__PURE__ */ _(Se, { children: [
1121
- /* @__PURE__ */ d(Aa, {}),
1122
- /* @__PURE__ */ d($a, {})
1120
+ f === "health" ? /* @__PURE__ */ d(Ve.Suspense, { fallback: /* @__PURE__ */ d("div", { className: "p-4 text-xs text-text-muted", children: "Loading..." }), children: /* @__PURE__ */ d(qa, {}) }) : f === "playlist" ? /* @__PURE__ */ d(Ve.Suspense, { fallback: /* @__PURE__ */ d("div", { className: "p-4 text-xs text-text-muted", children: "Loading..." }), children: /* @__PURE__ */ d(Ya, {}) }) : /* @__PURE__ */ _(Se, { children: [
1121
+ /* @__PURE__ */ d(Ia, {}),
1122
+ /* @__PURE__ */ d(Da, {})
1123
1123
  ] })
1124
1124
  ] });
1125
1125
  }
1126
- const vn = (t) => typeof t == "string" && Js.includes(t);
1127
- function Ya(t, e, n) {
1126
+ const vn = (t) => typeof t == "string" && qs.includes(t);
1127
+ function Za(t, e, n) {
1128
1128
  return vn(e) ? e : vn(n) ? n : "dark";
1129
1129
  }
1130
- function Xa(t, e) {
1131
- if (!hs(t)) return null;
1130
+ function ei(t, e) {
1131
+ if (!ms(t)) return null;
1132
1132
  const n = new URL(t, e);
1133
1133
  return n.origin === e ? n.href : null;
1134
1134
  }
1135
- function Za(t, e) {
1136
- const n = Xa(t.url, e);
1135
+ function ti(t, e) {
1136
+ const n = ei(t.url, e);
1137
1137
  return { id: t.id, name: t.name, load: n ? () => import(
1138
1138
  /* @vite-ignore */
1139
1139
  n
1140
1140
  ) : null };
1141
1141
  }
1142
1142
  const Je = (t) => t instanceof Error ? t.message : String(t);
1143
- function ei(t) {
1143
+ function ni(t) {
1144
1144
  let e = t.ctx, n = null, r = !1, s = !1;
1145
1145
  const i = /* @__PURE__ */ new Set(), a = (p, v) => t.onSettingsError?.(p, v), l = (p) => {
1146
1146
  if (i.delete(p))
@@ -1181,7 +1181,7 @@ function ei(t) {
1181
1181
  return;
1182
1182
  }
1183
1183
  if (r) return;
1184
- if (!pa(p)) {
1184
+ if (!ga(p)) {
1185
1185
  u("the game module does not export mount()");
1186
1186
  return;
1187
1187
  }
@@ -1193,7 +1193,7 @@ function ei(t) {
1193
1193
  u(`the game failed to start: ${Je(h)}`, h);
1194
1194
  return;
1195
1195
  }
1196
- if (!ma(g)) {
1196
+ if (!ba(g)) {
1197
1197
  u("the game's mount() did not return { unmount, update }");
1198
1198
  return;
1199
1199
  }
@@ -1224,18 +1224,18 @@ function ei(t) {
1224
1224
  };
1225
1225
  }
1226
1226
  function Sn({ activity: t, roomKey: e, layer: n }) {
1227
- const r = P(null), s = P(null), [i, a] = $(null), [l, o] = $(!1), c = x((k) => k.snapshot.leaderId), u = x((k) => k.me.clientId), f = !!c && c === u, p = x((k) => k.name), v = Qs()?.theme, g = Ya(void 0, v, ps().theme), h = Ee(() => ({
1227
+ const r = P(null), s = P(null), [i, a] = $(null), [l, o] = $(!1), c = x((k) => k.snapshot.leaderId), u = x((k) => k.me.clientId), f = !!c && c === u, p = x((k) => k.name), v = Ys()?.theme, g = Za(void 0, v, gs().theme), h = Ee(() => ({
1228
1228
  roomKey: e,
1229
1229
  identity: {
1230
1230
  // The registry userId — what RoomChrome's `userId` prop is.
1231
- userId: gs(),
1232
- userType: ms(),
1231
+ userId: ys(),
1232
+ userType: bs(),
1233
1233
  name: p || null
1234
1234
  },
1235
1235
  theme: g,
1236
1236
  isLeader: f,
1237
1237
  close: () => {
1238
- E("game", "bundle close", { gameId: t.id, isLeader: f, layer: n }), n !== "base" && (f ? Gn(null) : o(!0));
1238
+ E("game", "bundle close", { gameId: t.id, isLeader: f, layer: n }), n !== "base" && (f ? Vn(null) : o(!0));
1239
1239
  }
1240
1240
  }), [e, p, g, f, t.id, n]), y = fe(() => h), w = fe((k, m) => {
1241
1241
  C("game", "bundle failed", { gameId: t.id, message: k, cause: String(m) }), a(k);
@@ -1246,7 +1246,7 @@ function Sn({ activity: t, roomKey: e, layer: n }) {
1246
1246
  const k = r.current, m = t.load;
1247
1247
  if (!k || !m || l) return;
1248
1248
  E("game", "bundle mount", { gameId: t.id });
1249
- const { setGameSettings: T } = x.getState(), R = (S) => b.mountSettings(S), b = ei({
1249
+ const { setGameSettings: T } = x.getState(), R = (S) => b.mountSettings(S), b = ni({
1250
1250
  load: m,
1251
1251
  el: k,
1252
1252
  ctx: y(),
@@ -1284,8 +1284,8 @@ function Sn({ activity: t, roomKey: e, layer: n }) {
1284
1284
  }
1285
1285
  );
1286
1286
  }
1287
- const ti = "drawer-btn";
1288
- function ni({ open: t, onClose: e, header: n, footer: r, children: s }) {
1287
+ const ri = "drawer-btn";
1288
+ function si({ open: t, onClose: e, header: n, footer: r, children: s }) {
1289
1289
  return L(() => {
1290
1290
  if (!t) return;
1291
1291
  function i(a) {
@@ -1299,7 +1299,7 @@ function ni({ open: t, onClose: e, header: n, footer: r, children: s }) {
1299
1299
  onClick: (i) => i.stopPropagation(),
1300
1300
  children: [
1301
1301
  /* @__PURE__ */ _("div", { className: "p-3 border-b border-border flex items-center gap-2 text-sm", children: [
1302
- /* @__PURE__ */ d("button", { onClick: e, className: ti, children: "Close" }),
1302
+ /* @__PURE__ */ d("button", { onClick: e, className: ri, children: "Close" }),
1303
1303
  n
1304
1304
  ] }),
1305
1305
  s,
@@ -1308,40 +1308,43 @@ function ni({ open: t, onClose: e, header: n, footer: r, children: s }) {
1308
1308
  }
1309
1309
  ) }) : null;
1310
1310
  }
1311
- function ri({ open: t, onClose: e }) {
1312
- return /* @__PURE__ */ d(ni, { open: t, onClose: e, children: /* @__PURE__ */ d("div", { className: "px-4 py-3 text-xs text-text-muted", children: "Loading…" }) });
1311
+ function ai({ open: t, onClose: e }) {
1312
+ return /* @__PURE__ */ d(si, { open: t, onClose: e, children: /* @__PURE__ */ d("div", { className: "px-4 py-3 text-xs text-text-muted", children: "Loading…" }) });
1313
1313
  }
1314
- const pr = 9e3, wn = 1500, si = {
1314
+ const gr = 9e3, wn = 1500, ii = {
1315
1315
  classic: "[text-shadow:_-1px_-1px_0_#000,_1px_-1px_0_#000,_-1px_1px_0_#000,_1px_1px_0_#000,_0_-1px_0_#000,_0_1px_0_#000,_-1px_0_0_#000,_1px_0_0_#000]",
1316
1316
  cinema: "drop-shadow-[0_2px_4px_rgba(0,0,0,0.9)]",
1317
1317
  minimal: "drop-shadow-[0_2px_4px_rgba(0,0,0,0.9)] drop-shadow-[0_0_8px_rgba(0,0,0,0.7)]",
1318
1318
  contrast: "bg-black/70 px-2 py-0.5 rounded"
1319
+ }, xn = { WebkitTextStroke: "0.5px black", paintOrder: "stroke fill" }, En = {
1320
+ textShadow: "none",
1321
+ filter: "drop-shadow(0 0 1px black) drop-shadow(0 0 1px black)"
1319
1322
  };
1320
- function ai({ message: t, age: e, ccStyle: n }) {
1321
- const r = pr - wn;
1323
+ function oi({ message: t, age: e, ccStyle: n }) {
1324
+ const r = gr - wn;
1322
1325
  let s = 1;
1323
1326
  e > r && (s = Math.max(0, 1 - (e - r) / wn));
1324
- const i = si[n], a = x((u) => sr(u.roster, t.author)), l = tt(t.sprite, a), o = ir(t.isSystem ? void 0 : t.author), [c] = $(
1325
- () => t.live && t.text ? Dn(t.text, o) : null
1327
+ const i = ii[n], a = x((u) => ir(u.roster, t.author)), l = tt(t.sprite, a), o = cr(t.isSystem ? void 0 : t.author), [c] = $(
1328
+ () => t.live && t.text ? Hn(t.text, o) : null
1326
1329
  );
1327
1330
  return /* @__PURE__ */ _(
1328
1331
  "div",
1329
1332
  {
1330
1333
  className: `flex items-start gap-2 py-1 ${i}`,
1331
- style: { opacity: s, transition: "opacity 0.15s ease-out", ...or(l) },
1334
+ style: { opacity: s, transition: "opacity 0.15s ease-out", ...lr(l) },
1332
1335
  children: [
1333
- /* @__PURE__ */ d(cr, { sprite: t.sprite, url: a, worn: o }),
1334
- /* @__PURE__ */ _("div", { className: "min-w-0 flex-1", style: { WebkitTextStroke: "0.5px black", paintOrder: "stroke fill" }, children: [
1335
- o ? /* @__PURE__ */ d(ft, { html: On(t.name, o), className: "text-sm mr-2", style: { color: l } }) : /* @__PURE__ */ d("span", { className: "font-medium text-sm mr-2", style: { color: l }, children: t.name }),
1336
- c ? /* @__PURE__ */ d(ft, { html: c, className: "text-sm text-white break-words" }) : /* @__PURE__ */ d("span", { className: "text-sm text-white break-words", children: t.text }),
1337
- /* @__PURE__ */ d(lr, { images: t.images })
1336
+ /* @__PURE__ */ d(dr, { sprite: t.sprite, url: a, worn: o }),
1337
+ /* @__PURE__ */ _("div", { className: "min-w-0 flex-1", children: [
1338
+ o ? /* @__PURE__ */ d(ft, { html: Un(t.name, o), className: "text-sm mr-2", style: { color: l, ...En } }) : /* @__PURE__ */ d("span", { className: "font-medium text-sm mr-2", style: { color: l, ...xn }, children: t.name }),
1339
+ c ? /* @__PURE__ */ d(ft, { html: c, className: "text-sm text-white break-words", style: En }) : /* @__PURE__ */ d("span", { className: "text-sm text-white break-words", style: xn, children: t.text }),
1340
+ /* @__PURE__ */ d(ur, { images: t.images })
1338
1341
  ] })
1339
1342
  ]
1340
1343
  }
1341
1344
  );
1342
1345
  }
1343
- function ii() {
1344
- ar();
1346
+ function ci() {
1347
+ or();
1345
1348
  const t = x((f) => f.chat), e = x((f) => f.chatCollapsed), n = x((f) => f.floatingChatEnabled), r = x((f) => f.mediaPrefs.subtitleStyle), [s, i] = $(!1), [a, l] = $(() => Date.now());
1346
1349
  L(() => {
1347
1350
  const f = () => {
@@ -1357,7 +1360,7 @@ function ii() {
1357
1360
  return () => clearInterval(f);
1358
1361
  }, [o]);
1359
1362
  const c = n && (e || s), u = Ee(() => {
1360
- const f = a - pr;
1363
+ const f = a - gr;
1361
1364
  return t.filter((p) => !p.isSystem && p.ts > f).slice(-12);
1362
1365
  }, [t, a]);
1363
1366
  return !c || u.length === 0 ? null : /* @__PURE__ */ d(
@@ -1365,8 +1368,9 @@ function ii() {
1365
1368
  {
1366
1369
  className: "absolute right-4 w-80 z-20 pointer-events-none flex flex-col",
1367
1370
  style: { bottom: "35%" },
1371
+ "data-testid": "floating-chat",
1368
1372
  children: u.map((f) => /* @__PURE__ */ d(
1369
- ai,
1373
+ oi,
1370
1374
  {
1371
1375
  message: f,
1372
1376
  age: a - f.ts,
@@ -1377,18 +1381,18 @@ function ii() {
1377
1381
  }
1378
1382
  );
1379
1383
  }
1380
- const oi = 2;
1381
- function mr(t) {
1384
+ const li = 2;
1385
+ function br(t) {
1382
1386
  return t.duration_ms > 0 && t.duration_ms - t.playhead_ms <= qt;
1383
1387
  }
1384
- function gr(t) {
1388
+ function yr(t) {
1385
1389
  const e = t.video_ready_state ?? -1;
1386
- return e < 0 ? !0 : !(e <= oi && t.buffered_ahead_ms > qt);
1390
+ return e < 0 ? !0 : !(e <= li && t.buffered_ahead_ms > qt);
1387
1391
  }
1388
- function Ec(t) {
1389
- return t.playhead_ms === 0 && !t.is_buffering && t.buffered_ahead_ms === 0 ? "idle" : t.is_buffering ? "buffering" : mr(t) ? "healthy" : !gr(t) || t.buffered_ahead_ms <= Wn ? "critical" : t.buffered_ahead_ms <= qt ? "warning" : "healthy";
1392
+ function kc(t) {
1393
+ return t.playhead_ms === 0 && !t.is_buffering && t.buffered_ahead_ms === 0 ? "idle" : t.is_buffering ? "buffering" : br(t) ? "healthy" : !yr(t) || t.buffered_ahead_ms <= Kn ? "critical" : t.buffered_ahead_ms <= qt ? "warning" : "healthy";
1390
1394
  }
1391
- const Mc = {
1395
+ const _c = {
1392
1396
  idle: "Idle",
1393
1397
  buffering: "Buffering",
1394
1398
  critical: "Critical",
@@ -1396,7 +1400,7 @@ const Mc = {
1396
1400
  healthy: "Healthy"
1397
1401
  };
1398
1402
  let bt = null;
1399
- function br() {
1403
+ function vr() {
1400
1404
  if (bt) return bt;
1401
1405
  try {
1402
1406
  const t = window.AudioContext ?? window.webkitAudioContext;
@@ -1405,64 +1409,64 @@ function br() {
1405
1409
  }
1406
1410
  return bt;
1407
1411
  }
1408
- function yr(t) {
1412
+ function Sr(t) {
1409
1413
  t.state === "suspended" && t.resume().catch(() => {
1410
1414
  });
1411
1415
  }
1412
- function vr(t, e, n, r) {
1416
+ function wr(t, e, n, r) {
1413
1417
  t.gain.setValueAtTime(0, e), t.gain.linearRampToValueAtTime(n, e + 5e-3), t.gain.exponentialRampToValueAtTime(1e-4, e + r);
1414
1418
  }
1415
1419
  function We(t, e, n = 0.15, r = 0) {
1416
- const s = br();
1420
+ const s = vr();
1417
1421
  if (!s) return;
1418
- yr(s);
1422
+ Sr(s);
1419
1423
  const i = s.currentTime + r, a = s.createOscillator(), l = s.createGain();
1420
- a.type = "sine", a.frequency.value = t, vr(l, i, n, e / 1e3), a.connect(l).connect(s.destination), a.start(i), a.stop(i + e / 1e3 + 0.05);
1424
+ a.type = "sine", a.frequency.value = t, wr(l, i, n, e / 1e3), a.connect(l).connect(s.destination), a.start(i), a.stop(i + e / 1e3 + 0.05);
1421
1425
  }
1422
1426
  function Ft(t, e, n, r, s = 0.15, i = 0) {
1423
- const a = br();
1427
+ const a = vr();
1424
1428
  if (!a) return;
1425
- yr(a);
1429
+ Sr(a);
1426
1430
  const l = a.currentTime + i, o = a.createOscillator(), c = a.createOscillator(), u = a.createGain(), f = a.createGain();
1427
- o.type = "sine", o.frequency.value = t, c.type = "sine", c.frequency.value = e, u.gain.value = n * e, c.connect(u).connect(o.frequency), vr(f, l, s, r / 1e3), o.connect(f).connect(a.destination), o.start(l), o.stop(l + r / 1e3 + 0.05), c.start(l), c.stop(l + r / 1e3 + 0.05);
1431
+ o.type = "sine", o.frequency.value = t, c.type = "sine", c.frequency.value = e, u.gain.value = n * e, c.connect(u).connect(o.frequency), wr(f, l, s, r / 1e3), o.connect(f).connect(a.destination), o.start(l), o.stop(l + r / 1e3 + 0.05), c.start(l), c.stop(l + r / 1e3 + 0.05);
1428
1432
  }
1429
- function Sr() {
1433
+ function xr() {
1430
1434
  We(700, 60, 0.14, 0), We(700, 60, 0.14, 0.1), We(932, 120, 0.17, 0.2);
1431
1435
  }
1432
- function wr() {
1436
+ function Er() {
1433
1437
  We(784, 45, 0.07, 0), We(1047, 60, 0.07, 0.045);
1434
1438
  }
1435
- function xr() {
1439
+ function Mr() {
1436
1440
  We(659, 45, 0.06, 0), We(494, 70, 0.06, 0.045);
1437
1441
  }
1438
- function Er() {
1442
+ function kr() {
1439
1443
  Ft(587, 1174, 3, 320, 0.12, 0), Ft(880, 1760, 3, 320, 0.12, 0.06), Ft(884, 1768, 3, 320, 0.08, 0.06);
1440
1444
  }
1441
- Kn("__WP_SOUNDS__", {
1442
- start: Sr,
1443
- finish: Er,
1444
- on: wr,
1445
- off: xr
1445
+ zn("__WP_SOUNDS__", {
1446
+ start: xr,
1447
+ finish: kr,
1448
+ on: Er,
1449
+ off: Mr
1446
1450
  });
1447
- const xn = { on: 0, off: 0 };
1448
- function ci(t, e, n, r) {
1449
- if (!n || !r) return xn;
1451
+ const Mn = { on: 0, off: 0 };
1452
+ function di(t, e, n, r) {
1453
+ if (!n || !r) return Mn;
1450
1454
  const s = new Set(t), i = new Set(e);
1451
1455
  let a = 0;
1452
1456
  for (const o of i) s.has(o) || a++;
1453
1457
  let l = 0;
1454
1458
  for (const o of s) i.has(o) || l++;
1455
- return a === 0 && l === 0 ? xn : { on: a, off: l };
1459
+ return a === 0 && l === 0 ? Mn : { on: a, off: l };
1456
1460
  }
1457
- const li = 1200, be = 52, St = 4, Kt = (be - St) / 2, En = 2 * Math.PI * Kt, $e = be - St * 2 - 4;
1458
- function di(t) {
1459
- return mr(t) ? !0 : gr(t) ? t.buffered_ahead_ms >= Ce : !1;
1461
+ const ui = 1200, be = 52, St = 4, Vt = (be - St) / 2, kn = 2 * Math.PI * Vt, $e = be - St * 2 - 4;
1462
+ function fi(t) {
1463
+ return br(t) ? !0 : yr(t) ? t.buffered_ahead_ms >= Ce : !1;
1460
1464
  }
1461
- function ui(t) {
1465
+ function hi(t) {
1462
1466
  return `hsl(${Math.round(t * 120)}, 90%, 55%)`;
1463
1467
  }
1464
- function fi({ client: t, pictureUrl: e, fading: n, onFadeEnd: r }) {
1465
- const s = Math.min(1, t.buffered_ahead_ms / Ce), i = En * (1 - s), a = ui(s), l = tt(t.sprite_id, e);
1468
+ function pi({ client: t, pictureUrl: e, fading: n, onFadeEnd: r }) {
1469
+ const s = Math.min(1, t.buffered_ahead_ms / Ce), i = kn * (1 - s), a = hi(s), l = tt(t.sprite_id, e);
1466
1470
  return /* @__PURE__ */ _(
1467
1471
  "div",
1468
1472
  {
@@ -1470,7 +1474,7 @@ function fi({ client: t, pictureUrl: e, fading: n, onFadeEnd: r }) {
1470
1474
  "data-client-id": t.client_id,
1471
1475
  className: "flex flex-col items-center gap-1",
1472
1476
  style: n ? {
1473
- animation: `bufferFadeOut ${li}ms ease forwards`
1477
+ animation: `bufferFadeOut ${ui}ms ease forwards`
1474
1478
  } : void 0,
1475
1479
  onAnimationEnd: n ? r : void 0,
1476
1480
  children: [
@@ -1488,7 +1492,7 @@ function fi({ client: t, pictureUrl: e, fading: n, onFadeEnd: r }) {
1488
1492
  {
1489
1493
  cx: be / 2,
1490
1494
  cy: be / 2,
1491
- r: Kt,
1495
+ r: Vt,
1492
1496
  fill: "none",
1493
1497
  stroke: "rgba(255,255,255,0.15)",
1494
1498
  strokeWidth: St
@@ -1499,12 +1503,12 @@ function fi({ client: t, pictureUrl: e, fading: n, onFadeEnd: r }) {
1499
1503
  {
1500
1504
  cx: be / 2,
1501
1505
  cy: be / 2,
1502
- r: Kt,
1506
+ r: Vt,
1503
1507
  fill: "none",
1504
1508
  stroke: a,
1505
1509
  strokeWidth: St,
1506
1510
  strokeLinecap: "round",
1507
- strokeDasharray: En,
1511
+ strokeDasharray: kn,
1508
1512
  strokeDashoffset: i,
1509
1513
  style: { transition: "stroke-dashoffset 0.4s ease, stroke 0.4s ease" }
1510
1514
  }
@@ -1549,7 +1553,7 @@ function fi({ client: t, pictureUrl: e, fading: n, onFadeEnd: r }) {
1549
1553
  }
1550
1554
  );
1551
1555
  }
1552
- function hi({ clientId: t, sprite: e, pictureUrl: n, name: r, isReady: s, isSelf: i, onToggle: a }) {
1556
+ function mi({ clientId: t, sprite: e, pictureUrl: n, name: r, isReady: s, isSelf: i, onToggle: a }) {
1553
1557
  const l = tt(e, n), o = s ? "success" : "neutral", c = s ? /* @__PURE__ */ d(ut, { name: "tick" }) : /* @__PURE__ */ d(ut, { name: "hourglass" });
1554
1558
  return /* @__PURE__ */ _(
1555
1559
  "button",
@@ -1621,19 +1625,19 @@ function hi({ clientId: t, sprite: e, pictureUrl: n, name: r, isReady: s, isSelf
1621
1625
  }
1622
1626
  );
1623
1627
  }
1624
- const pi = { status: null, entries: [], completed: /* @__PURE__ */ new Set(), below: /* @__PURE__ */ new Set() };
1625
- function Mn(t, e) {
1628
+ const gi = { status: null, entries: [], completed: /* @__PURE__ */ new Set(), below: /* @__PURE__ */ new Set() };
1629
+ function _n(t, e) {
1626
1630
  if (!e || e.clients.length === 0) return { ...t, status: e, entries: [] };
1627
1631
  const n = new Set(t.completed), r = new Set(t.below), s = [];
1628
1632
  for (const i of e.clients) {
1629
1633
  const a = i.client_id;
1630
- di(i) ? r.has(a) && !n.has(a) ? (n.add(a), s.push({ client: i, completed: !0 })) : n.has(a) && s.push({ client: i, completed: !0 }) : (n.delete(a), r.add(a), s.push({ client: i, completed: !1 }));
1634
+ fi(i) ? r.has(a) && !n.has(a) ? (n.add(a), s.push({ client: i, completed: !0 })) : n.has(a) && s.push({ client: i, completed: !0 }) : (n.delete(a), r.add(a), s.push({ client: i, completed: !1 }));
1631
1635
  }
1632
1636
  return { status: e, entries: s, completed: n, below: r };
1633
1637
  }
1634
- function mi() {
1635
- const t = x((m) => m.bufferStatus), e = x((m) => m.readyCheck), n = x((m) => m.roster), r = x((m) => m.me.clientId), s = x((m) => m.snapshot.playing), i = nt(), [a, l] = $(() => Mn(pi, t));
1636
- a.status !== t && l(Mn(a, t));
1638
+ function bi() {
1639
+ const t = x((m) => m.bufferStatus), e = x((m) => m.readyCheck), n = x((m) => m.roster), r = x((m) => m.me.clientId), s = x((m) => m.snapshot.playing), i = nt(), [a, l] = $(() => _n(gi, t));
1640
+ a.status !== t && l(_n(a, t));
1637
1641
  const o = a.entries, c = (m) => {
1638
1642
  l((T) => {
1639
1643
  const R = new Set(T.completed), b = new Set(T.below);
@@ -1641,19 +1645,19 @@ function mi() {
1641
1645
  });
1642
1646
  }, u = new Set(e.ready), f = Object.values(n), p = !!r && u.has(r), v = e.active && f.length > 0 && e.ready.length >= f.length, g = P(e.active), h = P(v);
1643
1647
  L(() => {
1644
- !g.current && e.active && Sr(), g.current = e.active;
1648
+ !g.current && e.active && xr(), g.current = e.active;
1645
1649
  }, [e.active]), L(() => {
1646
- !h.current && v && Er(), h.current = v;
1650
+ !h.current && v && kr(), h.current = v;
1647
1651
  }, [v]);
1648
1652
  const y = P(e.ready), w = P(e.active);
1649
1653
  L(() => {
1650
- const { on: m, off: T } = ci(
1654
+ const { on: m, off: T } = di(
1651
1655
  y.current,
1652
1656
  e.ready,
1653
1657
  w.current,
1654
1658
  e.active
1655
1659
  );
1656
- m > 0 && wr(), T > 0 && xr(), y.current = e.ready, w.current = e.active;
1660
+ m > 0 && Er(), T > 0 && Mr(), y.current = e.ready, w.current = e.active;
1657
1661
  }, [e.ready, e.active]);
1658
1662
  const A = e.active, F = !A && o.length > 0, k = !A && !F && i && f.length > 0 && !s;
1659
1663
  return !A && !F && !k ? null : /* @__PURE__ */ _(Se, { children: [
@@ -1686,7 +1690,7 @@ function mi() {
1686
1690
  }
1687
1691
  ),
1688
1692
  /* @__PURE__ */ d("div", { className: "flex flex-col gap-3", children: f.map((m) => /* @__PURE__ */ d(
1689
- hi,
1693
+ mi,
1690
1694
  {
1691
1695
  clientId: m.clientId,
1692
1696
  sprite: m.sprite,
@@ -1694,13 +1698,13 @@ function mi() {
1694
1698
  name: m.name || "Anon",
1695
1699
  isReady: u.has(m.clientId),
1696
1700
  isSelf: m.clientId === r,
1697
- onToggle: () => bs(!p)
1701
+ onToggle: () => vs(!p)
1698
1702
  },
1699
1703
  m.clientId
1700
1704
  )) })
1701
1705
  ] }),
1702
1706
  F && o.map(({ client: m, completed: T }) => /* @__PURE__ */ d(
1703
- fi,
1707
+ pi,
1704
1708
  {
1705
1709
  client: m,
1706
1710
  pictureUrl: n[m.client_id]?.avatarUrl,
@@ -1714,7 +1718,7 @@ function mi() {
1714
1718
  {
1715
1719
  type: "button",
1716
1720
  "data-testid": "start-ready-check",
1717
- onClick: () => ys(),
1721
+ onClick: () => Ss(),
1718
1722
  className: "px-2.5 py-1 rounded bg-black/55 text-xs font-semibold tracking-wide hover:bg-black/75 transition-colors",
1719
1723
  style: { color: "#fff", pointerEvents: "auto" },
1720
1724
  title: "Ask everyone if they're ready",
@@ -1726,7 +1730,7 @@ function mi() {
1726
1730
  )
1727
1731
  ] });
1728
1732
  }
1729
- const Vt = {
1733
+ const Kt = {
1730
1734
  S: "var(--color-tier-s)",
1731
1735
  A: "var(--color-tier-a)",
1732
1736
  B: "var(--color-tier-b)",
@@ -1734,10 +1738,10 @@ const Vt = {
1734
1738
  D: "var(--color-tier-d)",
1735
1739
  F: "var(--color-tier-f)"
1736
1740
  }, Ge = "unranked";
1737
- function Mr(t) {
1741
+ function _r(t) {
1738
1742
  t?.complete && t.naturalWidth > 0 && (t.dataset.loaded = "true");
1739
1743
  }
1740
- function kn({
1744
+ function An({
1741
1745
  entry: t,
1742
1746
  draggable: e,
1743
1747
  picked: n,
@@ -1764,12 +1768,12 @@ function kn({
1764
1768
  /* @__PURE__ */ d(
1765
1769
  "img",
1766
1770
  {
1767
- src: Vn(t.id, t.thumbnail),
1771
+ src: Jn(t.id, t.thumbnail),
1768
1772
  alt: "",
1769
1773
  loading: "eager",
1770
1774
  decoding: "async",
1771
1775
  draggable: !1,
1772
- ref: Mr,
1776
+ ref: _r,
1773
1777
  onLoad: (i) => {
1774
1778
  i.currentTarget.dataset.loaded = "true";
1775
1779
  },
@@ -1784,7 +1788,7 @@ function kn({
1784
1788
  }
1785
1789
  );
1786
1790
  }
1787
- function gi({ sprite: t, url: e }) {
1791
+ function yi({ sprite: t, url: e }) {
1788
1792
  const n = tt(t, e);
1789
1793
  return /* @__PURE__ */ d(
1790
1794
  pt,
@@ -1797,7 +1801,7 @@ function gi({ sprite: t, url: e }) {
1797
1801
  }
1798
1802
  );
1799
1803
  }
1800
- function bi({
1804
+ function vi({
1801
1805
  anchor: t,
1802
1806
  itemId: e,
1803
1807
  snap: n
@@ -1824,13 +1828,13 @@ function bi({
1824
1828
  children: [
1825
1829
  /* @__PURE__ */ d("div", { className: "text-[11px] font-semibold text-text leading-snug pb-1.5 mb-1.5 border-b border-border", children: l }),
1826
1830
  Object.entries(a.votes).map(([o, c]) => /* @__PURE__ */ _("div", { className: "flex items-center gap-2 py-0.5", children: [
1827
- /* @__PURE__ */ d(gi, { sprite: n.sprites[o], url: n.pictures?.[o] }),
1831
+ /* @__PURE__ */ d(yi, { sprite: n.sprites[o], url: n.pictures?.[o] }),
1828
1832
  /* @__PURE__ */ d("span", { className: "flex-1 text-[11px] text-text-secondary truncate", children: n.names[o] ?? "viewer" }),
1829
1833
  /* @__PURE__ */ d(
1830
1834
  "span",
1831
1835
  {
1832
1836
  className: "w-5 h-4 grid place-items-center rounded text-[10px] font-bold shrink-0",
1833
- style: { background: Vt[c], color: "var(--color-tier-ink)" },
1837
+ style: { background: Kt[c], color: "var(--color-tier-ink)" },
1834
1838
  children: c
1835
1839
  }
1836
1840
  )
@@ -1841,7 +1845,7 @@ function bi({
1841
1845
  document.body
1842
1846
  );
1843
1847
  }
1844
- function yi() {
1848
+ function Si() {
1845
1849
  const t = x((b) => b.tierlistOpen), e = x((b) => b.setTierlistOpen), n = x((b) => b.tierlist), r = x((b) => b.tierlistDraft), s = x((b) => b.tierlistSaving), i = x((b) => b.moveTierlistItem), [a, l] = $(null), [o, c] = $(null), [u, f] = $(null), [p, v] = $(null), [g, h] = $("mine");
1846
1850
  L(() => {
1847
1851
  un(!0);
@@ -1857,18 +1861,18 @@ function yi() {
1857
1861
  const y = Ee(() => new Map((n?.items ?? []).map((b) => [b.id, b])), [n]), w = Ee(() => {
1858
1862
  const b = { S: [], A: [], B: [], C: [], D: [], F: [], [Ge]: [] }, S = /* @__PURE__ */ new Set();
1859
1863
  for (const I of Tt)
1860
- for (const D of r[I] ?? []) {
1861
- const H = y.get(D);
1862
- H && (b[I].push(H), S.add(D));
1864
+ for (const B of r[I] ?? []) {
1865
+ const H = y.get(B);
1866
+ H && (b[I].push(H), S.add(B));
1863
1867
  }
1864
1868
  for (const I of y.values()) S.has(I.id) || b[Ge].push(I);
1865
1869
  return b;
1866
1870
  }, [r, y]), A = (b, S, I) => {
1867
- const D = [...b.querySelectorAll("article[data-item-id]")].filter((j) => j.dataset.itemId !== I);
1871
+ const B = [...b.querySelectorAll("article[data-item-id]")].filter((j) => j.dataset.itemId !== I);
1868
1872
  let H = 0;
1869
- for (const j of D) {
1870
- const V = j.getBoundingClientRect();
1871
- S > V.left + V.width / 2 && H++;
1873
+ for (const j of B) {
1874
+ const K = j.getBoundingClientRect();
1875
+ S > K.left + K.width / 2 && H++;
1872
1876
  }
1873
1877
  return H;
1874
1878
  }, F = (b) => ({
@@ -1885,7 +1889,7 @@ function yi() {
1885
1889
  a && (i(a, b === Ge ? null : b), l(null));
1886
1890
  }
1887
1891
  }), k = U(async () => {
1888
- await vs(x.getState().tierlistDraft) && v(Date.now());
1892
+ await ws(x.getState().tierlistDraft) && v(Date.now());
1889
1893
  }, []);
1890
1894
  if (L(() => {
1891
1895
  if (p === null) return;
@@ -1937,7 +1941,7 @@ function yi() {
1937
1941
  "div",
1938
1942
  {
1939
1943
  className: "grid place-items-center select-none cursor-pointer",
1940
- style: { background: Vt[b], color: "var(--color-tier-ink)" },
1944
+ style: { background: Kt[b], color: "var(--color-tier-ink)" },
1941
1945
  onClick: () => {
1942
1946
  a && (i(a, b), l(null));
1943
1947
  },
@@ -1951,7 +1955,7 @@ function yi() {
1951
1955
  ...F(b),
1952
1956
  className: `flex items-center gap-2 p-2 overflow-x-auto transition-colors ${o === b ? "bg-primary/15 ring-1 ring-inset ring-primary" : "bg-bg-card"}`,
1953
1957
  children: w[b].map((S) => /* @__PURE__ */ d(
1954
- kn,
1958
+ An,
1955
1959
  {
1956
1960
  entry: S,
1957
1961
  draggable: !0,
@@ -1970,7 +1974,7 @@ function yi() {
1970
1974
  ...F(Ge),
1971
1975
  className: `flex items-center gap-2 p-2 overflow-x-auto min-h-[96px] border-t border-dashed border-border transition-colors ${o === Ge ? "bg-primary/15 ring-1 ring-inset ring-primary" : "bg-bg"}`,
1972
1976
  children: w[Ge].map((b) => /* @__PURE__ */ d(
1973
- kn,
1977
+ An,
1974
1978
  {
1975
1979
  entry: b,
1976
1980
  draggable: !0,
@@ -1990,12 +1994,12 @@ function yi() {
1990
1994
  "div",
1991
1995
  {
1992
1996
  className: "grid place-items-center select-none",
1993
- style: { background: Vt[b], color: "var(--color-tier-ink)" },
1997
+ style: { background: Kt[b], color: "var(--color-tier-ink)" },
1994
1998
  children: /* @__PURE__ */ d("span", { className: "text-2xl font-bold leading-none", children: b })
1995
1999
  }
1996
2000
  ),
1997
2001
  /* @__PURE__ */ d("div", { className: "flex items-stretch gap-2 p-2 overflow-x-auto bg-bg-card", children: S.map((I) => {
1998
- const D = y.get(I.mediaId);
2002
+ const B = y.get(I.mediaId);
1999
2003
  return /* @__PURE__ */ _(
2000
2004
  "div",
2001
2005
  {
@@ -2004,17 +2008,17 @@ function yi() {
2004
2008
  onMouseLeave: () => f(null),
2005
2009
  onFocus: (H) => f({ anchor: H.currentTarget.getBoundingClientRect(), itemId: I.mediaId }),
2006
2010
  onBlur: () => f(null),
2007
- "aria-label": `${D?.displayName ?? I.mediaId} — score ${I.score.toFixed(2)}. ${Object.entries(I.votes).map(([H, j]) => `${n.names[H] ?? "viewer"} ${j}`).join(", ")}`,
2011
+ "aria-label": `${B?.displayName ?? I.mediaId} — score ${I.score.toFixed(2)}. ${Object.entries(I.votes).map(([H, j]) => `${n.names[H] ?? "viewer"} ${j}`).join(", ")}`,
2008
2012
  className: "w-[124px] shrink-0 rounded-md overflow-hidden bg-bg-alt border border-border hover:border-primary transition-colors",
2009
2013
  children: [
2010
2014
  /* @__PURE__ */ d(
2011
2015
  "img",
2012
2016
  {
2013
- src: Vn(I.mediaId, D?.thumbnail),
2017
+ src: Jn(I.mediaId, B?.thumbnail),
2014
2018
  alt: "",
2015
2019
  loading: "eager",
2016
2020
  decoding: "async",
2017
- ref: Mr,
2021
+ ref: _r,
2018
2022
  onLoad: (H) => {
2019
2023
  H.currentTarget.dataset.loaded = "true";
2020
2024
  },
@@ -2024,7 +2028,7 @@ function yi() {
2024
2028
  className: "tl-card-img w-full aspect-video object-cover bg-bg-card"
2025
2029
  }
2026
2030
  ),
2027
- /* @__PURE__ */ d("div", { className: "px-1.5 pt-1 text-[11px] leading-tight text-text-secondary line-clamp-2 min-h-[28px]", children: D?.displayName ?? I.mediaId }),
2031
+ /* @__PURE__ */ d("div", { className: "px-1.5 pt-1 text-[11px] leading-tight text-text-secondary line-clamp-2 min-h-[28px]", children: B?.displayName ?? I.mediaId }),
2028
2032
  /* @__PURE__ */ _("div", { className: "px-1.5 pb-1 flex items-center gap-1 text-[10px] tabular-nums text-text-muted", children: [
2029
2033
  /* @__PURE__ */ d("span", { children: "score" }),
2030
2034
  /* @__PURE__ */ d("span", { className: "text-text-secondary", children: I.score.toFixed(2) })
@@ -2040,96 +2044,96 @@ function yi() {
2040
2044
  ]
2041
2045
  }
2042
2046
  ),
2043
- u && n && /* @__PURE__ */ d(bi, { anchor: u.anchor, itemId: u.itemId, snap: n })
2047
+ u && n && /* @__PURE__ */ d(vi, { anchor: u.anchor, itemId: u.itemId, snap: n })
2044
2048
  ]
2045
2049
  }
2046
2050
  ),
2047
2051
  document.body
2048
2052
  );
2049
2053
  }
2050
- function vi({ children: t }) {
2054
+ function wi({ children: t }) {
2051
2055
  const [e, n] = $(null);
2052
2056
  return L(() => {
2053
2057
  const r = () => n(document.fullscreenElement);
2054
2058
  return r(), document.addEventListener("fullscreenchange", r), () => document.removeEventListener("fullscreenchange", r);
2055
2059
  }, []), e ? wt(t, e) : /* @__PURE__ */ d(Se, { children: t });
2056
2060
  }
2057
- function kc({ className: t = "w-5 h-5" }) {
2061
+ function Ac({ className: t = "w-5 h-5" }) {
2058
2062
  return /* @__PURE__ */ d("svg", { className: t, fill: "currentColor", viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ d("path", { d: "M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z" }) });
2059
2063
  }
2060
- function Si({ className: t = "w-5 h-5" }) {
2064
+ function xi({ className: t = "w-5 h-5" }) {
2061
2065
  return /* @__PURE__ */ d("svg", { className: t, viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ d("path", { d: "M8 5v14l11-7z" }) });
2062
2066
  }
2063
- function wi({ className: t = "w-5 h-5" }) {
2067
+ function Ei({ className: t = "w-5 h-5" }) {
2064
2068
  return /* @__PURE__ */ d("svg", { className: t, viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ d("path", { d: "M6 19h4V5H6v14zm8-14v14h4V5h-4z" }) });
2065
2069
  }
2066
- function xi({ className: t = "w-5 h-5" }) {
2070
+ function Mi({ className: t = "w-5 h-5" }) {
2067
2071
  return /* @__PURE__ */ _("svg", { className: t, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
2068
2072
  /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z" }),
2069
2073
  /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2" })
2070
2074
  ] });
2071
2075
  }
2072
- function Ei({ className: t = "w-5 h-5" }) {
2076
+ function ki({ className: t = "w-5 h-5" }) {
2073
2077
  return /* @__PURE__ */ _("svg", { className: t, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
2074
2078
  /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z" }),
2075
2079
  /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15.536 8.464a5 5 0 010 7.072" })
2076
2080
  ] });
2077
2081
  }
2078
- function Mi({ className: t = "w-5 h-5" }) {
2082
+ function _i({ className: t = "w-5 h-5" }) {
2079
2083
  return /* @__PURE__ */ _("svg", { className: t, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
2080
2084
  /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z" }),
2081
2085
  /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15.536 8.464a5 5 0 010 7.072M18.364 5.636a9 9 0 010 12.728" })
2082
2086
  ] });
2083
2087
  }
2084
- function ki({ className: t = "w-5 h-5" }) {
2088
+ function Ai({ className: t = "w-5 h-5" }) {
2085
2089
  return /* @__PURE__ */ d("svg", { className: t, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" }) });
2086
2090
  }
2087
- function _i({ className: t = "w-5 h-5" }) {
2091
+ function Ti({ className: t = "w-5 h-5" }) {
2088
2092
  return /* @__PURE__ */ d("svg", { className: t, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 9V4H4m0 0l5 5M9 15v5H4m0 0l5-5M15 9V4h5m0 0l-5 5M15 15v5h5m0 0l-5-5" }) });
2089
2093
  }
2090
- function Ai({ className: t = "w-5 h-5" }) {
2094
+ function Ii({ className: t = "w-5 h-5" }) {
2091
2095
  return /* @__PURE__ */ d("svg", { className: t, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.5, children: /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15 19l-7-7 7-7" }) });
2092
2096
  }
2093
- function Ti({ className: t = "w-5 h-5" }) {
2097
+ function Ci({ className: t = "w-5 h-5" }) {
2094
2098
  return /* @__PURE__ */ d("svg", { className: t, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.5, children: /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 5l7 7-7 7" }) });
2095
2099
  }
2096
- function Ii({ className: t = "w-4 h-4" }) {
2100
+ function Ri({ className: t = "w-4 h-4" }) {
2097
2101
  return /* @__PURE__ */ _("svg", { className: t, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
2098
2102
  /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 4v16" }),
2099
2103
  /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15 12l-5 4v-8l5 4z" })
2100
2104
  ] });
2101
2105
  }
2102
- function Ci({ className: t = "w-4 h-4" }) {
2106
+ function Fi({ className: t = "w-4 h-4" }) {
2103
2107
  return /* @__PURE__ */ _("svg", { className: t, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
2104
2108
  /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M20 4v16" }),
2105
2109
  /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 12l5 4v-8l-5 4z" })
2106
2110
  ] });
2107
2111
  }
2108
- function Ri({ className: t = "w-5 h-5" }) {
2112
+ function Ni({ className: t = "w-5 h-5" }) {
2109
2113
  return /* @__PURE__ */ d("svg", { className: t, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 6l12 12M18 6L6 18" }) });
2110
2114
  }
2111
- function Fi({ className: t = "w-5 h-5" }) {
2115
+ function Li({ className: t = "w-5 h-5" }) {
2112
2116
  return /* @__PURE__ */ _("svg", { className: t, viewBox: "0 0 24 24", fill: "currentColor", children: [
2113
2117
  /* @__PURE__ */ d("path", { d: "M12 5l8 11H4z" }),
2114
2118
  /* @__PURE__ */ d("rect", { x: "4", y: "17", width: "16", height: "3", rx: "0.5" })
2115
2119
  ] });
2116
2120
  }
2117
- function Ni({ className: t = "w-5 h-5" }) {
2121
+ function $i({ className: t = "w-5 h-5" }) {
2118
2122
  return /* @__PURE__ */ d("svg", { className: t, fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M7 4v16M17 4v16M3 8h4m10 0h4M3 12h18M3 16h4m10 0h4M4 4h16a1 1 0 011 1v14a1 1 0 01-1 1H4a1 1 0 01-1-1V5a1 1 0 011-1z" }) });
2119
2123
  }
2120
- function kr({ site: t = "control bar", className: e = "ctr-btn" }) {
2124
+ function Ar({ site: t = "control bar", className: e = "ctr-btn" }) {
2121
2125
  return /* @__PURE__ */ d(
2122
2126
  "button",
2123
2127
  {
2124
- onClick: () => tr(t),
2128
+ onClick: () => rr(t),
2125
2129
  className: e,
2126
2130
  title: "Select Media",
2127
2131
  "aria-label": "Select Media",
2128
- children: /* @__PURE__ */ d(Ni, {})
2132
+ children: /* @__PURE__ */ d($i, {})
2129
2133
  }
2130
2134
  );
2131
2135
  }
2132
- function Li() {
2136
+ function Pi() {
2133
2137
  const t = x((a) => a.chatCollapsed), e = x((a) => a.toggleChatCollapsed), n = x((a) => !!a.snapshot.mediaId), r = xt(), s = Yt({ hasMedia: n, chatCollapsed: t, isFullscreen: r });
2134
2138
  return { panelHidden: s, toggle: () => {
2135
2139
  if (E("chat", s ? "Show chat" : "Hide chat", { isFullscreen: r, chatCollapsed: t }), !s) {
@@ -2141,8 +2145,8 @@ function Li() {
2141
2145
  });
2142
2146
  } };
2143
2147
  }
2144
- function _r({ className: t }) {
2145
- const { panelHidden: e, toggle: n } = Li(), r = e ? "Show chat" : "Hide chat";
2148
+ function Tr({ className: t }) {
2149
+ const { panelHidden: e, toggle: n } = Pi(), r = e ? "Show chat" : "Hide chat";
2146
2150
  return /* @__PURE__ */ d(
2147
2151
  "button",
2148
2152
  {
@@ -2152,38 +2156,38 @@ function _r({ className: t }) {
2152
2156
  title: r,
2153
2157
  "aria-label": r,
2154
2158
  "aria-expanded": !e,
2155
- children: e ? /* @__PURE__ */ d(Ci, { className: "w-5 h-5" }) : /* @__PURE__ */ d(Ii, { className: "w-5 h-5" })
2159
+ children: e ? /* @__PURE__ */ d(Fi, { className: "w-5 h-5" }) : /* @__PURE__ */ d(Ri, { className: "w-5 h-5" })
2156
2160
  }
2157
2161
  );
2158
2162
  }
2159
- function $i() {
2163
+ function Di() {
2160
2164
  const t = x((u) => u.chatCollapsed), e = x((u) => !!u.snapshot.mediaId), n = xt(), r = Et(), s = nt(), i = en(), a = Xt({
2161
2165
  isLeader: i,
2162
2166
  hasMedia: e,
2163
2167
  chatCollapsed: t,
2164
2168
  isFullscreen: n,
2165
2169
  gameOverlay: r !== null
2166
- }) === "room-corner", l = s && r !== null && !n, o = rr({ hasMedia: e, isFullscreen: n, gameOverlay: r !== null }) === "room-corner";
2170
+ }) === "room-corner", l = s && r !== null && !n, o = ar({ hasMedia: e, isFullscreen: n, gameOverlay: r !== null }) === "room-corner";
2167
2171
  return !a && !l && !o ? null : /* @__PURE__ */ _("div", { className: "absolute top-2 right-2 z-40 flex items-center gap-2", "data-testid": "room-corner-controls", children: [
2168
- a && /* @__PURE__ */ d(kr, { site: "room corner", className: "corner-btn" }),
2172
+ a && /* @__PURE__ */ d(Ar, { site: "room corner", className: "corner-btn" }),
2169
2173
  l && /* @__PURE__ */ d("button", { type: "button", onClick: () => {
2170
- E("game", "game_select", { gameId: null, source: "room corner" }), Gn(null);
2171
- }, className: "corner-btn", title: "Stop game", "aria-label": "Stop game", children: /* @__PURE__ */ d(Ri, {}) }),
2172
- o && /* @__PURE__ */ d(_r, { className: "corner-btn" })
2174
+ E("game", "game_select", { gameId: null, source: "room corner" }), Vn(null);
2175
+ }, className: "corner-btn", title: "Stop game", "aria-label": "Stop game", children: /* @__PURE__ */ d(Ni, {}) }),
2176
+ o && /* @__PURE__ */ d(Tr, { className: "corner-btn" })
2173
2177
  ] });
2174
2178
  }
2175
- function Pi() {
2176
- L(() => Ss((t) => {
2177
- const e = ws(t);
2178
- E("avatar", "Avatar changed in the settings popout", { sprite: e, source: t.avatar?.source }), zn(e);
2179
+ function Bi() {
2180
+ L(() => xs((t) => {
2181
+ const e = Es(t);
2182
+ E("avatar", "Avatar changed in the settings popout", { sprite: e, source: t.avatar?.source }), Qn(e);
2179
2183
  }), []);
2180
2184
  }
2181
- const Ar = [];
2182
- function _n(t) {
2183
- Ar.push(t);
2185
+ const Ir = [];
2186
+ function Tn(t) {
2187
+ Ir.push(t);
2184
2188
  }
2185
2189
  function Qe() {
2186
- const t = Ar.splice(0);
2190
+ const t = Ir.splice(0);
2187
2191
  for (const e of t)
2188
2192
  try {
2189
2193
  e();
@@ -2192,32 +2196,32 @@ function Qe() {
2192
2196
  }
2193
2197
  }
2194
2198
  let Nt = !1;
2195
- function Bi() {
2199
+ function Oi() {
2196
2200
  return Nt ? () => {
2197
2201
  } : (Nt = !0, document.addEventListener("click", Qe, { capture: !0, passive: !0 }), document.addEventListener("touchend", Qe, { capture: !0, passive: !0 }), document.addEventListener("keydown", Qe, { capture: !0, passive: !0 }), () => {
2198
2202
  document.removeEventListener("click", Qe, { capture: !0 }), document.removeEventListener("touchend", Qe, { capture: !0 }), document.removeEventListener("keydown", Qe, { capture: !0 }), Nt = !1;
2199
2203
  });
2200
2204
  }
2201
- const Di = 400;
2202
- function Oi(t) {
2205
+ const Hi = 400;
2206
+ function Ui(t) {
2203
2207
  return t === "leader" || t === "viewer" ? t : null;
2204
2208
  }
2205
- async function Hi(t) {
2206
- const e = xs(), n = await fetch(`${e}/api/rooms/validate/${encodeURIComponent(t)}`);
2209
+ async function ji(t) {
2210
+ const e = Ms(), n = await fetch(`${e}/api/rooms/validate/${encodeURIComponent(t)}`);
2207
2211
  if (n.status === 404) return null;
2208
2212
  if (!n.ok) throw new Error(`validate returned ${n.status}`);
2209
2213
  const r = await n.json();
2210
- return Oi(r?.type);
2214
+ return Ui(r?.type);
2211
2215
  }
2212
- async function Ui(t) {
2216
+ async function Gi(t) {
2213
2217
  for (let e = 0; e < 2; e++)
2214
2218
  try {
2215
- const n = await Hi(t);
2219
+ const n = await ji(t);
2216
2220
  x.getState().setRoomKeyType({ roomKey: t, type: n }), E("room", "Room key type probed", { roomKey: t, type: n });
2217
2221
  return;
2218
2222
  } catch (n) {
2219
2223
  if (e === 0) {
2220
- await new Promise((r) => setTimeout(r, Di));
2224
+ await new Promise((r) => setTimeout(r, Hi));
2221
2225
  continue;
2222
2226
  }
2223
2227
  C("room", "Room key type probe failed, falling back to socket truth", Y(n));
@@ -2225,16 +2229,16 @@ async function Ui(t) {
2225
2229
  }
2226
2230
  function Pe(t, e) {
2227
2231
  const r = x.getState().allocateClientSeq(), s = { kind: t, client_seq: r, ...e || {} };
2228
- return Jn().emit(Qn.CONTROL, s), r;
2232
+ return qn().emit(Yn.CONTROL, s), r;
2229
2233
  }
2230
- function _c(t) {
2234
+ function Tc(t) {
2231
2235
  return Pe("load", { media_id: t });
2232
2236
  }
2233
- function ji() {
2237
+ function Wi() {
2234
2238
  return Pe("home");
2235
2239
  }
2236
- function Gi() {
2237
- const t = Ka(), e = fr(), n = nt(), r = hr(), s = n && r && !e.ready, i = !e.ready && !s;
2240
+ function Vi() {
2241
+ const t = za(), e = pr(), n = nt(), r = mr(), s = n && r && !e.ready, i = !e.ready && !s;
2238
2242
  return /* @__PURE__ */ d(
2239
2243
  "button",
2240
2244
  {
@@ -2254,13 +2258,13 @@ function Gi() {
2254
2258
  className: "ctr-btn",
2255
2259
  title: s ? "Some viewers still loading — play anyway" : i ? "Waiting for sync..." : n ? t.playing ? "Pause" : "Play" : "Only the leader can control playback",
2256
2260
  "data-active": !i && n && t.playing ? "1" : "0",
2257
- children: t.playing ? /* @__PURE__ */ d(wi, {}) : /* @__PURE__ */ d(Si, {})
2261
+ children: t.playing ? /* @__PURE__ */ d(Ei, {}) : /* @__PURE__ */ d(xi, {})
2258
2262
  }
2259
2263
  );
2260
2264
  }
2261
- function Wi() {
2265
+ function Ki() {
2262
2266
  function t() {
2263
- E("controls", "Unload episode clicked"), ji();
2267
+ E("controls", "Unload episode clicked"), Wi();
2264
2268
  }
2265
2269
  return /* @__PURE__ */ d(
2266
2270
  "button",
@@ -2269,29 +2273,29 @@ function Wi() {
2269
2273
  className: "ctr-btn",
2270
2274
  title: "Unload episode (return to lobby)",
2271
2275
  "aria-label": "Unload episode",
2272
- children: /* @__PURE__ */ d(Fi, {})
2276
+ children: /* @__PURE__ */ d(Li, {})
2273
2277
  }
2274
2278
  );
2275
2279
  }
2276
- function Ki(t) {
2280
+ function zi(t) {
2277
2281
  return !t.isLeader || t.durationMs === 0 ? !0 : !t.ready && !t.canOverride;
2278
2282
  }
2279
- function Vi(t) {
2283
+ function Ji(t) {
2280
2284
  return t.localValue !== null ? t.localValue : t.displayPlayheadMs ?? t.snapshotPlayheadMs;
2281
2285
  }
2282
- function zi(t, e) {
2286
+ function Qi(t, e) {
2283
2287
  return e <= 0 ? 0 : t / e;
2284
2288
  }
2285
2289
  function Lt(t) {
2286
2290
  const e = Math.floor(t / 1e3), n = Math.floor(e / 3600), r = Math.floor(e % 3600 / 60), s = e % 60;
2287
2291
  return n > 0 ? `${n}:${r.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}` : `${r}:${s.toString().padStart(2, "0")}`;
2288
2292
  }
2289
- function Ji({ durationMs: t, displayPlayheadMs: e }) {
2290
- const n = x((S) => S.snapshot), r = x((S) => S.readiness), s = nt(), i = hr(), a = s && i && !r.ready, l = P(null), [o, c] = $(null), [u, f] = $(0), [p, v] = $(!1), [g, h] = $(null), y = P(0), [w, A] = $(n.mediaId);
2293
+ function qi({ durationMs: t, displayPlayheadMs: e }) {
2294
+ const n = x((S) => S.snapshot), r = x((S) => S.readiness), s = nt(), i = mr(), a = s && i && !r.ready, l = P(null), [o, c] = $(null), [u, f] = $(0), [p, v] = $(!1), [g, h] = $(null), y = P(0), [w, A] = $(n.mediaId);
2291
2295
  w !== n.mediaId && (A(n.mediaId), h(null), v(!1));
2292
2296
  const F = e ?? n.playheadMs;
2293
- !p && g !== null && Math.abs(F - g) < Wn && h(null);
2294
- const k = t || 0, m = Vi({ localValue: g, displayPlayheadMs: e, snapshotPlayheadMs: n.playheadMs }), T = P(0);
2297
+ !p && g !== null && Math.abs(F - g) < Kn && h(null);
2298
+ const k = t || 0, m = Ji({ localValue: g, displayPlayheadMs: e, snapshotPlayheadMs: n.playheadMs }), T = P(0);
2295
2299
  L(() => {
2296
2300
  if (p || g === null) return;
2297
2301
  const S = 1e4 - (Date.now() - T.current), I = setTimeout(() => {
@@ -2304,8 +2308,8 @@ function Ji({ durationMs: t, displayPlayheadMs: e }) {
2304
2308
  return () => clearTimeout(I);
2305
2309
  }, [F, p, g]);
2306
2310
  const R = U((S) => {
2307
- const I = S.currentTarget.getBoundingClientRect(), D = S.clientX - I.left, H = D / I.width, j = Math.round(H * k);
2308
- c(D), f(Math.max(0, Math.min(j, k)));
2311
+ const I = S.currentTarget.getBoundingClientRect(), B = S.clientX - I.left, H = B / I.width, j = Math.round(H * k);
2312
+ c(B), f(Math.max(0, Math.min(j, k)));
2309
2313
  }, [k]), b = U(() => {
2310
2314
  c(null);
2311
2315
  }, []);
@@ -2319,8 +2323,8 @@ function Ji({ durationMs: t, displayPlayheadMs: e }) {
2319
2323
  min: 0,
2320
2324
  max: k,
2321
2325
  value: m,
2322
- disabled: Ki({ isLeader: s, ready: r.ready, canOverride: a, durationMs: k }),
2323
- style: { "--progress": `${zi(m, k) * 100}%` },
2326
+ disabled: zi({ isLeader: s, ready: r.ready, canOverride: a, durationMs: k }),
2327
+ style: { "--progress": `${Qi(m, k) * 100}%` },
2324
2328
  onChange: (S) => {
2325
2329
  const I = Number(S.target.value);
2326
2330
  h(I), T.current = Date.now();
@@ -2352,7 +2356,7 @@ function Ji({ durationMs: t, displayPlayheadMs: e }) {
2352
2356
  /* @__PURE__ */ d("span", { className: "text-[11px] font-mono text-text-muted w-[45px] text-left shrink-0", children: Lt(k) })
2353
2357
  ] });
2354
2358
  }
2355
- function Qi({ videoRef: t }) {
2359
+ function Yi({ videoRef: t }) {
2356
2360
  const e = x((u) => u.mediaPrefs.volume), n = x((u) => u.mediaPrefs.muted), r = x((u) => u.setVolume), s = x((u) => u.setMuted);
2357
2361
  L(() => {
2358
2362
  const u = t.current;
@@ -2363,7 +2367,7 @@ function Qi({ videoRef: t }) {
2363
2367
  r(f), f > 0 && n && s(!1);
2364
2368
  }, a = () => {
2365
2369
  s(!n);
2366
- }, l = () => n || e === 0 ? /* @__PURE__ */ d(xi, {}) : e < 0.5 ? /* @__PURE__ */ d(Ei, {}) : /* @__PURE__ */ d(Mi, {}), o = n ? 0 : e, c = Math.round(o * 100);
2370
+ }, l = () => n || e === 0 ? /* @__PURE__ */ d(Mi, {}) : e < 0.5 ? /* @__PURE__ */ d(ki, {}) : /* @__PURE__ */ d(_i, {}), o = n ? 0 : e, c = Math.round(o * 100);
2367
2371
  return /* @__PURE__ */ _("div", { className: "flex items-center gap-2", children: [
2368
2372
  /* @__PURE__ */ d(
2369
2373
  "button",
@@ -2396,7 +2400,7 @@ function Qi({ videoRef: t }) {
2396
2400
  ] })
2397
2401
  ] });
2398
2402
  }
2399
- function qi({
2403
+ function Xi({
2400
2404
  tracks: t,
2401
2405
  selectedIndex: e,
2402
2406
  onSelect: n
@@ -2420,7 +2424,7 @@ function qi({
2420
2424
  )
2421
2425
  ] });
2422
2426
  }
2423
- function Yi({
2427
+ function Zi({
2424
2428
  tracks: t,
2425
2429
  selectedIndex: e,
2426
2430
  onSelect: n,
@@ -2457,13 +2461,13 @@ function Yi({
2457
2461
  )
2458
2462
  ] });
2459
2463
  }
2460
- const Xi = [
2464
+ const eo = [
2461
2465
  { value: "classic", label: "Classic" },
2462
2466
  { value: "cinema", label: "Cinema" },
2463
2467
  { value: "minimal", label: "Minimal" },
2464
2468
  { value: "contrast", label: "High Contrast" }
2465
2469
  ];
2466
- function Zi({ style: t, onStyleChange: e, enabled: n }) {
2470
+ function to({ style: t, onStyleChange: e, enabled: n }) {
2467
2471
  return n ? /* @__PURE__ */ _("div", { className: "flex items-center gap-2", children: [
2468
2472
  /* @__PURE__ */ d("span", { className: "text-[10px] opacity-60 uppercase tracking-wide", children: "Style" }),
2469
2473
  /* @__PURE__ */ d(
@@ -2474,12 +2478,12 @@ function Zi({ style: t, onStyleChange: e, enabled: n }) {
2474
2478
  className: "text-xs rounded px-2 py-1 cursor-pointer",
2475
2479
  title: "Select subtitle style",
2476
2480
  "aria-label": "Subtitle style selection",
2477
- children: Xi.map((r) => /* @__PURE__ */ d("option", { value: r.value, children: r.label }, r.value))
2481
+ children: eo.map((r) => /* @__PURE__ */ d("option", { value: r.value, children: r.label }, r.value))
2478
2482
  }
2479
2483
  )
2480
2484
  ] }) : null;
2481
2485
  }
2482
- function eo({ videoRef: t }) {
2486
+ function no({ videoRef: t }) {
2483
2487
  const [e, n] = $(!1);
2484
2488
  L(() => {
2485
2489
  const s = () => {
@@ -2509,11 +2513,11 @@ function eo({ videoRef: t }) {
2509
2513
  },
2510
2514
  className: "ctr-btn",
2511
2515
  title: e ? "Exit Fullscreen" : "Enter Fullscreen",
2512
- children: e ? /* @__PURE__ */ d(_i, {}) : /* @__PURE__ */ d(ki, {})
2516
+ children: e ? /* @__PURE__ */ d(Ti, {}) : /* @__PURE__ */ d(Ai, {})
2513
2517
  }
2514
2518
  );
2515
2519
  }
2516
- function to({
2520
+ function ro({
2517
2521
  videoRef: t,
2518
2522
  mediaId: e,
2519
2523
  durationMs: n,
@@ -2538,19 +2542,19 @@ function to({
2538
2542
  chatCollapsed: A,
2539
2543
  isFullscreen: F,
2540
2544
  gameOverlay: m
2541
- }) === "control-bar", R = rr({ hasMedia: !0, isFullscreen: F, gameOverlay: m }) === "control-bar", b = x((z) => z.floatingChatEnabled), S = P(null), I = P(null), [D, H] = $(!1), [j, V] = $(!1), [X, N] = $(""), [O, Q] = $(!1), W = ur(), [re, le] = $(!1), [Re, Ve] = $(!1), Mt = U(async (z) => {
2545
+ }) === "control-bar", R = ar({ hasMedia: !0, isFullscreen: F, gameOverlay: m }) === "control-bar", b = x((z) => z.floatingChatEnabled), S = P(null), I = P(null), [B, H] = $(!1), [j, K] = $(!1), [X, N] = $(""), [O, Q] = $(!1), W = hr(), [re, le] = $(!1), [Re, Ke] = $(!1), Mt = U(async (z) => {
2542
2546
  if (z.key !== "Enter") return;
2543
2547
  const he = X.trim();
2544
2548
  if (!he && !W.pending.length || O || W.uploading) return;
2545
2549
  const Me = await W.uploadPending();
2546
- Me !== null && (Hn(he, Me), N(""), W.clear(), Q(!0), setTimeout(() => Q(!1), Un), !document.hidden && document.hasFocus() && I.current?.focus());
2550
+ Me !== null && (jn(he, Me), N(""), W.clear(), Q(!0), setTimeout(() => Q(!1), Gn), !document.hidden && document.hasFocus() && I.current?.focus());
2547
2551
  }, [X, O, W]);
2548
2552
  L(() => () => y?.(!1), [e, y]);
2549
- const Be = r ?? !0, ye = U(() => {
2553
+ const De = r ?? !0, ye = U(() => {
2550
2554
  const z = S.current;
2551
2555
  if (!z) return;
2552
2556
  const { scrollLeft: he, scrollWidth: Me, clientWidth: kt } = z;
2553
- H(he > 5), V(he + kt < Me - 5);
2557
+ H(he > 5), K(he + kt < Me - 5);
2554
2558
  }, []);
2555
2559
  L(() => {
2556
2560
  const z = S.current;
@@ -2560,8 +2564,8 @@ function to({
2560
2564
  return he.observe(z), () => {
2561
2565
  z.removeEventListener("scroll", ye), he.disconnect();
2562
2566
  };
2563
- }, [ye, Be]);
2564
- const De = U((z) => {
2567
+ }, [ye, De]);
2568
+ const Be = U((z) => {
2565
2569
  const he = S.current;
2566
2570
  if (!he) return;
2567
2571
  const Me = z === "left" ? -200 : 200;
@@ -2570,12 +2574,12 @@ function to({
2570
2574
  if (!e) return null;
2571
2575
  const we = [
2572
2576
  "ctr-bar",
2573
- Be && "show"
2574
- ].filter(Boolean).join(" "), rt = D || j;
2577
+ De && "show"
2578
+ ].filter(Boolean).join(" "), rt = B || j;
2575
2579
  return /* @__PURE__ */ _(
2576
2580
  "div",
2577
2581
  {
2578
- className: `ctr-bar-wrapper ${Be ? "show" : ""}`,
2582
+ className: `ctr-bar-wrapper ${De ? "show" : ""}`,
2579
2583
  onFocus: (z) => {
2580
2584
  z.target instanceof HTMLSelectElement && y?.(!0);
2581
2585
  },
@@ -2588,18 +2592,18 @@ function to({
2588
2592
  children: [
2589
2593
  /* @__PURE__ */ _("div", { ref: S, className: we, children: [
2590
2594
  w && /* @__PURE__ */ _("div", { className: "cluster", children: [
2591
- /* @__PURE__ */ d(Gi, {}),
2592
- T && /* @__PURE__ */ d(kr, {}),
2593
- /* @__PURE__ */ d(Wi, {})
2595
+ /* @__PURE__ */ d(Vi, {}),
2596
+ T && /* @__PURE__ */ d(Ar, {}),
2597
+ /* @__PURE__ */ d(Ki, {})
2594
2598
  ] }),
2595
- /* @__PURE__ */ d("div", { className: "cluster-seek", children: /* @__PURE__ */ d(Ji, { durationMs: n, displayPlayheadMs: g }) }),
2599
+ /* @__PURE__ */ d("div", { className: "cluster-seek", children: /* @__PURE__ */ d(qi, { durationMs: n, displayPlayheadMs: g }) }),
2596
2600
  /* @__PURE__ */ _("div", { className: "cluster", children: [
2597
- /* @__PURE__ */ d(Qi, { videoRef: t }),
2601
+ /* @__PURE__ */ d(Yi, { videoRef: t }),
2598
2602
  s.length > 1 && /* @__PURE__ */ _(Se, { children: [
2599
2603
  /* @__PURE__ */ d("div", { className: "w-px h-5 bg-white/20" }),
2600
2604
  " ",
2601
2605
  /* @__PURE__ */ d(
2602
- qi,
2606
+ Xi,
2603
2607
  {
2604
2608
  tracks: s,
2605
2609
  selectedIndex: i,
@@ -2610,7 +2614,7 @@ function to({
2610
2614
  ] }),
2611
2615
  l.length > 0 && /* @__PURE__ */ _("div", { className: "cluster", children: [
2612
2616
  /* @__PURE__ */ d(
2613
- Yi,
2617
+ Zi,
2614
2618
  {
2615
2619
  tracks: l,
2616
2620
  selectedIndex: o,
@@ -2620,7 +2624,7 @@ function to({
2620
2624
  }
2621
2625
  ),
2622
2626
  /* @__PURE__ */ d(
2623
- Zi,
2627
+ to,
2624
2628
  {
2625
2629
  style: p,
2626
2630
  onStyleChange: v,
@@ -2636,15 +2640,15 @@ function to({
2636
2640
  onDrop: W.onDrop,
2637
2641
  onDragOver: W.onDragOver,
2638
2642
  children: [
2639
- /* @__PURE__ */ d(dr, { pending: W.pending, uploading: W.uploading, onRemove: W.remove }),
2643
+ /* @__PURE__ */ d(fr, { pending: W.pending, uploading: W.uploading, onRemove: W.remove }),
2640
2644
  /* @__PURE__ */ d(
2641
- er,
2645
+ nr,
2642
2646
  {
2643
2647
  open: re,
2644
2648
  onClose: () => le(!1),
2645
2649
  onPick: W.addMeme,
2646
2650
  onUnavailable: () => {
2647
- Ve(!0), le(!1);
2651
+ Ke(!0), le(!1);
2648
2652
  }
2649
2653
  }
2650
2654
  ),
@@ -2655,7 +2659,7 @@ function to({
2655
2659
  type: "text",
2656
2660
  value: X,
2657
2661
  onChange: (z) => {
2658
- N(z.target.value.slice(0, jn)), h?.();
2662
+ N(z.target.value.slice(0, Wn)), h?.();
2659
2663
  },
2660
2664
  onKeyDown: (z) => {
2661
2665
  Mt(z);
@@ -2682,27 +2686,27 @@ function to({
2682
2686
  }
2683
2687
  ),
2684
2688
  /* @__PURE__ */ _("div", { className: "cluster cluster-tight", children: [
2685
- R && /* @__PURE__ */ d(_r, { className: "ctr-btn" }),
2686
- /* @__PURE__ */ d(eo, { videoRef: t })
2689
+ R && /* @__PURE__ */ d(Tr, { className: "ctr-btn" }),
2690
+ /* @__PURE__ */ d(no, { videoRef: t })
2687
2691
  ] })
2688
2692
  ] }),
2689
2693
  rt && /* @__PURE__ */ _("div", { className: "ctr-scroll-group", children: [
2690
2694
  /* @__PURE__ */ d(
2691
2695
  "button",
2692
2696
  {
2693
- className: `ctr-scroll-btn ${D ? "visible" : ""}`,
2694
- onClick: () => De("left"),
2697
+ className: `ctr-scroll-btn ${B ? "visible" : ""}`,
2698
+ onClick: () => Be("left"),
2695
2699
  "aria-label": "Scroll left",
2696
- children: /* @__PURE__ */ d(Ai, {})
2700
+ children: /* @__PURE__ */ d(Ii, {})
2697
2701
  }
2698
2702
  ),
2699
2703
  /* @__PURE__ */ d(
2700
2704
  "button",
2701
2705
  {
2702
2706
  className: `ctr-scroll-btn ${j ? "visible" : ""}`,
2703
- onClick: () => De("right"),
2707
+ onClick: () => Be("right"),
2704
2708
  "aria-label": "Scroll right",
2705
- children: /* @__PURE__ */ d(Ti, {})
2709
+ children: /* @__PURE__ */ d(Ci, {})
2706
2710
  }
2707
2711
  )
2708
2712
  ] })
@@ -2710,44 +2714,44 @@ function to({
2710
2714
  }
2711
2715
  );
2712
2716
  }
2713
- const no = 1e3;
2714
- function ro(t) {
2715
- return t.hidden && t.roomPlaying && !t.seekInFlight && !t.ended && !t.localPause && t.sinceUserPauseMs >= no;
2717
+ const so = 1e3;
2718
+ function ao(t) {
2719
+ return t.hidden && t.roomPlaying && !t.seekInFlight && !t.ended && !t.localPause && t.sinceUserPauseMs >= so;
2716
2720
  }
2717
- function so(t, e) {
2721
+ function io(t, e) {
2718
2722
  return e.isLeader ? t === "play" && e.roomPlaying ? { kind: "resync" } : t === "pause" && !e.roomPlaying ? { kind: "none" } : { kind: "control", control: t } : t === "pause" ? { kind: "local-pause" } : e.roomPlaying ? { kind: "resync" } : { kind: "none" };
2719
2723
  }
2720
- const ao = 1e3;
2721
- function io(t) {
2724
+ const oo = 1e3;
2725
+ function co(t) {
2722
2726
  if (!t.roomPlaying || t.seekInFlight) return { kind: "none" };
2723
2727
  const e = t.durationMs > 0 ? Math.min(t.roomMs, t.durationMs) : t.roomMs;
2724
2728
  return Math.abs(e - t.elementMs) > t.driftToleranceMs ? { kind: "seek", targetMs: Math.round(e) } : t.elementPaused ? { kind: "resume" } : { kind: "none" };
2725
2729
  }
2726
- function oo(t, e, n) {
2730
+ function lo(t, e, n) {
2727
2731
  return t.playheadMs + (t.playing ? Math.max(0, n - e) : 0);
2728
2732
  }
2729
- function Tr(t) {
2733
+ function Cr(t) {
2730
2734
  const e = t.split("/").filter(Boolean);
2731
2735
  return e.length >= 2 ? e.slice(-2).join(" ") : e[e.length - 1] || t;
2732
2736
  }
2733
- function co(t) {
2737
+ function uo(t) {
2734
2738
  const e = t.split("/").filter(Boolean), n = [`${e.join("/")}/poster.jpg`];
2735
2739
  return e.length >= 2 && n.push(`${e.slice(0, -1).join("/")}/poster.jpg`), n;
2736
2740
  }
2737
- function lo({ mediaId: t, visible: e }) {
2738
- return t ? /* @__PURE__ */ d("div", { className: `media-title ${e ? "show" : ""}`, children: Tr(t) }) : null;
2741
+ function fo({ mediaId: t, visible: e }) {
2742
+ return t ? /* @__PURE__ */ d("div", { className: `media-title ${e ? "show" : ""}`, children: Cr(t) }) : null;
2739
2743
  }
2740
- const qe = 3, uo = 1e3, fo = 15e3, Z = {
2744
+ const qe = 3, ho = 1e3, po = 15e3, Z = {
2741
2745
  EQUAL: 1e-3,
2742
2746
  POINT: 0.05,
2743
2747
  RANGE: 0.1,
2744
2748
  FALLBACK: 1
2745
2749
  }, $t = 0.5, Pt = 3e3;
2746
2750
  function ct(t, e = {}) {
2747
- const { baseMs: n = uo, capMs: r = fo, jitter: s = 0.25 } = e, i = Math.min(n * Math.pow(2, t - 1), r), a = s > 0 ? Math.round(i * Math.random() * s) : 0;
2751
+ const { baseMs: n = ho, capMs: r = po, jitter: s = 0.25 } = e, i = Math.min(n * Math.pow(2, t - 1), r), a = s > 0 ? Math.round(i * Math.random() * s) : 0;
2748
2752
  return i + a;
2749
2753
  }
2750
- const An = 15, ho = 35e3, po = 2e3, Bt = 10;
2754
+ const In = 15, mo = 35e3, go = 2e3, Dt = 10;
2751
2755
  function Ie(t, e) {
2752
2756
  if (t.length === 0) return 0;
2753
2757
  if (e >= t[t.length - 1].end_ms) return t.length - 1;
@@ -2772,7 +2776,7 @@ function Ye(t, e, n = Z.POINT) {
2772
2776
  if (e >= t.start(r) - n && e <= t.end(r)) return r;
2773
2777
  return -1;
2774
2778
  }
2775
- function Dt(t, e, n, r = Z.RANGE) {
2779
+ function Bt(t, e, n, r = Z.RANGE) {
2776
2780
  const s = e / 1e3, i = n / 1e3;
2777
2781
  for (let a = 0; a < t.length; a++)
2778
2782
  if (t.start(a) < i + r && t.end(a) > s - r) return !0;
@@ -2781,23 +2785,23 @@ function Dt(t, e, n, r = Z.RANGE) {
2781
2785
  function ge(t) {
2782
2786
  return t ? Array.from({ length: t.length }, (e, n) => `${t.start(n).toFixed(2)}-${t.end(n).toFixed(2)}`) : [];
2783
2787
  }
2784
- function mo(t) {
2788
+ function bo(t) {
2785
2789
  if (t.length === 0) return 0;
2786
2790
  const e = t.reduce((r, s) => r + s.bytes, 0), n = t.reduce((r, s) => r + s.durationMs, 0);
2787
2791
  return n === 0 ? 0 : e / n * 1e3;
2788
2792
  }
2789
- const go = 8e5, bo = 4;
2793
+ const yo = 8e5, vo = 4;
2790
2794
  function ot(t) {
2791
2795
  if (t === 0) return 6e4;
2792
- const e = go / t * 1e3 * bo;
2796
+ const e = yo / t * 1e3 * vo;
2793
2797
  return Math.max(3e4, Math.min(12e4, Math.round(e)));
2794
2798
  }
2795
- function Tn(t, e) {
2799
+ function Cn(t, e) {
2796
2800
  for (let n = e; n >= 0; n--)
2797
2801
  if (t[n]?.keyframe) return n;
2798
2802
  return -1;
2799
2803
  }
2800
- function yo(t, e, n, r) {
2804
+ function So(t, e, n, r) {
2801
2805
  const s = t * 1e3 - 100, i = e * 1e3 + 100;
2802
2806
  for (const a of r) {
2803
2807
  const l = n[a];
@@ -2806,7 +2810,7 @@ function yo(t, e, n, r) {
2806
2810
  }
2807
2811
  return !1;
2808
2812
  }
2809
- function vo(t) {
2813
+ function wo(t) {
2810
2814
  const e = [], n = t.replace(/\r\n/g, `
2811
2815
  `).split(`
2812
2816
  `);
@@ -2816,7 +2820,7 @@ function vo(t) {
2816
2820
  for (; r < n.length; ) {
2817
2821
  const s = n[r].trim();
2818
2822
  if (s.includes("-->")) {
2819
- const i = s.split("-->"), a = In(i[0].trim()), l = i[1].trim().split(/\s+/), o = In(l[0]);
2823
+ const i = s.split("-->"), a = Rn(i[0].trim()), l = i[1].trim().split(/\s+/), o = Rn(l[0]);
2820
2824
  let c, u, f;
2821
2825
  for (let v = 1; v < l.length; v++) {
2822
2826
  const g = l[v];
@@ -2855,16 +2859,16 @@ function vo(t) {
2855
2859
  }
2856
2860
  return e;
2857
2861
  }
2858
- function In(t) {
2862
+ function Rn(t) {
2859
2863
  const e = t.split(":");
2860
2864
  if (e.length < 2) return null;
2861
2865
  let n = 0, r, s;
2862
2866
  return e.length === 3 ? (n = parseInt(e[0], 10), r = parseInt(e[1], 10), s = parseFloat(e[2])) : (r = parseInt(e[0], 10), s = parseFloat(e[1])), isNaN(n) || isNaN(r) || isNaN(s) ? null : n * 3600 + r * 60 + s;
2863
2867
  }
2864
- function So(t) {
2868
+ function xo(t) {
2865
2869
  return t.replace(/<\/?[^>]+(>|$)/g, "").replace(/\{[^}]+\}/g, "").replace(/\\N/g, " ").replace(/\s*\n\s*/g, " ").replace(/\s{2,}/g, " ").trim();
2866
2870
  }
2867
- const wo = {
2871
+ const Eo = {
2868
2872
  // Standard CC look: white text with thick black outline stroke
2869
2873
  classic: "text-white [text-shadow:_-2px_-2px_0_#000,_2px_-2px_0_#000,_-2px_2px_0_#000,_2px_2px_0_#000,_0_-2px_0_#000,_0_2px_0_#000,_-2px_0_0_#000,_2px_0_0_#000]",
2870
2874
  // DVD/theater style: yellow text on dark translucent box
@@ -2874,7 +2878,7 @@ const wo = {
2874
2878
  // Accessibility-focused: bold white text on solid black box
2875
2879
  contrast: "text-white font-bold bg-black px-3 py-1"
2876
2880
  };
2877
- function xo({ subtitleUrl: t, videoRef: e, style: n, enabled: r }) {
2881
+ function Mo({ subtitleUrl: t, videoRef: e, style: n, enabled: r }) {
2878
2882
  const [s, i] = $([]), [a, l] = $([]), o = P(null), [c, u] = $(40), [f, p] = $(18), [v, g] = $(t);
2879
2883
  v !== t && (g(t), t || i([])), L(() => {
2880
2884
  if (!t) return;
@@ -2888,7 +2892,7 @@ function xo({ subtitleUrl: t, videoRef: e, style: n, enabled: r }) {
2888
2892
  if (!b.ok) throw new Error(`Failed to fetch subtitles (status ${b.status})`);
2889
2893
  const S = await b.text();
2890
2894
  if (m) return;
2891
- const I = vo(S);
2895
+ const I = wo(S);
2892
2896
  i(I);
2893
2897
  return;
2894
2898
  } catch (b) {
@@ -2928,8 +2932,8 @@ function xo({ subtitleUrl: t, videoRef: e, style: n, enabled: r }) {
2928
2932
  const m = e.current, T = o.current?.parentElement;
2929
2933
  if (!m || !T) return;
2930
2934
  const R = () => {
2931
- const b = T.clientHeight, S = T.clientWidth, I = m.videoWidth || 1920, D = m.videoHeight || 1080, H = Math.min(S / I, b / D), j = D * H, V = (b - j) / 2, X = Math.max(16, j * 0.035), N = Math.max(X * 0.8, j * 0.055);
2932
- u(Math.max(V + N, 40)), p(X);
2935
+ const b = T.clientHeight, S = T.clientWidth, I = m.videoWidth || 1920, B = m.videoHeight || 1080, H = Math.min(S / I, b / B), j = B * H, K = (b - j) / 2, X = Math.max(16, j * 0.035), N = Math.max(X * 0.8, j * 0.055);
2936
+ u(Math.max(K + N, 40)), p(X);
2933
2937
  };
2934
2938
  return R(), window.addEventListener("resize", R), m.addEventListener("loadedmetadata", R), () => {
2935
2939
  window.removeEventListener("resize", R), m.removeEventListener("loadedmetadata", R);
@@ -2958,8 +2962,8 @@ function xo({ subtitleUrl: t, videoRef: e, style: n, enabled: r }) {
2958
2962
  children: /* @__PURE__ */ d(
2959
2963
  "div",
2960
2964
  {
2961
- className: `${R} font-medium max-w-[95%] inline-block antialiased ${wo[n]}`,
2962
- children: So(b.text)
2965
+ className: `${R} font-medium max-w-[95%] inline-block antialiased ${Eo[n]}`,
2966
+ children: xo(b.text)
2963
2967
  }
2964
2968
  )
2965
2969
  },
@@ -2996,7 +3000,7 @@ function xo({ subtitleUrl: t, videoRef: e, style: n, enabled: r }) {
2996
3000
  k(A.bl, A.bc, A.br, { bottom: `${c}px` }, o)
2997
3001
  ] });
2998
3002
  }
2999
- const Eo = 300, Mo = 50, ko = 100, _o = 100, Ao = 100, To = 100;
3003
+ const ko = 300, _o = 50, Ao = 100, To = 100, Io = 100, Co = 100;
3000
3004
  function Ot(t, e) {
3001
3005
  if (t.length === 0) return 0;
3002
3006
  const n = Math.min(Math.floor(e / 100 * t.length), t.length - 1);
@@ -3014,10 +3018,10 @@ function Ne(t) {
3014
3018
  max: Math.round(e[e.length - 1])
3015
3019
  };
3016
3020
  }
3017
- function Le(t, e = Eo) {
3021
+ function Le(t, e = ko) {
3018
3022
  t.length > e && t.splice(0, t.length - e);
3019
3023
  }
3020
- class Io {
3024
+ class Ro {
3021
3025
  // Fetch
3022
3026
  _fetches = [];
3023
3027
  _fetchTimeoutCount = 0;
@@ -3075,11 +3079,11 @@ class Io {
3075
3079
  }
3076
3080
  /** Called when waitForAppend times out. */
3077
3081
  recordAppendTimeout(e, n, r) {
3078
- this._appendTimeouts.push({ index: e, timeoutMs: n, queueDepth: r, ts: performance.now() }), Le(this._appendTimeouts, Mo);
3082
+ this._appendTimeouts.push({ index: e, timeoutMs: n, queueDepth: r, ts: performance.now() }), Le(this._appendTimeouts, _o);
3079
3083
  }
3080
3084
  /** Called when a seek completes (COMPLETED path in _execute). */
3081
3085
  recordSeekCompleted(e, n, r) {
3082
- this._seeks.push({ caller: e, targetMs: n, durationMs: r, ts: performance.now() }), Le(this._seeks, ko);
3086
+ this._seeks.push({ caller: e, targetMs: n, durationMs: r, ts: performance.now() }), Le(this._seeks, Ao);
3083
3087
  }
3084
3088
  /** Called when waitForSeeked resolves via timeout rather than the 'seeked' event. */
3085
3089
  recordWaitForSeekedTimeout() {
@@ -3101,11 +3105,11 @@ class Io {
3101
3105
  this._stallStart && (this._stalls.push({
3102
3106
  ...this._stallStart,
3103
3107
  durationMs: Math.round(performance.now() - this._stallStart.ts)
3104
- }), Le(this._stalls, _o), this._stallStart = null);
3108
+ }), Le(this._stalls, To), this._stallStart = null);
3105
3109
  }
3106
3110
  /** Called from _doEvict with the reason tag passed by the caller. */
3107
3111
  recordEvict(e, n, r) {
3108
- this._evictCounts[e] = (this._evictCounts[e] ?? 0) + 1, this._evicts.push({ reason: e, start: n, end: r, ts: performance.now() }), Le(this._evicts, Ao);
3112
+ this._evictCounts[e] = (this._evictCounts[e] ?? 0) + 1, this._evicts.push({ reason: e, start: n, end: r, ts: performance.now() }), Le(this._evicts, Io);
3109
3113
  }
3110
3114
  /** Called from FragmentManager.reconcileLoadedStates() when the browser's
3111
3115
  * own silent quota eviction is detected (fragments 'loaded' but gone from
@@ -3147,7 +3151,7 @@ class Io {
3147
3151
  },
3148
3152
  audio: {
3149
3153
  driftMs: Ne(this._audioDrifts),
3150
- highDriftCount: this._audioDrifts.filter((c) => c > To).length,
3154
+ highDriftCount: this._audioDrifts.filter((c) => c > Co).length,
3151
3155
  samples: this._audioDrifts.slice(-20).map((c) => Math.round(c))
3152
3156
  },
3153
3157
  stalls: {
@@ -3196,9 +3200,9 @@ class Io {
3196
3200
  this._fetches = [], this._fetchTimeoutCount = 0, this._fetchErrorCount = 0, this._appends = [], this._appendStarts.clear(), this._appendTimeouts = [], this._seeks = [], this._waitForSeekedTimeouts = 0, this._audioDrifts = [], this._stalls = [], this._stallStart = null, this._evictCounts = {}, this._evicts = [], this._browserEvictions = [];
3197
3201
  }
3198
3202
  }
3199
- const oe = new Io();
3200
- Kn("__WP_PERF__", oe);
3201
- class Co {
3203
+ const oe = new Ro();
3204
+ zn("__WP_PERF__", oe);
3205
+ class Fo {
3202
3206
  cache = /* @__PURE__ */ new Map();
3203
3207
  getOrCreate(e) {
3204
3208
  let n = this.cache.get(e);
@@ -3237,8 +3241,8 @@ class Co {
3237
3241
  this.cache.clear();
3238
3242
  }
3239
3243
  }
3240
- const ve = new Co(), Cn = 60, Ro = 5e3;
3241
- class Fo {
3244
+ const ve = new Fo(), Fn = 60, No = 5e3;
3245
+ class Lo {
3242
3246
  constructor(e) {
3243
3247
  this.deps = e;
3244
3248
  }
@@ -3318,7 +3322,7 @@ class Fo {
3318
3322
  if (this.evictStartedAt === 0)
3319
3323
  return this.evictStartedAt = Date.now(), !0;
3320
3324
  const e = Date.now() - this.evictStartedAt;
3321
- return e < Ro ? !0 : (C("buffer", `EVICT-STUCK isEvicting held ${e}ms — clearing; a remove() updateend was lost, eviction was disabled`), oe.recordEvict("stuck-recovered", 0, 0), this._isEvicting = !1, this.evictStartedAt = 0, !1);
3325
+ return e < No ? !0 : (C("buffer", `EVICT-STUCK isEvicting held ${e}ms — clearing; a remove() updateend was lost, eviction was disabled`), oe.recordEvict("stuck-recovered", 0, 0), this._isEvicting = !1, this.evictStartedAt = 0, !1);
3322
3326
  }
3323
3327
  /** Called on dispose, on SourceBuffer error, and on media change
3324
3328
  * (FragmentManager.setIndex) — see the note at that call site. */
@@ -3361,8 +3365,8 @@ class Fo {
3361
3365
  const s = e / 1e3, i = n.buffered, a = this.deps.getPendingSeekTargetMs(), l = a === null ? null : a / 1e3;
3362
3366
  for (let o = 0; o < i.length; o++) {
3363
3367
  const c = i.start(o), u = i.end(o);
3364
- if (c < s - Cn && u > s) {
3365
- const y = s - Cn;
3368
+ if (c < s - Fn && u > s) {
3369
+ const y = s - Fn;
3366
3370
  E("buffer", `EVICT-START [behind-tail-trim] range=${c.toFixed(2)}-${u.toFixed(2)} → trim [${c.toFixed(2)}-${y.toFixed(2)}] playhead=${s.toFixed(2)}`), this._doEvict(c, y, "behind-tail-trim");
3367
3371
  return;
3368
3372
  }
@@ -3483,13 +3487,13 @@ class Ze {
3483
3487
  * hold began. Lets processAppendQueue bound a hold that would otherwise
3484
3488
  * never end — see APPEND_HOLD_MAX_MS. */
3485
3489
  appendHold = null;
3486
- eviction = new Fo({
3490
+ eviction = new Lo({
3487
3491
  getFragments: () => this.fragments,
3488
3492
  getSourceBuffer: () => this.sourceBuffer,
3489
3493
  getMediaSource: () => this.mediaSource,
3490
3494
  isDisposed: () => this.disposed,
3491
3495
  fragmentStates: this.fragmentStates,
3492
- getPendingSeekTargetMs: () => this.pendingSeekTargetMs !== null && Date.now() - this.pendingSeekSetAtMs > ho ? null : this.pendingSeekTargetMs
3496
+ getPendingSeekTargetMs: () => this.pendingSeekTargetMs !== null && Date.now() - this.pendingSeekSetAtMs > mo ? null : this.pendingSeekTargetMs
3493
3497
  });
3494
3498
  lastGapWarnMs = 0;
3495
3499
  stableGapSignature = null;
@@ -3515,7 +3519,7 @@ class Ze {
3515
3519
  // timing, and APPEND-HOLD reason counts. Read by emitInitDigest() which warns
3516
3520
  // once at gate-pass time so the load shape is visible in session logs without
3517
3521
  // wp:reportLogs=true.
3518
- static INIT_TRACK_FRAGS = Es;
3522
+ static INIT_TRACK_FRAGS = ks;
3519
3523
  loadStartTs = 0;
3520
3524
  initFetchStart = 0;
3521
3525
  initFetchEnd = 0;
@@ -3590,8 +3594,8 @@ class Ze {
3590
3594
  * `fragment-route.realmedia.test.ts`; this is the client-side backstop.
3591
3595
  */
3592
3596
  async tryFragmentRoute(e, n, r) {
3593
- if (this.fragmentRouteDisabled || !this.delivery || !Ms()) return null;
3594
- const s = ks(this.delivery, e);
3597
+ if (this.fragmentRouteDisabled || !this.delivery || !_s()) return null;
3598
+ const s = As(this.delivery, e);
3595
3599
  if (!s)
3596
3600
  return this.disableFragmentRoute(e, "could not build a URL for this config"), null;
3597
3601
  try {
@@ -3718,14 +3722,14 @@ class Ze {
3718
3722
  }
3719
3723
  this.initAppendDone = performance.now(), this.initState = "loaded", this.initRetryCount = 0, E("buffer", `INIT-LOADED sbRanges=[${ge(this.sourceBuffer?.buffered).join(", ")}]`), this.processAppendQueue();
3720
3724
  } catch (l) {
3721
- ee("buffer", "Init segment fetch/append failed", { error: l.message }), a() || (this.initState = "pending", this.initRetryCount += 1, this.initRetryCount >= _s ? (this.initFailed = !0, C("buffer", "INIT-GIVE-UP — init segment failed repeatedly; rejecting waiters for fast recovery", {
3725
+ ee("buffer", "Init segment fetch/append failed", { error: l.message }), a() || (this.initState = "pending", this.initRetryCount += 1, this.initRetryCount >= Ts ? (this.initFailed = !0, C("buffer", "INIT-GIVE-UP — init segment failed repeatedly; rejecting waiters for fast recovery", {
3722
3726
  attempts: this.initRetryCount,
3723
3727
  error: l.message
3724
3728
  }), this.rejectAllWaiters(new Error("init segment failed after repeated retries"))) : this.disposed || setTimeout(() => {
3725
3729
  !this.disposed && this.initState === "pending" && this.fetchInit().catch((o) => {
3726
3730
  ee("buffer", "INIT-RETRY failed", Y(o));
3727
3731
  });
3728
- }, As));
3732
+ }, Is));
3729
3733
  }
3730
3734
  }
3731
3735
  /** Runs inside updateend after an append completes. Decides whether MSE
@@ -3813,7 +3817,7 @@ class Ze {
3813
3817
  ]), r = [], s = this.currentPlayheadMs / 1e3;
3814
3818
  for (let l = 1; l < e.buffered.length; l++) {
3815
3819
  const o = e.buffered.end(l - 1), c = e.buffered.start(l);
3816
- c <= s || yo(o, c, this.fragments, n) || r.push(`${o.toFixed(2)}-${c.toFixed(2)}`);
3820
+ c <= s || So(o, c, this.fragments, n) || r.push(`${o.toFixed(2)}-${c.toFixed(2)}`);
3817
3821
  }
3818
3822
  if (r.length === 0) {
3819
3823
  this.stableGapSignature = null, this.stableGapSince = 0;
@@ -3967,7 +3971,7 @@ class Ze {
3967
3971
  for (const [s, i] of this.fragmentStates) {
3968
3972
  if (i !== "loaded") continue;
3969
3973
  const a = this.fragments[s];
3970
- a && (Dt(e, a.start_ms, a.end_ms) || (this.fragmentStates.set(s, "pending"), n.push(s)));
3974
+ a && (Bt(e, a.start_ms, a.end_ms) || (this.fragmentStates.set(s, "pending"), n.push(s)));
3971
3975
  }
3972
3976
  if (n.length === 0) return;
3973
3977
  const r = ge(e).join(", ") || "(none)";
@@ -3986,7 +3990,7 @@ class Ze {
3986
3990
  if (this.isBuffered(e)) return { status: "buffered", fragmentIndex: n };
3987
3991
  const r = this.currentJobs.get(n);
3988
3992
  if (r) return { status: "loading", fragmentIndex: n, existingPromise: r.promise };
3989
- const s = Math.max(0, n - An), i = Math.min(this.fragments.length - 1, n + An);
3993
+ const s = Math.max(0, n - In), i = Math.min(this.fragments.length - 1, n + In);
3990
3994
  for (let a = s; a <= i; a++) {
3991
3995
  const l = this.fragmentStates.get(a);
3992
3996
  if (l === "loaded" || l === "loading") return { status: "nearby-pending", fragmentIndex: n };
@@ -4015,7 +4019,7 @@ class Ze {
4015
4019
  for (let y = l; y <= h; y++)
4016
4020
  this.discardCounts.delete(y), this.fetchErrorCycles.delete(y);
4017
4021
  }
4018
- const o = tn(this.fragments, e), c = this.fragments[o], u = c && this.sourceBuffer?.buffered && Dt(this.sourceBuffer.buffered, c.start_ms, c.end_ms), f = u ? l : o, p = s ? Math.min(this.fragments.length - 1, l + 1) : Ie(this.fragments, e + Ce);
4022
+ const o = tn(this.fragments, e), c = this.fragments[o], u = c && this.sourceBuffer?.buffered && Bt(this.sourceBuffer.buffered, c.start_ms, c.end_ms), f = u ? l : o, p = s ? Math.min(this.fragments.length - 1, l + 1) : Ie(this.fragments, e + Ce);
4019
4023
  this.initRange && this.initState !== "loaded" && await this.fetchInit();
4020
4024
  const v = [], g = [];
4021
4025
  for (let h = f; h <= p; h++) {
@@ -4123,7 +4127,7 @@ class Ze {
4123
4127
  bytes: p.buf.byteLength,
4124
4128
  ttfbMs: p.ttfbMs,
4125
4129
  cf: p.cfStatus
4126
- }), E("buffer", `FETCH-OK #${e} [${i}] ${p.buf.byteLength}B in ${Math.round(k)}ms via=frag-route (ttfb=${p.ttfbMs}ms cf=${p.cfStatus || "-"})`), k > 0 && (this.downloadSamples.push({ bytes: p.buf.byteLength, durationMs: k }), this.downloadSamples.length > Bt && this.downloadSamples.shift(), oe.recordFetch(e, p.buf.byteLength, k)), this.disposed || this.mediaUrl !== f) {
4130
+ }), E("buffer", `FETCH-OK #${e} [${i}] ${p.buf.byteLength}B in ${Math.round(k)}ms via=frag-route (ttfb=${p.ttfbMs}ms cf=${p.cfStatus || "-"})`), k > 0 && (this.downloadSamples.push({ bytes: p.buf.byteLength, durationMs: k }), this.downloadSamples.length > Dt && this.downloadSamples.shift(), oe.recordFetch(e, p.buf.byteLength, k)), this.disposed || this.mediaUrl !== f) {
4127
4131
  E("buffer", `FETCH-STALE #${e} discarding frag-route bytes (mediaUrl changed)`);
4128
4132
  return;
4129
4133
  }
@@ -4166,7 +4170,7 @@ class Ze {
4166
4170
  return;
4167
4171
  }
4168
4172
  const F = performance.now() - c;
4169
- if (this.isInInitPhase() && this.recordInitFragEvent(e, { fetchEnd: performance.now(), bytes: A.byteLength, ttfbMs: h, cf: y }), E("buffer", `FETCH-OK #${e} [${i}] ${A.byteLength}B in ${Math.round(F)}ms (ttfb=${h}ms cf=${y || "-"}) (${(A.byteLength / F * 1e3 / 1024).toFixed(0)} KB/s)`), F > 0 && (this.downloadSamples.push({ bytes: A.byteLength, durationMs: F }), this.downloadSamples.length > Bt && this.downloadSamples.shift(), oe.recordFetch(e, A.byteLength, F)), this.disposed || this.mediaUrl !== v) {
4173
+ if (this.isInInitPhase() && this.recordInitFragEvent(e, { fetchEnd: performance.now(), bytes: A.byteLength, ttfbMs: h, cf: y }), E("buffer", `FETCH-OK #${e} [${i}] ${A.byteLength}B in ${Math.round(F)}ms (ttfb=${h}ms cf=${y || "-"}) (${(A.byteLength / F * 1e3 / 1024).toFixed(0)} KB/s)`), F > 0 && (this.downloadSamples.push({ bytes: A.byteLength, durationMs: F }), this.downloadSamples.length > Dt && this.downloadSamples.shift(), oe.recordFetch(e, A.byteLength, F)), this.disposed || this.mediaUrl !== v) {
4170
4174
  E("buffer", `FETCH-STALE #${e} discarding (mediaUrl changed)`);
4171
4175
  return;
4172
4176
  }
@@ -4179,7 +4183,7 @@ class Ze {
4179
4183
  }
4180
4184
  if ((c.name === "TimeoutError" || c.message?.includes("signal timed out") || c.message?.includes("The operation was aborted")) && c.name !== "AbortError") {
4181
4185
  const f = ot(this.getAverageDownloadRate());
4182
- this.downloadSamples.push({ bytes: 0, durationMs: f }), this.downloadSamples.length > Bt && this.downloadSamples.shift(), oe.recordFetchTimeout(e), C("buffer", `FETCH-ERR #${e} [${i}] attempt=${o} timeout=${f}ms avgRate=${Math.round(this.getAverageDownloadRate())}Bps error=${c.message}`);
4186
+ this.downloadSamples.push({ bytes: 0, durationMs: f }), this.downloadSamples.length > Dt && this.downloadSamples.shift(), oe.recordFetchTimeout(e), C("buffer", `FETCH-ERR #${e} [${i}] attempt=${o} timeout=${f}ms avgRate=${Math.round(this.getAverageDownloadRate())}Bps error=${c.message}`);
4183
4187
  } else
4184
4188
  C("buffer", `FETCH-ERR #${e} [${i}] attempt=${o} error=${c.message}`);
4185
4189
  if (this.isInInitPhase() && this.recordInitFragEvent(e, { err: (c.name === "TimeoutError" ? "timeout" : c.message?.slice(0, 40)) || "err" }), this.fragmentStates.set(e, "pending"), o < qe) {
@@ -4211,10 +4215,10 @@ class Ze {
4211
4215
  if (e <= 0 || this.fragments.length === 0 || this.fragments[0].keyframe === void 0) return !1;
4212
4216
  const n = this.fragments[e];
4213
4217
  if (!n || n.keyframe) return !1;
4214
- const r = Tn(this.fragments, e - 1);
4218
+ const r = Cn(this.fragments, e - 1);
4215
4219
  if (r < 0 || this.fragmentStates.get(r) !== "error") return !1;
4216
4220
  const s = this.fragments[r];
4217
- if (this.sourceBuffer ? Dt(this.sourceBuffer.buffered, s.start_ms, s.end_ms) : !1) return !1;
4221
+ if (this.sourceBuffer ? Bt(this.sourceBuffer.buffered, s.start_ms, s.end_ms) : !1) return !1;
4218
4222
  const a = [], l = [];
4219
4223
  for (const o of this.appendQueue) {
4220
4224
  const c = this.fragments[o.index];
@@ -4222,7 +4226,7 @@ class Ze {
4222
4226
  l.push(o);
4223
4227
  continue;
4224
4228
  }
4225
- Tn(this.fragments, o.index - 1) === r ? (a.push(o.index), this.fragmentStates.set(o.index, "pending")) : l.push(o);
4229
+ Cn(this.fragments, o.index - 1) === r ? (a.push(o.index), this.fragmentStates.set(o.index, "pending")) : l.push(o);
4226
4230
  }
4227
4231
  return a.length === 0 ? !1 : (this.appendQueue = l, C("buffer", `APPEND-DROP-DEPENDENT [${a.join(",")}] — keyframe #${r} in error, not in SB`, {
4228
4232
  kfIdx: r,
@@ -4253,7 +4257,7 @@ class Ze {
4253
4257
  if (this.appendHold?.index !== e)
4254
4258
  return this.appendHold = { index: e, since: r }, !1;
4255
4259
  const s = r - this.appendHold.since;
4256
- if (s < Ts) return !1;
4260
+ if (s < Cs) return !1;
4257
4261
  C("buffer", `APPEND-HOLD-BREAK #${e} held ${s}ms behind ${n.length} pending fetch(es) — declaring them dead so the queue can drain`, {
4258
4262
  headIndex: e,
4259
4263
  heldMs: s,
@@ -4317,7 +4321,7 @@ class Ze {
4317
4321
  if (this.disposed || !this.sourceBuffer || (this.currentPlayheadMs = e, this.currentJobs.size >= ze)) return;
4318
4322
  const n = Ie(this.fragments, e), r = Math.min(this.fragments.length - 1, Ie(this.fragments, e + Xe)), s = Date.now();
4319
4323
  for (let a = n; a <= r; a++)
4320
- this.fragmentStates.get(a) === "error" && s - (this.errorTimestamps.get(a) ?? 0) >= Is && ((this.fetchErrorCycles.get(a) ?? 0) >= hn ? E("buffer", `PREFETCH-DEAD #${a} cycles=${this.fetchErrorCycles.get(a)} not resetting`) : (this.fragmentStates.set(a, "pending"), this.errorTimestamps.delete(a)));
4324
+ this.fragmentStates.get(a) === "error" && s - (this.errorTimestamps.get(a) ?? 0) >= Rs && ((this.fetchErrorCycles.get(a) ?? 0) >= hn ? E("buffer", `PREFETCH-DEAD #${a} cycles=${this.fetchErrorCycles.get(a)} not resetting`) : (this.fragmentStates.set(a, "pending"), this.errorTimestamps.delete(a)));
4321
4325
  let i = 0;
4322
4326
  for (let a = n; a <= r && i < ze - this.currentJobs.size; a++) {
4323
4327
  const l = this.fragmentStates.get(a);
@@ -4348,7 +4352,7 @@ class Ze {
4348
4352
  /** Public eviction entry point used by MediaPlayer / prefetch. Delegates
4349
4353
  * to the strategy which owns the isEvicting state + range choice logic. */
4350
4354
  evictBefore(e) {
4351
- this.pendingSeekTargetMs !== null && Math.abs(e - this.pendingSeekTargetMs) <= po && (this.pendingSeekTargetMs = null), this.eviction.evictBefore(e);
4355
+ this.pendingSeekTargetMs !== null && Math.abs(e - this.pendingSeekTargetMs) <= go && (this.pendingSeekTargetMs = null), this.eviction.evictBefore(e);
4352
4356
  }
4353
4357
  // Public entry point for socket reconnect scenarios. Clears stale in-flight
4354
4358
  // fetches and their pendingFetchIndices entries so the queue is unblocked on
@@ -4496,7 +4500,7 @@ class Ze {
4496
4500
  return { ranges: e, gaps: e.length > 1, fragmentStates: n };
4497
4501
  }
4498
4502
  getAverageDownloadRate() {
4499
- return mo(this.downloadSamples);
4503
+ return bo(this.downloadSamples);
4500
4504
  }
4501
4505
  /** Nominal media end time (ms) = last fragment's end. 0 if no index loaded.
4502
4506
  * Reported in health so the leader's status card can tell "near end-of-stream,
@@ -4570,7 +4574,7 @@ class Ze {
4570
4574
  if (this.eosRetryTimer) return;
4571
4575
  this.eosRetryTimer = setTimeout(() => {
4572
4576
  this.eosRetryTimer = null, this.tryEndOfStream();
4573
- }, Cs);
4577
+ }, Fs);
4574
4578
  return;
4575
4579
  }
4576
4580
  try {
@@ -4583,28 +4587,28 @@ class Ze {
4583
4587
  this.disposed = !0, this.eosRetryTimer && (clearTimeout(this.eosRetryTimer), this.eosRetryTimer = null), this.pendingEndOfStream = !1, this.abortAllJobs("dispose"), this.rejectAllWaiters(new Error("FragmentManager disposed")), this.appendQueue = [], this.isAppending = !1, this.eviction.reset(), this.appendingIndex = null, this.fragmentStates.clear(), this.errorTimestamps.clear(), this.discardCounts.clear(), this.fetchErrorCycles.clear(), this.downloadSamples = [], this.preAppendRanges = [], this.sourceBuffer = null, this.mediaSource = null, this.initState = "pending", this.initRange = null;
4584
4588
  }
4585
4589
  }
4586
- function No(t, e) {
4590
+ function $o(t, e) {
4587
4591
  return !!t && t !== "eng" && e;
4588
4592
  }
4589
- function Lo(t) {
4590
- return t.override !== null ? t.override : t.globalEnabled || No(t.selectedAudioLang, t.hasEngSub);
4593
+ function Po(t) {
4594
+ return t.override !== null ? t.override : t.globalEnabled || $o(t.selectedAudioLang, t.hasEngSub);
4591
4595
  }
4592
- const Ir = "wp_reload_history", nn = "wp_phantom_reload", Cr = 5 * 6e4, Rn = 3;
4593
- function $o() {
4596
+ const Rr = "wp_reload_history", nn = "wp_phantom_reload", Fr = 5 * 6e4, Nn = 3;
4597
+ function Do() {
4594
4598
  try {
4595
- const t = sessionStorage.getItem(Ir);
4596
- return (t ? JSON.parse(t) : []).filter((n) => Date.now() - n < Cr);
4599
+ const t = sessionStorage.getItem(Rr);
4600
+ return (t ? JSON.parse(t) : []).filter((n) => Date.now() - n < Fr);
4597
4601
  } catch {
4598
4602
  return [];
4599
4603
  }
4600
4604
  }
4601
4605
  function zt(t, e) {
4602
- const n = $o();
4603
- if (n.length >= Rn) {
4606
+ const n = Do();
4607
+ if (n.length >= Nn) {
4604
4608
  pn(
4605
4609
  "error",
4606
4610
  "buffer",
4607
- `AUTO-RELOAD SUPPRESSED reason=${t} — ${n.length} reloads in ${Cr / 6e4}m, giving up (connection looks unstable)`,
4611
+ `AUTO-RELOAD SUPPRESSED reason=${t} — ${n.length} reloads in ${Fr / 6e4}m, giving up (connection looks unstable)`,
4608
4612
  e
4609
4613
  );
4610
4614
  try {
@@ -4617,17 +4621,17 @@ function zt(t, e) {
4617
4621
  return !1;
4618
4622
  }
4619
4623
  try {
4620
- n.push(Date.now()), sessionStorage.setItem(Ir, JSON.stringify(n)), sessionStorage.setItem(nn, String(Date.now()));
4624
+ n.push(Date.now()), sessionStorage.setItem(Rr, JSON.stringify(n)), sessionStorage.setItem(nn, String(Date.now()));
4621
4625
  } catch {
4622
4626
  }
4623
- pn("error", "buffer", `AUTO-RELOAD reason=${t} attempt=${n.length}/${Rn}`, e);
4627
+ pn("error", "buffer", `AUTO-RELOAD reason=${t} attempt=${n.length}/${Nn}`, e);
4624
4628
  try {
4625
4629
  window.location.reload();
4626
4630
  } catch {
4627
4631
  }
4628
4632
  return !0;
4629
4633
  }
4630
- function Fn() {
4634
+ function Ln() {
4631
4635
  try {
4632
4636
  const t = sessionStorage.getItem(nn);
4633
4637
  return t ? Number(t) : null;
@@ -4635,13 +4639,13 @@ function Fn() {
4635
4639
  return null;
4636
4640
  }
4637
4641
  }
4638
- function Po() {
4642
+ function Bo() {
4639
4643
  try {
4640
4644
  sessionStorage.removeItem(nn);
4641
4645
  } catch {
4642
4646
  }
4643
4647
  }
4644
- function Bo() {
4648
+ function Oo() {
4645
4649
  const t = navigator;
4646
4650
  try {
4647
4651
  return typeof t.getAutoplayPolicy == "function" ? t.getAutoplayPolicy("mediaelement") : void 0;
@@ -4649,20 +4653,20 @@ function Bo() {
4649
4653
  return;
4650
4654
  }
4651
4655
  }
4652
- function Do(t, e) {
4656
+ function Ho(t, e) {
4653
4657
  return t === "disallowed" ? "deferred" : e ? "user-muted" : t === "allowed-muted" ? "muted-bridge" : "audible";
4654
4658
  }
4655
- function Rr(t, e) {
4656
- const n = Bo(), r = Do(n, e.userWantsMuted);
4659
+ function Nr(t, e) {
4660
+ const n = Oo(), r = Ho(n, e.userWantsMuted);
4657
4661
  E(e.label, "autoplay plan", { policy: n ?? "unknown", plan: r, userWantsMuted: e.userWantsMuted });
4658
4662
  const s = () => {
4659
4663
  t.muted = !0, t.play().then(() => {
4660
- e.onMutedBridge?.(), _n(() => {
4664
+ e.onMutedBridge?.(), Tn(() => {
4661
4665
  e.userWantsMuted || (t.muted = !1, e.onUnmuted?.(), E(e.label, "autoplay bridge unmuted on interaction"));
4662
4666
  });
4663
4667
  }).catch((i) => C(e.label, "muted-bridge play failed", { error: i?.name }));
4664
4668
  };
4665
- return r === "deferred" ? (_n(() => {
4669
+ return r === "deferred" ? (Tn(() => {
4666
4670
  t.play().catch((i) => C(e.label, "deferred play retry failed", { error: i?.name }));
4667
4671
  }), r) : r === "muted-bridge" ? (s(), r) : (t.muted = e.userWantsMuted, t.play().catch((i) => {
4668
4672
  i?.name === "NotAllowedError" && !e.userWantsMuted ? s() : i?.name !== "AbortError" && C(e.label, "video.play() failed", { error: i?.name, message: i?.message });
@@ -4674,7 +4678,7 @@ const ht = {
4674
4678
  /** Room-level seeks from snapshot changes — highest priority. */
4675
4679
  SEEK_EFFECT: 3
4676
4680
  };
4677
- function Fr(t, e = 3e3) {
4681
+ function Lr(t, e = 3e3) {
4678
4682
  return new Promise((n) => {
4679
4683
  if (!t.seeking) {
4680
4684
  n();
@@ -4693,7 +4697,7 @@ function Fr(t, e = 3e3) {
4693
4697
  t.addEventListener("seeked", s, { once: !0 });
4694
4698
  });
4695
4699
  }
4696
- class Oo {
4700
+ class Uo {
4697
4701
  // ── State ──
4698
4702
  _seekInFlight = !1;
4699
4703
  /** Route taken by the in-flight seek (buffered/loading/nearby-pending/far) —
@@ -4772,7 +4776,7 @@ class Oo {
4772
4776
  } else
4773
4777
  E("seek-coord", `ALREADY BUFFERED [${s}] target=${Math.round(r)}ms`);
4774
4778
  const p = r / 1e3;
4775
- a.currentTime = p, await Fr(a), this._checkAborted(n);
4779
+ a.currentTime = p, await Lr(a), this._checkAborted(n);
4776
4780
  const v = a.currentTime * 1e3, g = Math.round(performance.now() - o);
4777
4781
  C("seek-coord", `SEEK-DIGEST [${s}] route=${this._lastSeekRoute} ${g}ms`, {
4778
4782
  targetMs: Math.round(r),
@@ -4876,7 +4880,7 @@ class Oo {
4876
4880
  }
4877
4881
  _resume(e) {
4878
4882
  const n = x.getState();
4879
- Rr(e, {
4883
+ Nr(e, {
4880
4884
  userWantsMuted: n.mediaPrefs.muted,
4881
4885
  onMutedBridge: () => x.getState().setMutedForAutoplay(!0),
4882
4886
  onUnmuted: () => x.getState().setMutedForAutoplay(!1),
@@ -4885,14 +4889,14 @@ class Oo {
4885
4889
  }
4886
4890
  }
4887
4891
  let lt = null;
4888
- function Ho() {
4889
- lt === null && (E("health", "Starting health reporting"), Nn(), lt = window.setInterval(Nn, Rs));
4892
+ function jo() {
4893
+ lt === null && (E("health", "Starting health reporting"), $n(), lt = window.setInterval($n, Ns));
4890
4894
  }
4891
- function Uo() {
4895
+ function Go() {
4892
4896
  lt !== null && (E("health", "Stopping health reporting"), window.clearInterval(lt), lt = null);
4893
4897
  }
4894
- function Nn() {
4895
- const t = Jn();
4898
+ function $n() {
4899
+ const t = qn();
4896
4900
  if (!t.connected) return;
4897
4901
  const e = x.getState();
4898
4902
  if (!e.snapshot.mediaId) return;
@@ -4910,7 +4914,7 @@ function Nn() {
4910
4914
  (o < 0 || v < o) && (o = v);
4911
4915
  }
4912
4916
  const c = Math.max(0, a - s), u = o < 0 ? c : Math.min(c, o), f = e.drift.rtts.length > 0 ? e.drift.rtts.reduce((p, v) => p + v, 0) / e.drift.rtts.length : 0;
4913
- t.emit(Qn.HEALTH_REPORT, {
4917
+ t.emit(Yn.HEALTH_REPORT, {
4914
4918
  avg_download_rate_bps: n.getAverageDownloadRate(),
4915
4919
  buffered_ahead_ms: u,
4916
4920
  audio_buffered_ahead_ms: o < 0 ? -1 : Math.round(o),
@@ -4922,13 +4926,13 @@ function Nn() {
4922
4926
  fragments_error: i.fragmentStates.error || 0,
4923
4927
  video_ready_state: r?.readyState ?? -1,
4924
4928
  duration_ms: n.getMediaEndMs(),
4925
- delivery_arm: Ns(),
4926
- ...jo(r),
4927
- pong_age_ms: Fs(),
4929
+ delivery_arm: $s(),
4930
+ ...Wo(r),
4931
+ pong_age_ms: Ls(),
4928
4932
  reported_at: Date.now()
4929
4933
  });
4930
4934
  }
4931
- function jo(t) {
4935
+ function Wo(t) {
4932
4936
  const e = typeof navigator > "u" ? void 0 : navigator, n = e?.connection;
4933
4937
  return {
4934
4938
  page_visible: typeof document.visibilityState == "string" ? document.visibilityState === "visible" : void 0,
@@ -4940,8 +4944,8 @@ function jo(t) {
4940
4944
  net_downlink_mbps: typeof n?.downlink == "number" && n.downlink >= 0 ? n.downlink : void 0
4941
4945
  };
4942
4946
  }
4943
- const Go = 3e3;
4944
- function Wo() {
4947
+ const Vo = 3e3;
4948
+ function Ko() {
4945
4949
  const [t, e] = $(!1), n = P(null), r = P(!1), s = () => {
4946
4950
  n.current && (clearTimeout(n.current), n.current = null);
4947
4951
  }, i = U((o = 3e3) => {
@@ -4951,7 +4955,7 @@ function Wo() {
4951
4955
  }, []), a = U(() => {
4952
4956
  r.current || (s(), e(!1));
4953
4957
  }, []), l = U((o) => {
4954
- r.current !== o && (r.current = o, o ? (s(), e(!0)) : i(Go));
4958
+ r.current !== o && (r.current = o, o ? (s(), e(!0)) : i(Vo));
4955
4959
  }, [i]);
4956
4960
  return L(() => {
4957
4961
  const o = () => {
@@ -4962,27 +4966,27 @@ function Wo() {
4962
4966
  };
4963
4967
  }, [i]), { controlsVisible: t, showControls: i, hideControls: a, setControlsHeld: l };
4964
4968
  }
4965
- const Nr = [], Lr = [], Ko = {
4966
- fragments: Nr,
4969
+ const $r = [], Pr = [], zo = {
4970
+ fragments: $r,
4967
4971
  durationMs: null,
4968
4972
  mseCodec: null,
4969
4973
  initSegment: void 0,
4970
- audioTracks: Lr,
4974
+ audioTracks: Pr,
4971
4975
  contentToken: null
4972
4976
  };
4973
- function Vo(t, e) {
4974
- if (!t || t.url !== e) return Ko;
4977
+ function Jo(t, e) {
4978
+ if (!t || t.url !== e) return zo;
4975
4979
  const n = t.data;
4976
4980
  return {
4977
- fragments: n.fragments || Nr,
4981
+ fragments: n.fragments || $r,
4978
4982
  durationMs: n.duration_ms || null,
4979
4983
  mseCodec: n.mse_codec || null,
4980
4984
  initSegment: n.init_segment || void 0,
4981
- audioTracks: n.audio_tracks || Lr,
4985
+ audioTracks: n.audio_tracks || Pr,
4982
4986
  contentToken: n.content_token || null
4983
4987
  };
4984
4988
  }
4985
- function Ln(t) {
4989
+ function Pn(t) {
4986
4990
  try {
4987
4991
  const e = performance.getEntriesByName(t, "resource");
4988
4992
  if (!e.length) return null;
@@ -5000,7 +5004,7 @@ function Ln(t) {
5000
5004
  return null;
5001
5005
  }
5002
5006
  }
5003
- function zo(t) {
5007
+ function Qo(t) {
5004
5008
  const [e, n] = $(null);
5005
5009
  return L(() => {
5006
5010
  const r = new AbortController();
@@ -5021,7 +5025,7 @@ function zo(t) {
5021
5025
  const u = await o.text(), f = Math.round(performance.now() - l) - c, p = JSON.parse(u), v = Math.round(performance.now() - l) - c - f, g = c + f + v;
5022
5026
  if (r.signal.aborted) return;
5023
5027
  n({ url: t, data: p });
5024
- const h = Ln(t);
5028
+ const h = Pn(t);
5025
5029
  E("mse", "Index loaded", {
5026
5030
  attempt: i + 1,
5027
5031
  headerMs: c,
@@ -5039,7 +5043,7 @@ function zo(t) {
5039
5043
  } catch (o) {
5040
5044
  if (r.signal.aborted) return;
5041
5045
  i++;
5042
- const c = Math.round(performance.now() - l), u = Ln(t);
5046
+ const c = Math.round(performance.now() - l), u = Pn(t);
5043
5047
  C("mse", `Index fetch attempt ${i} failed (${c}ms)`, {
5044
5048
  error: o?.message,
5045
5049
  elapsedMs: c,
@@ -5053,7 +5057,7 @@ function zo(t) {
5053
5057
  return s(), () => {
5054
5058
  r.abort();
5055
5059
  };
5056
- }, [t]), Ee(() => Vo(e, t), [e, t]);
5060
+ }, [t]), Ee(() => Jo(e, t), [e, t]);
5057
5061
  }
5058
5062
  const Ht = {
5059
5063
  audioTracks: [],
@@ -5061,10 +5065,10 @@ const Ht = {
5061
5065
  selectedAudioIndex: 0,
5062
5066
  selectedSubtitleIndex: 0
5063
5067
  };
5064
- function Jo(t) {
5065
- const [e, n] = $(Ht), r = Ls(), s = x((u) => u.mediaPrefs.preferredAudioLang), [i, a] = $(t);
5068
+ function qo(t) {
5069
+ const [e, n] = $(Ht), r = Ps(), s = x((u) => u.mediaPrefs.preferredAudioLang), [i, a] = $(t);
5066
5070
  i !== t && (a(t), t && n(Ht));
5067
- const l = fe(() => ({ origin: $s(r), preferredAudioLang: s }));
5071
+ const l = fe(() => ({ origin: Ds(r), preferredAudioLang: s }));
5068
5072
  L(() => {
5069
5073
  if (!t) return;
5070
5074
  const u = new AbortController(), { origin: f, preferredAudioLang: p } = l();
@@ -5097,12 +5101,12 @@ function Jo(t) {
5097
5101
  setSelectedSubtitleIndex: c
5098
5102
  };
5099
5103
  }
5100
- const Qo = 100;
5101
- function qo(t) {
5102
- return !t.roomPlaying || t.videoPaused ? "not-playing" : t.seekInFlight ? "seeking" : t.advancedMs > Qo ? "advancing" : "stalled";
5104
+ const Yo = 100;
5105
+ function Xo(t) {
5106
+ return !t.roomPlaying || t.videoPaused ? "not-playing" : t.seekInFlight ? "seeking" : t.advancedMs > Yo ? "advancing" : "stalled";
5103
5107
  }
5104
- const Ut = 4e4, Yo = 3e3;
5105
- function Xo(t, e, n, r, s, i) {
5108
+ const Ut = 4e4, Zo = 3e3;
5109
+ function ec(t, e, n, r, s, i) {
5106
5110
  const a = fe((w) => {
5107
5111
  const A = {};
5108
5112
  return (i?.current ?? []).forEach((k, m) => {
@@ -5127,23 +5131,23 @@ function Xo(t, e, n, r, s, i) {
5127
5131
  function F() {
5128
5132
  A();
5129
5133
  const S = t.current;
5130
- S && (h.current = S.currentTime, g.current = setTimeout(k, Yo));
5134
+ S && (h.current = S.currentTime, g.current = setTimeout(k, Zo));
5131
5135
  }
5132
5136
  function k() {
5133
5137
  g.current = null;
5134
5138
  const S = t.current;
5135
5139
  if (!S) return;
5136
- const I = x.getState(), D = n.current, H = qo({
5140
+ const I = x.getState(), B = n.current, H = Xo({
5137
5141
  roomPlaying: I.snapshot.playing,
5138
5142
  videoPaused: S.paused,
5139
- seekInFlight: !!D?.seekInFlight,
5143
+ seekInFlight: !!B?.seekInFlight,
5140
5144
  advancedMs: (S.currentTime - h.current) * 1e3
5141
5145
  });
5142
5146
  if (H !== "stalled") {
5143
5147
  y.current = null, H !== "not-playing" && F();
5144
5148
  return;
5145
5149
  }
5146
- const j = S.currentTime * 1e3, V = e.current, X = Date.now();
5150
+ const j = S.currentTime * 1e3, K = e.current, X = Date.now();
5147
5151
  y.current === null && (y.current = X);
5148
5152
  const N = X - y.current;
5149
5153
  if (C("sync", "SILENT-STALL playhead frozen with no `waiting` event", {
@@ -5151,25 +5155,25 @@ function Xo(t, e, n, r, s, i) {
5151
5155
  readyState: S.readyState,
5152
5156
  frozenMs: N,
5153
5157
  // Reported for correlation only — see comment above; may look healthy.
5154
- reportedBufferedAheadMs: Math.round(V?.getBufferedAheadMs(j) ?? -1),
5158
+ reportedBufferedAheadMs: Math.round(K?.getBufferedAheadMs(j) ?? -1),
5155
5159
  // Per-track geometry. `reportedBufferedAheadMs` above is VIDEO's and read
5156
5160
  // a healthy 30s through the entire cedar-ridge 2026-08-25 freeze; the
5157
5161
  // starved track only shows up here. A track whose `bufferedEndMs` equals
5158
5162
  // the playhead is the one that stopped the playhead.
5159
- video: V?.getTrackDiag(j),
5163
+ video: K?.getTrackDiag(j),
5160
5164
  ...a(j)
5161
- }), l(j, "silent-stall"), V) {
5162
- V.reconcileLoadedStates();
5163
- const O = V.findNextRangeStart(j, Pt);
5164
- O !== null && D ? (C("sync", "SILENT-STALL gap-skip", {
5165
+ }), l(j, "silent-stall"), K) {
5166
+ K.reconcileLoadedStates();
5167
+ const O = K.findNextRangeStart(j, Pt);
5168
+ O !== null && B ? (C("sync", "SILENT-STALL gap-skip", {
5165
5169
  currentMs: Math.round(j),
5166
5170
  gapSkipTarget: Math.round(O)
5167
- }), D.submit({
5171
+ }), B.submit({
5168
5172
  targetMs: O,
5169
5173
  priority: ht.VIEWER_CORRECTION,
5170
5174
  caller: "silent-stall-gap-skip",
5171
5175
  pauseSeekResume: !1
5172
- }).catch((Q) => ee("sync", "SILENT-STALL gap-skip seek threw", Y(Q)))) : V.fetchNearby(j).catch((Q) => {
5176
+ }).catch((Q) => ee("sync", "SILENT-STALL gap-skip seek threw", Y(Q)))) : K.fetchNearby(j).catch((Q) => {
5173
5177
  const W = Y(Q);
5174
5178
  W.name !== "AbortError" && C("sync", "SILENT-STALL fetchNearby failed", {
5175
5179
  currentMs: Math.round(j),
@@ -5178,11 +5182,11 @@ function Xo(t, e, n, r, s, i) {
5178
5182
  });
5179
5183
  }
5180
5184
  if (N >= Ut) {
5181
- V?.dumpBufferDiagnostics(j, "silent-stall-reload"), zt("silent-stall", {
5185
+ K?.dumpBufferDiagnostics(j, "silent-stall-reload"), zt("silent-stall", {
5182
5186
  frozenMs: N,
5183
5187
  currentTime: +S.currentTime.toFixed(2),
5184
5188
  readyState: S.readyState,
5185
- loaded: V?.getLoadedCount?.() ?? -1
5189
+ loaded: K?.getLoadedCount?.() ?? -1
5186
5190
  }), y.current = null;
5187
5191
  return;
5188
5192
  }
@@ -5194,16 +5198,16 @@ function Xo(t, e, n, r, s, i) {
5194
5198
  function T() {
5195
5199
  const S = w.currentTime * 1e3;
5196
5200
  f.current = Date.now();
5197
- const I = x.getState(), D = I.snapshot.playing, H = !!I.snapshot.leaderId && I.snapshot.leaderId === I.me.clientId, j = I.snapshot.playheadMs + (I.snapshot.playing ? Date.now() - I.snapshotReceivedAt : 0);
5201
+ const I = x.getState(), B = I.snapshot.playing, H = !!I.snapshot.leaderId && I.snapshot.leaderId === I.me.clientId, j = I.snapshot.playheadMs + (I.snapshot.playing ? Date.now() - I.snapshotReceivedAt : 0);
5198
5202
  E("sync", "VIDEO waiting event", {
5199
5203
  currentTime: w.currentTime.toFixed(2),
5200
5204
  readyState: w.readyState,
5201
- playing: D,
5205
+ playing: B,
5202
5206
  isLeader: H,
5203
5207
  serverMsAtStall: Math.round(j)
5204
5208
  }), oe.recordStallStart(S, e.current?.getBufferedAheadMs(S) ?? -1);
5205
- const V = e.current, X = n.current, N = V?.getBufferedAheadMs(S) ?? 0;
5206
- if (V && N < 1e3 && V.dumpBufferDiagnostics(S, "stall-onset"), D && N >= 1e3) {
5209
+ const K = e.current, X = n.current, N = K?.getBufferedAheadMs(S) ?? 0;
5210
+ if (K && N < 1e3 && K.dumpBufferDiagnostics(S, "stall-onset"), B && N >= 1e3) {
5207
5211
  const O = a(S);
5208
5212
  Object.keys(O).length > 0 && C("sync", "STALL-TRACKS video buffer healthy at stall — per-track geometry", {
5209
5213
  currentMs: Math.round(S),
@@ -5211,9 +5215,9 @@ function Xo(t, e, n, r, s, i) {
5211
5215
  ...O
5212
5216
  });
5213
5217
  }
5214
- if (D && !X?.seekInFlight && S > 0 && l(S, "waiting"), D && V && !X?.seekInFlight && S > 0) {
5215
- V.reconcileLoadedStates();
5216
- const O = V.getBufferedAheadMs(S), Q = V.findNextRangeStart(S, Pt);
5218
+ if (B && !X?.seekInFlight && S > 0 && l(S, "waiting"), B && K && !X?.seekInFlight && S > 0) {
5219
+ K.reconcileLoadedStates();
5220
+ const O = K.getBufferedAheadMs(S), Q = K.findNextRangeStart(S, Pt);
5217
5221
  if (Q !== null && X)
5218
5222
  C("sync", "GAP-SKIP seeking over late-IDR gap", {
5219
5223
  currentMs: Math.round(S),
@@ -5225,7 +5229,7 @@ function Xo(t, e, n, r, s, i) {
5225
5229
  pauseSeekResume: !1
5226
5230
  }).catch((W) => ee("sync", "GAP-SKIP seek threw", Y(W)));
5227
5231
  else if (O < 500) {
5228
- const W = V.getForwardGapDiag(S);
5232
+ const W = K.getForwardGapDiag(S);
5229
5233
  W && W.nextRangeStartMs !== null && C("sync", "STALL-GAP not skipped", {
5230
5234
  currentMs: Math.round(S),
5231
5235
  atEdge: W.atEdge,
@@ -5233,7 +5237,7 @@ function Xo(t, e, n, r, s, i) {
5233
5237
  nextRangeStartMs: Math.round(W.nextRangeStartMs),
5234
5238
  gapMs: W.gapMs !== null ? Math.round(W.gapMs) : null,
5235
5239
  windowMs: Pt
5236
- }), V.fetchNearby(S).catch((re) => {
5240
+ }), K.fetchNearby(S).catch((re) => {
5237
5241
  const le = Y(re);
5238
5242
  le.name !== "AbortError" && C("sync", "Stall recovery fetchNearby failed", {
5239
5243
  currentMs: Math.round(S),
@@ -5242,11 +5246,11 @@ function Xo(t, e, n, r, s, i) {
5242
5246
  });
5243
5247
  }
5244
5248
  }
5245
- H && D && !c.current && (c.current = setTimeout(() => {
5249
+ H && B && !c.current && (c.current = setTimeout(() => {
5246
5250
  c.current = null;
5247
5251
  const O = x.getState(), Q = !!O.snapshot.leaderId && O.snapshot.leaderId === O.me.clientId, W = !!n.current?.seekInFlight;
5248
5252
  Q && !w.paused && w.readyState < 3 && !W && (C("sync", "Leader stall threshold reached — pausing room", { stallMs: mn }), u.current = !0, Pe("pause"));
5249
- }, mn)), D && !p.current && (v.current = w.currentTime, p.current = setTimeout(() => {
5253
+ }, mn)), B && !p.current && (v.current = w.currentTime, p.current = setTimeout(() => {
5250
5254
  p.current = null;
5251
5255
  const O = t.current;
5252
5256
  if (!O) return;
@@ -5272,17 +5276,17 @@ function Xo(t, e, n, r, s, i) {
5272
5276
  }
5273
5277
  function R() {
5274
5278
  oe.recordStallEnd(), c.current && (clearTimeout(c.current), c.current = null), p.current && (clearTimeout(p.current), p.current = null), y.current = null, F();
5275
- const S = x.getState(), I = S.snapshot.playing, D = !!S.snapshot.leaderId && S.snapshot.leaderId === S.me.clientId;
5276
- !I && !w.paused && o(w), D && u.current && !I && (u.current = !1, C("sync", "Leader stall recovered — resuming room", { currentTime: w.currentTime.toFixed(2) }), Pe("play"));
5279
+ const S = x.getState(), I = S.snapshot.playing, B = !!S.snapshot.leaderId && S.snapshot.leaderId === S.me.clientId;
5280
+ !I && !w.paused && o(w), B && u.current && !I && (u.current = !1, C("sync", "Leader stall recovered — resuming room", { currentTime: w.currentTime.toFixed(2) }), Pe("play"));
5277
5281
  const H = f.current !== null ? Date.now() - f.current : null;
5278
5282
  f.current = null;
5279
- const j = x.getState(), V = j.snapshot.playheadMs + (j.snapshot.playing ? Date.now() - j.snapshotReceivedAt : 0), X = w.currentTime * 1e3;
5283
+ const j = x.getState(), K = j.snapshot.playheadMs + (j.snapshot.playing ? Date.now() - j.snapshotReceivedAt : 0), X = w.currentTime * 1e3;
5280
5284
  E("sync", "VIDEO playing event", {
5281
5285
  currentTime: w.currentTime.toFixed(2),
5282
5286
  shouldPlay: I,
5283
5287
  stallDurationMs: H,
5284
5288
  // Positive = viewer is behind server; negative = viewer is ahead.
5285
- driftMs: H !== null ? Math.round(V - X) : null
5289
+ driftMs: H !== null ? Math.round(K - X) : null
5286
5290
  });
5287
5291
  }
5288
5292
  function b() {
@@ -5293,8 +5297,8 @@ function Xo(t, e, n, r, s, i) {
5293
5297
  };
5294
5298
  }, [r, t, e, n]);
5295
5299
  }
5296
- const Zo = 1.5;
5297
- function ec(t, e, n, r, s, i) {
5300
+ const tc = 1.5;
5301
+ function nc(t, e, n, r, s, i) {
5298
5302
  const a = P(null), l = P(null), o = U(() => {
5299
5303
  a.current && (clearInterval(a.current), a.current = null), l.current?.(), l.current = null;
5300
5304
  }, []);
@@ -5323,7 +5327,7 @@ function ec(t, e, n, r, s, i) {
5323
5327
  };
5324
5328
  a.current = setInterval(v, gn);
5325
5329
  const g = () => {
5326
- performance.now() - p >= gn * Zo && v();
5330
+ performance.now() - p >= gn * tc && v();
5327
5331
  };
5328
5332
  if (c && (c.addEventListener("timeupdate", g), l.current = () => c.removeEventListener("timeupdate", g)), c && !n.current?.seekInFlight) {
5329
5333
  p = performance.now();
@@ -5333,13 +5337,13 @@ function ec(t, e, n, r, s, i) {
5333
5337
  return o;
5334
5338
  }, [r, s, t, e, n, i, o]), { stopPrefetch: o };
5335
5339
  }
5336
- function tc(t, e, n, r, s, i) {
5340
+ function rc(t, e, n, r, s, i) {
5337
5341
  const a = x((f) => f.snapshot), l = x((f) => f.loadGeneration), o = P(l), c = fe((f) => s(f)), u = fe((f) => i(f));
5338
5342
  L(() => {
5339
5343
  const f = t.current;
5340
5344
  if (!f || !r) return;
5341
5345
  const p = a.playheadMs, v = n.current, g = l !== o.current;
5342
- o.current = l, !(!g && Math.abs(p - v) <= Ps) && (E("buffer", "Seek triggered", {
5346
+ o.current = l, !(!g && Math.abs(p - v) <= Bs) && (E("buffer", "Seek triggered", {
5343
5347
  targetMs: p,
5344
5348
  lastApplied: v,
5345
5349
  delta: Math.round(p - v),
@@ -5357,7 +5361,7 @@ function tc(t, e, n, r, s, i) {
5357
5361
  p && v ? (E("sync", "Play/pause sync", { playing: p, videoPaused: v, currentTime: Math.round(f.currentTime * 1e3) }), c(f)) : !p && !v && (E("sync", "Play/pause sync", { playing: p, videoPaused: v, currentTime: Math.round(f.currentTime * 1e3) }), u(f));
5358
5362
  }, [a.playing, r, t, e]);
5359
5363
  }
5360
- function $n(t, e) {
5364
+ function Dn(t, e) {
5361
5365
  return new Promise((n, r) => {
5362
5366
  const s = setTimeout(n, t);
5363
5367
  e.addEventListener("abort", () => {
@@ -5365,7 +5369,7 @@ function $n(t, e) {
5365
5369
  }, { once: !0 });
5366
5370
  });
5367
5371
  }
5368
- function nc(t) {
5372
+ function sc(t) {
5369
5373
  const e = x((a) => a.playlist), n = x((a) => a.activePlaylistIndex), r = x((a) => a.snapshot.mediaId), s = e?.id, i = fe(() => e);
5370
5374
  L(() => {
5371
5375
  const a = i();
@@ -5375,16 +5379,16 @@ function nc(t) {
5375
5379
  for (let o = 0; o < a.videos.length; o++) {
5376
5380
  if (l.signal.aborted) return;
5377
5381
  if (o === n) continue;
5378
- const c = a.videos[o], { mediaUrl: u, indexUrl: f } = qn(c.mediaId), p = 3e3, v = async () => {
5382
+ const c = a.videos[o], { mediaUrl: u, indexUrl: f } = Xn(c.mediaId), p = 3e3, v = async () => {
5379
5383
  for (; !l.signal.aborted && (t.current?.getPendingCount() ?? 0) !== 0; )
5380
5384
  try {
5381
- await $n(2e3, l.signal);
5385
+ await Dn(2e3, l.signal);
5382
5386
  } catch {
5383
5387
  return !1;
5384
5388
  }
5385
5389
  if (l.signal.aborted) return !1;
5386
5390
  try {
5387
- await $n(p, l.signal);
5391
+ await Dn(p, l.signal);
5388
5392
  } catch {
5389
5393
  return !1;
5390
5394
  }
@@ -5464,11 +5468,11 @@ function nc(t) {
5464
5468
  }, [s, n, r, t]);
5465
5469
  }
5466
5470
  const Te = "bg-play";
5467
- function rc() {
5471
+ function ac() {
5468
5472
  const t = x.getState();
5469
5473
  return !!t.snapshot.leaderId && t.snapshot.leaderId === t.me.clientId;
5470
5474
  }
5471
- function sc(t) {
5475
+ function ic(t) {
5472
5476
  return typeof Image > "u" ? Promise.resolve(null) : t.reduce(
5473
5477
  (e, n) => e.then((r) => r ?? new Promise((s) => {
5474
5478
  const i = new Image();
@@ -5477,18 +5481,18 @@ function sc(t) {
5477
5481
  Promise.resolve(null)
5478
5482
  );
5479
5483
  }
5480
- function ac(t, e, n, r, s, i) {
5484
+ function oc(t, e, n, r, s, i) {
5481
5485
  const a = P(!1), l = P(0), o = fe((u) => i(u)), c = fe((u) => {
5482
5486
  const f = t.current, p = e.current;
5483
5487
  if (!f || !s) return;
5484
- const v = x.getState(), g = f.currentTime * 1e3, h = oo(v.snapshot, v.snapshotReceivedAt, Date.now()), y = io({
5488
+ const v = x.getState(), g = f.currentTime * 1e3, h = lo(v.snapshot, v.snapshotReceivedAt, Date.now()), y = co({
5485
5489
  roomPlaying: v.snapshot.playing,
5486
5490
  seekInFlight: !!p?.seekInFlight,
5487
5491
  elementPaused: f.paused,
5488
5492
  elementMs: g,
5489
5493
  roomMs: h,
5490
5494
  durationMs: r,
5491
- driftToleranceMs: ao
5495
+ driftToleranceMs: oo
5492
5496
  }), w = Math.round(h - g);
5493
5497
  if (y.kind === "none") {
5494
5498
  E(Te, "resync not needed", { reason: u, driftMs: w });
@@ -5501,7 +5505,7 @@ function ac(t, e, n, r, s, i) {
5501
5505
  if (!u || !s) return;
5502
5506
  const f = () => {
5503
5507
  const v = x.getState();
5504
- ro({
5508
+ ao({
5505
5509
  hidden: document.visibilityState === "hidden",
5506
5510
  roomPlaying: v.snapshot.playing,
5507
5511
  seekInFlight: !!e.current?.seekInFlight,
@@ -5520,16 +5524,16 @@ function ac(t, e, n, r, s, i) {
5520
5524
  if (!u || typeof navigator > "u" || !("mediaSession" in navigator)) return;
5521
5525
  const f = navigator.mediaSession;
5522
5526
  let p = !1;
5523
- const v = Tr(n), g = (k) => {
5527
+ const v = Cr(n), g = (k) => {
5524
5528
  p || typeof MediaMetadata > "u" || (f.metadata = new MediaMetadata({
5525
5529
  title: v,
5526
5530
  artist: "Watch Party",
5527
5531
  artwork: k ? [{ src: k }] : []
5528
5532
  }));
5529
5533
  };
5530
- g(null), sc(co(n).map(Bs)).then(g);
5534
+ g(null), ic(uo(n).map(Os)).then(g);
5531
5535
  const h = (k) => () => {
5532
- const m = x.getState(), T = so(k, { isLeader: rc(), roomPlaying: m.snapshot.playing });
5536
+ const m = x.getState(), T = io(k, { isLeader: ac(), roomPlaying: m.snapshot.playing });
5533
5537
  switch (E(Te, "media session press", { action: k, result: T.kind }), k === "pause" && (l.current = Date.now()), T.kind) {
5534
5538
  case "control":
5535
5539
  Pe(T.control), T.control === "pause" && u.pause();
@@ -5602,12 +5606,12 @@ function ac(t, e, n, r, s, i) {
5602
5606
  };
5603
5607
  }, [t]);
5604
5608
  }
5605
- const ic = 3e5, oc = 1, cc = 1;
5609
+ const cc = 3e5, lc = 1, dc = 1;
5606
5610
  function jt(t) {
5607
5611
  ee("buffer", "initializePlayback threw", Y(t));
5608
5612
  }
5609
- function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5610
- const r = P(null), [s, i] = $(!1), [a, l] = $(!1), { controlsVisible: o, showControls: c, hideControls: u, setControlsHeld: f } = Wo();
5613
+ function uc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5614
+ const r = P(null), [s, i] = $(!1), [a, l] = $(!1), { controlsVisible: o, showControls: c, hideControls: u, setControlsHeld: f } = Ko();
5611
5615
  L(() => {
5612
5616
  const M = () => l(!!document.fullscreenElement);
5613
5617
  return document.addEventListener("fullscreenchange", M), () => document.removeEventListener("fullscreenchange", M);
@@ -5619,86 +5623,86 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5619
5623
  initSegment: h,
5620
5624
  audioTracks: y,
5621
5625
  contentToken: w
5622
- } = zo(e), A = U((M) => {
5626
+ } = Qo(e), A = U((M) => {
5623
5627
  if (!w) return null;
5624
- const B = t.replace(new RegExp(`/${gt.replace(/\./g, "\\.")}$`), "");
5625
- return B === t ? null : { baseUrl: B, token: w, trackId: M };
5626
- }, [w, t]), k = g !== null && y.length > 0, m = x((M) => M.readiness), T = P(!1), R = P(!1), b = P(null), S = P(null), I = P(null), D = P(0), H = P(0), j = P(null), [V, X] = $(0), N = P([]), O = P([]), Q = P(-1), W = P(!1), re = P(null), le = P(0), Re = P(null), Ve = P(0), Mt = x((M) => M.bufferState), Be = x((M) => M.setBufferState), {
5628
+ const D = t.replace(new RegExp(`/${gt.replace(/\./g, "\\.")}$`), "");
5629
+ return D === t ? null : { baseUrl: D, token: w, trackId: M };
5630
+ }, [w, t]), k = g !== null && y.length > 0, m = x((M) => M.readiness), T = P(!1), R = P(!1), b = P(null), S = P(null), I = P(null), B = P(0), H = P(0), j = P(null), [K, X] = $(0), N = P([]), O = P([]), Q = P(-1), W = P(!1), re = P(null), le = P(0), Re = P(null), Ke = P(0), Mt = x((M) => M.bufferState), De = x((M) => M.setBufferState), {
5627
5631
  audioTracks: ye,
5628
- subtitleTracks: De,
5632
+ subtitleTracks: Be,
5629
5633
  selectedAudioIndex: we,
5630
5634
  setSelectedAudioIndex: rt,
5631
5635
  selectedSubtitleIndex: z,
5632
5636
  setSelectedSubtitleIndex: he
5633
- } = Jo(n), Me = x((M) => M.mediaPrefs), kt = x((M) => M.mutedForAutoplay), $r = x((M) => M.setMutedForAutoplay), rn = x((M) => M.setSubtitlesEnabled), Pr = x((M) => M.setSubtitleStyle), _t = x((M) => M.setPreferredAudioLang), Br = Me.subtitlesEnabled, sn = Me.subtitleStyle, Dr = ye[we]?.lang, Or = De.some((M) => M.lang === "eng"), [Hr, an] = $(null), st = Lo({
5634
- override: Hr,
5635
- globalEnabled: Br,
5636
- selectedAudioLang: Dr,
5637
- hasEngSub: Or
5638
- }), Ur = U(() => {
5637
+ } = qo(n), Me = x((M) => M.mediaPrefs), kt = x((M) => M.mutedForAutoplay), Dr = x((M) => M.setMutedForAutoplay), rn = x((M) => M.setSubtitlesEnabled), Br = x((M) => M.setSubtitleStyle), _t = x((M) => M.setPreferredAudioLang), Or = Me.subtitlesEnabled, sn = Me.subtitleStyle, Hr = ye[we]?.lang, Ur = Be.some((M) => M.lang === "eng"), [jr, an] = $(null), st = Po({
5638
+ override: jr,
5639
+ globalEnabled: Or,
5640
+ selectedAudioLang: Hr,
5641
+ hasEngSub: Ur
5642
+ }), Gr = U(() => {
5639
5643
  const M = !st;
5640
5644
  an(M), rn(M);
5641
5645
  }, [st, rn]), mt = U((M) => {
5642
- const B = x.getState();
5643
- Rr(M, {
5644
- userWantsMuted: B.mediaPrefs.muted,
5645
- onMutedBridge: () => B.setMutedForAutoplay(!0),
5646
- onUnmuted: () => B.setMutedForAutoplay(!1),
5646
+ const D = x.getState();
5647
+ Nr(M, {
5648
+ userWantsMuted: D.mediaPrefs.muted,
5649
+ onMutedBridge: () => D.setMutedForAutoplay(!0),
5650
+ onUnmuted: () => D.setMutedForAutoplay(!1),
5647
5651
  label: "video"
5648
5652
  });
5649
5653
  }, []), on = U((M) => {
5650
5654
  M.pause();
5651
- }, []), [jr, cn] = $(0), [Gr, Wr] = $(n);
5652
- Gr !== n && (Wr(n), an(null), cn(0)), L(() => {
5655
+ }, []), [Wr, cn] = $(0), [Vr, Kr] = $(n);
5656
+ Vr !== n && (Kr(n), an(null), cn(0)), L(() => {
5653
5657
  const M = r.current;
5654
5658
  if (!M) return;
5655
- const B = () => {
5659
+ const D = () => {
5656
5660
  cn(Math.round(M.currentTime * 1e3));
5657
5661
  };
5658
- return M.addEventListener("timeupdate", B), () => M.removeEventListener("timeupdate", B);
5662
+ return M.addEventListener("timeupdate", D), () => M.removeEventListener("timeupdate", D);
5659
5663
  }, []);
5660
5664
  const at = U((M) => {
5661
- Be({ isBuffering: M });
5662
- }, [Be]), ln = U((M) => {
5663
- if (H.current >= cc) {
5665
+ De({ isBuffering: M });
5666
+ }, [De]), ln = U((M) => {
5667
+ if (H.current >= dc) {
5664
5668
  zt("phantom-recreate-exhausted", { reason: M, recreates: H.current, mediaId: n });
5665
5669
  return;
5666
5670
  }
5667
- H.current += 1, D.current = 0, C("buffer", "MSE-RECREATE — rebuilding MediaSource to clear corrupt buffer", {
5671
+ H.current += 1, B.current = 0, C("buffer", "MSE-RECREATE — rebuilding MediaSource to clear corrupt buffer", {
5668
5672
  reason: M,
5669
5673
  attempt: H.current
5670
- }), X((B) => B + 1);
5674
+ }), X((D) => D + 1);
5671
5675
  }, [n]);
5672
5676
  async function At() {
5673
- const M = I.current, B = r.current;
5677
+ const M = I.current, D = r.current;
5674
5678
  if (!M || !p.length || R.current) return;
5675
- const pe = x.getState().snapshot, K = pe.playheadMs || 0;
5676
- E("buffer", "Initializing playback", { mediaId: n, startMs: K, playing: pe.playing }), M.setPlayhead(K);
5679
+ const pe = x.getState().snapshot, V = pe.playheadMs || 0;
5680
+ E("buffer", "Initializing playback", { mediaId: n, startMs: V, playing: pe.playing }), M.setPlayhead(V);
5677
5681
  const de = performance.now();
5678
5682
  try {
5679
5683
  const ie = N.current, te = ie.map(
5680
- (G) => G.ensureBuffered(K, "initial-audio").catch((se) => {
5684
+ (G) => G.ensureBuffered(V, "initial-audio").catch((se) => {
5681
5685
  (G.isDisposed ? E : C)("buffer", G.isDisposed ? "Audio FM initial load cancelled by media change" : "Audio FM initial ensureBuffered failed", {
5682
5686
  error: se?.message
5683
5687
  });
5684
5688
  })
5685
5689
  );
5686
- if (await M.ensureBuffered(K, "initial"), M.isDisposed) return;
5687
- const ne = Ds;
5690
+ if (await M.ensureBuffered(V, "initial"), M.isDisposed) return;
5691
+ const ne = Hs;
5688
5692
  await Promise.allSettled(te);
5689
5693
  const J = ie.map(
5690
- (G) => G.waitForBuffered(K + Ce, ne)
5691
- ), xe = await M.waitForBuffered(K + Ce, ne);
5694
+ (G) => G.waitForBuffered(V + Ce, ne)
5695
+ ), xe = await M.waitForBuffered(V + Ce, ne);
5692
5696
  if (await Promise.allSettled(J), xe || C("buffer", "Buffer gate timeout — proceeding with partial buffer", {
5693
- startMs: K,
5694
- aheadMs: Math.round(M.getBufferedAheadMs(K)),
5697
+ startMs: V,
5698
+ aheadMs: Math.round(M.getBufferedAheadMs(V)),
5695
5699
  targetMs: Ce
5696
5700
  }), M.isDisposed) return;
5697
- if (M.getBufferedAheadMs(K) > ic && M.getLoadedCount() === 0) {
5698
- M.dumpBufferDiagnostics(K, "phantom-detected"), C("buffer", "PHANTOM-BUFFER detected at gate — recreating MediaSource", {
5699
- gateAheadMs: Math.round(M.getBufferedAheadMs(K)),
5701
+ if (M.getBufferedAheadMs(V) > cc && M.getLoadedCount() === 0) {
5702
+ M.dumpBufferDiagnostics(V, "phantom-detected"), C("buffer", "PHANTOM-BUFFER detected at gate — recreating MediaSource", {
5703
+ gateAheadMs: Math.round(M.getBufferedAheadMs(V)),
5700
5704
  loaded: M.getLoadedCount(),
5701
- startMs: Math.round(K),
5705
+ startMs: Math.round(V),
5702
5706
  recreateAttempt: H.current,
5703
5707
  mediaId: n
5704
5708
  }), ln("phantom-buffer");
@@ -5706,42 +5710,42 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5706
5710
  }
5707
5711
  const Oe = Math.round(performance.now() - de);
5708
5712
  E("buffer", "Buffer gate passed", {
5709
- aheadMs: Math.round(M.getBufferedAheadMs(K)),
5713
+ aheadMs: Math.round(M.getBufferedAheadMs(V)),
5710
5714
  totalMs: Oe
5711
5715
  });
5712
5716
  const ke = xe ? "gate-pass" : "gate-timeout";
5713
- M.emitInitDigest("video", ke), ie.forEach((G, se) => G.emitInitDigest(`audio:${se}`, ke)), T.current || (T.current = !0, Os(n));
5714
- let q = K;
5715
- if (B && q > 0) {
5716
- const G = B.buffered;
5717
+ M.emitInitDigest("video", ke), ie.forEach((G, se) => G.emitInitDigest(`audio:${se}`, ke)), T.current || (T.current = !0, Us(n));
5718
+ let q = V;
5719
+ if (D && q > 0) {
5720
+ const G = D.buffered;
5717
5721
  if (G.length > 0) {
5718
5722
  const se = q / 1e3, ae = G.start(0);
5719
5723
  se < ae && ae - se < 1 && (q = ae * 1e3);
5720
5724
  }
5721
- B.currentTime = q / 1e3, await Fr(B, 3e3);
5725
+ D.currentTime = q / 1e3, await Lr(D, 3e3);
5722
5726
  }
5723
- le.current = q, i(!0), R.current = !0, D.current = 0, Fn() && C("buffer", "RECOVERY-SUCCESS — playback initialized after an auto-reload", { mediaId: n }), Po(), E("buffer", "initializePlayback complete", {
5727
+ le.current = q, i(!0), R.current = !0, B.current = 0, Ln() && C("buffer", "RECOVERY-SUCCESS — playback initialized after an auto-reload", { mediaId: n }), Bo(), E("buffer", "initializePlayback complete", {
5724
5728
  mediaId: n,
5725
- startMs: K,
5729
+ startMs: V,
5726
5730
  seekMs: q,
5727
5731
  initDurationMs: Math.round(performance.now() - de)
5728
5732
  });
5729
5733
  const He = x.getState().snapshot;
5730
- if (B && He.playing && B.paused && (E("buffer", "initializePlayback: calling play()", { playing: He.playing }), mt(B)), M.isDisposed) return;
5734
+ if (D && He.playing && D.paused && (E("buffer", "initializePlayback: calling play()", { playing: He.playing }), mt(D)), M.isDisposed) return;
5731
5735
  const ce = x.getState();
5732
5736
  if (!(!!ce.snapshot.leaderId && ce.snapshot.leaderId === ce.me.clientId) && ce.snapshot.playing)
5733
5737
  try {
5734
5738
  const G = Date.now() - ce.snapshotReceivedAt, se = ce.snapshot.playheadMs + G;
5735
5739
  if (E("buffer", "Viewer correction computed", {
5736
- startMs: K,
5740
+ startMs: V,
5737
5741
  playheadMs: ce.snapshot.playheadMs,
5738
5742
  elapsed: G,
5739
5743
  correctedMs: se,
5740
- deltaSec: ((se - K) / 1e3).toFixed(1),
5744
+ deltaSec: ((se - V) / 1e3).toFixed(1),
5741
5745
  initialBufferMs: Oe
5742
- }), se > K) {
5746
+ }), se > V) {
5743
5747
  const ae = re.current;
5744
- if (B && ae) {
5748
+ if (D && ae) {
5745
5749
  const ue = x.getState(), me = Date.now() - ue.snapshotReceivedAt, Ue = ue.snapshot.playheadMs + me, Ae = Ue > se ? Ue : se;
5746
5750
  await ae.submit({
5747
5751
  targetMs: Ae,
@@ -5750,7 +5754,7 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5750
5754
  pauseSeekResume: !0,
5751
5755
  onComplete: (Fe) => {
5752
5756
  le.current = Fe, E("buffer", "Viewer correction applied", {
5753
- startMs: K,
5757
+ startMs: V,
5754
5758
  correctedMs: se,
5755
5759
  seekTarget: Ae,
5756
5760
  actualMs: Fe,
@@ -5775,7 +5779,7 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5775
5779
  error: ie?.message
5776
5780
  }), i(!0), R.current = !0;
5777
5781
  const te = x.getState().snapshot;
5778
- B && te.playing && B.paused && mt(B);
5782
+ D && te.playing && D.paused && mt(D);
5779
5783
  } else {
5780
5784
  const te = ie?.message || "";
5781
5785
  if (M.isDisposed || te.includes("FragmentManager disposed")) {
@@ -5785,23 +5789,23 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5785
5789
  return;
5786
5790
  }
5787
5791
  const ne = te.includes("SourceBuffer is full"), J = te.includes("init segment failed");
5788
- D.current += 1, ne || J || D.current > oc ? (ee("buffer", "Initialize playback failed — recreating MediaSource", {
5792
+ B.current += 1, ne || J || B.current > lc ? (ee("buffer", "Initialize playback failed — recreating MediaSource", {
5789
5793
  error: te,
5790
5794
  mediaId: n,
5791
- attempt: D.current,
5795
+ attempt: B.current,
5792
5796
  sbFull: ne,
5793
5797
  initFailed: J
5794
5798
  }), ln(ne ? "sourcebuffer-full" : J ? "init-failed" : "init-retry-cap")) : (ee("buffer", "Initialize playback error — will retry in 3s", {
5795
5799
  error: te,
5796
5800
  mediaId: n,
5797
- attempt: D.current
5801
+ attempt: B.current
5798
5802
  }), setTimeout(() => {
5799
5803
  I.current && !M.isDisposed && !R.current && (E("buffer", "Retrying initializePlayback"), At().catch(jt));
5800
5804
  }, 3e3));
5801
5805
  }
5802
5806
  }
5803
5807
  }
5804
- const Kr = fe(() => ({
5808
+ const zr = fe(() => ({
5805
5809
  useMseAudio: k,
5806
5810
  selectedAudioIndex: we,
5807
5811
  mseAudioTracks: y,
@@ -5813,14 +5817,14 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5813
5817
  if (!g) return;
5814
5818
  const {
5815
5819
  useMseAudio: M,
5816
- selectedAudioIndex: B,
5820
+ selectedAudioIndex: D,
5817
5821
  mseAudioTracks: pe,
5818
- fragments: K,
5822
+ fragments: V,
5819
5823
  deliveryFor: de,
5820
5824
  initializePlayback: ie
5821
- } = Kr();
5822
- j.current !== n && (j.current = n, H.current = 0, D.current = 0);
5823
- const te = Fn();
5825
+ } = zr();
5826
+ j.current !== n && (j.current = n, H.current = 0, B.current = 0);
5827
+ const te = Ln();
5824
5828
  te && C("buffer", "POST-AUTO-RELOAD — this load follows an auto-reload recovery", {
5825
5829
  reloadAtMs: te,
5826
5830
  sinceReloadMs: Date.now() - te,
@@ -5831,14 +5835,14 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5831
5835
  S.current = J;
5832
5836
  const xe = new Ze(at);
5833
5837
  I.current = xe;
5834
- const Oe = ++Ve.current;
5838
+ const Oe = ++Ke.current;
5835
5839
  window.__FRAGMENT_MANAGER__ = xe, window.__AUDIO_FRAGMENT_MANAGERS__ = N.current;
5836
- const ke = new Oo({
5840
+ const ke = new Uo({
5837
5841
  videoRef: r,
5838
5842
  fragmentManagerRef: I,
5839
5843
  audioFragmentManagersRef: N
5840
5844
  });
5841
- re.current = ke, window.__SEEK_COORDINATOR__ = ke, Ho();
5845
+ re.current = ke, window.__SEEK_COORDINATOR__ = ke, jo();
5842
5846
  const q = r.current, He = () => {
5843
5847
  const G = q?.error;
5844
5848
  G && (ee("video", `Media error code=${G.code}: ${G.message}`, {
@@ -5859,7 +5863,7 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5859
5863
  updating: se.updating
5860
5864
  });
5861
5865
  }), xe.setSourceBuffer(se, J), M) {
5862
- const ae = Math.max(0, Math.min(B, pe.length - 1)), ue = pe[ae], me = ue.mse_codec;
5866
+ const ae = Math.max(0, Math.min(D, pe.length - 1)), ue = pe[ae], me = ue.mse_codec;
5863
5867
  if (!MediaSource.isTypeSupported(me))
5864
5868
  C("mse", `Audio codec not supported: ${me}, track=${ue.track_id}`);
5865
5869
  else
@@ -5883,8 +5887,8 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5883
5887
  const Ue = r.current;
5884
5888
  Ue && (Ue.muted = !1);
5885
5889
  }
5886
- if (K.length) {
5887
- if (xe.setIndex(K, t, h, n, de()), xe.epoch = Oe, M) {
5890
+ if (V.length) {
5891
+ if (xe.setIndex(V, t, h, n, de()), xe.epoch = Oe, M) {
5888
5892
  const ae = Q.current, ue = N.current[0], me = ae >= 0 ? pe[ae] : void 0;
5889
5893
  if (ue && me) {
5890
5894
  const Ue = `${ce}/${me.path}`.replace(/\\/g, "/");
@@ -5904,7 +5908,7 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5904
5908
  }
5905
5909
  };
5906
5910
  return q && (J.addEventListener("sourceopen", _e), ne = URL.createObjectURL(J), q.src = ne, q.addEventListener("error", He)), () => {
5907
- q?.pause(), q && q.removeEventListener("error", He), J.removeEventListener("sourceopen", _e), Uo(), ke.dispose(), re.current = null, xe.dispose(), I.current = null, window.__FRAGMENT_MANAGER__ = null, window.__AUDIO_FRAGMENT_MANAGERS__ = null;
5911
+ q?.pause(), q && q.removeEventListener("error", He), J.removeEventListener("sourceopen", _e), Go(), ke.dispose(), re.current = null, xe.dispose(), I.current = null, window.__FRAGMENT_MANAGER__ = null, window.__AUDIO_FRAGMENT_MANAGERS__ = null;
5908
5912
  for (const G of N.current) G.dispose();
5909
5913
  if (N.current = [], J.readyState === "open") {
5910
5914
  for (const G of [b.current, ...O.current])
@@ -5921,14 +5925,14 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5921
5925
  }
5922
5926
  Re.current?.(), R.current = !1, T.current = !1, b.current = null, i(!1);
5923
5927
  };
5924
- }, [t, n, g, h, at, V]);
5925
- const Vr = fe(() => {
5926
- const M = I.current, B = Ve.current;
5928
+ }, [t, n, g, h, at, K]);
5929
+ const Jr = fe(() => {
5930
+ const M = I.current, D = Ke.current;
5927
5931
  if (S.current?.readyState === "open" && b.current && p.length && M) {
5928
- if (M.hasIndex && M.epoch === B) return;
5929
- if (M.setIndex(p, t, h, n, A()), M.epoch = B, k) {
5930
- const pe = t.replace(new RegExp(`/${gt.replace(/\./g, "\\.")}$`), ""), K = Q.current, de = N.current[0], ie = K >= 0 ? y[K] : void 0;
5931
- if (de && ie && !(de.hasIndex && de.epoch === B)) {
5932
+ if (M.hasIndex && M.epoch === D) return;
5933
+ if (M.setIndex(p, t, h, n, A()), M.epoch = D, k) {
5934
+ const pe = t.replace(new RegExp(`/${gt.replace(/\./g, "\\.")}$`), ""), V = Q.current, de = N.current[0], ie = V >= 0 ? y[V] : void 0;
5935
+ if (de && ie && !(de.hasIndex && de.epoch === D)) {
5932
5936
  const te = `${pe}/${ie.path}`.replace(/\\/g, "/");
5933
5937
  de.setIndex(
5934
5938
  ie.fragments,
@@ -5936,24 +5940,24 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5936
5940
  ie.init_segment,
5937
5941
  `${n}::audio::${ie.track_id}`,
5938
5942
  A(ie.track_id)
5939
- ), de.epoch = B;
5943
+ ), de.epoch = D;
5940
5944
  }
5941
5945
  }
5942
5946
  R.current || At().catch(jt);
5943
5947
  }
5944
5948
  });
5945
5949
  L(() => {
5946
- Vr();
5950
+ Jr();
5947
5951
  }, [p, t, h, y]), L(() => {
5948
5952
  const M = () => {
5949
5953
  I.current?.abortStaleJobs("socket-reconnect");
5950
- for (const B of N.current) B.abortStaleJobs("socket-reconnect");
5954
+ for (const D of N.current) D.abortStaleJobs("socket-reconnect");
5951
5955
  };
5952
5956
  return window.addEventListener("watchparty:socket-reconnect", M), () => window.removeEventListener("watchparty:socket-reconnect", M);
5953
5957
  }, []), L(() => (window.__AUDIO_SELECT__ = (M) => {
5954
5958
  rt(M);
5955
- const B = ye[M];
5956
- B?.lang && _t(B.lang);
5959
+ const D = ye[M];
5960
+ D?.lang && _t(D.lang);
5957
5961
  }, () => {
5958
5962
  window.__AUDIO_SELECT__ = null;
5959
5963
  }), [ye, rt, _t]), L(() => {
@@ -5967,12 +5971,12 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5967
5971
  C("audio", `MSE audio swap skipped — MediaSource readyState=${M?.readyState}`);
5968
5972
  return;
5969
5973
  }
5970
- const B = r.current;
5971
- if (!B) return;
5972
- const pe = we, K = y[pe], de = Ve.current;
5974
+ const D = r.current;
5975
+ if (!D) return;
5976
+ const pe = we, V = y[pe], de = Ke.current;
5973
5977
  W.current = !0;
5974
- const ie = Math.round(B.currentTime * 1e3);
5975
- E("audio", `MSE audio swap START idx=${Q.current}→${pe} lang=${K.lang} playheadMs=${ie}`), (async () => {
5978
+ const ie = Math.round(D.currentTime * 1e3);
5979
+ E("audio", `MSE audio swap START idx=${Q.current}→${pe} lang=${V.lang} playheadMs=${ie}`), (async () => {
5976
5980
  try {
5977
5981
  const te = N.current[0], ne = O.current[0];
5978
5982
  if (!ne) {
@@ -5999,39 +6003,39 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5999
6003
  }
6000
6004
  const J = new Ze(
6001
6005
  at,
6002
- { suppressEndOfStream: !0, label: `audio:${K.track_id}` }
6006
+ { suppressEndOfStream: !0, label: `audio:${V.track_id}` }
6003
6007
  );
6004
6008
  J.setSourceBuffer(ne, M);
6005
- const Oe = `${t.replace(new RegExp(`/${gt.replace(/\./g, "\\.")}$`), "")}/${K.path}`.replace(/\\/g, "/");
6009
+ const Oe = `${t.replace(new RegExp(`/${gt.replace(/\./g, "\\.")}$`), "")}/${V.path}`.replace(/\\/g, "/");
6006
6010
  J.setIndex(
6007
- K.fragments,
6011
+ V.fragments,
6008
6012
  Oe,
6009
- K.init_segment,
6010
- `${n}::audio::${K.track_id}`,
6011
- A(K.track_id)
6013
+ V.init_segment,
6014
+ `${n}::audio::${V.track_id}`,
6015
+ A(V.track_id)
6012
6016
  ), J.epoch = de, N.current.length = 0, N.current.push(J), Q.current = pe;
6013
- const ke = re.current?.inFlightTargetMs ?? Math.round(B.currentTime * 1e3), q = new AbortController();
6017
+ const ke = re.current?.inFlightTargetMs ?? Math.round(D.currentTime * 1e3), q = new AbortController();
6014
6018
  J.setPlayhead(ke);
6015
6019
  const He = J.ensureBuffered(ke, "audio-swap", q.signal);
6016
6020
  J.supersededSignal.addEventListener("abort", () => q.abort(), { once: !0 }), He.catch((ce) => {
6017
6021
  const _e = J.isDisposed || q.signal.aborted;
6018
6022
  (_e ? E : C)("audio", _e ? "audio-swap load superseded by a seek or a later swap" : "audio-swap ensureBuffered failed", { error: ce?.message });
6019
- }), E("audio", `MSE audio swap DONE idx=${pe} track=${K.track_id}`);
6023
+ }), E("audio", `MSE audio swap DONE idx=${pe} track=${V.track_id}`);
6020
6024
  } finally {
6021
6025
  W.current = !1;
6022
6026
  }
6023
6027
  })().catch((te) => ee("audio", "MSE audio swap failed", Y(te)));
6024
- }, [k, s, we, y, n, t, at, A]), tc(re, r, le, s, mt, on), Xo(r, I, re, s, on, N), ac(r, re, n, v ?? 0, s, mt);
6025
- const { stopPrefetch: dn } = ec(r, I, re, s, Be, N);
6026
- nc(I), L(() => {
6028
+ }, [k, s, we, y, n, t, at, A]), rc(re, r, le, s, mt, on), ec(r, I, re, s, on, N), oc(r, re, n, v ?? 0, s, mt);
6029
+ const { stopPrefetch: dn } = nc(r, I, re, s, De, N);
6030
+ sc(I), L(() => {
6027
6031
  Re.current = dn;
6028
6032
  }, [dn]);
6029
- const zr = U(() => {
6033
+ const Qr = U(() => {
6030
6034
  const M = r.current?.parentElement;
6031
- M && (document.fullscreenElement ? document.exitFullscreen().catch((B) => C("ui", "exitFullscreen failed", Y(B))) : M.requestFullscreen().catch((B) => C("ui", "requestFullscreen failed", Y(B))));
6032
- }, []), Jr = U((M) => {
6035
+ M && (document.fullscreenElement ? document.exitFullscreen().catch((D) => C("ui", "exitFullscreen failed", Y(D))) : M.requestFullscreen().catch((D) => C("ui", "requestFullscreen failed", Y(D))));
6036
+ }, []), qr = U((M) => {
6033
6037
  M.preventDefault();
6034
- }, []), Qr = st && De[z] ? De[z].url : null;
6038
+ }, []), Yr = st && Be[z] ? Be[z].url : null;
6035
6039
  return /* @__PURE__ */ _(
6036
6040
  "div",
6037
6041
  {
@@ -6046,42 +6050,42 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
6046
6050
  ref: r,
6047
6051
  className: "w-full h-full",
6048
6052
  playsInline: !0,
6049
- onDoubleClick: zr,
6050
- onContextMenu: Jr
6053
+ onDoubleClick: Qr,
6054
+ onContextMenu: qr
6051
6055
  }
6052
6056
  ),
6053
6057
  /* @__PURE__ */ d(
6054
- xo,
6058
+ Mo,
6055
6059
  {
6056
- subtitleUrl: Qr,
6060
+ subtitleUrl: Yr,
6057
6061
  videoRef: r,
6058
6062
  style: sn,
6059
6063
  enabled: st
6060
6064
  }
6061
6065
  ),
6062
- /* @__PURE__ */ d(lo, { mediaId: n, visible: o }),
6066
+ /* @__PURE__ */ d(fo, { mediaId: n, visible: o }),
6063
6067
  /* @__PURE__ */ d(
6064
- to,
6068
+ ro,
6065
6069
  {
6066
6070
  videoRef: r,
6067
6071
  mediaId: n,
6068
6072
  durationMs: v || void 0,
6069
6073
  visible: o,
6070
- displayPlayheadMs: jr,
6074
+ displayPlayheadMs: Wr,
6071
6075
  audioTracks: ye,
6072
6076
  selectedAudioIndex: we,
6073
6077
  onAudioSelect: (M) => {
6074
6078
  rt(M);
6075
- const B = ye[M];
6076
- B?.lang && _t(B.lang);
6079
+ const D = ye[M];
6080
+ D?.lang && _t(D.lang);
6077
6081
  },
6078
- subtitleTracks: De,
6082
+ subtitleTracks: Be,
6079
6083
  selectedSubtitleIndex: z,
6080
6084
  onSubtitleSelect: he,
6081
6085
  subtitlesEnabled: st,
6082
- onSubtitlesToggle: Ur,
6086
+ onSubtitlesToggle: Gr,
6083
6087
  subtitleStyle: sn,
6084
- onSubtitleStyleChange: Pr,
6088
+ onSubtitleStyleChange: Br,
6085
6089
  onChatActivity: () => c(5e3),
6086
6090
  onMenuHeld: f
6087
6091
  }
@@ -6092,7 +6096,7 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
6092
6096
  type: "button",
6093
6097
  onClick: () => {
6094
6098
  const M = r.current;
6095
- M && (M.muted = !1), $r(!1);
6099
+ M && (M.muted = !1), Dr(!1);
6096
6100
  },
6097
6101
  className: "autoplay-sound-badge",
6098
6102
  children: [
@@ -6109,14 +6113,14 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
6109
6113
  }
6110
6114
  );
6111
6115
  }
6112
- function dc() {
6113
- const t = x((n) => n.snapshot.mediaId), e = Ee(() => t ? { mediaId: t, ...qn(t) } : null, [t]);
6114
- return e ? /* @__PURE__ */ d(nr, { children: /* @__PURE__ */ d(lc, { mediaUrl: e.mediaUrl, indexUrl: e.indexUrl, mediaId: e.mediaId }) }) : /* @__PURE__ */ d(js, {});
6116
+ function fc() {
6117
+ const t = x((n) => n.snapshot.mediaId), e = Ee(() => t ? { mediaId: t, ...Xn(t) } : null, [t]);
6118
+ return e ? /* @__PURE__ */ d(sr, { children: /* @__PURE__ */ d(uc, { mediaUrl: e.mediaUrl, indexUrl: e.indexUrl, mediaId: e.mediaId }) }) : /* @__PURE__ */ d(Ws, {});
6115
6119
  }
6116
- const uc = (t) => {
6117
- const e = Xs(t);
6120
+ const hc = (t) => {
6121
+ const e = ea(t);
6118
6122
  return e.render(
6119
- /* @__PURE__ */ d(Hs.Provider, { value: Us(), children: /* @__PURE__ */ d(dc, {}) })
6123
+ /* @__PURE__ */ d(js.Provider, { value: Gs(), children: /* @__PURE__ */ d(fc, {}) })
6120
6124
  ), {
6121
6125
  update() {
6122
6126
  },
@@ -6127,21 +6131,21 @@ const uc = (t) => {
6127
6131
  queueMicrotask(() => e.unmount());
6128
6132
  }
6129
6133
  };
6130
- }, fc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6134
+ }, pc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6131
6135
  __proto__: null,
6132
- mount: uc
6133
- }, Symbol.toStringTag, { value: "Module" })), hc = {
6136
+ mount: hc
6137
+ }, Symbol.toStringTag, { value: "Module" })), mc = {
6134
6138
  id: "player",
6135
6139
  name: "Media player",
6136
- load: () => Promise.resolve(fc)
6137
- }, pc = Qt(() => import("./MediaDrawer-CXffVb5D.js"));
6138
- function mc() {
6140
+ load: () => Promise.resolve(pc)
6141
+ }, gc = Qt(() => import("./MediaDrawer-DHq4zHZo.js"));
6142
+ function bc() {
6139
6143
  const t = x((u) => u.snapshot), e = x((u) => u.ensureAutoIdentity), n = Et(), r = Ee(
6140
- () => n ? Za(n, window.location.origin) : null,
6144
+ () => n ? ti(n, window.location.origin) : null,
6141
6145
  [n]
6142
- ), s = Gs(), i = P(!1), [a, l] = $(!1), o = s.roomKey || null;
6143
- Pi(), L(() => Bi(), []), L(() => {
6144
- o && Ui(o);
6146
+ ), s = Vs(), i = P(!1), [a, l] = $(!1), o = s.roomKey || null;
6147
+ Bi(), L(() => Oi(), []), L(() => {
6148
+ o && Gi(o);
6145
6149
  }, [o]), L(() => {
6146
6150
  const u = () => l(!0);
6147
6151
  return window.addEventListener(Wt, u), () => window.removeEventListener(Wt, u);
@@ -6153,9 +6157,9 @@ function mc() {
6153
6157
  try {
6154
6158
  await Promise.race([
6155
6159
  Promise.all([
6156
- Ws(),
6157
6160
  Ks(),
6158
- Vs().then(zn)
6161
+ zs(),
6162
+ Js().then(Qn)
6159
6163
  ]),
6160
6164
  new Promise((g) => setTimeout(g, f))
6161
6165
  ]);
@@ -6166,7 +6170,7 @@ function mc() {
6166
6170
  const p = x.getState();
6167
6171
  E("room", "Joining room", { roomKey: o, name: p.name, sprite: p.sprite }), e();
6168
6172
  const v = x.getState();
6169
- zs({
6173
+ Qs({
6170
6174
  room_key: o,
6171
6175
  name: v.name || void 0,
6172
6176
  sprite: v.sprite || void 0
@@ -6180,37 +6184,37 @@ function mc() {
6180
6184
  }
6181
6185
  return o ? /* @__PURE__ */ _("div", { className: "relative flex-1 flex overflow-hidden min-h-0", children: [
6182
6186
  /* @__PURE__ */ _("div", { className: "flex-1 relative bg-black overflow-hidden min-w-0", children: [
6183
- /* @__PURE__ */ d(Sn, { activity: hc, roomKey: t.roomId ?? "", layer: "base" }),
6184
- r && t.roomId && /* @__PURE__ */ d(nr, { children: /* @__PURE__ */ d(Sn, { activity: r, roomKey: t.roomId, layer: "overlay" }, r.id) }),
6185
- /* @__PURE__ */ _(vi, { children: [
6186
- /* @__PURE__ */ d(ii, {}),
6187
- /* @__PURE__ */ d(mi, {}),
6188
- /* @__PURE__ */ d($i, {}),
6189
- /* @__PURE__ */ d(yi, {})
6187
+ /* @__PURE__ */ d(Sn, { activity: mc, roomKey: t.roomId ?? "", layer: "base" }),
6188
+ r && t.roomId && /* @__PURE__ */ d(sr, { children: /* @__PURE__ */ d(Sn, { activity: r, roomKey: t.roomId, layer: "overlay" }, r.id) }),
6189
+ /* @__PURE__ */ _(wi, { children: [
6190
+ /* @__PURE__ */ d(ci, {}),
6191
+ /* @__PURE__ */ d(bi, {}),
6192
+ /* @__PURE__ */ d(Di, {}),
6193
+ /* @__PURE__ */ d(Si, {})
6190
6194
  ] })
6191
6195
  ] }),
6192
- /* @__PURE__ */ d(qa, {}),
6193
- /* @__PURE__ */ d(Ke.Suspense, { fallback: /* @__PURE__ */ d(ri, { open: a, onClose: c }), children: /* @__PURE__ */ d(pc, { open: a, onClose: c }) })
6196
+ /* @__PURE__ */ d(Xa, {}),
6197
+ /* @__PURE__ */ d(Ve.Suspense, { fallback: /* @__PURE__ */ d(ai, { open: a, onClose: c }), children: /* @__PURE__ */ d(gc, { open: a, onClose: c }) })
6194
6198
  ] }) : (C("room", "No room key provided"), /* @__PURE__ */ d("div", { className: "flex-1 flex items-center justify-center p-6", children: /* @__PURE__ */ _("div", { className: "text-text-secondary", children: [
6195
6199
  "No room key provided. Go to the ",
6196
6200
  /* @__PURE__ */ d("a", { href: "/", className: "underline", children: "home page" }),
6197
6201
  " to select a room."
6198
6202
  ] }) }));
6199
6203
  }
6200
- const Ac = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6204
+ const Ic = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6201
6205
  __proto__: null,
6202
- default: mc
6206
+ default: bc
6203
6207
  }, Symbol.toStringTag, { value: "Module" }));
6204
6208
  export {
6205
- Mc as B,
6206
- ni as D,
6207
- Ac as R,
6208
- kc as S,
6209
- ti as a,
6210
- ji as b,
6211
- Ec as c,
6209
+ _c as B,
6210
+ si as D,
6211
+ Ic as R,
6212
+ Ac as S,
6213
+ ri as a,
6214
+ Wi as b,
6215
+ kc as c,
6212
6216
  nt as d,
6213
- _c as s,
6217
+ Tc as s,
6214
6218
  en as u
6215
6219
  };
6216
- //# sourceMappingURL=Room-CQy_wCnX.js.map
6220
+ //# sourceMappingURL=Room-DjbNxzkP.js.map