boss-web-player-sdk 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,3638 @@
1
+ import { c as e, t, u as n } from "./src-B8eoxemB.js";
2
+ import { createContext as r, createElement as i, forwardRef as a, useCallback as o, useContext as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
3
+ import { createPortal as f } from "react-dom";
4
+ import { Fragment as ee, jsx as p, jsxs as m } from "react/jsx-runtime";
5
+ import { createRoot as te } from "react-dom/client";
6
+ //#region ../ui-controls/src/ErrorScreen.tsx
7
+ function ne({ title: e = "Something Went Wrong", subtitle: t = "We encountered an error while playing this video.\nPlease try again.", onRetry: n }) {
8
+ return /* @__PURE__ */ m(ee, { children: [
9
+ /* @__PURE__ */ p("div", {
10
+ style: {
11
+ width: 80,
12
+ height: 80,
13
+ borderRadius: "50%",
14
+ background: "rgba(255,255,255,0.08)",
15
+ display: "flex",
16
+ alignItems: "center",
17
+ justifyContent: "center",
18
+ flexShrink: 0
19
+ },
20
+ children: /* @__PURE__ */ m("svg", {
21
+ width: "36",
22
+ height: "36",
23
+ viewBox: "0 0 24 24",
24
+ fill: "none",
25
+ stroke: "rgba(255,255,255,0.85)",
26
+ strokeWidth: "2",
27
+ strokeLinecap: "round",
28
+ strokeLinejoin: "round",
29
+ children: [
30
+ /* @__PURE__ */ p("path", { d: "M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" }),
31
+ /* @__PURE__ */ p("line", {
32
+ x1: "12",
33
+ y1: "9",
34
+ x2: "12",
35
+ y2: "13"
36
+ }),
37
+ /* @__PURE__ */ p("line", {
38
+ x1: "12",
39
+ y1: "17",
40
+ x2: "12.01",
41
+ y2: "17"
42
+ })
43
+ ]
44
+ })
45
+ }),
46
+ /* @__PURE__ */ m("div", {
47
+ style: {
48
+ textAlign: "center",
49
+ padding: "0 24px"
50
+ },
51
+ children: [/* @__PURE__ */ p("p", {
52
+ style: {
53
+ color: "#ffffff",
54
+ fontSize: 22,
55
+ fontWeight: 700,
56
+ margin: "0 0 8px",
57
+ letterSpacing: "-0.2px"
58
+ },
59
+ children: e
60
+ }), /* @__PURE__ */ p("p", {
61
+ style: {
62
+ color: "rgba(255,255,255,0.5)",
63
+ fontSize: 14,
64
+ margin: 0,
65
+ lineHeight: 1.6,
66
+ whiteSpace: "pre-line"
67
+ },
68
+ children: t
69
+ })]
70
+ }),
71
+ /* @__PURE__ */ m("button", {
72
+ onClick: n,
73
+ style: {
74
+ display: "flex",
75
+ alignItems: "center",
76
+ gap: 10,
77
+ background: "#ffffff",
78
+ color: "#09090e",
79
+ border: "none",
80
+ borderRadius: 10,
81
+ padding: "14px 32px",
82
+ fontSize: 16,
83
+ fontWeight: 700,
84
+ cursor: "pointer",
85
+ letterSpacing: "-0.1px"
86
+ },
87
+ children: [/* @__PURE__ */ m("svg", {
88
+ width: "20",
89
+ height: "20",
90
+ viewBox: "0 0 24 24",
91
+ fill: "none",
92
+ stroke: "currentColor",
93
+ strokeWidth: "2.5",
94
+ strokeLinecap: "round",
95
+ strokeLinejoin: "round",
96
+ children: [/* @__PURE__ */ p("polyline", { points: "1 4 1 10 7 10" }), /* @__PURE__ */ p("path", { d: "M3.51 15a9 9 0 1 0 .49-3.51" })]
97
+ }), "Retry Now"]
98
+ })
99
+ ] });
100
+ }
101
+ //#endregion
102
+ //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs
103
+ var h = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), g = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), _ = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), re = (e) => {
104
+ let t = _(e);
105
+ return t.charAt(0).toUpperCase() + t.slice(1);
106
+ }, ie = {
107
+ xmlns: "http://www.w3.org/2000/svg",
108
+ width: 24,
109
+ height: 24,
110
+ viewBox: "0 0 24 24",
111
+ fill: "none",
112
+ stroke: "currentColor",
113
+ strokeWidth: 2,
114
+ strokeLinecap: "round",
115
+ strokeLinejoin: "round"
116
+ }, ae = (e) => {
117
+ for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
118
+ return !1;
119
+ }, oe = r({}), se = () => s(oe), ce = a(({ color: e, size: t, strokeWidth: n, absoluteStrokeWidth: r, className: a = "", children: o, iconNode: s, ...c }, l) => {
120
+ let { size: u = 24, strokeWidth: d = 2, absoluteStrokeWidth: f = !1, color: ee = "currentColor", className: p = "" } = se() ?? {}, m = r ?? f ? Number(n ?? d) * 24 / Number(t ?? u) : n ?? d;
121
+ return i("svg", {
122
+ ref: l,
123
+ ...ie,
124
+ width: t ?? u ?? ie.width,
125
+ height: t ?? u ?? ie.height,
126
+ stroke: e ?? ee,
127
+ strokeWidth: m,
128
+ className: h("lucide", p, a),
129
+ ...!o && !ae(c) && { "aria-hidden": "true" },
130
+ ...c
131
+ }, [...s.map(([e, t]) => i(e, t)), ...Array.isArray(o) ? o : [o]]);
132
+ }), v = (e, t) => {
133
+ let n = a(({ className: n, ...r }, a) => i(ce, {
134
+ ref: a,
135
+ iconNode: t,
136
+ className: h(`lucide-${g(re(e))}`, `lucide-${e}`, n),
137
+ ...r
138
+ }));
139
+ return n.displayName = re(e), n;
140
+ }, le = v("airplay", [["path", {
141
+ d: "M5 17H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-1",
142
+ key: "ns4c3b"
143
+ }], ["path", {
144
+ d: "m12 15 5 6H7Z",
145
+ key: "14qnn2"
146
+ }]]), ue = v("captions", [["rect", {
147
+ width: "18",
148
+ height: "14",
149
+ x: "3",
150
+ y: "5",
151
+ rx: "2",
152
+ ry: "2",
153
+ key: "12ruh7"
154
+ }], ["path", {
155
+ d: "M7 15h4M15 15h2M7 11h2M13 11h4",
156
+ key: "1ueiar"
157
+ }]]), de = v("cast", [
158
+ ["path", {
159
+ d: "M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6",
160
+ key: "3zrzxg"
161
+ }],
162
+ ["path", {
163
+ d: "M2 12a9 9 0 0 1 8 8",
164
+ key: "g6cvee"
165
+ }],
166
+ ["path", {
167
+ d: "M2 16a5 5 0 0 1 4 4",
168
+ key: "1y1dii"
169
+ }],
170
+ ["line", {
171
+ x1: "2",
172
+ x2: "2.01",
173
+ y1: "20",
174
+ y2: "20",
175
+ key: "xu2jvo"
176
+ }]
177
+ ]), y = v("check", [["path", {
178
+ d: "M20 6 9 17l-5-5",
179
+ key: "1gmf2c"
180
+ }]]), fe = v("chevron-left", [["path", {
181
+ d: "m15 18-6-6 6-6",
182
+ key: "1wnfg3"
183
+ }]]), pe = v("external-link", [
184
+ ["path", {
185
+ d: "M15 3h6v6",
186
+ key: "1q9fwt"
187
+ }],
188
+ ["path", {
189
+ d: "M10 14 21 3",
190
+ key: "gplh6r"
191
+ }],
192
+ ["path", {
193
+ d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",
194
+ key: "a6xqqp"
195
+ }]
196
+ ]), me = v("gauge", [["path", {
197
+ d: "m12 14 4-4",
198
+ key: "9kzdfg"
199
+ }], ["path", {
200
+ d: "M3.34 19a10 10 0 1 1 17.32 0",
201
+ key: "19p75a"
202
+ }]]), he = v("languages", [
203
+ ["path", {
204
+ d: "m5 8 6 6",
205
+ key: "1wu5hv"
206
+ }],
207
+ ["path", {
208
+ d: "m4 14 6-6 2-3",
209
+ key: "1k1g8d"
210
+ }],
211
+ ["path", {
212
+ d: "M2 5h12",
213
+ key: "or177f"
214
+ }],
215
+ ["path", {
216
+ d: "M7 2h1",
217
+ key: "1t2jsx"
218
+ }],
219
+ ["path", {
220
+ d: "m22 22-5-10-5 10",
221
+ key: "don7ne"
222
+ }],
223
+ ["path", {
224
+ d: "M14 18h6",
225
+ key: "1m8k6r"
226
+ }]
227
+ ]), ge = v("list-video", [
228
+ ["path", {
229
+ d: "M21 5H3",
230
+ key: "1fi0y6"
231
+ }],
232
+ ["path", {
233
+ d: "M10 12H3",
234
+ key: "1ulcyk"
235
+ }],
236
+ ["path", {
237
+ d: "M10 19H3",
238
+ key: "108z41"
239
+ }],
240
+ ["path", {
241
+ d: "M15 12.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997a1 1 0 0 1-1.517-.86z",
242
+ key: "ms4nik"
243
+ }]
244
+ ]), _e = v("maximize", [
245
+ ["path", {
246
+ d: "M8 3H5a2 2 0 0 0-2 2v3",
247
+ key: "1dcmit"
248
+ }],
249
+ ["path", {
250
+ d: "M21 8V5a2 2 0 0 0-2-2h-3",
251
+ key: "1e4gt3"
252
+ }],
253
+ ["path", {
254
+ d: "M3 16v3a2 2 0 0 0 2 2h3",
255
+ key: "wsl5sc"
256
+ }],
257
+ ["path", {
258
+ d: "M16 21h3a2 2 0 0 0 2-2v-3",
259
+ key: "18trek"
260
+ }]
261
+ ]), ve = v("minimize", [
262
+ ["path", {
263
+ d: "M8 3v3a2 2 0 0 1-2 2H3",
264
+ key: "hohbtr"
265
+ }],
266
+ ["path", {
267
+ d: "M21 8h-3a2 2 0 0 1-2-2V3",
268
+ key: "5jw1f3"
269
+ }],
270
+ ["path", {
271
+ d: "M3 16h3a2 2 0 0 1 2 2v3",
272
+ key: "198tvr"
273
+ }],
274
+ ["path", {
275
+ d: "M16 21v-3a2 2 0 0 1 2-2h3",
276
+ key: "ph8mxp"
277
+ }]
278
+ ]), b = v("pause", [["rect", {
279
+ x: "14",
280
+ y: "3",
281
+ width: "5",
282
+ height: "18",
283
+ rx: "1",
284
+ key: "kaeet6"
285
+ }], ["rect", {
286
+ x: "5",
287
+ y: "3",
288
+ width: "5",
289
+ height: "18",
290
+ rx: "1",
291
+ key: "1wsw3u"
292
+ }]]), ye = v("picture-in-picture", [
293
+ ["path", {
294
+ d: "M2 10h6V4",
295
+ key: "zwrco"
296
+ }],
297
+ ["path", {
298
+ d: "m2 4 6 6",
299
+ key: "ug085t"
300
+ }],
301
+ ["path", {
302
+ d: "M21 10V7a2 2 0 0 0-2-2h-7",
303
+ key: "git5jr"
304
+ }],
305
+ ["path", {
306
+ d: "M3 14v2a2 2 0 0 0 2 2h3",
307
+ key: "1f7fh3"
308
+ }],
309
+ ["rect", {
310
+ x: "12",
311
+ y: "14",
312
+ width: "10",
313
+ height: "7",
314
+ rx: "1",
315
+ key: "1wjs3o"
316
+ }]
317
+ ]), be = v("play", [["path", {
318
+ d: "M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",
319
+ key: "10ikf1"
320
+ }]]), xe = v("rotate-ccw", [["path", {
321
+ d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",
322
+ key: "1357e3"
323
+ }], ["path", {
324
+ d: "M3 3v5h5",
325
+ key: "1xhq8a"
326
+ }]]), Se = v("rotate-cw", [["path", {
327
+ d: "M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",
328
+ key: "1p45f6"
329
+ }], ["path", {
330
+ d: "M21 3v5h-5",
331
+ key: "1q7to0"
332
+ }]]), Ce = v("volume-1", [["path", {
333
+ d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",
334
+ key: "uqj9uw"
335
+ }], ["path", {
336
+ d: "M16 9a5 5 0 0 1 0 6",
337
+ key: "1q6k2b"
338
+ }]]), we = v("volume-2", [
339
+ ["path", {
340
+ d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",
341
+ key: "uqj9uw"
342
+ }],
343
+ ["path", {
344
+ d: "M16 9a5 5 0 0 1 0 6",
345
+ key: "1q6k2b"
346
+ }],
347
+ ["path", {
348
+ d: "M19.364 18.364a9 9 0 0 0 0-12.728",
349
+ key: "ijwkga"
350
+ }]
351
+ ]), Te = v("volume-x", [
352
+ ["path", {
353
+ d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",
354
+ key: "uqj9uw"
355
+ }],
356
+ ["line", {
357
+ x1: "22",
358
+ x2: "16",
359
+ y1: "9",
360
+ y2: "15",
361
+ key: "1ewh16"
362
+ }],
363
+ ["line", {
364
+ x1: "16",
365
+ x2: "22",
366
+ y1: "9",
367
+ y2: "15",
368
+ key: "5ykzw1"
369
+ }]
370
+ ]), Ee = v("volume", [["path", {
371
+ d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",
372
+ key: "uqj9uw"
373
+ }]]), De = 1e4, Oe = !1, ke = "\n html, body { margin: 0; padding: 0; height: 100%; background: #000; overflow: hidden; }\n * { box-sizing: border-box; }\n .gb-pip-video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }\n .gb-pip-overlay {\n position: absolute; inset: 0; z-index: 2;\n display: flex; flex-direction: column; justify-content: space-between;\n font-family: system-ui, -apple-system, sans-serif; color: #fff;\n opacity: 0; transition: opacity 0.15s ease;\n background: linear-gradient(to bottom, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 25%, rgba(0,0,0,0) 65%, rgba(0,0,0,0.55) 100%);\n }\n .gb-pip-overlay:hover, .gb-pip-overlay.gb-pip-paused { opacity: 1; }\n .gb-pip-center {\n flex: 1; display: flex; align-items: center; justify-content: center; gap: 28px;\n }\n .gb-pip-btn {\n background: rgba(0,0,0,0.35); border: none; color: #fff; border-radius: 50%;\n width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;\n cursor: pointer; padding: 0;\n }\n .gb-pip-btn:hover { background: rgba(0,0,0,0.55); }\n .gb-pip-btn.gb-pip-play { width: 56px; height: 56px; }\n .gb-pip-bottom { padding: 6px 10px 8px; display: flex; flex-direction: column; gap: 4px; }\n .gb-pip-progress { position: relative; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.3); cursor: pointer; }\n .gb-pip-progress-fill { position: absolute; inset: 0; width: 0%; border-radius: 2px; background: #fff; }\n .gb-pip-time { font-size: 11px; font-variant-numeric: tabular-nums; opacity: 0.9; }\n", Ae = (e) => {
374
+ let t = e.match(/#EXT-X-TITLE:(.+)/);
375
+ if (t?.[1]?.trim()) return t[1].trim();
376
+ let n = e.match(/#EXT-X-SESSION-DATA:[^\n]*DATA-ID="[^"]*title[^"]*"[^\n]*VALUE="([^"]+)"/i);
377
+ return n?.[1]?.trim() ? n[1].trim() : null;
378
+ }, je = (e) => {
379
+ if (!e || e.length < 10 || e[0] !== 73 || e[1] !== 68 || e[2] !== 51) return null;
380
+ let t = e[3], n = (e[6] & 127) << 21 | (e[7] & 127) << 14 | (e[8] & 127) << 7 | e[9] & 127, r = Math.min(10 + n, e.length), i = 10;
381
+ for (; i + 10 <= r;) {
382
+ let n = String.fromCharCode(e[i], e[i + 1], e[i + 2], e[i + 3]), a = t >= 4 ? (e[i + 4] & 127) << 21 | (e[i + 5] & 127) << 14 | (e[i + 6] & 127) << 7 | e[i + 7] & 127 : e[i + 4] << 24 | e[i + 5] << 16 | e[i + 6] << 8 | e[i + 7];
383
+ if (a <= 0 || i + 10 + a > r) break;
384
+ if (n === "TIT2") {
385
+ let t = e[i + 10], n = e.slice(i + 11, i + 10 + a), r = (t === 1 || t === 2 ? new TextDecoder("utf-16").decode(n) : new TextDecoder(t === 3 ? "utf-8" : "latin1").decode(n)).replace(/\0/g, "").trim();
386
+ if (r) return r;
387
+ }
388
+ i += 10 + a;
389
+ }
390
+ return null;
391
+ }, Me = ({ size: e = 20 }) => /* @__PURE__ */ m("svg", {
392
+ width: e,
393
+ height: e,
394
+ viewBox: "0 0 24 24",
395
+ fill: "none",
396
+ stroke: "currentColor",
397
+ strokeWidth: "2",
398
+ strokeLinecap: "round",
399
+ strokeLinejoin: "round",
400
+ children: [
401
+ /* @__PURE__ */ p("rect", {
402
+ x: "2",
403
+ y: "5",
404
+ width: "20",
405
+ height: "14",
406
+ rx: "3"
407
+ }),
408
+ /* @__PURE__ */ p("path", { d: "M7 9v6M7 12h3M10 9v6" }),
409
+ /* @__PURE__ */ p("path", { d: "M14 9h1.5a3 3 0 0 1 0 6H14z" })
410
+ ]
411
+ }), Ne = ({ size: e = 20 }) => /* @__PURE__ */ m("svg", {
412
+ width: e,
413
+ height: e,
414
+ viewBox: "0 0 24 24",
415
+ fill: "none",
416
+ stroke: "currentColor",
417
+ strokeWidth: "2",
418
+ strokeLinecap: "round",
419
+ strokeLinejoin: "round",
420
+ children: [
421
+ /* @__PURE__ */ p("rect", {
422
+ x: "2",
423
+ y: "5",
424
+ width: "20",
425
+ height: "14",
426
+ rx: "3"
427
+ }),
428
+ /* @__PURE__ */ p("path", { d: "M7 9v6M7 12h3M10 9v6" }),
429
+ /* @__PURE__ */ p("path", { d: "M14 9h1.5a3 3 0 0 1 0 6H14z" })
430
+ ]
431
+ }), Pe = (e) => {
432
+ let t = e.replace("#", "");
433
+ return t.length === 6 ? `${parseInt(t.substring(0, 2), 16)}, ${parseInt(t.substring(2, 4), 16)}, ${parseInt(t.substring(4, 6), 16)}` : t.length === 3 ? `${parseInt(t[0] + t[0], 16)}, ${parseInt(t[1] + t[1], 16)}, ${parseInt(t[2] + t[2], 16)}` : "99, 102, 241";
434
+ }, Fe = {
435
+ en: "English",
436
+ eng: "English",
437
+ fr: "French",
438
+ fre: "French",
439
+ fra: "French",
440
+ es: "Spanish",
441
+ spa: "Spanish",
442
+ de: "German",
443
+ ger: "German",
444
+ deu: "German",
445
+ it: "Italian",
446
+ ita: "Italian",
447
+ pt: "Portuguese",
448
+ por: "Portuguese",
449
+ ja: "Japanese",
450
+ zh: "Chinese",
451
+ ko: "Korean",
452
+ ru: "Russian",
453
+ ar: "Arabic",
454
+ hi: "Hindi",
455
+ ta: "Tamil",
456
+ tam: "Tamil"
457
+ }, Ie = (e) => {
458
+ if (!e) return null;
459
+ let t = e.trim().toLowerCase(), n = t.match(/^(en|eng|fr|fre|fra|es|spa|de|ger|deu|it|ita|pt|por|ja|zh|ko|ru|ar|hi|ta|tam)/);
460
+ if (n && Fe[n[0]]) return Fe[n[0]];
461
+ for (let [e, n] of Object.entries(Fe)) if (t.includes(e)) return n;
462
+ return /english|anglais|ingles/i.test(t) ? "English" : /french|français/i.test(t) ? "French" : /spanish|español/i.test(t) ? "Spanish" : /german|deutsch/i.test(t) ? "German" : /italian|italiano/i.test(t) ? "Italian" : /portuguese|português/i.test(t) ? "Portuguese" : /japanese|nihongo/i.test(t) ? "Japanese" : /chinese|中文/i.test(t) ? "Chinese" : /korean|한국어/i.test(t) ? "Korean" : /tamil|தமிழ்/i.test(t) ? "Tamil" : /russian|русский/i.test(t) ? "Russian" : /arabic|العربية/i.test(t) ? "Arabic" : /hindi|हिन्दी/i.test(t) ? "Hindi" : null;
463
+ }, x = (e) => {
464
+ if (e.lang) {
465
+ let t = Ie(e.lang);
466
+ if (t) return t;
467
+ }
468
+ if (e.label) {
469
+ let t = e.label.trim(), n = t.split(/[#\d\.\s\-_/|:]+/).filter(Boolean);
470
+ for (let e = n.length - 1; e >= 0; --e) {
471
+ let t = Ie(n[e]);
472
+ if (t) return t;
473
+ }
474
+ let r = t.replace(/^[#\d\.\s]+/, "").trim();
475
+ return Ie(r) || r;
476
+ }
477
+ return "Unknown";
478
+ }, Le = (e) => {
479
+ let t = /* @__PURE__ */ new Set();
480
+ return e.filter((e) => {
481
+ let n = `${x(e).toLowerCase()}|${(e.lang || "").trim().toLowerCase()}`;
482
+ return t.has(n) ? !1 : (t.add(n), !0);
483
+ });
484
+ }, Re = (e) => {
485
+ let t = (e ?? "").split(":").map(Number);
486
+ return (t[0] || 0) * 3600 + (t[1] || 0) * 60 + (t[2] || 0);
487
+ }, ze = (e) => {
488
+ if (!e) return !1;
489
+ try {
490
+ let { protocol: t } = new URL(e, window.location.href);
491
+ return t === "http:" || t === "https:";
492
+ } catch {
493
+ return !1;
494
+ }
495
+ }, Be = (e) => {
496
+ if (typeof e == "number") return Number.isFinite(e) && e >= 0 ? e : null;
497
+ if (typeof e != "string") return null;
498
+ let t = e.trim();
499
+ if (!t) return null;
500
+ if (/^\d+:\d{1,2}:\d{1,2}(\.\d+)?$/.test(t)) return Re(t);
501
+ let n = Number(t);
502
+ return Number.isFinite(n) && n >= 0 ? n : null;
503
+ }, Ve = [
504
+ 0,
505
+ 1e3,
506
+ 2e3,
507
+ 3e3,
508
+ 5e3,
509
+ 8e3
510
+ ];
511
+ function He(e, t, n) {
512
+ let r = !1, i, a = (o) => {
513
+ i = setTimeout(() => {
514
+ r || fetch(e).then((e) => e.json()).then((e) => {
515
+ if (r) return;
516
+ let i = t(e);
517
+ if (i !== null) {
518
+ n(i);
519
+ return;
520
+ }
521
+ o + 1 < Ve.length && a(o + 1);
522
+ }).catch(() => {
523
+ r || o + 1 < Ve.length && a(o + 1);
524
+ });
525
+ }, Ve[o]);
526
+ };
527
+ return a(0), () => {
528
+ r = !0, i && clearTimeout(i);
529
+ };
530
+ }
531
+ var Ue = ({ src: r, autoplay: i = !1, muted: a = !1, chapters: s = [], keyMoments: te, subtitles: h = [], watermark: g, themeColor: _ = "#6366f1", drmConfig: re, firebaseConfig: ie, videoId: ae, onAnalyticsEvent: oe, onAdBreakChange: se, onKeyMomentsLoaded: ce, enableControls: v = !0, enableChromecast: Fe, enableKeyMoments: Ie, enableSubtitles: Ve, enableQuality: Ue, enablePlaybackSpeed: We, enablePiP: Ge, enableFullscreen: Ke = !0, autoFullscreen: qe = !1, watchProgressInterval: Je = 30, subtitleStyle: Ye = {}, resolvedEntitlement: Xe, licenseKey: Ze, title: S, chaptersDisplayMode: Qe = "strip", volumeControlType: $e = "slider", urlTransformer: et, pauseAdOnTabSwitch: tt = !0, enableSkipAd: nt = !1, skipAdAfterSeconds: rt = 5, overlayAdUrl: it, adTrackingUrl: at, sources: C, activeSourceIndex: ot = 0, onSourceChange: st, initialTime: ct, onTimeUpdate: lt }) => {
532
+ let ut = et ?? ((e) => e), w = u(null), dt = u(null), ft = u(!1), T = u(null), pt = u(0), mt = u(null), E = u(null), ht = u(null), gt = u(null), _t = u(!1), D = u(!1), O = u(null), k = u(null), A = u(null), vt = u(null), yt = u(() => {}), j = u(null), bt = u(!1), xt = u(null), St = (e) => {
533
+ !e || xt.current !== null || (xt.current = e.muted, e.muted = !0);
534
+ }, Ct = (e) => {
535
+ xt.current !== null && (e && (e.muted = xt.current), xt.current = null);
536
+ }, wt = u(null), Tt = u(!1), Et = u(null), Dt = u(null), Ot = u(null), kt = u(null), At = u(null), jt = u(null), Mt = u(C), Nt = u(st), Pt = u(!1), M = u(null), N = u(null), P = u(null), Ft = u(null), It = u(0), Lt = u(null), [Rt, zt] = d(!1), Bt = u(!1), Vt = u(null), [Ht, Ut] = d(null);
537
+ c(() => {
538
+ if (typeof window > "u" || Oe) return;
539
+ let e = window.requestAnimationFrame(() => {
540
+ let e = w.current;
541
+ if (!e) return;
542
+ let t = window.getComputedStyle(e);
543
+ t.overflow !== "hidden" && t.borderTopLeftRadius === "0px" && (Oe = !0, console.warn("[boss-web-player-sdk] Player styles appear to be missing — the player will look broken/unstyled.\nImport the stylesheet once at your app entry point:\n import 'boss-web-player-sdk/css';"));
544
+ });
545
+ return () => window.cancelAnimationFrame(e);
546
+ }, []), c(() => {
547
+ let e = w.current;
548
+ if (!e) return;
549
+ let t = new ResizeObserver((e) => {
550
+ for (let t of e) zt(t.contentRect.width <= 768);
551
+ });
552
+ return t.observe(e), zt(e.getBoundingClientRect().width <= 768), () => t.disconnect();
553
+ }, []);
554
+ let [F, Wt] = d(null), [Gt, Kt] = d(!1), qt = Xe ?? null, Jt = qt != null, Yt = qt?.features ?? {}, Xt = Jt ? !!(Yt.drm_protection && !Ze) : !1, I = {
555
+ enableSubtitles: Jt ? !!Yt.subtitle_support : typeof Ve == "boolean" ? Ve : !0,
556
+ enableChromecast: Jt ? !!Yt.chromecast : typeof Fe == "boolean" ? Fe : !0,
557
+ enableKeyMoments: Jt ? !!Yt.key_moments : typeof Ie == "boolean" ? Ie : !0,
558
+ enableQuality: Jt ? !!Yt.multiple_resolution : typeof Ue == "boolean" ? Ue : !0,
559
+ enablePlaybackSpeed: Jt ? !!Yt.playback_speed : typeof We == "boolean" ? We : !0,
560
+ enablePiP: Jt ? !!Yt.picture_in_picture : typeof Ge == "boolean" ? Ge : !0,
561
+ allowAirplay: Jt ? !!Yt.airplay : !1,
562
+ allowMultipleAudio: Jt ? !!Yt.multiple_audio : !0,
563
+ m3u8_playback: Jt ? !!Yt.m3u8_playback : !0,
564
+ drm_protection: Jt ? !!Yt.drm_protection : !1
565
+ }, [Zt, Qt] = d(!1), [$t, en] = d(0), [tn, nn] = d(!1), [L, rn] = d(0), [an, on] = d(0), [sn, cn] = d(1), [ln, un] = d(!1), [dn, fn] = d(!1), [pn, mn] = d(!1), [hn, gn] = d(!1), [_n, vn] = d(!1), yn = Rt || (pn || hn) && _n, [bn, xn] = d(!1), [Sn, Cn] = d(null), [wn, Tn] = d(!1), [R, En] = d([]), z = u([]), Dn = u(/* @__PURE__ */ new Set()), On = C && C.length > 0 ? C.map((e) => e.url).join("|") : r, [kn, An] = d(/* @__PURE__ */ new Set()), [jn, Mn] = d(On), Nn = u(null), Pn = u(!1), Fn = u(null);
566
+ jn !== On && (Mn(On), An(/* @__PURE__ */ new Set()), Dn.current = /* @__PURE__ */ new Set(), Nn.current = null, Pn.current = !1);
567
+ let In = u(null), Ln = u(!1), [Rn, zn] = d([]), [Bn, Vn] = d(null), Hn = u([]), Un = u(null), Wn = u(/* @__PURE__ */ new Set()), [Gn, Kn] = d([]), qn = u([]), Jn = u(null), [Yn, Xn] = d({
568
+ w: 0,
569
+ h: 0
570
+ }), [Zn, Qn] = d([]), $n = (e) => {
571
+ let t = qn.current.find((t) => e >= t.startTimeSeconds && e < t.endTimeSeconds);
572
+ if (t) return {
573
+ start: t.startTimeSeconds,
574
+ end: t.endTimeSeconds
575
+ };
576
+ let n = z.current.find((t) => e >= t.startTime && e < t.endTime);
577
+ return n ? {
578
+ start: n.startTime,
579
+ end: n.endTime
580
+ } : null;
581
+ }, er = l(() => R.reduce((e, t) => e + (t.endTime - t.startTime), 0), [R]), tr = an > 0 ? Math.max(0, an - er) : 0, B = R.length > 0 && tr > 0 ? tr : an, V = o((e) => {
582
+ let t = e;
583
+ for (let n of R) e >= n.endTime ? t -= n.endTime - n.startTime : e >= n.startTime && (t -= e - n.startTime);
584
+ return Math.max(0, t);
585
+ }, [R]), H = o((e) => {
586
+ let t = e;
587
+ for (let e of R) t >= e.startTime && (t += e.endTime - e.startTime);
588
+ return t;
589
+ }, [R]), [nr, rr] = d([]), [ir, ar] = d({
590
+ id: -1,
591
+ height: 0,
592
+ width: 0,
593
+ bitrate: 0,
594
+ label: "Auto"
595
+ }), [or, sr] = d(""), [U, cr] = d("off"), [lr, ur] = d(Le(h)), [dr, fr] = d([]), [pr, mr] = d(0);
596
+ c(() => {
597
+ if (F) {
598
+ let e = F.subtitles.getTracks();
599
+ ur(Le([...h, ...e.filter((e) => !h.some((t) => t.id === e.id))]));
600
+ } else ur(Le(h));
601
+ }, [h.map((e) => e.id).join(","), F]);
602
+ let [hr, gr] = d({
603
+ chapter: null,
604
+ index: -1
605
+ }), [W, _r] = d(te || s || []), [G, K] = d("none"), [vr, yr] = d(1), [br, xr] = d(!1), [Sr, Cr] = d({}), [wr, Tr] = d(""), [Er, Dr] = d(null), Or = u(!1), kr = JSON.stringify(W.map((e) => ({
606
+ title: e.title,
607
+ startTime: e.startTime
608
+ })));
609
+ c(() => {
610
+ _r(te || s || []);
611
+ }, [(te || s || []).map((e) => `${e.startTime}:${e.title}`).join(",")]), c(() => {
612
+ if (!r || !W || W.length === 0) return;
613
+ Cr({});
614
+ let e = document.createElement("video");
615
+ e.muted = !0, e.preload = "metadata", e.crossOrigin = "anonymous", e.style.cssText = "position:fixed;top:0;left:0;width:10px;height:10px;opacity:0.01;pointer-events:none;z-index:-9999;", document.body.appendChild(e);
616
+ let t = null, i = r.includes(".m3u8"), a = document.createElement("canvas");
617
+ a.width = 160, a.height = 90;
618
+ let o = a.getContext("2d"), s = 0, c = !1, l = () => {
619
+ if (s >= W.length) {
620
+ f();
621
+ return;
622
+ }
623
+ let t = W[s].startTime;
624
+ e.currentTime = t === 0 ? .01 : t;
625
+ }, u = () => {
626
+ if (o && e.readyState >= 2) {
627
+ o.drawImage(e, 0, 0, a.width, a.height);
628
+ let t = a.toDataURL("image/jpeg", .8);
629
+ Cr((e) => ({
630
+ ...e,
631
+ [s]: t
632
+ })), s++, l();
633
+ } else setTimeout(u, 100);
634
+ }, d = () => {
635
+ c || (c = !0, l());
636
+ };
637
+ e.addEventListener("seeked", u), e.addEventListener("canplay", d), i && n.isSupported() ? (t = new n({
638
+ enableWorker: !1,
639
+ maxBufferLength: 5,
640
+ xhrSetup: (e, t) => {
641
+ let n = re?.authToken;
642
+ try {
643
+ let r = ut(t), i = new URL(r, window.location.origin);
644
+ n && i.searchParams.set("token", n), e.open("GET", i.toString(), !0);
645
+ } catch (e) {
646
+ console.error("[WebVideoPlayer tempHls] xhrSetup error:", e);
647
+ }
648
+ }
649
+ }), t.loadSource(ut(r)), t.attachMedia(e)) : e.src = r, e.readyState >= 2 && d();
650
+ let f = () => {
651
+ e.removeEventListener("seeked", u), e.removeEventListener("canplay", d), t && t.destroy(), document.body.contains(e) && document.body.removeChild(e);
652
+ };
653
+ return f;
654
+ }, [r, kr]);
655
+ let [q, Ar] = d(null), [jr, Mr] = d(null), Nr = u(!1), [Pr, Fr] = d(!1), [Ir, Lr] = d(!1), [Rr, zr] = d(null), [Br, Vr] = d(null), [Hr, Ur] = d(0), [Wr, Gr] = d(0), [Kr, qr] = d(null), [Jr, Yr] = d(null), [J, Xr] = d(null);
656
+ c(() => {
657
+ if (vt.current && !vt.current.querySelector("google-cast-launcher")) {
658
+ let e = document.createElement("google-cast-launcher");
659
+ e.style.cursor = "pointer", e.style.width = "100%", e.style.height = "100%", e.style.display = "block", vt.current.appendChild(e);
660
+ }
661
+ }, []), c(() => {
662
+ if (!F) {
663
+ Fr(!1), Lr(!1), zr(null);
664
+ return;
665
+ }
666
+ let e = (e) => Fr(e), t = () => {
667
+ let e = F.getVideoElement(), t = !!e?.webkitCurrentPlaybackTargetIsWireless;
668
+ Lr(t), zr(t ? e.webkitCurrentPlaybackTargetName || "AirPlay device" : null);
669
+ };
670
+ e(F.casting.isAirPlayAvailable()), t();
671
+ let n = F.getVideoElement(), r = (t) => {
672
+ e(t.availability === "available");
673
+ }, i = () => {
674
+ t();
675
+ };
676
+ return "webkitShowPlaybackTargetPicker" in n && (n.addEventListener("webkitplaybacktargetavailabilitychanged", r), n.addEventListener("webkitcurrentplaybacktargetiswirelesschanged", i)), () => {
677
+ "webkitShowPlaybackTargetPicker" in n && (n.removeEventListener("webkitplaybacktargetavailabilitychanged", r), n.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged", i));
678
+ };
679
+ }, [F]);
680
+ let [Zr, Qr] = d(""), [$r, ei] = d(!0), [Y, ti] = d(!1), [ni, ri] = d(!1), ii = u(!1), ai = u(null), oi = u(!1), si = u(!1), ci = u("none"), li = u(h), ui = () => {
681
+ ei(!0), ai.current && window.clearTimeout(ai.current);
682
+ let e = Bt.current ? 3500 : 1e4;
683
+ ai.current = window.setTimeout(() => {
684
+ oi.current && ci.current === "none" && ei(!1);
685
+ }, e);
686
+ }, di = o((e) => {
687
+ At.current &&= (clearTimeout(At.current), null);
688
+ let t = Mt.current, n = t?.[e]?.label ?? "This format", r = t?.[0]?.label ?? "default";
689
+ jt.current = null, Dr(`${n} isn't supported on this device. Switched to ${r}.`), window.setTimeout(() => Dr(null), 4e3), Nt.current?.(0);
690
+ }, []);
691
+ c(() => {
692
+ if (!w.current) return;
693
+ let o = document.createElement("video");
694
+ o.muted = !0, o.preload = "metadata", o.crossOrigin = "anonymous", o.style.cssText = "display:none;position:absolute;pointer-events:none;", document.body.appendChild(o), E.current = o;
695
+ let s = r.includes(".m3u8");
696
+ if (s && n.isSupported()) {
697
+ let e = new n({
698
+ enableWorker: !1,
699
+ maxBufferLength: 5,
700
+ xhrSetup: (e, t) => {
701
+ let n = re?.authToken;
702
+ try {
703
+ let r = ut(t), i = new URL(r, window.location.origin);
704
+ n && i.searchParams.set("token", n), e.open("GET", i.toString(), !0);
705
+ } catch (e) {
706
+ console.error("[WebVideoPlayer hiddenHls] xhrSetup error:", e);
707
+ }
708
+ }
709
+ });
710
+ e.loadSource(ut(r)), e.attachMedia(o), ht.current = e, e.on(n.Events.MANIFEST_LOADED, (e, t) => {
711
+ if (S) return;
712
+ let n = Ae(t?.networkDetails?.responseText ?? "");
713
+ n && Qr(n);
714
+ }), e.on(n.Events.FRAG_PARSING_METADATA, (e, t) => {
715
+ if (!(S || Zr)) for (let e of t?.samples ?? []) {
716
+ let t = je(e.data);
717
+ if (t) {
718
+ Qr(t);
719
+ break;
720
+ }
721
+ }
722
+ });
723
+ } else s && o.canPlayType("application/vnd.apple.mpegurl"), o.src = r;
724
+ o.addEventListener("seeked", () => {
725
+ let e = mt.current;
726
+ if (!e) return;
727
+ let t = e.getContext("2d");
728
+ t && o.readyState >= 2 && (t.drawImage(o, 0, 0, e.width, e.height), qr(e.toDataURL("image/jpeg", .82)));
729
+ });
730
+ let c;
731
+ if (ie) {
732
+ let t = new e(ie);
733
+ dt.current = t, c = t.createCallback();
734
+ }
735
+ if (Xt) return;
736
+ let l = new t({
737
+ container: w.current,
738
+ src: r,
739
+ videoId: ae,
740
+ autoplay: i,
741
+ muted: a,
742
+ keyMoments: W,
743
+ subtitles: h,
744
+ drm: {
745
+ watermarkText: g,
746
+ allowedDomains: [
747
+ "localhost",
748
+ "127.0.0.1",
749
+ window.location.hostname
750
+ ],
751
+ ...re
752
+ },
753
+ analyticsCallback: (e) => {
754
+ if (e.sessionId && (Nn.current === null ? Nn.current = e.sessionId : e.sessionId !== Nn.current && (e = {
755
+ ...e,
756
+ sessionId: Nn.current
757
+ })), e.eventType === "session_start") {
758
+ if (Pn.current) return;
759
+ Pn.current = !0;
760
+ }
761
+ c?.(e), oe && oe(e);
762
+ },
763
+ analyticsSessionSeed: Fn.current?.key === On ? Fn.current.snapshot : void 0,
764
+ watchProgressInterval: Je * 1e3,
765
+ themeColor: _,
766
+ urlTransformer: et
767
+ });
768
+ l.on("keymomentsloaded", (e) => {
769
+ _r(e), ce && ce(e);
770
+ }), l.on("chaptersloaded", (e) => {
771
+ _r(e), ce && ce(e);
772
+ }), l.on("play", () => {
773
+ nn(!0), Tn(!1), ee(l.getCurrentTime(), !1);
774
+ }), l.on("pause", () => {
775
+ nn(!1), ee(l.getCurrentTime(), !0);
776
+ }), l.on("ended", () => {
777
+ nn(!1), Tn(!0);
778
+ });
779
+ let u = () => {
780
+ bt.current = !0, fn(!1), j.current && (j.current.style.opacity = "1"), St(l.getVideoElement());
781
+ }, d = () => {
782
+ requestAnimationFrame(() => {
783
+ requestAnimationFrame(() => {
784
+ bt.current = !1, j.current && (j.current.style.opacity = "0"), Ct(l.getVideoElement());
785
+ let e = l.getVideoElement();
786
+ e && !e.paused && e.readyState < 3 && fn(!0);
787
+ });
788
+ });
789
+ }, f = (e, t = !1) => {
790
+ D.current = !0;
791
+ let n = t ? e + .5 : Et.current ?? e + .5;
792
+ t || (Et.current = null), Tt.current = t, O.current = n, k.current = l.getCurrentTime(), u(), l.seek(n);
793
+ let r = l.getVideoElement();
794
+ if (r) {
795
+ let e = () => {
796
+ r.removeEventListener("seeked", e), A.current &&= (window.clearTimeout(A.current), null), D.current = !1, O.current = null, k.current = null;
797
+ let t = Tt.current;
798
+ Tt.current = !1, (t || Et.current === null) && d();
799
+ };
800
+ r.addEventListener("seeked", e);
801
+ }
802
+ A.current && window.clearTimeout(A.current), A.current = window.setTimeout(() => {
803
+ D.current = !1, O.current = null, k.current = null, A.current = null, Tt.current = !1, d();
804
+ }, 3e3);
805
+ };
806
+ wt.current = f;
807
+ let ee = (e, t) => {
808
+ if (!("mediaSession" in navigator) || !navigator.mediaSession.setPositionState) return;
809
+ navigator.mediaSession.playbackState = t ? "paused" : "playing";
810
+ let n = l.getDuration(), r = z.current.find((t) => e >= t.startTime && e < t.endTime);
811
+ if (r) {
812
+ let t = r.endTime - r.startTime, n = Math.max(0, e - r.startTime);
813
+ if (t > 0) try {
814
+ navigator.mediaSession.setPositionState({
815
+ duration: t,
816
+ playbackRate: 1,
817
+ position: Math.min(n, t)
818
+ });
819
+ } catch {}
820
+ } else {
821
+ let t = z.current.reduce((e, t) => e + (t.endTime - t.startTime), 0), r = n > 0 ? Math.max(0, n - t) : 0, i = e;
822
+ for (let t of z.current) e >= t.endTime ? i -= t.endTime - t.startTime : e >= t.startTime && (i -= e - t.startTime);
823
+ i = Math.max(0, i);
824
+ let a = z.current.length > 0 && r > 0 ? r : n;
825
+ if (a > 0) try {
826
+ navigator.mediaSession.setPositionState({
827
+ duration: a,
828
+ playbackRate: 1,
829
+ position: Math.min(i, a)
830
+ });
831
+ } catch {}
832
+ }
833
+ };
834
+ if (l.on("timeupdate", (e) => {
835
+ if (!D.current && N.current === null) {
836
+ let t = z.current.find((t) => Dn.current.has(t.startTime) && e >= t.startTime - .5 && e < t.endTime);
837
+ if (t) {
838
+ f(t.endTime);
839
+ return;
840
+ }
841
+ Et.current !== null && z.current.find((t) => e >= t.endTime - .5 && e < t.endTime) && u();
842
+ }
843
+ if (D.current && O.current !== null) {
844
+ let t = O.current;
845
+ if (k.current !== null && t < k.current ? e <= t + 2 && e >= t - 2 : e >= t - 2) {
846
+ D.current = !1, O.current = null, k.current = null, A.current &&= (window.clearTimeout(A.current), null);
847
+ let t = z.current.some((t) => e >= t.startTime && e < t.endTime), n = Tt.current;
848
+ Tt.current = !1, (n || !t && Et.current === null) && d();
849
+ } else return;
850
+ }
851
+ rn(e), It.current = e;
852
+ let t = l.getDuration();
853
+ if (on(t), N.current !== null && e >= N.current - 2) {
854
+ N.current = null, P.current &&= (window.clearTimeout(P.current), null);
855
+ let t = z.current.find((t) => Dn.current.has(t.startTime) && e >= t.startTime && e < t.endTime);
856
+ t && f(t.endTime), requestAnimationFrame(() => {
857
+ requestAnimationFrame(() => {
858
+ M.current && (M.current.style.opacity = "0");
859
+ });
860
+ });
861
+ }
862
+ if (!Pt.current && Ot.current === null && ct && ct > 0 && t > 0 && ct < t) {
863
+ Pt.current = !0;
864
+ let e = z.current.find((e) => ct >= e.startTime && ct < e.endTime), t = e ? e.startTime : ct;
865
+ Ft.current = e ? null : ct, N.current = t, l.seek(t), P.current && window.clearTimeout(P.current), P.current = window.setTimeout(() => {
866
+ N.current = null, P.current = null, M.current && (M.current.style.opacity = "0");
867
+ }, 4e3);
868
+ }
869
+ if (lt?.(e), Hn.current.length > 0) if (Un.current) {
870
+ let t = Un.current;
871
+ (e >= t.startTimeSeconds + t.durationSeconds || e < t.startTimeSeconds) && (Vn(null), Un.current = null);
872
+ } else {
873
+ let t = Hn.current.find((t) => e >= t.startTimeSeconds && e < t.startTimeSeconds + t.durationSeconds && !Wn.current.has(t.availId));
874
+ t && (Vn(t), Un.current = t, t.impressionBeacons.forEach((e) => {
875
+ fetch(e, { mode: "no-cors" }).catch(() => {});
876
+ }));
877
+ }
878
+ let n = l.keyMoments.getCurrentMoment(e);
879
+ gr({
880
+ chapter: n.keyMoment,
881
+ index: n.index
882
+ }), ee(e, l.getVideoElement().paused);
883
+ }), l.on("qualitylevels", (e) => {
884
+ rr(e);
885
+ let t = kt.current;
886
+ if (!t) return;
887
+ let n = t.qualityHeight === null ? void 0 : e.find((e) => e.height === t.qualityHeight);
888
+ n ? (l.setQuality(n.id), ar(n)) : ar({
889
+ id: -1,
890
+ height: 0,
891
+ width: 0,
892
+ bitrate: 0,
893
+ label: "Auto"
894
+ });
895
+ }), l.on("qualitychange", (e) => {
896
+ ar(e);
897
+ }), l.on("buffering", (e) => {
898
+ if (fn(e && !bt.current), !e) {
899
+ At.current &&= (clearTimeout(At.current), null), jt.current = null;
900
+ let e = kt.current;
901
+ if (e && (kt.current = null, e.playbackRate !== 1 && l.setPlaybackRate(e.playbackRate), l.setVolume(e.volume), l.setMute(e.muted)), Ot.current !== null) {
902
+ let e = Ot.current;
903
+ Ot.current = null, Pt.current = !0, N.current = e, P.current && window.clearTimeout(P.current), P.current = window.setTimeout(() => {
904
+ N.current = null, P.current = null, M.current && (M.current.style.opacity = "0");
905
+ }, 4e3), l.seek(e);
906
+ }
907
+ }
908
+ }), l.on("adbreakchange", (e) => {
909
+ if (l.analytics.setAdBreak(e, l.getVideoElement()), se && se(e), e) {
910
+ let e = l.getCurrentTime(), t = z.current.find((t) => e >= t.startTime && e < t.endTime);
911
+ if (ii.current = !1, ri(!1), t && Dn.current.has(t.startTime)) {
912
+ u(), D.current || f(t.endTime);
913
+ return;
914
+ }
915
+ t && (In.current = t.startTime), ti(!0), K("none"), d();
916
+ } else if (In.current !== null && (Dn.current.add(In.current), An(new Set(Dn.current)), In.current = null), ti(!1), Et.current !== null) {
917
+ let e = Et.current;
918
+ Et.current = null, D.current = !0, O.current = e, k.current = l.getCurrentTime(), u(), l.seek(e), A.current && window.clearTimeout(A.current), A.current = window.setTimeout(() => {
919
+ D.current = !1, O.current = null, k.current = null, A.current = null, d();
920
+ }, 3e3);
921
+ }
922
+ }), l.on("adbreaksloaded", (e) => {
923
+ z.current = e, En(e);
924
+ let t = Ft.current;
925
+ if (t === null) return;
926
+ Ft.current = null;
927
+ let n = e.find((e) => t >= e.startTime && t < e.endTime);
928
+ if (!n || Dn.current.has(n.startTime)) return;
929
+ let r = l.getCurrentTime();
930
+ r < n.startTime || r >= n.endTime || (M.current && (M.current.style.opacity = "1"), N.current = n.startTime, P.current && window.clearTimeout(P.current), P.current = window.setTimeout(() => {
931
+ N.current = null, P.current = null, M.current && (M.current.style.opacity = "0");
932
+ }, 4e3), l.seek(n.startTime));
933
+ }), l.on("volumechange", (e) => {
934
+ cn(e.volume), xt.current === null && un(e.muted);
935
+ }), l.on("pipchange", (e) => {
936
+ xn(e);
937
+ }), l.on("error", () => {
938
+ Qt(!0), fn(!1), N.current = null, P.current &&= (window.clearTimeout(P.current), null), M.current && (M.current.style.opacity = "0");
939
+ }), l.on("unsupportedcodec", () => {
940
+ let e = jt.current;
941
+ e && e.targetIdx !== 0 && (Mt.current?.length ?? 0) > 1 && di(e.targetIdx);
942
+ }), l.subtitles.onSubtitleChange((e) => {
943
+ sr(e);
944
+ }), l.on("subtitlesloaded", (e) => {
945
+ if (!I.enableSubtitles) return;
946
+ ur(Le([...e]));
947
+ let t = kt.current;
948
+ if (t) {
949
+ let n = t.subtitleId === "off" ? "off" : e.find((e) => e.id === t.subtitleId)?.id ?? (t.subtitleLang ? e.find((e) => e.lang === t.subtitleLang)?.id : void 0);
950
+ if (n) {
951
+ l.subtitles.setActiveTrack(n), cr(n);
952
+ return;
953
+ }
954
+ }
955
+ let n = e.find((e) => e.isDefault);
956
+ n && (l.subtitles.setActiveTrack(n.id), cr(n.id));
957
+ }), l.on("audiotracksloaded", (e) => {
958
+ fr(e);
959
+ let t = kt.current, n = t ? e.find((e) => t.audioLang && e.lang === t.audioLang) ?? e.find((e) => t.audioLabel && e.label === t.audioLabel) : void 0;
960
+ if (n) {
961
+ l.setAudioTrack(n.id), mr(n.id);
962
+ return;
963
+ }
964
+ mr(e[0]?.id ?? 0);
965
+ }), l.on("audiotrackchange", (e) => {
966
+ mr(e);
967
+ }), l.casting.onCastStateChange((e, t) => {
968
+ if (e) {
969
+ Nr.current = l.isMuted(), l.pause();
970
+ let e = l.getVideoElement();
971
+ e.muted = !0, Ar(t);
972
+ } else {
973
+ let e = l.casting.getRemoteState();
974
+ e && e.currentTime > 0 && (D.current = !0, O.current = e.currentTime, k.current = l.getCurrentTime(), l.seek(e.currentTime), A.current && window.clearTimeout(A.current), A.current = window.setTimeout(() => {
975
+ D.current = !1, O.current = null, k.current = null, A.current = null;
976
+ }, 3e3));
977
+ let t = l.getVideoElement();
978
+ t.muted = Nr.current, Ar(null), Mr(null);
979
+ }
980
+ }), l.casting.onRemoteStateChange((e) => {
981
+ Mr(e);
982
+ }), cn(l.getVolume()), un(l.isMuted()), "mediaSession" in navigator) try {
983
+ navigator.mediaSession.setActionHandler("seekto", (e) => {
984
+ if (e.seekTime == null || si.current || ii.current) return;
985
+ let t = e.seekTime;
986
+ for (let e of z.current) t >= e.startTime && (t += e.endTime - e.startTime);
987
+ Dt.current?.(t);
988
+ });
989
+ let e = (e, t) => {
990
+ if (si.current || ii.current) return;
991
+ let n = t && t > 0 ? t : 10, r = l.getCurrentTime(), i = r;
992
+ for (let e of z.current) r >= e.endTime ? i -= e.endTime - e.startTime : r >= e.startTime && (i -= r - e.startTime);
993
+ if (e) {
994
+ let e = z.current.reduce((e, t) => e + (t.endTime - t.startTime), 0), t = Math.max(0, l.getDuration() - e), r = Math.min(t, i + n);
995
+ for (let e of z.current) r >= e.startTime && (r += e.endTime - e.startTime);
996
+ Dt.current?.(r, {
997
+ eventType: "fast_forward",
998
+ skipSeconds: n
999
+ });
1000
+ } else {
1001
+ let e = Math.max(0, i - n);
1002
+ for (let t of z.current) e >= t.startTime && (e += t.endTime - t.startTime);
1003
+ Dt.current?.(e, {
1004
+ eventType: "fast_backward",
1005
+ skipSeconds: n
1006
+ });
1007
+ }
1008
+ };
1009
+ navigator.mediaSession.setActionHandler("seekforward", (t) => e(!0, t.seekOffset ?? void 0)), navigator.mediaSession.setActionHandler("seekbackward", (t) => e(!1, t.seekOffset ?? void 0));
1010
+ } catch {}
1011
+ let p = l.getVideoElement(), m = () => {
1012
+ if (!(document.pictureInPictureElement === p || p.webkitPresentationMode === "picture-in-picture") || D.current || N.current !== null || Ot.current !== null) return;
1013
+ let e = p.currentTime, t = It.current;
1014
+ if (!(Math.abs(e - t) < .5)) {
1015
+ if (si.current) {
1016
+ p.currentTime = t;
1017
+ return;
1018
+ }
1019
+ p.currentTime = t, Dt.current?.(e);
1020
+ }
1021
+ };
1022
+ p.addEventListener("seeking", m), Wt(l);
1023
+ let te = jt.current;
1024
+ te && te.targetIdx !== 0 && (At.current && clearTimeout(At.current), At.current = setTimeout(() => {
1025
+ At.current = null, !l.getBufferedRanges().some((e) => e.end > e.start) && di(te.targetIdx);
1026
+ }, De)), Ot.current !== null && (P.current && window.clearTimeout(P.current), P.current = window.setTimeout(() => {
1027
+ P.current = null, N.current = null, M.current && (M.current.style.opacity = "0"), fn(!1);
1028
+ }, 12e3)), qe && w.current && (ft.current = !0, w.current.requestFullscreen().catch(() => {
1029
+ ft.current = !1;
1030
+ }));
1031
+ let ne = () => {
1032
+ let e = document, t = !!(document.fullscreenElement || e.webkitFullscreenElement);
1033
+ mn(t), t || gn(!1);
1034
+ let n = l.getVideoElement();
1035
+ l.analytics.track(t ? "fullscreen_enter" : "fullscreen_exit", n);
1036
+ };
1037
+ document.addEventListener("fullscreenchange", ne), document.addEventListener("webkitfullscreenchange", ne);
1038
+ let v = (e) => {
1039
+ let t = document.activeElement;
1040
+ if (!(t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.getAttribute("contenteditable") === "true" || t.getAttribute("role") === "slider"))) {
1041
+ switch (e.key.toLowerCase()) {
1042
+ case " ":
1043
+ case "k":
1044
+ if (e.preventDefault(), l.getVideoElement().paused) l.play();
1045
+ else {
1046
+ l.pause();
1047
+ try {
1048
+ let e = l.getVideoElement();
1049
+ e && !e.paused && e.pause();
1050
+ } catch {}
1051
+ if (E.current && !E.current.paused) try {
1052
+ E.current.pause();
1053
+ } catch {}
1054
+ }
1055
+ break;
1056
+ case "arrowleft":
1057
+ case "j":
1058
+ if (e.preventDefault(), !si.current) {
1059
+ let e = l.getCurrentTime(), t = e;
1060
+ for (let n of z.current) e >= n.endTime ? t -= n.endTime - n.startTime : e >= n.startTime && (t -= e - n.startTime);
1061
+ let n = Math.max(0, t - 10);
1062
+ for (let e of z.current) n >= e.startTime && (n += e.endTime - e.startTime);
1063
+ Dt.current?.(n, {
1064
+ eventType: "fast_backward",
1065
+ skipSeconds: 10
1066
+ });
1067
+ }
1068
+ break;
1069
+ case "arrowright":
1070
+ case "l":
1071
+ if (e.preventDefault(), !si.current) {
1072
+ let e = l.getCurrentTime(), t = z.current.reduce((e, t) => e + (t.endTime - t.startTime), 0), n = Math.max(0, l.getDuration() - t), r = e;
1073
+ for (let t of z.current) e >= t.endTime ? r -= t.endTime - t.startTime : e >= t.startTime && (r -= e - t.startTime);
1074
+ let i = Math.min(n, r + 10);
1075
+ for (let e of z.current) i >= e.startTime && (i += e.endTime - e.startTime);
1076
+ Dt.current?.(i, {
1077
+ eventType: "fast_forward",
1078
+ skipSeconds: 10
1079
+ });
1080
+ }
1081
+ break;
1082
+ case "arrowup":
1083
+ e.preventDefault(), l.setVolume(l.getVolume() + .1);
1084
+ break;
1085
+ case "arrowdown":
1086
+ e.preventDefault(), l.setVolume(l.getVolume() - .1);
1087
+ break;
1088
+ case "m":
1089
+ e.preventDefault(), l.setMute(!l.isMuted());
1090
+ break;
1091
+ case "f":
1092
+ e.preventDefault(), yt.current();
1093
+ break;
1094
+ case "p":
1095
+ e.preventDefault(), si.current || l.togglePictureInPicture();
1096
+ break;
1097
+ case "c":
1098
+ if (e.preventDefault(), I.enableSubtitles && !si.current) if (l.subtitles.getActiveTrackId() !== "off") l.subtitles.setActiveTrack("off"), cr("off");
1099
+ else {
1100
+ let e = li.current;
1101
+ e && e.length > 0 && (l.subtitles.setActiveTrack(e[0].id), cr(e[0].id));
1102
+ }
1103
+ break;
1104
+ default: return;
1105
+ }
1106
+ ui();
1107
+ }
1108
+ };
1109
+ return document.addEventListener("keydown", v), ui(), () => {
1110
+ if (Fn.current = {
1111
+ key: On,
1112
+ snapshot: l.analytics.getSessionSnapshot()
1113
+ }, Lt.current) {
1114
+ let e = Lt.current, t = l.getVideoElement();
1115
+ w.current && t.ownerDocument !== document && (t.classList.remove("gb-pip-video"), w.current.insertBefore(t, w.current.firstChild)), Lt.current = null, Cn(null), xn(!1), e.close();
1116
+ }
1117
+ if (l.destroy(), dt.current?.destroy(), dt.current = null, document.body.style.overflow = "", document.body.style.touchAction = "", document.removeEventListener("fullscreenchange", ne), document.removeEventListener("webkitfullscreenchange", ne), document.removeEventListener("keydown", v), ai.current && window.clearTimeout(ai.current), A.current &&= (window.clearTimeout(A.current), null), At.current &&= (clearTimeout(At.current), null), bt.current = !1, j.current && (j.current.style.opacity = "0"), p.removeEventListener("seeking", m), "mediaSession" in navigator) {
1118
+ try {
1119
+ navigator.mediaSession.setActionHandler("seekto", null);
1120
+ } catch {}
1121
+ try {
1122
+ navigator.mediaSession.setActionHandler("seekforward", null);
1123
+ } catch {}
1124
+ try {
1125
+ navigator.mediaSession.setActionHandler("seekbackward", null);
1126
+ } catch {}
1127
+ }
1128
+ ht.current &&= (ht.current.destroy(), null), E.current &&= (document.body.removeChild(E.current), null), Pt.current = !1, N.current = null, P.current &&= (window.clearTimeout(P.current), null);
1129
+ };
1130
+ }, [
1131
+ r,
1132
+ g,
1133
+ $t
1134
+ ]), c(() => {
1135
+ if (F) {
1136
+ F.keyMoments.setKeyMoments(W);
1137
+ let e = w.current?.querySelector("video");
1138
+ if (e) {
1139
+ let t = F.keyMoments.getCurrentMoment(e.currentTime);
1140
+ gr({
1141
+ chapter: t.keyMoment,
1142
+ index: t.index
1143
+ });
1144
+ }
1145
+ }
1146
+ }, [kr, F]), c(() => {
1147
+ let e = (e) => {
1148
+ G !== "none" && (e.target.closest(".sdk-menu-container") || K("none"));
1149
+ };
1150
+ return document.addEventListener("click", e), () => {
1151
+ document.removeEventListener("click", e);
1152
+ };
1153
+ }, [G]), c(() => {
1154
+ oi.current = tn;
1155
+ }, [tn]), c(() => {
1156
+ si.current = Y;
1157
+ }, [Y]), c(() => {
1158
+ ii.current = ni;
1159
+ }, [ni]);
1160
+ let X = Y || ni;
1161
+ c(() => {
1162
+ Lt.current = Sn;
1163
+ }, [Sn]), c(() => {
1164
+ ci.current = G;
1165
+ }, [G]), c(() => {
1166
+ if (!Y || !F) return;
1167
+ let e = 0, t = F.getCurrentTime(), n = performance.now(), r = () => {
1168
+ let i = F.getVideoElement?.(), a = F.getCurrentTime(), o = performance.now(), s;
1169
+ if (a !== t) t = a, n = o, s = a;
1170
+ else if (i && !i.paused && !i.ended) {
1171
+ let e = i.playbackRate || 1;
1172
+ s = t + (o - n) / 1e3 * e;
1173
+ } else s = t;
1174
+ let c = $n(a);
1175
+ if (c) {
1176
+ let e = Math.min(s, a + .4, c.end), t = Math.min(100, Math.max(0, (e - c.start) / (c.end - c.start) * 100));
1177
+ (w.current?.querySelectorAll(".sdk-ad-progress-fill"))?.forEach((e) => {
1178
+ e.style.width = `${t}%`;
1179
+ });
1180
+ }
1181
+ e = requestAnimationFrame(r);
1182
+ };
1183
+ return e = requestAnimationFrame(r), () => cancelAnimationFrame(e);
1184
+ }, [Y, F]), c(() => {
1185
+ li.current = lr;
1186
+ }, [lr]), c(() => {
1187
+ Bt.current = Rt;
1188
+ }, [Rt]), c(() => {
1189
+ z.current = R;
1190
+ }, [R]), c(() => {
1191
+ Hn.current = Rn;
1192
+ }, [Rn]), c(() => {
1193
+ Un.current = Bn;
1194
+ }, [Bn]), c(() => {
1195
+ qn.current = Gn;
1196
+ }, [Gn]), c(() => {
1197
+ Mt.current = C;
1198
+ }, [C]), c(() => {
1199
+ let e = Jn.current;
1200
+ if (!Y || !e || typeof ResizeObserver > "u") return;
1201
+ let t = () => {
1202
+ let t = e.getBoundingClientRect();
1203
+ Xn((e) => e.w === t.width && e.h === t.height ? e : {
1204
+ w: t.width,
1205
+ h: t.height
1206
+ });
1207
+ };
1208
+ t();
1209
+ let n = new ResizeObserver(t);
1210
+ return n.observe(e), () => n.disconnect();
1211
+ }, [Y, Gn]), c(() => {
1212
+ Nt.current = st;
1213
+ }, [st]), c(() => {
1214
+ In.current = null, Ln.current = !1, Et.current = null, Ft.current = null, Vn(null), Un.current = null, Wn.current = /* @__PURE__ */ new Set(), Qt(!1);
1215
+ }, [r]), c(() => {
1216
+ Kt(!1);
1217
+ }, [r]), c(() => {
1218
+ if (!F) return;
1219
+ let e = F.getVideoElement();
1220
+ if (e && e.readyState >= 1) {
1221
+ Kt(!0);
1222
+ return;
1223
+ }
1224
+ let t = () => Kt(!0);
1225
+ return F.on("qualitylevels", t), e?.addEventListener("loadedmetadata", t), () => {
1226
+ F.off("qualitylevels", t), e?.removeEventListener("loadedmetadata", t);
1227
+ };
1228
+ }, [F]), c(() => {
1229
+ if (zn([]), !(!it || !Gt)) return He(it, (e) => {
1230
+ let t = /* @__PURE__ */ new Set(), n = [];
1231
+ for (let r of e.nonLinearAvails ?? []) {
1232
+ if (t.has(r.availId)) continue;
1233
+ t.add(r.availId);
1234
+ let e = r.nonLinearAdsList?.[0], i = e?.nonLinearAdList?.[0];
1235
+ if (!i?.staticResource) continue;
1236
+ let a = (e?.trackingEvents ?? []).filter((e) => e.eventType === "impression").flatMap((e) => e.beaconUrls ?? []), o = {};
1237
+ try {
1238
+ o = JSON.parse(i.adParameters ?? "{}");
1239
+ } catch {}
1240
+ let s = o.position ?? "bottom_center";
1241
+ n.push({
1242
+ availId: r.availId,
1243
+ startTimeSeconds: Re(r.startTime ?? ""),
1244
+ durationSeconds: Re(i.minSuggestedDuration ?? "00:00:15"),
1245
+ imageUrl: i.staticResource,
1246
+ imageWidth: parseInt(i.width ?? "320", 10),
1247
+ imageHeight: parseInt(i.height ?? "50", 10),
1248
+ title: i.adTitle ?? "",
1249
+ clickThrough: ze(i.clickThrough) ? i.clickThrough : "",
1250
+ clickTrackingUrl: i.clickTracking ?? "",
1251
+ impressionBeacons: a,
1252
+ position: s,
1253
+ dismissible: o.dismissible === !0
1254
+ });
1255
+ }
1256
+ return n.length > 0 ? n : null;
1257
+ }, zn);
1258
+ }, [
1259
+ it,
1260
+ r,
1261
+ Gt
1262
+ ]), c(() => {
1263
+ if (Kn([]), Qn([]), !(!at || !Gt)) return He(at, (e) => {
1264
+ let t = [], n = [];
1265
+ for (let r of e.avails ?? []) {
1266
+ let e = r.ads ?? [];
1267
+ if (e.length === 0) continue;
1268
+ let i = r.startTimeInSeconds ?? e[0].startTimeInSeconds ?? 0, a = e[e.length - 1], o = (a?.startTimeInSeconds ?? i) + (a?.durationInSeconds ?? 0);
1269
+ n.push({
1270
+ startTime: i,
1271
+ endTime: r.durationInSeconds == null ? Math.max(o, i) : i + r.durationInSeconds
1272
+ }), e.forEach((n, r) => {
1273
+ let i = Be(n?.skipOffset), a = i !== null, o = {};
1274
+ try {
1275
+ o = JSON.parse(n?.adParameters ?? "{}");
1276
+ } catch {}
1277
+ let s = o.ctaText && ze(o.redirectUrl) ? {
1278
+ text: o.ctaText,
1279
+ url: o.redirectUrl,
1280
+ title: o.title || void 0,
1281
+ description: o.description || void 0
1282
+ } : null, c = n.startTimeInSeconds ?? 0, l = n.durationInSeconds ?? 0;
1283
+ t.push({
1284
+ startTimeSeconds: c,
1285
+ endTimeSeconds: c + l,
1286
+ durationSeconds: l,
1287
+ skippable: a,
1288
+ skipOffsetSeconds: i ?? 0,
1289
+ cta: s,
1290
+ podIndex: r,
1291
+ podTotal: e.length
1292
+ });
1293
+ });
1294
+ }
1295
+ return t.length > 0 ? {
1296
+ pods: t,
1297
+ breaks: n
1298
+ } : null;
1299
+ }, ({ pods: e, breaks: t }) => {
1300
+ Kn(e), Qn(t);
1301
+ });
1302
+ }, [
1303
+ at,
1304
+ r,
1305
+ Gt
1306
+ ]), c(() => {
1307
+ !F || Zn.length === 0 || F.setAdBreaks(Zn);
1308
+ }, [F, Zn]), c(() => {
1309
+ if (!F) return;
1310
+ let e = () => {
1311
+ document.hidden ? tt && si.current && oi.current && (F.pause(), Ln.current = !0) : Ln.current &&= (F.play(), !1);
1312
+ };
1313
+ return document.addEventListener("visibilitychange", e), () => {
1314
+ document.removeEventListener("visibilitychange", e);
1315
+ };
1316
+ }, [F, tt]);
1317
+ let fi = () => {
1318
+ ui();
1319
+ }, pi = () => {
1320
+ qe && !ft.current && w.current && (ft.current = !0, w.current.requestFullscreen().catch(() => {}));
1321
+ }, mi = () => {
1322
+ if (F) {
1323
+ if (q) {
1324
+ F.casting.remotePlayPause(), ui();
1325
+ return;
1326
+ }
1327
+ if (wn) Z(0), pi(), F.play(), Tn(!1);
1328
+ else if (tn) {
1329
+ F.pause();
1330
+ try {
1331
+ let e = F.getVideoElement?.();
1332
+ e && !e.paused && e.pause();
1333
+ } catch {}
1334
+ if (w.current && w.current.querySelectorAll("video").forEach((e) => {
1335
+ try {
1336
+ e.pause();
1337
+ } catch {}
1338
+ }), E.current && !E.current.paused) try {
1339
+ E.current.pause();
1340
+ } catch {}
1341
+ } else pi(), F.play();
1342
+ ui();
1343
+ }
1344
+ }, hi = (e) => {
1345
+ if (!T.current || !F || B === 0) return 0;
1346
+ let t = T.current.getBoundingClientRect();
1347
+ return H(Math.max(0, Math.min(1, (e.clientX - t.left) / t.width)) * B);
1348
+ }, gi = (e) => {
1349
+ if (!F || Y || ni) return;
1350
+ _t.current = !0, Xr(hi(e));
1351
+ let t = (e) => {
1352
+ if (!_t.current || !T.current) return;
1353
+ let t = T.current.getBoundingClientRect(), n = H(Math.max(0, Math.min(1, (e.clientX - t.left) / t.width)) * B);
1354
+ Xr(n), Vr(e.clientX - t.left), Gr(n), E.current && (E.current.currentTime = n), ui();
1355
+ }, n = (e) => {
1356
+ if (_t.current = !1, T.current) {
1357
+ let t = T.current.getBoundingClientRect();
1358
+ Z(H(Math.max(0, Math.min(1, (e.clientX - t.left) / t.width)) * B));
1359
+ }
1360
+ Xr(null), Vr(null), qr(null), Yr(null), document.removeEventListener("mousemove", t), document.removeEventListener("mouseup", n);
1361
+ };
1362
+ document.addEventListener("mousemove", t), document.addEventListener("mouseup", n);
1363
+ }, Z = (e, t) => {
1364
+ if (!F) return;
1365
+ if (Ft.current = null, q) {
1366
+ F.casting.remoteSeek(e);
1367
+ return;
1368
+ }
1369
+ let n = Math.max(0, an > 0 ? Math.min(e, an) : e);
1370
+ if (t) {
1371
+ let { eventType: e, ...n } = t;
1372
+ F.attributeNextSeek(e, n);
1373
+ }
1374
+ let r = F.getCurrentTime();
1375
+ if (n > r && z.current.length > 0) {
1376
+ let e = z.current.filter((e) => e.startTime < n && e.endTime > r && !Dn.current.has(e.startTime)).sort((e, t) => e.startTime - t.startTime);
1377
+ if (e.length > 0) {
1378
+ Et.current = n;
1379
+ let t = e[e.length - 1], i = Math.max(t.startTime, r);
1380
+ D.current = !0, O.current = i, k.current = r, rn(i), ii.current = !0, ri(!0), j.current && (j.current.style.opacity = "1"), St(F.getVideoElement()), F.seek(i), A.current && window.clearTimeout(A.current), A.current = window.setTimeout(() => {
1381
+ D.current = !1, ii.current = !1, ri(!1), O.current = null, k.current = null, A.current = null, bt.current = !1, j.current && (j.current.style.opacity = "0"), Ct(F.getVideoElement());
1382
+ }, 3e3);
1383
+ return;
1384
+ }
1385
+ }
1386
+ Et.current = null;
1387
+ let i = z.current.find((e) => Dn.current.has(e.startTime) && n >= e.startTime - .5 && n < e.endTime + 2), a = i ? Math.max(n, i.endTime + .5) : n;
1388
+ D.current = !0, O.current = a, k.current = r, rn(a), bt.current = !1, j.current && (j.current.style.opacity = "0"), Ct(F.getVideoElement()), F.seek(a), A.current && window.clearTimeout(A.current), A.current = window.setTimeout(() => {
1389
+ D.current = !1, O.current = null, k.current = null, A.current = null, bt.current = !1, j.current && (j.current.style.opacity = "0");
1390
+ }, 3e3);
1391
+ };
1392
+ Dt.current = Z;
1393
+ let _i = () => {
1394
+ if (!F) return;
1395
+ if (q) {
1396
+ F.casting.remoteSetMute(!(jr?.isMuted ?? !1));
1397
+ return;
1398
+ }
1399
+ let e = !ln;
1400
+ F.setMute(e), un(e);
1401
+ }, vi = (e) => {
1402
+ F && (F.setPlaybackRate(e), yr(e), K("none"), Tr(`Playback speed: ${e === 1 ? "Normal" : `${e}x`}`));
1403
+ }, yi = (e) => {
1404
+ if (!F) return;
1405
+ F.setQuality(e);
1406
+ let t = nr.find((t) => t.id === e);
1407
+ t && (ar(t), Tr(`Quality: ${t.label}`)), K("none");
1408
+ }, bi = (e) => {
1409
+ if (F) if (F.subtitles.setActiveTrack(e), cr(e), K("none"), e === "off") Tr("Captions off");
1410
+ else {
1411
+ let t = lr.find((t) => t.id === e);
1412
+ Tr(`Captions: ${t ? x(t) : "on"}`);
1413
+ }
1414
+ }, xi = (e) => {
1415
+ if (F) {
1416
+ if (At.current &&= (clearTimeout(At.current), null), Dr(null), M.current && (M.current.style.opacity = "1"), fn(!0), jt.current === null) {
1417
+ Ot.current = F.getCurrentTime();
1418
+ let e = lr.find((e) => e.id === U), t = dr.find((e) => e.id === pr);
1419
+ kt.current = {
1420
+ playbackRate: vr,
1421
+ volume: sn,
1422
+ muted: ln,
1423
+ subtitleId: U,
1424
+ subtitleLang: e?.lang ?? null,
1425
+ audioLang: t && pr !== 0 ? t.lang : null,
1426
+ audioLabel: t && pr !== 0 ? t.label : null,
1427
+ qualityHeight: ir.id === -1 ? null : ir.height
1428
+ };
1429
+ }
1430
+ jt.current = { targetIdx: e }, K("none"), Tr(`Source: ${C?.[e]?.label ?? ""}`), st?.(e);
1431
+ }
1432
+ }, Si = (e, t) => {
1433
+ Z(e, {
1434
+ eventType: "key_moments",
1435
+ momentTitle: t?.title ?? "",
1436
+ momentTime: e
1437
+ }), K("none");
1438
+ }, Ci = o(() => {
1439
+ if (!Lt.current) return;
1440
+ let e = F?.getVideoElement?.();
1441
+ e && w.current && e.ownerDocument !== document && (e.classList.remove("gb-pip-video"), e.style.objectFit = "", w.current.insertBefore(e, w.current.firstChild)), Lt.current = null, Cn(null), xn(!1);
1442
+ }, [F]), wi = async () => {
1443
+ if (!F) return;
1444
+ let e = window.documentPictureInPicture;
1445
+ if (!e) {
1446
+ F.togglePictureInPicture();
1447
+ return;
1448
+ }
1449
+ if (Lt.current) {
1450
+ Lt.current.close();
1451
+ return;
1452
+ }
1453
+ try {
1454
+ let t = F.getVideoElement(), n = t.videoWidth && t.videoHeight ? t.videoWidth / t.videoHeight : 16 / 9, r = await e.requestWindow({
1455
+ width: 360,
1456
+ height: Math.round(360 / n)
1457
+ }), i = r.document.createElement("style");
1458
+ i.textContent = ke, r.document.head.appendChild(i), t.classList.add("gb-pip-video"), r.document.body.appendChild(t), r.addEventListener("pagehide", () => Ci(), { once: !0 }), Lt.current = r, Cn(r), xn(!0);
1459
+ } catch (e) {
1460
+ console.error("[PlayerSDK PiP] Failed to open custom Picture-in-Picture window:", e);
1461
+ }
1462
+ }, Ti = (e) => {
1463
+ if (Y || ni) return;
1464
+ let t = e.currentTarget.getBoundingClientRect();
1465
+ Z(H(Math.max(0, Math.min(1, (e.clientX - t.left) / t.width)) * B));
1466
+ }, Ei = () => {
1467
+ if (!w.current) return;
1468
+ let e = w.current, t = document, n = e, r = !!(document.fullscreenElement || t.webkitFullscreenElement), i = () => {
1469
+ gn(!0), mn(!0), document.body.style.overflow = "hidden", document.body.style.touchAction = "none", F?.analytics.track("fullscreen_enter", F.getVideoElement());
1470
+ }, a = () => {
1471
+ gn(!1), mn(!1), document.body.style.overflow = "", document.body.style.touchAction = "", F?.analytics.track("fullscreen_exit", F.getVideoElement());
1472
+ };
1473
+ if (r || hn) vn(!1), document.fullscreenElement ? document.exitFullscreen() : t.webkitFullscreenElement ? t.webkitExitFullscreen?.() : a();
1474
+ else {
1475
+ vn(Bt.current);
1476
+ let t = e.requestFullscreen?.bind(e) ?? n.webkitRequestFullscreen?.bind(n);
1477
+ t ? t().catch(i) : i();
1478
+ }
1479
+ };
1480
+ c(() => {
1481
+ yt.current = Ei;
1482
+ });
1483
+ let Di = () => {
1484
+ if (!Y) return;
1485
+ let e = R.find((e) => L >= e.startTime && L < e.endTime), t = Gn.find((e) => L >= e.startTimeSeconds && L < e.endTimeSeconds);
1486
+ if (t) {
1487
+ let n = t.podIndex >= t.podTotal - 1;
1488
+ wt.current?.(n ? e?.endTime ?? t.endTimeSeconds : t.endTimeSeconds, !n);
1489
+ return;
1490
+ }
1491
+ e && wt.current?.(e.endTime);
1492
+ }, Oi = () => {
1493
+ Un.current && Wn.current.add(Un.current.availId), Vn(null), Un.current = null;
1494
+ }, ki = (e) => {
1495
+ e.clickTrackingUrl && fetch(e.clickTrackingUrl, { mode: "no-cors" }).catch(() => {}), e.clickThrough && window.open(e.clickThrough, "_blank", "noopener,noreferrer");
1496
+ }, Ai = (e) => {
1497
+ window.open(e.url, "_blank", "noopener,noreferrer");
1498
+ }, ji = () => {
1499
+ F && (q ? F.casting.stopCasting() : F.casting.requestSession(r, L));
1500
+ }, Mi = () => {
1501
+ if (!F) return;
1502
+ let e = F.getVideoElement();
1503
+ if (Ir) {
1504
+ F.casting.stopAirPlay(e);
1505
+ return;
1506
+ }
1507
+ typeof e.webkitShowPlaybackTargetPicker == "function" || F.casting.isAirPlayAvailable() ? F.casting.requestAirPlaySession(e) : console.warn("[PlayerSDK AirPlay] AirPlay is not available on this device.");
1508
+ }, Ni = (e) => {
1509
+ if (!T.current || B === 0 || !F || Y || ni) return;
1510
+ let t = T.current.getBoundingClientRect();
1511
+ pt.current = t.width, Ur(Math.max(192 / 2, Math.min(e.clientX - t.left, t.width - 192 / 2)));
1512
+ let n = H(Math.max(0, Math.min(1, (e.clientX - t.left) / t.width)) * B);
1513
+ Vr(e.clientX - t.left), Gr(n), gt.current && window.clearTimeout(gt.current), gt.current = window.setTimeout(() => {
1514
+ E.current && (E.current.currentTime = n);
1515
+ }, 100), Yr(F.keyMoments.getCurrentMoment(n).keyMoment);
1516
+ }, Pi = (e) => {
1517
+ if (!T.current || B === 0) return 0;
1518
+ let t = T.current.getBoundingClientRect();
1519
+ return H(Math.max(0, Math.min(1, (e.clientX - t.left) / t.width)) * B);
1520
+ }, Fi = (e) => {
1521
+ if (!F || Y || ni || B === 0) return;
1522
+ e.preventDefault(), _t.current = !0, Xr(Pi(e.touches[0]));
1523
+ let t = (e) => {
1524
+ if (!_t.current || !T.current) return;
1525
+ let t = e.touches[0], n = T.current.getBoundingClientRect(), r = H(Math.max(0, Math.min(1, (t.clientX - n.left) / n.width)) * B);
1526
+ Xr(r), Gr(r), ui();
1527
+ }, n = (e) => {
1528
+ if (_t.current = !1, T.current && e.changedTouches[0]) {
1529
+ let t = e.changedTouches[0], n = T.current.getBoundingClientRect();
1530
+ Z(H(Math.max(0, Math.min(1, (t.clientX - n.left) / n.width)) * B));
1531
+ }
1532
+ Xr(null), document.removeEventListener("touchmove", t), document.removeEventListener("touchend", n);
1533
+ };
1534
+ document.addEventListener("touchmove", t, { passive: !1 }), document.addEventListener("touchend", n);
1535
+ }, Ii = () => {
1536
+ Vr(null), qr(null), Yr(null), gt.current && window.clearTimeout(gt.current);
1537
+ }, Q = (e) => {
1538
+ if (isNaN(e) || e < 0) return "00:00";
1539
+ let t = Math.floor(e), n = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60), i = t % 60, a = (e) => String(e).padStart(2, "0");
1540
+ return n > 0 ? `${a(n)}:${a(r)}:${a(i)}` : `${a(r)}:${a(i)}`;
1541
+ };
1542
+ c(() => {
1543
+ Or.current && Tr(tn ? "Playing" : "Paused");
1544
+ }, [tn]), c(() => {
1545
+ Or.current && Tr(ln ? "Muted" : "Unmuted");
1546
+ }, [ln]), c(() => {
1547
+ Or.current = !0;
1548
+ }, []), c(() => {
1549
+ let e = (e) => {
1550
+ e.key === "Escape" && ci.current !== "none" && (e.preventDefault(), K("none"));
1551
+ };
1552
+ return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
1553
+ }, []);
1554
+ let Li = q ? !(jr?.isPaused ?? !0) : tn, $ = q ? jr?.currentTime ?? 0 : L, Ri = q ? jr?.duration ?? 0 : B, zi = q ? jr?.volumeLevel ?? 1 : sn, Bi = q ? jr?.isMuted ?? !1 : ln, Vi = o((e) => {
1555
+ if (Y || ni || e.target.closest(".sdk-mobile-ctrl")) return;
1556
+ let t = Date.now(), n = w.current?.getBoundingClientRect(), r = e.clientX - (n?.left ?? 0), i = Vt.current;
1557
+ if (i && t - i.time < 300) {
1558
+ Vt.current = null;
1559
+ let e = r < (n?.width ?? 0) / 2, t = e ? -10 : 10;
1560
+ Z(H(Math.max(0, Math.min(B, V($) + t))), {
1561
+ eventType: e ? "fast_backward" : "fast_forward",
1562
+ skipSeconds: 10
1563
+ }), Ut(e ? "left" : "right"), window.setTimeout(() => Ut(null), 700), ui();
1564
+ } else Vt.current = {
1565
+ time: t,
1566
+ x: r
1567
+ }, $r ? (ei(!1), ai.current && window.clearTimeout(ai.current)) : ui();
1568
+ }, [
1569
+ Y,
1570
+ ni,
1571
+ B,
1572
+ V,
1573
+ $,
1574
+ H,
1575
+ Z,
1576
+ $r
1577
+ ]), Hi = () => p(Bi || zi === 0 ? Te : zi < .3 ? Ee : zi < .7 ? Ce : we, { size: 18 }), Ui = (e) => (t) => {
1578
+ t.key === "Enter" || t.key === " " ? (t.preventDefault(), e()) : t.key === "Escape" && (t.preventDefault(), K("none"));
1579
+ }, Wi = (e) => (t) => {
1580
+ (t.key === "Enter" || t.key === " ") && (t.preventDefault(), e());
1581
+ }, Gi = (e) => {
1582
+ if (!(Y || ni)) if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
1583
+ e.preventDefault();
1584
+ let t = e.key === "ArrowLeft" ? -5 : 5;
1585
+ Z(H(Math.max(0, Math.min(B, V($) + t))));
1586
+ } else e.key === "Home" ? (e.preventDefault(), Z(H(0))) : e.key === "End" && (e.preventDefault(), Z(H(B)));
1587
+ }, Ki = (e) => {
1588
+ K(G === e ? "none" : e);
1589
+ }, qi = o((e) => {
1590
+ if (!e) return;
1591
+ e.style.left = "";
1592
+ let t = w.current;
1593
+ if (!t) return;
1594
+ let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = n.right - (r.right - 8), a = r.left + 8 - n.left;
1595
+ i > 0 ? e.style.left = `calc(50% - ${Math.ceil(i)}px)` : a > 0 && (e.style.left = `calc(50% + ${Math.ceil(a)}px)`);
1596
+ }, []);
1597
+ return /* @__PURE__ */ m("div", {
1598
+ ref: w,
1599
+ role: "region",
1600
+ "aria-label": S || Zr ? `${S || Zr} video player` : "Video player",
1601
+ className: `sdk-player-container ${$r ? "controls-active" : ""} ${hn ? "sdk-fs-simulated" : ""}`,
1602
+ onMouseMove: fi,
1603
+ onTouchStart: yn ? void 0 : ui,
1604
+ onMouseLeave: () => {},
1605
+ style: {
1606
+ border: hn ? "none" : "1px solid rgba(255, 255, 255, 0.08)",
1607
+ "--sdk-theme-color": _,
1608
+ "--sdk-theme-color-rgb": Pe(_)
1609
+ },
1610
+ children: [
1611
+ /* @__PURE__ */ p("canvas", {
1612
+ ref: mt,
1613
+ width: 160,
1614
+ height: 90,
1615
+ style: {
1616
+ display: "none",
1617
+ position: "absolute",
1618
+ pointerEvents: "none"
1619
+ },
1620
+ "aria-hidden": "true"
1621
+ }),
1622
+ /* @__PURE__ */ p("div", {
1623
+ role: "status",
1624
+ "aria-live": "polite",
1625
+ "aria-atomic": "true",
1626
+ className: "sdk-sr-only",
1627
+ children: wr
1628
+ }),
1629
+ /* @__PURE__ */ p("div", {
1630
+ ref: j,
1631
+ style: {
1632
+ opacity: 0,
1633
+ position: "absolute",
1634
+ inset: 0,
1635
+ background: "#000",
1636
+ zIndex: 100,
1637
+ pointerEvents: "none",
1638
+ willChange: "opacity"
1639
+ },
1640
+ "aria-hidden": "true"
1641
+ }),
1642
+ Sn && /* @__PURE__ */ m("div", {
1643
+ className: "sdk-pip-placeholder",
1644
+ "aria-hidden": "true",
1645
+ children: [/* @__PURE__ */ p(ye, {
1646
+ size: 32,
1647
+ "aria-hidden": "true"
1648
+ }), /* @__PURE__ */ p("span", { children: "Playing in Picture-in-Picture" })]
1649
+ }),
1650
+ /* @__PURE__ */ p("div", {
1651
+ ref: M,
1652
+ style: {
1653
+ opacity: ct && ct > 0 ? 1 : 0,
1654
+ position: "absolute",
1655
+ inset: 0,
1656
+ background: "#000",
1657
+ zIndex: 100,
1658
+ pointerEvents: "none",
1659
+ willChange: "opacity"
1660
+ },
1661
+ "aria-hidden": "true"
1662
+ }),
1663
+ /* @__PURE__ */ p("div", {
1664
+ className: `sdk-spinner-overlay ${dn ? "active" : ""}`,
1665
+ "aria-hidden": "true",
1666
+ children: /* @__PURE__ */ p("div", { className: "sdk-spinner" })
1667
+ }),
1668
+ Zt && /* @__PURE__ */ p("div", {
1669
+ style: {
1670
+ position: "absolute",
1671
+ inset: 0,
1672
+ zIndex: 50,
1673
+ background: "rgba(9,9,14,0.96)",
1674
+ display: "flex",
1675
+ flexDirection: "column",
1676
+ alignItems: "center",
1677
+ justifyContent: "center",
1678
+ gap: 20,
1679
+ padding: "0 24px"
1680
+ },
1681
+ children: /* @__PURE__ */ p(ne, { onRetry: () => {
1682
+ Qt(!1), en((e) => e + 1);
1683
+ } })
1684
+ }),
1685
+ Er && /* @__PURE__ */ p("div", {
1686
+ style: {
1687
+ position: "absolute",
1688
+ top: "50%",
1689
+ left: "50%",
1690
+ transform: "translate(-50%, calc(-50% + 70px))",
1691
+ background: "rgba(0,0,0,0.82)",
1692
+ color: "#fff",
1693
+ fontSize: 13,
1694
+ fontWeight: 500,
1695
+ padding: "8px 16px",
1696
+ borderRadius: 8,
1697
+ zIndex: 102,
1698
+ pointerEvents: "none",
1699
+ maxWidth: "85%",
1700
+ textAlign: "center",
1701
+ backdropFilter: "blur(8px)",
1702
+ border: "1px solid rgba(255,255,255,0.12)"
1703
+ },
1704
+ children: Er
1705
+ }),
1706
+ I.enableSubtitles && !Y && or && U !== "off" && /* @__PURE__ */ p("div", {
1707
+ className: "sdk-subtitles-overlay",
1708
+ children: /* @__PURE__ */ p("span", {
1709
+ className: "sdk-subtitles-text",
1710
+ style: {
1711
+ fontSize: Ye.size === "small" ? "14px" : Ye.size === "large" ? "24px" : "18px",
1712
+ color: Ye.color ?? "#ffffff",
1713
+ background: Ye.background === "none" ? "transparent" : Ye.background === "solid" ? "rgba(0, 0, 0, 0.92)" : "rgba(15, 23, 42, 0.78)",
1714
+ border: Ye.background === "none" ? "none" : "1px solid rgba(255,255,255,0.08)",
1715
+ backdropFilter: Ye.background === "none" ? "none" : "blur(8px)"
1716
+ },
1717
+ dangerouslySetInnerHTML: { __html: or }
1718
+ })
1719
+ }),
1720
+ Bn && /* @__PURE__ */ m("div", {
1721
+ className: `sdk-overlay-ad sdk-overlay-ad--${Bn.position}`,
1722
+ role: "complementary",
1723
+ "aria-label": "Advertisement",
1724
+ children: [/* @__PURE__ */ m("div", {
1725
+ className: "sdk-overlay-ad-topbar",
1726
+ children: [/* @__PURE__ */ p("span", {
1727
+ className: "sdk-overlay-ad-label",
1728
+ children: "Ad"
1729
+ }), Bn.dismissible && /* @__PURE__ */ p("button", {
1730
+ className: "sdk-overlay-ad-close",
1731
+ onClick: Oi,
1732
+ "aria-label": "Close advertisement",
1733
+ children: "✕"
1734
+ })]
1735
+ }), /* @__PURE__ */ p("img", {
1736
+ src: Bn.imageUrl,
1737
+ width: Bn.imageWidth,
1738
+ height: Bn.imageHeight,
1739
+ alt: Bn.title || "Advertisement",
1740
+ className: "sdk-overlay-ad-img",
1741
+ onClick: () => ki(Bn)
1742
+ })]
1743
+ }),
1744
+ Y && (() => {
1745
+ let e = Gn.find((e) => L >= e.startTimeSeconds && L < e.endTimeSeconds), t = R.find((e) => L >= e.startTime && L < e.endTime), n = e ? Math.max(0, e.endTimeSeconds - L) : t ? Math.max(0, t.endTime - L) : 0, r = e ? L - e.startTimeSeconds : t ? L - t.startTime : 0, i = !!e && e.podTotal > 1, a = e ? e.skippable : nt, o = e ? e.skipOffsetSeconds : rt, s = a && r >= o, c = Math.ceil(o - r), l = r + n, u = l > 0 ? Math.min(1, Math.max(0, r / l)) : 0, d = 2.5, { w: f, h: te } = Yn, ne = Math.max(0, f - d), h = Math.max(0, te - d), g = Math.min(22 - d / 2, h / 2), _ = Math.max(0, ne - 2 * g), re = Math.max(0, h - 2 * g), ie = `M${1.25 + g + _ / 2},1.25h${_ / 2}a${g},${g} 0 0 1 ${g},${g}v${re}a${g},${g} 0 0 1 ${-g},${g}h${-_}a${g},${g} 0 0 1 ${-g},${-g}v${-re}a${g},${g} 0 0 1 ${g},${-g}h${_ / 2}`, ae = 2 * _ + 2 * re + 2 * Math.PI * g;
1746
+ return /* @__PURE__ */ m(ee, { children: [
1747
+ /* @__PURE__ */ m("div", {
1748
+ ref: Jn,
1749
+ className: "sdk-ad-countdown",
1750
+ role: "timer",
1751
+ "aria-label": i ? `Advertisement ${e.podIndex + 1} of ${e.podTotal} — ${Q(n)} remaining` : `Advertisement — ${Q(n)} remaining`,
1752
+ "aria-live": "off",
1753
+ children: [
1754
+ f > 0 && te > 0 && /* @__PURE__ */ m("svg", {
1755
+ className: "sdk-ad-countdown-border",
1756
+ width: f,
1757
+ height: te,
1758
+ viewBox: `0 0 ${f} ${te}`,
1759
+ "aria-hidden": "true",
1760
+ children: [/* @__PURE__ */ p("path", {
1761
+ className: "sdk-ad-countdown-border-track",
1762
+ d: ie,
1763
+ strokeWidth: d
1764
+ }), /* @__PURE__ */ p("path", {
1765
+ className: "sdk-ad-countdown-border-fill",
1766
+ d: ie,
1767
+ strokeWidth: d,
1768
+ strokeDasharray: ae,
1769
+ strokeDashoffset: ae * (1 - u)
1770
+ })]
1771
+ }),
1772
+ /* @__PURE__ */ p("span", {
1773
+ className: "sdk-ad-countdown-badge",
1774
+ "aria-hidden": "true",
1775
+ children: "Ad"
1776
+ }),
1777
+ i && /* @__PURE__ */ m("span", {
1778
+ className: "sdk-ad-countdown-count",
1779
+ "aria-hidden": "true",
1780
+ children: [
1781
+ e.podIndex + 1,
1782
+ " of ",
1783
+ e.podTotal
1784
+ ]
1785
+ }),
1786
+ /* @__PURE__ */ p("span", {
1787
+ className: "sdk-ad-countdown-sep",
1788
+ "aria-hidden": "true"
1789
+ }),
1790
+ /* @__PURE__ */ p("span", {
1791
+ className: "sdk-ad-countdown-time",
1792
+ "aria-hidden": "true",
1793
+ children: Q(n)
1794
+ })
1795
+ ]
1796
+ }),
1797
+ a && /* @__PURE__ */ p("button", {
1798
+ className: `sdk-skip-ad-btn ${s ? "sdk-skip-ad-btn--ready" : ""}`,
1799
+ onClick: s ? Di : void 0,
1800
+ disabled: !s,
1801
+ "aria-label": s ? "Skip advertisement" : `Skip advertisement available in ${c} seconds`,
1802
+ "aria-disabled": !s,
1803
+ children: s ? "Skip Ad ›" : `Skip in ${c}s`
1804
+ }),
1805
+ e?.cta && (() => {
1806
+ let t = e.cta, n = /* @__PURE__ */ m("button", {
1807
+ className: "sdk-ad-cta-btn",
1808
+ onClick: () => Ai(t),
1809
+ "aria-label": `${t.text} — opens advertiser site in a new tab`,
1810
+ children: [/* @__PURE__ */ p("span", {
1811
+ className: "sdk-ad-cta-btn-text",
1812
+ children: t.text
1813
+ }), /* @__PURE__ */ p(pe, {
1814
+ size: 15,
1815
+ "aria-hidden": "true"
1816
+ })]
1817
+ });
1818
+ return /* @__PURE__ */ p("div", {
1819
+ className: "sdk-ad-cta",
1820
+ role: "complementary",
1821
+ "aria-label": "Advertisement call to action",
1822
+ children: t.title ? /* @__PURE__ */ m("div", {
1823
+ className: "sdk-ad-cta-card",
1824
+ children: [/* @__PURE__ */ m("div", {
1825
+ className: "sdk-ad-cta-info",
1826
+ children: [/* @__PURE__ */ p("div", {
1827
+ className: "sdk-ad-cta-title",
1828
+ children: t.title
1829
+ }), t.description && /* @__PURE__ */ p("div", {
1830
+ className: "sdk-ad-cta-desc",
1831
+ children: t.description
1832
+ })]
1833
+ }), n]
1834
+ }) : n
1835
+ });
1836
+ })()
1837
+ ] });
1838
+ })(),
1839
+ Xt && /* @__PURE__ */ p("div", {
1840
+ style: {
1841
+ position: "absolute",
1842
+ inset: 0,
1843
+ display: "flex",
1844
+ alignItems: "center",
1845
+ justifyContent: "center",
1846
+ background: "rgba(0,0,0,0.72)",
1847
+ color: "#fff",
1848
+ zIndex: 60
1849
+ },
1850
+ children: /* @__PURE__ */ m("div", {
1851
+ style: {
1852
+ maxWidth: 480,
1853
+ textAlign: "center",
1854
+ padding: 24
1855
+ },
1856
+ children: [/* @__PURE__ */ p("h3", {
1857
+ style: { margin: "0 0 8px" },
1858
+ children: "Playback restricted"
1859
+ }), /* @__PURE__ */ p("p", {
1860
+ style: { margin: 0 },
1861
+ children: "Your account is missing a required license key. Please contact your administrator."
1862
+ })]
1863
+ })
1864
+ }),
1865
+ (q || Ir) && /* @__PURE__ */ p("div", { className: "sdk-cast-bg" }),
1866
+ yn && /* @__PURE__ */ m("div", {
1867
+ className: `sdk-mobile-overlay ${$r ? "active" : ""}`,
1868
+ onClick: Vi,
1869
+ children: [Ht && /* @__PURE__ */ p("div", {
1870
+ className: `sdk-mobile-doubletap ${Ht}`,
1871
+ children: /* @__PURE__ */ m("div", {
1872
+ className: "sdk-mobile-doubletap-icon",
1873
+ children: [p(Ht === "left" ? xe : Se, { size: 26 }), /* @__PURE__ */ p("span", {
1874
+ className: "sdk-mobile-doubletap-label",
1875
+ children: "10s"
1876
+ })]
1877
+ })
1878
+ }), v && /* @__PURE__ */ m(ee, { children: [
1879
+ /* @__PURE__ */ m("div", {
1880
+ className: "sdk-mobile-header sdk-mobile-ctrl",
1881
+ children: [/* @__PURE__ */ m("div", {
1882
+ className: "sdk-mobile-header-left",
1883
+ children: [(pn || hn) && /* @__PURE__ */ p("button", {
1884
+ className: "sdk-mobile-back-btn",
1885
+ onClick: Ei,
1886
+ "aria-label": "Exit fullscreen",
1887
+ children: /* @__PURE__ */ p(fe, {
1888
+ size: 22,
1889
+ "aria-hidden": "true"
1890
+ })
1891
+ }), (S || Zr) && /* @__PURE__ */ p("div", {
1892
+ className: "sdk-mobile-title",
1893
+ children: S || Zr
1894
+ })]
1895
+ }), /* @__PURE__ */ m("div", {
1896
+ className: "sdk-mobile-header-actions",
1897
+ children: [
1898
+ I.enablePiP && /* @__PURE__ */ p("button", {
1899
+ className: "sdk-mobile-hdr-btn",
1900
+ onClick: () => {
1901
+ Y || wi();
1902
+ },
1903
+ style: { color: bn ? _ : "" },
1904
+ "aria-label": bn ? "Exit picture-in-picture" : "Enter picture-in-picture",
1905
+ "aria-pressed": bn,
1906
+ children: /* @__PURE__ */ p(ye, {
1907
+ size: 20,
1908
+ "aria-hidden": "true"
1909
+ })
1910
+ }),
1911
+ I.enableChromecast && !Y && /* @__PURE__ */ p("button", {
1912
+ className: "sdk-mobile-hdr-btn",
1913
+ onClick: ji,
1914
+ "data-tooltip": q ? `Casting to ${q} — tap to disconnect` : "Cast to device",
1915
+ "aria-label": q ? `Stop casting to ${q}` : "Cast to device",
1916
+ "aria-pressed": !!q,
1917
+ style: { color: q ? "#3b82f6" : "" },
1918
+ children: /* @__PURE__ */ p(de, {
1919
+ size: 20,
1920
+ fill: q ? "currentColor" : "none",
1921
+ "aria-hidden": "true"
1922
+ })
1923
+ }),
1924
+ I.allowAirplay && Pr && /* @__PURE__ */ p("button", {
1925
+ className: "sdk-mobile-hdr-btn",
1926
+ onClick: Mi,
1927
+ "aria-label": Ir ? `Stop AirPlay to ${Rr || "device"}` : "AirPlay to device",
1928
+ "aria-pressed": Ir,
1929
+ style: { color: Ir ? _ : "" },
1930
+ children: /* @__PURE__ */ p(le, {
1931
+ size: 20,
1932
+ "aria-hidden": "true"
1933
+ })
1934
+ })
1935
+ ]
1936
+ })]
1937
+ }),
1938
+ /* @__PURE__ */ m("div", {
1939
+ className: "sdk-mobile-center-controls sdk-mobile-ctrl",
1940
+ children: [
1941
+ !Y && /* @__PURE__ */ m("button", {
1942
+ className: "sdk-mobile-seek-btn",
1943
+ onClick: () => Z(H(Math.max(0, V($) - 10)), {
1944
+ eventType: "fast_backward",
1945
+ skipSeconds: 10
1946
+ }),
1947
+ "aria-label": "Rewind 10 seconds",
1948
+ children: [/* @__PURE__ */ p(xe, {
1949
+ size: 22,
1950
+ "aria-hidden": "true"
1951
+ }), /* @__PURE__ */ p("span", {
1952
+ className: "sdk-mobile-seek-label",
1953
+ "aria-hidden": "true",
1954
+ children: "10"
1955
+ })]
1956
+ }),
1957
+ /* @__PURE__ */ p("button", {
1958
+ className: "sdk-mobile-play-btn",
1959
+ onClick: mi,
1960
+ "aria-label": wn ? "Replay" : Li ? "Pause" : "Play",
1961
+ children: wn ? /* @__PURE__ */ p(xe, {
1962
+ size: 38,
1963
+ "aria-hidden": "true"
1964
+ }) : Li ? /* @__PURE__ */ p(b, {
1965
+ size: 38,
1966
+ fill: "currentColor",
1967
+ "aria-hidden": "true"
1968
+ }) : /* @__PURE__ */ p(be, {
1969
+ size: 38,
1970
+ fill: "currentColor",
1971
+ style: { marginLeft: "3px" },
1972
+ "aria-hidden": "true"
1973
+ })
1974
+ }),
1975
+ !Y && /* @__PURE__ */ m("button", {
1976
+ className: "sdk-mobile-seek-btn",
1977
+ onClick: () => Z(H(Math.min(B, V($) + 10)), {
1978
+ eventType: "fast_forward",
1979
+ skipSeconds: 10
1980
+ }),
1981
+ "aria-label": "Skip forward 10 seconds",
1982
+ children: [/* @__PURE__ */ p(Se, {
1983
+ size: 22,
1984
+ "aria-hidden": "true"
1985
+ }), /* @__PURE__ */ p("span", {
1986
+ className: "sdk-mobile-seek-label",
1987
+ "aria-hidden": "true",
1988
+ children: "10"
1989
+ })]
1990
+ })
1991
+ ]
1992
+ }),
1993
+ /* @__PURE__ */ m("div", {
1994
+ className: "sdk-mobile-bottom-bar sdk-mobile-ctrl",
1995
+ children: [
1996
+ I.enableKeyMoments && br && W.length > 0 && /* @__PURE__ */ p("div", {
1997
+ className: "sdk-mobile-chapters-scroll",
1998
+ children: W.map((e, t) => {
1999
+ let n = hr.index === t;
2000
+ return /* @__PURE__ */ m("div", {
2001
+ role: "button",
2002
+ tabIndex: 0,
2003
+ className: `sdk-mobile-chapter-card${n ? " active" : ""}`,
2004
+ style: { borderColor: n ? _ : void 0 },
2005
+ "aria-label": `${e.title}, ${Q(e.startTime)}${n ? ", current chapter" : ""}`,
2006
+ "aria-current": n ? "true" : void 0,
2007
+ onClick: () => {
2008
+ Si(e.startTime, e);
2009
+ },
2010
+ onKeyDown: Wi(() => Si(e.startTime, e)),
2011
+ children: [/* @__PURE__ */ m("div", {
2012
+ className: "sdk-mobile-chapter-thumb",
2013
+ children: [Sr[t] || e.thumbnail ? /* @__PURE__ */ p("img", {
2014
+ src: Sr[t] || e.thumbnail,
2015
+ alt: "",
2016
+ "aria-hidden": "true",
2017
+ style: {
2018
+ width: "100%",
2019
+ height: "100%",
2020
+ objectFit: "cover",
2021
+ display: "block"
2022
+ }
2023
+ }) : /* @__PURE__ */ p(ge, {
2024
+ size: 16,
2025
+ "aria-hidden": "true",
2026
+ style: { color: n ? _ : "rgba(255,255,255,0.3)" }
2027
+ }), /* @__PURE__ */ p("span", {
2028
+ className: "sdk-mobile-chapter-time-badge",
2029
+ "aria-hidden": "true",
2030
+ children: Q(e.startTime)
2031
+ })]
2032
+ }), /* @__PURE__ */ p("div", {
2033
+ className: "sdk-mobile-chapter-title",
2034
+ style: { color: n ? _ : void 0 },
2035
+ children: e.title
2036
+ })]
2037
+ }, t);
2038
+ })
2039
+ }),
2040
+ /* @__PURE__ */ p("div", {
2041
+ ref: T,
2042
+ role: X ? void 0 : "slider",
2043
+ "aria-label": X ? void 0 : "Seek",
2044
+ "aria-valuemin": X ? void 0 : 0,
2045
+ "aria-valuemax": X ? void 0 : Math.round(B),
2046
+ "aria-valuenow": X ? void 0 : Math.round(V(J === null ? L : J)),
2047
+ "aria-valuetext": X ? void 0 : `${Q(V(J === null ? L : J))} of ${Q(B)}`,
2048
+ tabIndex: X ? void 0 : 0,
2049
+ className: `sdk-seekbar-container sdk-mobile-seekbar${Y ? " sdk-ad-mode" : ""}`,
2050
+ onMouseDown: X ? void 0 : gi,
2051
+ onMouseMove: X ? void 0 : Ni,
2052
+ onMouseLeave: X ? void 0 : Ii,
2053
+ onTouchStart: X ? void 0 : Fi,
2054
+ onKeyDown: X ? void 0 : Gi,
2055
+ style: {
2056
+ pointerEvents: X ? "none" : void 0,
2057
+ touchAction: "none"
2058
+ },
2059
+ children: Y ? /* @__PURE__ */ p("div", {
2060
+ className: "sdk-ad-progress-fill",
2061
+ style: { width: (() => {
2062
+ let e = F ? F.getCurrentTime() : L, t = $n(e);
2063
+ return t ? `${Math.min(100, Math.max(0, (e - t.start) / (t.end - t.start) * 100))}%` : "0%";
2064
+ })() }
2065
+ }) : /* @__PURE__ */ m(ee, { children: [
2066
+ /* @__PURE__ */ p("div", {
2067
+ className: "sdk-seekbar-buffered",
2068
+ style: { width: `${an ? (F && F.getBufferedRanges()[0]?.end || 0) / an * 100 : 0}%` }
2069
+ }),
2070
+ B > 0 && R.filter((e) => !kn.has(e.startTime)).map((e, t) => /* @__PURE__ */ p("div", {
2071
+ className: "sdk-seekbar-adbreak",
2072
+ style: {
2073
+ left: `${V(e.startTime) / B * 100}%`,
2074
+ width: "3px"
2075
+ }
2076
+ }, t)),
2077
+ /* @__PURE__ */ p("div", {
2078
+ className: "sdk-seekbar-progress",
2079
+ style: {
2080
+ width: q ? `${Ri > 0 ? $ / Ri * 100 : 0}%` : `${B ? V(J === null ? L : J) / B * 100 : 0}%`,
2081
+ background: "#ffffff",
2082
+ boxShadow: "none"
2083
+ },
2084
+ children: /* @__PURE__ */ p("div", {
2085
+ className: "sdk-seekbar-handle",
2086
+ style: {
2087
+ opacity: 1,
2088
+ transform: "scale(1)"
2089
+ }
2090
+ })
2091
+ }),
2092
+ I.enableKeyMoments && W.map((e, t) => B === 0 ? null : /* @__PURE__ */ p("div", {
2093
+ className: "sdk-seekbar-chapter-marker sdk-desktop-chapter-dot",
2094
+ style: { left: `${V(e.startTime) / B * 100}%` }
2095
+ }, t))
2096
+ ] })
2097
+ }),
2098
+ /* @__PURE__ */ m("div", {
2099
+ className: "sdk-mobile-controls-row",
2100
+ children: [!Y && /* @__PURE__ */ p("span", {
2101
+ className: "sdk-time-display",
2102
+ children: q ? `${Q($)} / ${Q(Ri)}` : `${Q(V(J === null ? L : J))} / ${Q(B)}`
2103
+ }), /* @__PURE__ */ m("div", {
2104
+ className: "sdk-mobile-bottom-icons",
2105
+ children: [
2106
+ I.enableKeyMoments && W.length > 0 && !Y && /* @__PURE__ */ p("button", {
2107
+ className: `sdk-mobile-icon-btn${br ? " active" : ""}`,
2108
+ onClick: () => {
2109
+ xr(!br);
2110
+ },
2111
+ "aria-label": br ? "Hide chapters" : "Show chapters",
2112
+ "aria-pressed": br,
2113
+ children: /* @__PURE__ */ p(ge, {
2114
+ size: 18,
2115
+ "aria-hidden": "true"
2116
+ })
2117
+ }),
2118
+ I.enableSubtitles && !Y && lr.some((e) => !e.isNative) && /* @__PURE__ */ m("div", {
2119
+ className: "sdk-menu-container",
2120
+ children: [/* @__PURE__ */ p("button", {
2121
+ className: `sdk-mobile-icon-btn${U === "off" ? "" : " active"}`,
2122
+ onClick: () => {
2123
+ Ki("subtitles");
2124
+ },
2125
+ "aria-label": "Captions",
2126
+ "aria-haspopup": "listbox",
2127
+ "aria-expanded": G === "subtitles",
2128
+ children: /* @__PURE__ */ p(ue, {
2129
+ size: 18,
2130
+ "aria-hidden": "true"
2131
+ })
2132
+ }), G === "subtitles" && /* @__PURE__ */ m("div", {
2133
+ ref: qi,
2134
+ className: "sdk-dropup-menu",
2135
+ role: "listbox",
2136
+ "aria-label": "Captions",
2137
+ children: [
2138
+ /* @__PURE__ */ p("div", {
2139
+ className: "sdk-dropup-header",
2140
+ "aria-hidden": "true",
2141
+ children: "Subtitles"
2142
+ }),
2143
+ /* @__PURE__ */ m("div", {
2144
+ role: "option",
2145
+ "aria-selected": U === "off",
2146
+ tabIndex: 0,
2147
+ className: `sdk-dropup-item ${U === "off" ? "active" : ""}`,
2148
+ onClick: () => bi("off"),
2149
+ onKeyDown: Ui(() => bi("off")),
2150
+ children: [/* @__PURE__ */ p("span", { children: "Off" }), U === "off" && /* @__PURE__ */ p(y, {
2151
+ size: 12,
2152
+ "aria-hidden": "true"
2153
+ })]
2154
+ }),
2155
+ lr.map((e) => /* @__PURE__ */ m("div", {
2156
+ role: "option",
2157
+ "aria-selected": U === e.id,
2158
+ tabIndex: 0,
2159
+ className: `sdk-dropup-item ${U === e.id ? "active" : ""}`,
2160
+ onClick: () => bi(e.id),
2161
+ onKeyDown: Ui(() => bi(e.id)),
2162
+ children: [/* @__PURE__ */ p("span", { children: x(e) }), U === e.id && /* @__PURE__ */ p(y, {
2163
+ size: 12,
2164
+ "aria-hidden": "true"
2165
+ })]
2166
+ }, e.id))
2167
+ ]
2168
+ })]
2169
+ }),
2170
+ I.allowMultipleAudio && dr.length > 1 && !Y && /* @__PURE__ */ m("div", {
2171
+ className: "sdk-menu-container",
2172
+ children: [/* @__PURE__ */ p("button", {
2173
+ className: `sdk-mobile-icon-btn${G === "audio" ? " active" : ""}`,
2174
+ onClick: () => {
2175
+ Ki("audio");
2176
+ },
2177
+ "aria-label": "Audio track",
2178
+ "aria-haspopup": "listbox",
2179
+ "aria-expanded": G === "audio",
2180
+ children: /* @__PURE__ */ p(he, {
2181
+ size: 18,
2182
+ "aria-hidden": "true"
2183
+ })
2184
+ }), G === "audio" && /* @__PURE__ */ m("div", {
2185
+ ref: qi,
2186
+ className: "sdk-dropup-menu",
2187
+ role: "listbox",
2188
+ "aria-label": "Audio track",
2189
+ children: [/* @__PURE__ */ p("div", {
2190
+ className: "sdk-dropup-header",
2191
+ "aria-hidden": "true",
2192
+ children: "Audio Track"
2193
+ }), dr.map((e) => /* @__PURE__ */ m("div", {
2194
+ role: "option",
2195
+ "aria-selected": pr === e.id,
2196
+ tabIndex: 0,
2197
+ className: `sdk-dropup-item ${pr === e.id ? "active" : ""}`,
2198
+ onClick: () => {
2199
+ F?.setAudioTrack(e.id), mr(e.id), K("none"), Tr(`Audio: ${x(e)}`);
2200
+ },
2201
+ onKeyDown: Ui(() => {
2202
+ F?.setAudioTrack(e.id), mr(e.id), K("none"), Tr(`Audio: ${x(e)}`);
2203
+ }),
2204
+ children: [/* @__PURE__ */ p("span", { children: x(e) }), pr === e.id && /* @__PURE__ */ p(y, {
2205
+ size: 12,
2206
+ "aria-hidden": "true"
2207
+ })]
2208
+ }, e.id))]
2209
+ })]
2210
+ }),
2211
+ I.enablePlaybackSpeed && !Y && /* @__PURE__ */ m("div", {
2212
+ className: "sdk-menu-container",
2213
+ children: [/* @__PURE__ */ p("button", {
2214
+ className: `sdk-mobile-icon-btn${G === "speed" ? " active" : ""}`,
2215
+ onClick: () => {
2216
+ Ki("speed");
2217
+ },
2218
+ "aria-label": "Playback speed",
2219
+ "aria-haspopup": "listbox",
2220
+ "aria-expanded": G === "speed",
2221
+ children: /* @__PURE__ */ p(me, {
2222
+ size: 18,
2223
+ "aria-hidden": "true"
2224
+ })
2225
+ }), G === "speed" && /* @__PURE__ */ m("div", {
2226
+ ref: qi,
2227
+ className: "sdk-dropup-menu",
2228
+ role: "listbox",
2229
+ "aria-label": "Playback speed",
2230
+ children: [/* @__PURE__ */ p("div", {
2231
+ className: "sdk-dropup-header",
2232
+ "aria-hidden": "true",
2233
+ children: "Speed"
2234
+ }), [
2235
+ .5,
2236
+ .75,
2237
+ 1,
2238
+ 1.25,
2239
+ 1.5,
2240
+ 2
2241
+ ].map((e) => /* @__PURE__ */ m("div", {
2242
+ role: "option",
2243
+ "aria-selected": vr === e,
2244
+ tabIndex: 0,
2245
+ className: `sdk-dropup-item ${vr === e ? "active" : ""}`,
2246
+ onClick: () => vi(e),
2247
+ onKeyDown: Ui(() => vi(e)),
2248
+ children: [/* @__PURE__ */ p("span", { children: e === 1 ? "Normal" : `${e}x` }), vr === e && /* @__PURE__ */ p(y, {
2249
+ size: 12,
2250
+ "aria-hidden": "true"
2251
+ })]
2252
+ }, e))]
2253
+ })]
2254
+ }),
2255
+ I.enableQuality && !Y && /* @__PURE__ */ m("div", {
2256
+ className: "sdk-menu-container",
2257
+ children: [/* @__PURE__ */ p("button", {
2258
+ className: `sdk-mobile-icon-btn${ir.id === -1 ? "" : " active"}`,
2259
+ onClick: () => {
2260
+ Ki("quality");
2261
+ },
2262
+ "aria-label": "Video quality",
2263
+ "aria-haspopup": "listbox",
2264
+ "aria-expanded": G === "quality",
2265
+ children: /* @__PURE__ */ p(Me, {
2266
+ size: 18,
2267
+ "aria-hidden": "true"
2268
+ })
2269
+ }), G === "quality" && /* @__PURE__ */ m("div", {
2270
+ ref: qi,
2271
+ className: "sdk-dropup-menu large",
2272
+ role: "listbox",
2273
+ "aria-label": "Video quality",
2274
+ children: [/* @__PURE__ */ p("div", {
2275
+ className: "sdk-dropup-header",
2276
+ "aria-hidden": "true",
2277
+ children: "Quality"
2278
+ }), nr.map((e) => /* @__PURE__ */ m("div", {
2279
+ role: "option",
2280
+ "aria-selected": ir.id === e.id,
2281
+ tabIndex: 0,
2282
+ className: `sdk-dropup-item ${ir.id === e.id ? "active" : ""}`,
2283
+ onClick: () => yi(e.id),
2284
+ onKeyDown: Ui(() => yi(e.id)),
2285
+ children: [/* @__PURE__ */ p("span", { children: e.label }), ir.id === e.id && /* @__PURE__ */ p(y, {
2286
+ size: 12,
2287
+ "aria-hidden": "true"
2288
+ })]
2289
+ }, e.id))]
2290
+ })]
2291
+ }),
2292
+ C && C.length > 1 && !Y && /* @__PURE__ */ m("div", {
2293
+ className: "sdk-menu-container",
2294
+ children: [/* @__PURE__ */ p("button", {
2295
+ className: `sdk-mobile-icon-btn${G === "sources" ? " active" : ""}`,
2296
+ onClick: () => {
2297
+ Ki("sources");
2298
+ },
2299
+ "aria-label": "Select source",
2300
+ "aria-haspopup": "listbox",
2301
+ "aria-expanded": G === "sources",
2302
+ children: /* @__PURE__ */ p(Ne, {
2303
+ size: 18,
2304
+ "aria-hidden": "true"
2305
+ })
2306
+ }), G === "sources" && /* @__PURE__ */ m("div", {
2307
+ ref: qi,
2308
+ className: "sdk-dropup-menu",
2309
+ role: "listbox",
2310
+ "aria-label": "Select source",
2311
+ children: [/* @__PURE__ */ p("div", {
2312
+ className: "sdk-dropup-header",
2313
+ "aria-hidden": "true",
2314
+ children: "Source"
2315
+ }), C.map((e, t) => /* @__PURE__ */ m("div", {
2316
+ role: "option",
2317
+ "aria-selected": ot === t,
2318
+ tabIndex: 0,
2319
+ className: `sdk-dropup-item ${ot === t ? "active" : ""}`,
2320
+ onClick: () => xi(t),
2321
+ onKeyDown: Ui(() => xi(t)),
2322
+ children: [/* @__PURE__ */ p("span", { children: e.label }), ot === t && /* @__PURE__ */ p(y, {
2323
+ size: 12,
2324
+ "aria-hidden": "true"
2325
+ })]
2326
+ }, t))]
2327
+ })]
2328
+ }),
2329
+ /* @__PURE__ */ p("button", {
2330
+ className: "sdk-mobile-icon-btn",
2331
+ onClick: Ei,
2332
+ "aria-label": pn || hn ? "Exit fullscreen" : "Enter fullscreen",
2333
+ "aria-pressed": pn || hn,
2334
+ children: p(pn ? ve : _e, {
2335
+ size: 18,
2336
+ "aria-hidden": "true"
2337
+ })
2338
+ })
2339
+ ]
2340
+ })]
2341
+ })
2342
+ ]
2343
+ })
2344
+ ] })]
2345
+ }),
2346
+ !yn && /* @__PURE__ */ m("div", {
2347
+ className: "sdk-controls-overlay",
2348
+ onClick: (e) => {
2349
+ Y || e.target.closest(".sdk-desktop-header") || e.target.closest(".sdk-desktop-center-controls") || e.target.closest(".sdk-desktop-bottom") || mi();
2350
+ },
2351
+ children: [/* @__PURE__ */ m("div", {
2352
+ className: "sdk-desktop-header",
2353
+ children: [/* @__PURE__ */ m("div", {
2354
+ className: "sdk-desktop-header-left",
2355
+ children: [(pn || hn) && /* @__PURE__ */ p("button", {
2356
+ className: "sdk-desktop-back-btn",
2357
+ onClick: (e) => {
2358
+ e.stopPropagation(), Ei();
2359
+ },
2360
+ "aria-label": "Exit fullscreen",
2361
+ children: /* @__PURE__ */ p(fe, {
2362
+ size: 22,
2363
+ "aria-hidden": "true"
2364
+ })
2365
+ }), (S || Zr) && /* @__PURE__ */ p("span", {
2366
+ className: "sdk-desktop-title",
2367
+ children: S || Zr
2368
+ })]
2369
+ }), /* @__PURE__ */ m("div", {
2370
+ className: "sdk-desktop-header-right",
2371
+ children: [
2372
+ I.enableChromecast && !Y && /* @__PURE__ */ p("button", {
2373
+ className: "sdk-desktop-hdr-btn",
2374
+ onClick: (e) => {
2375
+ e.stopPropagation(), ji();
2376
+ },
2377
+ "data-tooltip": q ? `Casting to ${q} — click to disconnect` : "Cast to device",
2378
+ "aria-label": q ? `Stop casting to ${q}` : "Cast to device",
2379
+ "aria-pressed": !!q,
2380
+ style: { color: q ? "#3b82f6" : "" },
2381
+ children: /* @__PURE__ */ p(de, {
2382
+ size: 20,
2383
+ fill: q ? "currentColor" : "none",
2384
+ "aria-hidden": "true"
2385
+ })
2386
+ }),
2387
+ q && /* @__PURE__ */ m("span", {
2388
+ className: "sdk-cast-indicator",
2389
+ "aria-hidden": "true",
2390
+ children: [/* @__PURE__ */ p(de, {
2391
+ size: 10,
2392
+ fill: "currentColor",
2393
+ "aria-hidden": "true"
2394
+ }), q]
2395
+ }),
2396
+ I.allowAirplay && Pr && /* @__PURE__ */ p("button", {
2397
+ className: "sdk-desktop-hdr-btn",
2398
+ onClick: (e) => {
2399
+ e.stopPropagation(), Mi();
2400
+ },
2401
+ "data-tooltip": Ir ? `AirPlay to ${Rr || "device"} — click to disconnect` : "AirPlay to device",
2402
+ "aria-label": Ir ? `Stop AirPlay to ${Rr || "device"}` : "AirPlay to device",
2403
+ "aria-pressed": Ir,
2404
+ style: { color: Ir ? _ : "" },
2405
+ children: /* @__PURE__ */ p(le, {
2406
+ size: 20,
2407
+ "aria-hidden": "true"
2408
+ })
2409
+ })
2410
+ ]
2411
+ })]
2412
+ }), v && /* @__PURE__ */ m(ee, { children: [
2413
+ /* @__PURE__ */ m("div", {
2414
+ className: "sdk-desktop-center-controls",
2415
+ style: { pointerEvents: "none" },
2416
+ children: [
2417
+ !Y && /* @__PURE__ */ p("button", {
2418
+ className: "sdk-desktop-seek-btn",
2419
+ style: { pointerEvents: "auto" },
2420
+ onClick: (e) => {
2421
+ e.stopPropagation(), Z(H(Math.max(0, V($) - 10)), {
2422
+ eventType: "fast_backward",
2423
+ skipSeconds: 10
2424
+ });
2425
+ },
2426
+ "aria-label": "Rewind 10 seconds",
2427
+ children: /* @__PURE__ */ m("div", {
2428
+ style: {
2429
+ position: "relative",
2430
+ display: "flex",
2431
+ alignItems: "center",
2432
+ justifyContent: "center"
2433
+ },
2434
+ children: [/* @__PURE__ */ p(xe, {
2435
+ size: 30,
2436
+ "aria-hidden": "true"
2437
+ }), /* @__PURE__ */ p("span", {
2438
+ className: "sdk-desktop-seek-label",
2439
+ "aria-hidden": "true",
2440
+ children: "10"
2441
+ })]
2442
+ })
2443
+ }),
2444
+ /* @__PURE__ */ p("button", {
2445
+ className: "sdk-desktop-play-btn",
2446
+ style: { pointerEvents: "auto" },
2447
+ onClick: (e) => {
2448
+ e.stopPropagation(), mi();
2449
+ },
2450
+ "aria-label": wn ? "Replay" : Li ? "Pause" : "Play",
2451
+ children: wn ? /* @__PURE__ */ p(xe, {
2452
+ size: 38,
2453
+ "aria-hidden": "true"
2454
+ }) : Li ? /* @__PURE__ */ p(b, {
2455
+ size: 38,
2456
+ fill: "currentColor",
2457
+ "aria-hidden": "true"
2458
+ }) : /* @__PURE__ */ p(be, {
2459
+ size: 38,
2460
+ fill: "currentColor",
2461
+ style: { marginLeft: "4px" },
2462
+ "aria-hidden": "true"
2463
+ })
2464
+ }),
2465
+ !Y && /* @__PURE__ */ p("button", {
2466
+ className: "sdk-desktop-seek-btn",
2467
+ style: { pointerEvents: "auto" },
2468
+ onClick: (e) => {
2469
+ e.stopPropagation(), Z(H(Math.min(B, V($) + 10)), {
2470
+ eventType: "fast_forward",
2471
+ skipSeconds: 10
2472
+ });
2473
+ },
2474
+ "aria-label": "Skip forward 10 seconds",
2475
+ children: /* @__PURE__ */ m("div", {
2476
+ style: {
2477
+ position: "relative",
2478
+ display: "flex",
2479
+ alignItems: "center",
2480
+ justifyContent: "center"
2481
+ },
2482
+ children: [/* @__PURE__ */ p(Se, {
2483
+ size: 30,
2484
+ "aria-hidden": "true"
2485
+ }), /* @__PURE__ */ p("span", {
2486
+ className: "sdk-desktop-seek-label",
2487
+ "aria-hidden": "true",
2488
+ children: "10"
2489
+ })]
2490
+ })
2491
+ })
2492
+ ]
2493
+ }),
2494
+ I.enableKeyMoments && br && W.length > 0 && Qe === "panel" && /* @__PURE__ */ m("div", {
2495
+ className: "sdk-chapters-panel",
2496
+ onClick: (e) => e.stopPropagation(),
2497
+ children: [/* @__PURE__ */ p("div", {
2498
+ className: "sdk-chapters-panel-header",
2499
+ children: /* @__PURE__ */ p("span", {
2500
+ className: "sdk-chapters-panel-title",
2501
+ children: "Chapters"
2502
+ })
2503
+ }), /* @__PURE__ */ p("div", {
2504
+ className: "sdk-chapters-panel-list",
2505
+ children: W.map((e, t) => {
2506
+ let n = hr.index === t;
2507
+ return /* @__PURE__ */ m("div", {
2508
+ role: "button",
2509
+ tabIndex: 0,
2510
+ className: `sdk-chapters-panel-item${n ? " active" : ""}`,
2511
+ "aria-label": `${e.title}, ${Q(e.startTime)}${n ? ", current chapter" : ""}`,
2512
+ "aria-current": n ? "true" : void 0,
2513
+ onClick: () => Si(e.startTime, e),
2514
+ onKeyDown: Wi(() => Si(e.startTime, e)),
2515
+ children: [/* @__PURE__ */ p("div", {
2516
+ className: "sdk-chapters-panel-thumb",
2517
+ children: Sr[t] || e.thumbnail ? /* @__PURE__ */ p("img", {
2518
+ src: Sr[t] || e.thumbnail,
2519
+ alt: "",
2520
+ "aria-hidden": "true",
2521
+ style: {
2522
+ width: "100%",
2523
+ height: "100%",
2524
+ objectFit: "cover",
2525
+ display: "block"
2526
+ }
2527
+ }) : /* @__PURE__ */ p(ge, {
2528
+ size: 18,
2529
+ "aria-hidden": "true",
2530
+ style: { color: "rgba(255,255,255,0.3)" }
2531
+ })
2532
+ }), /* @__PURE__ */ m("div", {
2533
+ className: "sdk-chapters-panel-info",
2534
+ children: [
2535
+ /* @__PURE__ */ p("div", {
2536
+ className: "sdk-chapters-panel-item-title",
2537
+ children: e.title
2538
+ }),
2539
+ e.description && /* @__PURE__ */ p("div", {
2540
+ className: "sdk-chapters-panel-item-desc",
2541
+ children: e.description
2542
+ }),
2543
+ /* @__PURE__ */ p("div", {
2544
+ className: "sdk-chapters-panel-item-time",
2545
+ "aria-hidden": "true",
2546
+ children: Q(e.startTime)
2547
+ })
2548
+ ]
2549
+ })]
2550
+ }, t);
2551
+ })
2552
+ })]
2553
+ }),
2554
+ /* @__PURE__ */ m("div", {
2555
+ className: "sdk-desktop-bottom",
2556
+ children: [
2557
+ I.enableKeyMoments && br && W.length > 0 && Qe === "strip" && /* @__PURE__ */ p("div", {
2558
+ className: "sdk-desktop-chapters-strip",
2559
+ children: W.map((e, t) => {
2560
+ let n = hr.index === t;
2561
+ return /* @__PURE__ */ m("div", {
2562
+ role: "button",
2563
+ tabIndex: 0,
2564
+ className: `sdk-desktop-chapter-card${n ? " active" : ""}`,
2565
+ "aria-label": `${e.title}, ${Q(e.startTime)}${n ? ", current chapter" : ""}`,
2566
+ "aria-current": n ? "true" : void 0,
2567
+ onClick: (t) => {
2568
+ t.stopPropagation(), Si(e.startTime, e);
2569
+ },
2570
+ onKeyDown: Wi(() => Si(e.startTime, e)),
2571
+ children: [
2572
+ /* @__PURE__ */ p("div", {
2573
+ className: "sdk-desktop-chapter-thumb",
2574
+ children: Sr[t] || e.thumbnail ? /* @__PURE__ */ p("img", {
2575
+ src: Sr[t] || e.thumbnail,
2576
+ alt: "",
2577
+ "aria-hidden": "true",
2578
+ style: {
2579
+ width: "100%",
2580
+ height: "100%",
2581
+ objectFit: "cover",
2582
+ display: "block"
2583
+ }
2584
+ }) : /* @__PURE__ */ p(ge, {
2585
+ size: 18,
2586
+ "aria-hidden": "true",
2587
+ style: { color: "rgba(255,255,255,0.35)" }
2588
+ })
2589
+ }),
2590
+ /* @__PURE__ */ p("div", {
2591
+ className: "sdk-desktop-chapter-title",
2592
+ children: e.title
2593
+ }),
2594
+ /* @__PURE__ */ p("div", {
2595
+ className: "sdk-desktop-chapter-time",
2596
+ "aria-hidden": "true",
2597
+ children: Q(e.startTime)
2598
+ })
2599
+ ]
2600
+ }, t);
2601
+ })
2602
+ }),
2603
+ /* @__PURE__ */ p("div", {
2604
+ ref: T,
2605
+ role: X ? void 0 : "slider",
2606
+ "aria-label": X ? void 0 : "Seek",
2607
+ "aria-valuemin": X ? void 0 : 0,
2608
+ "aria-valuemax": X ? void 0 : Math.round(B),
2609
+ "aria-valuenow": X ? void 0 : Math.round(V(J === null ? L : J)),
2610
+ "aria-valuetext": X ? void 0 : `${Q(V(J === null ? L : J))} of ${Q(B)}`,
2611
+ tabIndex: X ? void 0 : 0,
2612
+ className: `sdk-seekbar-container sdk-desktop-seekbar${Y ? " sdk-ad-mode" : ""}`,
2613
+ onMouseDown: X ? void 0 : gi,
2614
+ onMouseMove: X ? void 0 : Ni,
2615
+ onMouseLeave: X ? void 0 : Ii,
2616
+ onTouchStart: X ? void 0 : Fi,
2617
+ onKeyDown: X ? void 0 : Gi,
2618
+ style: { pointerEvents: X ? "none" : void 0 },
2619
+ children: Y ? /* @__PURE__ */ p("div", {
2620
+ className: "sdk-ad-progress-fill",
2621
+ style: { width: (() => {
2622
+ let e = F ? F.getCurrentTime() : L, t = $n(e);
2623
+ return t ? `${Math.min(100, Math.max(0, (e - t.start) / (t.end - t.start) * 100))}%` : "0%";
2624
+ })() }
2625
+ }) : /* @__PURE__ */ m(ee, { children: [
2626
+ /* @__PURE__ */ p("div", {
2627
+ className: "sdk-seekbar-buffered",
2628
+ style: { width: `${an ? (F && F.getBufferedRanges()[0]?.end || 0) / an * 100 : 0}%` }
2629
+ }),
2630
+ B > 0 && R.filter((e) => !kn.has(e.startTime)).map((e, t) => /* @__PURE__ */ p("div", {
2631
+ className: "sdk-seekbar-adbreak",
2632
+ style: {
2633
+ left: `${V(e.startTime) / B * 100}%`,
2634
+ width: "3px"
2635
+ }
2636
+ }, t)),
2637
+ /* @__PURE__ */ p("div", {
2638
+ className: "sdk-seekbar-progress",
2639
+ style: {
2640
+ width: q ? `${Ri > 0 ? $ / Ri * 100 : 0}%` : `${B ? V(J === null ? L : J) / B * 100 : 0}%`,
2641
+ background: "#ffffff",
2642
+ boxShadow: "none"
2643
+ },
2644
+ children: /* @__PURE__ */ p("div", { className: "sdk-seekbar-handle" })
2645
+ }),
2646
+ I.enableKeyMoments && W.map((e, t) => B === 0 ? null : /* @__PURE__ */ p("div", {
2647
+ className: "sdk-seekbar-chapter-marker sdk-desktop-chapter-dot",
2648
+ style: { left: `${V(e.startTime) / B * 100}%` }
2649
+ }, t)),
2650
+ Br !== null && Kr && /* @__PURE__ */ m("div", {
2651
+ className: "sdk-thumbnail-tooltip",
2652
+ style: { left: `${Hr}px` },
2653
+ children: [
2654
+ /* @__PURE__ */ p("div", {
2655
+ className: "sdk-thumbnail-preview",
2656
+ children: /* @__PURE__ */ p("img", {
2657
+ src: Kr,
2658
+ alt: "preview",
2659
+ style: {
2660
+ width: "100%",
2661
+ height: "100%",
2662
+ objectFit: "cover",
2663
+ borderRadius: "8px",
2664
+ display: "block"
2665
+ }
2666
+ })
2667
+ }),
2668
+ Jr && /* @__PURE__ */ p("div", {
2669
+ className: "sdk-thumbnail-chapter-name",
2670
+ children: Jr.title
2671
+ }),
2672
+ /* @__PURE__ */ p("div", {
2673
+ className: "sdk-thumbnail-time-label",
2674
+ children: Q(V(Wr))
2675
+ })
2676
+ ]
2677
+ })
2678
+ ] })
2679
+ }),
2680
+ /* @__PURE__ */ m("div", {
2681
+ className: "sdk-desktop-controls-row",
2682
+ children: [/* @__PURE__ */ m("div", {
2683
+ className: "sdk-desktop-left-controls",
2684
+ children: [!Y && /* @__PURE__ */ p("div", {
2685
+ className: "sdk-time-display",
2686
+ children: q ? `${Q($)} / ${Q(Ri)}` : `${Q(V(J === null ? L : J))} / ${Q(B)}`
2687
+ }), $e === "slider" && /* @__PURE__ */ m("div", {
2688
+ className: "sdk-volume-control",
2689
+ children: [/* @__PURE__ */ p("button", {
2690
+ className: "sdk-desktop-icon-btn",
2691
+ onClick: (e) => {
2692
+ e.stopPropagation(), _i();
2693
+ },
2694
+ "data-tooltip": Bi ? "Unmute" : "Mute",
2695
+ "aria-label": Bi ? "Unmute" : "Mute",
2696
+ "aria-pressed": Bi,
2697
+ children: Hi()
2698
+ }), /* @__PURE__ */ p("input", {
2699
+ type: "range",
2700
+ className: "sdk-volume-slider",
2701
+ min: 0,
2702
+ max: 1,
2703
+ step: .02,
2704
+ value: Bi ? 0 : zi,
2705
+ "aria-label": "Volume",
2706
+ "aria-valuetext": Bi ? "Muted" : `${Math.round(zi * 100)}%`,
2707
+ style: { "--vol-pct": Math.round((Bi ? 0 : zi) * 100) },
2708
+ onChange: (e) => {
2709
+ let t = parseFloat(e.target.value);
2710
+ q ? (F?.casting.remoteSetVolume(t), t > 0 && F?.casting.remoteSetMute(!1)) : (F?.setVolume(t), t > 0 && ln && F?.setMute(!1));
2711
+ },
2712
+ onClick: (e) => e.stopPropagation()
2713
+ })]
2714
+ })]
2715
+ }), /* @__PURE__ */ m("div", {
2716
+ className: "sdk-desktop-right-icons",
2717
+ children: [
2718
+ I.enableKeyMoments && W.length > 0 && !Y && /* @__PURE__ */ p("button", {
2719
+ className: `sdk-desktop-icon-btn${br ? " active" : ""}`,
2720
+ onClick: (e) => {
2721
+ e.stopPropagation(), xr(!br);
2722
+ },
2723
+ "data-tooltip": "Key Moments",
2724
+ "aria-label": br ? "Hide chapters" : "Show chapters",
2725
+ "aria-pressed": br,
2726
+ children: /* @__PURE__ */ p(ge, {
2727
+ size: 20,
2728
+ "aria-hidden": "true"
2729
+ })
2730
+ }),
2731
+ I.enableSubtitles && !Y && lr.some((e) => !e.isNative) && /* @__PURE__ */ m("div", {
2732
+ className: "sdk-menu-container",
2733
+ children: [/* @__PURE__ */ p("button", {
2734
+ className: `sdk-desktop-icon-btn${U === "off" ? "" : " active"}`,
2735
+ onClick: (e) => {
2736
+ e.stopPropagation(), Ki("subtitles");
2737
+ },
2738
+ "data-tooltip": "Captions",
2739
+ "aria-label": "Captions",
2740
+ "aria-haspopup": "listbox",
2741
+ "aria-expanded": G === "subtitles",
2742
+ children: /* @__PURE__ */ p(ue, {
2743
+ size: 20,
2744
+ "aria-hidden": "true"
2745
+ })
2746
+ }), G === "subtitles" && /* @__PURE__ */ m("div", {
2747
+ ref: qi,
2748
+ className: "sdk-dropup-menu",
2749
+ role: "listbox",
2750
+ "aria-label": "Captions",
2751
+ children: [
2752
+ /* @__PURE__ */ p("div", {
2753
+ className: "sdk-dropup-header",
2754
+ "aria-hidden": "true",
2755
+ children: "Subtitles"
2756
+ }),
2757
+ /* @__PURE__ */ m("div", {
2758
+ role: "option",
2759
+ "aria-selected": U === "off",
2760
+ tabIndex: 0,
2761
+ className: `sdk-dropup-item ${U === "off" ? "active" : ""}`,
2762
+ onClick: () => bi("off"),
2763
+ onKeyDown: Ui(() => bi("off")),
2764
+ children: [/* @__PURE__ */ p("span", { children: "Off" }), U === "off" && /* @__PURE__ */ p(y, {
2765
+ size: 12,
2766
+ "aria-hidden": "true"
2767
+ })]
2768
+ }),
2769
+ lr.map((e) => /* @__PURE__ */ m("div", {
2770
+ role: "option",
2771
+ "aria-selected": U === e.id,
2772
+ tabIndex: 0,
2773
+ className: `sdk-dropup-item ${U === e.id ? "active" : ""}`,
2774
+ onClick: () => bi(e.id),
2775
+ onKeyDown: Ui(() => bi(e.id)),
2776
+ children: [/* @__PURE__ */ p("span", { children: x(e) }), U === e.id && /* @__PURE__ */ p(y, {
2777
+ size: 12,
2778
+ "aria-hidden": "true"
2779
+ })]
2780
+ }, e.id))
2781
+ ]
2782
+ })]
2783
+ }),
2784
+ I.allowMultipleAudio && dr.length > 1 && !Y && /* @__PURE__ */ m("div", {
2785
+ className: "sdk-menu-container",
2786
+ children: [/* @__PURE__ */ p("button", {
2787
+ className: `sdk-desktop-icon-btn${G === "audio" ? " active" : ""}`,
2788
+ onClick: (e) => {
2789
+ e.stopPropagation(), Ki("audio");
2790
+ },
2791
+ "data-tooltip": "Audio Track",
2792
+ "aria-label": "Audio track",
2793
+ "aria-haspopup": "listbox",
2794
+ "aria-expanded": G === "audio",
2795
+ children: /* @__PURE__ */ p(he, {
2796
+ size: 20,
2797
+ "aria-hidden": "true"
2798
+ })
2799
+ }), G === "audio" && /* @__PURE__ */ m("div", {
2800
+ ref: qi,
2801
+ className: "sdk-dropup-menu",
2802
+ role: "listbox",
2803
+ "aria-label": "Audio track",
2804
+ children: [/* @__PURE__ */ p("div", {
2805
+ className: "sdk-dropup-header",
2806
+ "aria-hidden": "true",
2807
+ children: "Audio Track"
2808
+ }), dr.map((e) => /* @__PURE__ */ m("div", {
2809
+ role: "option",
2810
+ "aria-selected": pr === e.id,
2811
+ tabIndex: 0,
2812
+ className: `sdk-dropup-item ${pr === e.id ? "active" : ""}`,
2813
+ onClick: () => {
2814
+ F?.setAudioTrack(e.id), mr(e.id), K("none"), Tr(`Audio: ${x(e)}`);
2815
+ },
2816
+ onKeyDown: Ui(() => {
2817
+ F?.setAudioTrack(e.id), mr(e.id), K("none"), Tr(`Audio: ${x(e)}`);
2818
+ }),
2819
+ children: [/* @__PURE__ */ p("span", { children: x(e) }), pr === e.id && /* @__PURE__ */ p(y, {
2820
+ size: 12,
2821
+ "aria-hidden": "true"
2822
+ })]
2823
+ }, e.id))]
2824
+ })]
2825
+ }),
2826
+ I.enablePlaybackSpeed && !Y && /* @__PURE__ */ m("div", {
2827
+ className: "sdk-menu-container",
2828
+ children: [/* @__PURE__ */ p("button", {
2829
+ className: `sdk-desktop-icon-btn${G === "speed" ? " active" : ""}`,
2830
+ onClick: (e) => {
2831
+ e.stopPropagation(), Ki("speed");
2832
+ },
2833
+ "data-tooltip": "Playback Speed",
2834
+ "aria-label": "Playback speed",
2835
+ "aria-haspopup": "listbox",
2836
+ "aria-expanded": G === "speed",
2837
+ children: /* @__PURE__ */ p(me, {
2838
+ size: 20,
2839
+ "aria-hidden": "true"
2840
+ })
2841
+ }), G === "speed" && /* @__PURE__ */ m("div", {
2842
+ ref: qi,
2843
+ className: "sdk-dropup-menu",
2844
+ role: "listbox",
2845
+ "aria-label": "Playback speed",
2846
+ children: [/* @__PURE__ */ p("div", {
2847
+ className: "sdk-dropup-header",
2848
+ "aria-hidden": "true",
2849
+ children: "Speed"
2850
+ }), [
2851
+ .5,
2852
+ .75,
2853
+ 1,
2854
+ 1.25,
2855
+ 1.5,
2856
+ 2
2857
+ ].map((e) => /* @__PURE__ */ m("div", {
2858
+ role: "option",
2859
+ "aria-selected": vr === e,
2860
+ tabIndex: 0,
2861
+ className: `sdk-dropup-item ${vr === e ? "active" : ""}`,
2862
+ onClick: () => vi(e),
2863
+ onKeyDown: Ui(() => vi(e)),
2864
+ children: [/* @__PURE__ */ p("span", { children: e === 1 ? "Normal" : `${e}x` }), vr === e && /* @__PURE__ */ p(y, {
2865
+ size: 12,
2866
+ "aria-hidden": "true"
2867
+ })]
2868
+ }, e))]
2869
+ })]
2870
+ }),
2871
+ I.enableQuality && !Y && /* @__PURE__ */ m("div", {
2872
+ className: "sdk-menu-container",
2873
+ children: [/* @__PURE__ */ p("button", {
2874
+ className: `sdk-desktop-icon-btn${ir.id === -1 ? "" : " active"}`,
2875
+ onClick: (e) => {
2876
+ e.stopPropagation(), Ki("quality");
2877
+ },
2878
+ "data-tooltip": "Quality",
2879
+ "aria-label": "Video quality",
2880
+ "aria-haspopup": "listbox",
2881
+ "aria-expanded": G === "quality",
2882
+ children: /* @__PURE__ */ p(Me, {
2883
+ size: 20,
2884
+ "aria-hidden": "true"
2885
+ })
2886
+ }), G === "quality" && /* @__PURE__ */ m("div", {
2887
+ ref: qi,
2888
+ className: "sdk-dropup-menu large",
2889
+ role: "listbox",
2890
+ "aria-label": "Video quality",
2891
+ children: [/* @__PURE__ */ p("div", {
2892
+ className: "sdk-dropup-header",
2893
+ "aria-hidden": "true",
2894
+ children: "Quality"
2895
+ }), nr.map((e) => /* @__PURE__ */ m("div", {
2896
+ role: "option",
2897
+ "aria-selected": ir.id === e.id,
2898
+ tabIndex: 0,
2899
+ className: `sdk-dropup-item ${ir.id === e.id ? "active" : ""}`,
2900
+ onClick: () => yi(e.id),
2901
+ onKeyDown: Ui(() => yi(e.id)),
2902
+ children: [/* @__PURE__ */ p("span", { children: e.label }), ir.id === e.id && /* @__PURE__ */ p(y, {
2903
+ size: 12,
2904
+ "aria-hidden": "true"
2905
+ })]
2906
+ }, e.id))]
2907
+ })]
2908
+ }),
2909
+ C && C.length > 1 && !Y && /* @__PURE__ */ m("div", {
2910
+ className: "sdk-menu-container",
2911
+ children: [/* @__PURE__ */ p("button", {
2912
+ className: `sdk-desktop-icon-btn${G === "sources" ? " active" : ""}`,
2913
+ onClick: (e) => {
2914
+ e.stopPropagation(), Ki("sources");
2915
+ },
2916
+ "data-tooltip": "Select Source",
2917
+ "aria-label": "Select source",
2918
+ "aria-haspopup": "listbox",
2919
+ "aria-expanded": G === "sources",
2920
+ children: /* @__PURE__ */ p(Ne, {
2921
+ size: 20,
2922
+ "aria-hidden": "true"
2923
+ })
2924
+ }), G === "sources" && /* @__PURE__ */ m("div", {
2925
+ ref: qi,
2926
+ className: "sdk-dropup-menu",
2927
+ role: "listbox",
2928
+ "aria-label": "Select source",
2929
+ children: [/* @__PURE__ */ p("div", {
2930
+ className: "sdk-dropup-header",
2931
+ "aria-hidden": "true",
2932
+ children: "Source"
2933
+ }), C.map((e, t) => /* @__PURE__ */ m("div", {
2934
+ role: "option",
2935
+ "aria-selected": ot === t,
2936
+ tabIndex: 0,
2937
+ className: `sdk-dropup-item ${ot === t ? "active" : ""}`,
2938
+ onClick: () => xi(t),
2939
+ onKeyDown: Ui(() => xi(t)),
2940
+ children: [/* @__PURE__ */ p("span", { children: e.label }), ot === t && /* @__PURE__ */ p(y, {
2941
+ size: 12,
2942
+ "aria-hidden": "true"
2943
+ })]
2944
+ }, t))]
2945
+ })]
2946
+ }),
2947
+ I.enablePiP && !Y && /* @__PURE__ */ p("button", {
2948
+ className: `sdk-desktop-icon-btn${bn ? " active" : ""}`,
2949
+ onClick: (e) => {
2950
+ e.stopPropagation(), wi();
2951
+ },
2952
+ "data-tooltip": "Picture-in-Picture",
2953
+ "aria-label": bn ? "Exit picture-in-picture" : "Enter picture-in-picture",
2954
+ "aria-pressed": bn,
2955
+ children: /* @__PURE__ */ p(ye, {
2956
+ size: 20,
2957
+ "aria-hidden": "true"
2958
+ })
2959
+ }),
2960
+ $e === "button" && /* @__PURE__ */ p("button", {
2961
+ className: "sdk-desktop-icon-btn",
2962
+ onClick: (e) => {
2963
+ e.stopPropagation(), _i();
2964
+ },
2965
+ "data-tooltip": Bi ? "Unmute" : "Mute",
2966
+ "aria-label": Bi ? "Unmute" : "Mute",
2967
+ "aria-pressed": Bi,
2968
+ children: Hi()
2969
+ }),
2970
+ Ke && /* @__PURE__ */ p("button", {
2971
+ className: "sdk-desktop-icon-btn",
2972
+ onClick: (e) => {
2973
+ e.stopPropagation(), Ei();
2974
+ },
2975
+ "data-tooltip": pn || hn ? "Exit fullscreen" : "Fullscreen",
2976
+ "aria-label": pn || hn ? "Exit fullscreen" : "Enter fullscreen",
2977
+ "aria-pressed": pn || hn,
2978
+ children: p(pn ? ve : _e, {
2979
+ size: 20,
2980
+ "aria-hidden": "true"
2981
+ })
2982
+ })
2983
+ ]
2984
+ })]
2985
+ })
2986
+ ]
2987
+ })
2988
+ ] })]
2989
+ }),
2990
+ Sn && (() => {
2991
+ let e = R.find((e) => $ >= e.startTime && $ < e.endTime), t = e ? e.endTime - e.startTime : B, n = e ? Math.max(0, $ - e.startTime) : V($);
2992
+ return f(/* @__PURE__ */ m("div", {
2993
+ className: `gb-pip-overlay${Li ? "" : " gb-pip-paused"}`,
2994
+ children: [
2995
+ /* @__PURE__ */ p("div", {}),
2996
+ /* @__PURE__ */ m("div", {
2997
+ className: "gb-pip-center",
2998
+ children: [
2999
+ /* @__PURE__ */ p("button", {
3000
+ className: "gb-pip-btn",
3001
+ onClick: () => Z(H(Math.max(0, V($) - 10)), {
3002
+ eventType: "fast_backward",
3003
+ skipSeconds: 10
3004
+ }),
3005
+ "aria-label": "Rewind 10 seconds",
3006
+ disabled: Y,
3007
+ children: /* @__PURE__ */ p(xe, {
3008
+ size: 20,
3009
+ "aria-hidden": "true"
3010
+ })
3011
+ }),
3012
+ /* @__PURE__ */ p("button", {
3013
+ className: "gb-pip-btn gb-pip-play",
3014
+ onClick: mi,
3015
+ "aria-label": wn ? "Replay" : Li ? "Pause" : "Play",
3016
+ children: wn ? /* @__PURE__ */ p(xe, {
3017
+ size: 24,
3018
+ "aria-hidden": "true"
3019
+ }) : Li ? /* @__PURE__ */ p(b, {
3020
+ size: 24,
3021
+ "aria-hidden": "true"
3022
+ }) : /* @__PURE__ */ p(be, {
3023
+ size: 24,
3024
+ "aria-hidden": "true",
3025
+ style: { marginLeft: 2 }
3026
+ })
3027
+ }),
3028
+ /* @__PURE__ */ p("button", {
3029
+ className: "gb-pip-btn",
3030
+ onClick: () => Z(H(Math.min(B, V($) + 10)), {
3031
+ eventType: "fast_forward",
3032
+ skipSeconds: 10
3033
+ }),
3034
+ "aria-label": "Skip forward 10 seconds",
3035
+ disabled: Y,
3036
+ children: /* @__PURE__ */ p(Se, {
3037
+ size: 20,
3038
+ "aria-hidden": "true"
3039
+ })
3040
+ })
3041
+ ]
3042
+ }),
3043
+ /* @__PURE__ */ m("div", {
3044
+ className: "gb-pip-bottom",
3045
+ children: [/* @__PURE__ */ p("div", {
3046
+ className: "gb-pip-progress",
3047
+ onClick: Ti,
3048
+ children: /* @__PURE__ */ p("div", {
3049
+ className: "gb-pip-progress-fill",
3050
+ style: { width: `${t ? n / t * 100 : 0}%` }
3051
+ })
3052
+ }), /* @__PURE__ */ m("div", {
3053
+ className: "gb-pip-time",
3054
+ children: [
3055
+ Q(n),
3056
+ " / ",
3057
+ Q(t)
3058
+ ]
3059
+ })]
3060
+ })
3061
+ ]
3062
+ }), Sn.document.body);
3063
+ })()
3064
+ ]
3065
+ });
3066
+ }, We = "https://dev-api.go-boss.com";
3067
+ function Ge(e) {
3068
+ return {
3069
+ "x-player-key": e,
3070
+ "Content-Type": "application/json"
3071
+ };
3072
+ }
3073
+ async function Ke(e, t = We, n = {}) {
3074
+ let r = await fetch(`${t}/api/player/sdk/init`, {
3075
+ method: "POST",
3076
+ headers: Ge(e),
3077
+ body: JSON.stringify({ videoUrl: n.videoUrl })
3078
+ });
3079
+ if (!r.ok) throw Error(`SDK init failed: ${r.status}`);
3080
+ return await r.json();
3081
+ }
3082
+ async function qe(e, t, n = We) {
3083
+ let { sessionId: r, videoId: i, videoTitle: a, videoUrl: o, contentDurationSec: s } = t, c = await fetch(`${n}/api/player/sdk/session/start`, {
3084
+ method: "POST",
3085
+ headers: Ge(e),
3086
+ body: JSON.stringify({
3087
+ sessionId: r,
3088
+ videoId: i,
3089
+ videoTitle: a,
3090
+ videoUrl: o,
3091
+ contentDurationSec: typeof s == "number" && Number.isFinite(s) && s > 0 ? s : void 0
3092
+ })
3093
+ });
3094
+ if (!c.ok) throw Error(`Session start failed: ${c.status}`);
3095
+ }
3096
+ async function Je(e, t, n, r, i = We) {
3097
+ let a = {
3098
+ sessionId: t,
3099
+ currentTime: n,
3100
+ duration: r
3101
+ }, o = await fetch(`${i}/api/player/sdk/session/heartbeat`, {
3102
+ method: "POST",
3103
+ headers: Ge(e),
3104
+ body: JSON.stringify(a)
3105
+ });
3106
+ if (!o.ok) throw Error(`Heartbeat failed: ${o.status}`);
3107
+ }
3108
+ async function Ye(e, t, n = 0, r = 0, i = We) {
3109
+ let a = await fetch(`${i}/api/player/sdk/session/end`, {
3110
+ method: "POST",
3111
+ headers: Ge(e),
3112
+ body: JSON.stringify({
3113
+ sessionId: t,
3114
+ currentTime: n,
3115
+ duration: r
3116
+ })
3117
+ });
3118
+ if (!a.ok) throw Error(`Session end failed: ${a.status}`);
3119
+ }
3120
+ async function Xe(e, t, n = We) {
3121
+ let r = await fetch(`${n}/api/player/sdk/events`, {
3122
+ method: "POST",
3123
+ headers: Ge(e),
3124
+ body: JSON.stringify(t)
3125
+ });
3126
+ if (!r.ok) throw Error(`Event ${t.eventType} failed: ${r.status}`);
3127
+ }
3128
+ function Ze(e, t, n = 0, r = 0, i = We) {
3129
+ fetch(`${i}/api/player/sdk/session/end`, {
3130
+ method: "POST",
3131
+ headers: Ge(e),
3132
+ body: JSON.stringify({
3133
+ sessionId: t,
3134
+ currentTime: n,
3135
+ duration: r
3136
+ }),
3137
+ keepalive: !0
3138
+ });
3139
+ }
3140
+ //#endregion
3141
+ //#region src/delegate.ts
3142
+ function S() {
3143
+ if (!(typeof screen > "u")) return screen.orientation?.type ?? void 0;
3144
+ }
3145
+ var Qe = class {
3146
+ constructor() {
3147
+ this.autoplay = !1, this.keyMoments = [], this.isPlaybackActive = !1, this.hasFinished = !1, this.hasDismissed = !1, this.lastCurrentTime = 0, this.lastDuration = 0, this.lastWatchDuration = 0, this.prevSpeed = 1, this.pendingSeek = null;
3148
+ }
3149
+ setDelegate(e) {
3150
+ this.delegate = e;
3151
+ }
3152
+ setAutoplay(e) {
3153
+ this.autoplay = e;
3154
+ }
3155
+ setKeyMoments(e) {
3156
+ this.keyMoments = e;
3157
+ }
3158
+ handleAnalyticsEvent(e) {
3159
+ switch (typeof e.currentTime == "number" && !Number.isNaN(e.currentTime) && (this.lastCurrentTime = e.currentTime), typeof e.duration == "number" && !Number.isNaN(e.duration) && (this.lastDuration = e.duration), typeof e.totalWatchTime == "number" && (this.lastWatchDuration = e.totalWatchTime), e.eventType) {
3160
+ case "play":
3161
+ this.isPlaybackActive ? this.call("playerDidResumePlaying", e.currentTime) : (this.isPlaybackActive = !0, this.hasFinished = !1, this.call("playerDidStartPlaying", e.currentTime, this.autoplay));
3162
+ break;
3163
+ case "pause":
3164
+ e.duration > 0 && e.currentTime >= e.duration - .25 || this.call("playerDidPause", e.currentTime);
3165
+ break;
3166
+ case "ended":
3167
+ this.isPlaybackActive = !1, this.hasFinished = !0, this.call("playerDidFinishPlaying", e.currentTime, e.totalWatchTime ?? this.lastWatchDuration);
3168
+ break;
3169
+ case "seek":
3170
+ this.beginSeek(e.seekFrom ?? this.lastCurrentTime, e.seekTo ?? e.currentTime);
3171
+ break;
3172
+ case "fast_forward":
3173
+ this.beginSeek(Math.max(0, e.currentTime - (e.skipSeconds ?? 10)), e.currentTime);
3174
+ break;
3175
+ case "fast_backward":
3176
+ this.beginSeek(e.currentTime + (e.skipSeconds ?? 10), e.currentTime);
3177
+ break;
3178
+ case "buffering_start":
3179
+ this.call("playerDidStartBuffering", e.currentTime);
3180
+ break;
3181
+ case "buffering_end":
3182
+ this.call("playerDidFinishBuffering", e.currentTime);
3183
+ break;
3184
+ case "quality_change": {
3185
+ let t = e.rendition;
3186
+ t && t !== this.prevQuality && (this.call("playerDidChangeQuality", this.prevQuality, t, e.isAutoSwitch ?? !1), this.prevQuality = t);
3187
+ break;
3188
+ }
3189
+ case "subtitle_change":
3190
+ if (e.subtitleEnabled === !1) this.call("playerDidDisableSubtitle", this.prevSubtitle), this.prevSubtitle = void 0;
3191
+ else {
3192
+ let t = e.subtitleLanguage ?? "";
3193
+ this.call("playerDidChangeSubtitle", this.prevSubtitle, t), this.prevSubtitle = t;
3194
+ }
3195
+ break;
3196
+ case "audio_track_change": {
3197
+ let t = e.audioTrack ?? "";
3198
+ this.call("playerDidChangeAudioTrack", this.prevAudioTrack, t), this.prevAudioTrack = t;
3199
+ break;
3200
+ }
3201
+ case "speed_change": {
3202
+ let t = e.speed ?? 1;
3203
+ t !== this.prevSpeed && (this.call("playerDidChangePlaybackSpeed", this.prevSpeed, t), this.prevSpeed = t);
3204
+ break;
3205
+ }
3206
+ case "fullscreen_enter":
3207
+ this.call("playerDidEnterFullscreen", S());
3208
+ break;
3209
+ case "fullscreen_exit":
3210
+ this.call("playerDidExitFullscreen", S());
3211
+ break;
3212
+ case "key_moments": {
3213
+ let t = e.momentTitle ?? "", n = e.momentTime ?? e.currentTime, r = this.keyMoments, i = r.findIndex((e) => t && e.title === t || e.startTime === n), a = i >= 0 ? r[i] : void 0;
3214
+ this.call("playerDidSelectKeyMoment", i >= 0 ? String(i) : void 0, a?.title ?? t, a?.startTime ?? n, a?.endTime ?? n);
3215
+ break;
3216
+ }
3217
+ case "pip_toggle":
3218
+ (e.pipState ? e.pipState === "entered" : e.errorMessage === "entered") ? this.call("playerDidEnterPictureInPicture", e.currentTime) : this.call("playerDidExitPictureInPicture", e.currentTime);
3219
+ break;
3220
+ case "error":
3221
+ this.call("playerDidEncounterPlaybackError", e.errorCode == null ? "PLAYER_ERROR" : String(e.errorCode), e.errorMessage ?? "Unknown player error", e.isRecoverable ?? !1);
3222
+ break;
3223
+ case "network_error":
3224
+ this.call("playerDidEncounterNetworkError", e.errorCode ?? 0, e.errorMessage ?? "Network error", e.isRecoverable ?? !1);
3225
+ break;
3226
+ }
3227
+ }
3228
+ handleTimeUpdate(e) {
3229
+ if (this.lastCurrentTime = e, this.pendingSeek) {
3230
+ let { fromTime: t, startedWallMs: n } = this.pendingSeek;
3231
+ this.pendingSeek = null, this.call("playerDidFinishSeeking", t, e, (Date.now() - n) / 1e3);
3232
+ }
3233
+ this.call("playerDidUpdateCurrentTime", e, this.lastDuration);
3234
+ }
3235
+ notifyDismissed() {
3236
+ this.hasDismissed || !this.isPlaybackActive || this.hasFinished || (this.hasDismissed = !0, this.call("playerDidDismiss", this.lastCurrentTime, this.lastWatchDuration));
3237
+ }
3238
+ beginSeek(e, t) {
3239
+ if (this.pendingSeek) {
3240
+ this.pendingSeek.toTime = t;
3241
+ return;
3242
+ }
3243
+ this.pendingSeek = {
3244
+ fromTime: e,
3245
+ toTime: t,
3246
+ startedWallMs: Date.now()
3247
+ }, this.call("playerDidStartSeeking", e);
3248
+ }
3249
+ call(e, ...t) {
3250
+ let n = this.delegate, r = n?.[e];
3251
+ if (typeof r == "function") try {
3252
+ r.apply(n, t);
3253
+ } catch (t) {
3254
+ console.error(`[PlayerSDK Delegate] ${String(e)} callback failed:`, t);
3255
+ }
3256
+ }
3257
+ }, $e = {
3258
+ subtitles: "subtitle_support",
3259
+ ads: "ad_support",
3260
+ chapterMarkers: "key_moments",
3261
+ playbackSpeed: "playback_speed",
3262
+ airplay: "airplay",
3263
+ chromecast: "chromecast",
3264
+ pictureInPicture: "picture_in_picture",
3265
+ multipleResolution: "multiple_resolution",
3266
+ multipleAudio: "multiple_audio",
3267
+ drmProtection: "drm_protection",
3268
+ screenRecordingPrevention: "screen_recording_prevention",
3269
+ signalStrength: "signal_strength"
3270
+ };
3271
+ function et(e) {
3272
+ let t = {
3273
+ m3u8_playback: !0,
3274
+ subtitle_support: !1,
3275
+ playback_speed: !1,
3276
+ airplay: !1,
3277
+ chromecast: !1,
3278
+ picture_in_picture: !1,
3279
+ multiple_resolution: !1,
3280
+ multiple_audio: !1,
3281
+ key_moments: !1,
3282
+ drm_protection: !1,
3283
+ screen_recording_prevention: !1,
3284
+ signal_strength: !1,
3285
+ ad_support: !1
3286
+ };
3287
+ for (let [n, r] of Object.entries($e)) n in e && (t[r] = e[n]);
3288
+ return t;
3289
+ }
3290
+ function tt(e) {
3291
+ if (!e) return (e) => e;
3292
+ let t = [];
3293
+ for (let n of e.split(",")) {
3294
+ let [e, r] = n.split("=");
3295
+ e?.trim() && r?.trim() && t.push({
3296
+ domain: e.trim(),
3297
+ proxyPath: r.trim()
3298
+ });
3299
+ }
3300
+ return (e) => {
3301
+ for (let { domain: n, proxyPath: r } of t) if (e.includes(n)) try {
3302
+ let t = new URL(e);
3303
+ return `${r}${t.pathname}${t.search}`;
3304
+ } catch {
3305
+ return e.replace(`https://${n}`, r);
3306
+ }
3307
+ return e;
3308
+ };
3309
+ }
3310
+ function nt(e) {
3311
+ let t = e.replace("#", "");
3312
+ return t.length === 6 ? `${parseInt(t.substring(0, 2), 16)}, ${parseInt(t.substring(2, 4), 16)}, ${parseInt(t.substring(4, 6), 16)}` : "99, 102, 241";
3313
+ }
3314
+ var rt = 30 * 1e3;
3315
+ function it(e, t) {
3316
+ switch (e.eventType) {
3317
+ case "pause": return {
3318
+ eventType: "pause",
3319
+ extras: {}
3320
+ };
3321
+ case "seek": return {
3322
+ eventType: "seek",
3323
+ extras: {
3324
+ seekFrom: e.seekFrom ?? 0,
3325
+ seekTo: e.seekTo ?? e.currentTime ?? 0
3326
+ }
3327
+ };
3328
+ case "mute": return {
3329
+ eventType: "mute",
3330
+ extras: { isMuted: e.isMuted ?? !0 }
3331
+ };
3332
+ case "fast_forward": return {
3333
+ eventType: "fast_forward",
3334
+ extras: { skipSeconds: e.skipSeconds ?? 10 }
3335
+ };
3336
+ case "fast_backward": return {
3337
+ eventType: "fast_backward",
3338
+ extras: { skipSeconds: e.skipSeconds ?? 10 }
3339
+ };
3340
+ case "key_moments": return {
3341
+ eventType: "key_moments",
3342
+ extras: {
3343
+ momentTitle: e.momentTitle ?? "",
3344
+ momentTime: e.momentTime ?? 0
3345
+ }
3346
+ };
3347
+ case "buffering_start": return {
3348
+ eventType: "buffering_start",
3349
+ extras: { bufferingCount: e.bufferingCount ?? 0 }
3350
+ };
3351
+ case "buffering_end": return {
3352
+ eventType: "buffering_end",
3353
+ extras: {}
3354
+ };
3355
+ case "quality_change": return !t || !e.rendition || t === e.rendition ? null : {
3356
+ eventType: "quality_change",
3357
+ extras: {
3358
+ from: t,
3359
+ to: e.rendition
3360
+ }
3361
+ };
3362
+ case "speed_change": return {
3363
+ eventType: "speed_change",
3364
+ extras: { speed: e.speed ?? 1 }
3365
+ };
3366
+ case "subtitle_change": return e.subtitleEnabled === !1 ? {
3367
+ eventType: "subtitle_disable",
3368
+ extras: { enabled: !1 }
3369
+ } : {
3370
+ eventType: "subtitle_change",
3371
+ extras: {
3372
+ language: e.subtitleLanguage ?? "",
3373
+ enabled: !0
3374
+ }
3375
+ };
3376
+ case "audio_track_change": return {
3377
+ eventType: "audio_track_change",
3378
+ extras: { track: e.audioTrack ?? "" }
3379
+ };
3380
+ case "pip_toggle": return {
3381
+ eventType: "pip_toggle",
3382
+ extras: { enabled: e.errorMessage === "entered" }
3383
+ };
3384
+ case "fullscreen_enter": return {
3385
+ eventType: "fullscreen_toggle",
3386
+ extras: { enabled: !0 }
3387
+ };
3388
+ case "fullscreen_exit": return {
3389
+ eventType: "fullscreen_toggle",
3390
+ extras: { enabled: !1 }
3391
+ };
3392
+ case "error": return {
3393
+ eventType: "player_error",
3394
+ extras: {
3395
+ code: e.errorCode == null ? "PLAYER_ERROR" : String(e.errorCode),
3396
+ message: e.errorMessage ?? "Unknown player error"
3397
+ }
3398
+ };
3399
+ case "network_error": return {
3400
+ eventType: "network_error",
3401
+ extras: {
3402
+ code: e.errorCode ? String(e.errorCode) : "NETWORK_ERROR",
3403
+ message: e.errorMessage ?? "Network error"
3404
+ }
3405
+ };
3406
+ default: return null;
3407
+ }
3408
+ }
3409
+ function at({ playerKey: e, src: t, subtitles: n, licenseKey: r, themeColor: i = "#6366f1", firebaseConfig: a, proxyDomains: s, apiBaseUrl: l, adTrackingUrl: f, overlayAdUrl: ee, videoId: te, title: h, watermark: g, autoplay: _ = !1, muted: re = !1, autoFullscreen: ie = !1, enableControls: ae = !0, enableSkipAd: oe, skipAdAfterSeconds: se, chaptersDisplayMode: ce = "strip", volumeControlType: v = "slider", subtitleStyle: le, drmConfig: ue, onAnalyticsEvent: de, delegate: y, onKeyMomentsLoaded: fe, initialTime: pe, onTimeUpdate: me }) {
3410
+ let [he, ge] = d([]), [_e, ve] = d(0), [b] = d(() => new Qe());
3411
+ c(() => {
3412
+ b.setDelegate(y), b.setAutoplay(_);
3413
+ }, [
3414
+ b,
3415
+ y,
3416
+ _
3417
+ ]), c(() => () => b.notifyDismissed(), [b]);
3418
+ let ye = Array.isArray(t) ? t : [{
3419
+ label: "Default",
3420
+ url: t
3421
+ }], be = ye[_e]?.url ?? ye[0]?.url ?? "", [xe, Se] = d("loading"), [Ce, we] = d(null), [Te, Ee] = d(0), [De, Oe] = d("network"), ke = u(null), Ae = u(!1), je = u(""), Me = u(!1), Ne = u(!1), Pe = u(void 0), Fe = u(!1), Ie = u(rt), x = u(null), Le = u(0), Re = u(null), ze = u({
3422
+ currentTime: 0,
3423
+ duration: 0
3424
+ }), Be = u(() => {}), Ve = be.split("/").filter(Boolean), He = te || (Ve[Ve.length - 1] ?? "").replace(/\.m3u8.*$/, "") || "video", We = u(be);
3425
+ c(() => {
3426
+ We.current = be;
3427
+ }, [be]);
3428
+ let Ge = o(() => tt(s), [s])(), S = nt(i);
3429
+ c(() => {
3430
+ document.documentElement.style.setProperty("--accent-indigo", i), document.documentElement.style.setProperty("--accent-indigo-rgb", S);
3431
+ }, [i, S]), c(() => {
3432
+ let t = !1;
3433
+ return Ke(e, l, { videoUrl: We.current }).then((e) => {
3434
+ if (t) return;
3435
+ ke.current = e;
3436
+ let { features: n, planTier: r, heartbeatIntervalSeconds: i } = e.result.data;
3437
+ Ie.current = typeof i == "number" && i > 0 ? i * 1e3 : rt;
3438
+ let a = {
3439
+ package: r,
3440
+ is_active: !0,
3441
+ features: et(n),
3442
+ limits: { streaming_minutes: 0 }
3443
+ };
3444
+ console.log("[SDK] Player key validated. Features:", a.features), we(a), Se("ready");
3445
+ }).catch((e) => {
3446
+ if (t) return;
3447
+ console.error("[SDK] Player key validation failed:", e);
3448
+ let n = e.message ?? "";
3449
+ Oe(/init failed: 4\d\d/.test(n) ? "auth" : "network"), Se("error");
3450
+ }), () => {
3451
+ t = !0, x.current &&= (clearTimeout(x.current), null), Le.current = 0, Re.current = null, Se("loading"), we(null), Me.current = !1, je.current = "", Ne.current = !1, Pe.current = void 0;
3452
+ };
3453
+ }, [
3454
+ e,
3455
+ l,
3456
+ Te
3457
+ ]);
3458
+ let $e = o(() => {
3459
+ x.current && (clearTimeout(x.current), x.current = null, Re.current !== null && (Le.current += Date.now() - Re.current, Re.current = null));
3460
+ }, []), at = o(() => {
3461
+ x.current &&= (clearTimeout(x.current), null), Le.current = 0, Re.current = null;
3462
+ }, []), C = o(() => {
3463
+ if (x.current || !je.current) return;
3464
+ Re.current = Date.now();
3465
+ let t = Ie.current - Le.current;
3466
+ x.current = setTimeout(() => {
3467
+ x.current = null, Le.current = 0, Re.current = null;
3468
+ let { currentTime: t, duration: n } = ze.current;
3469
+ console.log(`[SDK] Heartbeat timer fired — ${Ie.current / 1e3}s of real content elapsed`), Je(e, je.current, t, n, l).catch((e) => console.warn("[SDK] Heartbeat failed:", e.message)), Be.current();
3470
+ }, t);
3471
+ }, [e, l]);
3472
+ c(() => {
3473
+ Be.current = C;
3474
+ }, [C]);
3475
+ let ot = u(!0);
3476
+ c(() => {
3477
+ if (ot.current) {
3478
+ ot.current = !1;
3479
+ return;
3480
+ }
3481
+ Fe.current = !0, Pe.current = void 0, $e();
3482
+ }, [_e, $e]), c(() => {
3483
+ let t = () => {
3484
+ if (b.notifyDismissed(), !je.current) return;
3485
+ Ne.current = !0, at();
3486
+ let { currentTime: t, duration: n } = ze.current;
3487
+ Ze(e, je.current, t, n, l);
3488
+ };
3489
+ return window.addEventListener("beforeunload", t), () => {
3490
+ window.removeEventListener("beforeunload", t), at();
3491
+ };
3492
+ }, [
3493
+ e,
3494
+ l,
3495
+ at,
3496
+ b
3497
+ ]);
3498
+ let st = o((t) => {
3499
+ let n = t;
3500
+ if (t.currentTime !== void 0 && (ze.current = {
3501
+ currentTime: t.currentTime,
3502
+ duration: t.duration
3503
+ }), t.eventType === "session_start" && !Me.current && (Me.current = !0, Ne.current = !1, je.current = typeof n.sessionId == "string" ? n.sessionId : "", qe(e, {
3504
+ sessionId: je.current,
3505
+ videoId: He,
3506
+ videoTitle: h,
3507
+ videoUrl: We.current,
3508
+ contentDurationSec: t.duration
3509
+ }, l).catch((e) => console.warn("[SDK] Session start failed:", e.message)), Ae.current || C()), t.eventType === "play" && Me.current && !Ae.current && !Fe.current && C(), t.eventType === "pause" && $e(), t.eventType === "buffering_start" && $e(), t.eventType === "buffering_end" && Me.current && !Ae.current && (Fe.current = !1, C()), t.eventType === "ended" && (at(), je.current)) {
3510
+ Ne.current = !0;
3511
+ let { currentTime: t, duration: n } = ze.current;
3512
+ Ye(e, je.current, t, n, l).catch((e) => console.warn("[SDK] Session end failed:", e.message));
3513
+ }
3514
+ if (Me.current && je.current && !Ne.current) {
3515
+ let n = it(t, Pe.current);
3516
+ n && Xe(e, {
3517
+ eventType: n.eventType,
3518
+ sessionId: je.current,
3519
+ currentTime: t.currentTime ?? 0,
3520
+ videoId: He,
3521
+ videoTitle: h,
3522
+ ...n.extras
3523
+ }, l).catch((e) => console.warn(`[SDK] Event ${n.eventType} failed:`, e.message));
3524
+ }
3525
+ t.eventType === "quality_change" && t.rendition && (Pe.current = t.rendition), console.log("[SDK Analytics]", t), b.handleAnalyticsEvent(t), de?.(t);
3526
+ }, [
3527
+ e,
3528
+ l,
3529
+ He,
3530
+ h,
3531
+ C,
3532
+ $e,
3533
+ at,
3534
+ de,
3535
+ b
3536
+ ]), ct = o((e) => {
3537
+ Ae.current = e, e ? ($e(), console.log("[SDK] Ad break started — heartbeat timer paused")) : (Me.current && C(), console.log("[SDK] Ad break ended — heartbeat timer resumed"));
3538
+ }, [$e, C]), lt = o((e) => {
3539
+ b.setKeyMoments(e), ge(e), fe?.(e);
3540
+ }, [fe, b]), ut = o((e) => {
3541
+ b.handleTimeUpdate(e), me?.(e);
3542
+ }, [me, b]);
3543
+ if (xe === "loading") return /* @__PURE__ */ m("div", {
3544
+ style: {
3545
+ width: "100%",
3546
+ aspectRatio: "16 / 9",
3547
+ background: "#000",
3548
+ borderRadius: 8,
3549
+ display: "flex",
3550
+ alignItems: "center",
3551
+ justifyContent: "center"
3552
+ },
3553
+ children: [/* @__PURE__ */ p("style", { children: "@keyframes boss-sdk-spin{to{transform:rotate(360deg)}}" }), /* @__PURE__ */ p("div", { style: {
3554
+ width: 60,
3555
+ height: 60,
3556
+ borderRadius: "50%",
3557
+ border: `4px solid rgba(${S}, 0.1)`,
3558
+ borderLeftColor: i,
3559
+ borderRightColor: `rgba(${S}, 0.2)`,
3560
+ filter: `drop-shadow(0 0 10px rgba(${S}, 0.5))`,
3561
+ animation: "boss-sdk-spin 1s linear infinite"
3562
+ } })]
3563
+ });
3564
+ if (xe === "error") {
3565
+ let e = De === "auth";
3566
+ return /* @__PURE__ */ p("div", {
3567
+ style: {
3568
+ width: "100%",
3569
+ aspectRatio: "16 / 9",
3570
+ background: "#09090e",
3571
+ borderRadius: 8,
3572
+ display: "flex",
3573
+ alignItems: "center",
3574
+ justifyContent: "center",
3575
+ flexDirection: "column",
3576
+ gap: 20
3577
+ },
3578
+ children: /* @__PURE__ */ p(ne, {
3579
+ title: e ? "Invalid Player Key" : "Something Went Wrong",
3580
+ subtitle: e ? "Your player key is invalid or expired.\nPlease check your configuration." : "We encountered an error while connecting.\nPlease try again.",
3581
+ onRetry: () => Ee((e) => e + 1)
3582
+ })
3583
+ });
3584
+ }
3585
+ return /* @__PURE__ */ p(Ue, {
3586
+ src: be,
3587
+ sources: ye,
3588
+ activeSourceIndex: _e,
3589
+ onSourceChange: (e) => ve(e),
3590
+ subtitles: n,
3591
+ keyMoments: he,
3592
+ themeColor: i,
3593
+ firebaseConfig: a,
3594
+ resolvedEntitlement: Ce,
3595
+ licenseKey: r,
3596
+ title: h,
3597
+ watermark: g,
3598
+ autoplay: _,
3599
+ muted: re,
3600
+ autoFullscreen: ie,
3601
+ enableControls: ae,
3602
+ enableSkipAd: oe,
3603
+ skipAdAfterSeconds: se,
3604
+ chaptersDisplayMode: ce,
3605
+ volumeControlType: v,
3606
+ subtitleStyle: le,
3607
+ drmConfig: ue,
3608
+ overlayAdUrl: ee,
3609
+ adTrackingUrl: f,
3610
+ videoId: He,
3611
+ urlTransformer: Ge,
3612
+ onAnalyticsEvent: st,
3613
+ onAdBreakChange: ct,
3614
+ onKeyMomentsLoaded: lt,
3615
+ initialTime: pe,
3616
+ onTimeUpdate: ut
3617
+ });
3618
+ }
3619
+ //#endregion
3620
+ //#region src/create-player.ts
3621
+ function C(e, t) {
3622
+ let n = te(e), r = t;
3623
+ return n.render(i(at, r)), {
3624
+ update(e) {
3625
+ r = {
3626
+ ...r,
3627
+ ...e
3628
+ }, n.render(i(at, r));
3629
+ },
3630
+ destroy() {
3631
+ n.unmount();
3632
+ }
3633
+ };
3634
+ }
3635
+ //#endregion
3636
+ export { at as BossVideoPlayer, e as FirebaseAnalyticsProvider, t as VideoPlayerSDK, Ue as WebVideoPlayer, C as createPlayer, Ye as endSession, Ke as initSdk, Xe as sendEvent, Je as sendHeartbeat, qe as startSession };
3637
+
3638
+ //# sourceMappingURL=index.js.map