UNPKG

@asicupv/paella-video-plugins

Version:
1,529 lines 734 kB
const M = Number.isFinite || function(a) { return typeof a == "number" && isFinite(a); }, ga = Number.isSafeInteger || function(a) { return typeof a == "number" && Math.abs(a) <= ma; }, ma = Number.MAX_SAFE_INTEGER || 9007199254740991; let G = /* @__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; }({}), R = /* @__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 z = { MANIFEST: "manifest", LEVEL: "level", AUDIO_TRACK: "audioTrack", SUBTITLE_TRACK: "subtitleTrack" }, $ = { MAIN: "main", AUDIO: "audio", SUBTITLE: "subtitle" }; class rt { // 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 pa { 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 rt(e), this.fast_ = new rt(t), this.defaultTTFB_ = i, this.ttfb_ = new rt(e); } update(e, t) { const { slow_: s, fast_: i, ttfb_: r } = this; s.halfLife !== e && (this.slow_ = new rt(e, s.getEstimate(), s.getTotalWeight())), i.halfLife !== t && (this.fast_ = new rt(t, i.getEstimate(), i.getTotalWeight())), r.halfLife !== e && (this.ttfb_ = new rt(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 Ea(a, e, t) { return (e = Ta(e)) in a ? Object.defineProperty(a, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : a[e] = t, a; } function ie() { return ie = 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; }, ie.apply(null, arguments); } function Ci(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 re(a) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e] != null ? arguments[e] : {}; e % 2 ? Ci(Object(t), !0).forEach(function(s) { Ea(a, s, t[s]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(a, Object.getOwnPropertyDescriptors(t)) : Ci(Object(t)).forEach(function(s) { Object.defineProperty(a, s, Object.getOwnPropertyDescriptor(t, s)); }); } return a; } function ya(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 Ta(a) { var e = ya(a, "string"); return typeof e == "symbol" ? e : e + ""; } class Pe { 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 = Ye, 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 Ye = function() { }, Sa = { trace: Ye, debug: Ye, log: Ye, warn: Ye, info: Ye, error: Ye }; function Bs() { return ie({}, Sa); } function va(a, e) { const t = self.console[a]; return t ? t.bind(self.console, `${e ? "[" + e + "] " : ""}[${a}] >`) : Ye; } function Pi(a, e, t) { return e[a] ? e[a].bind(e) : va(a, t); } const Us = Bs(); function xa(a, e, t) { const s = Bs(); 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] = Pi(r, a, t); }); try { s.log(`Debug logs enabled for "${e}" in hls.js version 1.6.6`); } catch { return Bs(); } i.forEach((r) => { Us[r] = Pi(r, a); }); } else ie(Us, s); return s; } const ee = Us; function qe(a = !0) { return typeof self > "u" ? void 0 : (a || !self.MediaSource) && self.ManagedMediaSource || self.MediaSource || self.WebKitMediaSource; } function Aa(a) { return typeof self < "u" && a === self.ManagedMediaSource; } function Yr(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 xe(a, e = !1) { if (typeof TextDecoder < "u") { const l = new TextDecoder("utf-8").decode(a); if (e) { const h = l.indexOf("\0"); return h !== -1 ? l.substring(0, h) : 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 Oe = { 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 La(a) { return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a; } var ps = { exports: {} }, ki; function Ia() { return ki || (ki = 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, h) { if (h = h || {}, c = c.trim(), l = l.trim(), !l) { if (!h.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 d = o.parseURL(l); if (!d) throw new Error("Error trying to parse relative URL."); if (d.scheme) return h.alwaysNormalize ? (d.path = o.normalizePath(d.path), o.buildURLFromParts(d)) : 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 E = { // 2c) Otherwise, the embedded URL inherits the scheme of // the base URL. scheme: g.scheme, netLoc: d.netLoc, path: null, params: d.params, query: d.query, fragment: d.fragment }; if (!d.netLoc && (E.netLoc = g.netLoc, d.path[0] !== "/")) if (!d.path) E.path = g.path, d.params || (E.params = g.params, d.query || (E.query = g.query)); else { var p = g.path, y = p.substring(0, p.lastIndexOf("/") + 1) + d.path; E.path = o.normalizePath(y); } return E.path === null && (E.path = h.alwaysNormalize ? o.normalizePath(d.path) : d.path), o.buildURLFromParts(E); }, 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; })(); }(ps)), ps.exports; } var si = Ia(); class ii { 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 ne = { AUDIO: "audio", VIDEO: "video", AUDIOVIDEO: "audiovideo" }; class Wr { 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, ba(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?.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 = { [ne.AUDIO]: null, [ne.VIDEO]: null, [ne.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 ii()), this._stats; } set stats(e) { this._stats = e; } get url() { return !this._url && this.baseurl && this.relurl && (this._url = si.buildAbsoluteURL(this.baseurl, this.relurl, { alwaysNormalize: !0 })), this._url || ""; } set url(e) { this._url = e; } clearElementaryStreamInfo() { const { elementaryStreams: e } = this; e[ne.AUDIO] = null, e[ne.VIDEO] = null, e[ne.AUDIOVIDEO] = null; } } function de(a) { return a.sn !== "initSegment"; } class Es extends Wr { 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 (M(e) && M(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 = M(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 (!M(e)) { this._programDateTime = this.rawProgramDateTime = null; return; } this._programDateTime = e; } get ref() { return de(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 Ra extends Wr { 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 qr(a, e) { const t = Object.getPrototypeOf(a); if (t) { const s = Object.getOwnPropertyDescriptor(t, e); return s || qr(t, e); } } function ba(a, e) { const t = qr(a, e); t && (t.enumerable = !0, Object.defineProperty(a, e, t)); } const wi = Math.pow(2, 32) - 1, _a = [].push, jr = { video: 1, audio: 2, id3: 3, text: 4 }; function ce(a) { return String.fromCharCode.apply(null, a); } function Xr(a, e) { const t = a[e] << 8 | a[e + 1]; return t < 0 ? 65536 + t : t; } function Y(a, e) { const t = zr(a, e); return t < 0 ? 4294967296 + t : t; } function Oi(a, e) { let t = Y(a, e); return t *= Math.pow(2, 32), t += Y(a, e + 4), t; } function zr(a, e) { return a[e] << 24 | a[e + 1] << 16 | a[e + 2] << 8 | a[e + 3]; } function Da(a) { const e = a.byteLength; for (let t = 0; t < e; ) { const s = Y(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 = Y(a, i), n = ce(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 && _a.apply(t, c); } i = o; } return t; } function Ca(a) { const e = [], t = a[0]; let s = 8; const i = Y(a, s); s += 4; let r = 0, n = 0; t === 0 ? (r = Y(a, s), n = Y(a, s + 4), s += 8) : (r = Oi(a, s), n = Oi(a, s + 8), s += 16), s += 2; let o = a.length + n; const c = Xr(a, s); s += 2; for (let l = 0; l < c; l++) { let h = s; const u = Y(a, h); h += 4; const d = u & 2147483647; if ((u & 2147483648) >>> 31 === 1) return ee.warn("SIDX has hierarchical references (not supported)"), null; const f = Y(a, h); h += 4, e.push({ referenceSize: d, subsegmentDuration: f, // unscaled info: { duration: f / i, start: o, end: o + d - 1 } }), o += d, h += 4, s = h; } return { earliestPresentationTime: r, timescale: i, version: t, referencesCount: c, references: e }; } function Qr(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 = Y(n, o === 0 ? 12 : 20), l = X(r, ["mdia", "mdhd"])[0]; if (l) { o = l[0]; const h = Y(l, o === 0 ? 12 : 20), u = X(r, ["mdia", "hdlr"])[0]; if (u) { const d = ce(u.subarray(8, 12)), g = { soun: ne.AUDIO, vide: ne.VIDEO }[d], f = X(r, ["mdia", "minf", "stbl", "stsd"])[0], E = Pa(f); g ? (e[c] = { timescale: h, type: g, stsd: E }, e[g] = re({ timescale: h, id: c }, E)) : e[c] = { timescale: h, type: d, stsd: E }; } } } } return X(a, ["moov", "mvex", "trex"]).forEach((i) => { const r = Y(i, 4), n = e[r]; n && (n.default = { duration: Y(i, 12), flags: Y(i, 20) }); }), e; } function Pa(a) { const e = a.subarray(8), t = e.subarray(86), s = ce(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 d = X(u, ["schm"])[0]; if (d) { const g = ce(d.subarray(4, 8)); if (g === "cbcs" || g === "cenc") { const f = X(u, ["frma"])[0]; f && (i = ce(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 += "." + Ot(c[1]) + Ot(c[2]) + Ot(c[3]), r = wt(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 h = 4; if (l[h++] !== 3) break; h = ys(l, h), h += 2; const u = l[h++]; if (u & 128 && (h += 2), u & 64 && (h += l[h++]), l[h++] !== 4) break; h = ys(l, h); const d = l[h++]; if (d === 64) i += "." + Ot(d); else break; if (h += 12, l[h++] !== 5) break; h = ys(l, h); const g = l[h++]; let f = (g & 248) >> 3; f === 31 && (f += 1 + ((g & 7) << 3) + ((l[h] & 224) >> 5)), i += "." + f; } break; } case "hvc1": case "hev1": { const c = X(t, ["hvcC"])[0]; if (c && c.length > 12) { const l = c[1], h = ["", "A", "B", "C"][l >> 6], u = l & 31, d = Y(c, 2), g = (l & 32) >> 5 ? "H" : "L", f = c[12], E = c.subarray(6, 12); i += "." + h + u, i += "." + ka(d).toString(16).toUpperCase(), i += "." + g + f; let p = ""; for (let y = E.length; y--; ) { const S = E[y]; (S || p) && (p = "." + S.toString(16).toUpperCase() + p); } i += p; } r = wt(o == "hev1" ? "dvhe" : "dvh1", t); break; } case "dvh1": case "dvhe": case "dvav": case "dva1": case "dav1": { i = wt(i, t) || i; break; } case "vp09": { const c = X(t, ["vpcC"])[0]; if (c && c.length > 6) { const l = c[4], h = c[5], u = c[6] >> 4 & 15; i += "." + we(l) + "." + we(h) + "." + we(u); } break; } case "av01": { const c = X(t, ["av1C"])[0]; if (c && c.length > 2) { const l = c[1] >>> 5, h = c[1] & 31, u = c[2] >>> 7 ? "H" : "M", d = (c[2] & 64) >> 6, g = (c[2] & 32) >> 5, f = l === 2 && d ? g ? 12 : 10 : d ? 10 : 8, E = (c[2] & 16) >> 4, p = (c[2] & 8) >> 3, y = (c[2] & 4) >> 2, S = c[2] & 3; i += "." + l + "." + we(h) + u + "." + we(f) + "." + E + "." + p + y + S + "." + we(1) + "." + we(1) + "." + we(1) + "." + 0, r = wt("dav1", t); } break; } } return { codec: i, encrypted: n, supplemental: r }; } function wt(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 + "." + we(i) + "." + we(r); } } function ka(a) { let e = 0; for (let t = 0; t < 32; t++) e |= (a >> t & 1) << 31 - t; return e >>> 0; } function ys(a, e) { const t = e + 5; for (; a[e++] & 128 && e < t; ) ; return e; } function Ot(a) { return ("0" + a.toString(16).toUpperCase()).slice(-2); } function we(a) { return (a < 10 ? "0" : "") + a; } function wa(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 h = c ? l.subarray(28) : l.subarray(78); X(h, ["sinf"]).forEach((d) => { const g = Zr(d); if (g) { const f = g.subarray(8, 24); f.some((E) => E !== 0) || (ee.log(`[eme] Patching keyId in 'enc${c ? "a" : "v"}>sinf>>tenc' box: ${Oe.hexDump(f)} -> ${Oe.hexDump(t)}`), g.set(t, 8)); } }); }); }), a; } function Zr(a) { const e = X(a, ["schm"])[0]; if (e) { const t = ce(e.subarray(4, 8)); if (t === "cbcs" || t === "cenc") return X(a, ["schi", "tenc"])[0]; } return null; } function Oa(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 = Y(o, 4), l = e[c]; if (!l) continue; const h = 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 v = Y(u, 4); T === 1 && (v === wi ? t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time") : (v *= wi + 1, v += Y(u, 8))), M(v) && (!M(h.start) || v < h.start) && (h.start = v); } const d = l.default, g = Y(o, 0) | d?.flags; let f = d?.duration || 0; g & 8 && (g & 2 ? f = Y(o, 12) : f = Y(o, 8)); const E = X(n, ["trun"]); let p = h.start || 0, y = 0, S = f; for (let T = 0; T < E.length; T++) { const v = E[T], L = Y(v, 4), D = h.sampleCount; h.sampleCount += L; const A = v[3] & 1, b = v[3] & 4, _ = v[2] & 1, x = v[2] & 2, P = v[2] & 4, w = v[2] & 8; let K = 8, U = L; for (A && (K += 4), b && L && (!(v[K + 1] & 1) && h.keyFrameIndex === void 0 && (h.keyFrameIndex = D), K += 4, _ ? (S = Y(v, K), K += 4) : S = f, x && (K += 4), w && (K += 4), p += S, y += S, U--); U--; ) _ ? (S = Y(v, K), K += 4) : S = f, x && (K += 4), P && (v[K + 1] & 1 || h.keyFrameIndex === void 0 && (h.keyFrameIndex = h.sampleCount - (U + 1), h.keyFrameStart = p), K += 4), w && (K += 4), p += S, y += S; !y && f && (y += f * L); } h.duration += y; } 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 = Ca(o[c]); if (l != null && l.references) { r = Math.min(r, l.earliestPresentationTime / l.timescale); const h = l.references.reduce((u, d) => u + d.info.duration || 0, 0); n = Math.max(n, h + l.earliestPresentationTime / l.timescale); } } n && M(n) && Object.keys(s).forEach((c) => { s[c].duration || (s[c].duration = n * s[c].timescale - s[c].start); }); } return s; } function Fa(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 be(a, e) { const t = new Uint8Array(a.length + e.length); return t.set(a), t.set(e, a.length), t; } function Fi(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 d = X(u, ["tfdt"]).map((g) => { const f = g[0]; let E = Y(g, 4); return f === 1 && (E *= Math.pow(2, 32), E += Y(g, 8)), E / i; })[0]; return d !== void 0 && (a = d), X(u, ["tfhd"]).map((g) => { const f = Y(g, 4), E = Y(g, 0) & 16777215, p = (E & 1) !== 0, y = (E & 2) !== 0, S = (E & 8) !== 0; let T = 0; const v = (E & 16) !== 0; let L = 0; const D = (E & 32) !== 0; let A = 8; f === r && (p && (A += 8), y && (A += 4), S && (T = Y(g, A), A += 4), v && (L = Y(g, A), A += 4), D && (A += 4), e.type === "video" && (n = ds(e.codec)), X(u, ["trun"]).map((b) => { const _ = b[0], x = Y(b, 0) & 16777215, P = (x & 1) !== 0; let w = 0; const K = (x & 4) !== 0, U = (x & 256) !== 0; let B = 0; const N = (x & 512) !== 0; let V = 0; const O = (x & 1024) !== 0, q = (x & 2048) !== 0; let H = 0; const F = Y(b, 4); let k = 8; P && (w = Y(b, k), k += 4), K && (k += 4); let j = w + l; for (let Q = 0; Q < F; Q++) { if (U ? (B = Y(b, k), k += 4) : B = T, N ? (V = Y(b, k), k += 4) : V = L, O && (k += 4), q && (_ === 0 ? H = Y(b, k) : H = zr(b, k), k += 4), e.type === ne.VIDEO) { let te = 0; for (; te < V; ) { const Z = Y(s, j); if (j += 4, Ma(n, s[j])) { const oe = s.subarray(j, j + Z); ri(oe, n ? 2 : 1, a + H / i, t); } j += Z, te += Z + 4; } } a += B / i; } })); }); }); }), t; } function ds(a) { if (!a) return !1; const e = a.substring(0, 4); return e === "hvc1" || e === "hev1" || // Dolby Vision e === "dvh1" || e === "dvhe"; } function Ma(a, e) { if (a) { const t = e >> 1 & 63; return t === 39 || t === 40; } else return (e & 31) === 6; } function ri(a, e, t, s) { const i = Jr(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 h = 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[h++] === 181) { const d = Xr(i, h); if (h += 2, d === 49) { const g = Y(i, h); if (h += 4, g === 1195456820) { const f = i[h++]; if (f === 3) { const E = i[h++], p = 31 & E, y = 64 & E, S = y ? 2 + p * 3 : 0, T = new Uint8Array(S); if (y) { T[0] = E; for (let v = 1; v < S; v++) T[v] = i[h++]; } 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 E = i[h++].toString(16); u.push(E.length == 1 ? "0" + E : E), (f === 3 || f === 5 || f === 7 || f === 9) && u.push("-"); } const d = o - 16, g = new Uint8Array(d); for (let f = 0; f < d; f++) g[f] = i[h++]; s.push({ payloadType: n, pts: t, uuid: u.join(""), userData: xe(g), userDataBytes: g }); } } } function Jr(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 Na(a) { const e = a[0]; let t = "", s = "", i = 0, r = 0, n = 0, o = 0, c = 0, l = 0; if (e === 0) { for (; ce(a.subarray(l, l + 1)) !== "\0"; ) t += ce(a.subarray(l, l + 1)), l += 1; for (t += ce(a.subarray(l, l + 1)), l += 1; ce(a.subarray(l, l + 1)) !== "\0"; ) s += ce(a.subarray(l, l + 1)), l += 1; s += ce(a.subarray(l, l + 1)), l += 1, i = Y(a, 12), r = Y(a, 16), o = Y(a, 20), c = Y(a, 24), l = 28; } else if (e === 1) { l += 4, i = Y(a, l), l += 4; const u = Y(a, l); l += 4; const d = Y(a, l); for (l += 4, n = 2 ** 32 * u + d, ga(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 = Y(a, l), l += 4, c = Y(a, l), l += 4; ce(a.subarray(l, l + 1)) !== "\0"; ) t += ce(a.subarray(l, l + 1)), l += 1; for (t += ce(a.subarray(l, l + 1)), l += 1; ce(a.subarray(l, l + 1)) !== "\0"; ) s += ce(a.subarray(l, l + 1)), l += 1; s += ce(a.subarray(l, l + 1)), l += 1; } const h = a.subarray(l, a.byteLength); return { schemeIdUri: t, value: s, timeScale: i, presentationTime: n, presentationTimeDelta: r, eventDuration: o, id: c, payload: h }; } function Ba(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 Ua(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), Ba( [112, 115, 115, 104], new Uint8Array([ s, 0, 0, 0 // Flags ]), a, // 16 bytes r, i, n, t || new Uint8Array() ); } function $a(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 = Ga(i); e.push(r), s += r.size; } } return e; } function Ga(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 = Oe.hexDump(new Uint8Array(n, t + 12, 16)); let c = null, l = null, h = 0; if (r === 0) h = 28; else if (r === 1) { const d = a.getUint32(28); if (!d || s < 32 + d * 16) return { offset: t, size: e }; c = []; for (let g = 0; g < d; g++) c.push(new Uint8Array(n, t + 32 + g * 16, 16)); h = 32 + d * 16; } if (!h) return { offset: t, size: e }; const u = a.getUint32(h); return e - 32 < u ? { offset: t, size: e } : (l = new Uint8Array(n, t + h + 4, u), { version: r, systemId: o, kids: c, data: l, offset: t, size: e }); } const en = () => /\(Windows.+Firefox\//i.test(navigator.userAgent), ft = { 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 ni(a, e) { const t = ft[e]; return !!t && !!t[a.slice(0, 4)]; } function $s(a, e, t = !0) { return !a.split(",").some((s) => !ai(s, e, t)); } function ai(a, e, t = !0) { var s; const i = qe(t); return (s = i?.isTypeSupported(Lt(a, e))) != null ? s : !1; } function Lt(a, e) { return `${e}/mp4;codecs=${a}`; } function Mi(a) { if (a) { const e = a.substring(0, 4); return ft.video[e]; } return 2; } function ss(a) { const e = en(); return a.split(",").reduce((t, s) => { const r = e && ds(s) ? 9 : ft.video[s]; return r ? (r * 2 + t) / (t ? 3 : 2) : (ft.audio[s] + t) / (t ? 2 : 1); }, 0); } const Ts = {}; function Ka(a, e = !0) { if (Ts[a]) return Ts[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 (ai(t[i], "audio", e)) return Ts[a] = t[i], t[i]; if (t[i] === "mp3" && (s = qe(e)) != null && s.isTypeSupported("audio/mpeg")) return ""; } return a; } const Va = /flac|opus|mp4a\.40\.34/i; function is(a, e = !0) { return a.replace(Va, (t) => Ka(t.toLowerCase(), e)); } function Ha(a, e) { const t = []; if (a) { const s = a.split(","); for (let i = 0; i < s.length; i++) ni(s[i], "video") || t.push(s[i]); } return e && t.push(e), t.join(","); } function jt(a, e) { if (a && (a.length > 4 || ["ac-3", "ec-3", "alac", "fLaC", "Opus"].indexOf(a) !== -1) && (Ni(a, "audio") || Ni(a, "video"))) 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 Ni(a, e) { return ni(a, e) && ai(a, e); } function Ya(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 Wa(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 Bi(a) { const e = qe(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 Gs(a) { return a.replace(/^.+codecs=["']?([^"']+).*$/, "$1"); } const tn = { supported: !0, configurations: [], decodingInfoResults: [{ supported: !0, powerEfficient: !0, smooth: !0 }] }; function sn(a, e) { return { supported: !1, configurations: e, decodingInfoResults: [{ supported: !1, smooth: !1, powerEfficient: !1 }], error: a }; } function qa(a, e, t, s, i, r) { const n = a.videoCodec, o = a.audioCodec ? a.audioGroups : null, c = r?.audioCodec, l = r?.channels, h = l ? parseInt(l) : c ? 1 / 0 : 2; let u = null; if (o != null && o.length) try { o.length === 1 && o[0] ? u = e.groups[o[0]].channels : u = o.reduce((d, g) => { if (g) { const f = e.groups[g]; if (!f) throw new Error(`Audio track group ${g} not found`); Object.keys(f.channels).forEach((E) => { d[E] = (d[E] || 0) + f.channels[E]; }); } return d; }, { 2: 0 }); } catch { return !0; } return n !== void 0 && // Force media capabilities check for HEVC to avoid failure on Windows (n.split(",").some((d) => ds(d)) || 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)) || !!u && M(h) && Object.keys(u).some((d) => parseInt(d) > h); } function rn(a, e, t, s = {}) { const i = a.videoCodec; if (!i && !a.audioCodec || !t) return Promise.resolve(tn); const r = [], n = ja(a), o = n.length, c = Xa(a, e, o > 0), l = c.length; for (let h = o || 1 * l || 1; h--; ) { const u = { type: "media-source" }; if (o && (u.video = n[h % o]), l) { u.audio = c[h % l]; const d = u.audio.bitrate; u.video && d && (u.video.bitrate -= d); } r.push(u); } if (i) { const h = navigator.userAgent; if (i.split(",").some((u) => ds(u)) && en()) return Promise.resolve(sn(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${h})`), r)); } return Promise.all(r.map((h) => { const u = Qa(h); return s[u] || (s[u] = t.decodingInfo(h)); })).then((h) => ({ supported: !h.some((u) => !u.supported), configurations: r, decodingInfoResults: h })).catch((h) => ({ supported: !1, configurations: r, decodingInfoResults: [], error: h })); } function ja(a) { var e; const t = (e = a.videoCodec) == null ? void 0 : e.split(","), s = nn(a), i = a.width || 640, r = a.height || 480, n = a.frameRate || 30, o = a.videoRange.toLowerCase(); return t ? t.map((c) => { const l = { contentType: Lt(Wa(c), "video"), width: i, height: r, bitrate: s, framerate: n }; return o !== "sdr" && (l.transferFunction = o), l; }) : []; } function Xa(a, e, t) { var s; const i = (s = a.audioCodec) == null ? void 0 : s.split(","), r = nn(a); return i && a.audioGroups ? a.audioGroups.reduce((n, o) => { var c; const l = o ? (c = e.groups[o]) == null ? void 0 : c.tracks : null; return l ? l.reduce((h, u) => { if (u.groupId === o) { const d = parseFloat(u.channels || ""); i.forEach((g) => { const f = { contentType: Lt(g, "audio"), bitrate: t ? za(g, r) : r }; d && (f.channels = "" + d), h.push(f); }); } return h; }, n) : n; }, []) : []; } function za(a, e) { if (e <= 1) return 1; let t = 128e3; return a === "ec-3" ? t = 768e3 : a === "ac-3" && (t = 64e4), Math.min(e / 2, t); } function nn(a) { return Math.ceil(Math.max(a.bitrate * 0.9, a.averageBitrate) / 1e3) * 1e3 || 1; } function Qa(a) { let e = ""; const { audio: t, video: s } = a; if (s) { const i = Gs(s.contentType); e += `${i}_r${s.height}x${s.width}f${Math.ceil(s.framerate)}${s.transferFunction || "sd"}_${Math.ceil(s.bitrate / 1e5)}`; } if (t) { const i = Gs(t.contentType); e += `${s ? "_" : ""}${i}_c${t.channels}`; } return e; } const Ks = ["NONE", "TYPE-0", "TYPE-1", null]; function Za(a) { return Ks.indexOf(a) > -1; } const rs = ["SDR", "PQ", "HLG"]; function Ja(a) { return !!a && rs.indexOf(a) > -1; } var Xt = { No: "", Yes: "YES", v2: "v2" }; function Ui(a) { const { canSkip