@oddin-gg/havik-player 2.3.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -142,7 +142,7 @@ function ae(e, t) {
142
142
  t?.addEventListener("abort", a, { once: !0 });
143
143
  });
144
144
  }
145
- async function v(e, t, r) {
145
+ async function oe(e, t, r) {
146
146
  let i = ee(t), a = Date.now(), s = i.timeoutMs == null ? Infinity : a + i.timeoutMs, c = 0, l;
147
147
  for (;;) {
148
148
  if (r?.aborted) throw new n("ABORTED", 0, "wait-for-live aborted");
@@ -168,21 +168,21 @@ async function v(e, t, r) {
168
168
  }
169
169
  //#endregion
170
170
  //#region src/core/resolve.ts
171
- async function y(e) {
171
+ async function v(e) {
172
172
  if (!e.matchUrn || typeof e.matchUrn != "string") throw new n("INVALID_URN", 0, "resolveStream: a non-empty matchUrn is required");
173
173
  let t = await u(c(e.baseUrl, `/v1/playback/${encodeURIComponent(e.matchUrn)}`), {
174
174
  credential: e.credential,
175
175
  signal: e.signal,
176
176
  apiHeaders: e.apiHeaders
177
177
  });
178
- if (!t.ok) throw await oe(t);
179
- return ce(await t.json(), e.matchUrn);
178
+ if (!t.ok) throw await se(t);
179
+ return le(await t.json(), e.matchUrn);
180
180
  }
181
- function b(e) {
182
- let t = () => y(e);
183
- return e.waitForLive ? v(t, e.waitForLive, e.signal) : t();
181
+ function y(e) {
182
+ let t = () => v(e);
183
+ return e.waitForLive ? oe(t, e.waitForLive, e.signal) : t();
184
184
  }
185
- async function oe(e) {
185
+ async function se(e) {
186
186
  let t = l(e.headers.get("retry-after")), i = e.headers.get("x-request-id") ?? e.headers.get("x-amzn-requestid") ?? void 0, a = e.statusText || `HTTP ${e.status}`, o, s;
187
187
  try {
188
188
  let t = await e.json();
@@ -198,7 +198,7 @@ async function oe(e) {
198
198
  liveStartsAtMs: s
199
199
  });
200
200
  }
201
- var se = /* @__PURE__ */ new Set([
201
+ var ce = /* @__PURE__ */ new Set([
202
202
  "matchUrn",
203
203
  "protocol",
204
204
  "drmEnabled",
@@ -209,7 +209,7 @@ var se = /* @__PURE__ */ new Set([
209
209
  "expiresAt",
210
210
  "analytics"
211
211
  ]);
212
- function x(e, t) {
212
+ function b(e, t) {
213
213
  let r;
214
214
  try {
215
215
  r = new URL(t);
@@ -219,57 +219,57 @@ function x(e, t) {
219
219
  if (r.protocol !== "https:" && r.protocol !== "http:") throw new n("INTERNAL", 0, `playback ${e} has a disallowed scheme: ${r.protocol}`);
220
220
  return t;
221
221
  }
222
- function ce(e, t) {
222
+ function le(e, t) {
223
223
  if (!e.manifestUrl) throw new n("INTERNAL", 0, "playback response is missing manifestUrl");
224
224
  let r = e.drmEnabled ?? !!e.drm, i = {
225
225
  matchUrn: e.matchUrn ?? t,
226
226
  protocol: "hls",
227
227
  drmEnabled: r,
228
- manifestUrl: x("manifestUrl", e.manifestUrl),
228
+ manifestUrl: b("manifestUrl", e.manifestUrl),
229
229
  serverTime: e.serverTime ?? ""
230
230
  };
231
231
  if (e.liveStartsAt && (i.liveStartsAt = e.liveStartsAt), typeof e.analytics?.sid == "string" && e.analytics.sid && (i.analytics = { sid: e.analytics.sid }), r && e.drm) {
232
232
  let t = {};
233
- e.drm.widevine?.licenseUrl && (t.widevine = { licenseUrl: x("widevine licenseUrl", e.drm.widevine.licenseUrl) }), e.drm.fairplay?.licenseUrl && e.drm.fairplay.certificateUrl && (t.fairplay = {
234
- licenseUrl: x("fairplay licenseUrl", e.drm.fairplay.licenseUrl),
235
- certificateUrl: x("fairplay certificateUrl", e.drm.fairplay.certificateUrl)
233
+ e.drm.widevine?.licenseUrl && (t.widevine = { licenseUrl: b("widevine licenseUrl", e.drm.widevine.licenseUrl) }), e.drm.fairplay?.licenseUrl && e.drm.fairplay.certificateUrl && (t.fairplay = {
234
+ licenseUrl: b("fairplay licenseUrl", e.drm.fairplay.licenseUrl),
235
+ certificateUrl: b("fairplay certificateUrl", e.drm.fairplay.certificateUrl)
236
236
  }), (t.widevine || t.fairplay) && (i.drm = t);
237
237
  }
238
238
  let a = {};
239
- for (let [t, n] of Object.entries(e)) se.has(t) || (a[t] = n);
239
+ for (let [t, n] of Object.entries(e)) ce.has(t) || (a[t] = n);
240
240
  return Object.keys(a).length > 0 && (i.extensions = a), i;
241
241
  }
242
242
  //#endregion
243
243
  //#region src/core/fullscreen.ts
244
- function le(e) {
244
+ function x(e) {
245
245
  return e.ownerDocument ?? document;
246
246
  }
247
- function ue(e) {
247
+ function S(e) {
248
248
  return e.fullscreenElement ?? e.webkitFullscreenElement ?? null;
249
249
  }
250
- function S(e, t) {
251
- let n = ue(le(e));
250
+ function C(e, t) {
251
+ let n = S(x(e));
252
252
  return n != null && (n === e || t != null && n === t) || e.webkitDisplayingFullscreen === !0;
253
253
  }
254
- async function C(e, t) {
254
+ async function w(e, t) {
255
255
  let n = t ?? e;
256
256
  if (typeof n.requestFullscreen == "function") return await n.requestFullscreen(), !0;
257
257
  if (typeof n.webkitRequestFullscreen == "function") return n.webkitRequestFullscreen(), !0;
258
258
  let r = e;
259
259
  return r.webkitSupportsFullscreen && typeof r.webkitEnterFullscreen == "function" ? (r.webkitEnterFullscreen(), !0) : !1;
260
260
  }
261
- async function w(e, t) {
261
+ async function T(e, t) {
262
262
  let n = e;
263
263
  if (n.webkitDisplayingFullscreen) {
264
264
  n.webkitExitFullscreen?.();
265
265
  return;
266
266
  }
267
- let r = le(e), i = ue(r);
267
+ let r = x(e), i = S(r);
268
268
  i != null && (i === e || t != null && i === t) && (typeof r.exitFullscreen == "function" ? await r.exitFullscreen() : r.webkitExitFullscreen?.());
269
269
  }
270
270
  //#endregion
271
271
  //#region src/core/catalog.ts
272
- async function de(e) {
272
+ async function ue(e) {
273
273
  let t = new URLSearchParams();
274
274
  e.status && t.set("status", Array.isArray(e.status) ? e.status.join(",") : e.status), e.sport && t.set("sport", e.sport);
275
275
  let i = t.toString(), a = c(e.baseUrl, "/v1/catalog" + (i ? `?${i}` : "")), o = new Headers();
@@ -287,12 +287,12 @@ async function de(e) {
287
287
  };
288
288
  if (!s.ok) throw new n(r(s.status), s.status, `catalog request failed (HTTP ${s.status})`);
289
289
  return {
290
- tournaments: fe(await s.json()),
290
+ tournaments: de(await s.json()),
291
291
  etag: s.headers.get("etag") ?? void 0,
292
292
  notModified: !1
293
293
  };
294
294
  }
295
- function fe(e) {
295
+ function de(e) {
296
296
  return (e.tournaments ?? []).map((e) => {
297
297
  let t = e.urn ?? "", n = e.name ?? "", r = e.sport ?? "";
298
298
  return {
@@ -312,7 +312,7 @@ function fe(e) {
312
312
  };
313
313
  });
314
314
  }
315
- async function pe(e) {
315
+ async function fe(e) {
316
316
  let t = c(e.baseUrl, `/v1/tournaments/${encodeURIComponent(e.urn)}`), i = new Headers();
317
317
  e.etag && i.set("If-None-Match", e.etag);
318
318
  let a = await u(t, {
@@ -332,13 +332,13 @@ async function pe(e) {
332
332
  };
333
333
  if (!a.ok) throw new n(r(a.status), a.status, `tournament request failed (HTTP ${a.status})`);
334
334
  return {
335
- tournament: me(await a.json()),
335
+ tournament: pe(await a.json()),
336
336
  etag: a.headers.get("etag") ?? void 0,
337
337
  notModified: !1,
338
338
  notFound: !1
339
339
  };
340
340
  }
341
- function me(e) {
341
+ function pe(e) {
342
342
  let t = e.urn ?? "", n = e.name ?? "", r = e.sport ?? "";
343
343
  return {
344
344
  urn: t,
@@ -356,12 +356,12 @@ function me(e) {
356
356
  }))
357
357
  };
358
358
  }
359
- function he(e) {
359
+ function me(e) {
360
360
  return e.tournaments.flatMap((e) => e.matches);
361
361
  }
362
362
  //#endregion
363
363
  //#region src/core/poll.ts
364
- function ge(e) {
364
+ function he(e) {
365
365
  let t = Math.max(2e3, e.intervalMs ?? 1e4), i = new AbortController(), a, o, s, l = !1, d = () => {
366
366
  l || (a = setTimeout(f, t));
367
367
  }, f = async () => {
@@ -397,7 +397,7 @@ function ge(e) {
397
397
  }
398
398
  //#endregion
399
399
  //#region src/core/events.ts
400
- function T(e) {
400
+ function E(e) {
401
401
  let t = Math.max(250, e.minBackoffMs ?? 1e3), n = Math.max(t, e.maxBackoffMs ?? 15e3), r = new AbortController(), i = !1, a = (e) => new Promise((t) => {
402
402
  if (r.signal.aborted) return t();
403
403
  let n = setTimeout(t, e);
@@ -464,7 +464,7 @@ function T(e) {
464
464
  i || (i = !0, r.abort());
465
465
  } };
466
466
  }
467
- function E(e) {
467
+ function D(e) {
468
468
  try {
469
469
  let t = new URL(e);
470
470
  return t.hostname = `events.${t.hostname}`, t.pathname = "", t.search = "", t.origin;
@@ -474,27 +474,27 @@ function E(e) {
474
474
  }
475
475
  //#endregion
476
476
  //#region src/core/drm/deviceId.ts
477
- var D = "havik.player.deviceId", O;
478
- function k() {
479
- if (O) return O;
477
+ var O = "havik.player.deviceId", k;
478
+ function A() {
479
+ if (k) return k;
480
480
  try {
481
- let e = globalThis.localStorage?.getItem(D);
482
- if (e) return O = e, e;
481
+ let e = globalThis.localStorage?.getItem(O);
482
+ if (e) return k = e, e;
483
483
  } catch {}
484
- let e = ve();
485
- O = e;
484
+ let e = _e();
485
+ k = e;
486
486
  try {
487
- globalThis.localStorage?.setItem(D, e);
487
+ globalThis.localStorage?.setItem(O, e);
488
488
  } catch {}
489
489
  return e;
490
490
  }
491
- function _e() {
492
- O = void 0;
491
+ function ge() {
492
+ k = void 0;
493
493
  try {
494
- globalThis.localStorage?.removeItem(D);
494
+ globalThis.localStorage?.removeItem(O);
495
495
  } catch {}
496
496
  }
497
- function ve() {
497
+ function _e() {
498
498
  let e = globalThis.crypto;
499
499
  if (e && typeof e.randomUUID == "function") return e.randomUUID();
500
500
  let t = /* @__PURE__ */ new Uint8Array(16);
@@ -506,21 +506,21 @@ function ve() {
506
506
  }
507
507
  //#endregion
508
508
  //#region src/core/drm/headers.ts
509
- function ye(e, t, n = {}) {
509
+ function ve(e, t, n = {}) {
510
510
  let r = {
511
511
  "x-api-key": t.apiKey,
512
512
  "X-Match-Urn": e.matchUrn,
513
- "X-Device-Id": n.deviceId ?? k(),
513
+ "X-Device-Id": n.deviceId ?? A(),
514
514
  "Content-Type": "application/octet-stream"
515
515
  };
516
516
  return n.userId && (r["X-User-Id"] = n.userId), r;
517
517
  }
518
518
  //#endregion
519
519
  //#region src/core/drm/cdm.ts
520
- var A = /* @__PURE__ */ new WeakMap();
521
- function be(e, t) {
522
- let n = A.get(e);
523
- n || (n = /* @__PURE__ */ new Map(), A.set(e, n));
520
+ var j = /* @__PURE__ */ new WeakMap();
521
+ function ye(e, t) {
522
+ let n = j.get(e);
523
+ n || (n = /* @__PURE__ */ new Map(), j.set(e, n));
524
524
  let r = n.get(t.keySystem);
525
525
  if (r) return r;
526
526
  let i = t.createMediaKeys().catch((e) => {
@@ -528,22 +528,22 @@ function be(e, t) {
528
528
  });
529
529
  return n.set(t.keySystem, i), i;
530
530
  }
531
- function j() {
531
+ function M() {
532
532
  return typeof navigator < "u" && typeof navigator.requestMediaKeySystemAccess == "function";
533
533
  }
534
- var M = ["SW_SECURE_DECODE", "SW_SECURE_CRYPTO"];
535
- function xe(e) {
534
+ var N = ["SW_SECURE_DECODE", "SW_SECURE_CRYPTO"];
535
+ function be(e) {
536
536
  return e.startsWith("com.widevine");
537
537
  }
538
- function N(e, t) {
539
- if (!xe(e)) return t;
538
+ function xe(e, t) {
539
+ if (!be(e)) return t;
540
540
  let n = (e, t) => {
541
541
  let n = e.videoCapabilities;
542
542
  return !n?.length || !n.some((e) => e.robustness) ? !1 : n.every((e) => {
543
- let n = M.indexOf(e.robustness);
544
- return n === -1 || M.indexOf(t) > n;
543
+ let n = N.indexOf(e.robustness);
544
+ return n === -1 || N.indexOf(t) > n;
545
545
  });
546
- }, r = M.flatMap((e) => t.filter((t) => n(t, e)).map((t) => ({
546
+ }, r = N.flatMap((e) => t.filter((t) => n(t, e)).map((t) => ({
547
547
  ...t,
548
548
  videoCapabilities: t.videoCapabilities?.map((t) => ({
549
549
  ...t,
@@ -553,10 +553,10 @@ function N(e, t) {
553
553
  return [...t, ...r];
554
554
  }
555
555
  function Se(e) {
556
- return (t, n) => j() ? navigator.requestMediaKeySystemAccess(t, N(t, n)).then((t) => ({
556
+ return (t, n) => M() ? navigator.requestMediaKeySystemAccess(t, xe(t, n)).then((t) => ({
557
557
  keySystem: t.keySystem,
558
558
  getConfiguration: () => t.getConfiguration(),
559
- createMediaKeys: () => be(e, t)
559
+ createMediaKeys: () => ye(e, t)
560
560
  })) : Promise.reject(/* @__PURE__ */ Error("navigator.requestMediaKeySystemAccess is unavailable — EME needs a secure context (https, or localhost)"));
561
561
  }
562
562
  //#endregion
@@ -582,7 +582,7 @@ function Ee(e) {
582
582
  robustness: "",
583
583
  encryptionScheme: "cbcs"
584
584
  }]
585
- }] : N("com.widevine.alpha", [{
585
+ }] : xe("com.widevine.alpha", [{
586
586
  initDataTypes: ["cenc"],
587
587
  videoCapabilities: [{
588
588
  contentType: we,
@@ -672,7 +672,7 @@ var Ae = /\.(m3u8|ts|m4s|mp4|cmfv|cmfa)(\?|$)/i;
672
672
  function je(e) {
673
673
  if (typeof performance > "u" || typeof performance.getEntriesByType != "function") return "";
674
674
  let t = "", n = -1, r = performance.getEntriesByType("resource");
675
- for (let i of r) if (!(i.startTime < e) && !(i.initiatorType !== "video" && i.initiatorType !== "audio" && !Ae.test(i.name)) && i.startTime >= n) {
675
+ for (let i of r) if (!(i.startTime < e) && (i.initiatorType === "video" || i.initiatorType === "audio" || Ae.test(i.name)) && i.startTime >= n) {
676
676
  let e = L(i.name);
677
677
  e && (t = e, n = i.startTime);
678
678
  }
@@ -776,7 +776,7 @@ var V = class {
776
776
  });
777
777
  this.onEncrypted = (n) => {
778
778
  let i = n;
779
- !i.initData || this.fairplayArmed || (this.fairplayArmed = !0, this.fairplayKeyIV = Ne(i.initData), (async () => {
779
+ i.initData && !this.fairplayArmed && (this.fairplayArmed = !0, this.fairplayKeyIV = Ne(i.initData), (async () => {
780
780
  try {
781
781
  let n = await (await navigator.requestMediaKeySystemAccess("com.apple.fps", [{
782
782
  initDataTypes: [i.initDataType],
@@ -1034,7 +1034,7 @@ var U = class {
1034
1034
  videoEncryptionScheme: "cbcs",
1035
1035
  audioEncryptionScheme: "cbcs"
1036
1036
  },
1037
- ...j() ? { requestMediaKeySystemAccessFunc: Se(t) } : {},
1037
+ ...M() ? { requestMediaKeySystemAccessFunc: Se(t) } : {},
1038
1038
  licenseXhrSetup: (e, t) => {
1039
1039
  e.open("POST", this.licenseUrl ?? t, !0), e.setRequestHeader("x-api-key", r.apiKey), e.setRequestHeader("X-Match-Urn", n.matchUrn), e.setRequestHeader("X-Device-Id", i), a && e.setRequestHeader("X-User-Id", a), this.licenseRequested = !0;
1040
1040
  let o = performance.now();
@@ -1435,6 +1435,9 @@ var lt = class {
1435
1435
  hiddenTotalMs = 0;
1436
1436
  lastHbPlayingMs = 0;
1437
1437
  lastHbHiddenMs = 0;
1438
+ lastHbRebufferMs = 0;
1439
+ lastHbRebufferCount = 0;
1440
+ lastHbActiveMs = 0;
1438
1441
  rebufferCount = 0;
1439
1442
  rebufferTotalMs = 0;
1440
1443
  bufferingSinceMs = null;
@@ -1602,31 +1605,35 @@ var lt = class {
1602
1605
  this.playingSinceMs !== null && (n += t - this.playingSinceMs);
1603
1606
  let r = this.hiddenTotalMs;
1604
1607
  this.hiddenSinceMs !== null && (r += t - this.hiddenSinceMs);
1605
- let i = {}, a = e.bytesLoaded ?? 0;
1606
- a > this.lastBytes && (i.bytesDownloadedDelta = a - this.lastBytes), this.lastBytes = a;
1607
- let o = e.playlistBytesLoaded ?? 0;
1608
- o > this.lastPlaylistBytes && (i.playlistBytesDelta = o - this.lastPlaylistBytes), this.lastPlaylistBytes = o;
1609
- let s = e.droppedFrames ?? 0;
1610
- s > this.lastDropped && (i.droppedFramesDelta = s - this.lastDropped), this.lastDropped = s;
1611
- let c = e.renditionSwitches ?? 0;
1612
- c > this.lastSwitches && (i.renditionSwitchesDelta = c - this.lastSwitches), this.lastSwitches = c, n > this.lastHbPlayingMs && (i.playingMsDelta = Math.round(n - this.lastHbPlayingMs)), this.lastHbPlayingMs = n, r > this.lastHbHiddenMs && (i.hiddenMsDelta = Math.round(r - this.lastHbHiddenMs)), this.lastHbHiddenMs = r, typeof e.latencySeconds == "number" && (i.latencyMs = Math.round(e.latencySeconds * 1e3)), typeof e.targetLatencySeconds == "number" && (i.targetLatencyMs = Math.round(e.targetLatencySeconds * 1e3)), typeof e.bandwidthKbps == "number" && (i.bandwidthEstKbps = e.bandwidthKbps), typeof e.levelHeight == "number" && (i.renditionHeight = e.levelHeight), typeof e.renditionBitrateKbps == "number" && (i.renditionBitrateKbps = e.renditionBitrateKbps), e.atLiveEdge === !0 && (i.atLiveEdge = !0), typeof e.bufferedMs == "number" && e.bufferedMs > 0 && (i.bufferedMs = Math.round(e.bufferedMs)), i.playerState = q[e.state] ?? "PLAYER_STATE_UNSPECIFIED";
1613
- let l = this.mutedTotalMs;
1614
- this.mutedSinceMs !== null && (l += t - this.mutedSinceMs), l > this.lastHbMutedMs && (i.mutedMsDelta = Math.round(l - this.lastHbMutedMs)), this.lastHbMutedMs = l;
1615
- let u = e.upshifts ?? 0;
1616
- u > this.lastUpshifts && (i.upshiftsDelta = u - this.lastUpshifts), this.lastUpshifts = u;
1617
- let d = e.downshifts ?? 0;
1618
- d > this.lastDownshifts && (i.downshiftsDelta = d - this.lastDownshifts), this.lastDownshifts = d;
1619
- let f = e.decodedFrames ?? 0;
1620
- f > this.lastDecoded && (i.decodedFramesDelta = f - this.lastDecoded), this.lastDecoded = f;
1621
- let p = e.requestErrors ?? 0;
1622
- p > this.lastRequestErrors && (i.requestErrorsDelta = p - this.lastRequestErrors), this.lastRequestErrors = p;
1623
- let m = e.requestCount ?? 0, h = m - this.lastRequestCount;
1624
- if (this.lastRequestCount = m, h > 0) {
1625
- i.requestCountDelta = h;
1626
- let t = e.requestTimesMs ?? [], n = t.slice(Math.max(0, t.length - h)).sort((e, t) => e - t);
1627
- n.length > 0 && (i.requestTimeP50Ms = K(n, 50), i.requestTimeP95Ms = K(n, 95));
1608
+ let i = this.rebufferTotalMs;
1609
+ this.bufferingSinceMs !== null && (i += t - this.bufferingSinceMs);
1610
+ let a = this.activeTotalMs;
1611
+ this.activeSinceMs !== null && (a += t - this.activeSinceMs);
1612
+ let o = {}, s = e.bytesLoaded ?? 0;
1613
+ s > this.lastBytes && (o.bytesDownloadedDelta = s - this.lastBytes), this.lastBytes = s;
1614
+ let c = e.playlistBytesLoaded ?? 0;
1615
+ c > this.lastPlaylistBytes && (o.playlistBytesDelta = c - this.lastPlaylistBytes), this.lastPlaylistBytes = c;
1616
+ let l = e.droppedFrames ?? 0;
1617
+ l > this.lastDropped && (o.droppedFramesDelta = l - this.lastDropped), this.lastDropped = l;
1618
+ let u = e.renditionSwitches ?? 0;
1619
+ u > this.lastSwitches && (o.renditionSwitchesDelta = u - this.lastSwitches), this.lastSwitches = u, n > this.lastHbPlayingMs && (o.playingMsDelta = Math.round(n - this.lastHbPlayingMs)), this.lastHbPlayingMs = n, r > this.lastHbHiddenMs && (o.hiddenMsDelta = Math.round(r - this.lastHbHiddenMs)), this.lastHbHiddenMs = r, i > this.lastHbRebufferMs && (o.rebufferMsDelta = Math.round(i - this.lastHbRebufferMs)), this.lastHbRebufferMs = i, this.rebufferCount > this.lastHbRebufferCount && (o.rebufferCountDelta = this.rebufferCount - this.lastHbRebufferCount), this.lastHbRebufferCount = this.rebufferCount, a > this.lastHbActiveMs && (o.activeMsDelta = Math.round(a - this.lastHbActiveMs)), this.lastHbActiveMs = a, typeof e.latencySeconds == "number" && (o.latencyMs = Math.round(e.latencySeconds * 1e3)), typeof e.targetLatencySeconds == "number" && (o.targetLatencyMs = Math.round(e.targetLatencySeconds * 1e3)), typeof e.bandwidthKbps == "number" && (o.bandwidthEstKbps = e.bandwidthKbps), typeof e.levelHeight == "number" && (o.renditionHeight = e.levelHeight), typeof e.renditionBitrateKbps == "number" && (o.renditionBitrateKbps = e.renditionBitrateKbps), e.atLiveEdge === !0 && (o.atLiveEdge = !0), typeof e.bufferedMs == "number" && e.bufferedMs > 0 && (o.bufferedMs = Math.round(e.bufferedMs)), o.playerState = q[e.state] ?? "PLAYER_STATE_UNSPECIFIED";
1620
+ let d = this.mutedTotalMs;
1621
+ this.mutedSinceMs !== null && (d += t - this.mutedSinceMs), d > this.lastHbMutedMs && (o.mutedMsDelta = Math.round(d - this.lastHbMutedMs)), this.lastHbMutedMs = d;
1622
+ let f = e.upshifts ?? 0;
1623
+ f > this.lastUpshifts && (o.upshiftsDelta = f - this.lastUpshifts), this.lastUpshifts = f;
1624
+ let p = e.downshifts ?? 0;
1625
+ p > this.lastDownshifts && (o.downshiftsDelta = p - this.lastDownshifts), this.lastDownshifts = p;
1626
+ let m = e.decodedFrames ?? 0;
1627
+ m > this.lastDecoded && (o.decodedFramesDelta = m - this.lastDecoded), this.lastDecoded = m;
1628
+ let h = e.requestErrors ?? 0;
1629
+ h > this.lastRequestErrors && (o.requestErrorsDelta = h - this.lastRequestErrors), this.lastRequestErrors = h;
1630
+ let g = e.requestCount ?? 0, _ = g - this.lastRequestCount;
1631
+ if (this.lastRequestCount = g, _ > 0) {
1632
+ o.requestCountDelta = _;
1633
+ let t = e.requestTimesMs ?? [], n = t.slice(Math.max(0, t.length - _)).sort((e, t) => e - t);
1634
+ n.length > 0 && (o.requestTimeP50Ms = K(n, 50), o.requestTimeP95Ms = K(n, 95));
1628
1635
  }
1629
- typeof e.latencySeconds == "number" && typeof e.targetLatencySeconds == "number" && (i.driftMs = Math.round((e.latencySeconds - e.targetLatencySeconds) * 1e3)), typeof e.playbackRate == "number" && e.playbackRate > 0 && (i.playbackRate = e.playbackRate), e.qualityPinned === !0 && (i.qualityPinned = !0), e.cdnHost && (i.cdnHost = e.cdnHost), this.maybeEmitMediaInfo(e), this.enqueue({ heartbeat: i }), this.flush(), a > 0 && this.noteFirstBytes();
1636
+ typeof e.latencySeconds == "number" && typeof e.targetLatencySeconds == "number" && (o.driftMs = Math.round((e.latencySeconds - e.targetLatencySeconds) * 1e3)), typeof e.playbackRate == "number" && e.playbackRate > 0 && (o.playbackRate = e.playbackRate), e.qualityPinned === !0 && (o.qualityPinned = !0), e.cdnHost && (o.cdnHost = e.cdnHost), this.maybeEmitMediaInfo(e), this.enqueue({ heartbeat: o }), this.flush(), s > 0 && this.noteFirstBytes();
1630
1637
  }
1631
1638
  maybeEmitMediaInfo(e) {
1632
1639
  if (!(e.videoCodec ?? e.keySystem ?? e.ladderHeights)) return;
@@ -1760,7 +1767,7 @@ async function mt() {
1760
1767
  }
1761
1768
  //#endregion
1762
1769
  //#region src/core/version.ts
1763
- var ht = "2.3.1", J = {
1770
+ var ht = "2.5.0", J = {
1764
1771
  accent: "#E1B600",
1765
1772
  accentText: "#1B1C23",
1766
1773
  background: "#0e0f13",
@@ -2082,11 +2089,11 @@ var St = class {
2082
2089
  }
2083
2090
  async toggleFullscreen() {
2084
2091
  try {
2085
- S(this.video, this.root) ? await w(this.video, this.root) : await C(this.video, this.root);
2092
+ C(this.video, this.root) ? await T(this.video, this.root) : await w(this.video, this.root);
2086
2093
  } catch {}
2087
2094
  }
2088
2095
  syncFullscreen() {
2089
- let e = S(this.video, this.root);
2096
+ let e = C(this.video, this.root);
2090
2097
  this.setIcon(this.fsBtn, e ? "fullscreenExit" : "fullscreen"), this.fsBtn.setAttribute("aria-label", e ? "Exit fullscreen" : "Fullscreen");
2091
2098
  }
2092
2099
  poke() {
@@ -2230,7 +2237,7 @@ var Pt = class {
2230
2237
  this.opts.muted && (this.opts.video.muted = !0), this.opts.poster && (this.opts.video.poster = this.opts.poster), this.mountControls(), this.attachPipListeners(), this.setState("loading");
2231
2238
  let e = ++this.loadGen, t = this.resolveOptions();
2232
2239
  try {
2233
- let n = await y(t);
2240
+ let n = await v(t);
2234
2241
  if (await this.onResolved(n, e), e === this.loadGen && this._state === "error" && this._lastError) {
2235
2242
  let e = this._lastError;
2236
2243
  throw this.destroy(), e;
@@ -2253,11 +2260,11 @@ var Pt = class {
2253
2260
  };
2254
2261
  }
2255
2262
  beginArming(e, t, n = !1) {
2256
- let r = this.opts.liveStateEvents === !1 ? void 0 : this.opts.eventsBaseUrl ?? E(this.opts.baseUrl);
2263
+ let r = this.opts.liveStateEvents === !1 ? void 0 : this.opts.eventsBaseUrl ?? D(this.opts.baseUrl);
2257
2264
  r ? this.armWithSse(e, r, t, n) : this.beginArmingByPolling(e);
2258
2265
  }
2259
2266
  beginArmingByPolling(e) {
2260
- b({
2267
+ y({
2261
2268
  ...this.resolveOptions(),
2262
2269
  signal: this.abort.signal,
2263
2270
  waitForLive: this.buildWaitConfig(e)
@@ -2291,7 +2298,7 @@ var Pt = class {
2291
2298
  }
2292
2299
  }
2293
2300
  }, h = () => {
2294
- a || s || p() || (s = !0, b({
2301
+ a || s || p() || (s = !0, y({
2295
2302
  ...this.resolveOptions(),
2296
2303
  signal: c.signal,
2297
2304
  waitForLive: this.buildWaitConfig(e)
@@ -2299,7 +2306,7 @@ var Pt = class {
2299
2306
  a || p() || c.signal.aborted || (a = !0, this.closeArming(), this.fail(e instanceof n ? e : new n("INTERNAL", 0, String(e))));
2300
2307
  }));
2301
2308
  }, g = () => {
2302
- a || p() || y(this.resolveOptions()).then((e) => m(e)).catch((e) => {
2309
+ a || p() || v(this.resolveOptions()).then((e) => m(e)).catch((e) => {
2303
2310
  if (!(a || p())) {
2304
2311
  if (e instanceof n && o(e.code)) {
2305
2312
  h();
@@ -2313,7 +2320,7 @@ var Pt = class {
2313
2320
  !a && !p() && h();
2314
2321
  }, e);
2315
2322
  };
2316
- _(Dt), this.armingSub = T({
2323
+ _(Dt), this.armingSub = E({
2317
2324
  eventsBaseUrl: t,
2318
2325
  matchUrn: this.opts.matchUrn,
2319
2326
  credential: this.opts.credential,
@@ -2400,7 +2407,7 @@ var Pt = class {
2400
2407
  video: this.opts.video,
2401
2408
  descriptor: e,
2402
2409
  credential: t,
2403
- deviceId: k(),
2410
+ deviceId: A(),
2404
2411
  userId: this.opts.userId,
2405
2412
  lowLatency: this.opts.lowLatency === void 0 || this.opts.lowLatency === "auto" || this.opts.lowLatency,
2406
2413
  snapToLiveOnRefocus: this.opts.snapToLiveOnRefocus,
@@ -2441,11 +2448,11 @@ var Pt = class {
2441
2448
  }
2442
2449
  startLiveState(e) {
2443
2450
  if (this.opts.liveStateEvents === !1) return;
2444
- let t = this.opts.eventsBaseUrl ?? E(this.opts.baseUrl);
2451
+ let t = this.opts.eventsBaseUrl ?? D(this.opts.baseUrl);
2445
2452
  if (!t) return;
2446
2453
  this.closeLiveState();
2447
2454
  let r = 0, i = !1;
2448
- this.liveStateSub = T({
2455
+ this.liveStateSub = E({
2449
2456
  eventsBaseUrl: t,
2450
2457
  matchUrn: this.opts.matchUrn,
2451
2458
  credential: this.opts.credential,
@@ -2476,7 +2483,7 @@ var Pt = class {
2476
2483
  return this.opts.rejoinOnLive !== !1 && this.opts.liveStateEvents !== !1;
2477
2484
  }
2478
2485
  scheduleRejoin(e) {
2479
- !this.rejoinEnabled() || this.rejoinTimer || (this.rejoinTimer = setTimeout(() => {
2486
+ this.rejoinEnabled() && !this.rejoinTimer && (this.rejoinTimer = setTimeout(() => {
2480
2487
  this.rejoinTimer = null, !(this.destroyed || e !== this.loadGen || this._state !== "ended") && this.rejoin();
2481
2488
  }, Math.random() * kt));
2482
2489
  }
@@ -2545,15 +2552,15 @@ var Pt = class {
2545
2552
  scheduleLicenseRefresh() {
2546
2553
  this.stopRefresh();
2547
2554
  let e = this.opts.licenseRefreshMs ?? Mt;
2548
- !e || !this._descriptor?.drmEnabled || (this.refreshTimer = setInterval(() => void this.refreshLicense(), e));
2555
+ e && this._descriptor?.drmEnabled && (this.refreshTimer = setInterval(() => void this.refreshLicense(), e));
2549
2556
  }
2550
2557
  stopRefresh() {
2551
2558
  this.refreshTimer && clearInterval(this.refreshTimer), this.refreshTimer = void 0;
2552
2559
  }
2553
2560
  async refreshLicense() {
2554
2561
  let e = this.engine;
2555
- if (!(this.destroyed || !e)) try {
2556
- let t = await y(this.resolveOptions());
2562
+ if (!this.destroyed && e) try {
2563
+ let t = await v(this.resolveOptions());
2557
2564
  if (this.destroyed || this.engine !== e) return;
2558
2565
  let n = t.drm?.widevine?.licenseUrl, r = t.drm?.fairplay?.licenseUrl;
2559
2566
  (n || r) && (e.setLicenseUrls({
@@ -2625,10 +2632,10 @@ var Pt = class {
2625
2632
  e.pictureInPictureElement === this.opts.video && typeof e.exitPictureInPicture == "function" && await e.exitPictureInPicture();
2626
2633
  }
2627
2634
  async enterFullscreen() {
2628
- return !this.destroyed && C(this.opts.video, this.container ?? void 0);
2635
+ return !this.destroyed && w(this.opts.video, this.container ?? void 0);
2629
2636
  }
2630
2637
  async exitFullscreen() {
2631
- await w(this.opts.video, this.container ?? void 0);
2638
+ await T(this.opts.video, this.container ?? void 0);
2632
2639
  }
2633
2640
  retry() {
2634
2641
  return this.reload();
@@ -2638,7 +2645,7 @@ var Pt = class {
2638
2645
  let e = ++this.loadGen;
2639
2646
  this.teardownPlayback();
2640
2647
  try {
2641
- let t = await b({
2648
+ let t = await y({
2642
2649
  ...this.resolveOptions(),
2643
2650
  waitForLive: this.opts.waitForLive ? this.buildWaitConfig(e) : void 0
2644
2651
  });
@@ -2906,7 +2913,7 @@ async function Rt() {
2906
2913
  case "oddin:destroy": c();
2907
2914
  }
2908
2915
  }, u = (e) => {
2909
- !r || e.origin !== r || $(e.data) && l(e.data);
2916
+ r && e.origin === r && $(e.data) && l(e.data);
2910
2917
  };
2911
2918
  r && window.addEventListener("message", u), window.addEventListener("pagehide", c, { once: !0 }), await s(e.matchUrn), i({
2912
2919
  type: "oddin:ready",
@@ -2925,6 +2932,6 @@ function Bt() {
2925
2932
  e.textContent = "html,body{margin:0;height:100%;background:#000;overflow:hidden}body{display:flex}", document.head.appendChild(e);
2926
2933
  }
2927
2934
  //#endregion
2928
- export { J as ODDIN_THEME, n as PlaybackError, X as applyTheme, Rt as bootEmbed, _e as clearDeviceId, Nt as createPlayer, E as deriveEventsBaseUrl, De as detectDrmSupport, C as enterVideoFullscreen, w as exitVideoFullscreen, de as fetchCatalog, pe as fetchTournament, he as flattenMatches, k as getDeviceId, ke as isLowLatencyManifest, $ as isOddinMessage, ye as licenseRequestHeaders, Ft as mountEmbed, v as pollToLive, b as resolveStream, T as subscribeLiveState, S as videoFullscreenActive, ge as watchStatus };
2935
+ export { J as ODDIN_THEME, n as PlaybackError, X as applyTheme, Rt as bootEmbed, ge as clearDeviceId, Nt as createPlayer, D as deriveEventsBaseUrl, De as detectDrmSupport, w as enterVideoFullscreen, T as exitVideoFullscreen, ue as fetchCatalog, fe as fetchTournament, me as flattenMatches, A as getDeviceId, ke as isLowLatencyManifest, $ as isOddinMessage, ve as licenseRequestHeaders, Ft as mountEmbed, oe as pollToLive, y as resolveStream, E as subscribeLiveState, C as videoFullscreenActive, he as watchStatus };
2929
2936
 
2930
2937
  //# sourceMappingURL=index.js.map