@vindral/web-sdk 4.3.1 → 4.3.2-2-gffc6c8655

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.
@@ -427,11 +427,11 @@ var nt = () => typeof HTMLCanvasElement < "u" && typeof HTMLCanvasElement.protot
427
427
  };
428
428
  }, Nt = class {
429
429
  constructor(t = 10) {
430
- e(this, "rates", void 0), e(this, "_total", 0), e(this, "accumulatedValues", 0), e(this, "lastTickTime", Date.now()), e(this, "add", (e) => {
430
+ e(this, "rates", void 0), e(this, "_total", 0), e(this, "accumulatedValues", 0), e(this, "lastTickTime", performance.now()), e(this, "add", (e) => {
431
431
  this.accumulatedValues += e, this._total += e;
432
432
  }), e(this, "tick", () => {
433
- let e = this.accumulatedValues / ((Date.now() - this.lastTickTime) / 1e3);
434
- this.rates.push(e), this.accumulatedValues = 0, this.lastTickTime = Date.now();
433
+ let e = performance.now(), t = this.accumulatedValues / ((e - this.lastTickTime) / 1e3);
434
+ this.rates.push(t), this.accumulatedValues = 0, this.lastTickTime = e;
435
435
  }), this.rates = new v(t);
436
436
  }
437
437
  get total() {
@@ -705,18 +705,18 @@ var A = class {
705
705
  sn = j, e(j, "create", () => new sn());
706
706
  //#endregion
707
707
  //#region ../../libs/utils/src/timeRangesUtils.ts
708
- var cn = (e, t = Date.now()) => {
708
+ var cn = (e, t = performance.now()) => {
709
709
  let n = e.length;
710
710
  if (n > 0) {
711
711
  let r = e[n - 1];
712
712
  r.end || (r.end = t);
713
713
  }
714
- }, ln = (e, t = Date.now()) => {
715
- cn(e), e.push({ start: t });
714
+ }, ln = (e, t = performance.now()) => {
715
+ cn(e, t), e.push({ start: t });
716
716
  }, un = (e) => e.reduce((e, t) => {
717
717
  var n;
718
- return e + (((n = t.end) == null ? Date.now() : n) - t.start);
719
- }, 0), dn = (e, t, n = Date.now()) => e.reduce((e, r) => {
718
+ return e + (((n = t.end) == null ? performance.now() : n) - t.start);
719
+ }, 0), dn = (e, t, n = performance.now()) => e.reduce((e, r) => {
720
720
  var i;
721
721
  let a = Math.max(n - t, r.start), o = (i = r.end) == null ? n : i;
722
722
  return Math.max(0, o - a) + e;
@@ -3527,10 +3527,10 @@ var ds = (e) => {
3527
3527
  })), e(this, "onBufferStateChange", () => {
3528
3528
  this.emit("buffer state", this.getBufferState());
3529
3529
  }), e(this, "onSeekStart", () => {
3530
- this.seekStartTime = Date.now();
3530
+ this.seekStartTime = performance.now();
3531
3531
  }), e(this, "onSeekEnd", () => {
3532
3532
  if (!this.seekStartTime) return;
3533
- let e = Date.now() - this.seekStartTime;
3533
+ let e = performance.now() - this.seekStartTime;
3534
3534
  this.seekTimes.push(e), this._totalSeekTime += e, this.seekStartTime = void 0;
3535
3535
  }), this.logger = s, this._userProvidedMuted = i, this.element = document.createElement(n), this.element instanceof HTMLVideoElement && (this.element.playsInline = !0), this.element.controls = !1, this.element.autoplay = r, this.element.muted = i, a !== void 0 && (this.element.volume = a), this.element.style.display = "block", this.element.style.width = "100%", this.element.disableRemotePlayback = !0, this.element.setAttribute("poster", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAJCAQAAACRI2S5AAAAEElEQVR42mNkIAAYRxWAAQAG9gAKqv6+AwAAAABJRU5ErkJggg=="), this.onPlayPause(), setTimeout(() => {
3536
3536
  !this.element || !c || this.element.setAttribute("poster", c);
@@ -3615,7 +3615,7 @@ var ds = (e) => {
3615
3615
  maxCooldownRatio: 2
3616
3616
  }, Ss = (e) => (t) => t > e, Cs = class {
3617
3617
  constructor(t, n, r, i) {
3618
- e(this, "qualityOfServiceSource", void 0), e(this, "config", void 0), e(this, "emitter", void 0), e(this, "logger", void 0), e(this, "isSuspended", !1), e(this, "lastAdaptTime", Date.now()), e(this, "isEnabled", !0), e(this, "load", () => {
3618
+ e(this, "qualityOfServiceSource", void 0), e(this, "config", void 0), e(this, "emitter", void 0), e(this, "logger", void 0), e(this, "isSuspended", !1), e(this, "lastAdaptTime", performance.now()), e(this, "isEnabled", !0), e(this, "load", () => {
3619
3619
  this.emitter.on("buffer state", this.onBufferState), this.emitter.on("adapted level", this.onAdaptedLevel);
3620
3620
  }), e(this, "unload", () => {
3621
3621
  this.emitter.off("buffer state", this.onBufferState), this.emitter.off("adapted level", this.onAdaptedLevel);
@@ -3624,12 +3624,12 @@ var ds = (e) => {
3624
3624
  }), e(this, "unsuspend", () => {
3625
3625
  this.reset(), this.isSuspended = !1;
3626
3626
  }), e(this, "reset", (e = 0) => {
3627
- this.lastAdaptTime = Date.now() + e;
3627
+ this.lastAdaptTime = performance.now() + e;
3628
3628
  }), e(this, "getStatistics", () => ({ isAbrEnabled: this.isEnabled })), e(this, "isQoSOk", (e) => {
3629
3629
  let t = this.qualityOfServiceSource.getLevelStats(e), { upgradesFromLevel: n, downgradesFromLevel: r } = t == null ? {
3630
3630
  upgradesFromLevel: [],
3631
3631
  downgradesFromLevel: []
3632
- } : t, i = Date.now() - this.config.maxDowngradeLookbackMs, a = r.filter(Ss(i)).length, o = n.filter(Ss(i)).length;
3632
+ } : t, i = performance.now() - this.config.maxDowngradeLookbackMs, a = r.filter(Ss(i)).length, o = n.filter(Ss(i)).length;
3633
3633
  if (a - o > this.config.maxRecentDowngradesCount) return this.logger.debug("Recent downgrades count is over maximum", {
3634
3634
  downgrades: a - o,
3635
3635
  maxRecentDowngradesCount: this.config.maxRecentDowngradesCount
@@ -3643,13 +3643,13 @@ var ds = (e) => {
3643
3643
  recentDowngrades: a,
3644
3644
  timeSpentPlayingInAtLeastLevelRatio: s
3645
3645
  }), !1;
3646
- let l = Math.max(0, r.length - n.length - c), u = Date.now() - this.config.maxDowngradeLookbackMs * l, d = r.filter(Ss(u)).length;
3646
+ let l = Math.max(0, r.length - n.length - c), u = performance.now() - this.config.maxDowngradeLookbackMs * l, d = r.filter(Ss(u)).length;
3647
3647
  return d && l > this.config.maxCooldownRatio ? (this.logger.debug("Too many downgrades compared to time spent playing", {
3648
3648
  downgradesWithinCooldownTime: d,
3649
3649
  cooldownRatio: l
3650
3650
  }), !1) : !0;
3651
3651
  }), e(this, "onBufferState", (e) => {
3652
- if (!this.isEnabled || this.isSuspended || this.lastAdaptTime + this.config.cooldownTime > Date.now()) return;
3652
+ if (!this.isEnabled || this.isSuspended || this.lastAdaptTime + this.config.cooldownTime > performance.now()) return;
3653
3653
  let { bufferFullness: t, general: n } = this.qualityOfServiceSource.getMetrics(), r = this.qualityOfServiceSource.getBufferFullnessRegression();
3654
3654
  if (!r) return;
3655
3655
  let i = 10 * 1e3, a = 30 * 1e3, { slope: o } = r, s = r.predict(bs), c = o < 0, l = r.predict(bs) < _s && r.slope < 0, u = r.predict(bs) > ys, d = this.qualityOfServiceSource.timeSpentBufferingLast(a), f = this.qualityOfServiceSource.timeSpentActiveLast(a), p = this.qualityOfServiceSource.bufferingEventsLast(a), m = f > 0 ? d / f : 0, h = this.qualityOfServiceSource.getTargetBufferTime();
@@ -3693,7 +3693,7 @@ var ws, Ts = {
3693
3693
  maxBufferingRatio: { last30Seconds: .15 }
3694
3694
  }, Es = class t {
3695
3695
  constructor(n, r, i, a, o) {
3696
- e(this, "qualityOfServiceSource", void 0), e(this, "targetBufferTimeTarget", void 0), e(this, "config", void 0), e(this, "emitter", void 0), e(this, "logger", void 0), e(this, "isSuspended", !1), e(this, "lastIncreaseTime", Date.now()), e(this, "bufferTimeAdjustmentCount", 0), e(this, "load", () => {
3696
+ e(this, "qualityOfServiceSource", void 0), e(this, "targetBufferTimeTarget", void 0), e(this, "config", void 0), e(this, "emitter", void 0), e(this, "logger", void 0), e(this, "isSuspended", !1), e(this, "lastIncreaseTime", performance.now()), e(this, "bufferTimeAdjustmentCount", 0), e(this, "load", () => {
3697
3697
  this.emitter.on("buffer state", this.onBufferState);
3698
3698
  }), e(this, "unload", () => {
3699
3699
  this.emitter.off("buffer state", this.onBufferState);
@@ -3702,10 +3702,10 @@ var ws, Ts = {
3702
3702
  }), e(this, "unsuspend", () => {
3703
3703
  this.reset(), this.isSuspended = !1;
3704
3704
  }), e(this, "reset", () => {
3705
- this.lastIncreaseTime = Date.now();
3705
+ this.lastIncreaseTime = performance.now();
3706
3706
  }), e(this, "getStatistics", () => ({ bufferTimeAdjustmentCount: this.bufferTimeAdjustmentCount })), e(this, "onBufferState", (e) => {
3707
3707
  let { minBufferTime: n, maxBufferTime: r, cooldownTime: i } = this.config;
3708
- if (this.isSuspended || this.lastIncreaseTime + i > Date.now() || this.targetBufferTimeTarget.targetBufferTime >= r) return;
3708
+ if (this.isSuspended || this.lastIncreaseTime + i > performance.now() || this.targetBufferTimeTarget.targetBufferTime >= r) return;
3709
3709
  let a = this.qualityOfServiceSource.timeSpentBufferingLast(30 * 1e3), o = this.qualityOfServiceSource.bufferingEventsLast(30 * 1e3), s = a / this.qualityOfServiceSource.timeSpentActiveLast(30 * 1e3), c = Math.ceil(Math.max((r - n) / (t.BUFFER_TIME_MAX_STEPS - 1), t.BUFFER_TIME_STEP_SIZE));
3710
3710
  (s > this.config.maxBufferingRatio.last30Seconds || o > this.config.maxBufferingEvents.last30Seconds) && (this.targetBufferTimeTarget.targetBufferTime = Math.min(r, this.targetBufferTimeTarget.targetBufferTime + c), this.bufferTimeAdjustmentCount++, this.reset());
3711
3711
  }), this.qualityOfServiceSource = i, this.targetBufferTimeTarget = a, this.config = w(w({}, Ts), o), this.emitter = n, this.logger = r;
@@ -5010,8 +5010,8 @@ var td = class {
5010
5010
  onOk(e) {
5011
5011
  let n = Math.max(0, Date.now() - x(ad, this)), r = Number(e.expires);
5012
5012
  if (r > 0) {
5013
- let e = Math.max(t.minGraceTime, Math.min(r / 10, t.maxGraceTime));
5014
- Promise.race([hn(r - e - n), this.done().catch(o)]).then(() => x(od, this).resolve(this.expiryState())).catch(o);
5013
+ let e = Math.max(t.minGraceTime, Math.min(r / 10, t.maxGraceTime)), i = Math.min(r - e - n, t.maxTimeout);
5014
+ Promise.race([hn(i), this.done().catch(o)]).then(() => x(od, this).resolve(this.expiryState())).catch(o);
5015
5015
  }
5016
5016
  x(nd, this).resolve(e);
5017
5017
  }
@@ -5040,7 +5040,7 @@ var td = class {
5040
5040
  return x(od, this).promise;
5041
5041
  }
5042
5042
  };
5043
- e(cd, "maxGraceTime", 15e3), e(cd, "minGraceTime", 3e3);
5043
+ e(cd, "maxGraceTime", 15e3), e(cd, "minGraceTime", 3e3), e(cd, "maxTimeout", 2147483647);
5044
5044
  //#endregion
5045
5045
  //#region ../../libs/moq/src/protocol/wire-format/ObjectWriter.ts
5046
5046
  var ld = /* @__PURE__ */ new WeakMap(), ud = /* @__PURE__ */ new WeakMap(), dd = class {
@@ -7645,8 +7645,8 @@ function bg(e, n) {
7645
7645
  };
7646
7646
  t = s, i = c, a = ne;
7647
7647
  let h = p.producerReferenceTime(), ee = x(cg, r).get(n.track.namespace) || 0;
7648
- if (h && Date.now() - ee > 1e3) {
7649
- x(cg, r).set(n.track.namespace, Date.now());
7648
+ if (h && performance.now() - ee > 1e3) {
7649
+ x(cg, r).set(n.track.namespace, performance.now());
7650
7650
  let t = e.wallclock() - h.getTime();
7651
7651
  x(eg, r).debug("timing-info", {
7652
7652
  mediaType: p.mediaType(),
@@ -7800,7 +7800,7 @@ var Dg = (e, t) => {
7800
7800
  }
7801
7801
  n && this.emit("error", n), this.emit("close", this);
7802
7802
  }), e(this, "onOpen", () => {
7803
- this.logger.info("Opened", w({}, this.options)), this.readyState() === WebSocket.OPEN && (this.clearConnectTimeout(), this._connectTime = Date.now() - this.connectStartTime, this.reconnectState.reconnectRetries = 0, this._isConnectInProgress = !1, this.emit("open", this));
7803
+ this.logger.info("Opened", w({}, this.options)), this.readyState() === WebSocket.OPEN && (this.clearConnectTimeout(), this._connectTime = performance.now() - this.connectStartTime, this.reconnectState.reconnectRetries = 0, this._isConnectInProgress = !1, this.emit("open", this));
7804
7804
  }), e(this, "clearConnectTimeout", () => {
7805
7805
  this.connectTimeout && (clearTimeout(this.connectTimeout), this.connectTimeout = void 0);
7806
7806
  }), e(this, "startConnectTimeout", () => {
@@ -7820,7 +7820,7 @@ var Dg = (e, t) => {
7820
7820
  try {
7821
7821
  if (!i.shouldContinueConnecting) return i._isConnectInProgress = !1, i.logger.info("Connection aborted"), !1;
7822
7822
  let e = yield i.options.connectHandler();
7823
- if (i.connectStartTime = Date.now(), !i.shouldContinueConnecting) return i._isConnectInProgress = !1, i.logger.info("Connection aborted"), !1;
7823
+ if (i.connectStartTime = performance.now(), !i.shouldContinueConnecting) return i._isConnectInProgress = !1, i.logger.info("Connection aborted"), !1;
7824
7824
  i.logger.info("Connecting websocket", w(w({}, i.options), {}, { url: e }));
7825
7825
  let n = new WebSocket(e);
7826
7826
  return t = n, n.binaryType = "arraybuffer", n.onmessage = i.onMessage, n.addEventListener("error", i.onError), n.addEventListener("close", i.onClose), n.addEventListener("open", i.onOpen), i.websocket = n, i.startConnectTimeout(), !0;
@@ -7850,7 +7850,7 @@ var Dg = (e, t) => {
7850
7850
  }, Fg = class n {
7851
7851
  constructor(r, i, a, s) {
7852
7852
  var c = this;
7853
- e(this, "emitter", void 0), e(this, "transport", void 0), e(this, "logger", void 0), e(this, "config", void 0), e(this, "rtts", void 0), e(this, "lastPingSentTime", Date.now()), e(this, "isPingInFlight", !1), e(this, "connectCount", 0), e(this, "missedPings", 0), e(this, "isContextSwitchInProgress", !1), e(this, "signalBuffer", []), e(this, "dataBuffer", []), e(this, "disconnected", new T()), e(this, "unload", () => {
7853
+ e(this, "emitter", void 0), e(this, "transport", void 0), e(this, "logger", void 0), e(this, "config", void 0), e(this, "rtts", void 0), e(this, "lastPingSentTime", performance.now()), e(this, "isPingInFlight", !1), e(this, "connectCount", 0), e(this, "missedPings", 0), e(this, "isContextSwitchInProgress", !1), e(this, "signalBuffer", []), e(this, "dataBuffer", []), e(this, "disconnected", new T()), e(this, "unload", () => {
7854
7854
  this.logger.debug("Unloading module..."), this.close("Unloading"), this.emitter.off("send signal", this.sendSignal), this.emitter.off("disconnect", this.close), this.emitter.off("reconnect", this.reconnect), this.logger.debug("Unloaded module");
7855
7855
  }), e(this, "suspend", () => {
7856
7856
  this.resetPingState(), this.transport.suspend();
@@ -7920,7 +7920,7 @@ var Dg = (e, t) => {
7920
7920
  if (!Sn(t)) return;
7921
7921
  switch (t.type) {
7922
7922
  case "pong":
7923
- this.lastPingSentTime && (this.rtts.push(Date.now() - this.lastPingSentTime), this.isPingInFlight = !1, this.emitter.emit("rtt", Ot(this.rtts.items())));
7923
+ this.lastPingSentTime && (this.rtts.push(performance.now() - this.lastPingSentTime), this.isPingInFlight = !1, this.emitter.emit("rtt", Ot(this.rtts.items())));
7924
7924
  break;
7925
7925
  case "context switch":
7926
7926
  this.logger.info("Starting context switch"), this.emitter.emit("context switch started"), this.isContextSwitchInProgress = !0;
@@ -7958,12 +7958,12 @@ var Dg = (e, t) => {
7958
7958
  this.close(e);
7959
7959
  }), e(this, "resetPingState", () => {
7960
7960
  this.missedPings = 0, this.isPingInFlight = !1;
7961
- }), e(this, "pingCooldownExpired", () => Date.now() - this.lastPingSentTime > n.PING_INTERVAL), e(this, "sendPing", () => {
7961
+ }), e(this, "pingCooldownExpired", () => performance.now() - this.lastPingSentTime > n.PING_INTERVAL), e(this, "sendPing", () => {
7962
7962
  if (this.isPingInFlight) {
7963
7963
  this.missedPings++, this.missedPings > n.MAX_MISSED_PINGS && this.reconnect("missed pings");
7964
7964
  return;
7965
7965
  }
7966
- this.isPingInFlight = !0, this.lastPingSentTime = Date.now(), this.missedPings = 0, this.sendSignal({ type: "ping" });
7966
+ this.isPingInFlight = !0, this.lastPingSentTime = performance.now(), this.missedPings = 0, this.sendSignal({ type: "ping" });
7967
7967
  }), this.logger = i, this.emitter = r, this.config = a, this.rtts = s, this.emitter.on("send signal", this.sendSignal), this.emitter.on("disconnect", this.close), this.emitter.on("reconnect", this.reconnect), this.disconnected.promise.catch(o), this.transport = this.connectWebSocketTransport();
7968
7968
  }
7969
7969
  closed() {
@@ -8045,7 +8045,9 @@ var Ig = (e) => {
8045
8045
  transportSelectionReason: void 0
8046
8046
  };
8047
8047
  }), e(this, "connect", () => {
8048
- S(Wg, this, !0), !x(Gg, this) && (x(Qg, this) === void 0 && S(Yg, this, performance.now()), S(Gg, this, b(a_, this, p_).call(this)));
8048
+ if (S(Wg, this, !0), x(Gg, this)) return;
8049
+ let e = performance.now();
8050
+ x(Qg, this) === void 0 && S(Yg, this, e), x(Xg, this) === void 0 && S(Xg, this, e), S(Gg, this, b(a_, this, p_).call(this));
8049
8051
  }), y(this, n_, () => {
8050
8052
  x(Qg, this) !== void 0 || x(Yg, this) === void 0 || !x(Wg, this) || (S(Qg, this, performance.now() - x(Yg, this)), S(Yg, this, void 0));
8051
8053
  }), e(this, "disconnect", (e = "Disconnect Requested") => {
@@ -8065,7 +8067,7 @@ var Ig = (e) => {
8065
8067
  throw o.emitter.emit("error", te(e instanceof Error ? e : void 0)), e;
8066
8068
  }
8067
8069
  })), y(this, i_, t(function* () {
8068
- let e = Date.now(), t = () => Date.now() - e, r = globalThis.AbortController ? new AbortController() : void 0, i = setTimeout(() => r == null ? void 0 : r.abort(), n.PING_TIMEOUT);
8070
+ let e = performance.now(), t = () => performance.now() - e, r = globalThis.AbortController ? new AbortController() : void 0, i = setTimeout(() => r == null ? void 0 : r.abort(), n.PING_TIMEOUT);
8069
8071
  try {
8070
8072
  return yield fetch(new URL("/api/v4/connect/ping", o.config.options.get("url")).toString(), {
8071
8073
  method: "HEAD",
@@ -8090,9 +8092,9 @@ var Ig = (e) => {
8090
8092
  return function(t) {
8091
8093
  return e.apply(this, arguments);
8092
8094
  };
8093
- }()), y(this, l_, (e = Date.now()) => {
8095
+ }()), y(this, l_, (e = performance.now()) => {
8094
8096
  x(d_, this).call(this, e), x(e_, this).push(e);
8095
- }), y(this, u_, (e = Date.now()) => (x(d_, this).call(this, e), x(e_, this).length >= n.RECONNECT_BACKOFF_BURST_THRESHOLD)), y(this, d_, (e) => {
8097
+ }), y(this, u_, (e = performance.now()) => (x(d_, this).call(this, e), x(e_, this).length >= n.RECONNECT_BACKOFF_BURST_THRESHOLD)), y(this, d_, (e) => {
8096
8098
  for (; x(e_, this).length > 0;) {
8097
8099
  let t = x(e_, this)[0];
8098
8100
  if (t === void 0 || t > e - n.RECONNECT_BACKOFF_BURST_WINDOW_MS) return;
@@ -8109,7 +8111,7 @@ var Ig = (e) => {
8109
8111
  get estimatedBandwidth() {
8110
8112
  return this.connectionImpl && "estimatedBandwidth" in this.connectionImpl && this.connectionImpl.estimatedBandwidth ? this.connectionImpl.estimatedBandwidth : Pg(this.rtt);
8111
8113
  }
8112
- get firstConnectionTime() {
8114
+ get firstConnectStartTime() {
8113
8115
  return x(Xg, this);
8114
8116
  }
8115
8117
  get lastConnectionTime() {
@@ -8148,7 +8150,7 @@ function p_() {
8148
8150
  } catch (e) {
8149
8151
  throw o = "cached_edge", e;
8150
8152
  }
8151
- x(o_, e).call(e), S(Jg, e, (a = x(Jg, e), a++, a)), S(Kg, e, 0), S(Zg, e, Date.now()), x(Xg, e) || S(Xg, e, x(Zg, e)), x(n_, e).call(e), yield e.connectionImpl.closed(), e.logger.info("Connection closed"), o = "cached_edge";
8153
+ x(o_, e).call(e), S(Jg, e, (a = x(Jg, e), a++, a)), S(Kg, e, 0), S(Zg, e, performance.now()), x(n_, e).call(e), yield e.connectionImpl.closed(), e.logger.info("Connection closed"), o = "cached_edge";
8152
8154
  } catch (n) {
8153
8155
  e.logger.warn("Failed to connect", n);
8154
8156
  let r = t.shiftedEdge();
@@ -8413,7 +8415,7 @@ var v_ = 5, y_ = 100, b_ = 1e3, x_ = class r {
8413
8415
  }
8414
8416
  }
8415
8417
  if (!r) if (e.codec === "opus") {
8416
- let { OpusDecoderContext: t } = yield import("./B9WEkxkT.js");
8418
+ let { OpusDecoderContext: t } = yield import("./BsJtUY1Z.js");
8417
8419
  r = yield t.create(e.sampleRate || 48e3, e.channels || 2);
8418
8420
  } else {
8419
8421
  let t = l ? a ? `WebCodecs audio decoder initialization failed: ${a.message}` : o ? "WebCodecs audio decoder could not be initialized." : "WebCodecs AudioDecoder API is not supported in this environment." : "WebCodecs audio decoding is disabled.";
@@ -8429,7 +8431,7 @@ var v_ = 5, y_ = 100, b_ = 1e3, x_ = class r {
8429
8431
  break;
8430
8432
  }
8431
8433
  case "video": {
8432
- let { VideoDecoderWorkerContext: n } = yield import("./DtpcQ7ay.js"), r = yield n.create(i.createContext("VideoDecoderWorker"), a, c, l, u, d, () => s.currentTime);
8434
+ let { VideoDecoderWorkerContext: n } = yield import("./CLJilV9Y.js"), r = yield n.create(i.createContext("VideoDecoderWorker"), a, c, l, u, d, () => s.currentTime);
8433
8435
  p = r.isWebCodecs, h = r.usingOffscreenCanvas, t.set(e.type, {
8434
8436
  buffer: [],
8435
8437
  decoderContext: r,
@@ -8490,7 +8492,7 @@ var w_, T_ = (e) => (t, n, r) => t.timestamp <= n || t.timestampAdded <= r - e,
8490
8492
  }), e(this, "unload", () => {
8491
8493
  this.timers.unload(), this.emitter.off("add event", this.addEvent);
8492
8494
  }), e(this, "addEvent", (e) => {
8493
- this.logger.debug("Adding event", { event: e }), !this.waitingEvents.some((t) => t.id !== void 0 && t.id === e.id) && this.waitingEvents.push(w(w({}, e), {}, { timestampAdded: Date.now() }));
8495
+ this.logger.debug("Adding event", { event: e }), !this.waitingEvents.some((t) => t.id !== void 0 && t.id === e.id) && this.waitingEvents.push(w(w({}, e), {}, { timestampAdded: performance.now() }));
8494
8496
  }), e(this, "extractEvent", (e, t) => {
8495
8497
  t.type === "video" && e.channelId !== t.channelId && this.addEvent({
8496
8498
  type: "channel switch",
@@ -8503,7 +8505,7 @@ var w_, T_ = (e) => (t, n, r) => t.timestamp <= n || t.timestampAdded <= r - e,
8503
8505
  });
8504
8506
  }), e(this, "onBufferedStateChanged", () => {
8505
8507
  var e;
8506
- let t = Date.now(), n = (e = this.timeSource.drift) == null ? 0 : e, r = this.timeSource.serverCurrentTime - n;
8508
+ let t = performance.now(), n = (e = this.timeSource.drift) == null ? 0 : e, r = this.timeSource.serverCurrentTime - n;
8507
8509
  if (this.waitingEvents.length === 0) return;
8508
8510
  let i = this.waitingEvents.filter((e) => this.isTriggered(e, r, t));
8509
8511
  this.waitingEvents = this.waitingEvents.filter((e) => !this.isTriggered(e, r, t)), i.forEach((e) => {
@@ -8517,7 +8519,7 @@ w_ = E_, e(E_, "EVENT_TIMEOUT", 5e3), e(E_, "EVENT_CHECK_INTERVAL", 20), e(E_, "
8517
8519
  //#region ../../libs/web-sdk/src/modules/IncomingDataModule.ts
8518
8520
  var D_, O_ = class t {
8519
8521
  constructor(n) {
8520
- e(this, "emitter", void 0), e(this, "timers", j.create()), e(this, "bytesReceived", /* @__PURE__ */ new Map()), e(this, "timeoutInterval", void 0), e(this, "lastBytesUpdated", Date.now()), e(this, "load", () => {
8522
+ e(this, "emitter", void 0), e(this, "timers", j.create()), e(this, "bytesReceived", /* @__PURE__ */ new Map()), e(this, "timeoutInterval", void 0), e(this, "lastBytesUpdated", performance.now()), e(this, "load", () => {
8521
8523
  this.emitter.on("connection state", this.onConnectionState), this.timers.setInterval(() => this.bytesReceived.forEach((e) => e.tick()), 100);
8522
8524
  }), e(this, "unload", () => {
8523
8525
  this.emitter.off("connection state", this.onConnectionState), this.timers.unload();
@@ -8531,15 +8533,15 @@ var D_, O_ = class t {
8531
8533
  }), e;
8532
8534
  }), e(this, "add", (e, n) => {
8533
8535
  let r = this.bytesReceived.get(e);
8534
- r || (r = new Nt(20), this.bytesReceived.set(e, r)), n > 0 && (this.lastBytesUpdated = Date.now(), this.timeoutInterval || (this.timeoutInterval = this.timers.setInterval(this.checkTimeout, t.UPDATE_RECEIVED_BYTES_INTERVAL))), r.add(n);
8536
+ r || (r = new Nt(20), this.bytesReceived.set(e, r)), n > 0 && (this.lastBytesUpdated = performance.now(), this.timeoutInterval || (this.timeoutInterval = this.timers.setInterval(this.checkTimeout, t.UPDATE_RECEIVED_BYTES_INTERVAL))), r.add(n);
8535
8537
  }), e(this, "getStatistics", () => ({
8536
8538
  bytesReceived: this.totalBytesReceived(),
8537
8539
  videoBitRate: this.averageBitRate("video"),
8538
8540
  audioBitRate: this.averageBitRate("audio")
8539
8541
  })), e(this, "onConnectionState", (e) => {
8540
- this.clearTimeoutInterval(), e === "connected" && (this.lastBytesUpdated = Date.now(), this.timeoutInterval = this.timers.setInterval(this.checkTimeout, t.UPDATE_RECEIVED_BYTES_INTERVAL));
8542
+ this.clearTimeoutInterval(), e === "connected" && (this.lastBytesUpdated = performance.now(), this.timeoutInterval = this.timers.setInterval(this.checkTimeout, t.UPDATE_RECEIVED_BYTES_INTERVAL));
8541
8543
  }), e(this, "checkTimeout", () => {
8542
- let e = Date.now() - this.lastBytesUpdated;
8544
+ let e = performance.now() - this.lastBytesUpdated;
8543
8545
  if (this.totalBytesReceived() === 0 && e > t.NO_DATA_ERROR_TIMEOUT) {
8544
8546
  this.emitter.emit("error", a()), this.emitter.emit("reconnect", "no incoming data"), this.clearTimeoutInterval();
8545
8547
  return;
@@ -8568,28 +8570,28 @@ var k_ = 1e3, A_ = 50, j_ = class t {
8568
8570
  return `${e}-${t}`;
8569
8571
  }
8570
8572
  recordSample(e) {
8571
- var t, n, r, i;
8572
- let a = this.getTrackingKey(e.type, e.renditionId), o = (t = (n = globalThis.performance) == null || (r = n.now) == null ? void 0 : r.call(n)) == null ? Date.now() : t, s = e.timestamp / e.timescale * 1e3, c = this.trackingState.get(a);
8573
- if (!c) {
8574
- this.trackingState.set(a, {
8575
- lastArrivalTime: o,
8576
- lastTimestampMs: s,
8573
+ var t;
8574
+ let n = this.getTrackingKey(e.type, e.renditionId), r = performance.now(), i = e.timestamp / e.timescale * 1e3, a = this.trackingState.get(n);
8575
+ if (!a) {
8576
+ this.trackingState.set(n, {
8577
+ lastArrivalTime: r,
8578
+ lastTimestampMs: i,
8577
8579
  jitterSamples: new v(k_),
8578
8580
  interArrivalTimes: new v(k_)
8579
- }), this.runningJitter.set(a, 0), this.recentJitterSamples.set(a, new v(A_));
8581
+ }), this.runningJitter.set(n, 0), this.recentJitterSamples.set(n, new v(A_));
8580
8582
  return;
8581
8583
  }
8582
- let l = s - c.lastTimestampMs;
8583
- if (l <= 0) {
8584
- c.lastArrivalTime = o, c.lastTimestampMs = s;
8584
+ let o = i - a.lastTimestampMs;
8585
+ if (o <= 0) {
8586
+ a.lastArrivalTime = r, a.lastTimestampMs = i;
8585
8587
  return;
8586
8588
  }
8587
- let u = o - c.lastArrivalTime, d = Math.abs(u - l);
8588
- c.jitterSamples.push(d), c.interArrivalTimes.push(u);
8589
- let f = (i = this.runningJitter.get(a)) == null ? 0 : i, p = f + (d - f) / 16;
8590
- this.runningJitter.set(a, p);
8591
- let m = this.recentJitterSamples.get(a);
8592
- m || (m = new v(A_), this.recentJitterSamples.set(a, m)), m.push(d), c.lastArrivalTime = o, c.lastTimestampMs = s;
8589
+ let s = r - a.lastArrivalTime, c = Math.abs(s - o);
8590
+ a.jitterSamples.push(c), a.interArrivalTimes.push(s);
8591
+ let l = (t = this.runningJitter.get(n)) == null ? 0 : t, u = l + (c - l) / 16;
8592
+ this.runningJitter.set(n, u);
8593
+ let d = this.recentJitterSamples.get(n);
8594
+ d || (d = new v(A_), this.recentJitterSamples.set(n, d)), d.push(c), a.lastArrivalTime = r, a.lastTimestampMs = i;
8593
8595
  }
8594
8596
  getJitterForType(e) {
8595
8597
  for (let [i, a] of this.trackingState) if (i.startsWith(e)) {
@@ -8932,6 +8934,12 @@ var V_ = /* @__PURE__ */ new WeakMap(), H_ = class {
8932
8934
  var e;
8933
8935
  return (e = x(V_, this).find((e) => e.mode === "showing")) == null ? void 0 : e.language;
8934
8936
  }
8937
+ get tracks() {
8938
+ return x(V_, this);
8939
+ }
8940
+ get activeTrack() {
8941
+ return x(V_, this).find((e) => e.mode === "showing");
8942
+ }
8935
8943
  getActiveCues(e) {
8936
8944
  let t = x(V_, this).find((e) => e.mode === "showing");
8937
8945
  return t ? t.cues.filter(({ startTime: t, endTime: n }) => e >= t && e <= n) : [];
@@ -9059,17 +9067,15 @@ G_ = K_, e(K_, "create", (e, t, n, r, i, a, o, s) => new G_(e, t, n, r, i, a, o,
9059
9067
  //#region ../../libs/web-sdk/src/modules/ModernCanvasModule.ts
9060
9068
  var q_, J_ = class {
9061
9069
  constructor(t, n, r, i, { muted: a, volume: s, type: c, poster: l, offscreenCanvas: u, bufferTime: d }) {
9062
- e(this, "logger", void 0), e(this, "emitter", void 0), e(this, "mediaElement", void 0), e(this, "audioPlayer", void 0), e(this, "videoPlayer", void 0), e(this, "pool", void 0), e(this, "isDisconnected", !0), e(this, "_userProvidedMuted", !1), e(this, "timers", new j()), e(this, "offscreenCanvas", void 0), e(this, "nativeTextTrack", void 0), e(this, "nativeTrackCues", []), e(this, "volumeState", void 0), e(this, "textTracks", new H_()), e(this, "reset", () => {}), e(this, "load", () => {
9063
- this.mediaElement.load(), this.emitter.on("decoded frame", this.onDecodedFrame), this.emitter.on("flush buffers", this.flushBuffers), this.emitter.on("ios-hack: reset size", this.resetCanvasSize), this.emitter.on("enter picture in picture", this.onEnterIOSHack), this.emitter.on("exit picture in picture", this.onExitIOSHack), this.element().element.addEventListener("webkitendfullscreen", this.onExitIOSHack), this.element().element.addEventListener("webkitbeginfullscreen", this.onEnterIOSHack), this.videoPlayer.load(), this.nativeTextTrack = this.mediaElement.element.addTextTrack("subtitles", "", ""), this.nativeTextTrack.mode = "showing", this.timers.setInterval(() => {
9064
- if (!this.textTracks.language) {
9065
- this.clearNativeTrackCues();
9066
- return;
9067
- }
9068
- let e = this.textTracks.getActiveCues(this.currentTime / 1e3);
9069
- this.updateNativeTrackCues(e);
9070
- }, 100);
9070
+ e(this, "logger", void 0), e(this, "emitter", void 0), e(this, "mediaElement", void 0), e(this, "audioPlayer", void 0), e(this, "videoPlayer", void 0), e(this, "pool", void 0), e(this, "isDisconnected", !0), e(this, "_userProvidedMuted", !1), e(this, "timers", new j()), e(this, "offscreenCanvas", void 0), e(this, "nativeTracksByLanguage", /* @__PURE__ */ new Map()), e(this, "nativeCuesByLanguage", /* @__PURE__ */ new Map()), e(this, "lastCanvasCueTexts", []), e(this, "isIOSNativeFullscreen", !1), e(this, "isSyncingNativeTextTracks", !1), e(this, "renderCanvasSubtitlesInNativeFullscreen", (() => {
9071
+ let e = rt().platform;
9072
+ return e.isIOS && e.iosVersion <= 16;
9073
+ })()), e(this, "volumeState", void 0), e(this, "textTracks", new H_()), e(this, "reset", () => {}), e(this, "load", () => {
9074
+ this.mediaElement.load(), this.emitter.on("decoded frame", this.onDecodedFrame), this.emitter.on("flush buffers", this.flushBuffers), this.emitter.on("ios-hack: reset size", this.resetCanvasSize), this.emitter.on("enter picture in picture", this.onEnterIOSHack), this.emitter.on("exit picture in picture", this.onExitIOSHack), this.element().element.textTracks.addEventListener("change", this.onNativeTextTrackChange), this.element().element.addEventListener("webkitendfullscreen", this.onExitIOSHack), this.element().element.addEventListener("webkitbeginfullscreen", this.onEnterIOSHack), this.videoPlayer.load(), this.timers.setInterval(this.syncNativeTextTracks, 100);
9071
9075
  }), e(this, "unload", () => {
9072
- this.emitter.off("target buffer time", this.onTargetBufferTime), this.emitter.off("decoded frame", this.onDecodedFrame), this.emitter.off("flush buffers", this.flushBuffers), this.emitter.off("ios-hack: reset size", this.resetCanvasSize), this.emitter.off("enter picture in picture", this.onEnterIOSHack), this.emitter.off("exit picture in picture", this.onExitIOSHack), this.element().element.removeEventListener("webkitendfullscreen", this.onExitIOSHack), this.element().element.removeEventListener("webkitbeginfullscreen", this.onEnterIOSHack), this.clearNativeTrackCues(), this.nativeTextTrack = void 0, this.mediaElement.unload(), this.timers.unload(), this.audioPlayer.unload(), this.videoPlayer.unload();
9076
+ this.emitter.off("target buffer time", this.onTargetBufferTime), this.emitter.off("decoded frame", this.onDecodedFrame), this.emitter.off("flush buffers", this.flushBuffers), this.emitter.off("ios-hack: reset size", this.resetCanvasSize), this.emitter.off("enter picture in picture", this.onEnterIOSHack), this.emitter.off("exit picture in picture", this.onExitIOSHack), this.element().element.textTracks.removeEventListener("change", this.onNativeTextTrackChange), this.element().element.removeEventListener("webkitendfullscreen", this.onExitIOSHack), this.element().element.removeEventListener("webkitbeginfullscreen", this.onEnterIOSHack);
9077
+ for (let e of this.nativeTracksByLanguage.keys()) this.clearNativeCues(e);
9078
+ this.nativeTracksByLanguage.clear(), this.nativeCuesByLanguage.clear(), this.mediaElement.unload(), this.timers.unload(), this.audioPlayer.unload(), this.videoPlayer.unload();
9073
9079
  }), e(this, "suspend", () => {
9074
9080
  this.videoPlayer.suspend(), this.audioPlayer.suspend();
9075
9081
  }), e(this, "unsuspend", () => {
@@ -9081,9 +9087,9 @@ var q_, J_ = class {
9081
9087
  }), e(this, "resetCanvasSize", () => {
9082
9088
  this.videoPlayer.resetSize();
9083
9089
  }), e(this, "onEnterIOSHack", () => {
9084
- this.mediaElement._iosHackEnterPiPMode();
9090
+ this.isIOSNativeFullscreen = !0, this.mediaElement._iosHackEnterPiPMode();
9085
9091
  }), e(this, "onExitIOSHack", () => {
9086
- this.mediaElement._iosHackExitPiPMode();
9092
+ this.isIOSNativeFullscreen = !1, this.clearCanvasCues(), this.mediaElement._iosHackExitPiPMode();
9087
9093
  }), e(this, "onDecodedFrame", (e) => {
9088
9094
  try {
9089
9095
  this.audioPlayer.onDecodedFrame(e);
@@ -9111,23 +9117,60 @@ var q_, J_ = class {
9111
9117
  let e = !this.mediaElement.element.paused;
9112
9118
  this.logger.info("Reconnecting canvas stream after renderer change", { wasPlaying: e }), this.connectStreams(), e && this.mediaElement.tryPlay();
9113
9119
  }
9114
- }), e(this, "clearNativeTrackCues", () => {
9115
- if (this.nativeTextTrack) {
9116
- for (let e of this.nativeTrackCues) try {
9117
- this.nativeTextTrack.removeCue(e);
9118
- } catch (e) {}
9119
- this.nativeTrackCues = [];
9120
+ }), e(this, "ensureNativeTrack", (e) => {
9121
+ let t = this.nativeTracksByLanguage.get(e.language);
9122
+ if (t) return t;
9123
+ let n = this.mediaElement.element.addTextTrack(e.kind, e.label, e.language);
9124
+ return this.nativeTracksByLanguage.set(e.language, n), this.nativeCuesByLanguage.set(e.language, []), n;
9125
+ }), e(this, "getSelectedNativeTextTrack", () => {
9126
+ let e = this.mediaElement.element.textTracks;
9127
+ for (let t = 0; t < e.length; t++) {
9128
+ let n = e[t];
9129
+ if ((n == null ? void 0 : n.mode) === "showing") return n;
9130
+ }
9131
+ }), e(this, "onNativeTextTrackChange", () => {
9132
+ if (this.isSyncingNativeTextTracks) return;
9133
+ let e = this.getSelectedNativeTextTrack();
9134
+ if (!e) {
9135
+ this.emitter.emit("native text track selected", void 0);
9136
+ return;
9120
9137
  }
9121
- }), e(this, "updateNativeTrackCues", (e) => {
9122
- let t = this.nativeTextTrack;
9123
- if (!t) return;
9124
- let n = e.map((e) => e.text), r = this.nativeTrackCues.map((e) => e.text);
9125
- if (!(n.length === r.length && n.every((e, t) => e === r[t]))) {
9126
- this.clearNativeTrackCues();
9127
- for (let n of e) {
9128
- let e = new VTTCue(0, 999999999, n.text);
9129
- t.addCue(e), this.nativeTrackCues.push(e);
9130
- }
9138
+ let t = this.textTracks.tracks.find((t) => t.language === e.language);
9139
+ t && this.emitter.emit("native text track selected", t.label);
9140
+ }), e(this, "clearNativeCues", (e) => {
9141
+ let t = this.nativeTracksByLanguage.get(e), n = this.nativeCuesByLanguage.get(e);
9142
+ if (!(!t || !n || n.length === 0)) {
9143
+ for (let e of n) try {
9144
+ t.removeCue(e);
9145
+ } catch (e) {}
9146
+ this.nativeCuesByLanguage.set(e, []);
9147
+ }
9148
+ }), e(this, "setNativeCues", (e, t) => {
9149
+ let n = this.nativeTracksByLanguage.get(e), r = this.nativeCuesByLanguage.get(e);
9150
+ if (!n || !r || Ft(t.map((e) => e.text), r.map((e) => e.text))) return;
9151
+ this.clearNativeCues(e);
9152
+ let i = [];
9153
+ for (let e of t) {
9154
+ let t = new VTTCue(0, 2 ** 53 - 1, e.text);
9155
+ n.addCue(t), i.push(t);
9156
+ }
9157
+ this.nativeCuesByLanguage.set(e, i);
9158
+ }), e(this, "shouldRenderCanvasCues", () => this.canvasCuesEnabled && this.isIOSNativeFullscreen), e(this, "setCanvasCues", (e, t = !1) => {
9159
+ let n = e.map((e) => e.text);
9160
+ !t && Ft(n, this.lastCanvasCueTexts) || (this.lastCanvasCueTexts = n, this.videoPlayer.setActiveCues(e, {
9161
+ width: this.mediaElement.element.clientWidth,
9162
+ height: this.mediaElement.element.clientHeight
9163
+ }));
9164
+ }), e(this, "clearCanvasCues", () => {
9165
+ this.canvasCuesEnabled && this.setCanvasCues([], !0);
9166
+ }), e(this, "syncNativeTextTracks", () => {
9167
+ for (let e of this.textTracks.tracks) this.ensureNativeTrack(e);
9168
+ let e = this.textTracks.activeTrack, t = e ? this.textTracks.getActiveCues(this.currentTime / 1e3) : [];
9169
+ this.shouldRenderCanvasCues() && this.setCanvasCues(t), this.isSyncingNativeTextTracks = !0;
9170
+ try {
9171
+ for (let [n, r] of this.nativeTracksByLanguage) n === (e == null ? void 0 : e.language) ? (r.mode !== "showing" && (r.mode = "showing"), this.setNativeCues(n, t)) : (r.mode !== "disabled" && (r.mode = "disabled"), this.clearNativeCues(n));
9172
+ } finally {
9173
+ this.isSyncingNativeTextTracks = !1;
9131
9174
  }
9132
9175
  }), e(this, "updateVolumeState", () => {
9133
9176
  let e = {
@@ -9211,6 +9254,9 @@ var q_, J_ = class {
9211
9254
  pause() {
9212
9255
  this.mediaElement.pause();
9213
9256
  }
9257
+ get canvasCuesEnabled() {
9258
+ return this.renderCanvasSubtitlesInNativeFullscreen && !this.offscreenCanvas;
9259
+ }
9214
9260
  };
9215
9261
  q_ = J_, e(J_, "create", (e, t, n, r, i) => new q_(e, t, n, r, i));
9216
9262
  //#endregion
@@ -9312,7 +9358,7 @@ function iv(e, { mediaSource: t, mimeType: n, codec: r }) {
9312
9358
  sourceBuffer: t.addSourceBuffer(n),
9313
9359
  isWorkingOnPendingSamples: !1,
9314
9360
  sequenceNumber: 0,
9315
- lastBufferCleanupTime: Date.now()
9361
+ lastBufferCleanupTime: performance.now()
9316
9362
  });
9317
9363
  }
9318
9364
  function av({ initSegments: e, pendingSamples: t }) {
@@ -9331,7 +9377,7 @@ function av({ initSegments: e, pendingSamples: t }) {
9331
9377
  var ov = class {
9332
9378
  constructor(n, a, s) {
9333
9379
  var u = this;
9334
- e(this, "maxChunkSize", 20), e(this, "minConsecutiveErrorsBeforeEmit", 5), e(this, "maxSecondsInBuffer", 60), e(this, "logger", void 0), e(this, "timers", j.create()), e(this, "emitter", void 0), e(this, "mediaElement", void 0), e(this, "mediaSource", new tv()), e(this, "trackContexts", /* @__PURE__ */ new Map()), e(this, "autoRecoverFromMediaErrors", !0), e(this, "quotaErrorCount", 0), e(this, "recoveredFromErrorCount", 0), e(this, "sourceOpenStartTime", Date.now()), e(this, "sourceOpenEndTime", Date.now()), e(this, "pendingTracksToAddSourceBuffers", void 0), e(this, "hasAddedInitialPosterFrame", !0), e(this, "videoKeyframeTimestamps", []), e(this, "isReopening", !1), e(this, "playbackStallCount", 0), e(this, "hasStartedPlayback", !1), e(this, "isPlaybackStalled", !1), e(this, "load", () => {
9380
+ e(this, "maxChunkSize", 20), e(this, "minConsecutiveErrorsBeforeEmit", 5), e(this, "maxSecondsInBuffer", 60), e(this, "logger", void 0), e(this, "timers", j.create()), e(this, "emitter", void 0), e(this, "mediaElement", void 0), e(this, "mediaSource", new tv()), e(this, "trackContexts", /* @__PURE__ */ new Map()), e(this, "autoRecoverFromMediaErrors", !0), e(this, "quotaErrorCount", 0), e(this, "recoveredFromErrorCount", 0), e(this, "sourceOpenStartTime", performance.now()), e(this, "sourceOpenEndTime", performance.now()), e(this, "pendingTracksToAddSourceBuffers", void 0), e(this, "hasAddedInitialPosterFrame", !0), e(this, "videoKeyframeTimestamps", []), e(this, "isReopening", !1), e(this, "playbackStallCount", 0), e(this, "hasStartedPlayback", !1), e(this, "isPlaybackStalled", !1), e(this, "load", () => {
9335
9381
  this.emitter.on("init segment", this.init), this.emitter.on("coded sample", this.onCodedSample), this.emitter.on("flush buffers", this.flushBuffers), this.emitter.on("fragment", this.onFragment);
9336
9382
  }), e(this, "unload", () => {
9337
9383
  this.logger.debug("Unloading module..."), this.emitter.off("init segment", this.init), this.emitter.off("coded sample", this.onCodedSample), this.emitter.off("flush buffers", this.flushBuffers), this.emitter.off("fragment", this.onFragment), this.mediaSource.off("source ended", this.onSourceEnded), this.mediaSource.off("source open", this.onSourceOpen), this.mediaElement.removeEventListener("error", this.onMediaElementError), this.mediaElement.removeEventListener("waiting", this.onPlaybackStall), this.mediaElement.removeEventListener("stalled", this.onPlaybackStall), this.mediaElement.removeEventListener("playing", this.onPlaybackProgress), this.mediaElement.removeEventListener("pause", this.onPlaybackPauseOrSeek), this.mediaElement.removeEventListener("seeking", this.onPlaybackPauseOrSeek), this.mediaSource.detach(this.mediaElement), this.trackContexts.forEach((e) => {
@@ -9494,7 +9540,7 @@ var ov = class {
9494
9540
  "fragmented" in n || (yield r.sourceBuffer.appendBuffer(a));
9495
9541
  }
9496
9542
  let s = Math.max(0, n.timestamp / n.timescale - u.maxSecondsInBuffer);
9497
- s > 0 && Date.now() - r.lastBufferCleanupTime > 1e4 && (r.lastBufferCleanupTime = Date.now(), yield r.sourceBuffer.removeBuffer(0, s + 10));
9543
+ s > 0 && performance.now() - r.lastBufferCleanupTime > 1e4 && (r.lastBufferCleanupTime = performance.now(), yield r.sourceBuffer.removeBuffer(0, s + 10));
9498
9544
  try {
9499
9545
  let t = r.sequenceNumber;
9500
9546
  if ("fragmented" in n) for (let t of e) "initData" in t && (yield r.sourceBuffer.appendBuffer(t.data, t.initData));
@@ -9585,7 +9631,7 @@ var ov = class {
9585
9631
  mediaElementError: (t = this.mediaElement.error) == null ? void 0 : t.message
9586
9632
  });
9587
9633
  }), e(this, "onSourceOpen", () => {
9588
- this.logger.debug("source opened"), this.sourceOpenEndTime = Date.now(), this.isReopening = !1, this.pendingTracksToAddSourceBuffers && (this.setSourceBuffers(this.pendingTracksToAddSourceBuffers), this.pendingTracksToAddSourceBuffers = void 0);
9634
+ this.logger.debug("source opened"), this.sourceOpenEndTime = performance.now(), this.isReopening = !1, this.pendingTracksToAddSourceBuffers && (this.setSourceBuffers(this.pendingTracksToAddSourceBuffers), this.pendingTracksToAddSourceBuffers = void 0);
9589
9635
  }), e(this, "reopenMediaSource", (e) => {
9590
9636
  this.logger.info("Re-opening MediaSource", { reason: e }), this.isReopening = !0, this.recoveredFromErrorCount++;
9591
9637
  let t = !this.mediaElement.paused, n = [];
@@ -9595,7 +9641,7 @@ var ov = class {
9595
9641
  mimeType: e.mimeType,
9596
9642
  codec: e.codec
9597
9643
  });
9598
- }), this.sourceOpenStartTime = Date.now(), this.pendingTracksToAddSourceBuffers = n, this.mediaSource.detach(this.mediaElement), this.setTrackContexts(this.trackContexts), this.mediaSource.attach(this.mediaElement), t && this.mediaElement.play().catch(o);
9644
+ }), this.sourceOpenStartTime = performance.now(), this.pendingTracksToAddSourceBuffers = n, this.mediaSource.detach(this.mediaElement), this.setTrackContexts(this.trackContexts), this.mediaSource.attach(this.mediaElement), t && this.mediaElement.play().catch(o);
9599
9645
  }), e(this, "onMediaElementError", () => {
9600
9646
  let { error: e } = this.mediaElement;
9601
9647
  if (!e || this.isReopening) return;
@@ -9751,7 +9797,7 @@ var gv, _v = class {
9751
9797
  needsInputForVideoCount: this.needsInputForVideoCount
9752
9798
  })), e(this, "onBufferedStateChanged", ({ buffered: e, isPaused: t, playbackState: n }) => {
9753
9799
  let r = this.clockSource.currentTime, i = e.some((e) => e.start <= r && r < e.end), a = e[e.length - 1], o = a ? a.end - a.start >= this.targetBufferTime : !1, s = a ? Math.max(0, a.end - r) / this.targetBufferTime : 0, c = t ? "paused" : n, l = this.state;
9754
- this.currentTimeIsInRange !== i && !i ? (this.lastBufferStateEvent = "drained", this.emitter.emit("buffer state event", this.lastBufferStateEvent)) : i && o && this.lastBufferStateEvent === "drained" && (this.lastBufferStateEvent = "filled", this.emitter.emit("buffer state event", this.lastBufferStateEvent)), c === "playing" && !this.firstFrameTime && (this.firstFrameTime = Date.now()), this.currentTimeIsInRange = i, this.state = c, this.bufferFullness = i ? s : 0, l !== c && this.emitter.emit("playback state", c), this.emitter.emit("buffer fullness", this.bufferFullness);
9800
+ this.currentTimeIsInRange !== i && !i ? (this.lastBufferStateEvent = "drained", this.emitter.emit("buffer state event", this.lastBufferStateEvent)) : i && o && this.lastBufferStateEvent === "drained" && (this.lastBufferStateEvent = "filled", this.emitter.emit("buffer state event", this.lastBufferStateEvent)), c === "playing" && this.firstFrameTime === void 0 && (this.firstFrameTime = performance.now()), this.currentTimeIsInRange = i, this.state = c, this.bufferFullness = i ? s : 0, l !== c && this.emitter.emit("playback state", c), this.emitter.emit("buffer fullness", this.bufferFullness);
9755
9801
  }), e(this, "onNeedsUserInput", ({ forAudio: e, forVideo: t }) => {
9756
9802
  e && this.needsInputForAudioCount++, t && this.needsInputForVideoCount++;
9757
9803
  }), this.emitter = t, this.logger = n, this.clockSource = r, this.targetBufferTime = i, this.emitter.on("buffer state", this.onBufferedStateChanged), this.emitter.on("needs user input", this.onNeedsUserInput), this.emitter.emit("target buffer time", i);
@@ -9810,7 +9856,7 @@ var vv, yv = () => ({
9810
9856
  t || (this.hasAsserted = !0, console.assert(t, `Buffering ratios should be less than 1 - actual: ${Array.from(e.values()).reduce((e, t) => e + t, 0)}`));
9811
9857
  }
9812
9858
  return e;
9813
- }), e(this, "bufferingEventsLast", (e) => this.metrics.general.bufferingRanges.filter((t) => t.start >= Date.now() - e).length), e(this, "timeSpentBufferingLast", (e) => dn(this.metrics.general.bufferingRanges, e)), e(this, "timeSpentActiveLast", (e) => dn(this.metrics.general.activeRanges, e)), e(this, "timeSpentPlayingInAtLeastLevelRatio", (e) => {
9859
+ }), e(this, "bufferingEventsLast", (e) => this.metrics.general.bufferingRanges.filter((t) => t.start >= performance.now() - e).length), e(this, "timeSpentBufferingLast", (e) => dn(this.metrics.general.bufferingRanges, e)), e(this, "timeSpentActiveLast", (e) => dn(this.metrics.general.activeRanges, e)), e(this, "timeSpentPlayingInAtLeastLevelRatio", (e) => {
9814
9860
  var t, n, r, i;
9815
9861
  let a = this.timeSpentBuffering(), o = this.timeActive(), s = this.bufferingRatios(), c = this.activeRatios(), l = ((t = (n = e.video) == null ? void 0 : n.bitRate) == null ? 0 : t) + ((r = (i = e.audio) == null ? void 0 : i.bitRate) == null ? 0 : r), u = a / o;
9816
9862
  return Object.keys(this.metrics.levels).map((e) => parseInt(e, 10)).filter((e) => e >= l).reduce((e, t) => {
@@ -9838,12 +9884,12 @@ var vv, yv = () => ({
9838
9884
  this.logger.info("rendition level changed", {
9839
9885
  fromLevel: l,
9840
9886
  toLevel: u
9841
- }), this.metrics.general.activeRanges.length === 0 && this.setActive(), e.from && e.to && (l < u ? this.metrics.general.upgradesFromLevel.push(Date.now()) : this.metrics.general.downgradesFromLevel.push(Date.now()));
9887
+ }), this.metrics.general.activeRanges.length === 0 && this.setActive(), e.from && e.to && (l < u ? this.metrics.general.upgradesFromLevel.push(performance.now()) : this.metrics.general.downgradesFromLevel.push(performance.now()));
9842
9888
  let d = !1;
9843
9889
  if (e.from) {
9844
9890
  var f;
9845
9891
  let e = (f = this.metrics.levels[l]) == null ? yv() : f;
9846
- l < u ? e.upgradesFromLevel.push(Date.now()) : e.downgradesFromLevel.push(Date.now()), cn(e.activeRanges);
9892
+ l < u ? e.upgradesFromLevel.push(performance.now()) : e.downgradesFromLevel.push(performance.now()), cn(e.activeRanges);
9847
9893
  let t = e.bufferingRanges[e.bufferingRanges.length - 1];
9848
9894
  d = !!t && !t.end, cn(e.bufferingRanges), this.metrics.levels[l] = e;
9849
9895
  }
@@ -10093,7 +10139,7 @@ var Ov, kv = 5e3, Av = () => Ye() || Ke(), jv = (e) => e && Av() ? 100 : 0, Mv =
10093
10139
  this._driftSamplesToCollect = e, this.driftSamples = new v(e);
10094
10140
  }
10095
10141
  constructor(t, n, r, i, a, o = !0) {
10096
- e(this, "emitter", void 0), e(this, "logger", void 0), e(this, "playbackSource", void 0), e(this, "bufferSource", void 0), e(this, "keyframeTimestamps", new v(10)), e(this, "lastSeekTime", Date.now()), e(this, "lastAdjustmentTime", Date.now()), e(this, "lastDecayCheckTime", Date.now()), e(this, "config", void 0), e(this, "state", void 0), e(this, "allowTimeshiftOnAudio", !1), e(this, "syncInfoToleranceMaxMs", 150), e(this, "syncInfoToleranceStep", 20), e(this, "seekOvershoot", void 0), e(this, "timers", j.create()), e(this, "rtt", 0), e(this, "channelSyncInfo", /* @__PURE__ */ new Map()), e(this, "seekAdjustmentCount", 0), e(this, "timeshiftAdjustmentCount", 0), e(this, "syncInfoCorrectionCount", 0), e(this, "playbackRateAdjustmentCount", 0), e(this, "lastPlaybackRateChangeTime", 0), e(this, "seekAdjustmentTimestamps", []), e(this, "timeshiftAdjustmentTimestamps", []), e(this, "_driftSamplesToCollect", 5), e(this, "driftSamples", new v(this._driftSamplesToCollect)), e(this, "timestampOffset", void 0), e(this, "currentChannelId", void 0), e(this, "highestSeenTimestamps", /* @__PURE__ */ new Map()), e(this, "isSuspended", !1), e(this, "isSyncAdjustmentActivated", !1), e(this, "queuedTimeshift", !1), e(this, "playbackState", void 0), e(this, "hasPerformedRecoverySeekInCurrentRecoveryState", !1), e(this, "shouldSeekAfterBuffering", !1), e(this, "usesMse", void 0), e(this, "load", () => {
10142
+ e(this, "emitter", void 0), e(this, "logger", void 0), e(this, "playbackSource", void 0), e(this, "bufferSource", void 0), e(this, "keyframeTimestamps", new v(10)), e(this, "lastSeekTime", void 0), e(this, "lastAdjustmentTime", performance.now()), e(this, "lastDecayCheckTime", performance.now()), e(this, "config", void 0), e(this, "state", void 0), e(this, "allowTimeshiftOnAudio", !1), e(this, "syncInfoToleranceMaxMs", 150), e(this, "syncInfoToleranceStep", 20), e(this, "seekOvershoot", void 0), e(this, "timers", j.create()), e(this, "rtt", 0), e(this, "channelSyncInfo", /* @__PURE__ */ new Map()), e(this, "seekAdjustmentCount", 0), e(this, "timeshiftAdjustmentCount", 0), e(this, "syncInfoCorrectionCount", 0), e(this, "playbackRateAdjustmentCount", 0), e(this, "lastPlaybackRateChangeTime", 0), e(this, "seekAdjustmentTimestamps", []), e(this, "timeshiftAdjustmentTimestamps", []), e(this, "_driftSamplesToCollect", 5), e(this, "driftSamples", new v(this._driftSamplesToCollect)), e(this, "timestampOffset", void 0), e(this, "currentChannelId", void 0), e(this, "highestSeenTimestamps", /* @__PURE__ */ new Map()), e(this, "isSuspended", !1), e(this, "isSyncAdjustmentActivated", !1), e(this, "queuedTimeshift", !1), e(this, "playbackState", void 0), e(this, "hasPerformedRecoverySeekInCurrentRecoveryState", !1), e(this, "shouldSeekAfterBuffering", !1), e(this, "usesMse", void 0), e(this, "load", () => {
10097
10143
  this.timers.setInterval(this.onSync, 100);
10098
10144
  }), e(this, "unload", () => {
10099
10145
  this.logger.debug("Unloading module..."), this.emitter.off("rtt", this.updateRtt), this.emitter.off("playback state", this.onPlaybackState), this.timers.unload(), this.logger.debug("Unloaded module");
@@ -10104,7 +10150,7 @@ var Ov, kv = 5e3, Av = () => Ye() || Ke(), jv = (e) => e && Av() ? 100 : 0, Mv =
10104
10150
  }), e(this, "deactivateSyncAdjustments", () => {
10105
10151
  this.isSyncAdjustmentActivated = !1;
10106
10152
  }), e(this, "activateSyncAdjustments", () => {
10107
- this.tryApplySyncInfo(0), this.lastSeekTime = Date.now(), this.isSyncAdjustmentActivated = !0;
10153
+ this.tryApplySyncInfo(0), this.isSyncAdjustmentActivated = !0;
10108
10154
  }), e(this, "reset", () => {
10109
10155
  this.logger.info("Reset sync state"), this.currentChannelId = void 0, this.timestampOffset = void 0, this.resetSyncState(), this.highestSeenTimestamps.clear();
10110
10156
  }), e(this, "getTimeshiftOffset", () => {
@@ -10115,7 +10161,7 @@ var Ov, kv = 5e3, Av = () => Ye() || Ke(), jv = (e) => e && Av() ? 100 : 0, Mv =
10115
10161
  }), e(this, "getEffectiveSeekToleranceMs", () => this.config.timeshift.enabled ? this.config.seek.toleranceMs * 2 : this.config.seek.toleranceMs), e(this, "getLiveEdgeTime", (e) => {
10116
10162
  let t = this.channelSyncInfo.get(e);
10117
10163
  if (!t) return;
10118
- let n = Date.now() - t.localTimestamp;
10164
+ let n = performance.now() - t.localTimestamp;
10119
10165
  return t.timestamp + n;
10120
10166
  }), e(this, "getLiveEdgeTimeLatencyAdjusted", (e) => {
10121
10167
  let t = this.getLiveEdgeTime(e);
@@ -10123,7 +10169,7 @@ var Ov, kv = 5e3, Av = () => Ye() || Ke(), jv = (e) => e && Av() ? 100 : 0, Mv =
10123
10169
  }), e(this, "getWallclockTime", (e) => {
10124
10170
  let t = this.channelSyncInfo.get(e);
10125
10171
  if (!t) return;
10126
- let n = Date.now() - t.localTimestamp;
10172
+ let n = performance.now() - t.localTimestamp;
10127
10173
  return t.wallclockTime + n;
10128
10174
  }), e(this, "getWallclockTimeLatencyAdjusted", (e) => {
10129
10175
  let t = this.getWallclockTime(e);
@@ -10182,12 +10228,12 @@ var Ov, kv = 5e3, Av = () => Ye() || Ke(), jv = (e) => e && Av() ? 100 : 0, Mv =
10182
10228
  };
10183
10229
  }), e(this, "updateRtt", (e) => {
10184
10230
  this.rtt = e;
10185
- }), e(this, "isPlaybackSourceReadyToSeek", () => !this.isSeeking() && this.isSeekCooldownExpired() && this.isSyncAdjustmentActivated), e(this, "isPlaybackSourceReady", () => !this.isSeeking() && this.isSyncAdjustmentActivated), e(this, "isSeeking", () => this.playbackSource.isSeeking ? !this.isSeekTimeoutExpired() : !1), e(this, "isAllowedToSync", () => this.isPlaybackSourceReadyToSeek() && !!this.currentChannelId && !this.isSuspended && !this.playbackSource.isPaused), e(this, "isAllowedToSyncIgnoringCooldown", () => this.isPlaybackSourceReady() && !!this.currentChannelId && !this.isSuspended && !this.playbackSource.isPaused), e(this, "isSeekCooldownExpired", () => Date.now() - this.lastSeekTime > this.config.seek.cooldownMs), e(this, "isSeekTimeoutExpired", () => Date.now() - this.lastSeekTime > this.config.seek.timeoutMs), e(this, "currentTimeshiftToleranceMs", () => Math.min(this.config.timeshift.toleranceMs * this.state.timeshiftToleranceMultiplier, this.config.timeshift.toleranceMaxMs)), e(this, "currentSeekToleranceMs", () => Math.min(this.state.seekToleranceMultiplier * this.getEffectiveSeekToleranceMs(), this.config.seek.toleranceMaxMs)), e(this, "currentEmergencySeekToleranceMs", () => Math.max(this.currentSeekToleranceMs() + this.getEffectiveSeekToleranceMs(), this.bufferSource.getTargetBufferTime())), e(this, "currentAheadToleranceMs", () => {
10231
+ }), e(this, "isPlaybackSourceReadyToSeek", () => !this.isSeeking() && this.isSeekCooldownExpired() && this.isSyncAdjustmentActivated), e(this, "isPlaybackSourceReady", () => !this.isSeeking() && this.isSyncAdjustmentActivated), e(this, "isSeeking", () => this.playbackSource.isSeeking ? !this.isSeekTimeoutExpired() : !1), e(this, "isAllowedToSync", () => this.isPlaybackSourceReadyToSeek() && !!this.currentChannelId && !this.isSuspended && !this.playbackSource.isPaused), e(this, "isAllowedToSyncIgnoringCooldown", () => this.isPlaybackSourceReady() && !!this.currentChannelId && !this.isSuspended && !this.playbackSource.isPaused), e(this, "isSeekCooldownExpired", () => this.lastSeekTime === void 0 || performance.now() - this.lastSeekTime > this.config.seek.cooldownMs), e(this, "isSeekTimeoutExpired", () => this.lastSeekTime === void 0 || performance.now() - this.lastSeekTime > this.config.seek.timeoutMs), e(this, "currentTimeshiftToleranceMs", () => Math.min(this.config.timeshift.toleranceMs * this.state.timeshiftToleranceMultiplier, this.config.timeshift.toleranceMaxMs)), e(this, "currentSeekToleranceMs", () => Math.min(this.state.seekToleranceMultiplier * this.getEffectiveSeekToleranceMs(), this.config.seek.toleranceMaxMs)), e(this, "currentEmergencySeekToleranceMs", () => Math.max(this.currentSeekToleranceMs() + this.getEffectiveSeekToleranceMs(), this.bufferSource.getTargetBufferTime())), e(this, "currentAheadToleranceMs", () => {
10186
10232
  let e = Math.max(this.config.seek.aheadToleranceMs * this.state.seekToleranceMultiplier, 400), t = this.playbackSource.seekTime > 500 ? e : this.config.seek.aheadToleranceMs;
10187
10233
  return Math.min(t, this.bufferSource.getTargetBufferTime() / 2);
10188
10234
  }), e(this, "tryDecayMultipliers", () => {
10189
10235
  if (!this.config.backoff.decayEnabled) return;
10190
- let e = Date.now();
10236
+ let e = performance.now();
10191
10237
  if (e - this.lastDecayCheckTime < this.config.backoff.decayCheckInterval) return;
10192
10238
  this.lastDecayCheckTime = e;
10193
10239
  let t = this.seekAdjustmentTimestamps.length > 0 ? Math.max(...this.seekAdjustmentTimestamps) : 0, n = this.timeshiftAdjustmentTimestamps.length > 0 ? Math.max(...this.timeshiftAdjustmentTimestamps) : 0, r = e - Math.max(t, n, this.lastAdjustmentTime), i = Math.max(this.state.seekToleranceMultiplier, this.state.timeshiftToleranceMultiplier), a = this.config.seek.timeoutMs * this.config.backoff.decayCooldownMultiplier * i;
@@ -10216,7 +10262,7 @@ var Ov, kv = 5e3, Av = () => Ye() || Ke(), jv = (e) => e && Av() ? 100 : 0, Mv =
10216
10262
  this.seekAdjustmentTimestamps = this.seekAdjustmentTimestamps.filter((e) => e > t), this.timeshiftAdjustmentTimestamps = this.timeshiftAdjustmentTimestamps.filter((e) => e > t);
10217
10263
  }
10218
10264
  }), e(this, "applyBackoff", () => {
10219
- if (this.config.backoff.enabled && (this.lastAdjustmentTime = Date.now(), this.seekAdjustmentCount > 0 && this.seekAdjustmentCount % this.config.seek.backoffEveryN === 0)) {
10265
+ if (this.config.backoff.enabled && (this.lastAdjustmentTime = performance.now(), this.seekAdjustmentCount > 0 && this.seekAdjustmentCount % this.config.seek.backoffEveryN === 0)) {
10220
10266
  let e = this.state.seekToleranceMultiplier, t = this.config.seek.toleranceMaxMs / this.getEffectiveSeekToleranceMs();
10221
10267
  this.state.seekToleranceMultiplier = Math.min(this.state.seekToleranceMultiplier + this.config.seek.toleranceMultiplierStep, t), e !== this.state.seekToleranceMultiplier && this.logger.info("Backoff: Increasing seek tolerance multiplier", {
10222
10268
  from: e,
@@ -10227,8 +10273,8 @@ var Ov, kv = 5e3, Av = () => Ye() || Ke(), jv = (e) => e && Av() ? 100 : 0, Mv =
10227
10273
  }), e(this, "tryPlaybackRateSync", (e) => {
10228
10274
  if (!this.config.playbackRate.enabled) return !1;
10229
10275
  let t = this.playbackSource.playbackRate !== 1, n = Math.abs(e), r = t && n < this.config.playbackRate.stopDiff, i = !t && n >= this.config.playbackRate.startDiff;
10230
- if (n > this.config.playbackRate.maxDiff) return t && (this.playbackSource.playbackRate = 1, this.lastPlaybackRateChangeTime = Date.now()), !1;
10231
- let a = Date.now(), o = a - this.lastPlaybackRateChangeTime >= this.config.playbackRate.cooldownMs;
10276
+ if (n > this.config.playbackRate.maxDiff) return t && (this.playbackSource.playbackRate = 1, this.lastPlaybackRateChangeTime = performance.now()), !1;
10277
+ let a = performance.now(), o = a - this.lastPlaybackRateChangeTime >= this.config.playbackRate.cooldownMs;
10232
10278
  if (r && o) return this.playbackSource.playbackRate = 1, this.lastPlaybackRateChangeTime = a, this.logger.info("Resetting playback rate to 1", { drift: e }), !0;
10233
10279
  if (i && o) {
10234
10280
  let t = e > 0 ? 1 + this.config.playbackRate.speed : 1 - this.config.playbackRate.speed;
@@ -10256,7 +10302,7 @@ var Ov, kv = 5e3, Av = () => Ye() || Ke(), jv = (e) => e && Av() ? 100 : 0, Mv =
10256
10302
  return;
10257
10303
  }
10258
10304
  if (n >= this.getEffectiveSeekToleranceMs() || n < this.currentTimeshiftToleranceMs()) return;
10259
- let r = Date.now() - this.config.seek.timeoutMs * this.state.timeshiftToleranceMultiplier, i = this.timeshiftAdjustmentTimestamps.filter(Mv(r)).length;
10305
+ let r = performance.now() - this.config.seek.timeoutMs * this.state.timeshiftToleranceMultiplier, i = this.timeshiftAdjustmentTimestamps.filter(Mv(r)).length;
10260
10306
  if (i && this.state.timeshiftToleranceMultiplier > 2) {
10261
10307
  this.logger.debug("Too many timeshifts within sliding window", {
10262
10308
  timeshiftCooldownThreshold: r,
@@ -10298,7 +10344,8 @@ var Ov, kv = 5e3, Av = () => Ye() || Ke(), jv = (e) => e && Av() ? 100 : 0, Mv =
10298
10344
  };
10299
10345
  }), e(this, "applySeek", (e, t) => {
10300
10346
  let n = this.playbackSource.seekTime, r = this.buildSeekPlan(e, t);
10301
- r && (this.logger.info("Adjusting for drift using seek", {
10347
+ if (!r) return;
10348
+ this.logger.info("Adjusting for drift using seek", {
10302
10349
  drift: e,
10303
10350
  currentTime: this.playbackSource.currentTime,
10304
10351
  recoverySeekReason: t,
@@ -10309,19 +10356,23 @@ var Ov, kv = 5e3, Av = () => Ye() || Ke(), jv = (e) => e && Av() ? 100 : 0, Mv =
10309
10356
  seekTime: n,
10310
10357
  rtt: this.rtt,
10311
10358
  seekToleranceMultiplier: this.state.seekToleranceMultiplier
10312
- }), this.lastSeekTime = Date.now(), t && (this.hasPerformedRecoverySeekInCurrentRecoveryState = !0), this.clearRecoverySeekFlags(), this.driftSamples.clear(), this.seekAdjustmentTimestamps.push(this.lastSeekTime), this.seekAdjustmentCount++, this.playbackSource.currentTime = r.targetCurrentTime + Math.min(n, this.bufferSource.getTargetBufferTime()), this.applyBackoff());
10359
+ });
10360
+ let i = performance.now();
10361
+ this.lastSeekTime = i, t && (this.hasPerformedRecoverySeekInCurrentRecoveryState = !0), this.clearRecoverySeekFlags(), this.driftSamples.clear(), this.seekAdjustmentTimestamps.push(i), this.seekAdjustmentCount++, this.playbackSource.currentTime = r.targetCurrentTime + Math.min(n, this.bufferSource.getTargetBufferTime()), this.applyBackoff();
10313
10362
  }), e(this, "applyTimeshift", (e) => {
10314
10363
  var t;
10315
10364
  let n = (t = e == null ? this.drift : e) == null ? 0 : t;
10316
10365
  if (!this.timestampOffset) return;
10317
10366
  let r = n;
10318
- if (this.logger.info("Adjusting for drift using timeshift", {
10367
+ this.logger.info("Adjusting for drift using timeshift", {
10319
10368
  drift: n,
10320
10369
  syncAmount: r,
10321
10370
  currentTime: this.playbackSource.currentTime,
10322
10371
  rtt: this.rtt,
10323
10372
  timeshiftToleranceMultiplier: this.state.timeshiftToleranceMultiplier
10324
- }), this.timestampOffset += r, this.lastSeekTime = Date.now(), this.lastAdjustmentTime = Date.now(), !this.playbackSource.isPaused && (this.driftSamples.clear(), this.timeshiftAdjustmentTimestamps.push(this.lastSeekTime), this.timeshiftAdjustmentCount++, this.config.backoff.enabled && this.timeshiftAdjustmentCount > 0 && this.timeshiftAdjustmentCount % this.config.timeshift.backoffEveryN === 0)) {
10373
+ }), this.timestampOffset += r;
10374
+ let i = performance.now();
10375
+ if (this.lastSeekTime = i, this.lastAdjustmentTime = i, !this.playbackSource.isPaused && (this.driftSamples.clear(), this.timeshiftAdjustmentTimestamps.push(i), this.timeshiftAdjustmentCount++, this.config.backoff.enabled && this.timeshiftAdjustmentCount > 0 && this.timeshiftAdjustmentCount % this.config.timeshift.backoffEveryN === 0)) {
10325
10376
  let e = this.state.timeshiftToleranceMultiplier, t = this.config.timeshift.toleranceMaxMs / this.config.timeshift.toleranceMs;
10326
10377
  this.state.timeshiftToleranceMultiplier = Math.min(this.state.timeshiftToleranceMultiplier + 1, t), e !== this.state.timeshiftToleranceMultiplier && this.logger.info("Backoff: Increasing timeshift tolerance multiplier", {
10327
10378
  from: e,
@@ -10336,7 +10387,7 @@ var Ov, kv = 5e3, Av = () => Ye() || Ke(), jv = (e) => e && Av() ? 100 : 0, Mv =
10336
10387
  if (!r && !this.isAllowedToSyncIgnoringCooldown() || r && (this.isSeeking() || !this.currentChannelId || this.isSuspended || this.playbackSource.isPaused) || (this.driftSamples.push(t), !this.isSeekCooldownExpired()) || !r && this.driftSamples.items().length < this.driftSamplesToCollect && Math.abs(t) < 2e3) return;
10337
10388
  let i = r ? t : At(this.driftSamples.items());
10338
10389
  if (!r && this.tryPlaybackRateSync(i) || !r && this.shouldSkipNormalSeek(i)) return;
10339
- let a = Date.now() - this.config.seek.timeoutMs * this.state.seekToleranceMultiplier, o = this.seekAdjustmentTimestamps.filter(Mv(a)).length, s = this.currentEmergencySeekToleranceMs(), c = i > 0 && i >= s;
10390
+ let a = performance.now() - this.config.seek.timeoutMs * this.state.seekToleranceMultiplier, o = this.seekAdjustmentTimestamps.filter(Mv(a)).length, s = this.currentEmergencySeekToleranceMs(), c = i > 0 && i >= s;
10340
10391
  if (o && this.state.seekToleranceMultiplier > 2 && !r && !c) {
10341
10392
  this.logger.debug("Too many seek adjustments within sliding window", {
10342
10393
  seekCooldownThreshold: a,
@@ -10378,7 +10429,7 @@ var Ov, kv = 5e3, Av = () => Ye() || Ke(), jv = (e) => e && Av() ? 100 : 0, Mv =
10378
10429
  }, typeof window < "u" && window.location.search.includes("playbackRateAdjustmentEnabled") && (this.config.playbackRate.enabled = !0), this.emitter.on("rtt", this.updateRtt), this.emitter.on("playback state", this.onPlaybackState), this.logger.info("SyncModule initialized", { config: this.config });
10379
10430
  }
10380
10431
  updateChannelSyncInfo(e, t) {
10381
- let n = Date.now(), r = this.channelSyncInfo.get(e), i = this.getLiveEdgeTime(e);
10432
+ let n = performance.now(), r = this.channelSyncInfo.get(e), i = this.getLiveEdgeTime(e);
10382
10433
  if (this.isSuspended) return;
10383
10434
  if (!r || !i) {
10384
10435
  this.logger.info("Initial timing info", { syncInfo: t }), this.channelSyncInfo.set(e, w(w({}, t), {}, {
@@ -10396,7 +10447,7 @@ var Ov, kv = 5e3, Av = () => Ye() || Ke(), jv = (e) => e && Av() ? 100 : 0, Mv =
10396
10447
  diffFromEstimated: c,
10397
10448
  timestampDelta: o,
10398
10449
  wallclockDelta: a,
10399
- localWallclockDelta: s
10450
+ localTimestampDelta: s
10400
10451
  }), Math.abs(c) >= Math.max(this.bufferSource.getTargetBufferTime() * 2, 3e3)) {
10401
10452
  this.logger.info("Resetting sync info", { diffFromEstimated: c }), this.channelSyncInfo.set(e, w(w({}, t), {}, {
10402
10453
  localTimestamp: n,
@@ -10640,8 +10691,41 @@ var Uv = class {
10640
10691
  data: e.payload,
10641
10692
  duration: 0
10642
10693
  });
10643
- }, Zv = (e, t) => e && typeof e == "object" && t in e, Qv = (e) => !(typeof e != "object" || !Zv(e, "channelId") || typeof e.channelId != "string" || !Zv(e, "url") || typeof e.url != "string" || e.channelId.length === 0 || e.url.length === 0), $v = (e) => {
10644
- if (!Qv(e)) throw new g("Invalid options", {
10694
+ }, Zv = ({ average: e, last: t, max: n, min: r }) => ({
10695
+ average: Math.round(e),
10696
+ last: Math.round(t),
10697
+ max: Math.round(n),
10698
+ min: Math.round(r)
10699
+ }), Qv = [
10700
+ "timeSpentBuffering",
10701
+ "timePerBufferingEvent",
10702
+ "drift",
10703
+ "seekTime",
10704
+ "totalSeekTime",
10705
+ "currentSeekToleranceMs",
10706
+ "currentAheadToleranceMs",
10707
+ "averageDrift",
10708
+ "videoKeyframeIntervalMs",
10709
+ "timeToConnected",
10710
+ "mediaSourceOpenTime"
10711
+ ], $v = [
10712
+ "videoDecodeTime",
10713
+ "audioDecodeTime",
10714
+ "videoTransportTime",
10715
+ "rtt"
10716
+ ], ey = (e) => typeof e == "object" && !!e && "min" in e && "max" in e && "average" in e && "last" in e, ty = (e) => {
10717
+ let t = w({}, e);
10718
+ for (let e of Qv) {
10719
+ let n = t[e];
10720
+ typeof n == "number" && (t[e] = Math.round(n));
10721
+ }
10722
+ for (let e of $v) {
10723
+ let n = t[e];
10724
+ ey(n) && (t[e] = Zv(n));
10725
+ }
10726
+ return t;
10727
+ }, ny = (e, t) => e && typeof e == "object" && t in e, ry = (e) => !(typeof e != "object" || !ny(e, "channelId") || typeof e.channelId != "string" || !ny(e, "url") || typeof e.url != "string" || e.channelId.length === 0 || e.url.length === 0), iy = (e) => {
10728
+ if (!ry(e)) throw new g("Invalid options", {
10645
10729
  isFatal: !0,
10646
10730
  code: "invalid_options"
10647
10731
  });
@@ -10650,13 +10734,13 @@ var Uv = class {
10650
10734
  let n = t;
10651
10735
  n[e] === void 0 && delete n[e];
10652
10736
  }), t;
10653
- }, ey = (e) => {
10737
+ }, ay = (e) => {
10654
10738
  if (typeof e != "object" || !e) throw Error("not an object");
10655
10739
  if (!("video" in e)) throw Error("missing video in subscription");
10656
10740
  if (!("audio" in e)) throw Error("missing audio in subscription");
10657
10741
  if (!("channelId" in e)) throw Error("missing channelId");
10658
10742
  return !0;
10659
- }, ty = class {
10743
+ }, oy = class {
10660
10744
  constructor(n) {
10661
10745
  var r = this;
10662
10746
  e(this, "cache", /* @__PURE__ */ new Map()), e(this, "inFlight", /* @__PURE__ */ new Map()), e(this, "checkVideoSupport", function() {
@@ -10717,10 +10801,10 @@ var Uv = class {
10717
10801
  return this.inFlight.set(e, o), o;
10718
10802
  }), this.logger = n;
10719
10803
  }
10720
- }, ny = /* @__PURE__ */ new WeakMap(), ry = /* @__PURE__ */ new WeakMap(), iy = /* @__PURE__ */ new WeakMap(), ay = class n extends ge {
10804
+ }, sy = /* @__PURE__ */ new WeakMap(), cy = /* @__PURE__ */ new WeakMap(), ly = /* @__PURE__ */ new WeakMap(), uy = class n extends ge {
10721
10805
  constructor(r) {
10722
10806
  var i, a;
10723
- super(), i = this, e(this, "pictureInPicture", void 0), e(this, "drm", void 0), e(this, "browser", rt()), e(this, "options", void 0), e(this, "element", void 0), e(this, "playbackSource", void 0), e(this, "emitter", new ge()), e(this, "logger", void 0), e(this, "modules", void 0), e(this, "clientIp", void 0), e(this, "sessionId", void 0), e(this, "clientId", mn()), e(this, "_channels", []), e(this, "createdAt", Date.now()), e(this, "offscreenCanvasElement", void 0), e(this, "webCodecsRenditionSupport", void 0), e(this, "hasCalledConnect", !1), e(this, "latestEmittedLanguages", []), e(this, "wakeLock", void 0), e(this, "pool", new xe(n.MAX_POOL_SIZE)), e(this, "userAgentInformation", new pn()), e(this, "encryptedMediaExtensions", void 0), y(this, ny, 0), y(this, ry, []), e(this, "sampleProcessingSesssions", /* @__PURE__ */ new Map()), e(this, "sizes", /* @__PURE__ */ new Map()), e(this, "isSuspended", !0), e(this, "disconnectTimeout", void 0), e(this, "offscreenSubtitleInterval", void 0), y(this, iy, void 0), e(this, "attach", (e) => {
10807
+ super(), i = this, e(this, "pictureInPicture", void 0), e(this, "drm", void 0), e(this, "browser", rt()), e(this, "options", void 0), e(this, "element", void 0), e(this, "playbackSource", void 0), e(this, "emitter", new ge()), e(this, "logger", void 0), e(this, "modules", void 0), e(this, "clientIp", void 0), e(this, "sessionId", void 0), e(this, "clientId", mn()), e(this, "_channels", []), e(this, "createdAt", performance.now()), e(this, "offscreenCanvasElement", void 0), e(this, "webCodecsRenditionSupport", void 0), e(this, "hasCalledConnect", !1), e(this, "latestEmittedLanguages", []), e(this, "wakeLock", void 0), e(this, "pool", new xe(n.MAX_POOL_SIZE)), e(this, "userAgentInformation", new pn()), e(this, "encryptedMediaExtensions", void 0), y(this, sy, 0), y(this, cy, []), e(this, "sampleProcessingSesssions", /* @__PURE__ */ new Map()), e(this, "sizes", /* @__PURE__ */ new Map()), e(this, "isSuspended", !0), e(this, "disconnectTimeout", void 0), e(this, "offscreenSubtitleInterval", void 0), y(this, ly, void 0), e(this, "attach", (e) => {
10724
10808
  var t;
10725
10809
  (t = this.wakeLock) == null || t.attach(e), e.appendChild(this.element);
10726
10810
  }), e(this, "setElement", (e) => {
@@ -10803,20 +10887,20 @@ var Uv = class {
10803
10887
  }), e(this, "updateTextTracks", (e) => {
10804
10888
  let t = e.filter((e) => e.codec === "webvtt");
10805
10889
  t.forEach((e) => {
10806
- if (!x(ry, this).find((t) => t.language === e.language)) {
10890
+ if (!x(cy, this).find((t) => t.language === e.language)) {
10807
10891
  if (this.modules.canvasModule) {
10808
10892
  let t = this.modules.canvasModule.textTracks.addTextTrack(e.kind, e.label || e.language || "", e.language || "");
10809
- x(ry, this).push(t);
10893
+ x(cy, this).push(t);
10810
10894
  } else if (this.mediaElement instanceof HTMLVideoElement) {
10811
10895
  let t = this.mediaElement.addTextTrack(e.kind, e.label || e.language, e.language);
10812
- x(ry, this).push(t);
10896
+ x(cy, this).push(t);
10813
10897
  }
10814
10898
  }
10815
10899
  });
10816
- for (let e of x(ry, this)) t.find((t) => t.language === e.language) ? e.mode === "disabled" && (e.mode = "hidden") : e.mode = "disabled";
10900
+ for (let e of x(cy, this)) t.find((t) => t.language === e.language) ? e.mode === "disabled" && (e.mode = "hidden") : e.mode = "disabled";
10817
10901
  this.emit("text tracks", this.textTracks);
10818
10902
  }), e(this, "cleanupTextTracks", (e = this.currentTime - 2e4) => {
10819
- x(ry, this).forEach((t) => {
10903
+ x(cy, this).forEach((t) => {
10820
10904
  if (t.cues) for (let n of t.cues) n.endTime * 1e3 < e - 2e3 && t.removeCue(n);
10821
10905
  });
10822
10906
  }), e(this, "filterRenditions", function() {
@@ -10889,11 +10973,15 @@ var Uv = class {
10889
10973
  bitRate: this.abrEnabled ? r : this.options.get("maxVideoBitRate")
10890
10974
  }, e));
10891
10975
  }
10892
- l && (this.modules.subscription.setAudioConstraint({
10893
- codec: l,
10894
- bitRate: this.abrEnabled ? i : this.options.get("maxAudioBitRate"),
10895
- language: this.options.get("language")
10896
- }), (!d.includes(this.options.get("language")) || this.language === void 0) && this.modules.subscription.setLanguage(d[0])), this.alignSizeAndBitRate(this.targetSubscription);
10976
+ if (l) {
10977
+ let e = this.modules.subscription.getTargetSubscription().audio.language, t = e == null ? this.options.get("language") : e;
10978
+ this.modules.subscription.setAudioConstraint({
10979
+ codec: l,
10980
+ bitRate: this.abrEnabled ? i : this.options.get("maxAudioBitRate"),
10981
+ language: t
10982
+ }), (t === void 0 || !d.includes(t)) && this.modules.subscription.setLanguage(d[0]);
10983
+ }
10984
+ this.alignSizeAndBitRate(this.targetSubscription);
10897
10985
  let f = this.modules.subscription.getTargetSubscription();
10898
10986
  this.emitter.emit("subscription changed", {
10899
10987
  to: f,
@@ -10994,12 +11082,12 @@ var Uv = class {
10994
11082
  this.hasCalledConnect ? this.unsuspend() : this.playbackState !== "playing" && (this._connect(), self.addEventListener("__vindral_register_debug__", this.registerDebugInstance), this.modules.timer.setInterval(() => this.cleanupTextTracks(), n.REMOVE_CUE_THRESHOLD)), (e = this.wakeLock) == null || e.enable(), this.playbackState === "paused" && (this.resetModules(), this.emitter.emit("flush buffers"), this.cleanupTextTracks(2 ** 53 - 1)), this.playbackSource.play();
10995
11083
  }), e(this, "getStatistics", () => {
10996
11084
  let e = Object.values(this.modules).reduce((e, t) => t && "getStatistics" in t ? w(w({}, e), t.getStatistics()) : e, this.getRuntimeInfo()), t = Math.round(this.timeActive > 0 ? (e.bytesReceived || 0) * 8 / (this.timeActive / 1e3) : 0), n = this.uptime / 36e5, r = Math.max(0, (e.connectCount || 0) - 1), i = n > 0 ? r / n : 0, a = this.timeActive / 6e4, o = Math.max(a, 1), s = a > 0 ? (e.seekAdjustmentCount || 0) / o : 0, c = a > 0 ? (e.timeshiftAdjustmentCount || 0) / o : 0;
10997
- return w(w({}, e), {}, {
11085
+ return ty(w(w({}, e), {}, {
10998
11086
  averageBitRate: t,
10999
11087
  reconnectsPerHour: i,
11000
11088
  seekAdjustmentsPerMinute: s,
11001
11089
  timeshiftAdjustmentsPerMinute: c
11002
- });
11090
+ }));
11003
11091
  }), e(this, "resetModules", () => {
11004
11092
  Object.values(this.modules).forEach((e) => {
11005
11093
  e && "reset" in e && e.reset();
@@ -11007,8 +11095,8 @@ var Uv = class {
11007
11095
  }), e(this, "getRuntimeInfo", () => {
11008
11096
  let e = this.modules.canvasModule instanceof J_ ? !0 : void 0;
11009
11097
  return w({
11010
- uptime: Date.now() - this.createdAt,
11011
- version: "4.3.1",
11098
+ uptime: this.uptime,
11099
+ version: "4.3.2-2-gffc6c8655",
11012
11100
  clientId: this.clientId,
11013
11101
  sessionId: this.sessionId,
11014
11102
  channelId: this.channelId,
@@ -11040,9 +11128,9 @@ var Uv = class {
11040
11128
  this.logger.info("Buffer filled - starting playback", { currentTime: e }), this.playbackSource.currentTime = e, this.modules.sync.activateSyncAdjustments(), this.playbackSource.isActivated = !0;
11041
11129
  } else e === "drained" && this.playbackSource.isPaused && (this.playbackSource.isActivated = !1, this.modules.sync.deactivateSyncAdjustments());
11042
11130
  }), e(this, "timeToFirstFrame", () => {
11043
- let e = this.modules.playback.getFirstFrameTime(), t = this.modules.connection.firstConnectionTime;
11044
- if (t && e) return e - t;
11045
- }), this.options = new Uv(w(w({}, Cn), $v(r))), r.telemetryEnabled === void 0 && ["localhost", "127.0.0.1"].includes(location.hostname) && this.options.set("telemetryEnabled", !1);
11131
+ let e = this.modules.playback.getFirstFrameTime(), t = this.modules.connection.firstConnectStartTime;
11132
+ if (t !== void 0 && e !== void 0) return Math.round(e - t);
11133
+ }), this.options = new Uv(w(w({}, Cn), iy(r))), r.telemetryEnabled === void 0 && ["localhost", "127.0.0.1"].includes(location.hostname) && this.options.set("telemetryEnabled", !1);
11046
11134
  let o = {
11047
11135
  channelId: this.options.get("channelId"),
11048
11136
  audio: {
@@ -11055,7 +11143,7 @@ var Uv = class {
11055
11143
  height: this.options.get("maxSize").height
11056
11144
  }
11057
11145
  }, s = O.get();
11058
- s.setLevel(this.options.get("logLevel")), s.setDebug(!1), this.logger = s, this.webCodecsRenditionSupport = new ty(s), r.iosMediaElementEnabled !== void 0 && this.logger.warn("Option iosMediaElementEnabled is deprecated and will be removed in a future release. Use streamToMediaElementEnabled instead.");
11146
+ s.setLevel(this.options.get("logLevel")), s.setDebug(!1), this.logger = s, this.webCodecsRenditionSupport = new oy(s), r.iosMediaElementEnabled !== void 0 && this.logger.warn("Option iosMediaElementEnabled is deprecated and will be removed in a future release. Use streamToMediaElementEnabled instead.");
11059
11147
  let c = (a = r.streamToMediaElementEnabled) == null ? r.iosMediaElementEnabled : a;
11060
11148
  c !== void 0 && (this.options.set("streamToMediaElementEnabled", c), this.options.set("iosMediaElementEnabled", c));
11061
11149
  let l = r.mseEnabled !== void 0, f = r.decoders !== void 0;
@@ -11203,7 +11291,7 @@ var Uv = class {
11203
11291
  a = Math.max(r - 2, 0);
11204
11292
  break;
11205
11293
  case "reconnect": if (r === 0 || this.modules.qualityOfService.timeSpentBufferingLast(6e3) > 5e3) {
11206
- if (!this.modules.connection.lastConnectionTime || Date.now() - this.modules.connection.lastConnectionTime < this.modules.qualityOfService.fatalQosGraceTime() || this.modules.connection.getState() !== "connected") return;
11294
+ if (this.modules.connection.lastConnectionTime === void 0 || performance.now() - this.modules.connection.lastConnectionTime < this.modules.qualityOfService.fatalQosGraceTime() || this.modules.connection.getState() !== "connected") return;
11207
11295
  this.modules.qualityOfService.incrementFatalQosCount(), this.logger.info("Reconnecting due to poor qos"), this.modules.connection.reconnect("Fatal QOS"), this.emitter.emit("adapted level");
11208
11296
  return;
11209
11297
  } else a = 0;
@@ -11215,14 +11303,16 @@ var Uv = class {
11215
11303
  audio: w(w({}, this.targetSubscription.audio), d == null ? void 0 : d.audio)
11216
11304
  })), this.emitter.emit("adapted level");
11217
11305
  }), this.emitter.on("text track data", (e) => {
11218
- let t = x(ry, this).find((t) => t.language === e.language), n = this.modules.sync.getTimeshiftOffset() / 1e3, r = n - x(ny, this);
11219
- if (S(ny, this, n), t) {
11306
+ let t = x(cy, this).find((t) => t.language === e.language), n = this.modules.sync.getTimeshiftOffset() / 1e3, r = n - x(sy, this);
11307
+ if (S(sy, this, n), t) {
11220
11308
  if (t.cues) for (let e of t.cues) e.startTime -= r, e.endTime -= r;
11221
11309
  for (let r of e.cues) {
11222
11310
  let e = new VTTCue(r.startTime - n, r.endTime - n, r.text);
11223
11311
  t.addCue(e);
11224
11312
  }
11225
11313
  }
11314
+ }), this.emitter.on("native text track selected", (e) => {
11315
+ this.textTrack = e;
11226
11316
  }), this.emitter.on("received signal", (e) => {
11227
11317
  let t = e, n = this.modules.subscription.getCurrentSubscription();
11228
11318
  switch (this.logger.debug("received", w({}, t)), t.type) {
@@ -11230,19 +11320,19 @@ var Uv = class {
11230
11320
  this.clientIp = t.ip;
11231
11321
  break;
11232
11322
  case "renditions":
11233
- this.updateTextTracks(t.renditions), S(iy, this, this.filterRenditions(t.renditions).then((e) => {
11323
+ this.updateTextTracks(t.renditions), S(ly, this, this.filterRenditions(t.renditions).then((e) => {
11234
11324
  this.emitter.emit("renditions", {
11235
11325
  renditions: e,
11236
11326
  channelId: this.currentSubscription.channelId
11237
11327
  }), this.emit("rendition levels", this.modules.renditions.getRenditionLevels()), this.emitLanguagesIfChanged();
11238
11328
  }).finally(() => {
11239
- S(iy, this, void 0);
11329
+ S(ly, this, void 0);
11240
11330
  }));
11241
11331
  break;
11242
11332
  case "subscription changed":
11243
11333
  var r;
11244
11334
  try {
11245
- ey(t.subscription);
11335
+ ay(t.subscription);
11246
11336
  } catch (e) {
11247
11337
  this.emitter.emit("error", new g("Subscription failed validation", {
11248
11338
  source: e instanceof Error ? e : void 0,
@@ -11357,7 +11447,7 @@ var Uv = class {
11357
11447
  let be = function() {
11358
11448
  var e = t(function* (e) {
11359
11449
  let t = e.channelId;
11360
- x(iy, i) && (yield x(iy, i));
11450
+ x(ly, i) && (yield x(ly, i));
11361
11451
  let n = i.modules.renditions.getRendition(e.renditionId, t);
11362
11452
  if (!Xo(e.flags)) {
11363
11453
  if (Zo(e.flags)) {
@@ -11365,8 +11455,8 @@ var Uv = class {
11365
11455
  if (e.renditionId !== 0) {
11366
11456
  let e = ce(t);
11367
11457
  if (e && e.language !== void 0) {
11368
- let t = new cs().parse(e.content || ""), r = n / 1e3, a = x(ry, i).find((t) => t.language === e.language), o = r - x(ny, i);
11369
- if (S(ny, i, r), a) {
11458
+ let t = new cs().parse(e.content || ""), r = n / 1e3, a = x(cy, i).find((t) => t.language === e.language), o = r - x(sy, i);
11459
+ if (S(sy, i, r), a) {
11370
11460
  if (a.cues) for (let e of a.cues) e.startTime -= o, e.endTime -= o;
11371
11461
  for (let e of t) {
11372
11462
  let t = new VTTCue(e.startTime - r, e.endTime - r, e.text);
@@ -11509,7 +11599,7 @@ var Uv = class {
11509
11599
  this.modules.subscription.setLanguage(e), this.alignSizeAndBitRate(this.targetSubscription);
11510
11600
  }
11511
11601
  set textTrack(e) {
11512
- e !== this.textTrack && (x(ry, this).forEach((t) => {
11602
+ e !== this.textTrack && (x(cy, this).forEach((t) => {
11513
11603
  if (t.label === e) t.mode = "showing";
11514
11604
  else {
11515
11605
  if (t.mode === "showing" && t.cues) for (let e of [...t.cues]) t.removeCue(e);
@@ -11518,11 +11608,11 @@ var Uv = class {
11518
11608
  }), this.emitter.emit("text track", e));
11519
11609
  }
11520
11610
  get textTracks() {
11521
- return x(ry, this).filter((e) => e.mode !== "disabled").map((e) => e.label);
11611
+ return x(cy, this).filter((e) => e.mode !== "disabled").map((e) => e.label);
11522
11612
  }
11523
11613
  get textTrack() {
11524
11614
  var e;
11525
- return (e = x(ry, this).find((e) => e.mode === "showing")) == null ? void 0 : e.label;
11615
+ return (e = x(cy, this).find((e) => e.mode === "showing")) == null ? void 0 : e.label;
11526
11616
  }
11527
11617
  get channelId() {
11528
11618
  var e, t;
@@ -11603,10 +11693,10 @@ var Uv = class {
11603
11693
  return this.modules.qualityOfService.bufferingRatios();
11604
11694
  }
11605
11695
  get timeSpentBuffering() {
11606
- return this.modules.qualityOfService.timeSpentBuffering();
11696
+ return Math.round(this.modules.qualityOfService.timeSpentBuffering());
11607
11697
  }
11608
11698
  get timeActive() {
11609
- return this.modules.qualityOfService.timeActive();
11699
+ return Math.round(this.modules.qualityOfService.timeActive());
11610
11700
  }
11611
11701
  get mediaElement() {
11612
11702
  return this.element;
@@ -11620,7 +11710,7 @@ var Uv = class {
11620
11710
  return (e = this.encryptedMediaExtensions) == null ? void 0 : e.getStatistics();
11621
11711
  }
11622
11712
  get uptime() {
11623
- return Date.now() - this.createdAt;
11713
+ return Math.round(performance.now() - this.createdAt);
11624
11714
  }
11625
11715
  suspend() {
11626
11716
  this.isSuspended || (Object.values(this.modules).forEach((e) => {
@@ -11675,6 +11765,6 @@ var Uv = class {
11675
11765
  return t === void 0 ? this.shouldUseWebCodecs(e) : t;
11676
11766
  }
11677
11767
  };
11678
- e(ay, "MAX_POOL_SIZE", 10), e(ay, "DISCONNECT_TIMEOUT", 15 * 1e3), e(ay, "REMOVE_CUE_THRESHOLD", 1e3 * 10);
11768
+ e(uy, "MAX_POOL_SIZE", 10), e(uy, "DISCONNECT_TIMEOUT", 15 * 1e3), e(uy, "REMOVE_CUE_THRESHOLD", 1e3 * 10);
11679
11769
  //#endregion
11680
- export { $e as _, ut as a, lt as c, wt as d, St as f, Tt as g, xt as h, mt as i, ft as l, _t as m, O as n, pt as o, bt as p, dt as r, yt as s, ay as t, gt as u, Qe as v };
11770
+ export { $e as _, ut as a, lt as c, wt as d, St as f, Tt as g, xt as h, mt as i, ft as l, _t as m, O as n, pt as o, bt as p, dt as r, yt as s, uy as t, gt as u, Qe as v };