@banou/media-player 0.10.41 → 0.10.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -471,13 +471,17 @@ var se = {
471
471
  n,
472
472
  r
473
473
  ]);
474
- }, Fe = 5e3, Ie = 6e4, Le = ({ publicPath: e, workerUrl: t, length: n, read: r, downloadedRanges: i }) => {
474
+ }, Fe = 5e3, Ie = 6e4, Le = 1e6, Re = (e, t) => !e || e.some(([e, n]) => e <= 0 && n >= Math.min(Le, t)), ze = ({ publicPath: e, workerUrl: t, length: n, read: r, downloadedRanges: i }) => {
475
475
  let [a, s] = T([]), c = w(null), l = w(r);
476
476
  l.current = r;
477
477
  let u = C(() => i?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [i?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")]), d = w(u);
478
- return d.current = u, S(() => {
478
+ d.current = u;
479
+ let f = w(null);
480
+ return S(() => {
479
481
  if (!n || !r || !e || !t) return;
480
- let i = !1, a = null, u, f = Fe, p = () => {
482
+ let i = !1, a = null, u, p = Fe, m = () => {
483
+ f.current = null;
484
+ let r = !Re(d.current, n);
481
485
  o({
482
486
  publicPath: e,
483
487
  workerUrl: t,
@@ -493,25 +497,29 @@ var se = {
493
497
  }
494
498
  a = e, c.current = e, e.update(d.current);
495
499
  }, () => {
496
- i || (u = setTimeout(p, f), f = Math.min(f * 2, Ie));
500
+ if (i || (u = setTimeout(m, p), p = Math.min(p * 2, Ie), !r)) return;
501
+ let e = () => {
502
+ clearTimeout(u), m();
503
+ };
504
+ Re(d.current, n) ? e() : f.current = e;
497
505
  });
498
506
  };
499
- return p(), () => {
500
- i = !0, clearTimeout(u), c.current = null, a?.destroy(), s([]);
507
+ return m(), () => {
508
+ i = !0, f.current = null, clearTimeout(u), c.current = null, a?.destroy(), s([]);
501
509
  };
502
510
  }, [
503
511
  n,
504
512
  e,
505
513
  t
506
514
  ]), S(() => {
507
- c.current?.update(u);
515
+ c.current?.update(u), n && Re(u, n) && f.current?.();
508
516
  }, [u]), {
509
517
  thumbnails: a,
510
518
  requestThumbnail: b((e) => {
511
519
  c.current?.prioritize(e);
512
520
  }, [])
513
521
  };
514
- }, Re = (e, t) => {
522
+ }, Be = (e, t) => {
515
523
  let n = w(null), [i, a] = T(!1), [o] = T(() => r());
516
524
  S(() => {
517
525
  if (!e || !t || !o) return;
@@ -539,10 +547,10 @@ var se = {
539
547
  mode: o,
540
548
  burnedIn: i
541
549
  };
542
- }, ze = "(hover: hover) and (pointer: fine)", Be = () => typeof matchMedia == "function" ? matchMedia(ze) : void 0, Ve = (e) => {
543
- let t = Be();
550
+ }, Ve = "(hover: hover) and (pointer: fine)", He = () => typeof matchMedia == "function" ? matchMedia(Ve) : void 0, Ue = (e) => {
551
+ let t = He();
544
552
  return t?.addEventListener("change", e), () => t?.removeEventListener("change", e);
545
- }, He = () => !!Be()?.matches, Ue = () => !1, We = (e, t) => {
553
+ }, We = () => !!He()?.matches, Ge = () => !1, Ke = (e, t) => {
546
554
  let [n, r] = T(!1), [i, a] = T(), o = w(t);
547
555
  t && (o.current = t);
548
556
  let s = w(!1), c = b((e) => {
@@ -565,7 +573,7 @@ var se = {
565
573
  d,
566
574
  u
567
575
  ]);
568
- let f = E(Ve, He, Ue), [p, m] = T(!1);
576
+ let f = E(Ue, We, Ge), [p, m] = T(!1);
569
577
  S(() => {
570
578
  if (!d) return;
571
579
  let e = (e) => {
@@ -606,61 +614,66 @@ var se = {
606
614
  u,
607
615
  g
608
616
  ]);
609
- }, Ge = async (e, t, n = {}) => (await e.audioWorklet.addModule(t), new AudioWorkletNode(e, "banou-volume-normalizer", {
617
+ }, qe = async (e, t, n = {}) => (await e.audioWorklet.addModule(t), new AudioWorkletNode(e, "banou-volume-normalizer", {
610
618
  channelCountMode: "max",
611
619
  processorOptions: n
612
- })), Ke = /* @__PURE__ */ new WeakMap(), qe = (e) => new Promise((t, n) => {
620
+ })), Je = /* @__PURE__ */ new WeakMap(), Ye = (e) => new Promise((t, n) => {
613
621
  let r = () => {
614
622
  (e.state === "running" || e.state === "closed") && (e.removeEventListener("statechange", r), e.state === "running" ? t() : n(new DOMException("The AudioContext closed before it ran", "InvalidStateError")));
615
623
  };
616
624
  e.addEventListener("statechange", r), r();
617
- }), Je = (e, t, n = {}) => {
618
- let r = Ke.get(e);
625
+ }), Xe = (e, t, n = {}) => {
626
+ let r = Je.get(e);
619
627
  if (r) return r.wake(), r;
620
- let i = new AudioContext(), a = n.enabled !== !1, o, s = !1, c = () => 20 * Math.log10(Math.max(e.volume, 1e-6)), l = e.ownerDocument, u = () => {
628
+ let i = new AudioContext(), a = n.enabled !== !1, o, s = !1, c = !1, l = () => 20 * Math.log10(Math.max(e.volume, 1e-6)), u = e.ownerDocument, d = () => {
621
629
  i.state === "suspended" && i.resume().catch(() => {});
622
- }, d = (e) => {
630
+ }, f = (e) => {
623
631
  for (let t of [
624
632
  "pointerdown",
625
633
  "pointerup",
626
634
  "keydown"
627
- ]) e ? l.addEventListener(t, u, !0) : l.removeEventListener(t, u, !0);
628
- }, f = () => {
629
- let e = !s && i.state === "suspended";
630
- d(e), e && o && u();
635
+ ]) e ? u.addEventListener(t, d, !0) : u.removeEventListener(t, d, !0);
636
+ }, p = () => {
637
+ c && i.state === "running" && i.suspend().catch(() => {});
638
+ let e = !s && !c && i.state === "suspended";
639
+ f(e), e && o && d();
631
640
  };
632
- i.addEventListener("statechange", f), f();
633
- let p = (async () => {
634
- let r = await Ge(i, t, {
641
+ i.addEventListener("statechange", p), p();
642
+ let m = (async () => {
643
+ let r = await qe(i, t, {
635
644
  ...n,
636
645
  enabled: a,
637
- inputGainDb: c()
646
+ inputGainDb: l()
638
647
  });
639
- await qe(i);
648
+ await Ye(i);
640
649
  let s = R(i, e);
641
650
  return r.port.postMessage({
642
651
  enabled: a,
643
- inputGainDb: c()
644
- }), s.connect(r).connect(i.destination), e.addEventListener("volumechange", () => r.port.postMessage({ inputGainDb: c() })), e.addEventListener("seeking", () => r.port.postMessage({ reset: "seek" })), e.addEventListener("emptied", () => r.port.postMessage({ reset: "source" })), o = r, r;
652
+ inputGainDb: l()
653
+ }), s.connect(r).connect(i.destination), e.addEventListener("volumechange", () => r.port.postMessage({ inputGainDb: l() })), e.addEventListener("seeking", () => r.port.postMessage({ reset: "seek" })), e.addEventListener("emptied", () => r.port.postMessage({ reset: "source" })), e.addEventListener("pause", () => {
654
+ c = !0, i.state === "running" && i.suspend().catch(() => {});
655
+ }), e.addEventListener("play", () => {
656
+ c = !1, d();
657
+ }), o = r, r;
645
658
  })();
646
- p.catch(() => {
647
- s = !0, d(!1), i.close().catch(() => {});
659
+ m.catch(() => {
660
+ s = !0, f(!1), i.close().catch(() => {});
648
661
  });
649
- let m = {
662
+ let h = {
650
663
  context: i,
651
- routed: p,
664
+ routed: m,
652
665
  setEnabled: (e) => {
653
666
  a = e, o?.port.postMessage({ enabled: a });
654
667
  },
655
668
  release: () => {
656
- s = !0, d(!1), e.isConnected ? i.state === "running" && i.suspend().catch(() => {}) : (Ke.delete(e), i.close().catch(() => {}));
669
+ s = !0, f(!1), e.isConnected ? i.state === "running" && i.suspend().catch(() => {}) : (Je.delete(e), i.close().catch(() => {}));
657
670
  },
658
671
  wake: () => {
659
- i.state !== "closed" && (s = !1, u(), f());
672
+ i.state !== "closed" && (s = !1, d(), p());
660
673
  }
661
674
  };
662
- return Ke.set(e, m), m;
663
- }, Ye = 20, Xe = 5, Ze = 1, Qe = 50, $e = ({ node: t, element: n, scriptUrl: r, source: i }) => {
675
+ return Je.set(e, h), h;
676
+ }, Ze = 20, Qe = 5, $e = 1, et = 50, tt = ({ node: t, element: n, scriptUrl: r, source: i }) => {
664
677
  let a = !1, o, s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), l = () => {
665
678
  for (let e of [...c]) e();
666
679
  c.clear();
@@ -707,7 +720,7 @@ var se = {
707
720
  }), S = () => p.postMessage({
708
721
  type: "playhead",
709
722
  time: n.currentTime
710
- }), C = setInterval(x, Qe), w = [
723
+ }), C = setInterval(x, et), w = [
711
724
  "play",
712
725
  "playing",
713
726
  "pause",
@@ -724,7 +737,7 @@ var se = {
724
737
  return t >= (h.end ?? T) - .05 ? null : t;
725
738
  }, N = (e) => j.get(Math.round(e * 10)) === g ? "idle" : e, F = () => {
726
739
  let e = n.currentTime, t = M(e), r = O && y !== D;
727
- if (t !== null && t < e + Ye) return r && k <= t + 1 && t <= A + Xe ? "read" : N(t);
740
+ if (t !== null && t < e + Ze) return r && k <= t + 1 && t <= A + Qe ? "read" : N(t);
728
741
  if (r) return "read";
729
742
  let i = t ?? M(0);
730
743
  return i === null ? "done" : N(i);
@@ -789,7 +802,7 @@ var se = {
789
802
  await H(e), e.finished && await V(!0);
790
803
  } else {
791
804
  await V(!1), j.set(Math.round(e * 10), g);
792
- let t = B.seek(Math.max(0, e - Ze));
805
+ let t = B.seek(Math.max(0, e - $e));
793
806
  f(!0);
794
807
  let r = await L(t);
795
808
  if (a) return;
@@ -861,12 +874,12 @@ var se = {
861
874
  },
862
875
  stop: ne
863
876
  };
864
- }, et = (e, t, n, r, i) => {
877
+ }, nt = (e, t, n, r, i) => {
865
878
  let a = w(null), [o, s] = T(!1), [c, l] = T(null);
866
879
  S(() => {
867
880
  if (e && t) {
868
881
  if (n && !a.current) {
869
- let r = Je(e, t, { enabled: n });
882
+ let r = Xe(e, t, { enabled: n });
870
883
  a.current = r, r.routed.then((e) => {
871
884
  a.current === r && l(e);
872
885
  }, (e) => {
@@ -890,7 +903,7 @@ var se = {
890
903
  return S(() => {
891
904
  let r = f.current;
892
905
  if (!c || !e || !t || !n || !r) return;
893
- let i = $e({
906
+ let i = tt({
894
907
  node: c,
895
908
  element: e,
896
909
  scriptUrl: t,
@@ -912,7 +925,7 @@ var se = {
912
925
  ]), S(() => {
913
926
  d.current?.update(i);
914
927
  }, [i]), { refused: o };
915
- }, tt = () => {
928
+ }, rt = () => {
916
929
  let e, t, n, r = () => n && e?.audioStreamIndex === n.audioStreamIndex ? n : void 0;
917
930
  return {
918
931
  push: (n) => {
@@ -958,7 +971,7 @@ var se = {
958
971
  medium: "\n font-weight: 500;\n font-size: calc(0.8 * var(--mp-unit));\n line-height: calc(1.1 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1 * var(--mp-unit));\n line-height: calc(1.4 * var(--mp-unit));\n }\n ",
959
972
  regular: "\n font-weight: 400;\n font-size: calc(0.8 * var(--mp-unit));\n line-height: calc(1.1 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1 * var(--mp-unit));\n line-height: calc(1.4 * var(--mp-unit));\n }\n "
960
973
  }
961
- }, nt = D`
974
+ }, it = D`
962
975
  display: flex;
963
976
  justify-content: center;
964
977
  align-items: center;
@@ -971,7 +984,7 @@ var se = {
971
984
  margin: auto;
972
985
  pointer-events: none;
973
986
  }
974
- `, rt = D`
987
+ `, at = D`
975
988
  position: absolute;
976
989
  top: 0;
977
990
  left: 0;
@@ -1000,9 +1013,9 @@ var se = {
1000
1013
 
1001
1014
  background: linear-gradient(180deg, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.3) 30%, rgba(0,0,0,0.2) 60%, rgba(0,0,0,0.1) 80%, transparent 100%);
1002
1015
  transition: opacity 0.1s cubic-bezier(.4,0,1,1);
1003
- `, it = O`
1016
+ `, ot = O`
1004
1017
  to { transform: rotate(360deg); }
1005
- `, at = D`
1018
+ `, st = D`
1006
1019
  position: absolute;
1007
1020
  inset: 0;
1008
1021
  z-index: 2;
@@ -1018,9 +1031,9 @@ var se = {
1018
1031
  border-radius: 50%;
1019
1032
  border: 3px solid rgba(255, 255, 255, 0.25);
1020
1033
  border-top-color: #fff;
1021
- animation: ${it} 0.8s linear infinite;
1034
+ animation: ${ot} 0.8s linear infinite;
1022
1035
  }
1023
- `, ot = D`
1036
+ `, ct = D`
1024
1037
  position: absolute;
1025
1038
  inset: auto 0 20%;
1026
1039
  z-index: 3;
@@ -1030,36 +1043,36 @@ var se = {
1030
1043
  ${$.bLarge.regular}
1031
1044
  text-shadow: 0 0 4px rgba(0, 0, 0, 1);
1032
1045
  pointer-events: none;
1033
- `, st = new Set(Object.values(a)), ct = (e) => e instanceof Error && st.has(e.label ?? ""), lt = (e, { format: t }) => ct(e) ? t(e.label, e.values) : e instanceof Error ? e.message : typeof e == "string" ? e : t(a.failed), ut = ({ onSubtitleRef: e }) => {
1046
+ `, lt = new Set(Object.values(a)), ut = (e) => e instanceof Error && lt.has(e.label ?? ""), dt = (e, { format: t }) => ut(e) ? t(e.label, e.values) : e instanceof Error ? e.message : typeof e == "string" ? e : t(a.failed), ft = ({ onSubtitleRef: e }) => {
1034
1047
  let t = Q(), n = X((e) => e.title), r = X((e) => e.hideUI), i = X((e) => e.playbackError), a = X((e) => e.ready), o = X((e) => e.size), s = X((e) => e.waiting), c = X((e) => e.seekingTo);
1035
1048
  return /* @__PURE__ */ L(F, { children: [
1036
1049
  n ? /* @__PURE__ */ I("div", {
1037
1050
  className: "title",
1038
1051
  dir: "auto",
1039
- css: rt,
1052
+ css: at,
1040
1053
  style: { ...r ? {
1041
1054
  opacity: "0",
1042
1055
  pointerEvents: "none"
1043
1056
  } : {} },
1044
1057
  children: n
1045
1058
  }) : void 0,
1046
- ((o ? !a : s) || c !== void 0) && !i ? /* @__PURE__ */ I("div", { css: at }) : void 0,
1059
+ ((o ? !a : s) || c !== void 0) && !i ? /* @__PURE__ */ I("div", { css: st }) : void 0,
1047
1060
  i ? /* @__PURE__ */ I("div", {
1048
- css: ot,
1061
+ css: ct,
1049
1062
  dir: "auto",
1050
- children: lt(i, t)
1063
+ children: dt(i, t)
1051
1064
  }) : void 0,
1052
1065
  /* @__PURE__ */ I("div", {
1053
1066
  className: "subtitles",
1054
1067
  ref: e,
1055
- css: nt
1068
+ css: it
1056
1069
  })
1057
1070
  ] });
1058
- }, dt = 1e-4, ft = 1, pt = (e) => Math.max(dt, Math.min(ft, e)) ** 2, mt = (e) => Math.max(dt, Math.min(ft, e)) ** (ft / 2), ht = (e) => {
1071
+ }, pt = 1e-4, mt = 1, ht = (e) => Math.max(pt, Math.min(mt, e)) ** 2, gt = (e) => Math.max(pt, Math.min(mt, e)) ** (mt / 2), _t = (e) => {
1059
1072
  if (e === void 0) return "0:00";
1060
1073
  let t = Math.floor(e / 3600), n = Math.floor(e % 3600 / 60), r = Math.floor(e % 60);
1061
1074
  return t > 0 ? `${t}:${n < 10 ? "0" : ""}${n}:${r < 10 ? "0" : ""}${r}` : `${n}:${r < 10 ? "0" : ""}${r}`;
1062
- }, gt = (e, t) => `${ht(e)} / ${ht(t)}`, _t = (e) => D`
1075
+ }, vt = (e, t) => `${_t(e)} / ${_t(t)}`, yt = (e) => D`
1063
1076
  display: flex;
1064
1077
  justify-content: flex-start;
1065
1078
 
@@ -1105,25 +1118,25 @@ var se = {
1105
1118
  ${e === "lg" && D`
1106
1119
  padding: calc(1.2 * var(--mp-unit))!important;
1107
1120
  `}
1108
- `, vt = {
1121
+ `, bt = {
1109
1122
  x: -1,
1110
1123
  y: -1,
1111
1124
  anchors: 0
1112
- }, yt = (e) => {
1113
- vt.x = e.clientX, vt.y = e.clientY;
1114
- }, bt = () => (vt.anchors++ === 0 && window.addEventListener("pointermove", yt, {
1125
+ }, xt = (e) => {
1126
+ bt.x = e.clientX, bt.y = e.clientY;
1127
+ }, St = () => (bt.anchors++ === 0 && window.addEventListener("pointermove", xt, {
1115
1128
  capture: !0,
1116
1129
  passive: !0
1117
1130
  }), () => {
1118
- --vt.anchors === 0 && window.removeEventListener("pointermove", yt, { capture: !0 });
1119
- }), xt = v(!1), St = ({ id: e, toolTipText: t, text: n, delayShow: r = 0, closeDelay: i = 0, offset: a = 20, tooltipPlace: o = "top", disabled: s = !1, size: c = "md" }) => {
1120
- let l = w(null), u = w(null), d = x(xt);
1131
+ --bt.anchors === 0 && window.removeEventListener("pointermove", xt, { capture: !0 });
1132
+ }), Ct = v(!1), wt = ({ id: e, toolTipText: t, text: n, delayShow: r = 0, closeDelay: i = 0, offset: a = 20, tooltipPlace: o = "top", disabled: s = !1, size: c = "md" }) => {
1133
+ let l = w(null), u = w(null), d = x(Ct);
1121
1134
  return S(() => {
1122
- let e = bt(), t = () => {
1135
+ let e = St(), t = () => {
1123
1136
  let e = l.current;
1124
1137
  if (!e) return;
1125
1138
  let { left: t, right: n, top: r, bottom: i } = e.getBoundingClientRect();
1126
- vt.x >= t && vt.x < n && vt.y >= r && vt.y < i || u.current?.close();
1139
+ bt.x >= t && bt.x < n && bt.y >= r && bt.y < i || u.current?.close();
1127
1140
  }, n = ["fullscreenchange", "webkitfullscreenchange"];
1128
1141
  for (let e of n) document.addEventListener(e, t);
1129
1142
  return d && window.addEventListener("resize", t), () => {
@@ -1142,12 +1155,12 @@ var se = {
1142
1155
  children: n
1143
1156
  }), !s && /* @__PURE__ */ I(oe, {
1144
1157
  ref: u,
1145
- css: _t(c),
1158
+ css: yt(c),
1146
1159
  id: e,
1147
1160
  noArrow: !0,
1148
1161
  children: t
1149
1162
  })] });
1150
- }, Ct = ({ ref: e, onChange: t, orientation: n = "horizontal", disabled: r = !1 }) => {
1163
+ }, Tt = ({ ref: e, onChange: t, orientation: n = "horizontal", disabled: r = !1 }) => {
1151
1164
  let [i, a] = T(!1), o = w(t);
1152
1165
  o.current = t;
1153
1166
  let s = w(null), c = b((t, r) => {
@@ -1186,7 +1199,7 @@ var se = {
1186
1199
  style: { touchAction: "none" }
1187
1200
  }
1188
1201
  };
1189
- }, wt = D`
1202
+ }, Et = D`
1190
1203
  position: relative;
1191
1204
  height: calc(.4 * var(--mp-unit));
1192
1205
 
@@ -1405,7 +1418,7 @@ var se = {
1405
1418
  --thumbnail-width: calc(18 * var(--mp-unit));
1406
1419
  --thumbnail-half: calc(9 * var(--mp-unit));
1407
1420
  }
1408
- `, Tt = 4, Et = () => {
1421
+ `, Dt = 4, Ot = () => {
1409
1422
  let e = X(), t = X((e) => e.currentTime), n = X((e) => e.requestSeek), r = X((e) => e.duration), i = X((e) => e.size), a = X((e) => e.downloadedRanges), o = X((e) => e.buffered), s = X((e) => e.indexes), c = X((e) => e.thumbnails), l = X((e) => e.thumbnailAt), u = X((e) => e.requestThumbnail), d = X((e) => e.chapters), f = X((e) => e.seekingTo), h = X((e) => e.setSourceState), g = X((e) => e.hideUI), _ = w(null), [v, y] = T(void 0), [b, x] = T(void 0), E = (e) => {
1410
1423
  x(e), u(e);
1411
1424
  }, D = !!b;
@@ -1414,13 +1427,13 @@ var se = {
1414
1427
  }, [h, D]), S(() => {
1415
1428
  g && E(void 0);
1416
1429
  }, [g]);
1417
- let O = w(void 0), k = w(0), A = w(void 0), j = w(void 0), M = w(!1), { dragging: N, handlers: P } = Ct({
1430
+ let O = w(void 0), k = w(0), A = w(void 0), j = w(void 0), M = w(!1), { dragging: N, handlers: P } = Tt({
1418
1431
  ref: _,
1419
1432
  onChange: (e) => {
1420
1433
  if (k.current += 1, A.current = e, j.current === void 0) j.current = e;
1421
1434
  else if (!M.current) {
1422
1435
  let t = _.current?.getBoundingClientRect().width ?? 0;
1423
- Math.abs(e - j.current) * t > Tt && (M.current = !0);
1436
+ Math.abs(e - j.current) * t > Dt && (M.current = !0);
1424
1437
  }
1425
1438
  y(e), O.current !== "mouse" && E(e * r);
1426
1439
  }
@@ -1526,7 +1539,7 @@ var se = {
1526
1539
  ]
1527
1540
  });
1528
1541
  return /* @__PURE__ */ L("div", {
1529
- css: wt,
1542
+ css: Et,
1530
1543
  ref: _,
1531
1544
  className: [
1532
1545
  "progress-bar",
@@ -1547,7 +1560,7 @@ var se = {
1547
1560
  },
1548
1561
  children: [/* @__PURE__ */ I("span", {
1549
1562
  className: "cursor-time-value",
1550
- children: ht(b)
1563
+ children: _t(b)
1551
1564
  }), J ? /* @__PURE__ */ I("span", {
1552
1565
  className: "chapter-title",
1553
1566
  children: J.title
@@ -1571,7 +1584,7 @@ var se = {
1571
1584
  })
1572
1585
  ]
1573
1586
  });
1574
- }, Dt = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%23fff'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='icon%20icon-tabler%20icons-tabler-outline%20icon-tabler-picture-in-picture'%3e%3cpath%20stroke='none'%20d='M0%200h24v24H0z'%20fill='none'%20/%3e%3cpath%20d='M11%2019h-6a2%202%200%200%201%20-2%20-2v-10a2%202%200%200%201%202%20-2h14a2%202%200%200%201%202%202v4'%20/%3e%3cpath%20d='M14%2014m0%201a1%201%200%200%201%201%20-1h5a1%201%200%200%201%201%201v3a1%201%200%200%201%20-1%201h-5a1%201%200%200%201%20-1%20-1z'%20/%3e%3c/svg%3e", Ot = {
1587
+ }, kt = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%23fff'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='icon%20icon-tabler%20icons-tabler-outline%20icon-tabler-picture-in-picture'%3e%3cpath%20stroke='none'%20d='M0%200h24v24H0z'%20fill='none'%20/%3e%3cpath%20d='M11%2019h-6a2%202%200%200%201%20-2%20-2v-10a2%202%200%200%201%202%20-2h14a2%202%200%200%201%202%202v4'%20/%3e%3cpath%20d='M14%2014m0%201a1%201%200%200%201%201%20-1h5a1%201%200%200%201%201%201v3a1%201%200%200%201%20-1%201h-5a1%201%200%200%201%20-1%20-1z'%20/%3e%3c/svg%3e", At = {
1575
1588
  xmlns: "http://www.w3.org/2000/svg",
1576
1589
  width: 24,
1577
1590
  height: 24,
@@ -1581,8 +1594,8 @@ var se = {
1581
1594
  strokeWidth: 2,
1582
1595
  strokeLinecap: "round",
1583
1596
  strokeLinejoin: "round"
1584
- }, kt = (e) => /* @__PURE__ */ L("svg", {
1585
- ...Ot,
1597
+ }, jt = (e) => /* @__PURE__ */ L("svg", {
1598
+ ...At,
1586
1599
  ...e,
1587
1600
  children: [
1588
1601
  /* @__PURE__ */ I("path", { d: "M21 11V7a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h5" }),
@@ -1596,8 +1609,8 @@ var se = {
1596
1609
  }),
1597
1610
  /* @__PURE__ */ I("path", { d: "M14.5 18.5h2m2 0h1" })
1598
1611
  ]
1599
- }), At = (e) => /* @__PURE__ */ L("svg", {
1600
- ...Ot,
1612
+ }), Mt = (e) => /* @__PURE__ */ L("svg", {
1613
+ ...At,
1601
1614
  ...e,
1602
1615
  children: [
1603
1616
  /* @__PURE__ */ I("path", { d: "M21 11V7a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h5" }),
@@ -1611,7 +1624,7 @@ var se = {
1611
1624
  }),
1612
1625
  /* @__PURE__ */ I("path", { d: "M6 9h3m2 0h2" })
1613
1626
  ]
1614
- }), jt = D`
1627
+ }), Nt = D`
1615
1628
  .popover {
1616
1629
  position: absolute;
1617
1630
  /* Anchored to the PLAYER's right edge, never to the gear. The gear is not the last control in the
@@ -1739,7 +1752,7 @@ var se = {
1739
1752
  ${$.bSmall.regular}
1740
1753
  }
1741
1754
  }
1742
- `, Mt = ({ title: e, tracks: t, selected: n, onSelect: r, onBack: i, offLabel: o, pending: s, failed: c }) => {
1755
+ `, Pt = ({ title: e, tracks: t, selected: n, onSelect: r, onBack: i, offLabel: o, pending: s, failed: c }) => {
1743
1756
  let { format: l } = Q(), u = s !== void 0, d = (e, i, a) => {
1744
1757
  let o = u && s === e, c = u || t.find((t) => t.id === e)?.disabled;
1745
1758
  return /* @__PURE__ */ L("div", {
@@ -1767,7 +1780,7 @@ var se = {
1767
1780
  t.map(({ id: e, label: t }) => d(e, t, "description"))
1768
1781
  ]
1769
1782
  });
1770
- }, Nt = ({ onReset: e } = {}) => {
1783
+ }, Ft = ({ onReset: e } = {}) => {
1771
1784
  let t = w(null), [n, r] = T(!1), [i, a] = T(void 0), [o, s] = T(!1), c = w(e);
1772
1785
  c.current = e;
1773
1786
  let l = () => {
@@ -1808,7 +1821,7 @@ var se = {
1808
1821
  });
1809
1822
  }
1810
1823
  };
1811
- }, Pt = D`
1824
+ }, It = D`
1812
1825
  /* Not a containing block, for the reason given on popoverStyle: the menu anchors to the control bar,
1813
1826
  which is the width of the player box, so it can be clamped to it. */
1814
1827
  position: static;
@@ -1824,7 +1837,7 @@ position: static;
1824
1837
  }
1825
1838
  }
1826
1839
 
1827
- ${jt}
1840
+ ${Nt}
1828
1841
 
1829
1842
  .popover.error-list {
1830
1843
  /* Wider than a track menu and taller, because these rows are sentences rather than labels, and a
@@ -1896,25 +1909,25 @@ ${jt}
1896
1909
  }
1897
1910
  }
1898
1911
  }
1899
- `, Ft = (e, t) => new Date(e).toLocaleTimeString(t), It = (e) => e === void 0 || !Number.isFinite(e) ? void 0 : ht(Math.max(0, e)), Lt = (e) => e.reduce((e, t) => e + t.count, 0), Rt = (e) => e.map((e, t) => {
1900
- let n = It(e.atMediaTime), r = e.count > 1 ? `${new Date(e.at).toISOString()} to ${new Date(e.lastAt).toISOString()} ×${e.count}` : new Date(e.at).toISOString();
1912
+ `, Lt = (e, t) => new Date(e).toLocaleTimeString(t), Rt = (e) => e === void 0 || !Number.isFinite(e) ? void 0 : _t(Math.max(0, e)), zt = (e) => e.reduce((e, t) => e + t.count, 0), Bt = (e) => e.map((e, t) => {
1913
+ let n = Rt(e.atMediaTime), r = e.count > 1 ? `${new Date(e.at).toISOString()} to ${new Date(e.lastAt).toISOString()} ×${e.count}` : new Date(e.at).toISOString();
1901
1914
  return [
1902
1915
  `${t + 1}. ${r}${n ? ` (at ${n})` : ""}${e.recovered ? " [recovered]" : ""}`,
1903
1916
  e.message,
1904
1917
  e.detail
1905
1918
  ].filter(Boolean).join("\n");
1906
- }).join("\n\n"), zt = () => {
1907
- let e = X((e) => e.playbackErrors), { format: t, locale: n } = Q(), { open: r, toggle: i, containerRef: o } = Nt(), [s, c] = T(!1);
1919
+ }).join("\n\n"), Vt = () => {
1920
+ let e = X((e) => e.playbackErrors), { format: t, locale: n } = Q(), { open: r, toggle: i, containerRef: o } = Ft(), [s, c] = T(!1);
1908
1921
  if (e.length === 0) return null;
1909
1922
  let l = () => {
1910
- navigator.clipboard?.writeText(Rt(e)).then(() => {
1923
+ navigator.clipboard?.writeText(Bt(e)).then(() => {
1911
1924
  c(!0), setTimeout(() => c(!1), 2e3);
1912
1925
  }, (e) => console.warn("[media-player] could not copy the errors:", e));
1913
- }, u = t(a.errors, { count: Lt(e) });
1926
+ }, u = t(a.errors, { count: zt(e) });
1914
1927
  return /* @__PURE__ */ L("div", {
1915
- css: Pt,
1928
+ css: It,
1916
1929
  ref: o,
1917
- children: [/* @__PURE__ */ I(St, {
1930
+ children: [/* @__PURE__ */ I(wt, {
1918
1931
  id: "errors",
1919
1932
  disabled: r,
1920
1933
  text: /* @__PURE__ */ I("button", {
@@ -1944,10 +1957,10 @@ ${jt}
1944
1957
  className: "when",
1945
1958
  children: [
1946
1959
  e.count > 1 ? t(a.errorSpan, {
1947
- start: Ft(e.at, n),
1948
- end: Ft(e.lastAt, n)
1949
- }) : Ft(e.at, n),
1950
- It(e.atMediaTime) ? ` ${t(a.errorAt, { time: It(e.atMediaTime) })}` : "",
1960
+ start: Lt(e.at, n),
1961
+ end: Lt(e.lastAt, n)
1962
+ }) : Lt(e.at, n),
1963
+ Rt(e.atMediaTime) ? ` ${t(a.errorAt, { time: Rt(e.atMediaTime) })}` : "",
1951
1964
  e.recovered ? ` ${t(a.recovered)}` : "",
1952
1965
  e.count > 1 ? /* @__PURE__ */ I("span", {
1953
1966
  className: "count",
@@ -1967,7 +1980,7 @@ ${jt}
1967
1980
  }, `${e.at}-${r}`))]
1968
1981
  })]
1969
1982
  });
1970
- }, Bt = D`
1983
+ }, Ht = D`
1971
1984
  display: flex;
1972
1985
  align-items: center;
1973
1986
  justify-content: center;
@@ -2020,8 +2033,8 @@ width: 100%;
2020
2033
  }
2021
2034
  }
2022
2035
  }
2023
- `, Vt = () => {
2024
- let e = X(), { format: t, number: n } = Q(), r = X((e) => e.playbackRate), i = w(null), o = w(null), s = .25, c = 2.75, l = (e, t = .05) => Math.round(e / t) * t, u = l(r || 1), d = (e) => (e - s) / c * 100, f = (e) => l(s + e * c), { handlers: p } = Ct({
2036
+ `, Ut = () => {
2037
+ let e = X(), { format: t, number: n } = Q(), r = X((e) => e.playbackRate), i = w(null), o = w(null), s = .25, c = 2.75, l = (e, t = .05) => Math.round(e / t) * t, u = l(r || 1), d = (e) => (e - s) / c * 100, f = (e) => l(s + e * c), { handlers: p } = Tt({
2025
2038
  ref: o,
2026
2039
  onChange: (t) => e.setPlaybackRate(f(t))
2027
2040
  }), m = (t) => {
@@ -2037,7 +2050,7 @@ width: 100%;
2037
2050
  }, [r]);
2038
2051
  let h = d(u);
2039
2052
  return /* @__PURE__ */ L("div", {
2040
- css: Bt,
2053
+ css: Ht,
2041
2054
  children: [/* @__PURE__ */ I("div", { children: t(a.speed, { rate: n(u, {
2042
2055
  minimumFractionDigits: 2,
2043
2056
  maximumFractionDigits: 2
@@ -2058,7 +2071,7 @@ width: 100%;
2058
2071
  })
2059
2072
  })]
2060
2073
  });
2061
- }, Ht = D`
2074
+ }, Wt = D`
2062
2075
  /* Deliberately NOT a containing block. The menu anchors to the control bar instead, which is exactly
2063
2076
  as wide as the player box and can therefore be clamped to it. The outside-click check uses
2064
2077
  \`contains\` on the ref, which is DOM containment and needs no position, and the bar's other
@@ -2076,7 +2089,7 @@ position: static;
2076
2089
  }
2077
2090
  }
2078
2091
 
2079
- ${jt}
2092
+ ${Nt}
2080
2093
 
2081
2094
  .switch {
2082
2095
  position: relative;
@@ -2153,13 +2166,13 @@ ${jt}
2153
2166
  }
2154
2167
  }
2155
2168
 
2156
- `, Ut = [
2169
+ `, Gt = [
2157
2170
  .5,
2158
2171
  1,
2159
2172
  1.5,
2160
2173
  2
2161
- ], Wt = () => {
2162
- let e = X(), { format: t, number: n } = Q(), r = X((e) => e.playbackRate), i = X((e) => e.audioTracks), o = X((e) => e.selectedAudioTrack), s = X((e) => e.selectAudioTrack), c = X((e) => e.quality), l = X((e) => e.volumeNormalizer), u = X((e) => e.autoplayNext), [d, f] = T(0), { open: p, toggle: m, containerRef: h, pending: g, failed: _, runSelect: v } = Nt({ onReset: () => f(0) }), y = (t) => {
2174
+ ], Kt = () => {
2175
+ let e = X(), { format: t, number: n } = Q(), r = X((e) => e.playbackRate), i = X((e) => e.audioTracks), o = X((e) => e.selectedAudioTrack), s = X((e) => e.selectAudioTrack), c = X((e) => e.quality), l = X((e) => e.volumeNormalizer), u = X((e) => e.autoplayNext), [d, f] = T(0), { open: p, toggle: m, containerRef: h, pending: g, failed: _, runSelect: v } = Ft({ onReset: () => f(0) }), y = (t) => {
2163
2176
  e.setPlaybackRate(t), f(0);
2164
2177
  }, b = (e) => {
2165
2178
  e !== void 0 && v(e, () => s(e));
@@ -2169,10 +2182,10 @@ ${jt}
2169
2182
  f(e);
2170
2183
  };
2171
2184
  return /* @__PURE__ */ L("div", {
2172
- css: Ht,
2185
+ css: Wt,
2173
2186
  ref: h,
2174
2187
  children: [
2175
- /* @__PURE__ */ I(St, {
2188
+ /* @__PURE__ */ I(wt, {
2176
2189
  id: "settings",
2177
2190
  disabled: p,
2178
2191
  text: /* @__PURE__ */ I("button", {
@@ -2240,18 +2253,18 @@ ${jt}
2240
2253
  }),
2241
2254
  /* @__PURE__ */ I("div", {
2242
2255
  className: "slider no-hover",
2243
- children: /* @__PURE__ */ I(Vt, {})
2256
+ children: /* @__PURE__ */ I(Ut, {})
2244
2257
  }),
2245
2258
  /* @__PURE__ */ I("div", {
2246
2259
  className: "options no-hover",
2247
- children: Ut.map((e) => /* @__PURE__ */ I("div", {
2260
+ children: Gt.map((e) => /* @__PURE__ */ I("div", {
2248
2261
  onClick: () => y(e),
2249
2262
  children: t(a.speed, { rate: n(e) })
2250
2263
  }, e))
2251
2264
  })
2252
2265
  ]
2253
2266
  }),
2254
- p && d === 2 && /* @__PURE__ */ I(Mt, {
2267
+ p && d === 2 && /* @__PURE__ */ I(Pt, {
2255
2268
  title: t(a.audio),
2256
2269
  tracks: i,
2257
2270
  selected: o,
@@ -2260,7 +2273,7 @@ ${jt}
2260
2273
  pending: g,
2261
2274
  failed: _
2262
2275
  }),
2263
- p && d === 3 && c && /* @__PURE__ */ I(Mt, {
2276
+ p && d === 3 && c && /* @__PURE__ */ I(Pt, {
2264
2277
  title: t(a.quality),
2265
2278
  tracks: c.options,
2266
2279
  selected: c.selectedId ?? void 0,
@@ -2272,7 +2285,7 @@ ${jt}
2272
2285
  })
2273
2286
  ]
2274
2287
  });
2275
- }, Gt = D`
2288
+ }, qt = D`
2276
2289
  /* Not a containing block, for the reason given on popoverStyle: the menu anchors to the control bar,
2277
2290
  which is the width of the player box, so it can be clamped to it. */
2278
2291
  position: static;
@@ -2288,15 +2301,15 @@ position: static;
2288
2301
  }
2289
2302
  }
2290
2303
 
2291
- ${jt}
2292
- `, Kt = () => {
2293
- let { format: e } = Q(), t = X((e) => e.subtitleTracks), n = X((e) => e.selectedSubtitleTrack), r = X((e) => e.selectSubtitleTrack), i = X((e) => e.subtitleOffLabel), { open: o, toggle: s, containerRef: c, pending: l, failed: u, runSelect: d } = Nt();
2304
+ ${Nt}
2305
+ `, Jt = () => {
2306
+ let { format: e } = Q(), t = X((e) => e.subtitleTracks), n = X((e) => e.selectedSubtitleTrack), r = X((e) => e.selectSubtitleTrack), i = X((e) => e.subtitleOffLabel), { open: o, toggle: s, containerRef: c, pending: l, failed: u, runSelect: d } = Ft();
2294
2307
  if (t.length === 0) return null;
2295
2308
  let f = n !== void 0;
2296
2309
  return /* @__PURE__ */ L("div", {
2297
- css: Gt,
2310
+ css: qt,
2298
2311
  ref: c,
2299
- children: [/* @__PURE__ */ I(St, {
2312
+ children: [/* @__PURE__ */ I(wt, {
2300
2313
  id: "subtitles",
2301
2314
  disabled: o,
2302
2315
  text: /* @__PURE__ */ I("button", {
@@ -2309,7 +2322,7 @@ ${jt}
2309
2322
  children: f ? /* @__PURE__ */ I(z, { className: "captions" }) : /* @__PURE__ */ I(B, { className: "captions-off" })
2310
2323
  }),
2311
2324
  toolTipText: /* @__PURE__ */ I("span", { children: e(a.subtitles) })
2312
- }), o && /* @__PURE__ */ I(Mt, {
2325
+ }), o && /* @__PURE__ */ I(Pt, {
2313
2326
  title: e(a.subtitles),
2314
2327
  tracks: t,
2315
2328
  selected: n,
@@ -2319,13 +2332,13 @@ ${jt}
2319
2332
  failed: u
2320
2333
  })]
2321
2334
  });
2322
- }, qt = {
2335
+ }, Yt = {
2323
2336
  primary: "#EAEBEE",
2324
2337
  secondary: "#D0D0D9",
2325
2338
  hover: "rgba(255, 255, 255, 0.13)",
2326
2339
  borderPrimary: "#384F70",
2327
2340
  backgroundTooltip: "#222222"
2328
- }, Jt = D`
2341
+ }, Xt = D`
2329
2342
  display: flex;
2330
2343
  align-items: center;
2331
2344
 
@@ -2368,8 +2381,8 @@ ${jt}
2368
2381
  width: 10px;
2369
2382
  height: 10px;
2370
2383
  }
2371
- `, Yt = ({ value: e, onChange: t }) => {
2372
- let { number: n } = Q(), r = X((e) => e.volume), i = X((e) => e.muted), a = w(null), o = w(null), { handlers: s } = Ct({
2384
+ `, Zt = ({ value: e, onChange: t }) => {
2385
+ let { number: n } = Q(), r = X((e) => e.volume), i = X((e) => e.muted), a = w(null), o = w(null), { handlers: s } = Tt({
2373
2386
  ref: o,
2374
2387
  onChange: t
2375
2388
  }), c = (n) => {
@@ -2383,12 +2396,12 @@ ${jt}
2383
2396
  e && e.removeEventListener("wheel", c);
2384
2397
  };
2385
2398
  }, [e]);
2386
- let l = e * 100, u = C(() => Math.round(i ? 0 : mt(r) * 100), [r, i]);
2387
- return /* @__PURE__ */ I(St, {
2399
+ let l = e * 100, u = C(() => Math.round(i ? 0 : gt(r) * 100), [r, i]);
2400
+ return /* @__PURE__ */ I(wt, {
2388
2401
  id: "volume-slider",
2389
2402
  text: /* @__PURE__ */ I("div", {
2390
2403
  ref: a,
2391
- css: Jt,
2404
+ css: Xt,
2392
2405
  ...s,
2393
2406
  children: /* @__PURE__ */ I("div", {
2394
2407
  ref: o,
@@ -2407,7 +2420,7 @@ ${jt}
2407
2420
  children: n(u / 100, { style: "percent" })
2408
2421
  })
2409
2422
  });
2410
- }, Xt = D`
2423
+ }, Qt = D`
2411
2424
  position: relative;
2412
2425
  display: flex;
2413
2426
  align-items: center;
@@ -2470,11 +2483,11 @@ ${jt}
2470
2483
  }
2471
2484
  }
2472
2485
 
2473
- `, Zt = ({ ref: e }) => {
2474
- let t = X(), { format: n } = Q(), r = X((e) => e.volume), i = X((e) => e.muted), o = C(() => mt(r), [r]);
2486
+ `, $t = ({ ref: e }) => {
2487
+ let t = X(), { format: n } = Q(), r = X((e) => e.volume), i = X((e) => e.muted), o = C(() => gt(r), [r]);
2475
2488
  return /* @__PURE__ */ L("div", {
2476
- css: Xt,
2477
- children: [/* @__PURE__ */ I(St, {
2489
+ css: Qt,
2490
+ children: [/* @__PURE__ */ I(wt, {
2478
2491
  id: "sound",
2479
2492
  text: /* @__PURE__ */ I("button", {
2480
2493
  className: "sound",
@@ -2493,16 +2506,16 @@ ${jt}
2493
2506
  className: "volume-slider-container",
2494
2507
  children: /* @__PURE__ */ I("div", {
2495
2508
  className: "volume-slider-background",
2496
- children: /* @__PURE__ */ I(Yt, {
2509
+ children: /* @__PURE__ */ I(Zt, {
2497
2510
  value: i ? 0 : o,
2498
2511
  onChange: (e) => {
2499
- t.setVolume(pt(e));
2512
+ t.setVolume(ht(e));
2500
2513
  }
2501
2514
  })
2502
2515
  })
2503
2516
  })]
2504
2517
  });
2505
- }, Qt = .05, $t = 5, en = 50, tn = 1e3, nn = D`
2518
+ }, en = .05, tn = 5, nn = 50, rn = 1e3, an = D`
2506
2519
  position: absolute;
2507
2520
  bottom: 0;
2508
2521
  width: 100%;
@@ -2594,7 +2607,7 @@ ${jt}
2594
2607
  /* .armed is the hover of a control letting its click through, which takes no pointer events
2595
2608
  of its own and so is never :hover */
2596
2609
  :hover, &.armed {
2597
- background-color: ${qt.hover};
2610
+ background-color: ${Yt.hover};
2598
2611
  }
2599
2612
 
2600
2613
  /* the hit area grows, the icon does not, keyed on the pointer because a narrow desktop
@@ -2632,12 +2645,12 @@ ${jt}
2632
2645
  }
2633
2646
  }
2634
2647
  }
2635
- `, rn = ({ shortcuts: e = "window", root: t, fullscreen: n }) => {
2648
+ `, on = ({ shortcuts: e = "window", root: t, fullscreen: n }) => {
2636
2649
  let r = X(), { format: i } = Q(), o = X((e) => e.paused), s = X((e) => e.currentTime), c = X((e) => e.duration), l = X((e) => e.seekingTo), u = X((e) => e.fullscreen), d = n ? n.active : u, f = w(n);
2637
2650
  f.current = n;
2638
2651
  let p = X((e) => e.hideUI), m = X((e) => e.togglePictureInPicture), h = X((e) => e.pictureInPictureMode), g = X((e) => e.burnedInSubtitles), _ = X((e) => e.passThroughPictureInPicture), v = X((e) => e.subtitleTracks), y = X((e) => e.requestSeek), x = X((e) => e.stepFrame), [C, E] = T(null), D = w(null), O = w(void 0), k = h === "burn-in", A = v.length > 0, j = c > 0 && s === c, M = b(({ direction: e, stepSize: t }) => {
2639
- let n = mt(r.volume), i = e === "up" ? t : -t, a = Math.max(0, Math.min(1, n + i)), o = r.muted;
2640
- r.setVolume(pt(a)), o && !r.muted && r.toggleMuted();
2652
+ let n = gt(r.volume), i = e === "up" ? t : -t, a = Math.max(0, Math.min(1, n + i)), o = r.muted;
2653
+ r.setVolume(ht(a)), o && !r.muted && r.toggleMuted();
2641
2654
  }, [r]), N = w(!1), P = b(() => {
2642
2655
  f.current ? f.current.request() : r.toggleFullscreen();
2643
2656
  }, [r]);
@@ -2656,16 +2669,16 @@ ${jt}
2656
2669
  else if (a.key === "m") r.toggleMuted();
2657
2670
  else if (a.key === "ArrowUp") M({
2658
2671
  direction: "up",
2659
- stepSize: Qt
2672
+ stepSize: en
2660
2673
  });
2661
2674
  else if (a.key === "ArrowDown") M({
2662
2675
  direction: "down",
2663
- stepSize: Qt
2676
+ stepSize: en
2664
2677
  });
2665
2678
  else if (a.key === "ArrowRight") {
2666
2679
  if (!r.duration) return;
2667
- n(Math.min(r.currentTime + $t, r.duration));
2668
- } else a.key === "ArrowLeft" ? n(Math.max(r.currentTime - $t, 0)) : (a.key === "<" || a.key === ">") && x ? x(a.key === ">" ? 1 : -1) : l = !1;
2680
+ n(Math.min(r.currentTime + tn, r.duration));
2681
+ } else a.key === "ArrowLeft" ? n(Math.max(r.currentTime - tn, 0)) : (a.key === "<" || a.key === ">") && x ? x(a.key === ">" ? 1 : -1) : l = !1;
2669
2682
  l && a.preventDefault();
2670
2683
  };
2671
2684
  return window.addEventListener("keydown", o), window.addEventListener("pointerdown", a, !0), window.addEventListener("focusin", a, !0), () => {
@@ -2683,10 +2696,10 @@ ${jt}
2683
2696
  let F = b((e) => {
2684
2697
  e.preventDefault(), e.deltaY < 0 ? M({
2685
2698
  direction: "up",
2686
- stepSize: Qt
2699
+ stepSize: en
2687
2700
  }) : M({
2688
2701
  direction: "down",
2689
- stepSize: Qt
2702
+ stepSize: en
2690
2703
  });
2691
2704
  }, [M]);
2692
2705
  S(() => {
@@ -2712,23 +2725,23 @@ ${jt}
2712
2725
  }
2713
2726
  let n = D.current, r = document.activeElement;
2714
2727
  n && r?.tagName === "IFRAME" && r.closest(".video")?.parentElement?.contains(n) && n.focus({ preventScroll: !0 });
2715
- }, en);
2728
+ }, nn);
2716
2729
  return O.current = t, () => {
2717
- e = Date.now() + tn;
2730
+ e = Date.now() + rn;
2718
2731
  };
2719
2732
  }, [z]), S(() => () => clearInterval(O.current), []), /* @__PURE__ */ L("div", {
2720
2733
  className: "control-bar",
2721
- css: nn,
2734
+ css: an,
2722
2735
  style: { ...p ? {
2723
2736
  opacity: "0",
2724
2737
  pointerEvents: "none"
2725
2738
  } : z ? { pointerEvents: "none" } : {} },
2726
- children: [/* @__PURE__ */ I(Et, {}), /* @__PURE__ */ L("div", {
2739
+ children: [/* @__PURE__ */ I(Ot, {}), /* @__PURE__ */ L("div", {
2727
2740
  className: "actions",
2728
2741
  children: [/* @__PURE__ */ L("div", {
2729
2742
  className: "left",
2730
2743
  children: [
2731
- /* @__PURE__ */ I(St, {
2744
+ /* @__PURE__ */ I(wt, {
2732
2745
  id: "play",
2733
2746
  tooltipPlace: "top-start",
2734
2747
  text: /* @__PURE__ */ I("button", {
@@ -2740,19 +2753,19 @@ ${jt}
2740
2753
  }),
2741
2754
  toolTipText: /* @__PURE__ */ I("span", { children: i(j ? a.replayKey : o ? a.playKey : a.pauseKey) })
2742
2755
  }),
2743
- /* @__PURE__ */ I(Zt, { ref: E }),
2756
+ /* @__PURE__ */ I($t, { ref: E }),
2744
2757
  /* @__PURE__ */ I("div", {
2745
2758
  className: "time",
2746
- children: gt(l ?? s, c)
2759
+ children: vt(l ?? s, c)
2747
2760
  })
2748
2761
  ]
2749
2762
  }), /* @__PURE__ */ L("div", {
2750
2763
  className: "right",
2751
2764
  children: [
2752
- /* @__PURE__ */ I(zt, {}),
2765
+ /* @__PURE__ */ I(Vt, {}),
2766
+ /* @__PURE__ */ I(Jt, {}),
2753
2767
  /* @__PURE__ */ I(Kt, {}),
2754
- /* @__PURE__ */ I(Wt, {}),
2755
- _ ? /* @__PURE__ */ I(St, {
2768
+ _ ? /* @__PURE__ */ I(wt, {
2756
2769
  id: "picture-in-picture",
2757
2770
  tooltipPlace: "top-end",
2758
2771
  text: /* @__PURE__ */ I("button", {
@@ -2765,12 +2778,12 @@ ${jt}
2765
2778
  "aria-label": i(a.pictureInPicture),
2766
2779
  "aria-pressed": _.active,
2767
2780
  children: /* @__PURE__ */ I("img", {
2768
- src: Dt,
2781
+ src: kt,
2769
2782
  alt: ""
2770
2783
  })
2771
2784
  }),
2772
2785
  toolTipText: /* @__PURE__ */ I("span", { children: i(_.active ? a.exitPictureInPicture : a.pictureInPicture) })
2773
- }) : m ? /* @__PURE__ */ I(St, {
2786
+ }) : m ? /* @__PURE__ */ I(wt, {
2774
2787
  id: "picture-in-picture",
2775
2788
  tooltipPlace: "top-end",
2776
2789
  text: /* @__PURE__ */ I("button", {
@@ -2780,14 +2793,14 @@ ${jt}
2780
2793
  disabled: k && !A,
2781
2794
  "aria-label": i(k ? a.burnIn : a.pictureInPicture),
2782
2795
  "aria-pressed": k ? g : void 0,
2783
- children: k ? I(g ? kt : At, {}) : /* @__PURE__ */ I("img", {
2784
- src: Dt,
2796
+ children: k ? I(g ? jt : Mt, {}) : /* @__PURE__ */ I("img", {
2797
+ src: kt,
2785
2798
  alt: ""
2786
2799
  })
2787
2800
  }),
2788
2801
  toolTipText: /* @__PURE__ */ I("span", { children: i(k ? A ? g ? a.burnedIn : a.burnInOffer : a.noSubtitles : a.pictureInPicture) })
2789
2802
  }) : null,
2790
- /* @__PURE__ */ I(St, {
2803
+ /* @__PURE__ */ I(wt, {
2791
2804
  id: "full-screen",
2792
2805
  tooltipPlace: "top-end",
2793
2806
  text: /* @__PURE__ */ I("button", {
@@ -2804,7 +2817,7 @@ ${jt}
2804
2817
  })]
2805
2818
  })]
2806
2819
  });
2807
- }, an = 9e3, on = D`
2820
+ }, sn = 9e3, cn = D`
2808
2821
  position: absolute;
2809
2822
  inset: 0;
2810
2823
  z-index: 2;
@@ -2847,7 +2860,7 @@ ${jt}
2847
2860
  line-height: 1;
2848
2861
  color: #fff;
2849
2862
  }
2850
- `, sn = () => {
2863
+ `, ln = () => {
2851
2864
  let { format: e } = Q(), t = X((e) => e.burnedInSubtitles), n = X((e) => e.pictureInPictureMode), [r, i] = T(!1);
2852
2865
  return S(() => {
2853
2866
  if (n !== "burn-in" || !t) {
@@ -2855,10 +2868,10 @@ ${jt}
2855
2868
  return;
2856
2869
  }
2857
2870
  i(!0);
2858
- let e = setTimeout(() => i(!1), an);
2871
+ let e = setTimeout(() => i(!1), sn);
2859
2872
  return () => clearTimeout(e);
2860
2873
  }, [n, t]), n !== "burn-in" || !t ? null : /* @__PURE__ */ I("div", {
2861
- css: on,
2874
+ css: cn,
2862
2875
  className: r ? "show" : "",
2863
2876
  role: "status",
2864
2877
  children: /* @__PURE__ */ L("div", {
@@ -2873,10 +2886,10 @@ ${jt}
2873
2886
  })]
2874
2887
  })
2875
2888
  });
2876
- }, cn = 1, ln = 6e3, un = 1, dn = {
2889
+ }, un = 1, dn = 6e3, fn = 1, pn = {
2877
2890
  opening: a.skipOpening,
2878
2891
  ending: a.skipEnding
2879
- }, fn = D`
2892
+ }, mn = D`
2880
2893
  position: absolute;
2881
2894
  inset: 0;
2882
2895
  z-index: 2;
@@ -2927,13 +2940,13 @@ ${jt}
2927
2940
  bottom: calc(9 * var(--mp-unit));
2928
2941
  }
2929
2942
  }
2930
- `, pn = ({ endingOffered: e }) => {
2943
+ `, hn = ({ endingOffered: e }) => {
2931
2944
  let t = X((e) => e.chapters), n = X((e) => e.currentTime), r = X((e) => e.requestSeek), i = X((e) => e.seekPreview), a = X(), { format: o } = Q(), s = C(() => {
2932
2945
  let n = h(t), r = e ? -1 : n.lastIndexOf("ending");
2933
2946
  return n.map((e, t) => t === r ? void 0 : e);
2934
2947
  }, [t, e]), c = C(() => {
2935
2948
  if (typeof n != "number") return;
2936
- let e = t.findIndex((e, t) => s[t] !== void 0 && e.start - cn <= n && n < e.end), r = e >= 0 ? s[e] : void 0;
2949
+ let e = t.findIndex((e, t) => s[t] !== void 0 && e.start - un <= n && n < e.end), r = e >= 0 ? s[e] : void 0;
2937
2950
  return r ? {
2938
2951
  kind: r,
2939
2952
  end: t[e].end
@@ -2945,7 +2958,7 @@ ${jt}
2945
2958
  ]), l = w(0), [u, d] = T(0);
2946
2959
  S(() => {
2947
2960
  let e = typeof n == "number" ? n : 0, t = l.current;
2948
- l.current = e, e < t - un && d((e) => e + 1);
2961
+ l.current = e, e < t - fn && d((e) => e + 1);
2949
2962
  }, [n]);
2950
2963
  let [f, p] = T(!1), m = c ? `${c.kind}@${c.end}` : "";
2951
2964
  return S(() => {
@@ -2954,12 +2967,12 @@ ${jt}
2954
2967
  return;
2955
2968
  }
2956
2969
  p(!0);
2957
- let e = setTimeout(() => p(!1), ln);
2970
+ let e = setTimeout(() => p(!1), dn);
2958
2971
  return () => clearTimeout(e);
2959
2972
  }, [m, u]), S(() => {
2960
2973
  c || p(!1);
2961
2974
  }, [c]), c ? /* @__PURE__ */ I("div", {
2962
- css: fn,
2975
+ css: mn,
2963
2976
  className: f && !i ? "show" : "",
2964
2977
  children: /* @__PURE__ */ I("button", {
2965
2978
  type: "button",
@@ -2967,10 +2980,10 @@ ${jt}
2967
2980
  onClick: () => {
2968
2981
  p(!1), r ? r(c.end) : a.seek(c.end);
2969
2982
  },
2970
- children: o(dn[c.kind])
2983
+ children: o(pn[c.kind])
2971
2984
  })
2972
2985
  }) : null;
2973
- }, mn = 3e3, hn = D`
2986
+ }, gn = 3e3, _n = D`
2974
2987
  position: absolute;
2975
2988
  inset: 0;
2976
2989
  z-index: 2;
@@ -2981,10 +2994,10 @@ ${jt}
2981
2994
  hoverable while faded out, popping a tooltip over nothing. It cascades where pointer-events does
2982
2995
  not, and transitioning it holds the item on screen for the length of the fade. */
2983
2996
  transition: opacity 0.1s cubic-bezier(.4,0,1,1), visibility 0.1s;
2984
- `, gn = (e, t) => {
2997
+ `, vn = (e, t) => {
2985
2998
  let n = e.left - t.left, r = e.top - t.top;
2986
2999
  return `path(evenodd, 'M0 0H${t.width}V${t.height}H0Z M${n} ${r}H${n + e.width}V${r + e.height}H${n}Z')`;
2987
- }, _n = D`
3000
+ }, yn = D`
2988
3001
  position: relative;
2989
3002
  background-color: black;
2990
3003
  display: flex;
@@ -3041,13 +3054,13 @@ ${jt}
3041
3054
  &.hide {
3042
3055
  cursor: none;
3043
3056
  }
3044
- `, vn = (e, t = "") => g.toArray(e).flatMap((e, n) => {
3057
+ `, bn = (e, t = "") => g.toArray(e).flatMap((e, n) => {
3045
3058
  let r = `${t}${y(e) && e.key != null ? e.key : n}`;
3046
- return y(e) && e.type === _ ? vn(e.props.children, `${r}/`) : [{
3059
+ return y(e) && e.type === _ ? bn(e.props.children, `${r}/`) : [{
3047
3060
  key: r,
3048
3061
  item: e
3049
3062
  }];
3050
- }), yn = ({ ref: e, onVideoRef: t, onSubtitleRef: n, overlay: r, controls: i, shortcuts: a, fullscreen: o, endingOffered: s, children: c }) => {
3063
+ }), xn = ({ ref: e, onVideoRef: t, onSubtitleRef: n, overlay: r, controls: i, shortcuts: a, fullscreen: o, endingOffered: s, children: c }) => {
3051
3064
  let l = X(), u = X((e) => e.hideUI), d = X((e) => e.setHideUI), f = X((e) => e.hasMedia), p = X((e) => e.passThroughPictureInPicture), m = w(void 0), h = w("mouse"), g = w({
3052
3065
  x: -1,
3053
3066
  y: -1
@@ -3073,12 +3086,12 @@ ${jt}
3073
3086
  return !n || !v.current.contains(n) || n.closest(".video") ? !1 : !n.closest(".control-bar") || _.current || !!v.current.querySelector(".control-bar [aria-expanded=\"true\"]");
3074
3087
  }, C = () => {
3075
3088
  if (x()) {
3076
- m.current = setTimeout(C, mn);
3089
+ m.current = setTimeout(C, gn);
3077
3090
  return;
3078
3091
  }
3079
3092
  y();
3080
3093
  }, T = () => {
3081
- d(!1), clearTimeout(m.current), m.current = setTimeout(C, mn);
3094
+ d(!1), clearTimeout(m.current), m.current = setTimeout(C, gn);
3082
3095
  }, E = (e) => {
3083
3096
  h.current = e.pointerType, e.pointerType === "mouse" && (g.current = {
3084
3097
  x: e.clientX,
@@ -3090,7 +3103,7 @@ ${jt}
3090
3103
  _.current = !1;
3091
3104
  }, k = w(!0);
3092
3105
  return /* @__PURE__ */ L("div", {
3093
- css: _n,
3106
+ css: yn,
3094
3107
  ref: b,
3095
3108
  onPointerMove: E,
3096
3109
  onPointerDown: D,
@@ -3105,9 +3118,9 @@ ${jt}
3105
3118
  className: u ? "hide" : "",
3106
3119
  tabIndex: a === "player" ? -1 : void 0,
3107
3120
  children: [
3108
- /* @__PURE__ */ I(ut, { onSubtitleRef: n }),
3109
- vn(r).map(({ key: e, item: t }) => /* @__PURE__ */ I("div", {
3110
- css: hn,
3121
+ /* @__PURE__ */ I(ft, { onSubtitleRef: n }),
3122
+ bn(r).map(({ key: e, item: t }) => /* @__PURE__ */ I("div", {
3123
+ css: _n,
3111
3124
  style: { ...u ? {
3112
3125
  opacity: "0",
3113
3126
  visibility: "hidden",
@@ -3115,19 +3128,19 @@ ${jt}
3115
3128
  } : {} },
3116
3129
  children: t
3117
3130
  }, e)),
3118
- i === !1 ? null : /* @__PURE__ */ I(xt, {
3131
+ i === !1 ? null : /* @__PURE__ */ I(Ct, {
3119
3132
  value: !!o,
3120
- children: /* @__PURE__ */ I(rn, {
3133
+ children: /* @__PURE__ */ I(on, {
3121
3134
  shortcuts: a,
3122
3135
  root: v,
3123
3136
  fullscreen: o
3124
3137
  })
3125
3138
  }),
3126
- /* @__PURE__ */ I(sn, {}),
3127
- /* @__PURE__ */ I(pn, { endingOffered: s }),
3139
+ /* @__PURE__ */ I(ln, {}),
3140
+ /* @__PURE__ */ I(hn, { endingOffered: s }),
3128
3141
  p?.armed && v.current ? /* @__PURE__ */ I("div", {
3129
3142
  className: "pass-through",
3130
- style: { clipPath: gn(p.armed, v.current.getBoundingClientRect()) },
3143
+ style: { clipPath: vn(p.armed, v.current.getBoundingClientRect()) },
3131
3144
  onPointerOver: p.disarm
3132
3145
  }) : null,
3133
3146
  /* @__PURE__ */ L("div", {
@@ -3150,7 +3163,7 @@ ${jt}
3150
3163
  })
3151
3164
  ]
3152
3165
  });
3153
- }, bn = (e, t) => ({ title: e.options.find((e) => e.id === t)?.label }), xn = (e, t) => e instanceof Promise ? e.then(t) : t(), Sn = ({ options: e, children: t }) => {
3166
+ }, Sn = (e, t) => ({ title: e.options.find((e) => e.id === t)?.label }), Cn = (e, t) => e instanceof Promise ? e.then(t) : t(), wn = ({ options: e, children: t }) => {
3154
3167
  let n = "media" in e ? e : null, r = n ? null : e, { title: i, chapters: a } = e, { size: o, downloadedRanges: s, publicPath: c, libavWorkerUrl: l, read: f, thumbnailRead: p, thumbnailsEnabled: m, readsDownload: h } = r ?? {}, g = j(), _ = A(), [v, y] = T(null), [b, x] = T(null), E = n?.media ?? v;
3155
3168
  S(() => (g?.(E), () => g?.(null)), [E, g]), Pe(E, n?.stepFrame);
3156
3169
  let { expose: D } = e, [O, k] = T(null), [M, N] = T(!0), [P, F] = T(null), [L, R] = T(e.autoplayNext), [z] = T(() => Object.assign(new EventTarget(), {
@@ -3198,7 +3211,7 @@ ${jt}
3198
3211
  let G = e.fullscreen ?? (O === null ? void 0 : {
3199
3212
  active: O,
3200
3213
  request: () => z.dispatchEvent(new Event("fullscreenrequest"))
3201
- }), K = C(() => tt(), [o]);
3214
+ }), K = C(() => rt(), [o]);
3202
3215
  Ae(v, b, r, h ? K.push : void 0);
3203
3216
  let ie = r?.normalizeVolume ?? !0, [q, J] = T(ie);
3204
3217
  S(() => {
@@ -3208,7 +3221,7 @@ ${jt}
3208
3221
  ae.current = r?.onNormalizeVolumeChange;
3209
3222
  let oe = r?.normalizerWorkletUrl, se = w(p ?? f);
3210
3223
  se.current = p ?? f;
3211
- let Y = X((e) => e.selectedAudioTrack), ce = !!f, { refused: le } = et(v, oe, q, C(() => ce && o && c && l && typeof Y == "number" && Y >= 0 ? h ? {
3224
+ let Y = X((e) => e.selectedAudioTrack), ce = !!f, { refused: le } = nt(v, oe, q, C(() => ce && o && c && l && typeof Y == "number" && Y >= 0 ? h ? {
3212
3225
  tap: K,
3213
3226
  audioStreamIndex: Y
3214
3227
  } : {
@@ -3235,13 +3248,13 @@ ${jt}
3235
3248
  oe,
3236
3249
  q,
3237
3250
  le
3238
- ]), { thumbnails: de, requestThumbnail: fe } = Le({
3251
+ ]), { thumbnails: de, requestThumbnail: fe } = ze({
3239
3252
  publicPath: c,
3240
3253
  workerUrl: l,
3241
3254
  length: m === !1 ? void 0 : o,
3242
3255
  read: p ?? f,
3243
3256
  downloadedRanges: s
3244
- }), pe = n?.thumbnails?.all ?? de, { toggle: me, mode: he, burnedIn: ge } = Re(v, b), _e = We(n?.media ?? null, n?.pictureInPicture), Z = X((e) => e.setSourceState), ve = n ? !!n.media : o !== void 0;
3257
+ }), pe = n?.thumbnails?.all ?? de, { toggle: me, mode: he, burnedIn: ge } = Be(v, b), _e = Ke(n?.media ?? null, n?.pictureInPicture), Z = X((e) => e.setSourceState), ve = n ? !!n.media : o !== void 0;
3245
3258
  S(() => {
3246
3259
  Z({
3247
3260
  title: i,
@@ -3302,11 +3315,11 @@ ${jt}
3302
3315
  })),
3303
3316
  selectedSubtitleTrack: ye.selectedId ?? void 0,
3304
3317
  selectSubtitleTrack: (e) => {
3305
- let t = e == null ? null : String(e), n = t === null ? void 0 : bn(ye, t), r = ye.selectedId === null;
3306
- return xn(ye.select(t), () => {
3318
+ let t = e == null ? null : String(e), n = t === null ? void 0 : Sn(ye, t), r = ye.selectedId === null;
3319
+ return Cn(ye.select(t), () => {
3307
3320
  let e = t === null ? null : u(n) ?? (r ? n?.title : void 0), i = xe.current;
3308
3321
  e !== void 0 && i.options.onPreferredSubtitleLanguageChange?.(e);
3309
- let a = i.audio && bn(i.audio, i.audio.selectedId ?? "");
3322
+ let a = i.audio && Sn(i.audio, i.audio.selectedId ?? "");
3310
3323
  e && d(a, e) && i.options.onAlwaysShowSubtitlesChange?.(!0);
3311
3324
  });
3312
3325
  },
@@ -3320,8 +3333,8 @@ ${jt}
3320
3333
  disabled: n
3321
3334
  })),
3322
3335
  selectedAudioTrack: be.selectedId ?? void 0,
3323
- selectAudioTrack: (e) => xn(be.select(String(e)), () => {
3324
- let t = u(bn(be, String(e)));
3336
+ selectAudioTrack: (e) => Cn(be.select(String(e)), () => {
3337
+ let t = u(Sn(be, String(e)));
3325
3338
  t !== void 0 && xe.current.options.onPreferredAudioLanguageChange?.(t);
3326
3339
  })
3327
3340
  });
@@ -3331,7 +3344,7 @@ ${jt}
3331
3344
  Z({ quality: Se });
3332
3345
  }, [Z, Se]), S(() => {
3333
3346
  a && Z({ chapters: a });
3334
- }, [Z, a]), /* @__PURE__ */ I(yn, {
3347
+ }, [Z, a]), /* @__PURE__ */ I(xn, {
3335
3348
  ref: _,
3336
3349
  onVideoRef: n ? void 0 : y,
3337
3350
  onSubtitleRef: x,
@@ -3342,7 +3355,7 @@ ${jt}
3342
3355
  endingOffered: M,
3343
3356
  children: t
3344
3357
  });
3345
- }, Cn = D`
3358
+ }, Tn = D`
3346
3359
  /**
3347
3360
  * The chrome's whole scale, in one place.
3348
3361
  *
@@ -3412,20 +3425,20 @@ ${jt}
3412
3425
  height: 100%;
3413
3426
  width: 100%;
3414
3427
  overflow: hidden;
3415
- `, wn = (e) => /* @__PURE__ */ I("div", {
3416
- css: Cn,
3428
+ `, En = (e) => /* @__PURE__ */ I("div", {
3429
+ css: Tn,
3417
3430
  children: /* @__PURE__ */ I(ce.Provider, { children: /* @__PURE__ */ I(ye, {
3418
3431
  language: e.language,
3419
- children: /* @__PURE__ */ I(Sn, {
3432
+ children: /* @__PURE__ */ I(wn, {
3420
3433
  options: e,
3421
3434
  children: e.children
3422
3435
  })
3423
3436
  }) })
3424
- }), Tn = (e) => !!e && typeof e == "object" && "at" in e, En = (e) => !!e && typeof e == "object" && "selection" in e, Dn = ({ blob: e, name: t }) => ({
3437
+ }), Dn = (e) => !!e && typeof e == "object" && "at" in e, On = (e) => !!e && typeof e == "object" && "selection" in e, kn = ({ blob: e, name: t }) => ({
3425
3438
  length: e.size,
3426
3439
  name: t ?? (e instanceof File ? e.name : void 0),
3427
3440
  read: (t, n) => e.slice(t, t + n).arrayBuffer()
3428
- }), On = async (e, t) => {
3441
+ }), An = async (e, t) => {
3429
3442
  let n = await fetch(e, {
3430
3443
  headers: { Range: "bytes=0-1" },
3431
3444
  credentials: t
@@ -3435,8 +3448,8 @@ ${jt}
3435
3448
  if (!Number.isFinite(i) || i <= 0) throw Error("The source did not report its length");
3436
3449
  if (!r && n.status !== 206) throw Error("The source does not support range requests");
3437
3450
  return i;
3438
- }, kn = async ({ url: e, length: t, name: n, credentials: r }) => {
3439
- let i = t ?? await On(e, r);
3451
+ }, jn = async ({ url: e, length: t, name: n, credentials: r }) => {
3452
+ let i = t ?? await An(e, r);
3440
3453
  return {
3441
3454
  length: i,
3442
3455
  name: n,
@@ -3452,9 +3465,9 @@ ${jt}
3452
3465
  },
3453
3466
  readsDownload: !0
3454
3467
  };
3455
- }, An = async (e) => {
3456
- if ("blob" in e) return Dn(e);
3457
- if ("url" in e) return kn(e);
3468
+ }, Mn = async (e) => {
3469
+ if ("blob" in e) return kn(e);
3470
+ if ("url" in e) return jn(e);
3458
3471
  if ("read" in e) return {
3459
3472
  length: e.length,
3460
3473
  name: e.name,
@@ -3463,4 +3476,4 @@ ${jt}
3463
3476
  throw Error(`Unknown source type: ${e}`);
3464
3477
  };
3465
3478
  //#endregion
3466
- export { wn as MediaPlayer, wn as default, ce as Player, t as SUBTITLES_OFF, c as createPictureInPicture, l as createSubtitleRenderer, o as createThumbnailGenerator, An as inputToRemuxerInput, En as isDelegatedTracks, Tn as isExternalThumbnails, Y as sourceFeature, s as startPlayback, Re as usePictureInPicture, X as usePlayer, Le as useSeekThumbnails };
3479
+ export { En as MediaPlayer, En as default, ce as Player, t as SUBTITLES_OFF, c as createPictureInPicture, l as createSubtitleRenderer, o as createThumbnailGenerator, Mn as inputToRemuxerInput, On as isDelegatedTracks, Dn as isExternalThumbnails, Y as sourceFeature, s as startPlayback, Be as usePictureInPicture, X as usePlayer, ze as useSeekThumbnails };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@banou/media-player",
3
- "version": "0.10.41",
3
+ "version": "0.10.42",
4
4
  "description": "A video player for containers and codecs the browser cannot play natively, remuxed on the fly",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -80,6 +80,8 @@ export const attachVolumeNormalizer = (
80
80
  let enabled = options.enabled !== false
81
81
  let node: AudioWorkletNode | undefined
82
82
  let released = false
83
+ // paused, so `follow` keeps the context suspended rather than resuming it
84
+ let held = false
83
85
  const inputGainDb = () => 20 * Math.log10(Math.max(element.volume, 1e-6))
84
86
 
85
87
  const document = element.ownerDocument
@@ -92,7 +94,8 @@ export const attachVolumeNormalizer = (
92
94
  }
93
95
  }
94
96
  const follow = () => {
95
- const suspended = !released && context.state === 'suspended'
97
+ if (held && context.state === 'running') context.suspend().catch(() => {})
98
+ const suspended = !released && !held && context.state === 'suspended'
96
99
  listen(suspended)
97
100
  // Suspended by something else once routed: Chrome freezes the element and Firefox plays it silent until the
98
101
  // context runs, and the page's activation already allows a resume.
@@ -111,6 +114,17 @@ export const attachVolumeNormalizer = (
111
114
  // the live detector describes where the playhead was, and a new file owes nothing to the last one's level
112
115
  element.addEventListener('seeking', () => created.port.postMessage({ reset: 'seek' }))
113
116
  element.addEventListener('emptied', () => created.port.postMessage({ reset: 'source' }))
117
+ // Paused, a running context wakes the audio threads 390 to 620 times a second and a suspended one 20 to 30 (Chrome
118
+ // 156, 2026-11-17), while Firefox 157 wakes about 700 times a second either way. Resumed by play, the sound flows
119
+ // on within 45 ms in Chrome 156 and 80 ms in Firefox 157.
120
+ element.addEventListener('pause', () => {
121
+ held = true
122
+ if (context.state === 'running') context.suspend().catch(() => {})
123
+ })
124
+ element.addEventListener('play', () => {
125
+ held = false
126
+ resume()
127
+ })
114
128
  node = created
115
129
  return created
116
130
  })()
@@ -8,6 +8,11 @@ import { createThumbnailGenerator } from '../../engine'
8
8
  // backs off because each failed init costs a wasm worker
9
9
  const RETRY_DELAY = 5_000
10
10
  const MAX_RETRY_DELAY = 60_000
11
+ // libav-wasm's thumbnailer starts with a read of this much from offset 0
12
+ const HEAD_BYTES = 1_000_000
13
+
14
+ const holdsHead = (ranges: [number, number][] | undefined, length: number) =>
15
+ !ranges || ranges.some(([start, end]) => start <= 0 && end >= Math.min(HEAD_BYTES, length))
11
16
 
12
17
  export type UseSeekThumbnailsOptions = {
13
18
  /** Optional alongside `length`/`read`: with no bytes there is nothing to generate from. */
@@ -46,6 +51,7 @@ export const useSeekThumbnails = ({
46
51
  )
47
52
  const rangesRef = useRef(ranges)
48
53
  rangesRef.current = ranges
54
+ const retryOnHead = useRef<(() => void) | null>(null)
49
55
 
50
56
  useEffect(() => {
51
57
  if (!length || !read || !publicPath || !workerUrl) return
@@ -54,6 +60,8 @@ export const useSeekThumbnails = ({
54
60
  let retry: ReturnType<typeof setTimeout> | undefined
55
61
  let delay = RETRY_DELAY
56
62
  const boot = () => {
63
+ retryOnHead.current = null
64
+ const early = !holdsHead(rangesRef.current, length)
57
65
  createThumbnailGenerator({
58
66
  publicPath,
59
67
  workerUrl,
@@ -72,11 +80,21 @@ export const useSeekThumbnails = ({
72
80
  if (cancelled) return
73
81
  retry = setTimeout(boot, delay)
74
82
  delay = Math.min(delay * 2, MAX_RETRY_DELAY)
83
+ // A reopened torrent refuses the head until the engine reports its pieces, so a boot that began before
84
+ // the head was readable goes again as soon as it is. Only that boot: any other failure keeps the backoff.
85
+ if (!early) return
86
+ const again = () => {
87
+ clearTimeout(retry)
88
+ boot()
89
+ }
90
+ if (holdsHead(rangesRef.current, length)) again()
91
+ else retryOnHead.current = again
75
92
  })
76
93
  }
77
94
  boot()
78
95
  return () => {
79
96
  cancelled = true
97
+ retryOnHead.current = null
80
98
  clearTimeout(retry)
81
99
  generatorRef.current = null
82
100
  generator?.destroy()
@@ -84,7 +102,10 @@ export const useSeekThumbnails = ({
84
102
  }
85
103
  }, [length, publicPath, workerUrl])
86
104
 
87
- useEffect(() => { generatorRef.current?.update(ranges) }, [ranges])
105
+ useEffect(() => {
106
+ generatorRef.current?.update(ranges)
107
+ if (length && holdsHead(ranges, length)) retryOnHead.current?.()
108
+ }, [ranges])
88
109
 
89
110
  const requestThumbnail = useCallback((time: number | undefined) => {
90
111
  generatorRef.current?.prioritize(time)