@banou/media-player 0.6.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +149 -3
  2. package/dist/engine/index.d.ts +10 -0
  3. package/dist/engine/index.js +2 -0
  4. package/dist/engine/picture-in-picture.d.ts +27 -0
  5. package/dist/engine/playback.d.ts +45 -0
  6. package/dist/engine/source-buffer.d.ts +12 -0
  7. package/dist/engine/subtitles.d.ts +36 -0
  8. package/dist/engine/thumbnails.d.ts +22 -0
  9. package/dist/engine-Dmc7JSd9.js +470 -0
  10. package/dist/index.d.ts +14 -0
  11. package/dist/index.js +1610 -0
  12. package/dist/react/components/chrome.d.ts +12 -0
  13. package/dist/react/components/control-bar.d.ts +2 -0
  14. package/dist/react/components/overlay.d.ts +4 -0
  15. package/dist/react/components/playback-slider.d.ts +2 -0
  16. package/dist/react/components/progress-bar.d.ts +2 -0
  17. package/dist/react/components/settings.d.ts +2 -0
  18. package/dist/react/components/sound.d.ts +7 -0
  19. package/{build → dist/react}/components/tooltip-display.d.ts +8 -8
  20. package/dist/react/components/volume-slider.d.ts +6 -0
  21. package/dist/react/hooks/use-drag-value.d.ts +23 -0
  22. package/dist/react/hooks/use-picture-in-picture.d.ts +2 -0
  23. package/dist/react/hooks/use-playback.d.ts +8 -0
  24. package/dist/react/hooks/use-thumbnails.d.ts +12 -0
  25. package/dist/react/media.d.ts +98 -0
  26. package/dist/react/player.d.ts +26 -0
  27. package/dist/react/source-feature.d.ts +106 -0
  28. package/dist/react/video-player.d.ts +83 -0
  29. package/dist/utils/source.d.ts +30 -0
  30. package/dist/utils/track-label.d.ts +31 -0
  31. package/dist/utils/volume-utils.d.ts +6 -0
  32. package/package.json +58 -37
  33. package/src/lib/engine/index.ts +14 -0
  34. package/src/lib/engine/picture-in-picture.ts +250 -0
  35. package/src/lib/engine/playback.ts +352 -0
  36. package/src/lib/engine/source-buffer.ts +61 -0
  37. package/src/lib/engine/subtitles.ts +210 -0
  38. package/src/lib/engine/thumbnails.ts +137 -0
  39. package/src/lib/globals.d.ts +8 -0
  40. package/src/lib/index.tsx +51 -0
  41. package/src/lib/react/components/chrome.tsx +130 -0
  42. package/src/{components → lib/react/components}/control-bar.tsx +74 -96
  43. package/src/lib/react/components/overlay.tsx +125 -0
  44. package/src/{components → lib/react/components}/playback-slider.tsx +30 -52
  45. package/src/lib/react/components/progress-bar.tsx +341 -0
  46. package/src/lib/react/components/settings.tsx +384 -0
  47. package/src/lib/react/components/sound.tsx +133 -0
  48. package/src/{components → lib/react/components}/tooltip-display.tsx +15 -12
  49. package/src/{components → lib/react/components}/volume-slider.tsx +32 -46
  50. package/src/lib/react/hooks/use-drag-value.ts +73 -0
  51. package/src/lib/react/hooks/use-picture-in-picture.ts +36 -0
  52. package/src/lib/react/hooks/use-playback.ts +146 -0
  53. package/src/lib/react/hooks/use-thumbnails.ts +78 -0
  54. package/src/lib/react/media.ts +124 -0
  55. package/src/lib/react/player.ts +20 -0
  56. package/src/lib/react/source-feature.ts +108 -0
  57. package/src/lib/react/video-player.tsx +223 -0
  58. package/src/lib/utils/fonts.ts +160 -0
  59. package/src/lib/utils/source.ts +60 -0
  60. package/src/lib/utils/track-label.ts +51 -0
  61. package/src/lib/utils/volume-utils.ts +13 -0
  62. package/build/components/chrome.d.ts +0 -7
  63. package/build/components/control-bar.d.ts +0 -6
  64. package/build/components/overlay.d.ts +0 -4
  65. package/build/components/playback-slider.d.ts +0 -2
  66. package/build/components/progress-bar.d.ts +0 -1
  67. package/build/components/settings.d.ts +0 -2
  68. package/build/components/sound.d.ts +0 -4
  69. package/build/components/volume-slider.d.ts +0 -6
  70. package/build/index.d.ts +0 -26
  71. package/build/index.js +0 -3416
  72. package/build/main.d.ts +0 -1
  73. package/build/state-machines/data-source.d.ts +0 -27
  74. package/build/state-machines/index.d.ts +0 -34038
  75. package/build/state-machines/media-properties.d.ts +0 -45
  76. package/build/state-machines/media-source.d.ts +0 -34
  77. package/build/state-machines/media.d.ts +0 -8558
  78. package/build/state-machines/subtitles.d.ts +0 -56
  79. package/build/state-machines/thumbnails.d.ts +0 -24
  80. package/build/state-machines/utils.d.ts +0 -26
  81. package/build/utils/actor-utils.d.ts +0 -2
  82. package/build/utils/context.d.ts +0 -14
  83. package/build/utils/index.d.ts +0 -4
  84. package/build/utils/languages.d.ts +0 -260
  85. package/build/utils/mp4box.d.ts +0 -61
  86. package/build/utils/use-local-storage.d.ts +0 -3
  87. package/build/utils/use-scrub.d.ts +0 -11
  88. package/build/utils/volume-utils.d.ts +0 -17
  89. package/build/utils/window-height.d.ts +0 -2
  90. package/src/components/chrome.tsx +0 -95
  91. package/src/components/overlay.tsx +0 -91
  92. package/src/components/progress-bar.tsx +0 -251
  93. package/src/components/settings.tsx +0 -322
  94. package/src/components/sound.tsx +0 -101
  95. package/src/index.tsx +0 -195
  96. package/src/main.tsx +0 -169
  97. package/src/state-machines/data-source.ts +0 -84
  98. package/src/state-machines/index.ts +0 -5
  99. package/src/state-machines/media-properties.ts +0 -82
  100. package/src/state-machines/media-source.ts +0 -129
  101. package/src/state-machines/media.ts +0 -255
  102. package/src/state-machines/subtitles.ts +0 -285
  103. package/src/state-machines/thumbnails.ts +0 -123
  104. package/src/state-machines/utils.ts +0 -94
  105. package/src/utils/actor-utils.ts +0 -19
  106. package/src/utils/context.ts +0 -23
  107. package/src/utils/fonts.ts +0 -160
  108. package/src/utils/index.ts +0 -229
  109. package/src/utils/languages.ts +0 -262
  110. package/src/utils/mp4box.ts +0 -74
  111. package/src/utils/use-local-storage.ts +0 -30
  112. package/src/utils/use-scrub.ts +0 -40
  113. package/src/utils/volume-utils.ts +0 -39
  114. package/src/utils/window-height.ts +0 -19
  115. package/src/vite-env.d.ts +0 -1
  116. package/tsconfig.json +0 -28
  117. package/tsconfig.node.json +0 -9
  118. /package/{build → dist}/utils/colors.d.ts +0 -0
  119. /package/{build → dist}/utils/fonts.d.ts +0 -0
  120. /package/{build → dist}/utils/time.d.ts +0 -0
  121. /package/src/{assets → lib/assets}/picture-in-picture.svg +0 -0
  122. /package/src/{utils → lib/utils}/colors.ts +0 -0
  123. /package/src/{utils → lib/utils}/time.ts +0 -0
package/dist/index.js ADDED
@@ -0,0 +1,1610 @@
1
+ import { i as e, n as t, o as n, s as r, t as i } from "./engine-Dmc7JSd9.js";
2
+ import { useCallback as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
3
+ import { css as u, keyframes as d } from "@emotion/react";
4
+ import { createPlayer as f, useContainerAttach as p, useMediaAttach as m } from "@videojs/react";
5
+ import { definePlayerFeature as h, videoFeatures as g } from "@videojs/core/dom";
6
+ import { Fragment as _, jsx as v, jsxs as y } from "@emotion/react/jsx-runtime";
7
+ import { ChevronLeft as b, ChevronRight as x, Maximize as S, Minimize as C, Pause as w, Play as T, RotateCcw as E, Settings as D, Volume1 as O, Volume2 as k, VolumeX as A } from "react-feather";
8
+ import { Tooltip as j } from "react-tooltip";
9
+ //#region src/lib/react/source-feature.ts
10
+ var ee = {
11
+ indexes: [],
12
+ thumbnails: [],
13
+ subtitleTracks: [],
14
+ selectedSubtitleTrack: void 0,
15
+ selectSubtitleTrack: () => {},
16
+ audioTracks: [],
17
+ selectedAudioTrack: void 0,
18
+ selectAudioTrack: () => {},
19
+ hideUI: !1,
20
+ setHideUI: () => {},
21
+ togglePictureInPicture: () => {},
22
+ playbackError: null,
23
+ ready: !1,
24
+ setSourceState: () => {}
25
+ }, M = h({
26
+ name: "source",
27
+ state: () => ({ ...ee }),
28
+ attach({ set: e }) {
29
+ e({
30
+ setSourceState: (t) => e(t),
31
+ setHideUI: (t) => e({ hideUI: t })
32
+ });
33
+ }
34
+ }), N = f({
35
+ features: [...g, M],
36
+ displayName: "MediaPlayer"
37
+ }), P = N.usePlayer, te = (e) => {
38
+ if (!(!e || e === "und")) try {
39
+ return new Intl.DisplayNames([navigator.language || "en"], {
40
+ type: "language",
41
+ fallback: "none"
42
+ }).of(e) || void 0;
43
+ } catch {
44
+ return;
45
+ }
46
+ }, F = (e) => e?.replace(/_/g, " ").trim() || void 0, ne = (e) => {
47
+ let t = e.map((e) => te(e.language) ?? F(e.title) ?? `Track ${e.streamIndex}`), n = t.reduce((e, t) => ({
48
+ ...e,
49
+ [t]: (e[t] ?? 0) + 1
50
+ }), {});
51
+ return e.map((e, r) => {
52
+ let i = t[r], a = F(e.title);
53
+ return {
54
+ track: e,
55
+ label: (n[i] ?? 0) > 1 && a && a !== i ? `${i} (${a})` : i
56
+ };
57
+ });
58
+ }, I = (e) => ne(e).map(({ track: e, label: t }) => ({
59
+ id: e.streamIndex,
60
+ label: t
61
+ })), re = (t, n, r) => {
62
+ let i = P(), { read: s, size: u, publicPath: d = "", libavWorkerUrl: f = "", jassubWorkerUrl: p = "", jassubWasmUrl: m = "", jassubLegacyWasmUrl: h, defaultFontUrl: g, bufferSize: _, autoplay: v = !1 } = r ?? {}, [y, b] = l(void 0), x = c(null), S = c(0), C = c(!1), w = c(s);
63
+ w.current = s;
64
+ let T = c(r?.onSeek);
65
+ T.current = r?.onSeek;
66
+ let E = c(r?.onPlaybackError);
67
+ E.current = r?.onPlaybackError;
68
+ let D = a((e) => {
69
+ let t = typeof e == "number" ? e : void 0;
70
+ C.current = !0, i.setSourceState({ selectedSubtitleTrack: t }), x.current?.selectSubtitleStream(t);
71
+ }, [i]), O = a((e) => {
72
+ typeof e == "number" && (i.setSourceState({ selectedAudioTrack: e }), b(e));
73
+ }, [i]), k = P((e) => e.setSourceState);
74
+ o(() => {
75
+ k({
76
+ selectSubtitleTrack: D,
77
+ selectAudioTrack: O
78
+ });
79
+ }, [
80
+ k,
81
+ D,
82
+ O
83
+ ]), o(() => {
84
+ if (!t || !n || !u || !s) return;
85
+ let r = !1;
86
+ i.setSourceState({
87
+ playbackError: null,
88
+ ready: !1
89
+ });
90
+ let a = (e) => {
91
+ r || (console.error("playback failed", e), i.setSourceState({ playbackError: e }), E.current?.(e));
92
+ };
93
+ return (async () => {
94
+ try {
95
+ let o = await e({
96
+ videoElement: t,
97
+ canvasElement: n,
98
+ read: (e, t) => w.current(e, t),
99
+ length: u,
100
+ publicPath: d,
101
+ libavWorkerUrl: f,
102
+ jassubWorkerUrl: p,
103
+ jassubWasmUrl: m,
104
+ jassubLegacyWasmUrl: h,
105
+ defaultFontUrl: g,
106
+ bufferSize: _,
107
+ audioStreamIndex: y,
108
+ onReady: () => {
109
+ r || (i.setSourceState({ ready: !0 }), S.current > 0 && (t.currentTime = S.current, S.current = 0), v && t.play().catch(() => {}));
110
+ },
111
+ onError: a,
112
+ onRecovered: () => {
113
+ r || i.setSourceState({ playbackError: null });
114
+ },
115
+ onSeek: (e) => T.current?.(e),
116
+ onSubtitleStreams: (e) => {
117
+ r || i.setSourceState({
118
+ subtitleTracks: I(e),
119
+ ...C.current ? {} : { selectedSubtitleTrack: e[0]?.streamIndex }
120
+ });
121
+ },
122
+ onAudioStreams: (e, t) => {
123
+ r || i.setSourceState({
124
+ audioTracks: I(e),
125
+ selectedAudioTrack: t
126
+ });
127
+ }
128
+ });
129
+ if (r) {
130
+ o.destroy();
131
+ return;
132
+ }
133
+ x.current = o, i.setSourceState({ indexes: o.indexes });
134
+ let s = i.selectedSubtitleTrack;
135
+ typeof s == "number" && o.selectSubtitleStream(s);
136
+ } catch (e) {
137
+ a(e);
138
+ }
139
+ })(), () => {
140
+ r = !0, S.current = t.currentTime, x.current?.destroy(), x.current = null, i.setSourceState({ ready: !1 });
141
+ };
142
+ }, [
143
+ i,
144
+ t,
145
+ n,
146
+ u,
147
+ d,
148
+ f,
149
+ p,
150
+ m,
151
+ h,
152
+ g,
153
+ _,
154
+ y,
155
+ v
156
+ ]);
157
+ }, L = 5e3, R = 6e4, z = ({ publicPath: e, workerUrl: n, length: r, read: i, downloadedRanges: a }) => {
158
+ let [u, d] = l([]), f = c(null), p = c(i);
159
+ p.current = i;
160
+ let m = s(() => a?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [a?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")]), h = c(m);
161
+ return h.current = m, o(() => {
162
+ if (!r || !i || !e || !n) return;
163
+ let a = !1, o = null, s, c = L, l = () => {
164
+ t({
165
+ publicPath: e,
166
+ workerUrl: n,
167
+ length: r,
168
+ read: (e, t) => p.current(e, t),
169
+ onThumbnails: (e) => {
170
+ a || d(e);
171
+ }
172
+ }).then((e) => {
173
+ if (a) {
174
+ e.destroy();
175
+ return;
176
+ }
177
+ o = e, f.current = e, e.update(h.current);
178
+ }, () => {
179
+ a || (s = setTimeout(l, c), c = Math.min(c * 2, R));
180
+ });
181
+ };
182
+ return l(), () => {
183
+ a = !0, clearTimeout(s), f.current = null, o?.destroy(), d([]);
184
+ };
185
+ }, [
186
+ r,
187
+ e,
188
+ n
189
+ ]), o(() => {
190
+ f.current?.update(m);
191
+ }, [m]), u;
192
+ }, B = (e, t) => {
193
+ let n = P(), r = c(null);
194
+ return o(() => {
195
+ if (!e || !t) return;
196
+ let a = i({
197
+ video: e,
198
+ canvas: t,
199
+ fallback: () => n.togglePictureInPicture()
200
+ });
201
+ return r.current = a, () => {
202
+ a.destroy(), r.current = null;
203
+ };
204
+ }, [
205
+ e,
206
+ t,
207
+ n
208
+ ]), a(() => {
209
+ r.current?.toggle().catch((e) => {
210
+ console.warn("picture in picture was refused", e);
211
+ });
212
+ }, []);
213
+ }, V = {
214
+ headings: {
215
+ large: "\n font-weight: 600;\n font-size: calc(2.8 * var(--mp-unit));\n line-height: calc(3.4 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(3.4 * var(--mp-unit));\n line-height: calc(4.1 * var(--mp-unit));\n }\n ",
216
+ medium: "\n font-weight: 600;\n font-size: calc(2.4 * var(--mp-unit));\n line-height: calc(2.9 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(2.8 * var(--mp-unit));\n line-height: calc(3.4 * var(--mp-unit));\n }\n ",
217
+ small: "\n font-weight: 500;\n font-size: calc(1.8 * var(--mp-unit));\n line-height: calc(1.9 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.8 * var(--mp-unit));\n line-height: calc(2.2 * var(--mp-unit));\n }\n @media (min-width: 2560px) {\n font-size: calc(2.2 * var(--mp-unit));\n line-height: calc(2.6 * var(--mp-unit));\n }\n ",
218
+ extraSmall: "\n font-weight: 500;\n font-size: calc(1.4 * var(--mp-unit));\n line-height: calc(1.7 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.6 * var(--mp-unit));\n line-height: calc(1.9 * var(--mp-unit));\n }\n "
219
+ },
220
+ bLarge: {
221
+ bold: "\n font-weight: 600;\n font-size: calc(1.4 * var(--mp-unit));\n line-height: calc(2 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.6 * var(--mp-unit));\n line-height: calc(2.2 * var(--mp-unit));\n }\n ",
222
+ medium: "\n font-weight: 500;\n font-size: calc(1.4 * var(--mp-unit));\n line-height: calc(2 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.6 * var(--mp-unit));\n line-height: calc(2.2 * var(--mp-unit));\n }\n ",
223
+ regular: "\n font-weight: 400;\n font-size: calc(1.4 * var(--mp-unit));\n line-height: calc(2 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.6 * var(--mp-unit));\n line-height: calc(2.2 * var(--mp-unit));\n }\n "
224
+ },
225
+ bMedium: {
226
+ bold: "\n font-weight: 600;\n font-size: calc(1.2 * var(--mp-unit));\n line-height: calc(1.7 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.4 * var(--mp-unit));\n line-height: calc(2 * var(--mp-unit));\n }\n ",
227
+ medium: "\n font-weight: 500;\n font-size: calc(1.2 * var(--mp-unit));\n line-height: calc(1.7 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.4 * var(--mp-unit));\n line-height: calc(2 * var(--mp-unit));\n }\n ",
228
+ regular: "\n font-weight: 400;\n font-size: calc(1.2 * var(--mp-unit));\n line-height: calc(1.7 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.4 * var(--mp-unit));\n line-height: calc(2 * var(--mp-unit));\n }\n "
229
+ },
230
+ bSmall: {
231
+ bold: "\n font-weight: 600;\n font-size: calc(1 * var(--mp-unit));\n line-height: calc(1.4 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.2 * var(--mp-unit));\n line-height: calc(1.7 * var(--mp-unit));\n }\n ",
232
+ medium: "\n font-weight: 500;\n font-size: calc(1 * var(--mp-unit));\n line-height: calc(1.4 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.2 * var(--mp-unit));\n line-height: calc(1.7 * var(--mp-unit));\n }\n ",
233
+ regular: "\n font-weight: 400;\n font-size: calc(1 * var(--mp-unit));\n line-height: calc(1.4 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1.2 * var(--mp-unit));\n line-height: calc(1.7 * var(--mp-unit));\n }\n "
234
+ },
235
+ bExtraSmall: {
236
+ bold: "\n font-weight: 600;\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 ",
237
+ 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 ",
238
+ 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 "
239
+ }
240
+ }, ie = u`
241
+ top: unset !important;
242
+ left: unset !important;
243
+ width: 100%;
244
+ height: 100%;
245
+ margin: auto;
246
+ pointer-events: none;
247
+ `, ae = u`
248
+ position: absolute;
249
+ top: 0;
250
+ left: 0;
251
+ width: 100%;
252
+ padding: calc(1.2 * var(--mp-unit)) calc(1.6 * var(--mp-unit));
253
+ /* clears a notch once the player is fullscreen; resolves to zero everywhere else */
254
+ padding-top: calc(calc(1.2 * var(--mp-unit)) + env(safe-area-inset-top, 0px));
255
+ ${V.headings.small}
256
+ color: white;
257
+ text-shadow: 0 0 4px rgba(0, 0, 0, 1);
258
+ z-index: 2;
259
+ pointer-events: none;
260
+
261
+ /* one line with an ellipsis until there is width to wrap, since a release filename would
262
+ otherwise run to four lines on a phone */
263
+ white-space: nowrap;
264
+ overflow: hidden;
265
+ text-overflow: ellipsis;
266
+
267
+ @media (min-width: 768px) {
268
+ padding: calc(2.4 * var(--mp-unit));
269
+ padding-top: calc(calc(2.4 * var(--mp-unit)) + env(safe-area-inset-top, 0px));
270
+ white-space: normal;
271
+ overflow: visible;
272
+ }
273
+
274
+ 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%);
275
+ transition: opacity 0.1s cubic-bezier(.4,0,1,1);
276
+ `, oe = u`
277
+ position: absolute;
278
+ inset: 0;
279
+ z-index: 2;
280
+ display: flex;
281
+ justify-content: center;
282
+ align-items: center;
283
+ pointer-events: none;
284
+
285
+ ::after {
286
+ content: '';
287
+ width: calc(4 * var(--mp-unit));
288
+ height: calc(4 * var(--mp-unit));
289
+ border-radius: 50%;
290
+ border: 3px solid rgba(255, 255, 255, 0.25);
291
+ border-top-color: #fff;
292
+ animation: ${d`
293
+ to { transform: rotate(360deg); }
294
+ `} 0.8s linear infinite;
295
+ }
296
+ `, se = u`
297
+ position: absolute;
298
+ inset: auto 0 20%;
299
+ z-index: 3;
300
+ padding: 0 calc(2 * var(--mp-unit));
301
+ text-align: center;
302
+ color: #fff;
303
+ ${V.bLarge.regular}
304
+ text-shadow: 0 0 4px rgba(0, 0, 0, 1);
305
+ pointer-events: none;
306
+ `, ce = (e) => e instanceof Error ? e.message : typeof e == "string" ? e : "Playback failed", le = ({ onCanvasRef: e }) => {
307
+ let t = P((e) => e.title), n = P((e) => e.hideUI), r = P((e) => e.playbackError), i = P((e) => e.ready), a = P((e) => e.size), o = P((e) => e.waiting);
308
+ return /* @__PURE__ */ y(_, { children: [
309
+ t ? /* @__PURE__ */ v("div", {
310
+ css: ae,
311
+ style: { ...n ? {
312
+ opacity: "0",
313
+ pointerEvents: "none"
314
+ } : {} },
315
+ children: t
316
+ }) : void 0,
317
+ (a ? !i : o) && !r ? /* @__PURE__ */ v("div", { css: oe }) : void 0,
318
+ r ? /* @__PURE__ */ v("div", {
319
+ css: se,
320
+ children: ce(r)
321
+ }) : void 0,
322
+ /* @__PURE__ */ v("canvas", {
323
+ ref: e,
324
+ css: ie
325
+ })
326
+ ] });
327
+ }, H = 1e-4, U = 1, W = (e) => Math.max(H, Math.min(U, e)) ** 2, G = (e) => Math.max(H, Math.min(U, e)) ** (U / 2), K = (e) => {
328
+ if (e === void 0) return "0:00";
329
+ let t = Math.floor(e / 3600), n = Math.floor(e % 3600 / 60), r = Math.floor(e % 60);
330
+ return t > 0 ? `${t}:${n < 10 ? "0" : ""}${n}:${r < 10 ? "0" : ""}${r}` : `${n}:${r < 10 ? "0" : ""}${r}`;
331
+ }, ue = (e, t) => `${K(e)} / ${K(t)}`, de = (e) => u`
332
+ display: flex;
333
+ justify-content: flex-end;
334
+
335
+ border-radius: calc(0.4 * var(--mp-unit));
336
+ user-select: none;
337
+
338
+ z-index: 3;
339
+
340
+ * {
341
+ ${V.bMedium.regular}
342
+ }
343
+
344
+ ${e === "sm" && u`
345
+ padding: calc(0.4 * var(--mp-unit))!important;
346
+ `}
347
+ ${e === "md" && u`
348
+ padding: calc(0.6 * var(--mp-unit))!important;
349
+ `}
350
+ ${e === "lg" && u`
351
+ padding: calc(1.2 * var(--mp-unit))!important;
352
+ `}
353
+ `, q = ({ id: e, toolTipText: t, text: n, delayShow: r = 0, closeDelay: i = 0, offset: a = 20, tooltipPlace: o = "top", disabled: s = !1, size: c = "md" }) => /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("div", {
354
+ "data-tooltip-id": e,
355
+ "data-open": !0,
356
+ "data-tooltip-offset": a,
357
+ "data-tooltip-delay-show": r,
358
+ "data-tooltip-delay-hide": i,
359
+ "data-tooltip-place": o,
360
+ children: n
361
+ }), !s && /* @__PURE__ */ v(j, {
362
+ css: de(c),
363
+ id: e,
364
+ noArrow: !0,
365
+ children: t
366
+ })] }), J = ({ ref: e, onChange: t, orientation: n = "horizontal", disabled: r = !1 }) => {
367
+ let [i, s] = l(!1), u = c(t);
368
+ u.current = t;
369
+ let d = c(null), f = a((t, r) => {
370
+ let i = e.current;
371
+ if (!i) return 0;
372
+ let { left: a, right: o, top: s, bottom: c } = i.getBoundingClientRect(), l = n === "horizontal" ? (t - a) / (o - a) : (c - r) / (c - s);
373
+ return Math.min(Math.max(l, 0), 1);
374
+ }, [e, n]), p = a((e) => {
375
+ r || e.button > 0 || (d.current = e.pointerId, e.currentTarget.setPointerCapture?.(e.pointerId), s(!0), u.current(f(e.clientX, e.clientY)));
376
+ }, [r, f]), m = a((e) => {
377
+ d.current === e.pointerId && u.current(f(e.clientX, e.clientY));
378
+ }, [f]), h = a((e) => {
379
+ d.current === e.pointerId && (d.current = null, e.currentTarget.releasePointerCapture?.(e.pointerId), s(!1));
380
+ }, []);
381
+ return o(() => {
382
+ r && (d.current = null, s(!1));
383
+ }, [r]), {
384
+ dragging: i,
385
+ handlers: {
386
+ onPointerDown: p,
387
+ onPointerMove: m,
388
+ onPointerUp: h,
389
+ onPointerCancel: h,
390
+ style: { touchAction: "none" }
391
+ }
392
+ };
393
+ }, fe = u`
394
+ position: relative;
395
+ height: calc(.4 * var(--mp-unit));
396
+
397
+ --thumbnail-width: calc(25 * var(--mp-unit));
398
+ --thumbnail-half: calc(12.5 * var(--mp-unit));
399
+
400
+ transition: transform .2s ease-in-out;
401
+
402
+ margin: 0 12px;
403
+ @media (min-width: 768px) {
404
+ margin: 0 16px;
405
+ }
406
+ @media (min-width: 2560px) {
407
+ margin: 0 24px;
408
+ }
409
+
410
+ user-select: none;
411
+ cursor: pointer;
412
+
413
+ :hover {
414
+ .background-bar {
415
+ transform: scaleY(1.5);
416
+ }
417
+ .loaded {
418
+ transform: scaleY(1.5);
419
+ top: calc(-.1 * var(--mp-unit));
420
+ }
421
+ .play-container {
422
+ transform: scaleY(1.5);
423
+ }
424
+ }
425
+
426
+
427
+ .background-bar {
428
+ position: absolute;
429
+ inset: 0;
430
+ background-color: hsla(0, 100%, 100%, .2);
431
+ }
432
+
433
+ .cursor-time {
434
+ display: flex;
435
+ justify-content: center;
436
+
437
+ text-shadow: 0 0 4px rgba(0, 0, 0, 1);
438
+ ${V.bMedium.bold}
439
+
440
+ position: absolute;
441
+ top: calc(-2.5 * var(--mp-unit));
442
+ width: calc(5 * var(--mp-unit));
443
+
444
+ margin-left: calc(-2.5 * var(--mp-unit));
445
+ pointer-events: none;
446
+ }
447
+
448
+ .loaded {
449
+ transform-origin: 0 0;
450
+ position: absolute;
451
+ bottom: 0;
452
+ height: calc(.4 * var(--mp-unit));
453
+ width: 100%;
454
+ .loaded-part {
455
+ transform-origin: 0 0;
456
+ bottom: 0;
457
+ height: calc(.4 * var(--mp-unit));
458
+ width: 100%;
459
+ position: absolute;
460
+ background-color: hsla(0, 100%, 100%, .4);
461
+ }
462
+ }
463
+
464
+ .play-container {
465
+ position: absolute;
466
+ bottom: 0;
467
+ width: 100%;
468
+ height: calc(.4 * var(--mp-unit));
469
+ }
470
+
471
+ .play {
472
+ transform-origin: 0 0;
473
+ background-color: #f03;
474
+ position: absolute;
475
+ bottom: 0;
476
+ height: calc(.4 * var(--mp-unit));
477
+ width: 100%;
478
+ }
479
+
480
+ .padding {
481
+ position: absolute;
482
+ bottom: -7.5px;
483
+ height: calc(2 * var(--mp-unit));
484
+ width: 100%;
485
+ }
486
+
487
+ .thumbnail {
488
+ display: flex;
489
+ justify-content: center;
490
+
491
+ position: absolute;
492
+ top: calc(calc(-3.4375 * var(--mp-unit)) - var(--thumbnail-width) * 9/16);
493
+ height: calc(var(--thumbnail-width) * 9/16);
494
+ width: var(--thumbnail-width);
495
+
496
+ margin-left: calc(var(--thumbnail-half) * -1);
497
+ pointer-events: none;
498
+
499
+ img {
500
+ border-radius: calc(.4 * var(--mp-unit));
501
+ box-shadow: 0 0 calc(1 * var(--mp-unit)) rgba(0, 0, 0, .5);
502
+
503
+ width: 100%;
504
+ height: 100%;
505
+ object-fit: cover;
506
+ }
507
+ }
508
+
509
+ /* a thumb is far wider than a cursor, so the hit strip grows to 44px and the track thickens */
510
+ @media (pointer: coarse) {
511
+ height: calc(.6 * var(--mp-unit));
512
+
513
+ /* press feedback, coarse only: a finger has no hover, so without this the bar gives no sign
514
+ it is being dragged */
515
+ &.dragging {
516
+ .background-bar, .loaded, .play-container {
517
+ transform: scaleY(1.5);
518
+ }
519
+ }
520
+
521
+ .loaded {
522
+ height: calc(.6 * var(--mp-unit));
523
+ .loaded-part {
524
+ height: calc(.6 * var(--mp-unit));
525
+ }
526
+ }
527
+
528
+ .play-container {
529
+ height: calc(.6 * var(--mp-unit));
530
+ }
531
+
532
+ .play {
533
+ height: calc(.6 * var(--mp-unit));
534
+ }
535
+
536
+ /* grows upward into the video: centred, it would hang over the control row and win hit
537
+ testing against taps meant for play, mute and fullscreen */
538
+ .padding {
539
+ height: 44px;
540
+ bottom: 0;
541
+ }
542
+ }
543
+
544
+ /* the clamp only holds the preview inside the bar while the bar is the wider of the two, so
545
+ below that the preview is narrowed instead */
546
+ @media (max-width: 480px) {
547
+ --thumbnail-width: calc(18 * var(--mp-unit));
548
+ --thumbnail-half: calc(9 * var(--mp-unit));
549
+ }
550
+ `, pe = () => {
551
+ let e = P(), t = P((e) => e.currentTime), n = P((e) => e.duration), r = P((e) => e.size), i = P((e) => e.downloadedRanges), a = P((e) => e.indexes), u = P((e) => e.thumbnails), d = P((e) => e.thumbnailAt), f = c(null), [p, m] = l(void 0), [h, g] = l(void 0), _ = c(void 0), { dragging: b, handlers: x } = J({
552
+ ref: f,
553
+ onChange: (e) => {
554
+ m(e), _.current !== "mouse" && g(e * n);
555
+ }
556
+ }), S = (e) => {
557
+ _.current = e.pointerType, x.onPointerDown(e);
558
+ }, C = (e) => {
559
+ x.onPointerUp(e), e.pointerType !== "mouse" && g(void 0);
560
+ }, w = (e) => {
561
+ if (!f.current) return;
562
+ let { left: t, right: r } = f.current.getBoundingClientRect();
563
+ return Math.min(Math.max((e - t) / (r - t), 0), 1) * n;
564
+ }, T = (e) => {
565
+ g(w(e.clientX));
566
+ }, E = () => {
567
+ f.current && g(void 0);
568
+ }, D = (e) => n ? e / n * 100 : 0, O = s(() => i?.map((e, t) => {
569
+ if (!r || !n) return null;
570
+ let i = a.filter((t) => e.startByteOffset <= t.pos && t.pos <= e.endByteOffset), o = i.at(0), s = i.at(-1);
571
+ if (!o || !s) return null;
572
+ let c = o.timestamp / n, l = s.timestamp / n, u = Number((l - c).toFixed(2)), d = c * 100;
573
+ return /* @__PURE__ */ v("div", {
574
+ className: "loaded-part",
575
+ style: {
576
+ transform: `scaleX(${u})`,
577
+ marginLeft: `${d}%`
578
+ }
579
+ }, t);
580
+ }) ?? [], [
581
+ n,
582
+ a.length,
583
+ i?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}/${t}`).join(",")
584
+ ]), k = s(() => {
585
+ if (!h || h < 0) return;
586
+ let e = Math.floor(h / 3600), t = Math.floor((h - e * 3600) / 60), n = Math.floor(h - e * 3600 - t * 60);
587
+ return `${e > 0 ? `${e}:` : ""}${t < 10 ? "0" : ""}${t}:${n < 10 ? "0" : ""}${n}`;
588
+ }, [h]);
589
+ o(() => {
590
+ if (p === void 0 || !n) return;
591
+ let t = p * n;
592
+ e.seek(t);
593
+ }, [
594
+ e,
595
+ p,
596
+ n
597
+ ]);
598
+ let A = s(() => !n || typeof t != "number" ? 0 : t / n, [n, t]), j = s(() => {
599
+ if (h) {
600
+ if (d) return d(h);
601
+ if (u.length) return u.find(({ startTime: e, endTime: t }) => e <= h && h < t);
602
+ }
603
+ }, [
604
+ u,
605
+ d,
606
+ h
607
+ ]);
608
+ return /* @__PURE__ */ y("div", {
609
+ css: fe,
610
+ ref: f,
611
+ className: b ? "progress-bar dragging" : "progress-bar",
612
+ onMouseMove: T,
613
+ onMouseOut: E,
614
+ children: [
615
+ /* @__PURE__ */ v("div", { className: "background-bar" }),
616
+ h ? /* @__PURE__ */ v("div", {
617
+ className: "cursor-time",
618
+ style: { left: `clamp(calc(1.8 * var(--mp-unit)), ${D(h)}%, calc(100% - calc(1.8 * var(--mp-unit))))` },
619
+ children: k
620
+ }) : void 0,
621
+ /* @__PURE__ */ v("div", { className: "progress" }),
622
+ /* @__PURE__ */ v("div", {
623
+ className: "loaded",
624
+ children: O
625
+ }),
626
+ /* @__PURE__ */ v("div", { className: "hover" }),
627
+ /* @__PURE__ */ v("div", {
628
+ className: "play-container",
629
+ children: /* @__PURE__ */ v("div", {
630
+ className: "play",
631
+ style: { transform: `scaleX(${A})` }
632
+ })
633
+ }),
634
+ /* @__PURE__ */ v("div", { className: "chapters" }),
635
+ /* @__PURE__ */ v("div", { className: "scrubber" }),
636
+ /* @__PURE__ */ v("div", {
637
+ className: "padding",
638
+ ...x,
639
+ onPointerDown: S,
640
+ onPointerUp: C,
641
+ onPointerCancel: C
642
+ }),
643
+ /* @__PURE__ */ v("div", {
644
+ className: "thumbnail",
645
+ style: { left: `clamp(var(--thumbnail-half), ${D(h ?? 1)}%, calc(100% - var(--thumbnail-half)))` },
646
+ children: j?.url ? /* @__PURE__ */ v("img", { src: j.url }) : void 0
647
+ })
648
+ ]
649
+ });
650
+ }, me = "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", he = u`
651
+ display: flex;
652
+ align-items: center;
653
+ justify-content: center;
654
+ flex-direction: column;
655
+ width: 100%;
656
+
657
+ .playback-slider {
658
+ display: flex;
659
+ align-items: center;
660
+
661
+ padding: 8px 4px;
662
+ margin: 0 2px;
663
+ /* a finger needs a 44px band to press, so the padding grows while the track stays 3px */
664
+ @media (pointer: coarse) {
665
+ padding: 20px 8px;
666
+ }
667
+
668
+ cursor: pointer;
669
+
670
+ > div {
671
+ position: relative;
672
+
673
+ background: #ccc;
674
+ border-radius: 4px;
675
+
676
+ width: 120px;
677
+ max-width: 100%;
678
+ height: 3px;
679
+ @media (min-width: 768px) {
680
+ height: 4px;
681
+ }
682
+ }
683
+
684
+ .playback-handle {
685
+ position: absolute;
686
+
687
+
688
+ background: #ffffff;
689
+ border-radius: 50%;
690
+ transform: translateX(-50%);
691
+ pointer-events: none;
692
+
693
+ width: 10px;
694
+ height: 10px;
695
+ top: -3.5px;
696
+ @media (min-width: 768px) {
697
+ width: 12px;
698
+ height: 12px;
699
+ top: -4px;
700
+ }
701
+ }
702
+ }
703
+ `, ge = () => {
704
+ let e = P(), t = P((e) => e.playbackRate), n = c(null), r = c(null), i = .25, a = 3 - i, s = (e, t = .05) => Math.round(e / t) * t, l = s(t || 1), u = (e) => (e - i) / a * 100, d = (e) => s(i + e * a), { handlers: f } = J({
705
+ ref: r,
706
+ onChange: (t) => e.setPlaybackRate(d(t))
707
+ }), p = (t) => {
708
+ t.preventDefault();
709
+ let n = .05, r = l;
710
+ r = t.deltaY < 0 ? Math.min(3, r + n) : Math.max(i, r - n), e.setPlaybackRate(r);
711
+ };
712
+ o(() => {
713
+ let e = n.current;
714
+ return e && e.addEventListener("wheel", p, { passive: !1 }), () => {
715
+ e && e.removeEventListener("wheel", p);
716
+ };
717
+ }, [t]);
718
+ let m = u(l);
719
+ return /* @__PURE__ */ y("div", {
720
+ css: he,
721
+ children: [/* @__PURE__ */ y("div", { children: [l.toFixed(2), "x"] }), /* @__PURE__ */ v("div", {
722
+ className: "playback-slider",
723
+ ref: n,
724
+ ...f,
725
+ children: /* @__PURE__ */ v("div", {
726
+ ref: r,
727
+ style: { background: `linear-gradient(to right,
728
+ #fff 0% ${m}%,
729
+ #3A3A3A ${m}% 100%
730
+ )` },
731
+ children: /* @__PURE__ */ v("div", {
732
+ className: "playback-handle",
733
+ style: { left: `${m}%` }
734
+ })
735
+ })
736
+ })]
737
+ });
738
+ }, _e = u`
739
+ position: relative;
740
+
741
+ .settings {
742
+ /* the icon keeps its size, the pressable box grows around it */
743
+ @media (pointer: coarse) {
744
+ box-sizing: border-box;
745
+ justify-content: center;
746
+
747
+ min-width: 44px;
748
+ min-height: 44px;
749
+ }
750
+ }
751
+
752
+ .popover {
753
+ position: absolute;
754
+ /* the gear sits a couple of buttons in from the right edge, so a centred popover hangs off that
755
+ edge on a phone. It anchors to the button instead until the viewport has room to centre it. */
756
+ right: 0;
757
+ transform: none;
758
+
759
+ overflow-y: auto;
760
+ width: 180px;
761
+ max-width: calc(100vw - 24px);
762
+ height: 160px;
763
+ top: -180px;
764
+ @media (min-width: 768px) {
765
+ right: 50%;
766
+ transform: translateX(50%);
767
+ width: 250px;
768
+ height: 160px;
769
+ }
770
+
771
+ display: flex;
772
+ flex-direction: column;
773
+
774
+ border-radius: 8px;
775
+ background-color: rgba(28,28,28,0.95);
776
+ ${V.bMedium.regular}
777
+
778
+ z-index: 4;
779
+
780
+ > div {
781
+ display: flex;
782
+ align-items: center;
783
+ justify-content: space-between;
784
+
785
+ color: #fff;
786
+ outline: none;
787
+
788
+ padding: 8px 6px 8px 12px;
789
+
790
+ width: 100%;
791
+ /* rows keep their own height inside the fixed height column, so a long page scrolls rather than
792
+ squashing every row into it */
793
+ flex-shrink: 0;
794
+ @media (pointer: coarse) {
795
+ box-sizing: border-box;
796
+ min-height: 44px;
797
+ }
798
+
799
+ :first-of-type {
800
+ border-radius: 8px 8px 0 0;
801
+ }
802
+ :last-of-type {
803
+ border-radius: 0 0 8px 8px;
804
+ }
805
+ :not(&.no-hover) {
806
+ cursor: pointer;
807
+ }
808
+ :not(&.no-hover):hover {
809
+ background-color: rgba(255,255,255,.1);
810
+ }
811
+
812
+ > div {
813
+ display: flex;
814
+ align-items: center;
815
+ justify-content: center;
816
+
817
+ .secondary {
818
+ color: #eee;
819
+ ${V.bSmall.regular}
820
+ }
821
+ }
822
+ }
823
+
824
+ .back {
825
+ display: flex;
826
+ align-items: center;
827
+ justify-content: flex-start;
828
+ border-bottom: 1px solid #4D4D4E;
829
+
830
+ svg {
831
+ transform: translateX(-4px);
832
+ transition: transform 0.2s ease-in-out;
833
+ }
834
+
835
+ :hover {
836
+ svg {
837
+ transform: translateX(-8px);
838
+ }
839
+ }
840
+ }
841
+ }
842
+
843
+ .playback-rate {
844
+ .slider {
845
+ width: 100%;
846
+ }
847
+ .options {
848
+ display: grid;
849
+ grid-template-columns: 1fr 1fr 1fr 1fr;
850
+ align-items: center;
851
+
852
+ padding: 8px 12px;
853
+ /* four presets across a 180px popover leave targets 34px wide, so a finger gets two rows of two
854
+ until the popover is wide enough for the row of four */
855
+ @media (pointer: coarse) {
856
+ grid-template-columns: 1fr 1fr;
857
+ }
858
+ @media (pointer: coarse) and (min-width: 768px) {
859
+ grid-template-columns: 1fr 1fr 1fr 1fr;
860
+ }
861
+
862
+ > div {
863
+ display: flex;
864
+ align-items: center;
865
+ border-radius: 4px;
866
+
867
+ padding: 8px 6px;
868
+ height: 100%;
869
+ @media (pointer: coarse) {
870
+ box-sizing: border-box;
871
+ min-height: 44px;
872
+ }
873
+
874
+ cursor: pointer;
875
+ :hover {
876
+ background-color: rgba(255,255,255,.1);
877
+ }
878
+ }
879
+ }
880
+ }
881
+
882
+ .track-list {
883
+ .description {
884
+ word-break: break-word;
885
+ }
886
+ }
887
+ `, Y = ({ title: e, tracks: t, selected: n, onSelect: r, onBack: i, allowDisable: a }) => /* @__PURE__ */ y("div", {
888
+ className: "popover track-list",
889
+ children: [
890
+ /* @__PURE__ */ y("div", {
891
+ className: "back",
892
+ onClick: i,
893
+ children: [/* @__PURE__ */ v(b, {}), /* @__PURE__ */ v("span", { children: e })]
894
+ }),
895
+ a ? /* @__PURE__ */ y("div", {
896
+ onClick: () => r(void 0),
897
+ children: [/* @__PURE__ */ v("span", { children: "Disable" }), /* @__PURE__ */ v("span", { children: n === void 0 ? "✓" : "" })]
898
+ }) : null,
899
+ t.map(({ id: e, label: t }) => /* @__PURE__ */ y("div", {
900
+ onClick: () => r(e),
901
+ className: "description",
902
+ children: [/* @__PURE__ */ v("span", { children: t }), /* @__PURE__ */ v("span", { children: n === e ? "✓" : "" })]
903
+ }, e))
904
+ ]
905
+ }), ve = () => {
906
+ let e = P(), t = P((e) => e.playbackRate), n = P((e) => e.subtitleTracks), r = P((e) => e.selectedSubtitleTrack), i = P((e) => e.selectSubtitleTrack), a = P((e) => e.audioTracks), s = P((e) => e.selectedAudioTrack), u = P((e) => e.selectAudioTrack), [d, f] = l(!1), [p, m] = l(0), h = c(null), g = () => {
907
+ f(!d), m(0);
908
+ }, _ = (t) => {
909
+ e.setPlaybackRate(t), m(0);
910
+ };
911
+ o(() => {
912
+ let e = (e) => {
913
+ d && h.current && !h.current.contains(e.target) && g();
914
+ };
915
+ return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
916
+ }, [d]);
917
+ let S = (e) => {
918
+ i(e), g();
919
+ }, C = (e) => {
920
+ e !== void 0 && u(e), g();
921
+ }, w = (e) => () => {
922
+ m(e);
923
+ };
924
+ return /* @__PURE__ */ y("div", {
925
+ css: _e,
926
+ ref: h,
927
+ children: [
928
+ /* @__PURE__ */ v(q, {
929
+ id: "settings",
930
+ disabled: d,
931
+ text: /* @__PURE__ */ v("button", {
932
+ className: "settings",
933
+ type: "button",
934
+ onClick: g,
935
+ children: /* @__PURE__ */ v(D, {})
936
+ }),
937
+ toolTipText: /* @__PURE__ */ v("span", { children: "Settings" })
938
+ }),
939
+ d && p === 0 && /* @__PURE__ */ y("div", {
940
+ className: "popover menu",
941
+ children: [
942
+ a.length > 1 ? /* @__PURE__ */ y("div", {
943
+ onClick: w(3),
944
+ children: [/* @__PURE__ */ v("div", { children: "Audio" }), /* @__PURE__ */ v("div", { children: /* @__PURE__ */ v(x, {}) })]
945
+ }) : null,
946
+ n.length > 0 ? /* @__PURE__ */ y("div", {
947
+ onClick: w(2),
948
+ children: [/* @__PURE__ */ v("div", { children: "Subtitles" }), /* @__PURE__ */ v("div", { children: /* @__PURE__ */ v(x, {}) })]
949
+ }) : null,
950
+ /* @__PURE__ */ y("div", {
951
+ onClick: w(1),
952
+ children: [/* @__PURE__ */ v("div", { children: "Playback speed" }), /* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("span", {
953
+ className: "secondary",
954
+ children: t === 1 ? "(Default)" : t.toFixed(2)
955
+ }), /* @__PURE__ */ v(x, {})] })]
956
+ })
957
+ ]
958
+ }),
959
+ d && p === 1 && /* @__PURE__ */ y("div", {
960
+ className: "popover playback-rate",
961
+ children: [
962
+ /* @__PURE__ */ y("div", {
963
+ className: "back",
964
+ onClick: w(0),
965
+ children: [/* @__PURE__ */ v(b, {}), /* @__PURE__ */ v("span", { children: "Playback speed" })]
966
+ }),
967
+ /* @__PURE__ */ v("div", {
968
+ className: "slider no-hover",
969
+ children: /* @__PURE__ */ v(ge, {})
970
+ }),
971
+ /* @__PURE__ */ y("div", {
972
+ className: "options no-hover",
973
+ children: [
974
+ /* @__PURE__ */ v("div", {
975
+ onClick: () => _(.5),
976
+ children: "0.5x"
977
+ }),
978
+ /* @__PURE__ */ v("div", {
979
+ onClick: () => _(1),
980
+ children: "1x"
981
+ }),
982
+ /* @__PURE__ */ v("div", {
983
+ onClick: () => _(1.5),
984
+ children: "1.5x"
985
+ }),
986
+ /* @__PURE__ */ v("div", {
987
+ onClick: () => _(2),
988
+ children: "2x"
989
+ })
990
+ ]
991
+ })
992
+ ]
993
+ }),
994
+ d && p === 2 && /* @__PURE__ */ v(Y, {
995
+ title: "Subtitles",
996
+ tracks: n,
997
+ selected: r,
998
+ onSelect: S,
999
+ onBack: w(0),
1000
+ allowDisable: !0
1001
+ }),
1002
+ d && p === 3 && /* @__PURE__ */ v(Y, {
1003
+ title: "Audio",
1004
+ tracks: a,
1005
+ selected: s,
1006
+ onSelect: C,
1007
+ onBack: w(0)
1008
+ })
1009
+ ]
1010
+ });
1011
+ }, ye = {
1012
+ primary: "#EAEBEE",
1013
+ secondary: "#D0D0D9",
1014
+ hover: "rgba(255, 255, 255, 0.13)",
1015
+ borderPrimary: "#384F70",
1016
+ backgroundTooltip: "#222222"
1017
+ }, be = u`
1018
+ display: flex;
1019
+ align-items: center;
1020
+
1021
+ padding: 16px 4px;
1022
+ margin: 0 2px;
1023
+ /* a finger needs a 44px band to press, so the padding grows while the track stays 3px */
1024
+ @media (pointer: coarse) {
1025
+ padding: 22px 4px;
1026
+ }
1027
+
1028
+ cursor: pointer;
1029
+
1030
+ > div {
1031
+ position: relative;
1032
+
1033
+ background: #ccc;
1034
+ border-radius: 4px;
1035
+
1036
+ width: 80px;
1037
+ height: 3px;
1038
+ /* the control bar has under 360px to fit every button once the slider is always open, so the
1039
+ track lends some of its length back on a phone and takes it again on anything wider */
1040
+ @media (pointer: coarse) {
1041
+ width: 64px;
1042
+ }
1043
+ @media (pointer: coarse) and (min-width: 768px) {
1044
+ width: 80px;
1045
+ }
1046
+ }
1047
+
1048
+ .volume-handle {
1049
+ position: absolute;
1050
+ top: -3.5px;
1051
+
1052
+ background: #ffffff;
1053
+ border-radius: 50%;
1054
+ transform: translateX(-50%);
1055
+ pointer-events: none;
1056
+
1057
+ width: 10px;
1058
+ height: 10px;
1059
+ }
1060
+ `, xe = ({ value: e, onChange: t }) => {
1061
+ let n = P((e) => e.volume), r = P((e) => e.muted), i = c(null), a = c(null), { handlers: l } = J({
1062
+ ref: a,
1063
+ onChange: t
1064
+ }), u = (n) => {
1065
+ n.preventDefault();
1066
+ let r = .05, i = e;
1067
+ i = n.deltaY < 0 ? Math.min(1, i + r) : Math.max(0, i - r), t(i);
1068
+ };
1069
+ o(() => {
1070
+ let e = i.current;
1071
+ return e && e.addEventListener("wheel", u, { passive: !1 }), () => {
1072
+ e && e.removeEventListener("wheel", u);
1073
+ };
1074
+ }, [e]);
1075
+ let d = e * 100, f = s(() => Math.round(r ? 0 : G(n) * 100), [n, r]);
1076
+ return /* @__PURE__ */ v(q, {
1077
+ id: "volume-slider",
1078
+ text: /* @__PURE__ */ v("div", {
1079
+ ref: i,
1080
+ css: be,
1081
+ ...l,
1082
+ children: /* @__PURE__ */ v("div", {
1083
+ ref: a,
1084
+ style: { background: `linear-gradient(to right,
1085
+ #fff 0% ${d}%,
1086
+ #3A3A3A ${d}% 100%
1087
+ )` },
1088
+ children: /* @__PURE__ */ v("div", {
1089
+ className: "volume-handle",
1090
+ style: { left: `${e * 100}%` }
1091
+ })
1092
+ })
1093
+ }),
1094
+ toolTipText: /* @__PURE__ */ y("div", {
1095
+ className: "volume-value",
1096
+ children: [f, "%"]
1097
+ })
1098
+ });
1099
+ }, Se = u`
1100
+ position: relative;
1101
+ display: flex;
1102
+ align-items: center;
1103
+
1104
+ .volume-slider-container {
1105
+ display: flex;
1106
+ align-items: center;
1107
+
1108
+ width: 0;
1109
+ margin-right: 0;
1110
+ overflow: hidden;
1111
+ pointer-events: none;
1112
+
1113
+ transition: margin .2s cubic-bezier(0.4,0,1,1), width .2s cubic-bezier(0.4,0,1,1);
1114
+ -webkit-transition: margin .2s cubic-bezier(0.4,0,1,1), width .2s cubic-bezier(0.4,0,1,1);
1115
+
1116
+ .volume-slider-background {
1117
+ display: flex;
1118
+ flex-direction: row;
1119
+ align-items: center;
1120
+
1121
+ border-radius: 4px;
1122
+
1123
+ .volume-value {
1124
+ ${V.bMedium.regular};
1125
+ color: #ffffff;
1126
+ }
1127
+ }
1128
+ }
1129
+
1130
+ &:hover .volume-slider-container {
1131
+ width: calc(9 * var(--mp-unit));
1132
+
1133
+ transition: margin .2s cubic-bezier(0,0,0.2,1), width .2s cubic-bezier(0,0,0.2,1);
1134
+ -webkit-transition: margin .2s cubic-bezier(0,0,0.2,1), width .2s cubic-bezier(0,0,0.2,1);
1135
+
1136
+ pointer-events: auto;
1137
+ }
1138
+
1139
+ /* a touch screen has no hover, so the slider stays open there and the button only mutes */
1140
+ @media (pointer: coarse) {
1141
+ /* auto, not a fixed rem: the container keeps overflow: hidden, so a narrower fixed width
1142
+ silently clips the track and makes the clipped part unhittable */
1143
+ .volume-slider-container,
1144
+ &:hover .volume-slider-container {
1145
+ width: auto;
1146
+
1147
+ pointer-events: auto;
1148
+ }
1149
+
1150
+ /* a 44px press target around an 18px icon, floored here because the control bar sets the
1151
+ padding at a higher specificity */
1152
+ .sound {
1153
+ /* border-box explicitly, since a consumer reset cannot be assumed */
1154
+ box-sizing: border-box;
1155
+ justify-content: center;
1156
+
1157
+ min-width: 44px;
1158
+ min-height: 44px;
1159
+ }
1160
+ }
1161
+
1162
+ `, Ce = ({ ref: e }) => {
1163
+ let t = P(), n = P((e) => e.volume), r = P((e) => e.muted), i = s(() => G(n), [n]);
1164
+ return /* @__PURE__ */ y("div", {
1165
+ css: Se,
1166
+ children: [/* @__PURE__ */ v(q, {
1167
+ id: "sound",
1168
+ text: /* @__PURE__ */ v("button", {
1169
+ className: "sound",
1170
+ type: "button",
1171
+ onClick: () => t.toggleMuted(),
1172
+ ref: e,
1173
+ children: v(r || n === 0 ? A : n <= .5 ? O : k, {
1174
+ size: 18,
1175
+ color: "#fff"
1176
+ })
1177
+ }),
1178
+ toolTipText: /* @__PURE__ */ v("span", { children: r ? "Unmute (m)" : "Mute (m)" })
1179
+ }), /* @__PURE__ */ v("div", {
1180
+ className: "volume-slider-container",
1181
+ children: /* @__PURE__ */ v("div", {
1182
+ className: "volume-slider-background",
1183
+ children: /* @__PURE__ */ v(xe, {
1184
+ value: r ? 0 : i,
1185
+ onChange: (e) => {
1186
+ t.setVolume(W(e));
1187
+ }
1188
+ })
1189
+ })
1190
+ })]
1191
+ });
1192
+ }, X = .05, Z = 5, we = u`
1193
+ position: absolute;
1194
+ bottom: 0;
1195
+ width: 100%;
1196
+
1197
+ background: linear-gradient(0deg, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0.45) 20%, rgba(0,0,0,0.3) 40%, rgba(0,0,0,0.15) 70%, transparent 100%);
1198
+ transition: opacity 0.1s cubic-bezier(.4,0,1,1);
1199
+
1200
+ .actions {
1201
+ display: flex;
1202
+ justify-content: space-between;
1203
+
1204
+ /* repeated per breakpoint: nested at-rules are hoisted after the rule, so a shorthand inside a
1205
+ media query would override a longhand above it and silently drop the safe-area inset */
1206
+ padding: 6px calc(12px + env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px));
1207
+ @media (min-width: 768px) {
1208
+ padding: 8px calc(16px + env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
1209
+ }
1210
+ @media (min-width: 2560px) {
1211
+ padding: 8px calc(24px + env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) calc(24px + env(safe-area-inset-left, 0px));
1212
+ }
1213
+
1214
+ .left, .right {
1215
+ display: flex;
1216
+ align-items: center;
1217
+
1218
+ button {
1219
+ display: flex;
1220
+ align-items: center;
1221
+
1222
+ outline: none;
1223
+ border: none;
1224
+ background: none;
1225
+
1226
+ svg {
1227
+ width: 18px;
1228
+ height: 18px;
1229
+ @media (min-width: 768px) {
1230
+ width: 24px;
1231
+ height: 24px;
1232
+ }
1233
+ @media (min-width: 2560px) {
1234
+ width: 28px;
1235
+ height: 28px;
1236
+ }
1237
+ }
1238
+
1239
+ svg {
1240
+ stroke: #fff;
1241
+ }
1242
+ }
1243
+
1244
+ .play, .sound, .time, .settings, .picture-in-picture, .full-screen {
1245
+ display: flex;
1246
+ align-items: center;
1247
+
1248
+ height: 100%;
1249
+
1250
+ border-radius: 4px;
1251
+ user-select: none;
1252
+
1253
+ padding: 8px;
1254
+ @media (min-width: 768px) {
1255
+ padding: 8px 12px;
1256
+ }
1257
+ @media (min-width: 2560px) {
1258
+ padding: 8px 12px;
1259
+ }
1260
+ }
1261
+
1262
+ .play, .sound, .settings, .picture-in-picture, .full-screen {
1263
+ border-radius: 4px;
1264
+
1265
+ padding: 8px;
1266
+ @media (min-width: 768px) {
1267
+ padding: 8px 12px;
1268
+ }
1269
+ @media (min-width: 2560px) {
1270
+ padding: 8px 12px;
1271
+ }
1272
+
1273
+ cursor: pointer;
1274
+
1275
+ :hover {
1276
+ background-color: ${ye.hover};
1277
+ }
1278
+
1279
+ /* the hit area grows, the icon does not, keyed on the pointer because a narrow desktop
1280
+ window still has a mouse */
1281
+ @media (pointer: coarse) {
1282
+ /* border-box explicitly, since a consumer reset cannot be assumed */
1283
+ box-sizing: border-box;
1284
+ min-width: 44px;
1285
+ min-height: 44px;
1286
+ justify-content: center;
1287
+ }
1288
+ }
1289
+ }
1290
+
1291
+ .left {
1292
+ .time {
1293
+ ${V.bMedium.regular}
1294
+ text-shadow: 0 0 4px rgba(0, 0, 0, 1);
1295
+ }
1296
+ }
1297
+ .right {
1298
+ .picture-in-picture {
1299
+ img {
1300
+ width: 22px;
1301
+ height: 22px;
1302
+ @media (min-width: 768px) {
1303
+ width: 28px;
1304
+ height: 28px;
1305
+ }
1306
+ @media (min-width: 2560px) {
1307
+ width: 32px;
1308
+ height: 32px;
1309
+ }
1310
+ }
1311
+ }
1312
+ }
1313
+ }
1314
+ `, Te = () => {
1315
+ let e = P(), t = P((e) => e.paused), n = P((e) => e.currentTime), r = P((e) => e.duration), i = P((e) => e.fullscreen), s = P((e) => e.hideUI), c = P((e) => e.togglePictureInPicture), [u, d] = l(null), f = r > 0 && n === r, p = a(({ direction: t, stepSize: n }) => {
1316
+ let r = G(e.volume), i = t === "up" ? n : -n, a = Math.max(0, Math.min(1, r + i)), o = e.muted;
1317
+ e.setVolume(W(a)), o && !e.muted && e.toggleMuted();
1318
+ }, [e]);
1319
+ o(() => {
1320
+ let t = (t) => {
1321
+ let n = t.target;
1322
+ if (n?.isContentEditable || /^(input|textarea|select)$/i.test(n?.tagName ?? "")) return;
1323
+ let r = !0;
1324
+ if (t.key === "f") e.toggleFullscreen();
1325
+ else if (t.key === "k") e.togglePaused();
1326
+ else if (t.key === " ") e.togglePaused();
1327
+ else if (t.key === "m") e.toggleMuted();
1328
+ else if (t.key === "ArrowUp") p({
1329
+ direction: "up",
1330
+ stepSize: X
1331
+ });
1332
+ else if (t.key === "ArrowDown") p({
1333
+ direction: "down",
1334
+ stepSize: X
1335
+ });
1336
+ else if (t.key === "ArrowRight") {
1337
+ if (!e.duration) return;
1338
+ e.seek(Math.min(e.currentTime + Z, e.duration));
1339
+ } else t.key === "ArrowLeft" ? e.seek(Math.max(e.currentTime - Z, 0)) : r = !1;
1340
+ r && t.preventDefault();
1341
+ };
1342
+ return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
1343
+ }, [e, p]);
1344
+ let m = a((e) => {
1345
+ e.preventDefault(), e.deltaY < 0 ? p({
1346
+ direction: "up",
1347
+ stepSize: X
1348
+ }) : p({
1349
+ direction: "down",
1350
+ stepSize: X
1351
+ });
1352
+ }, [p]);
1353
+ return o(() => {
1354
+ if (u) return u.addEventListener("wheel", m, { passive: !1 }), () => u.removeEventListener("wheel", m);
1355
+ }, [u, m]), /* @__PURE__ */ y("div", {
1356
+ css: we,
1357
+ style: { ...s ? {
1358
+ opacity: "0",
1359
+ pointerEvents: "none"
1360
+ } : {} },
1361
+ children: [/* @__PURE__ */ v(pe, {}), /* @__PURE__ */ y("div", {
1362
+ className: "actions",
1363
+ children: [/* @__PURE__ */ y("div", {
1364
+ className: "left",
1365
+ children: [
1366
+ /* @__PURE__ */ v(q, {
1367
+ id: "play",
1368
+ tooltipPlace: "top-start",
1369
+ text: /* @__PURE__ */ v("button", {
1370
+ className: "play",
1371
+ type: "button",
1372
+ onClick: () => e.togglePaused(),
1373
+ children: v(f ? E : t ? T : w, {})
1374
+ }),
1375
+ toolTipText: /* @__PURE__ */ v("span", { children: f ? "Replay (k)" : t ? "Play (k)" : "Pause (k)" })
1376
+ }),
1377
+ /* @__PURE__ */ v(Ce, { ref: d }),
1378
+ /* @__PURE__ */ v("div", {
1379
+ className: "time",
1380
+ children: ue(n, r)
1381
+ })
1382
+ ]
1383
+ }), /* @__PURE__ */ y("div", {
1384
+ className: "right",
1385
+ children: [
1386
+ /* @__PURE__ */ v(ve, {}),
1387
+ /* @__PURE__ */ v(q, {
1388
+ id: "picture-in-picture",
1389
+ text: /* @__PURE__ */ v("button", {
1390
+ className: "picture-in-picture",
1391
+ type: "button",
1392
+ onClick: c,
1393
+ children: /* @__PURE__ */ v("img", { src: me })
1394
+ }),
1395
+ toolTipText: /* @__PURE__ */ v("span", { children: "Picture in picture" })
1396
+ }),
1397
+ /* @__PURE__ */ v(q, {
1398
+ id: "full-screen",
1399
+ tooltipPlace: "top-end",
1400
+ text: /* @__PURE__ */ v("button", {
1401
+ className: "full-screen",
1402
+ type: "button",
1403
+ onClick: () => e.toggleFullscreen(),
1404
+ children: v(i ? C : S, {})
1405
+ }),
1406
+ toolTipText: /* @__PURE__ */ v("span", { children: i ? "Exit full screen (f)" : "Full screen (f)" })
1407
+ })
1408
+ ]
1409
+ })]
1410
+ })]
1411
+ });
1412
+ }, Ee = 3e3, De = u`
1413
+ position: relative;
1414
+ background-color: black;
1415
+ display: flex;
1416
+ justify-content: center;
1417
+ align-items: center;
1418
+ height: 100%;
1419
+ width: 100%;
1420
+
1421
+ & > div:not(:last-of-type) {
1422
+ position: absolute;
1423
+ z-index: 2;
1424
+ }
1425
+
1426
+ canvas {
1427
+ height: 100%;
1428
+ width: 100%;
1429
+ pointer-events: none;
1430
+ position: absolute;
1431
+ z-index: 1;
1432
+ }
1433
+
1434
+ .video, video {
1435
+ height: 100%;
1436
+ width: 100%;
1437
+ background-color: black;
1438
+ object-fit: contain;
1439
+ }
1440
+
1441
+ &.hide {
1442
+ cursor: none;
1443
+ }
1444
+ `, Oe = ({ ref: e, onVideoRef: t, onCanvasRef: n, overlay: r, children: i }) => {
1445
+ let a = P(), s = P((e) => e.hideUI), l = P((e) => e.setHideUI), u = c(void 0), d = c("mouse");
1446
+ o(() => () => clearTimeout(u.current), []);
1447
+ let f = () => {
1448
+ l(!1), clearTimeout(u.current), u.current = setTimeout(() => l(!0), Ee);
1449
+ };
1450
+ return /* @__PURE__ */ y("div", {
1451
+ css: De,
1452
+ ref: e,
1453
+ onPointerMove: (e) => {
1454
+ d.current = e.pointerType, e.pointerType === "mouse" && f();
1455
+ },
1456
+ onPointerDown: (e) => {
1457
+ d.current = e.pointerType;
1458
+ },
1459
+ onMouseOut: (e) => {
1460
+ let t = e.relatedTarget;
1461
+ if (t && e.currentTarget.contains(t)) return;
1462
+ let { left: n, right: r, top: i, bottom: a } = e.currentTarget.getBoundingClientRect();
1463
+ e.clientX >= n && e.clientX < r && e.clientY >= i && e.clientY < a || (clearTimeout(u.current), l(!0));
1464
+ },
1465
+ className: s ? "hide" : "",
1466
+ children: [
1467
+ /* @__PURE__ */ v(le, { onCanvasRef: n }),
1468
+ r,
1469
+ /* @__PURE__ */ v(Te, {}),
1470
+ /* @__PURE__ */ y("div", {
1471
+ className: "video",
1472
+ onClick: () => {
1473
+ if (d.current === "mouse") {
1474
+ a.togglePaused();
1475
+ return;
1476
+ }
1477
+ s ? f() : (clearTimeout(u.current), l(!0));
1478
+ },
1479
+ children: [t ? /* @__PURE__ */ v("video", {
1480
+ ref: t,
1481
+ playsInline: !0
1482
+ }) : null, i]
1483
+ })
1484
+ ]
1485
+ });
1486
+ }, Q = ({ options: e, children: t }) => {
1487
+ let n = "media" in e ? e : null, r = n ? null : e, { title: i } = e, { size: a, downloadedRanges: s, publicPath: c, libavWorkerUrl: u, read: d, thumbnailRead: f, thumbnailsEnabled: h } = r ?? {}, g = m(), _ = p(), [y, b] = l(null), [x, S] = l(null), C = n?.media ?? y;
1488
+ o(() => (g?.(C), () => g?.(null)), [C, g]), re(y, x, r);
1489
+ let w = z({
1490
+ publicPath: c,
1491
+ workerUrl: u,
1492
+ length: h === !1 ? void 0 : a,
1493
+ read: f ?? d,
1494
+ downloadedRanges: s
1495
+ }), T = n?.thumbnails?.all ?? w, E = B(y, x), D = P((e) => e.setSourceState);
1496
+ o(() => {
1497
+ D({
1498
+ title: i,
1499
+ size: a,
1500
+ downloadedRanges: s
1501
+ });
1502
+ }, [
1503
+ D,
1504
+ i,
1505
+ a,
1506
+ s
1507
+ ]);
1508
+ let O = n?.thumbnails?.at;
1509
+ o(() => {
1510
+ D({
1511
+ thumbnails: T,
1512
+ thumbnailAt: O,
1513
+ togglePictureInPicture: E
1514
+ });
1515
+ }, [
1516
+ D,
1517
+ T,
1518
+ O,
1519
+ E
1520
+ ]);
1521
+ let k = n?.subtitles?.selection, A = n?.audioTracks?.selection;
1522
+ return o(() => {
1523
+ k && D({
1524
+ subtitleTracks: k.options.map(({ id: e, label: t }) => ({
1525
+ id: e,
1526
+ label: t
1527
+ })),
1528
+ selectedSubtitleTrack: k.selectedId ?? void 0,
1529
+ selectSubtitleTrack: (e) => k.select(e == null ? null : String(e))
1530
+ });
1531
+ }, [D, k]), o(() => {
1532
+ A && D({
1533
+ audioTracks: A.options.map(({ id: e, label: t }) => ({
1534
+ id: e,
1535
+ label: t
1536
+ })),
1537
+ selectedAudioTrack: A.selectedId ?? void 0,
1538
+ selectAudioTrack: (e) => A.select(String(e))
1539
+ });
1540
+ }, [D, A]), /* @__PURE__ */ v(Oe, {
1541
+ ref: _,
1542
+ onVideoRef: n ? void 0 : b,
1543
+ onCanvasRef: S,
1544
+ overlay: e.overlay,
1545
+ children: t
1546
+ });
1547
+ }, ke = u`
1548
+ /**
1549
+ * The chrome's whole scale, in one place.
1550
+ *
1551
+ * Everything inside is sized against this rather than against \`rem\`, because \`rem\` is root
1552
+ * relative and a library cannot own the host page's root font. The old contract was that the host
1553
+ * set \`html { font-size: 62.5% }\`, which silently rendered every control 1.6x too large in any app
1554
+ * that did not, and could not be met by an app whose own screens are sized against the default.
1555
+ * Override it on the player element to rescale the whole chrome.
1556
+ */
1557
+ --mp-unit: 10px;
1558
+
1559
+ display: flex;
1560
+ justify-content: center;
1561
+ background-color: #111;
1562
+ height: 100%;
1563
+ width: 100%;
1564
+ overflow: hidden;
1565
+ `, $ = (e) => /* @__PURE__ */ v("div", {
1566
+ css: ke,
1567
+ children: /* @__PURE__ */ v(N.Provider, { children: /* @__PURE__ */ v(Q, {
1568
+ options: e,
1569
+ children: e.children
1570
+ }) })
1571
+ }), Ae = (e) => !!e && typeof e == "object" && "at" in e, je = (e) => !!e && typeof e == "object" && "selection" in e, Me = ({ blob: e, name: t }) => ({
1572
+ length: e.size,
1573
+ name: t ?? (e instanceof File ? e.name : void 0),
1574
+ read: (t, n) => e.slice(t, t + n).arrayBuffer()
1575
+ }), Ne = async (e, t) => {
1576
+ let n = await fetch(e, {
1577
+ headers: { Range: "bytes=0-1" },
1578
+ credentials: t
1579
+ });
1580
+ if (!n.ok) throw Error(`The source could not be read: HTTP ${n.status}`);
1581
+ let r = n.headers.get("Content-Range")?.split("/").at(1), i = Number(r || n.headers.get("Content-Length"));
1582
+ if (!Number.isFinite(i) || i <= 0) throw Error("The source did not report its length");
1583
+ if (!r && n.status !== 206) throw Error("The source does not support range requests");
1584
+ return i;
1585
+ }, Pe = async ({ url: e, length: t, name: n, credentials: r }) => {
1586
+ let i = t ?? await Ne(e, r);
1587
+ return {
1588
+ length: i,
1589
+ name: n,
1590
+ read: async (t, n) => {
1591
+ let a = await fetch(e, {
1592
+ headers: { Range: `bytes=${t}-${Math.min(t + n, i) - 1}` },
1593
+ credentials: r
1594
+ });
1595
+ if (!a.ok) throw Error(`The source could not be read: HTTP ${a.status}`);
1596
+ return a.arrayBuffer();
1597
+ }
1598
+ };
1599
+ }, Fe = async (e) => {
1600
+ if ("blob" in e) return Me(e);
1601
+ if ("url" in e) return Pe(e);
1602
+ if ("read" in e) return {
1603
+ length: e.length,
1604
+ name: e.name,
1605
+ read: e.read
1606
+ };
1607
+ throw Error(`Unknown source type: ${e}`);
1608
+ };
1609
+ //#endregion
1610
+ export { $ as MediaPlayer, $ as default, N as Player, n as SUBTITLES_OFF, i as createPictureInPicture, r as createSubtitleRenderer, t as createThumbnailGenerator, Fe as inputToRemuxerInput, je as isDelegatedTracks, Ae as isExternalThumbnails, M as sourceFeature, e as startPlayback, B as usePictureInPicture, P as usePlayer, z as useSeekThumbnails };