vue3-video-play3
Version:
hls.js player component for Vue3
1,487 lines • 771 kB
JavaScript
import { computed as pt, openBlock as re, createElementBlock as ae, normalizeClass as ft, normalizeStyle as gt, ref as rt, onUnmounted as An, createElementVNode as U, toDisplayString as fe, unref as ut, defineComponent as Qt, withDirectives as Re, createVNode as ce, createTextVNode as Ke, vShow as be, useCssVars as Pi, nextTick as Ln, getCurrentInstance as Za, createCommentVNode as ve, reactive as xs, withModifiers as Ja, watch as In, onMounted as Rn, Transition as ui, withCtx as hi, Fragment as As, renderList as Ls, useAttrs as eo, mergeProps as to, createBlock as so, withKeys as Ot } from "vue";
function io(a, e, t) {
var s = t || {}, i = s.noTrailing, r = i === void 0 ? !1 : i, n = s.noLeading, o = n === void 0 ? !1 : n, c = s.debounceMode, l = c === void 0 ? void 0 : c, d, u = !1, h = 0;
function g() {
d && clearTimeout(d);
}
function f(p) {
var E = p || {}, v = E.upcomingOnly, T = v === void 0 ? !1 : v;
g(), u = !T;
}
function y() {
for (var p = arguments.length, E = new Array(p), v = 0; v < p; v++)
E[v] = arguments[v];
var T = this, S = Date.now() - h;
if (u)
return;
function x() {
h = Date.now(), e.apply(T, E);
}
function _() {
d = void 0;
}
!o && l && !d && x(), g(), l === void 0 && S > a ? o ? (h = Date.now(), r || (d = setTimeout(l ? _ : x, a))) : x() : r !== !0 && (d = setTimeout(l ? _ : x, l === void 0 ? a - S : a));
}
return y.cancel = f, y;
}
function nr(a, e, t) {
var s = t || {}, i = s.atBegin, r = i === void 0 ? !1 : i;
return io(a, e, {
debounceMode: r !== !1
});
}
const B = Number.isFinite || function(a) {
return typeof a == "number" && isFinite(a);
}, ro = Number.isSafeInteger || function(a) {
return typeof a == "number" && Math.abs(a) <= no;
}, no = Number.MAX_SAFE_INTEGER || 9007199254740991;
let W = /* @__PURE__ */ function(a) {
return a.NETWORK_ERROR = "networkError", a.MEDIA_ERROR = "mediaError", a.KEY_SYSTEM_ERROR = "keySystemError", a.MUX_ERROR = "muxError", a.OTHER_ERROR = "otherError", a;
}({}), b = /* @__PURE__ */ function(a) {
return a.KEY_SYSTEM_NO_KEYS = "keySystemNoKeys", a.KEY_SYSTEM_NO_ACCESS = "keySystemNoAccess", a.KEY_SYSTEM_NO_SESSION = "keySystemNoSession", a.KEY_SYSTEM_NO_CONFIGURED_LICENSE = "keySystemNoConfiguredLicense", a.KEY_SYSTEM_LICENSE_REQUEST_FAILED = "keySystemLicenseRequestFailed", a.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED = "keySystemServerCertificateRequestFailed", a.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED = "keySystemServerCertificateUpdateFailed", a.KEY_SYSTEM_SESSION_UPDATE_FAILED = "keySystemSessionUpdateFailed", a.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED = "keySystemStatusOutputRestricted", a.KEY_SYSTEM_STATUS_INTERNAL_ERROR = "keySystemStatusInternalError", a.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR = "keySystemDestroyMediaKeysError", a.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR = "keySystemDestroyCloseSessionError", a.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR = "keySystemDestroyRemoveSessionError", a.MANIFEST_LOAD_ERROR = "manifestLoadError", a.MANIFEST_LOAD_TIMEOUT = "manifestLoadTimeOut", a.MANIFEST_PARSING_ERROR = "manifestParsingError", a.MANIFEST_INCOMPATIBLE_CODECS_ERROR = "manifestIncompatibleCodecsError", a.LEVEL_EMPTY_ERROR = "levelEmptyError", a.LEVEL_LOAD_ERROR = "levelLoadError", a.LEVEL_LOAD_TIMEOUT = "levelLoadTimeOut", a.LEVEL_PARSING_ERROR = "levelParsingError", a.LEVEL_SWITCH_ERROR = "levelSwitchError", a.AUDIO_TRACK_LOAD_ERROR = "audioTrackLoadError", a.AUDIO_TRACK_LOAD_TIMEOUT = "audioTrackLoadTimeOut", a.SUBTITLE_LOAD_ERROR = "subtitleTrackLoadError", a.SUBTITLE_TRACK_LOAD_TIMEOUT = "subtitleTrackLoadTimeOut", a.FRAG_LOAD_ERROR = "fragLoadError", a.FRAG_LOAD_TIMEOUT = "fragLoadTimeOut", a.FRAG_DECRYPT_ERROR = "fragDecryptError", a.FRAG_PARSING_ERROR = "fragParsingError", a.FRAG_GAP = "fragGap", a.REMUX_ALLOC_ERROR = "remuxAllocError", a.KEY_LOAD_ERROR = "keyLoadError", a.KEY_LOAD_TIMEOUT = "keyLoadTimeOut", a.BUFFER_ADD_CODEC_ERROR = "bufferAddCodecError", a.BUFFER_INCOMPATIBLE_CODECS_ERROR = "bufferIncompatibleCodecsError", a.BUFFER_APPEND_ERROR = "bufferAppendError", a.BUFFER_APPENDING_ERROR = "bufferAppendingError", a.BUFFER_STALLED_ERROR = "bufferStalledError", a.BUFFER_FULL_ERROR = "bufferFullError", a.BUFFER_SEEK_OVER_HOLE = "bufferSeekOverHole", a.BUFFER_NUDGE_ON_STALL = "bufferNudgeOnStall", a.ASSET_LIST_LOAD_ERROR = "assetListLoadError", a.ASSET_LIST_LOAD_TIMEOUT = "assetListLoadTimeout", a.ASSET_LIST_PARSING_ERROR = "assetListParsingError", a.INTERSTITIAL_ASSET_ITEM_ERROR = "interstitialAssetItemError", a.INTERNAL_EXCEPTION = "internalException", a.INTERNAL_ABORTED = "aborted", a.ATTACH_MEDIA_ERROR = "attachMediaError", a.UNKNOWN = "unknown", a;
}({}), m = /* @__PURE__ */ function(a) {
return a.MEDIA_ATTACHING = "hlsMediaAttaching", a.MEDIA_ATTACHED = "hlsMediaAttached", a.MEDIA_DETACHING = "hlsMediaDetaching", a.MEDIA_DETACHED = "hlsMediaDetached", a.MEDIA_ENDED = "hlsMediaEnded", a.STALL_RESOLVED = "hlsStallResolved", a.BUFFER_RESET = "hlsBufferReset", a.BUFFER_CODECS = "hlsBufferCodecs", a.BUFFER_CREATED = "hlsBufferCreated", a.BUFFER_APPENDING = "hlsBufferAppending", a.BUFFER_APPENDED = "hlsBufferAppended", a.BUFFER_EOS = "hlsBufferEos", a.BUFFERED_TO_END = "hlsBufferedToEnd", a.BUFFER_FLUSHING = "hlsBufferFlushing", a.BUFFER_FLUSHED = "hlsBufferFlushed", a.MANIFEST_LOADING = "hlsManifestLoading", a.MANIFEST_LOADED = "hlsManifestLoaded", a.MANIFEST_PARSED = "hlsManifestParsed", a.LEVEL_SWITCHING = "hlsLevelSwitching", a.LEVEL_SWITCHED = "hlsLevelSwitched", a.LEVEL_LOADING = "hlsLevelLoading", a.LEVEL_LOADED = "hlsLevelLoaded", a.LEVEL_UPDATED = "hlsLevelUpdated", a.LEVEL_PTS_UPDATED = "hlsLevelPtsUpdated", a.LEVELS_UPDATED = "hlsLevelsUpdated", a.AUDIO_TRACKS_UPDATED = "hlsAudioTracksUpdated", a.AUDIO_TRACK_SWITCHING = "hlsAudioTrackSwitching", a.AUDIO_TRACK_SWITCHED = "hlsAudioTrackSwitched", a.AUDIO_TRACK_LOADING = "hlsAudioTrackLoading", a.AUDIO_TRACK_LOADED = "hlsAudioTrackLoaded", a.AUDIO_TRACK_UPDATED = "hlsAudioTrackUpdated", a.SUBTITLE_TRACKS_UPDATED = "hlsSubtitleTracksUpdated", a.SUBTITLE_TRACKS_CLEARED = "hlsSubtitleTracksCleared", a.SUBTITLE_TRACK_SWITCH = "hlsSubtitleTrackSwitch", a.SUBTITLE_TRACK_LOADING = "hlsSubtitleTrackLoading", a.SUBTITLE_TRACK_LOADED = "hlsSubtitleTrackLoaded", a.SUBTITLE_TRACK_UPDATED = "hlsSubtitleTrackUpdated", a.SUBTITLE_FRAG_PROCESSED = "hlsSubtitleFragProcessed", a.CUES_PARSED = "hlsCuesParsed", a.NON_NATIVE_TEXT_TRACKS_FOUND = "hlsNonNativeTextTracksFound", a.INIT_PTS_FOUND = "hlsInitPtsFound", a.FRAG_LOADING = "hlsFragLoading", a.FRAG_LOAD_EMERGENCY_ABORTED = "hlsFragLoadEmergencyAborted", a.FRAG_LOADED = "hlsFragLoaded", a.FRAG_DECRYPTED = "hlsFragDecrypted", a.FRAG_PARSING_INIT_SEGMENT = "hlsFragParsingInitSegment", a.FRAG_PARSING_USERDATA = "hlsFragParsingUserdata", a.FRAG_PARSING_METADATA = "hlsFragParsingMetadata", a.FRAG_PARSED = "hlsFragParsed", a.FRAG_BUFFERED = "hlsFragBuffered", a.FRAG_CHANGED = "hlsFragChanged", a.FPS_DROP = "hlsFpsDrop", a.FPS_DROP_LEVEL_CAPPING = "hlsFpsDropLevelCapping", a.MAX_AUTO_LEVEL_UPDATED = "hlsMaxAutoLevelUpdated", a.ERROR = "hlsError", a.DESTROYING = "hlsDestroying", a.KEY_LOADING = "hlsKeyLoading", a.KEY_LOADED = "hlsKeyLoaded", a.LIVE_BACK_BUFFER_REACHED = "hlsLiveBackBufferReached", a.BACK_BUFFER_REACHED = "hlsBackBufferReached", a.STEERING_MANIFEST_LOADED = "hlsSteeringManifestLoaded", a.ASSET_LIST_LOADING = "hlsAssetListLoading", a.ASSET_LIST_LOADED = "hlsAssetListLoaded", a.INTERSTITIALS_UPDATED = "hlsInterstitialsUpdated", a.INTERSTITIALS_BUFFERED_TO_BOUNDARY = "hlsInterstitialsBufferedToBoundary", a.INTERSTITIAL_ASSET_PLAYER_CREATED = "hlsInterstitialAssetPlayerCreated", a.INTERSTITIAL_STARTED = "hlsInterstitialStarted", a.INTERSTITIAL_ASSET_STARTED = "hlsInterstitialAssetStarted", a.INTERSTITIAL_ASSET_ENDED = "hlsInterstitialAssetEnded", a.INTERSTITIAL_ASSET_ERROR = "hlsInterstitialAssetError", a.INTERSTITIAL_ENDED = "hlsInterstitialEnded", a.INTERSTITIALS_PRIMARY_RESUMED = "hlsInterstitialsPrimaryResumed", a.PLAYOUT_LIMIT_REACHED = "hlsPlayoutLimitReached", a.EVENT_CUE_ENTER = "hlsEventCueEnter", a;
}({});
var Q = {
MANIFEST: "manifest",
LEVEL: "level",
AUDIO_TRACK: "audioTrack",
SUBTITLE_TRACK: "subtitleTrack"
}, H = {
MAIN: "main",
AUDIO: "audio",
SUBTITLE: "subtitle"
};
class vt {
// About half of the estimated value will be from the last |halfLife| samples by weight.
constructor(e, t = 0, s = 0) {
this.halfLife = void 0, this.alpha_ = void 0, this.estimate_ = void 0, this.totalWeight_ = void 0, this.halfLife = e, this.alpha_ = e ? Math.exp(Math.log(0.5) / e) : 0, this.estimate_ = t, this.totalWeight_ = s;
}
sample(e, t) {
const s = Math.pow(this.alpha_, e);
this.estimate_ = t * (1 - s) + s * this.estimate_, this.totalWeight_ += e;
}
getTotalWeight() {
return this.totalWeight_;
}
getEstimate() {
if (this.alpha_) {
const e = 1 - Math.pow(this.alpha_, this.totalWeight_);
if (e)
return this.estimate_ / e;
}
return this.estimate_;
}
}
class ao {
constructor(e, t, s, i = 100) {
this.defaultEstimate_ = void 0, this.minWeight_ = void 0, this.minDelayMs_ = void 0, this.slow_ = void 0, this.fast_ = void 0, this.defaultTTFB_ = void 0, this.ttfb_ = void 0, this.defaultEstimate_ = s, this.minWeight_ = 1e-3, this.minDelayMs_ = 50, this.slow_ = new vt(e), this.fast_ = new vt(t), this.defaultTTFB_ = i, this.ttfb_ = new vt(e);
}
update(e, t) {
const {
slow_: s,
fast_: i,
ttfb_: r
} = this;
s.halfLife !== e && (this.slow_ = new vt(e, s.getEstimate(), s.getTotalWeight())), i.halfLife !== t && (this.fast_ = new vt(t, i.getEstimate(), i.getTotalWeight())), r.halfLife !== e && (this.ttfb_ = new vt(e, r.getEstimate(), r.getTotalWeight()));
}
sample(e, t) {
e = Math.max(e, this.minDelayMs_);
const s = 8 * t, i = e / 1e3, r = s / i;
this.fast_.sample(i, r), this.slow_.sample(i, r);
}
sampleTTFB(e) {
const t = e / 1e3, s = Math.sqrt(2) * Math.exp(-Math.pow(t, 2) / 2);
this.ttfb_.sample(s, Math.max(e, 5));
}
canEstimate() {
return this.fast_.getTotalWeight() >= this.minWeight_;
}
getEstimate() {
return this.canEstimate() ? Math.min(this.fast_.getEstimate(), this.slow_.getEstimate()) : this.defaultEstimate_;
}
getEstimateTTFB() {
return this.ttfb_.getTotalWeight() >= this.minWeight_ ? this.ttfb_.getEstimate() : this.defaultTTFB_;
}
get defaultEstimate() {
return this.defaultEstimate_;
}
destroy() {
}
}
function oo(a, e, t) {
return (e = co(e)) in a ? Object.defineProperty(a, e, {
value: t,
enumerable: !0,
configurable: !0,
writable: !0
}) : a[e] = t, a;
}
function ne() {
return ne = Object.assign ? Object.assign.bind() : function(a) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var s in t)
({}).hasOwnProperty.call(t, s) && (a[s] = t[s]);
}
return a;
}, ne.apply(null, arguments);
}
function ar(a, e) {
var t = Object.keys(a);
if (Object.getOwnPropertySymbols) {
var s = Object.getOwnPropertySymbols(a);
e && (s = s.filter(function(i) {
return Object.getOwnPropertyDescriptor(a, i).enumerable;
})), t.push.apply(t, s);
}
return t;
}
function se(a) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e] != null ? arguments[e] : {};
e % 2 ? ar(Object(t), !0).forEach(function(s) {
oo(a, s, t[s]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(a, Object.getOwnPropertyDescriptors(t)) : ar(Object(t)).forEach(function(s) {
Object.defineProperty(a, s, Object.getOwnPropertyDescriptor(t, s));
});
}
return a;
}
function lo(a, e) {
if (typeof a != "object" || !a)
return a;
var t = a[Symbol.toPrimitive];
if (t !== void 0) {
var s = t.call(a, e);
if (typeof s != "object")
return s;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (e === "string" ? String : Number)(a);
}
function co(a) {
var e = lo(a, "string");
return typeof e == "symbol" ? e : e + "";
}
class Ze {
constructor(e, t) {
this.trace = void 0, this.debug = void 0, this.log = void 0, this.warn = void 0, this.info = void 0, this.error = void 0;
const s = `[${e}]:`;
this.trace = st, this.debug = t.debug.bind(null, s), this.log = t.log.bind(null, s), this.warn = t.warn.bind(null, s), this.info = t.info.bind(null, s), this.error = t.error.bind(null, s);
}
}
const st = function() {
}, uo = {
trace: st,
debug: st,
log: st,
warn: st,
info: st,
error: st
};
function fi() {
return ne({}, uo);
}
function ho(a, e) {
const t = self.console[a];
return t ? t.bind(self.console, `${e ? "[" + e + "] " : ""}[${a}] >`) : st;
}
function or(a, e, t) {
return e[a] ? e[a].bind(e) : ho(a, t);
}
const gi = fi();
function fo(a, e, t) {
const s = fi();
if (typeof console == "object" && a === !0 || typeof a == "object") {
const i = [
// Remove out from list here to hard-disable a log-level
// 'trace',
"debug",
"log",
"info",
"warn",
"error"
];
i.forEach((r) => {
s[r] = or(r, a, t);
});
try {
s.log(`Debug logs enabled for "${e}" in hls.js version 1.6.5`);
} catch {
return fi();
}
i.forEach((r) => {
gi[r] = or(r, a);
});
} else
ne(gi, s);
return s;
}
const ee = gi;
function nt(a = !0) {
return typeof self > "u" ? void 0 : (a || !self.MediaSource) && self.ManagedMediaSource || self.MediaSource || self.WebKitMediaSource;
}
function go(a) {
return typeof self < "u" && a === self.ManagedMediaSource;
}
function bn(a, e) {
const t = Object.keys(a), s = Object.keys(e), i = t.length, r = s.length;
return !i || !r || i === r && !t.some((n) => s.indexOf(n) === -1);
}
function De(a, e = !1) {
if (typeof TextDecoder < "u") {
const l = new TextDecoder("utf-8").decode(a);
if (e) {
const d = l.indexOf("\0");
return d !== -1 ? l.substring(0, d) : l;
}
return l.replace(/\0/g, "");
}
const t = a.length;
let s, i, r, n = "", o = 0;
for (; o < t; ) {
if (s = a[o++], s === 0 && e)
return n;
if (s === 0 || s === 3)
continue;
switch (s >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
n += String.fromCharCode(s);
break;
case 12:
case 13:
i = a[o++], n += String.fromCharCode((s & 31) << 6 | i & 63);
break;
case 14:
i = a[o++], r = a[o++], n += String.fromCharCode((s & 15) << 12 | (i & 63) << 6 | (r & 63) << 0);
break;
}
}
return n;
}
const $e = {
hexDump: function(a) {
let e = "";
for (let t = 0; t < a.length; t++) {
let s = a[t].toString(16);
s.length < 2 && (s = "0" + s), e += s;
}
return e;
}
};
function mo(a) {
return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a;
}
var $s = { exports: {} }, lr;
function po() {
return lr || (lr = 1, function(a, e) {
(function(t) {
var s = /^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/, i = /^(?=([^\/?#]*))\1([^]*)$/, r = /(?:\/|^)\.(?=\/)/g, n = /(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g, o = {
// If opts.alwaysNormalize is true then the path will always be normalized even when it starts with / or //
// E.g
// With opts.alwaysNormalize = false (default, spec compliant)
// http://a.com/b/cd + /e/f/../g => http://a.com/e/f/../g
// With opts.alwaysNormalize = true (not spec compliant)
// http://a.com/b/cd + /e/f/../g => http://a.com/e/g
buildAbsoluteURL: function(c, l, d) {
if (d = d || {}, c = c.trim(), l = l.trim(), !l) {
if (!d.alwaysNormalize)
return c;
var u = o.parseURL(c);
if (!u)
throw new Error("Error trying to parse base URL.");
return u.path = o.normalizePath(
u.path
), o.buildURLFromParts(u);
}
var h = o.parseURL(l);
if (!h)
throw new Error("Error trying to parse relative URL.");
if (h.scheme)
return d.alwaysNormalize ? (h.path = o.normalizePath(h.path), o.buildURLFromParts(h)) : l;
var g = o.parseURL(c);
if (!g)
throw new Error("Error trying to parse base URL.");
if (!g.netLoc && g.path && g.path[0] !== "/") {
var f = i.exec(g.path);
g.netLoc = f[1], g.path = f[2];
}
g.netLoc && !g.path && (g.path = "/");
var y = {
// 2c) Otherwise, the embedded URL inherits the scheme of
// the base URL.
scheme: g.scheme,
netLoc: h.netLoc,
path: null,
params: h.params,
query: h.query,
fragment: h.fragment
};
if (!h.netLoc && (y.netLoc = g.netLoc, h.path[0] !== "/"))
if (!h.path)
y.path = g.path, h.params || (y.params = g.params, h.query || (y.query = g.query));
else {
var p = g.path, E = p.substring(0, p.lastIndexOf("/") + 1) + h.path;
y.path = o.normalizePath(E);
}
return y.path === null && (y.path = d.alwaysNormalize ? o.normalizePath(h.path) : h.path), o.buildURLFromParts(y);
},
parseURL: function(c) {
var l = s.exec(c);
return l ? {
scheme: l[1] || "",
netLoc: l[2] || "",
path: l[3] || "",
params: l[4] || "",
query: l[5] || "",
fragment: l[6] || ""
} : null;
},
normalizePath: function(c) {
for (c = c.split("").reverse().join("").replace(r, ""); c.length !== (c = c.replace(n, "")).length; )
;
return c.split("").reverse().join("");
},
buildURLFromParts: function(c) {
return c.scheme + c.netLoc + c.path + c.params + c.query + c.fragment;
}
};
a.exports = o;
})();
}($s)), $s.exports;
}
var ki = po();
class wi {
constructor() {
this.aborted = !1, this.loaded = 0, this.retry = 0, this.total = 0, this.chunkCount = 0, this.bwEstimate = 0, this.loading = {
start: 0,
first: 0,
end: 0
}, this.parsing = {
start: 0,
end: 0
}, this.buffering = {
start: 0,
first: 0,
end: 0
};
}
}
var le = {
AUDIO: "audio",
VIDEO: "video",
AUDIOVIDEO: "audiovideo"
};
class _n {
constructor(e) {
this._byteRange = null, this._url = null, this._stats = null, this._streams = null, this.base = void 0, this.relurl = void 0, typeof e == "string" && (e = {
url: e
}), this.base = e, Eo(this, "stats");
}
// setByteRange converts a EXT-X-BYTERANGE attribute into a two element array
setByteRange(e, t) {
const s = e.split("@", 2);
let i;
s.length === 1 ? i = (t == null ? void 0 : t.byteRangeEndOffset) || 0 : i = parseInt(s[1]), this._byteRange = [i, parseInt(s[0]) + i];
}
get baseurl() {
return this.base.url;
}
get byteRange() {
return this._byteRange === null ? [] : this._byteRange;
}
get byteRangeStartOffset() {
return this.byteRange[0];
}
get byteRangeEndOffset() {
return this.byteRange[1];
}
get elementaryStreams() {
return this._streams === null && (this._streams = {
[le.AUDIO]: null,
[le.VIDEO]: null,
[le.AUDIOVIDEO]: null
}), this._streams;
}
set elementaryStreams(e) {
this._streams = e;
}
get hasStats() {
return this._stats !== null;
}
get hasStreams() {
return this._streams !== null;
}
get stats() {
return this._stats === null && (this._stats = new wi()), this._stats;
}
set stats(e) {
this._stats = e;
}
get url() {
return !this._url && this.baseurl && this.relurl && (this._url = ki.buildAbsoluteURL(this.baseurl, this.relurl, {
alwaysNormalize: !0
})), this._url || "";
}
set url(e) {
this._url = e;
}
clearElementaryStreamInfo() {
const {
elementaryStreams: e
} = this;
e[le.AUDIO] = null, e[le.VIDEO] = null, e[le.AUDIOVIDEO] = null;
}
}
function pe(a) {
return a.sn !== "initSegment";
}
class Gs extends _n {
constructor(e, t) {
super(t), this._decryptdata = null, this._programDateTime = null, this._ref = null, this._bitrate = void 0, this.rawProgramDateTime = null, this.tagList = [], this.duration = 0, this.sn = 0, this.levelkeys = void 0, this.type = void 0, this.loader = null, this.keyLoader = null, this.level = -1, this.cc = 0, this.startPTS = void 0, this.endPTS = void 0, this.startDTS = void 0, this.endDTS = void 0, this.start = 0, this.playlistOffset = 0, this.deltaPTS = void 0, this.maxStartPTS = void 0, this.minEndPTS = void 0, this.data = void 0, this.bitrateTest = !1, this.title = null, this.initSegment = null, this.endList = void 0, this.gap = void 0, this.urlId = 0, this.type = e;
}
get byteLength() {
if (this.hasStats) {
const e = this.stats.total;
if (e)
return e;
}
if (this.byteRange) {
const e = this.byteRange[0], t = this.byteRange[1];
if (B(e) && B(t))
return t - e;
}
return null;
}
get bitrate() {
return this.byteLength ? this.byteLength * 8 / this.duration : this._bitrate ? this._bitrate : null;
}
set bitrate(e) {
this._bitrate = e;
}
get decryptdata() {
const {
levelkeys: e
} = this;
if (!e && !this._decryptdata)
return null;
if (!this._decryptdata && this.levelkeys && !this.levelkeys.NONE) {
const t = this.levelkeys.identity;
if (t)
this._decryptdata = t.getDecryptData(this.sn);
else {
const s = Object.keys(this.levelkeys);
if (s.length === 1)
return this._decryptdata = this.levelkeys[s[0]].getDecryptData(this.sn);
}
}
return this._decryptdata;
}
get end() {
return this.start + this.duration;
}
get endProgramDateTime() {
if (this.programDateTime === null)
return null;
const e = B(this.duration) ? this.duration : 0;
return this.programDateTime + e * 1e3;
}
get encrypted() {
var e;
if ((e = this._decryptdata) != null && e.encrypted)
return !0;
if (this.levelkeys) {
const t = Object.keys(this.levelkeys), s = t.length;
if (s > 1 || s === 1 && this.levelkeys[t[0]].encrypted)
return !0;
}
return !1;
}
get programDateTime() {
return this._programDateTime === null && this.rawProgramDateTime && (this.programDateTime = Date.parse(this.rawProgramDateTime)), this._programDateTime;
}
set programDateTime(e) {
if (!B(e)) {
this._programDateTime = this.rawProgramDateTime = null;
return;
}
this._programDateTime = e;
}
get ref() {
return pe(this) ? (this._ref || (this._ref = {
base: this.base,
start: this.start,
duration: this.duration,
sn: this.sn,
programDateTime: this.programDateTime
}), this._ref) : null;
}
addStart(e) {
this.setStart(this.start + e);
}
setStart(e) {
this.start = e, this._ref && (this._ref.start = e);
}
setDuration(e) {
this.duration = e, this._ref && (this._ref.duration = e);
}
setKeyFormat(e) {
if (this.levelkeys) {
const t = this.levelkeys[e];
t && !this._decryptdata && (this._decryptdata = t.getDecryptData(this.sn));
}
}
abortRequests() {
var e, t;
(e = this.loader) == null || e.abort(), (t = this.keyLoader) == null || t.abort();
}
setElementaryStreamInfo(e, t, s, i, r, n = !1) {
const {
elementaryStreams: o
} = this, c = o[e];
if (!c) {
o[e] = {
startPTS: t,
endPTS: s,
startDTS: i,
endDTS: r,
partial: n
};
return;
}
c.startPTS = Math.min(c.startPTS, t), c.endPTS = Math.max(c.endPTS, s), c.startDTS = Math.min(c.startDTS, i), c.endDTS = Math.max(c.endDTS, r);
}
}
class yo extends _n {
constructor(e, t, s, i, r) {
super(s), this.fragOffset = 0, this.duration = 0, this.gap = !1, this.independent = !1, this.relurl = void 0, this.fragment = void 0, this.index = void 0, this.duration = e.decimalFloatingPoint("DURATION"), this.gap = e.bool("GAP"), this.independent = e.bool("INDEPENDENT"), this.relurl = e.enumeratedString("URI"), this.fragment = t, this.index = i;
const n = e.enumeratedString("BYTERANGE");
n && this.setByteRange(n, r), r && (this.fragOffset = r.fragOffset + r.duration);
}
get start() {
return this.fragment.start + this.fragOffset;
}
get end() {
return this.start + this.duration;
}
get loaded() {
const {
elementaryStreams: e
} = this;
return !!(e.audio || e.video || e.audiovideo);
}
}
function Dn(a, e) {
const t = Object.getPrototypeOf(a);
if (t) {
const s = Object.getOwnPropertyDescriptor(t, e);
return s || Dn(t, e);
}
}
function Eo(a, e) {
const t = Dn(a, e);
t && (t.enumerable = !0, Object.defineProperty(a, e, t));
}
const Is = Math.pow(2, 32) - 1, To = [].push, Cn = {
video: 1,
audio: 2,
id3: 3,
text: 4
};
function he(a) {
return String.fromCharCode.apply(null, a);
}
function Pn(a, e) {
const t = a[e] << 8 | a[e + 1];
return t < 0 ? 65536 + t : t;
}
function q(a, e) {
const t = kn(a, e);
return t < 0 ? 4294967296 + t : t;
}
function cr(a, e) {
let t = q(a, e);
return t *= Math.pow(2, 32), t += q(a, e + 4), t;
}
function kn(a, e) {
return a[e] << 24 | a[e + 1] << 16 | a[e + 2] << 8 | a[e + 3];
}
function Vs(a, e, t) {
a[e] = t >> 24, a[e + 1] = t >> 16 & 255, a[e + 2] = t >> 8 & 255, a[e + 3] = t & 255;
}
function vo(a) {
const e = a.byteLength;
for (let t = 0; t < e; ) {
const s = q(a, t);
if (s > 8 && a[t + 4] === 109 && a[t + 5] === 111 && a[t + 6] === 111 && a[t + 7] === 102)
return !0;
t = s > 1 ? t + s : e;
}
return !1;
}
function X(a, e) {
const t = [];
if (!e.length)
return t;
const s = a.byteLength;
for (let i = 0; i < s; ) {
const r = q(a, i), n = he(a.subarray(i + 4, i + 8)), o = r > 1 ? i + r : s;
if (n === e[0])
if (e.length === 1)
t.push(a.subarray(i + 8, o));
else {
const c = X(a.subarray(i + 8, o), e.slice(1));
c.length && To.apply(t, c);
}
i = o;
}
return t;
}
function So(a) {
const e = [], t = a[0];
let s = 8;
const i = q(a, s);
s += 4;
let r = 0, n = 0;
t === 0 ? (r = q(a, s), n = q(a, s + 4), s += 8) : (r = cr(a, s), n = cr(a, s + 8), s += 16), s += 2;
let o = a.length + n;
const c = Pn(a, s);
s += 2;
for (let l = 0; l < c; l++) {
let d = s;
const u = q(a, d);
d += 4;
const h = u & 2147483647;
if ((u & 2147483648) >>> 31 === 1)
return ee.warn("SIDX has hierarchical references (not supported)"), null;
const f = q(a, d);
d += 4, e.push({
referenceSize: h,
subsegmentDuration: f,
// unscaled
info: {
duration: f / i,
start: o,
end: o + h - 1
}
}), o += h, d += 4, s = d;
}
return {
earliestPresentationTime: r,
timescale: i,
version: t,
referencesCount: c,
references: e
};
}
function wn(a) {
const e = [], t = X(a, ["moov", "trak"]);
for (let i = 0; i < t.length; i++) {
const r = t[i], n = X(r, ["tkhd"])[0];
if (n) {
let o = n[0];
const c = q(n, o === 0 ? 12 : 20), l = X(r, ["mdia", "mdhd"])[0];
if (l) {
o = l[0];
const d = q(l, o === 0 ? 12 : 20), u = X(r, ["mdia", "hdlr"])[0];
if (u) {
const h = he(u.subarray(8, 12)), g = {
soun: le.AUDIO,
vide: le.VIDEO
}[h], f = X(r, ["mdia", "minf", "stbl", "stsd"])[0], y = xo(f);
g ? (e[c] = {
timescale: d,
type: g,
stsd: y
}, e[g] = se({
timescale: d,
id: c
}, y)) : e[c] = {
timescale: d,
type: h,
stsd: y
};
}
}
}
}
return X(a, ["moov", "mvex", "trex"]).forEach((i) => {
const r = q(i, 4), n = e[r];
n && (n.default = {
duration: q(i, 12),
flags: q(i, 20)
});
}), e;
}
function xo(a) {
const e = a.subarray(8), t = e.subarray(8 + 78), s = he(e.subarray(4, 8));
let i = s, r;
const n = s === "enca" || s === "encv";
if (n) {
const l = X(e, [s])[0].subarray(s === "enca" ? 28 : 78);
X(l, ["sinf"]).forEach((u) => {
const h = X(u, ["schm"])[0];
if (h) {
const g = he(h.subarray(4, 8));
if (g === "cbcs" || g === "cenc") {
const f = X(u, ["frma"])[0];
f && (i = he(f));
}
}
});
}
const o = i;
switch (i) {
case "avc1":
case "avc2":
case "avc3":
case "avc4": {
const c = X(t, ["avcC"])[0];
c && c.length > 3 && (i += "." + es(c[1]) + es(c[2]) + es(c[3]), r = Jt(o === "avc1" ? "dva1" : "dvav", t));
break;
}
case "mp4a": {
const c = X(e, [s])[0], l = X(c.subarray(28), ["esds"])[0];
if (l && l.length > 7) {
let d = 4;
if (l[d++] !== 3)
break;
d = Ks(l, d), d += 2;
const u = l[d++];
if (u & 128 && (d += 2), u & 64 && (d += l[d++]), l[d++] !== 4)
break;
d = Ks(l, d);
const h = l[d++];
if (h === 64)
i += "." + es(h);
else
break;
if (d += 12, l[d++] !== 5)
break;
d = Ks(l, d);
const g = l[d++];
let f = (g & 248) >> 3;
f === 31 && (f += 1 + ((g & 7) << 3) + ((l[d] & 224) >> 5)), i += "." + f;
}
break;
}
case "hvc1":
case "hev1": {
const c = X(t, ["hvcC"])[0];
if (c && c.length > 12) {
const l = c[1], d = ["", "A", "B", "C"][l >> 6], u = l & 31, h = q(c, 2), g = (l & 32) >> 5 ? "H" : "L", f = c[12], y = c.subarray(6, 12);
i += "." + d + u, i += "." + Ao(h).toString(16).toUpperCase(), i += "." + g + f;
let p = "";
for (let E = y.length; E--; ) {
const v = y[E];
(v || p) && (p = "." + v.toString(16).toUpperCase() + p);
}
i += p;
}
r = Jt(o == "hev1" ? "dvhe" : "dvh1", t);
break;
}
case "dvh1":
case "dvhe":
case "dvav":
case "dva1":
case "dav1": {
i = Jt(i, t) || i;
break;
}
case "vp09": {
const c = X(t, ["vpcC"])[0];
if (c && c.length > 6) {
const l = c[4], d = c[5], u = c[6] >> 4 & 15;
i += "." + Ue(l) + "." + Ue(d) + "." + Ue(u);
}
break;
}
case "av01": {
const c = X(t, ["av1C"])[0];
if (c && c.length > 2) {
const l = c[1] >>> 5, d = c[1] & 31, u = c[2] >>> 7 ? "H" : "M", h = (c[2] & 64) >> 6, g = (c[2] & 32) >> 5, f = l === 2 && h ? g ? 12 : 10 : h ? 10 : 8, y = (c[2] & 16) >> 4, p = (c[2] & 8) >> 3, E = (c[2] & 4) >> 2, v = c[2] & 3, T = 1, S = 1, x = 1, _ = 0;
i += "." + l + "." + Ue(d) + u + "." + Ue(f) + "." + y + "." + p + E + v + "." + Ue(T) + "." + Ue(S) + "." + Ue(x) + "." + _, r = Jt("dav1", t);
}
break;
}
}
return {
codec: i,
encrypted: n,
supplemental: r
};
}
function Jt(a, e) {
const t = X(e, ["dvvC"]), s = t.length ? t[0] : X(e, ["dvcC"])[0];
if (s) {
const i = s[2] >> 1 & 127, r = s[2] << 5 & 32 | s[3] >> 3 & 31;
return a + "." + Ue(i) + "." + Ue(r);
}
}
function Ao(a) {
let e = 0;
for (let t = 0; t < 32; t++)
e |= (a >> t & 1) << 32 - 1 - t;
return e >>> 0;
}
function Ks(a, e) {
const t = e + 5;
for (; a[e++] & 128 && e < t; )
;
return e;
}
function es(a) {
return ("0" + a.toString(16).toUpperCase()).slice(-2);
}
function Ue(a) {
return (a < 10 ? "0" : "") + a;
}
function Lo(a, e) {
if (!a || !e)
return a;
const t = e.keyId;
return t && e.isCommonEncryption && X(a, ["moov", "trak"]).forEach((i) => {
const n = X(i, ["mdia", "minf", "stbl", "stsd"])[0].subarray(8);
let o = X(n, ["enca"]);
const c = o.length > 0;
c || (o = X(n, ["encv"])), o.forEach((l) => {
const d = c ? l.subarray(28) : l.subarray(78);
X(d, ["sinf"]).forEach((h) => {
const g = On(h);
if (g) {
const f = g.subarray(8, 24);
f.some((y) => y !== 0) || (ee.log(`[eme] Patching keyId in 'enc${c ? "a" : "v"}>sinf>>tenc' box: ${$e.hexDump(f)} -> ${$e.hexDump(t)}`), g.set(t, 8));
}
});
});
}), a;
}
function On(a) {
const e = X(a, ["schm"])[0];
if (e) {
const t = he(e.subarray(4, 8));
if (t === "cbcs" || t === "cenc")
return X(a, ["schi", "tenc"])[0];
}
return null;
}
function Io(a, e, t) {
const s = {}, i = X(a, ["moof", "traf"]);
for (let r = 0; r < i.length; r++) {
const n = i[r], o = X(n, ["tfhd"])[0], c = q(o, 4), l = e[c];
if (!l)
continue;
const d = s[c] || (s[c] = {
start: NaN,
duration: 0,
sampleCount: 0,
timescale: l.timescale,
type: l.type
}), u = X(n, ["tfdt"])[0];
if (u) {
const T = u[0];
let S = q(u, 4);
T === 1 && (S === Is ? t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time") : (S *= Is + 1, S += q(u, 8))), B(S) && (!B(d.start) || S < d.start) && (d.start = S);
}
const h = l.default, g = q(o, 0) | (h == null ? void 0 : h.flags);
let f = (h == null ? void 0 : h.duration) || 0;
g & 8 && (g & 2 ? f = q(o, 12) : f = q(o, 8));
const y = X(n, ["trun"]);
let p = d.start || 0, E = 0, v = f;
for (let T = 0; T < y.length; T++) {
const S = y[T], x = q(S, 4), _ = d.sampleCount;
d.sampleCount += x;
const A = S[3] & 1, R = S[3] & 4, D = S[2] & 1, L = S[2] & 2, w = S[2] & 4, N = S[2] & 8;
let Y = 8, $ = x;
for (A && (Y += 4), R && x && (!(S[Y + 1] & 1) && d.keyFrameIndex === void 0 && (d.keyFrameIndex = _), Y += 4, D ? (v = q(S, Y), Y += 4) : v = f, L && (Y += 4), N && (Y += 4), p += v, E += v, $--); $--; )
D ? (v = q(S, Y), Y += 4) : v = f, L && (Y += 4), w && (S[Y + 1] & 1 || d.keyFrameIndex === void 0 && (d.keyFrameIndex = d.sampleCount - ($ + 1), d.keyFrameStart = p), Y += 4), N && (Y += 4), p += v, E += v;
!E && f && (E += f * x);
}
d.duration += E;
}
if (!Object.keys(s).some((r) => s[r].duration)) {
let r = 1 / 0, n = 0;
const o = X(a, ["sidx"]);
for (let c = 0; c < o.length; c++) {
const l = So(o[c]);
if (l != null && l.references) {
r = Math.min(r, l.earliestPresentationTime / l.timescale);
const d = l.references.reduce((u, h) => u + h.info.duration || 0, 0);
n = Math.max(n, d + l.earliestPresentationTime / l.timescale);
}
}
n && B(n) && Object.keys(s).forEach((c) => {
s[c].duration || (s[c].duration = n * s[c].timescale - s[c].start);
});
}
return s;
}
function Ro(a, e, t) {
X(e, ["moof", "traf"]).forEach((s) => {
X(s, ["tfhd"]).forEach((i) => {
const r = q(i, 4), n = a[r];
if (!n)
return;
const o = n.timescale || 9e4;
X(s, ["tfdt"]).forEach((c) => {
const l = c[0], d = t * o;
if (d) {
let u = q(c, 4);
if (l === 0)
u -= d, u = Math.max(u, 0), Vs(c, 4, u);
else {
u *= Math.pow(2, 32), u += q(c, 8), u -= d, u = Math.max(u, 0);
const h = Math.floor(u / (Is + 1)), g = Math.floor(u % (Is + 1));
Vs(c, 4, h), Vs(c, 8, g);
}
}
});
});
});
}
function bo(a) {
const e = {
valid: null,
remainder: null
}, t = X(a, ["moof"]);
if (t.length < 2)
return e.remainder = a, e;
const s = t[t.length - 1];
return e.valid = a.slice(0, s.byteOffset - 8), e.remainder = a.slice(s.byteOffset - 8), e;
}
function Oe(a, e) {
const t = new Uint8Array(a.length + e.length);
return t.set(a), t.set(e, a.length), t;
}
function dr(a, e) {
const t = [], s = e.samples, i = e.timescale, r = e.id;
let n = !1;
return X(s, ["moof"]).map((c) => {
const l = c.byteOffset - 8;
X(c, ["traf"]).map((u) => {
const h = X(u, ["tfdt"]).map((g) => {
const f = g[0];
let y = q(g, 4);
return f === 1 && (y *= Math.pow(2, 32), y += q(g, 8)), y / i;
})[0];
return h !== void 0 && (a = h), X(u, ["tfhd"]).map((g) => {
const f = q(g, 4), y = q(g, 0) & 16777215, p = (y & 1) !== 0, E = (y & 2) !== 0, v = (y & 8) !== 0;
let T = 0;
const S = (y & 16) !== 0;
let x = 0;
const _ = (y & 32) !== 0;
let A = 8;
f === r && (p && (A += 8), E && (A += 4), v && (T = q(g, A), A += 4), S && (x = q(g, A), A += 4), _ && (A += 4), e.type === "video" && (n = Ms(e.codec)), X(u, ["trun"]).map((R) => {
const D = R[0], L = q(R, 0) & 16777215, w = (L & 1) !== 0;
let N = 0;
const Y = (L & 4) !== 0, $ = (L & 256) !== 0;
let G = 0;
const F = (L & 512) !== 0;
let V = 0;
const K = (L & 1024) !== 0, O = (L & 2048) !== 0;
let C = 0;
const k = q(R, 4);
let M = 8;
w && (N = q(R, M), M += 4), Y && (M += 4);
let j = N + l;
for (let Z = 0; Z < k; Z++) {
if ($ ? (G = q(R, M), M += 4) : G = T, F ? (V = q(R, M), M += 4) : V = x, K && (M += 4), O && (D === 0 ? C = q(R, M) : C = kn(R, M), M += 4), e.type === le.VIDEO) {
let te = 0;
for (; te < V; ) {
const oe = q(s, j);
if (j += 4, _o(n, s[j])) {
const Te = s.subarray(j, j + oe);
Oi(Te, n ? 2 : 1, a + C / i, t);
}
j += oe, te += oe + 4;
}
}
a += G / i;
}
}));
});
});
}), t;
}
function Ms(a) {
if (!a)
return !1;
const e = a.substring(0, 4);
return e === "hvc1" || e === "hev1" || // Dolby Vision
e === "dvh1" || e === "dvhe";
}
function _o(a, e) {
if (a) {
const t = e >> 1 & 63;
return t === 39 || t === 40;
} else
return (e & 31) === 6;
}
function Oi(a, e, t, s) {
const i = Fn(a);
let r = 0;
r += e;
let n = 0, o = 0, c = 0;
for (; r < i.length; ) {
n = 0;
do {
if (r >= i.length)
break;
c = i[r++], n += c;
} while (c === 255);
o = 0;
do {
if (r >= i.length)
break;
c = i[r++], o += c;
} while (c === 255);
const l = i.length - r;
let d = r;
if (o < l)
r += o;
else if (o > l) {
ee.error(`Malformed SEI payload. ${o} is too small, only ${l} bytes left to parse.`);
break;
}
if (n === 4) {
if (i[d++] === 181) {
const h = Pn(i, d);
if (d += 2, h === 49) {
const g = q(i, d);
if (d += 4, g === 1195456820) {
const f = i[d++];
if (f === 3) {
const y = i[d++], p = 31 & y, E = 64 & y, v = E ? 2 + p * 3 : 0, T = new Uint8Array(v);
if (E) {
T[0] = y;
for (let S = 1; S < v; S++)
T[S] = i[d++];
}
s.push({
type: f,
payloadType: n,
pts: t,
bytes: T
});
}
}
}
}
} else if (n === 5 && o > 16) {
const u = [];
for (let f = 0; f < 16; f++) {
const y = i[d++].toString(16);
u.push(y.length == 1 ? "0" + y : y), (f === 3 || f === 5 || f === 7 || f === 9) && u.push("-");
}
const h = o - 16, g = new Uint8Array(h);
for (let f = 0; f < h; f++)
g[f] = i[d++];
s.push({
payloadType: n,
pts: t,
uuid: u.join(""),
userData: De(g),
userDataBytes: g
});
}
}
}
function Fn(a) {
const e = a.byteLength, t = [];
let s = 1;
for (; s < e - 2; )
a[s] === 0 && a[s + 1] === 0 && a[s + 2] === 3 ? (t.push(s + 2), s += 2) : s++;
if (t.length === 0)
return a;
const i = e - t.length, r = new Uint8Array(i);
let n = 0;
for (s = 0; s < i; n++, s++)
n === t[0] && (n++, t.shift()), r[s] = a[n];
return r;
}
function Do(a) {
const e = a[0];
let t = "", s = "", i = 0, r = 0, n = 0, o = 0, c = 0, l = 0;
if (e === 0) {
for (; he(a.subarray(l, l + 1)) !== "\0"; )
t += he(a.subarray(l, l + 1)), l += 1;
for (t += he(a.subarray(l, l + 1)), l += 1; he(a.subarray(l, l + 1)) !== "\0"; )
s += he(a.subarray(l, l + 1)), l += 1;
s += he(a.subarray(l, l + 1)), l += 1, i = q(a, 12), r = q(a, 16), o = q(a, 20), c = q(a, 24), l = 28;
} else if (e === 1) {
l += 4, i = q(a, l), l += 4;
const u = q(a, l);
l += 4;
const h = q(a, l);
for (l += 4, n = 2 ** 32 * u + h, ro(n) || (n = Number.MAX_SAFE_INTEGER, ee.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")), o = q(a, l), l += 4, c = q(a, l), l += 4; he(a.subarray(l, l + 1)) !== "\0"; )
t += he(a.subarray(l, l + 1)), l += 1;
for (t += he(a.subarray(l, l + 1)), l += 1; he(a.subarray(l, l + 1)) !== "\0"; )
s += he(a.subarray(l, l + 1)), l += 1;
s += he(a.subarray(l, l + 1)), l += 1;
}
const d = a.subarray(l, a.byteLength);
return {
schemeIdUri: t,
value: s,
timeScale: i,
presentationTime: n,
presentationTimeDelta: r,
eventDuration: o,
id: c,
payload: d
};
}
function Co(a, ...e) {
const t = e.length;
let s = 8, i = t;
for (; i--; )
s += e[i].byteLength;
const r = new Uint8Array(s);
for (r[0] = s >> 24 & 255, r[1] = s >> 16 & 255, r[2] = s >> 8 & 255, r[3] = s & 255, r.set(a, 4), i = 0, s = 8; i < t; i++)
r.set(e[i], s), s += e[i].byteLength;
return r;
}
function Po(a, e, t) {
if (a.byteLength !== 16)
throw new RangeError("Invalid system id");
let s, i;
s = 0, i = new Uint8Array();
let r;
s > 0 ? (r = new Uint8Array(4), e.length > 0 && new DataView(r.buffer).setUint32(0, e.length, !1)) : r = new Uint8Array();
const n = new Uint8Array(4);
return t && t.byteLength > 0 && new DataView(n.buffer).setUint32(0, t.byteLength, !1), Co(
[112, 115, 115, 104],
new Uint8Array([
s,
0,
0,
0
// Flags
]),
a,
// 16 bytes
r,
i,
n,
t || new Uint8Array()
);
}
function ko(a) {
const e = [];
if (a instanceof ArrayBuffer) {
const t = a.byteLength;
let s = 0;
for (; s + 32 < t; ) {
const i = new DataView(a, s), r = wo(i);
e.push(r), s += r.size;
}
}
return e;
}
function wo(a) {
const e = a.getUint32(0), t = a.byteOffset, s = a.byteLength;
if (s < e)
return {
offset: t,
size: s
};
if (a.getUint32(4) !== 1886614376)
return {
offset: t,
size: e
};
const r = a.getUint32(8) >>> 24;
if (r !== 0 && r !== 1)
return {
offset: t,
size: e
};
const n = a.buffer, o = $e.hexDump(new Uint8Array(n, t + 12, 16)), c = a.getUint32(28);
let l = null, d = null;
if (r === 0) {
if (e - 32 < c || c < 22)
return {
offset: t,
size: e
};
d = new Uint8Array(n, t + 32, c);
} else if (r === 1) {
if (!c || s < t + 32 + c * 16 + 16)
return {
offset: t,
size: e
};
l = [];
for (let u = 0; u < c; u++)
l.push(new Uint8Array(n, t + 32 + u * 16, 16));
}
return {
version: r,
systemId: o,
kids: l,
data: d,
offset: t,
size: e
};
}
const Mn = () => /\(Windows.+Firefox\//i.test(navigator.userAgent), Dt = {
audio: {
a3ds: 1,
"ac-3": 0.95,
"ac-4": 1,
alac: 0.9,
alaw: 1,
dra1: 1,
"dts+": 1,
"dts-": 1,
dtsc: 1,
dtse: 1,
dtsh: 1,
"ec-3": 0.9,
enca: 1,
fLaC: 0.9,
// MP4-RA listed codec entry for FLAC
flac: 0.9,
// legacy browser codec name for FLAC
FLAC: 0.9,
// some manifests may list "FLAC" with Apple's tools
g719: 1,
g726: 1,
m4ae: 1,
mha1: 1,
mha2: 1,
mhm1: 1,
mhm2: 1,
mlpa: 1,
mp4a: 1,
"raw ": 1,
Opus: 1,
opus: 1,
// browsers expect this to be lowercase despite MP4RA says 'Opus'
samr: 1,
sawb: 1,
sawp: 1,
sevc: 1,
sqcp: 1,
ssmv: 1,
twos: 1,
ulaw: 1
},
video: {
avc1: 1,
avc2: 1,
avc3: 1,
avc4: 1,
avcp: 1,
av01: 0.8,
dav1: 0.8,
drac: 1,
dva1: 1,
dvav: 1,
dvh1: 0.7,
dvhe: 0.7,
encv: 1,
hev1: 0.75,
hvc1: 0.75,
mjp2: 1,
mp4v: 1,
mvc1: 1,
mvc2: 1,
mvc3: 1,
mvc4: 1,
resv: 1,
rv60: 1,
s263: 1,
svc1: 1,
svc2: 1,
"vc-1": 1,
vp08: 1,
vp09: 0.9
},
text: {
stpp: 1,
wvtt: 1
}
};
function Nn(a, e) {
const t = Dt[e];
return !!t && !!t[a.slice(0, 4)];
}
function mi(a, e, t = !0) {
return !a.split(",").some((s) => !Bn(s, e, t));
}
function Bn(a, e, t = !0) {
var s;
const i = nt(t);
return (s = i == null ? void 0 : i.isTypeSupported(Kt(a, e))) != null ? s : !1;
}
function Kt(a, e) {
return `${e}/mp4;codecs=${a}`;
}
function ur(a) {
if (a) {
const e = a.substring(0, 4);
return Dt.video[e];
}
return 2;
}
function Rs(a) {
const e = Mn();
return a.split(",").reduce((t, s) => {
const r = e && Ms(s) ? 9 : Dt.video[s];
return r ? (r * 2 + t) / (t ? 3 : 2) : (Dt.audio[s] + t) / (t ? 2 : 1);
}, 0);
}
const Hs = {};
function Oo(a, e = !0) {
if (Hs[a])
return Hs[a];
const t = {
// Idealy fLaC and Opus would be first (spec-compliant) but
// some browsers will report that fLaC is supported then fail.
// see: https://bugs.chromium.org/p/chromium/issues/detail?id=1422728
flac: ["flac", "fLaC", "FLAC"],
opus: ["opus", "Opus"],
// Replace audio codec info if browser does not support mp4a.40.34,
// and demuxer can fallback to 'audio/mpeg' or 'audio/mp4;codecs="mp3"'
"mp4a.40.34": ["mp3"]
}[a];
for (let i = 0; i < t.length; i++) {
var s;
if (Bn(t[i], "audio", e))
return Hs[a] = t[i], t[i];
if (t[i] === "mp3" && (s = nt(e)) != null && s.isTypeSupported("audio/mpeg"))
return "";
}
return a;
}
const Fo = /flac|opus|mp4a\.40\.34/i;
function bs(a, e = !0) {
return a.replace(Fo, (t) => Oo(t.toLowerCase(), e));
}
function Mo(a, e) {
const t = [];
if (a) {
const s = a.split(",");
for (let i = 0; i < s.length; i++)
Nn(s[i], "video") || t.push(s[i]);
}
return e && t.push(e), t.join(",");
}
function gs(a, e) {
if (a && (a.length > 4 || ["ac-3", "ec-3", "alac", "fLaC", "Opus"].indexOf(a) !== -1))
return a;
if (e) {
const t = e.split(",");
if (t.length > 1) {
if (a) {
for (let s = t.length; s--; )
if (t[s].substring(0, 4) === a.substring(0, 4))
return t[s];
}
return t[0];
}
}
return e || a;
}
function No(a) {
const e = a.split(",");
for (let t = 0; t < e.length; t++) {
const s = e[t].split(".");
s.length > 2 && s[0] === "avc1" && (e[t] = `avc1.${parseInt(s[1]).toString(16)}${("000" + parseInt(s[2]).toString(16)).slice(-4)}`);
}
return e.join(",");
}
function Bo(a) {
if (a.startsWith("av01.")) {
const e = a.split("."), t = ["0", "111", "01", "01", "01", "0"];
for (let s = e.length; s > 4 && s < 10; s++)
e[s] = t[s - 4];
return e.join(".");
}
return a;
}
function hr(a) {
const e = nt(a) || {
isTypeSupported: () => !1
};
return {
mpeg: e.isTypeSupported("audio/mpeg"),
mp3: e.isTypeSupported('audio/mp4; codecs="mp3"'),
ac3: e.isTypeSupported('audio/mp4; codecs="ac-3"')
};
}
function Un(a) {
return a.replace(/^.+codecs=["']?([^"']+).*$/, "$1");
}
const $n = {
supported: !0,
configurations: [],
decodingInfoResults: [{
supported: !0,
powerEfficient: !0,
smooth: !0
}]
};
function Gn(a, e) {
return {
supported: !1,
configurations: e,
decodingInfoResults: [{
supported: !1,
smooth: !1,
powerEfficient: !1
}],
error: a
};
}
const fr = {};
function Uo(a, e, t, s, i, r) {
const n = a.audioCodec ? a.audioGroups : null, o = r == null ? void 0 : r.audioCodec, c = r == null ? void 0 : r.channels, l = c ? parseInt(c) : o ? 1 / 0 : 2;
let d = null;
if (n != null && n.length)
try {
n.length === 1 && n[0] ? d = e.groups[n[0]].channels : d = n.reduce((u, h) => {
if (h) {
const g = e.groups[h];
if (!g)
throw new Error(`Audio track group ${h} not found`);
Object.keys(g.channels).forEach((f) => {
u[f] = (u[f] || 0) + g.channels[f];
});
}
return u;
}, {
2: 0
});
} catch {
return !0;
}
return a.videoCodec !== void 0 && (a.width > 1920 && a.height > 1088 || a.height > 1920 && a.width > 1088 || a.frameRate > Math.max(s, 30) || a.videoRange !== "SDR" && a.videoRange !== t || a.bitrate > Math.max(i, 8e6)) || !!d && B(l) && Object.keys(d).some((u) => parseInt(u) > l);
}
function Vn(a, e, t) {
const s = a.videoCodec, i = a.audioCodec;
if (!s && !i || !t)
return Promise.resolve($n);
const r = [];
if (s) {
const n = {
width: a.width,
height: a.height,
bitrate: Math.ceil(Math.max(a.bitrate * 0.9, a.averageBitrate)),
// Assume a framerate of 30fps since MediaCapabilities will not accept Level default of 0.
framerate: a.frameRate || 30
}, o = a.videoRange;
o !== "SDR" && (n.transferFunction = o.toLowerCase());
const c = s.split(","), l = navigator.userAgent;
if (c.some((d) => Ms(d)) && Mn())
return Promise.resolve(Gn(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result base