@glitchlab/react-video-player 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,53 +1,24 @@
1
1
  "use client";
2
- import { jsx as r, jsxs as m } from "react/jsx-runtime";
3
- import X, { useRef as H, useImperativeHandle as q, useEffect as G, useState as $, useMemo as I, useCallback as b } from "react";
4
- import E from "hls.js";
5
- function _(e) {
6
- var o, n, t = "";
7
- if (typeof e == "string" || typeof e == "number") t += e;
2
+ import { jsxs as v, jsx as t } from "react/jsx-runtime";
3
+ import pe, { useState as k, useRef as V, useCallback as S, useEffect as x, useImperativeHandle as me, useMemo as U } from "react";
4
+ import $ from "hls.js";
5
+ function Q(e) {
6
+ var n, s, r = "";
7
+ if (typeof e == "string" || typeof e == "number") r += e;
8
8
  else if (typeof e == "object") if (Array.isArray(e)) {
9
- var l = e.length;
10
- for (o = 0; o < l; o++) e[o] && (n = _(e[o])) && (t && (t += " "), t += n);
11
- } else for (n in e) e[n] && (t && (t += " "), t += n);
12
- return t;
9
+ var i = e.length;
10
+ for (n = 0; n < i; n++) e[n] && (s = Q(e[n])) && (r && (r += " "), r += s);
11
+ } else for (s in e) e[s] && (r && (r += " "), r += s);
12
+ return r;
13
13
  }
14
- function Z() {
15
- for (var e, o, n = 0, t = "", l = arguments.length; n < l; n++) (e = arguments[n]) && (o = _(e)) && (t && (t += " "), t += o);
16
- return t;
14
+ function H() {
15
+ for (var e, n, s = 0, r = "", i = arguments.length; s < i; s++) (e = arguments[s]) && (n = Q(e)) && (r && (r += " "), r += n);
16
+ return r;
17
17
  }
18
- const B = X.forwardRef(
19
- ({ src: e, hlsConfig: o, isHls: n, autoPlay: t, children: l, ...f }, d) => {
20
- const a = H(null), c = H(null);
21
- q(d, () => a.current);
22
- const y = globalThis.window !== void 0 && E.isSupported(), C = !!n || y && typeof e == "string" && e.endsWith(".m3u8");
23
- return G(() => {
24
- if (!e) return;
25
- const s = a.current;
26
- if (!s) return;
27
- const u = () => {
28
- t && s.play().catch(() => {
29
- });
30
- };
31
- for (c.current && (c.current.destroy(), c.current = null), s.pause(), s.removeAttribute("src"); s.firstChild; ) s.firstChild.remove();
32
- if (C) {
33
- const i = new E(o);
34
- c.current = i, i.attachMedia(s), i.loadSource(e), i.on(E.Events.MANIFEST_PARSED, u), i.on(E.Events.ERROR, (R, T) => {
35
- T.fatal && (i.destroy(), c.current = null);
36
- });
37
- } else
38
- s.src = e, s.load(), s.addEventListener("loadedmetadata", u, { once: !0 });
39
- return () => {
40
- for (s.removeEventListener("loadedmetadata", u), c.current && (c.current.destroy(), c.current = null), s.pause(), s.removeAttribute("src"); s.firstChild; ) s.firstChild.remove();
41
- s.load();
42
- };
43
- }, [e, C, o, t]), /* @__PURE__ */ r("video", { ref: a, ...f, children: l });
44
- }
45
- );
46
- B.displayName = "HLSPlayer";
47
- const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) => /* @__PURE__ */ m(
18
+ const K = "gvp-icon", L = (e) => e ? `${K} ${e}` : K, fe = ({ className: e }) => /* @__PURE__ */ v(
48
19
  "svg",
49
20
  {
50
- className: M(e),
21
+ className: L(e),
51
22
  width: "20",
52
23
  height: "20",
53
24
  viewBox: "0 0 24 24",
@@ -55,7 +26,7 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
55
26
  xmlns: "http://www.w3.org/2000/svg",
56
27
  "aria-hidden": "true",
57
28
  children: [
58
- /* @__PURE__ */ r(
29
+ /* @__PURE__ */ t(
59
30
  "path",
60
31
  {
61
32
  d: "M14 2H10C6.72077 2 5.08116 2 3.91891 2.81382C3.48891 3.1149 3.1149 3.48891 2.81382 3.91891C2 5.08116 2 6.72077 2 10C2 13.2792 2 14.9188 2.81382 16.0811C3.1149 16.5111 3.48891 16.8851 3.91891 17.1862C5.08116 18 6.72077 18 10 18H14C17.2792 18 18.9188 18 20.0811 17.1862C20.5111 16.8851 20.8851 16.5111 21.1862 16.0811C22 14.9188 22 13.2792 22 10C22 6.72077 22 5.08116 21.1862 3.91891C20.8851 3.48891 20.5111 3.1149 20.0811 2.81382C18.9188 2 17.2792 2 14 2Z",
@@ -64,7 +35,7 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
64
35
  strokeLinecap: "round"
65
36
  }
66
37
  ),
67
- /* @__PURE__ */ r(
38
+ /* @__PURE__ */ t(
68
39
  "path",
69
40
  {
70
41
  d: "M11 15H13",
@@ -74,7 +45,7 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
74
45
  strokeLinejoin: "round"
75
46
  }
76
47
  ),
77
- /* @__PURE__ */ r(
48
+ /* @__PURE__ */ t(
78
49
  "path",
79
50
  {
80
51
  d: "M14.5 22L14.1845 21.5811C13.4733 20.6369 13.2969 19.1944 13.7468 18M9.5 22L9.8155 21.5811C10.5267 20.6369 10.7031 19.1944 10.2532 18",
@@ -83,13 +54,13 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
83
54
  strokeLinecap: "round"
84
55
  }
85
56
  ),
86
- /* @__PURE__ */ r("path", { d: "M7 22H17", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
57
+ /* @__PURE__ */ t("path", { d: "M7 22H17", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
87
58
  ]
88
59
  }
89
- ), Q = ({ className: e }) => /* @__PURE__ */ m(
60
+ ), ge = ({ className: e }) => /* @__PURE__ */ v(
90
61
  "svg",
91
62
  {
92
- className: M(e),
63
+ className: L(e),
93
64
  width: "20",
94
65
  height: "20",
95
66
  viewBox: "0 0 24 24",
@@ -97,7 +68,7 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
97
68
  xmlns: "http://www.w3.org/2000/svg",
98
69
  "aria-hidden": "true",
99
70
  children: [
100
- /* @__PURE__ */ r(
71
+ /* @__PURE__ */ t(
101
72
  "path",
102
73
  {
103
74
  d: "M5 9C5 5.70017 5 4.05025 6.02513 3.02513C7.05025 2 8.70017 2 12 2C15.2998 2 16.9497 2 17.9749 3.02513C19 4.05025 19 5.70017 19 9V15C19 18.2998 19 19.9497 17.9749 20.9749C16.9497 22 15.2998 22 12 22C8.70017 22 7.05025 22 6.02513 20.9749C5 19.9497 5 18.2998 5 15V9Z",
@@ -106,7 +77,7 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
106
77
  strokeLinecap: "round"
107
78
  }
108
79
  ),
109
- /* @__PURE__ */ r(
80
+ /* @__PURE__ */ t(
110
81
  "path",
111
82
  {
112
83
  d: "M11 19H13",
@@ -116,7 +87,7 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
116
87
  strokeLinejoin: "round"
117
88
  }
118
89
  ),
119
- /* @__PURE__ */ r(
90
+ /* @__PURE__ */ t(
120
91
  "path",
121
92
  {
122
93
  d: "M9 2L9.089 2.53402C9.28188 3.69129 9.37832 4.26993 9.77519 4.62204C10.1892 4.98934 10.7761 5 12 5C13.2239 5 13.8108 4.98934 14.2248 4.62204C14.6217 4.26993 14.7181 3.69129 14.911 2.53402L15 2",
@@ -127,17 +98,17 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
127
98
  )
128
99
  ]
129
100
  }
130
- ), F = ({ className: e }) => /* @__PURE__ */ r(
101
+ ), ve = ({ className: e }) => /* @__PURE__ */ t(
131
102
  "svg",
132
103
  {
133
- className: M(e),
104
+ className: L(e),
134
105
  width: "14",
135
106
  height: "14",
136
107
  viewBox: "0 0 14 14",
137
108
  fill: "none",
138
109
  xmlns: "http://www.w3.org/2000/svg",
139
110
  "aria-hidden": "true",
140
- children: /* @__PURE__ */ r(
111
+ children: /* @__PURE__ */ t(
141
112
  "path",
142
113
  {
143
114
  d: "M6.94994 5.53594L12.1929 0.292938C12.5834 -0.0975275 13.2165 -0.0975279 13.6069 0.292938C13.9974 0.683403 13.9974 1.31647 13.6069 1.70694L8.36394 6.94994L13.6069 12.1929C13.9974 12.5834 13.9974 13.2165 13.6069 13.6069C13.2165 13.9974 12.5834 13.9974 12.1929 13.6069L6.94994 8.36394L1.70694 13.6069C1.31647 13.9974 0.683403 13.9974 0.292938 13.6069C-0.0975279 13.2165 -0.0975277 12.5834 0.292938 12.1929L5.53594 6.94994L0.292938 1.70694C-0.0975279 1.31647 -0.0975279 0.683403 0.292938 0.292938C0.683403 -0.0975279 1.31647 -0.0975277 1.70694 0.292938L6.94994 5.53594Z",
@@ -145,17 +116,17 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
145
116
  }
146
117
  )
147
118
  }
148
- ), ee = ({ className: e }) => /* @__PURE__ */ r(
119
+ ), ke = ({ className: e }) => /* @__PURE__ */ t(
149
120
  "svg",
150
121
  {
151
- className: M(e),
122
+ className: L(e),
152
123
  width: "22",
153
124
  height: "22",
154
125
  viewBox: "0 0 16 16",
155
126
  fill: "none",
156
127
  xmlns: "http://www.w3.org/2000/svg",
157
128
  "aria-hidden": "true",
158
- children: /* @__PURE__ */ r(
129
+ children: /* @__PURE__ */ t(
159
130
  "path",
160
131
  {
161
132
  d: "M5.3335 11.45V4.54997C5.3335 4.36108 5.40016 4.20275 5.5335 4.07497C5.66683 3.94719 5.82238 3.8833 6.00016 3.8833C6.05572 3.8833 6.11405 3.89163 6.17516 3.9083C6.23627 3.92497 6.29461 3.94997 6.35016 3.9833L11.7835 7.4333C11.8835 7.49997 11.9585 7.5833 12.0085 7.6833C12.0585 7.7833 12.0835 7.88886 12.0835 7.99997C12.0835 8.11108 12.0585 8.21663 12.0085 8.31663C11.9585 8.41663 11.8835 8.49997 11.7835 8.56663L6.35016 12.0166C6.29461 12.05 6.23627 12.075 6.17516 12.0916C6.11405 12.1083 6.05572 12.1166 6.00016 12.1166C5.82238 12.1166 5.66683 12.0527 5.5335 11.925C5.40016 11.7972 5.3335 11.6389 5.3335 11.45Z",
@@ -163,224 +134,1147 @@ const U = "gvp-icon", M = (e) => e ? `${U} ${e}` : U, K = ({ className: e }) =>
163
134
  }
164
135
  )
165
136
  }
137
+ ), we = ({ className: e }) => /* @__PURE__ */ v(
138
+ "svg",
139
+ {
140
+ className: L(e),
141
+ width: "16",
142
+ height: "16",
143
+ viewBox: "0 0 24 24",
144
+ fill: "none",
145
+ xmlns: "http://www.w3.org/2000/svg",
146
+ "aria-hidden": "true",
147
+ children: [
148
+ /* @__PURE__ */ t(
149
+ "path",
150
+ {
151
+ d: "M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",
152
+ stroke: "currentColor",
153
+ strokeWidth: "1.5",
154
+ strokeLinejoin: "round"
155
+ }
156
+ ),
157
+ /* @__PURE__ */ t(
158
+ "path",
159
+ {
160
+ d: "M16.5 8C17.5 9 18 10.5 18 12C18 13.5 17.5 15 16.5 16M19 5.5C20.5 7 21.5 9.5 21.5 12C21.5 14.5 20.5 17 19 18.5",
161
+ stroke: "currentColor",
162
+ strokeWidth: "1.5",
163
+ strokeLinecap: "round"
164
+ }
165
+ )
166
+ ]
167
+ }
168
+ ), be = ({ className: e }) => /* @__PURE__ */ t(
169
+ "svg",
170
+ {
171
+ className: L(e),
172
+ width: "16",
173
+ height: "16",
174
+ viewBox: "0 0 24 24",
175
+ fill: "none",
176
+ xmlns: "http://www.w3.org/2000/svg",
177
+ "aria-hidden": "true",
178
+ children: /* @__PURE__ */ t(
179
+ "path",
180
+ {
181
+ d: "M7 5.5V18.5C7 19.2659 7.84856 19.7261 8.4899 19.3071L19.0801 12.4014C19.6644 12.0204 19.6644 11.9796 19.0801 11.5986L8.4899 4.69288C7.84856 4.27388 7 4.73408 7 5.5Z",
182
+ fill: "currentColor"
183
+ }
184
+ )
185
+ }
186
+ ), Ce = ({ className: e }) => /* @__PURE__ */ v(
187
+ "svg",
188
+ {
189
+ className: L(e),
190
+ width: "16",
191
+ height: "16",
192
+ viewBox: "0 0 24 24",
193
+ fill: "none",
194
+ xmlns: "http://www.w3.org/2000/svg",
195
+ "aria-hidden": "true",
196
+ children: [
197
+ /* @__PURE__ */ t("rect", { x: "6", y: "5", width: "4", height: "14", rx: "1", fill: "currentColor" }),
198
+ /* @__PURE__ */ t("rect", { x: "14", y: "5", width: "4", height: "14", rx: "1", fill: "currentColor" })
199
+ ]
200
+ }
201
+ ), Le = ({ className: e }) => /* @__PURE__ */ v(
202
+ "svg",
203
+ {
204
+ className: L(e),
205
+ width: "18",
206
+ height: "18",
207
+ viewBox: "0 0 24 24",
208
+ fill: "none",
209
+ xmlns: "http://www.w3.org/2000/svg",
210
+ "aria-hidden": "true",
211
+ children: [
212
+ /* @__PURE__ */ t(
213
+ "path",
214
+ {
215
+ d: "M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",
216
+ stroke: "currentColor",
217
+ strokeWidth: "1.5",
218
+ strokeLinejoin: "round"
219
+ }
220
+ ),
221
+ /* @__PURE__ */ t(
222
+ "path",
223
+ {
224
+ d: "M16.5 8C17.5 9 18 10.5 18 12C18 13.5 17.5 15 16.5 16M19 5.5C20.5 7 21.5 9.5 21.5 12C21.5 14.5 20.5 17 19 18.5",
225
+ stroke: "currentColor",
226
+ strokeWidth: "1.5",
227
+ strokeLinecap: "round"
228
+ }
229
+ )
230
+ ]
231
+ }
232
+ ), Ee = ({ className: e }) => /* @__PURE__ */ v(
233
+ "svg",
234
+ {
235
+ className: L(e),
236
+ width: "18",
237
+ height: "18",
238
+ viewBox: "0 0 24 24",
239
+ fill: "none",
240
+ xmlns: "http://www.w3.org/2000/svg",
241
+ "aria-hidden": "true",
242
+ children: [
243
+ /* @__PURE__ */ t(
244
+ "path",
245
+ {
246
+ d: "M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",
247
+ stroke: "currentColor",
248
+ strokeWidth: "1.5",
249
+ strokeLinejoin: "round"
250
+ }
251
+ ),
252
+ /* @__PURE__ */ t(
253
+ "path",
254
+ {
255
+ d: "M16.5 8C17.5 9 18 10.5 18 12C18 13.5 17.5 15 16.5 16",
256
+ stroke: "currentColor",
257
+ strokeWidth: "1.5",
258
+ strokeLinecap: "round"
259
+ }
260
+ )
261
+ ]
262
+ }
263
+ ), ye = ({ className: e }) => /* @__PURE__ */ v(
264
+ "svg",
265
+ {
266
+ className: L(e),
267
+ width: "18",
268
+ height: "18",
269
+ viewBox: "0 0 24 24",
270
+ fill: "none",
271
+ xmlns: "http://www.w3.org/2000/svg",
272
+ "aria-hidden": "true",
273
+ children: [
274
+ /* @__PURE__ */ t(
275
+ "path",
276
+ {
277
+ d: "M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",
278
+ stroke: "currentColor",
279
+ strokeWidth: "1.5",
280
+ strokeLinejoin: "round"
281
+ }
282
+ ),
283
+ /* @__PURE__ */ t(
284
+ "path",
285
+ {
286
+ d: "M16 9L22 15M22 9L16 15",
287
+ stroke: "currentColor",
288
+ strokeWidth: "1.5",
289
+ strokeLinecap: "round"
290
+ }
291
+ )
292
+ ]
293
+ }
294
+ ), xe = ({ className: e }) => /* @__PURE__ */ t(
295
+ "svg",
296
+ {
297
+ className: L(e),
298
+ width: "18",
299
+ height: "18",
300
+ viewBox: "0 0 24 24",
301
+ fill: "none",
302
+ xmlns: "http://www.w3.org/2000/svg",
303
+ "aria-hidden": "true",
304
+ children: /* @__PURE__ */ t(
305
+ "path",
306
+ {
307
+ d: "M4 9V4H9M15 4H20V9M20 15V20H15M9 20H4V15",
308
+ stroke: "currentColor",
309
+ strokeWidth: "1.75",
310
+ strokeLinecap: "round",
311
+ strokeLinejoin: "round"
312
+ }
313
+ )
314
+ }
315
+ ), Ne = ({ className: e }) => /* @__PURE__ */ t(
316
+ "svg",
317
+ {
318
+ className: L(e),
319
+ width: "18",
320
+ height: "18",
321
+ viewBox: "0 0 24 24",
322
+ fill: "none",
323
+ xmlns: "http://www.w3.org/2000/svg",
324
+ "aria-hidden": "true",
325
+ children: /* @__PURE__ */ t(
326
+ "path",
327
+ {
328
+ d: "M9 4V9H4M15 9V4H20M15 20V15H20M9 15H4V20",
329
+ stroke: "currentColor",
330
+ strokeWidth: "1.75",
331
+ strokeLinecap: "round",
332
+ strokeLinejoin: "round"
333
+ }
334
+ )
335
+ }
336
+ ), Me = ({ className: e }) => /* @__PURE__ */ v(
337
+ "svg",
338
+ {
339
+ className: L(e),
340
+ width: "18",
341
+ height: "18",
342
+ viewBox: "0 0 24 24",
343
+ fill: "none",
344
+ xmlns: "http://www.w3.org/2000/svg",
345
+ "aria-hidden": "true",
346
+ children: [
347
+ /* @__PURE__ */ t("rect", { x: "2", y: "4", width: "20", height: "16", rx: "2", stroke: "currentColor", strokeWidth: "1.5" }),
348
+ /* @__PURE__ */ t("rect", { x: "12", y: "12", width: "8", height: "5", rx: "1", fill: "currentColor" })
349
+ ]
350
+ }
351
+ ), Pe = ({ className: e }) => /* @__PURE__ */ v(
352
+ "svg",
353
+ {
354
+ className: L(e),
355
+ width: "18",
356
+ height: "18",
357
+ viewBox: "0 0 24 24",
358
+ fill: "none",
359
+ xmlns: "http://www.w3.org/2000/svg",
360
+ "aria-hidden": "true",
361
+ children: [
362
+ /* @__PURE__ */ t("rect", { x: "2", y: "5", width: "20", height: "14", rx: "3", stroke: "currentColor", strokeWidth: "1.5" }),
363
+ /* @__PURE__ */ t("path", { d: "M7 12H11M13 12H17M7 15H9M11 15H13M15 15H17", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
364
+ ]
365
+ }
366
+ ), Te = ({ className: e }) => /* @__PURE__ */ v(
367
+ "svg",
368
+ {
369
+ className: L(e),
370
+ width: "16",
371
+ height: "16",
372
+ viewBox: "0 0 24 24",
373
+ fill: "none",
374
+ xmlns: "http://www.w3.org/2000/svg",
375
+ "aria-hidden": "true",
376
+ children: [
377
+ /* @__PURE__ */ t(
378
+ "path",
379
+ {
380
+ d: "M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2Z",
381
+ stroke: "currentColor",
382
+ strokeWidth: "1.5"
383
+ }
384
+ ),
385
+ /* @__PURE__ */ t(
386
+ "path",
387
+ {
388
+ d: "M12 8V12L14.5 14.5",
389
+ stroke: "currentColor",
390
+ strokeWidth: "1.5",
391
+ strokeLinecap: "round",
392
+ strokeLinejoin: "round"
393
+ }
394
+ )
395
+ ]
396
+ }
397
+ ), Ie = ({ className: e }) => /* @__PURE__ */ t(
398
+ "svg",
399
+ {
400
+ className: L(e),
401
+ width: "12",
402
+ height: "12",
403
+ viewBox: "0 0 24 24",
404
+ fill: "none",
405
+ xmlns: "http://www.w3.org/2000/svg",
406
+ "aria-hidden": "true",
407
+ children: /* @__PURE__ */ t(
408
+ "path",
409
+ {
410
+ d: "M6 9L12 15L18 9",
411
+ stroke: "currentColor",
412
+ strokeWidth: "2",
413
+ strokeLinecap: "round",
414
+ strokeLinejoin: "round"
415
+ }
416
+ )
417
+ }
418
+ );
419
+ function J(e) {
420
+ if (!Number.isFinite(e) || e < 0) return "--:--";
421
+ const n = Math.floor(e), s = Math.floor(n / 3600), r = Math.floor(n % 3600 / 60), u = (n % 60).toString().padStart(2, "0");
422
+ if (s > 0) {
423
+ const c = r.toString().padStart(2, "0");
424
+ return `${s}:${c}:${u}`;
425
+ }
426
+ return `${r}:${u}`;
427
+ }
428
+ const X = (() => {
429
+ if (typeof navigator > "u") return !1;
430
+ const e = navigator.userAgent;
431
+ return /iPad|iPhone|iPod/.test(e) || e.includes("Mac") && navigator.maxTouchPoints > 1;
432
+ })(), q = typeof navigator > "u" ? !1 : /iPhone|iPod/.test(navigator.userAgent), Se = 3e3, B = {
433
+ isSupported() {
434
+ return typeof document > "u" ? !1 : !!(document.fullscreenEnabled || document.webkitFullscreenEnabled);
435
+ },
436
+ element() {
437
+ return typeof document > "u" ? null : document.fullscreenElement ?? document.webkitFullscreenElement ?? null;
438
+ },
439
+ request(e) {
440
+ const n = e.requestFullscreen ?? e.webkitRequestFullscreen;
441
+ return n ? n.call(e) : Promise.reject(new Error("Fullscreen not supported"));
442
+ },
443
+ exit() {
444
+ const e = document.exitFullscreen ?? document.webkitExitFullscreen;
445
+ return e ? e.call(document) : Promise.reject(new Error("Fullscreen not supported"));
446
+ },
447
+ onChange(e) {
448
+ return document.addEventListener("fullscreenchange", e), document.addEventListener("webkitfullscreenchange", e), () => {
449
+ document.removeEventListener("fullscreenchange", e), document.removeEventListener("webkitfullscreenchange", e);
450
+ };
451
+ }
452
+ }, He = ({
453
+ video: e,
454
+ isPlaying: n,
455
+ container: s,
456
+ onTogglePlay: r
457
+ }) => {
458
+ const [i, u] = k(!0), c = V(null), a = S(() => {
459
+ c.current !== null && (clearTimeout(c.current), c.current = null);
460
+ }, []), l = S(() => {
461
+ a(), n && (c.current = setTimeout(() => u(!1), Se));
462
+ }, [a, n]), m = S(() => {
463
+ u(!0), l();
464
+ }, [l]);
465
+ return x(() => {
466
+ if (!n) {
467
+ a(), u(!0);
468
+ return;
469
+ }
470
+ return l(), a;
471
+ }, [n, l, a]), x(() => {
472
+ if (!s) return;
473
+ const f = () => m();
474
+ return s.addEventListener("mousemove", f), s.addEventListener("touchstart", f), s.addEventListener("focusin", f), () => {
475
+ s.removeEventListener("mousemove", f), s.removeEventListener("touchstart", f), s.removeEventListener("focusin", f);
476
+ };
477
+ }, [s, m]), x(() => {
478
+ if (!s || !e) return;
479
+ const f = (o) => {
480
+ if (!(!s.contains(document.activeElement) || o.target.tagName === "INPUT" && o.key !== " "))
481
+ switch (o.key) {
482
+ case " ":
483
+ case "k":
484
+ o.preventDefault(), r(), m();
485
+ break;
486
+ case "ArrowLeft":
487
+ o.preventDefault(), e.currentTime = Math.max(0, e.currentTime - 5), m();
488
+ break;
489
+ case "ArrowRight":
490
+ o.preventDefault(), e.currentTime = Math.min(e.duration || 0, e.currentTime + 5), m();
491
+ break;
492
+ case "ArrowUp":
493
+ o.preventDefault(), e.volume = Math.min(1, e.volume + 0.1), e.muted && (e.muted = !1), m();
494
+ break;
495
+ case "ArrowDown":
496
+ o.preventDefault(), e.volume = Math.max(0, e.volume - 0.1), m();
497
+ break;
498
+ case "m":
499
+ e.muted = !e.muted, m();
500
+ break;
501
+ case "f":
502
+ B.element() === s ? B.exit().catch(() => {
503
+ }) : B.request(s).catch(() => {
504
+ }), m();
505
+ break;
506
+ case "p":
507
+ document.pictureInPictureElement ? document.exitPictureInPicture().catch(() => {
508
+ }) : document.pictureInPictureEnabled && e.requestPictureInPicture().catch(() => {
509
+ }), m();
510
+ break;
511
+ }
512
+ };
513
+ return document.addEventListener("keydown", f), () => document.removeEventListener("keydown", f);
514
+ }, [s, e, r, m]), /* @__PURE__ */ t(
515
+ "div",
516
+ {
517
+ role: "toolbar",
518
+ "aria-label": "Video controls",
519
+ className: H("gvp-controls", !i && "is-hidden"),
520
+ onMouseEnter: a,
521
+ onMouseLeave: l,
522
+ children: /* @__PURE__ */ v("div", { className: "gvp-controls-row", children: [
523
+ /* @__PURE__ */ t(Ve, { isPlaying: n, onToggle: r }),
524
+ /* @__PURE__ */ t(Be, { video: e }),
525
+ /* @__PURE__ */ t(De, { video: e }),
526
+ /* @__PURE__ */ t(Re, { video: e }),
527
+ /* @__PURE__ */ t(We, { video: e }),
528
+ /* @__PURE__ */ t(Ae, { video: e }),
529
+ /* @__PURE__ */ t(je, { video: e }),
530
+ /* @__PURE__ */ t(Ze, { container: s, video: e })
531
+ ] })
532
+ }
533
+ );
534
+ }, Ve = ({
535
+ isPlaying: e,
536
+ onToggle: n
537
+ }) => /* @__PURE__ */ t(
538
+ "button",
539
+ {
540
+ type: "button",
541
+ className: "gvp-ctrl-btn",
542
+ "aria-label": e ? "Pause" : "Play",
543
+ "aria-pressed": e,
544
+ onClick: n,
545
+ children: e ? /* @__PURE__ */ t(Ce, {}) : /* @__PURE__ */ t(be, {})
546
+ }
547
+ ), Be = ({ video: e }) => {
548
+ const [n, s] = k(0), [r, i] = k(0), [u, c] = k(0);
549
+ x(() => {
550
+ if (!e) return;
551
+ const o = () => s(e.currentTime), p = () => i(Number.isFinite(e.duration) ? e.duration : 0), g = () => {
552
+ const d = e.buffered;
553
+ if (!d || d.length === 0) {
554
+ c(0);
555
+ return;
556
+ }
557
+ let w = d.end(d.length - 1);
558
+ for (let C = 0; C < d.length; C++)
559
+ if (d.start(C) <= e.currentTime && e.currentTime <= d.end(C)) {
560
+ w = d.end(C);
561
+ break;
562
+ }
563
+ c(w);
564
+ };
565
+ return o(), p(), g(), e.addEventListener("timeupdate", o), e.addEventListener("durationchange", p), e.addEventListener("loadedmetadata", p), e.addEventListener("progress", g), e.addEventListener("timeupdate", g), () => {
566
+ e.removeEventListener("timeupdate", o), e.removeEventListener("durationchange", p), e.removeEventListener("loadedmetadata", p), e.removeEventListener("progress", g), e.removeEventListener("timeupdate", g);
567
+ };
568
+ }, [e]);
569
+ const a = r > 0, l = a ? n / r * 100 : 0, m = a ? u / r * 100 : 0, f = (o) => {
570
+ if (!e || !a) return;
571
+ const p = Number(o.target.value) / 100 * r;
572
+ e.currentTime = p, s(p);
573
+ };
574
+ return /* @__PURE__ */ v("div", { className: "gvp-seek", children: [
575
+ /* @__PURE__ */ v("div", { className: "gvp-seek-track", children: [
576
+ /* @__PURE__ */ t(
577
+ "div",
578
+ {
579
+ className: "gvp-seek-buffered",
580
+ style: { width: `${m}%` }
581
+ }
582
+ ),
583
+ /* @__PURE__ */ t(
584
+ "div",
585
+ {
586
+ className: "gvp-seek-progress",
587
+ style: { width: `${l}%` }
588
+ }
589
+ )
590
+ ] }),
591
+ /* @__PURE__ */ t(
592
+ "input",
593
+ {
594
+ type: "range",
595
+ className: "gvp-seek-input",
596
+ min: 0,
597
+ max: 100,
598
+ step: 0.1,
599
+ value: l,
600
+ onChange: f,
601
+ disabled: !a,
602
+ "aria-label": "Seek",
603
+ "aria-valuemin": 0,
604
+ "aria-valuemax": Math.floor(r),
605
+ "aria-valuenow": Math.floor(n)
606
+ }
607
+ )
608
+ ] });
609
+ }, De = ({ video: e }) => {
610
+ const [n, s] = k(0), [r, i] = k(0);
611
+ return x(() => {
612
+ if (!e) return;
613
+ const u = () => s(e.currentTime), c = () => i(Number.isFinite(e.duration) ? e.duration : 0);
614
+ return u(), c(), e.addEventListener("timeupdate", u), e.addEventListener("durationchange", c), e.addEventListener("loadedmetadata", c), () => {
615
+ e.removeEventListener("timeupdate", u), e.removeEventListener("durationchange", c), e.removeEventListener("loadedmetadata", c);
616
+ };
617
+ }, [e]), /* @__PURE__ */ v("span", { className: "gvp-time", "aria-live": "off", children: [
618
+ J(n),
619
+ " / ",
620
+ J(r)
621
+ ] });
622
+ }, Ae = ({ video: e }) => {
623
+ const [n, s] = k(1), [r, i] = k(!1);
624
+ x(() => {
625
+ if (!e) return;
626
+ const m = () => {
627
+ s(e.volume), i(e.muted);
628
+ };
629
+ return m(), e.addEventListener("volumechange", m), () => e.removeEventListener("volumechange", m);
630
+ }, [e]);
631
+ const u = () => {
632
+ e && (e.muted = !e.muted);
633
+ }, c = (m) => {
634
+ if (!e) return;
635
+ const f = Number(m.target.value) / 100;
636
+ e.volume = f, f > 0 && e.muted && (e.muted = !1);
637
+ };
638
+ let a = Le;
639
+ r || n === 0 ? a = ye : n < 0.5 && (a = Ee);
640
+ const l = r ? 0 : Math.round(n * 100);
641
+ return /* @__PURE__ */ v("div", { className: H("gvp-volume", !X && "is-expandable"), children: [
642
+ /* @__PURE__ */ t(
643
+ "button",
644
+ {
645
+ type: "button",
646
+ className: "gvp-ctrl-btn",
647
+ "aria-label": r ? "Unmute" : "Mute",
648
+ "aria-pressed": r,
649
+ onClick: u,
650
+ children: /* @__PURE__ */ t(a, {})
651
+ }
652
+ ),
653
+ !X && /* @__PURE__ */ v("div", { className: "gvp-volume-slider-wrap", children: [
654
+ /* @__PURE__ */ t("div", { className: "gvp-volume-track", children: /* @__PURE__ */ t(
655
+ "div",
656
+ {
657
+ className: "gvp-volume-fill",
658
+ style: { width: `${l}%` }
659
+ }
660
+ ) }),
661
+ /* @__PURE__ */ t(
662
+ "input",
663
+ {
664
+ type: "range",
665
+ className: "gvp-volume-input",
666
+ min: 0,
667
+ max: 100,
668
+ step: 1,
669
+ value: l,
670
+ onChange: c,
671
+ "aria-label": "Volume",
672
+ "aria-valuemin": 0,
673
+ "aria-valuemax": 100,
674
+ "aria-valuenow": l
675
+ }
676
+ )
677
+ ] })
678
+ ] });
679
+ }, $e = [0.5, 0.75, 1, 1.25, 1.5, 2], Re = ({ video: e }) => {
680
+ const [n, s] = k(1), [r, i] = k(!1), u = V(null);
681
+ x(() => {
682
+ if (!e) return;
683
+ const l = () => s(e.playbackRate);
684
+ return l(), e.addEventListener("ratechange", l), () => e.removeEventListener("ratechange", l);
685
+ }, [e]), x(() => {
686
+ if (!r) return;
687
+ const l = (f) => {
688
+ u.current && !u.current.contains(f.target) && i(!1);
689
+ }, m = (f) => {
690
+ f.key === "Escape" && i(!1);
691
+ };
692
+ return document.addEventListener("mousedown", l), document.addEventListener("keydown", m), () => {
693
+ document.removeEventListener("mousedown", l), document.removeEventListener("keydown", m);
694
+ };
695
+ }, [r]);
696
+ const c = (l) => {
697
+ e && (e.playbackRate = l), s(l), i(!1);
698
+ }, a = n === 1 ? "1×" : `${n}×`;
699
+ return /* @__PURE__ */ v("div", { className: "gvp-speed", ref: u, children: [
700
+ /* @__PURE__ */ v(
701
+ "button",
702
+ {
703
+ type: "button",
704
+ className: "gvp-ctrl-btn gvp-speed-btn",
705
+ "aria-haspopup": "listbox",
706
+ "aria-expanded": r,
707
+ "aria-label": `Playback speed: ${a}`,
708
+ onClick: () => i((l) => !l),
709
+ children: [
710
+ /* @__PURE__ */ t(Te, {}),
711
+ /* @__PURE__ */ t("span", { className: "gvp-speed-label", children: a })
712
+ ]
713
+ }
714
+ ),
715
+ r && // NOSONAR: typescript:S6819
716
+ /* @__PURE__ */ t("ul", { className: "gvp-speed-menu", role: "listbox", "aria-label": "Playback speed", children: $e.map((l) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
717
+ "button",
718
+ {
719
+ type: "button",
720
+ role: "option",
721
+ "aria-selected": l === n,
722
+ className: H("gvp-speed-menu-item", l === n && "is-active"),
723
+ onClick: () => c(l),
724
+ children: l === 1 ? "Normal" : `${l}×`
725
+ }
726
+ ) }, l)) })
727
+ ] });
728
+ }, We = ({ video: e }) => {
729
+ const [n, s] = k([]), [r, i] = k(-1), [u, c] = k(!1), a = V(null), l = S((o) => {
730
+ const p = [];
731
+ for (let d = 0; d < o.length; d++) {
732
+ const w = o[d];
733
+ (w.kind === "subtitles" || w.kind === "captions") && p.push({ index: d, label: w.label || w.language || `Track ${d + 1}`, language: w.language });
734
+ }
735
+ s(p);
736
+ let g = -1;
737
+ for (let d = 0; d < o.length; d++)
738
+ if (o[d].mode === "showing") {
739
+ g = d;
740
+ break;
741
+ }
742
+ i(g);
743
+ }, []);
744
+ x(() => {
745
+ if (!e) {
746
+ s([]), i(-1);
747
+ return;
748
+ }
749
+ const o = e.textTracks;
750
+ l(o);
751
+ const p = () => l(o);
752
+ return o.addEventListener("addtrack", p), o.addEventListener("removetrack", p), o.addEventListener("change", p), () => {
753
+ o.removeEventListener("addtrack", p), o.removeEventListener("removetrack", p), o.removeEventListener("change", p);
754
+ };
755
+ }, [e, l]), x(() => {
756
+ if (!u) return;
757
+ const o = (g) => {
758
+ a.current && !a.current.contains(g.target) && c(!1);
759
+ }, p = (g) => {
760
+ g.key === "Escape" && c(!1);
761
+ };
762
+ return document.addEventListener("mousedown", o), document.addEventListener("keydown", p), () => {
763
+ document.removeEventListener("mousedown", o), document.removeEventListener("keydown", p);
764
+ };
765
+ }, [u]);
766
+ const m = (o) => {
767
+ if (!e) return;
768
+ const p = e.textTracks;
769
+ for (let g = 0; g < p.length; g++)
770
+ p[g].mode = g === o ? "showing" : "hidden";
771
+ i(o), c(!1);
772
+ }, f = () => {
773
+ if (!e) return;
774
+ const o = e.textTracks;
775
+ for (let p = 0; p < o.length; p++) o[p].mode = "hidden";
776
+ i(-1), c(!1);
777
+ };
778
+ return n.length === 0 ? null : /* @__PURE__ */ v("div", { className: "gvp-captions", ref: a, children: [
779
+ /* @__PURE__ */ t(
780
+ "button",
781
+ {
782
+ type: "button",
783
+ className: H("gvp-ctrl-btn", r >= 0 && "is-active"),
784
+ "aria-haspopup": "listbox",
785
+ "aria-expanded": u,
786
+ "aria-label": "Captions",
787
+ "aria-pressed": r >= 0,
788
+ onClick: () => c((o) => !o),
789
+ children: /* @__PURE__ */ t(Pe, {})
790
+ }
791
+ ),
792
+ u && // NOSONAR: typescript:S6819
793
+ /* @__PURE__ */ v("ul", { className: "gvp-captions-menu", role: "listbox", "aria-label": "Captions", children: [
794
+ /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
795
+ "button",
796
+ {
797
+ type: "button",
798
+ role: "option",
799
+ "aria-selected": r === -1,
800
+ className: H("gvp-captions-menu-item", r === -1 && "is-active"),
801
+ onClick: f,
802
+ children: "Off"
803
+ }
804
+ ) }),
805
+ n.map((o) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
806
+ "button",
807
+ {
808
+ type: "button",
809
+ role: "option",
810
+ "aria-selected": o.index === r,
811
+ className: H("gvp-captions-menu-item", o.index === r && "is-active"),
812
+ onClick: () => m(o.index),
813
+ children: o.label
814
+ }
815
+ ) }, o.index))
816
+ ] })
817
+ ] });
818
+ }, je = ({ video: e }) => {
819
+ const [n, s] = k(!1);
820
+ if (x(() => {
821
+ if (!e) return;
822
+ const i = () => s(!0), u = () => s(!1);
823
+ return e.addEventListener("enterpictureinpicture", i), e.addEventListener("leavepictureinpicture", u), () => {
824
+ e.removeEventListener("enterpictureinpicture", i), e.removeEventListener("leavepictureinpicture", u);
825
+ };
826
+ }, [e]), !document.pictureInPictureEnabled) return null;
827
+ const r = () => {
828
+ document.pictureInPictureElement ? document.exitPictureInPicture().catch(() => {
829
+ }) : e == null || e.requestPictureInPicture().catch(() => {
830
+ });
831
+ };
832
+ return /* @__PURE__ */ t(
833
+ "button",
834
+ {
835
+ type: "button",
836
+ className: H("gvp-ctrl-btn", n && "is-active"),
837
+ "aria-label": n ? "Exit picture-in-picture" : "Picture-in-picture",
838
+ "aria-pressed": n,
839
+ onClick: r,
840
+ children: /* @__PURE__ */ t(Me, {})
841
+ }
842
+ );
843
+ }, Ze = ({ container: e, video: n }) => {
844
+ const [s, r] = k(!1);
845
+ return x(() => {
846
+ if (q) return;
847
+ const l = () => r(B.element() === e);
848
+ return l(), B.onChange(l);
849
+ }, [e]), B.isSupported() || q && n !== null && typeof n.webkitEnterFullscreen == "function" ? /* @__PURE__ */ t(
850
+ "button",
851
+ {
852
+ type: "button",
853
+ className: "gvp-ctrl-btn",
854
+ "aria-label": s ? "Exit fullscreen" : "Enter fullscreen",
855
+ "aria-pressed": s,
856
+ onClick: () => {
857
+ var l;
858
+ if (q) {
859
+ (l = n == null ? void 0 : n.webkitEnterFullscreen) == null || l.call(n);
860
+ return;
861
+ }
862
+ s ? B.exit().catch(() => {
863
+ }) : e && B.request(e).catch(() => {
864
+ });
865
+ },
866
+ children: /* @__PURE__ */ t(s ? Ne : xe, {})
867
+ }
868
+ ) : null;
869
+ };
870
+ function G(e, n, s) {
871
+ const r = e == null ? void 0 : e.trim();
872
+ if (r) return r;
873
+ if (n) {
874
+ try {
875
+ const u = new Intl.DisplayNames(void 0, { type: "language" }).of(n);
876
+ if (u && u !== n) return u;
877
+ } catch {
878
+ }
879
+ return n;
880
+ }
881
+ return `Audio ${s + 1}`;
882
+ }
883
+ const ee = pe.forwardRef(
884
+ ({
885
+ src: e,
886
+ hlsConfig: n,
887
+ isHls: s,
888
+ autoPlay: r,
889
+ children: i,
890
+ onAudioTracks: u,
891
+ audioTrackIndex: c,
892
+ ...a
893
+ }, l) => {
894
+ const m = V(null), f = V(null), o = V(u);
895
+ o.current = u, me(l, () => m.current);
896
+ const p = globalThis.window !== void 0 && $.isSupported(), g = !!s || p && typeof e == "string" && e.endsWith(".m3u8");
897
+ return x(() => {
898
+ var P, R, D;
899
+ if (!e) return;
900
+ const d = m.current;
901
+ if (!d) return;
902
+ const w = (h) => {
903
+ var E;
904
+ (E = o.current) == null || E.call(o, h);
905
+ }, C = () => {
906
+ r && d.play().catch(() => {
907
+ });
908
+ };
909
+ for (f.current && (f.current.destroy(), f.current = null), d.pause(), d.removeAttribute("src"); d.firstChild; ) d.firstChild.remove();
910
+ w([]);
911
+ let N;
912
+ if (g) {
913
+ const h = new $(n);
914
+ f.current = h;
915
+ const E = () => {
916
+ const M = h.audioTracks.map((b, T) => ({
917
+ index: T,
918
+ label: G(b.name, b.lang, T),
919
+ lang: b.lang || void 0
920
+ }));
921
+ w(M);
922
+ };
923
+ h.on($.Events.MANIFEST_PARSED, C), h.on($.Events.AUDIO_TRACKS_UPDATED, E), h.on($.Events.AUDIO_TRACK_SWITCHED, E), h.on($.Events.ERROR, (M, b) => {
924
+ b.fatal && (h.destroy(), f.current = null);
925
+ }), h.attachMedia(d), h.loadSource(e);
926
+ } else {
927
+ d.src = e, d.load(), d.addEventListener("loadedmetadata", C, { once: !0 });
928
+ const h = d.audioTracks;
929
+ if (h) {
930
+ const E = () => {
931
+ const M = [];
932
+ for (let b = 0; b < h.length; b++) {
933
+ const T = h[b];
934
+ M.push({
935
+ index: b,
936
+ label: G(T.label, T.language, b),
937
+ lang: T.language || void 0
938
+ });
939
+ }
940
+ w(M);
941
+ };
942
+ (P = h.addEventListener) == null || P.call(h, "addtrack", E), (R = h.addEventListener) == null || R.call(h, "removetrack", E), (D = h.addEventListener) == null || D.call(h, "change", E), h.length > 0 && E(), N = () => {
943
+ var M, b, T;
944
+ (M = h.removeEventListener) == null || M.call(h, "addtrack", E), (b = h.removeEventListener) == null || b.call(h, "removetrack", E), (T = h.removeEventListener) == null || T.call(h, "change", E);
945
+ };
946
+ }
947
+ }
948
+ return () => {
949
+ for (d.removeEventListener("loadedmetadata", C), N == null || N(), f.current && (f.current.destroy(), f.current = null), d.pause(), d.removeAttribute("src"); d.firstChild; ) d.firstChild.remove();
950
+ d.load(), w([]);
951
+ };
952
+ }, [e, g, n, r]), x(() => {
953
+ var C;
954
+ if (c == null || c < 0) return;
955
+ const d = f.current;
956
+ if (d) {
957
+ d.audioTrack !== c && (d.audioTrack = c);
958
+ return;
959
+ }
960
+ const w = (C = m.current) == null ? void 0 : C.audioTracks;
961
+ if (w)
962
+ for (let N = 0; N < w.length; N++)
963
+ w[N].enabled = N === c;
964
+ }, [c]), // Captions are the consumer's responsibility — pass <track> elements as children.
965
+ // NOSONAR: typescript:S4084
966
+ /* @__PURE__ */ t("video", { ref: m, ...a, children: i });
967
+ }
166
968
  );
167
- function te(e) {
969
+ ee.displayName = "HLSPlayer";
970
+ function Ue(e) {
168
971
  if (!e) return null;
169
972
  if (/^[A-Za-z0-9_-]{11}$/.test(e)) return e;
170
- let o;
973
+ let n;
171
974
  try {
172
- o = new URL(e);
975
+ n = new URL(e);
173
976
  } catch {
174
977
  return null;
175
978
  }
176
- const n = o.hostname.replace(/^www\./, "");
177
- if (n === "youtu.be") {
178
- const t = o.pathname.slice(1).split("/")[0];
179
- return /^[A-Za-z0-9_-]{11}$/.test(t) ? t : null;
979
+ const s = n.hostname.replace(/^www\./, "");
980
+ if (s === "youtu.be") {
981
+ const r = n.pathname.slice(1).split("/")[0];
982
+ return /^[A-Za-z0-9_-]{11}$/.test(r) ? r : null;
180
983
  }
181
- if (n === "youtube.com" || n === "m.youtube.com" || n === "music.youtube.com" || n === "youtube-nocookie.com") {
182
- const t = o.searchParams.get("v");
183
- if (t && /^[A-Za-z0-9_-]{11}$/.test(t)) return t;
184
- const l = /^\/(?:embed|shorts|v|live)\/([A-Za-z0-9_-]{11})/.exec(
185
- o.pathname
984
+ if (s === "youtube.com" || s === "m.youtube.com" || s === "music.youtube.com" || s === "youtube-nocookie.com") {
985
+ const r = n.searchParams.get("v");
986
+ if (r && /^[A-Za-z0-9_-]{11}$/.test(r)) return r;
987
+ const i = /^\/(?:embed|shorts|v|live)\/([A-Za-z0-9_-]{11})/.exec(
988
+ n.pathname
186
989
  );
187
- if (l) return l[1];
990
+ if (i) return i[1];
188
991
  }
189
992
  return null;
190
993
  }
191
- function re(e) {
994
+ function _e(e) {
192
995
  try {
193
- const o = new URL(e), n = o.searchParams.get("t") ?? o.searchParams.get("start");
194
- if (!n) return null;
195
- if (/^\d+s?$/.test(n)) return Number.parseInt(n, 10);
196
- const t = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(n);
197
- if (t) {
198
- const l = Number.parseInt(t[1] ?? "0", 10), f = Number.parseInt(t[2] ?? "0", 10), d = Number.parseInt(t[3] ?? "0", 10), a = l * 3600 + f * 60 + d;
996
+ const n = new URL(e), s = n.searchParams.get("t") ?? n.searchParams.get("start");
997
+ if (!s) return null;
998
+ if (/^\d+s?$/.test(s)) return Number.parseInt(s, 10);
999
+ const r = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(s);
1000
+ if (r) {
1001
+ const i = Number.parseInt(r[1] ?? "0", 10), u = Number.parseInt(r[2] ?? "0", 10), c = Number.parseInt(r[3] ?? "0", 10), a = i * 3600 + u * 60 + c;
199
1002
  return a > 0 ? a : null;
200
1003
  }
201
1004
  } catch {
202
1005
  }
203
1006
  return null;
204
1007
  }
205
- function ne(e, o = {}) {
206
- const { autoPlay: n = !1, muted: t = !0, loop: l = !1, controls: f = !0, startSeconds: d } = o, a = new URLSearchParams({
1008
+ function Oe(e, n = {}) {
1009
+ const { autoPlay: s = !1, muted: r = !0, loop: i = !1, controls: u = !0, startSeconds: c } = n, a = new URLSearchParams({
207
1010
  rel: "0",
208
1011
  modestbranding: "1",
209
1012
  playsinline: "1",
210
- controls: f ? "1" : "0"
1013
+ controls: u ? "1" : "0"
211
1014
  });
212
- return n ? (a.set("autoplay", "1"), a.set("mute", "1")) : t && a.set("mute", "1"), l && (a.set("loop", "1"), a.set("playlist", e)), d && d > 0 && a.set("start", String(d)), `https://www.youtube-nocookie.com/embed/${e}?${a.toString()}`;
1015
+ return s ? (a.set("autoplay", "1"), a.set("mute", "1")) : r && a.set("mute", "1"), i && (a.set("loop", "1"), a.set("playlist", e)), c && c > 0 && a.set("start", String(c)), `https://www.youtube-nocookie.com/embed/${e}?${a.toString()}`;
213
1016
  }
214
- const ae = ({
1017
+ const Fe = ({
1018
+ tracks: e,
1019
+ activeIndex: n,
1020
+ onSelect: s
1021
+ }) => {
1022
+ const [r, i] = k(!1), u = V(null);
1023
+ x(() => {
1024
+ if (!r) return;
1025
+ const a = (m) => {
1026
+ u.current && !u.current.contains(m.target) && i(!1);
1027
+ }, l = (m) => {
1028
+ m.key === "Escape" && i(!1);
1029
+ };
1030
+ return document.addEventListener("mousedown", a), document.addEventListener("keydown", l), () => {
1031
+ document.removeEventListener("mousedown", a), document.removeEventListener("keydown", l);
1032
+ };
1033
+ }, [r]);
1034
+ const c = e.find((a) => a.index === n) ?? e[0];
1035
+ return /* @__PURE__ */ v("div", { className: "gvp-audio", ref: u, children: [
1036
+ /* @__PURE__ */ v(
1037
+ "button",
1038
+ {
1039
+ type: "button",
1040
+ className: "gvp-audio-btn",
1041
+ "aria-haspopup": "listbox",
1042
+ "aria-expanded": r,
1043
+ "aria-label": "Audio track",
1044
+ onClick: () => i((a) => !a),
1045
+ children: [
1046
+ /* @__PURE__ */ t(we, {}),
1047
+ /* @__PURE__ */ t("span", { className: "gvp-audio-label", children: c == null ? void 0 : c.label }),
1048
+ /* @__PURE__ */ t(Ie, {})
1049
+ ]
1050
+ }
1051
+ ),
1052
+ r && // A native <select> can't be styled to sit inside the player overlay
1053
+ // (it renders the OS dropdown chrome), so this is a custom listbox with
1054
+ // full keyboard + ARIA support.
1055
+ // NOSONAR: typescript:S6819
1056
+ /* @__PURE__ */ t("ul", { className: "gvp-audio-menu", role: "listbox", "aria-label": "Audio tracks", children: e.map((a) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
1057
+ "button",
1058
+ {
1059
+ type: "button",
1060
+ role: "option",
1061
+ "aria-selected": a.index === n,
1062
+ className: H(
1063
+ "gvp-audio-menu-item",
1064
+ a.index === n && "is-active"
1065
+ ),
1066
+ onClick: () => {
1067
+ s(a.index), i(!1);
1068
+ },
1069
+ children: a.label
1070
+ }
1071
+ ) }, a.index)) })
1072
+ ] });
1073
+ }, Ke = ({
215
1074
  src: e,
216
- poster: o,
217
- showDeviceToggle: n = !0,
218
- defaultDevice: t = "desktop",
219
- hoverPlay: l = !1,
220
- tooltipText: f,
221
- onClose: d,
1075
+ poster: n,
1076
+ showDeviceToggle: s = !0,
1077
+ defaultDevice: r = "desktop",
1078
+ hoverPlay: i = !1,
1079
+ tooltipText: u,
1080
+ onClose: c,
222
1081
  className: a = "",
223
- muted: c = !0,
224
- loop: y = !1,
225
- controls: C = !1,
226
- autoPlay: s = !1,
227
- frameMaxWidth: u,
228
- aspectRatio: i,
229
- hlsConfig: R,
230
- children: T
1082
+ muted: l = !0,
1083
+ loop: m = !1,
1084
+ controls: f = !1,
1085
+ autoPlay: o = !1,
1086
+ frameMaxWidth: p,
1087
+ aspectRatio: g,
1088
+ hlsConfig: d,
1089
+ children: w
231
1090
  }) => {
232
- const w = H(null), k = H(null), [h, j] = $(t), [V, g] = $(!1), [z, L] = $(!1), N = I(() => te(e), [e]), v = N !== null, D = I(() => h === "mobile" ? (i == null ? void 0 : i.mobile) ?? "9/16" : (i == null ? void 0 : i.desktop) ?? "16/9", [h, i]), Y = I(() => h === "mobile" ? (u == null ? void 0 : u.mobile) ?? "420px" : (u == null ? void 0 : u.desktop) ?? "960px", [h, u]), A = I(
233
- () => N ? ne(N, {
234
- autoPlay: s,
235
- muted: c,
236
- loop: y,
237
- controls: C,
238
- startSeconds: re(e)
1091
+ const C = V(null), N = V(null), [P, R] = k(r), [D, h] = k(!1), [E, M] = k(!1), [b, T] = k([]), [_, z] = k(-1), [te, ne] = k(null), [re, se] = k(null), oe = S((y) => {
1092
+ C.current = y, se(y);
1093
+ }, []), A = f === "custom", O = f === !0, W = U(() => Ue(e), [e]), I = W !== null, ae = U(() => P === "mobile" ? (g == null ? void 0 : g.mobile) ?? "9/16" : (g == null ? void 0 : g.desktop) ?? "16/9", [P, g]), le = U(() => P === "mobile" ? (p == null ? void 0 : p.mobile) ?? "420px" : (p == null ? void 0 : p.desktop) ?? "960px", [P, p]), ie = U(
1094
+ () => W ? Oe(W, {
1095
+ autoPlay: o,
1096
+ muted: l,
1097
+ loop: m,
1098
+ // Custom controls can't drive an iframe, so YouTube falls
1099
+ // back to its own controls in that mode.
1100
+ controls: A ? !0 : O,
1101
+ startSeconds: _e(e)
239
1102
  }) : null,
240
- [N, e, s, c, y, C]
241
- ), S = b(async () => {
242
- const p = w.current;
243
- if (p) {
244
- if (k.current)
1103
+ [W, e, o, l, m, A, O]
1104
+ ), ce = S((y) => {
1105
+ T(y), z(-1);
1106
+ }, []), j = S(async () => {
1107
+ const y = C.current;
1108
+ if (y) {
1109
+ if (N.current)
245
1110
  try {
246
- await k.current;
1111
+ await N.current;
247
1112
  } catch {
248
1113
  }
249
- p.pause();
1114
+ y.pause();
250
1115
  }
251
- }, []), P = b(async () => {
252
- const p = w.current;
253
- if (p)
1116
+ }, []), Z = S(async () => {
1117
+ const y = C.current;
1118
+ if (y)
254
1119
  try {
255
- p.readyState < 2 && p.load();
256
- const x = p.play();
257
- k.current = x, await x, g(!0);
1120
+ y.readyState < 2 && y.load();
1121
+ const Y = y.play();
1122
+ N.current = Y, await Y, h(!0);
258
1123
  } catch {
259
- g(!1);
1124
+ h(!1);
260
1125
  } finally {
261
- k.current = null;
1126
+ N.current = null;
262
1127
  }
263
- }, []), J = b(() => {
264
- !l || v || P();
265
- }, [l, v, P]), O = b(() => {
266
- !l || v || S().then(() => g(!1));
267
- }, [l, v, S]), W = b(async () => {
268
- const p = w.current;
269
- p && (p.paused ? await P() : (await S(), g(!1)));
270
- }, [P, S]);
1128
+ }, []), ue = S(() => {
1129
+ !i || I || Z();
1130
+ }, [i, I, Z]), de = S(() => {
1131
+ !i || I || j().then(() => h(!1));
1132
+ }, [i, I, j]), F = S(async () => {
1133
+ const y = C.current;
1134
+ y && (y.paused ? await Z() : (await j(), h(!1)));
1135
+ }, [Z, j]), he = !I && b.length > 1;
271
1136
  return (
272
1137
  // The mouse handlers are a progressive enhancement (hoverPlay + tooltip).
273
1138
  // Keyboard/click users reach the same actions via the inner <button> elements,
274
1139
  // so the outer container is intentionally non-interactive at the role level.
275
1140
  // NOSONAR: typescript:S6848
276
- /* @__PURE__ */ m(
1141
+ /* @__PURE__ */ v(
277
1142
  "div",
278
1143
  {
279
- className: Z("gvp-root", a),
280
- style: { width: Y, aspectRatio: D },
1144
+ ref: ne,
1145
+ className: H("gvp-root", a),
1146
+ style: { width: le, aspectRatio: ae },
281
1147
  onMouseEnter: () => {
282
- L(!0), J();
1148
+ M(!0), ue();
283
1149
  },
284
1150
  onMouseLeave: () => {
285
- L(!1), O();
1151
+ M(!1), de();
286
1152
  },
287
1153
  children: [
288
- v ? /* @__PURE__ */ r(
1154
+ I ? /* @__PURE__ */ t(
289
1155
  "iframe",
290
1156
  {
291
1157
  className: "gvp-video gvp-youtube",
292
- src: A ?? void 0,
1158
+ src: ie ?? void 0,
293
1159
  title: "YouTube video player",
294
1160
  allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",
295
1161
  allowFullScreen: !0,
296
1162
  referrerPolicy: "strict-origin-when-cross-origin"
297
1163
  }
298
- ) : /* @__PURE__ */ r(
299
- B,
1164
+ ) : /* @__PURE__ */ t(
1165
+ ee,
300
1166
  {
301
- ref: w,
1167
+ ref: oe,
302
1168
  src: e,
303
- poster: o,
304
- muted: c,
305
- loop: y,
1169
+ poster: n,
1170
+ muted: l,
1171
+ loop: m,
306
1172
  playsInline: !0,
307
1173
  preload: "metadata",
308
- controls: C,
309
- autoPlay: s,
310
- hlsConfig: R,
1174
+ controls: O,
1175
+ autoPlay: o,
1176
+ hlsConfig: d,
311
1177
  className: "gvp-video",
312
- onPlay: () => g(!0),
313
- onPause: () => g(!1),
314
- children: T
1178
+ onPlay: () => h(!0),
1179
+ onPause: () => h(!1),
1180
+ onAudioTracks: ce,
1181
+ audioTrackIndex: _,
1182
+ children: w
315
1183
  }
316
1184
  ),
317
- !v && /* @__PURE__ */ r("div", { className: "gvp-vignette" }),
318
- n && /* @__PURE__ */ r("div", { className: "gvp-toggle", children: /* @__PURE__ */ m("div", { className: "gvp-toggle-pill", children: [
319
- /* @__PURE__ */ r(
1185
+ !I && /* @__PURE__ */ t("div", { className: "gvp-vignette" }),
1186
+ s && /* @__PURE__ */ t("div", { className: "gvp-toggle", children: /* @__PURE__ */ v("div", { className: "gvp-toggle-pill", children: [
1187
+ /* @__PURE__ */ t(
320
1188
  "button",
321
1189
  {
322
1190
  type: "button",
323
- onClick: () => j("desktop"),
324
- className: Z(
1191
+ onClick: () => R("desktop"),
1192
+ className: H(
325
1193
  "gvp-toggle-btn",
326
- h === "desktop" && "is-active"
1194
+ P === "desktop" && "is-active"
327
1195
  ),
328
1196
  "aria-label": "Desktop view",
329
- "aria-pressed": h === "desktop",
330
- children: /* @__PURE__ */ r(K, {})
1197
+ "aria-pressed": P === "desktop",
1198
+ children: /* @__PURE__ */ t(fe, {})
331
1199
  }
332
1200
  ),
333
- /* @__PURE__ */ r("div", { className: "gvp-toggle-divider" }),
334
- /* @__PURE__ */ r(
1201
+ /* @__PURE__ */ t("div", { className: "gvp-toggle-divider" }),
1202
+ /* @__PURE__ */ t(
335
1203
  "button",
336
1204
  {
337
1205
  type: "button",
338
- onClick: () => j("mobile"),
339
- className: Z(
1206
+ onClick: () => R("mobile"),
1207
+ className: H(
340
1208
  "gvp-toggle-btn",
341
- h === "mobile" && "is-active"
1209
+ P === "mobile" && "is-active"
342
1210
  ),
343
1211
  "aria-label": "Mobile view",
344
- "aria-pressed": h === "mobile",
345
- children: /* @__PURE__ */ r(Q, {})
1212
+ "aria-pressed": P === "mobile",
1213
+ children: /* @__PURE__ */ t(ge, {})
346
1214
  }
347
1215
  )
348
1216
  ] }) }),
349
- d && /* @__PURE__ */ r(
1217
+ c && /* @__PURE__ */ t(
350
1218
  "button",
351
1219
  {
352
1220
  type: "button",
353
- onClick: d,
1221
+ onClick: c,
354
1222
  className: "gvp-close",
355
1223
  "aria-label": "Close",
356
- children: /* @__PURE__ */ r(F, {})
1224
+ children: /* @__PURE__ */ t(ve, {})
1225
+ }
1226
+ ),
1227
+ he && /* @__PURE__ */ t(
1228
+ Fe,
1229
+ {
1230
+ tracks: b,
1231
+ activeIndex: _ >= 0 ? _ : b[0].index,
1232
+ onSelect: z
357
1233
  }
358
1234
  ),
359
- !v && !V && /* @__PURE__ */ r("div", { className: "gvp-play-wrap", children: /* @__PURE__ */ m(
1235
+ !I && A && /* @__PURE__ */ t(
360
1236
  "button",
361
1237
  {
362
1238
  type: "button",
363
- onClick: () => void W(),
364
- onMouseEnter: () => L(!0),
365
- onMouseLeave: () => L(!1),
1239
+ className: "gvp-click-layer",
1240
+ onClick: () => void F(),
1241
+ "aria-label": D ? "Pause" : "Play"
1242
+ }
1243
+ ),
1244
+ !I && !A && !D && /* @__PURE__ */ t("div", { className: "gvp-play-wrap", children: /* @__PURE__ */ v(
1245
+ "button",
1246
+ {
1247
+ type: "button",
1248
+ onClick: () => void F(),
1249
+ onMouseEnter: () => M(!0),
1250
+ onMouseLeave: () => M(!1),
366
1251
  className: "gvp-play",
367
1252
  "aria-label": "Play",
368
1253
  children: [
369
- /* @__PURE__ */ r(ee, {}),
370
- f && z && /* @__PURE__ */ r("span", { className: "gvp-tooltip", role: "tooltip", children: f })
1254
+ /* @__PURE__ */ t(ke, {}),
1255
+ u && E && /* @__PURE__ */ t("span", { className: "gvp-tooltip", role: "tooltip", children: u })
371
1256
  ]
372
1257
  }
373
1258
  ) }),
374
- !v && /* @__PURE__ */ r("div", { className: "gvp-bottom-fade" })
1259
+ !I && A && /* @__PURE__ */ t(
1260
+ He,
1261
+ {
1262
+ video: re,
1263
+ isPlaying: D,
1264
+ container: te,
1265
+ onTogglePlay: () => void F()
1266
+ }
1267
+ ),
1268
+ !I && !A && /* @__PURE__ */ t("div", { className: "gvp-bottom-fade" })
375
1269
  ]
376
1270
  }
377
1271
  )
378
1272
  );
379
1273
  };
380
1274
  export {
381
- ae as ReactVideoPlayer,
382
- te as parseYouTubeId,
383
- re as parseYouTubeStart,
384
- ne as youTubeEmbedUrl
1275
+ Ke as ReactVideoPlayer,
1276
+ Ue as parseYouTubeId,
1277
+ _e as parseYouTubeStart,
1278
+ Oe as youTubeEmbedUrl
385
1279
  };
386
1280
  //# sourceMappingURL=index.mjs.map