@mediatrack/open-player
Version:
文档见 [分秒帧开放平台](https://open.mediatrack.cn/#/docs/api/jssdk/player)
1,422 lines • 715 kB
JavaScript
function BE(l) {
return l && l.__esModule && Object.prototype.hasOwnProperty.call(l, "default") ? l.default : l;
}
var Jh = { exports: {} };
(function(l, t) {
(function(e) {
var i = /^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/, r = /^(?=([^\/?#]*))\1([^]*)$/, s = /(?:\/|^)\.(?=\/)/g, o = /(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g, u = {
// 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, f, d) {
if (d = d || {}, c = c.trim(), f = f.trim(), !f) {
if (!d.alwaysNormalize)
return c;
var g = u.parseURL(c);
if (!g)
throw new Error("Error trying to parse base URL.");
return g.path = u.normalizePath(
g.path
), u.buildURLFromParts(g);
}
var p = u.parseURL(f);
if (!p)
throw new Error("Error trying to parse relative URL.");
if (p.scheme)
return d.alwaysNormalize ? (p.path = u.normalizePath(p.path), u.buildURLFromParts(p)) : f;
var T = u.parseURL(c);
if (!T)
throw new Error("Error trying to parse base URL.");
if (!T.netLoc && T.path && T.path[0] !== "/") {
var E = r.exec(T.path);
T.netLoc = E[1], T.path = E[2];
}
T.netLoc && !T.path && (T.path = "/");
var L = {
// 2c) Otherwise, the embedded URL inherits the scheme of
// the base URL.
scheme: T.scheme,
netLoc: p.netLoc,
path: null,
params: p.params,
query: p.query,
fragment: p.fragment
};
if (!p.netLoc && (L.netLoc = T.netLoc, p.path[0] !== "/"))
if (!p.path)
L.path = T.path, p.params || (L.params = T.params, p.query || (L.query = T.query));
else {
var S = T.path, _ = S.substring(0, S.lastIndexOf("/") + 1) + p.path;
L.path = u.normalizePath(_);
}
return L.path === null && (L.path = d.alwaysNormalize ? u.normalizePath(p.path) : p.path), u.buildURLFromParts(L);
},
parseURL: function(c) {
var f = i.exec(c);
return f ? {
scheme: f[1] || "",
netLoc: f[2] || "",
path: f[3] || "",
params: f[4] || "",
query: f[5] || "",
fragment: f[6] || ""
} : null;
},
normalizePath: function(c) {
for (c = c.split("").reverse().join("").replace(s, ""); c.length !== (c = c.replace(o, "")).length; )
;
return c.split("").reverse().join("");
},
buildURLFromParts: function(c) {
return c.scheme + c.netLoc + c.path + c.params + c.query + c.fragment;
}
};
l.exports = u;
})();
})(Jh);
var co = Jh.exports;
function rh(l, t) {
var e = Object.keys(l);
if (Object.getOwnPropertySymbols) {
var i = Object.getOwnPropertySymbols(l);
t && (i = i.filter(function(r) {
return Object.getOwnPropertyDescriptor(l, r).enumerable;
})), e.push.apply(e, i);
}
return e;
}
function Ae(l) {
for (var t = 1; t < arguments.length; t++) {
var e = arguments[t] != null ? arguments[t] : {};
t % 2 ? rh(Object(e), !0).forEach(function(i) {
GE(l, i, e[i]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(l, Object.getOwnPropertyDescriptors(e)) : rh(Object(e)).forEach(function(i) {
Object.defineProperty(l, i, Object.getOwnPropertyDescriptor(e, i));
});
}
return l;
}
function GE(l, t, e) {
return t = HE(t), t in l ? Object.defineProperty(l, t, {
value: e,
enumerable: !0,
configurable: !0,
writable: !0
}) : l[t] = e, l;
}
function Qt() {
return Qt = Object.assign ? Object.assign.bind() : function(l) {
for (var t = 1; t < arguments.length; t++) {
var e = arguments[t];
for (var i in e)
Object.prototype.hasOwnProperty.call(e, i) && (l[i] = e[i]);
}
return l;
}, Qt.apply(this, arguments);
}
function $E(l, t) {
if (typeof l != "object" || l === null)
return l;
var e = l[Symbol.toPrimitive];
if (e !== void 0) {
var i = e.call(l, t || "default");
if (typeof i != "object")
return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (t === "string" ? String : Number)(l);
}
function HE(l) {
var t = $E(l, "string");
return typeof t == "symbol" ? t : String(t);
}
const ut = Number.isFinite || function(l) {
return typeof l == "number" && isFinite(l);
};
let v = /* @__PURE__ */ function(l) {
return l.MEDIA_ATTACHING = "hlsMediaAttaching", l.MEDIA_ATTACHED = "hlsMediaAttached", l.MEDIA_DETACHING = "hlsMediaDetaching", l.MEDIA_DETACHED = "hlsMediaDetached", l.BUFFER_RESET = "hlsBufferReset", l.BUFFER_CODECS = "hlsBufferCodecs", l.BUFFER_CREATED = "hlsBufferCreated", l.BUFFER_APPENDING = "hlsBufferAppending", l.BUFFER_APPENDED = "hlsBufferAppended", l.BUFFER_EOS = "hlsBufferEos", l.BUFFER_FLUSHING = "hlsBufferFlushing", l.BUFFER_FLUSHED = "hlsBufferFlushed", l.MANIFEST_LOADING = "hlsManifestLoading", l.MANIFEST_LOADED = "hlsManifestLoaded", l.MANIFEST_PARSED = "hlsManifestParsed", l.LEVEL_SWITCHING = "hlsLevelSwitching", l.LEVEL_SWITCHED = "hlsLevelSwitched", l.LEVEL_LOADING = "hlsLevelLoading", l.LEVEL_LOADED = "hlsLevelLoaded", l.LEVEL_UPDATED = "hlsLevelUpdated", l.LEVEL_PTS_UPDATED = "hlsLevelPtsUpdated", l.LEVELS_UPDATED = "hlsLevelsUpdated", l.AUDIO_TRACKS_UPDATED = "hlsAudioTracksUpdated", l.AUDIO_TRACK_SWITCHING = "hlsAudioTrackSwitching", l.AUDIO_TRACK_SWITCHED = "hlsAudioTrackSwitched", l.AUDIO_TRACK_LOADING = "hlsAudioTrackLoading", l.AUDIO_TRACK_LOADED = "hlsAudioTrackLoaded", l.SUBTITLE_TRACKS_UPDATED = "hlsSubtitleTracksUpdated", l.SUBTITLE_TRACKS_CLEARED = "hlsSubtitleTracksCleared", l.SUBTITLE_TRACK_SWITCH = "hlsSubtitleTrackSwitch", l.SUBTITLE_TRACK_LOADING = "hlsSubtitleTrackLoading", l.SUBTITLE_TRACK_LOADED = "hlsSubtitleTrackLoaded", l.SUBTITLE_FRAG_PROCESSED = "hlsSubtitleFragProcessed", l.CUES_PARSED = "hlsCuesParsed", l.NON_NATIVE_TEXT_TRACKS_FOUND = "hlsNonNativeTextTracksFound", l.INIT_PTS_FOUND = "hlsInitPtsFound", l.FRAG_LOADING = "hlsFragLoading", l.FRAG_LOAD_EMERGENCY_ABORTED = "hlsFragLoadEmergencyAborted", l.FRAG_LOADED = "hlsFragLoaded", l.FRAG_DECRYPTED = "hlsFragDecrypted", l.FRAG_PARSING_INIT_SEGMENT = "hlsFragParsingInitSegment", l.FRAG_PARSING_USERDATA = "hlsFragParsingUserdata", l.FRAG_PARSING_METADATA = "hlsFragParsingMetadata", l.FRAG_PARSED = "hlsFragParsed", l.FRAG_BUFFERED = "hlsFragBuffered", l.FRAG_CHANGED = "hlsFragChanged", l.FPS_DROP = "hlsFpsDrop", l.FPS_DROP_LEVEL_CAPPING = "hlsFpsDropLevelCapping", l.ERROR = "hlsError", l.DESTROYING = "hlsDestroying", l.KEY_LOADING = "hlsKeyLoading", l.KEY_LOADED = "hlsKeyLoaded", l.LIVE_BACK_BUFFER_REACHED = "hlsLiveBackBufferReached", l.BACK_BUFFER_REACHED = "hlsBackBufferReached", l;
}({}), dt = /* @__PURE__ */ function(l) {
return l.NETWORK_ERROR = "networkError", l.MEDIA_ERROR = "mediaError", l.KEY_SYSTEM_ERROR = "keySystemError", l.MUX_ERROR = "muxError", l.OTHER_ERROR = "otherError", l;
}({}), z = /* @__PURE__ */ function(l) {
return l.KEY_SYSTEM_NO_KEYS = "keySystemNoKeys", l.KEY_SYSTEM_NO_ACCESS = "keySystemNoAccess", l.KEY_SYSTEM_NO_SESSION = "keySystemNoSession", l.KEY_SYSTEM_NO_CONFIGURED_LICENSE = "keySystemNoConfiguredLicense", l.KEY_SYSTEM_LICENSE_REQUEST_FAILED = "keySystemLicenseRequestFailed", l.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED = "keySystemServerCertificateRequestFailed", l.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED = "keySystemServerCertificateUpdateFailed", l.KEY_SYSTEM_SESSION_UPDATE_FAILED = "keySystemSessionUpdateFailed", l.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED = "keySystemStatusOutputRestricted", l.KEY_SYSTEM_STATUS_INTERNAL_ERROR = "keySystemStatusInternalError", l.MANIFEST_LOAD_ERROR = "manifestLoadError", l.MANIFEST_LOAD_TIMEOUT = "manifestLoadTimeOut", l.MANIFEST_PARSING_ERROR = "manifestParsingError", l.MANIFEST_INCOMPATIBLE_CODECS_ERROR = "manifestIncompatibleCodecsError", l.LEVEL_EMPTY_ERROR = "levelEmptyError", l.LEVEL_LOAD_ERROR = "levelLoadError", l.LEVEL_LOAD_TIMEOUT = "levelLoadTimeOut", l.LEVEL_PARSING_ERROR = "levelParsingError", l.LEVEL_SWITCH_ERROR = "levelSwitchError", l.AUDIO_TRACK_LOAD_ERROR = "audioTrackLoadError", l.AUDIO_TRACK_LOAD_TIMEOUT = "audioTrackLoadTimeOut", l.SUBTITLE_LOAD_ERROR = "subtitleTrackLoadError", l.SUBTITLE_TRACK_LOAD_TIMEOUT = "subtitleTrackLoadTimeOut", l.FRAG_LOAD_ERROR = "fragLoadError", l.FRAG_LOAD_TIMEOUT = "fragLoadTimeOut", l.FRAG_DECRYPT_ERROR = "fragDecryptError", l.FRAG_PARSING_ERROR = "fragParsingError", l.FRAG_GAP = "fragGap", l.REMUX_ALLOC_ERROR = "remuxAllocError", l.KEY_LOAD_ERROR = "keyLoadError", l.KEY_LOAD_TIMEOUT = "keyLoadTimeOut", l.BUFFER_ADD_CODEC_ERROR = "bufferAddCodecError", l.BUFFER_INCOMPATIBLE_CODECS_ERROR = "bufferIncompatibleCodecsError", l.BUFFER_APPEND_ERROR = "bufferAppendError", l.BUFFER_APPENDING_ERROR = "bufferAppendingError", l.BUFFER_STALLED_ERROR = "bufferStalledError", l.BUFFER_FULL_ERROR = "bufferFullError", l.BUFFER_SEEK_OVER_HOLE = "bufferSeekOverHole", l.BUFFER_NUDGE_ON_STALL = "bufferNudgeOnStall", l.INTERNAL_EXCEPTION = "internalException", l.INTERNAL_ABORTED = "aborted", l.UNKNOWN = "unknown", l;
}({});
const zi = function() {
}, eo = {
trace: zi,
debug: zi,
log: zi,
warn: zi,
info: zi,
error: zi
};
let Hn = eo;
function KE(l) {
const t = self.console[l];
return t ? t.bind(self.console, `[${l}] >`) : zi;
}
function WE(l, ...t) {
t.forEach(function(e) {
Hn[e] = l[e] ? l[e].bind(l) : KE(e);
});
}
function VE(l, t) {
if (self.console && l === !0 || typeof l == "object") {
WE(
l,
// Remove out from list here to hard-disable a log-level
// 'trace',
"debug",
"log",
"info",
"warn",
"error"
);
try {
Hn.log(`Debug logs enabled for "${t}" in hls.js version 1.4.3`);
} catch {
Hn = eo;
}
} else
Hn = eo;
}
const G = Hn, YE = /^(\d+)x(\d+)$/, sh = /(.+?)=(".*?"|.*?)(?:,|$)/g;
class Wt {
constructor(t) {
typeof t == "string" && (t = Wt.parseAttrList(t));
for (const e in t)
t.hasOwnProperty(e) && (e.substring(0, 2) === "X-" && (this.clientAttrs = this.clientAttrs || [], this.clientAttrs.push(e)), this[e] = t[e]);
}
decimalInteger(t) {
const e = parseInt(this[t], 10);
return e > Number.MAX_SAFE_INTEGER ? 1 / 0 : e;
}
hexadecimalInteger(t) {
if (this[t]) {
let e = (this[t] || "0x").slice(2);
e = (e.length & 1 ? "0" : "") + e;
const i = new Uint8Array(e.length / 2);
for (let r = 0; r < e.length / 2; r++)
i[r] = parseInt(e.slice(r * 2, r * 2 + 2), 16);
return i;
} else
return null;
}
hexadecimalIntegerAsNumber(t) {
const e = parseInt(this[t], 16);
return e > Number.MAX_SAFE_INTEGER ? 1 / 0 : e;
}
decimalFloatingPoint(t) {
return parseFloat(this[t]);
}
optionalFloat(t, e) {
const i = this[t];
return i ? parseFloat(i) : e;
}
enumeratedString(t) {
return this[t];
}
bool(t) {
return this[t] === "YES";
}
decimalResolution(t) {
const e = YE.exec(this[t]);
if (e !== null)
return {
width: parseInt(e[1], 10),
height: parseInt(e[2], 10)
};
}
static parseAttrList(t) {
let e;
const i = {}, r = '"';
for (sh.lastIndex = 0; (e = sh.exec(t)) !== null; ) {
let s = e[2];
s.indexOf(r) === 0 && s.lastIndexOf(r) === s.length - 1 && (s = s.slice(1, -1));
const o = e[1].trim();
i[o] = s;
}
return i;
}
}
function qE(l) {
return l !== "ID" && l !== "CLASS" && l !== "START-DATE" && l !== "DURATION" && l !== "END-DATE" && l !== "END-ON-NEXT";
}
function zE(l) {
return l === "SCTE35-OUT" || l === "SCTE35-IN";
}
class tc {
constructor(t, e) {
if (this.attr = void 0, this._startDate = void 0, this._endDate = void 0, this._badValueForSameId = void 0, e) {
const i = e.attr;
for (const r in i)
if (Object.prototype.hasOwnProperty.call(t, r) && t[r] !== i[r]) {
G.warn(`DATERANGE tag attribute: "${r}" does not match for tags with ID: "${t.ID}"`), this._badValueForSameId = r;
break;
}
t = Qt(new Wt({}), i, t);
}
if (this.attr = t, this._startDate = new Date(t["START-DATE"]), "END-DATE" in this.attr) {
const i = new Date(this.attr["END-DATE"]);
ut(i.getTime()) && (this._endDate = i);
}
}
get id() {
return this.attr.ID;
}
get class() {
return this.attr.CLASS;
}
get startDate() {
return this._startDate;
}
get endDate() {
if (this._endDate)
return this._endDate;
const t = this.duration;
return t !== null ? new Date(this._startDate.getTime() + t * 1e3) : null;
}
get duration() {
if ("DURATION" in this.attr) {
const t = this.attr.decimalFloatingPoint("DURATION");
if (ut(t))
return t;
} else if (this._endDate)
return (this._endDate.getTime() - this._startDate.getTime()) / 1e3;
return null;
}
get plannedDuration() {
return "PLANNED-DURATION" in this.attr ? this.attr.decimalFloatingPoint("PLANNED-DURATION") : null;
}
get endOnNext() {
return this.attr.bool("END-ON-NEXT");
}
get isValid() {
return !!this.id && !this._badValueForSameId && ut(this.startDate.getTime()) && (this.duration === null || this.duration >= 0) && (!this.endOnNext || !!this.class);
}
}
class rs {
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 Ft = {
AUDIO: "audio",
VIDEO: "video",
AUDIOVIDEO: "audiovideo"
};
class ec {
// baseurl is the URL to the playlist
// relurl is the portion of the URL that comes from inside the playlist.
// Holds the types of data this fragment supports
constructor(t) {
this._byteRange = null, this._url = null, this.baseurl = void 0, this.relurl = void 0, this.elementaryStreams = {
[Ft.AUDIO]: null,
[Ft.VIDEO]: null,
[Ft.AUDIOVIDEO]: null
}, this.baseurl = t;
}
// setByteRange converts a EXT-X-BYTERANGE attribute into a two element array
setByteRange(t, e) {
const i = t.split("@", 2), r = [];
i.length === 1 ? r[0] = e ? e.byteRangeEndOffset : 0 : r[0] = parseInt(i[1]), r[1] = parseInt(i[0]) + r[0], this._byteRange = r;
}
get byteRange() {
return this._byteRange ? this._byteRange : [];
}
get byteRangeStartOffset() {
return this.byteRange[0];
}
get byteRangeEndOffset() {
return this.byteRange[1];
}
get url() {
return !this._url && this.baseurl && this.relurl && (this._url = co.buildAbsoluteURL(this.baseurl, this.relurl, {
alwaysNormalize: !0
})), this._url || "";
}
set url(t) {
this._url = t;
}
}
class Da extends ec {
// EXTINF has to be present for a m3u8 to be considered valid
// sn notates the sequence number for a segment, and if set to a string can be 'initSegment'
// levelkeys are the EXT-X-KEY tags that apply to this segment for decryption
// core difference from the private field _decryptdata is the lack of the initialized IV
// _decryptdata will set the IV for this segment based on the segment number in the fragment
// A string representing the fragment type
// A reference to the loader. Set while the fragment is loading, and removed afterwards. Used to abort fragment loading
// A reference to the key loader. Set while the key is loading, and removed afterwards. Used to abort key loading
// The level/track index to which the fragment belongs
// The continuity counter of the fragment
// The starting Presentation Time Stamp (PTS) of the fragment. Set after transmux complete.
// The ending Presentation Time Stamp (PTS) of the fragment. Set after transmux complete.
// The starting Decode Time Stamp (DTS) of the fragment. Set after transmux complete.
// The ending Decode Time Stamp (DTS) of the fragment. Set after transmux complete.
// The start time of the fragment, as listed in the manifest. Updated after transmux complete.
// Set by `updateFragPTSDTS` in level-helper
// The maximum starting Presentation Time Stamp (audio/video PTS) of the fragment. Set after transmux complete.
// The minimum ending Presentation Time Stamp (audio/video PTS) of the fragment. Set after transmux complete.
// Load/parse timing information
// A flag indicating whether the segment was downloaded in order to test bitrate, and was not buffered
// #EXTINF segment title
// The Media Initialization Section for this segment
// Fragment is the last fragment in the media playlist
// Fragment is marked by an EXT-X-GAP tag indicating that it does not contain media data and should not be loaded
constructor(t, e) {
super(e), this._decryptdata = null, this.rawProgramDateTime = null, this.programDateTime = 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.deltaPTS = void 0, this.maxStartPTS = void 0, this.minEndPTS = void 0, this.stats = new rs(), this.urlId = 0, this.data = void 0, this.bitrateTest = !1, this.title = null, this.initSegment = null, this.endList = void 0, this.gap = void 0, this.type = t;
}
get decryptdata() {
const {
levelkeys: t
} = this;
if (!t && !this._decryptdata)
return null;
if (!this._decryptdata && this.levelkeys && !this.levelkeys.NONE) {
const e = this.levelkeys.identity;
if (e)
this._decryptdata = e.getDecryptData(this.sn);
else {
const i = Object.keys(this.levelkeys);
if (i.length === 1)
return this._decryptdata = this.levelkeys[i[0]].getDecryptData(this.sn);
}
}
return this._decryptdata;
}
get end() {
return this.start + this.duration;
}
get endProgramDateTime() {
if (this.programDateTime === null || !ut(this.programDateTime))
return null;
const t = ut(this.duration) ? this.duration : 0;
return this.programDateTime + t * 1e3;
}
get encrypted() {
var t;
if ((t = this._decryptdata) != null && t.encrypted)
return !0;
if (this.levelkeys) {
const e = Object.keys(this.levelkeys), i = e.length;
if (i > 1 || i === 1 && this.levelkeys[e[0]].encrypted)
return !0;
}
return !1;
}
setKeyFormat(t) {
if (this.levelkeys) {
const e = this.levelkeys[t];
e && !this._decryptdata && (this._decryptdata = e.getDecryptData(this.sn));
}
}
abortRequests() {
var t, e;
(t = this.loader) == null || t.abort(), (e = this.keyLoader) == null || e.abort();
}
setElementaryStreamInfo(t, e, i, r, s, o = !1) {
const {
elementaryStreams: u
} = this, c = u[t];
if (!c) {
u[t] = {
startPTS: e,
endPTS: i,
startDTS: r,
endDTS: s,
partial: o
};
return;
}
c.startPTS = Math.min(c.startPTS, e), c.endPTS = Math.max(c.endPTS, i), c.startDTS = Math.min(c.startDTS, r), c.endDTS = Math.max(c.endDTS, s);
}
clearElementaryStreamInfo() {
const {
elementaryStreams: t
} = this;
t[Ft.AUDIO] = null, t[Ft.VIDEO] = null, t[Ft.AUDIOVIDEO] = null;
}
}
class XE extends ec {
constructor(t, e, i, r, s) {
super(i), 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.stats = new rs(), this.duration = t.decimalFloatingPoint("DURATION"), this.gap = t.bool("GAP"), this.independent = t.bool("INDEPENDENT"), this.relurl = t.enumeratedString("URI"), this.fragment = e, this.index = r;
const o = t.enumeratedString("BYTERANGE");
o && this.setByteRange(o, s), s && (this.fragOffset = s.fragOffset + s.duration);
}
get start() {
return this.fragment.start + this.fragOffset;
}
get end() {
return this.start + this.duration;
}
get loaded() {
const {
elementaryStreams: t
} = this;
return !!(t.audio || t.video || t.audiovideo);
}
}
const jE = 10;
class QE {
// Manifest reload synchronization
constructor(t) {
this.PTSKnown = !1, this.alignedSliding = !1, this.averagetargetduration = void 0, this.endCC = 0, this.endSN = 0, this.fragments = void 0, this.fragmentHint = void 0, this.partList = null, this.dateRanges = void 0, this.live = !0, this.ageHeader = 0, this.advancedDateTime = void 0, this.updated = !0, this.advanced = !0, this.availabilityDelay = void 0, this.misses = 0, this.startCC = 0, this.startSN = 0, this.startTimeOffset = null, this.targetduration = 0, this.totalduration = 0, this.type = null, this.url = void 0, this.m3u8 = "", this.version = null, this.canBlockReload = !1, this.canSkipUntil = 0, this.canSkipDateRanges = !1, this.skippedSegments = 0, this.recentlyRemovedDateranges = void 0, this.partHoldBack = 0, this.holdBack = 0, this.partTarget = 0, this.preloadHint = void 0, this.renditionReports = void 0, this.tuneInGoal = 0, this.deltaUpdateFailed = void 0, this.driftStartTime = 0, this.driftEndTime = 0, this.driftStart = 0, this.driftEnd = 0, this.encryptedFragments = void 0, this.playlistParsingError = null, this.variableList = null, this.hasVariableRefs = !1, this.fragments = [], this.encryptedFragments = [], this.dateRanges = {}, this.url = t;
}
reloaded(t) {
if (!t) {
this.advanced = !0, this.updated = !0;
return;
}
const e = this.lastPartSn - t.lastPartSn, i = this.lastPartIndex - t.lastPartIndex;
this.updated = this.endSN !== t.endSN || !!i || !!e, this.advanced = this.endSN > t.endSN || e > 0 || e === 0 && i > 0, this.updated || this.advanced ? this.misses = Math.floor(t.misses * 0.6) : this.misses = t.misses + 1, this.availabilityDelay = t.availabilityDelay;
}
get hasProgramDateTime() {
return this.fragments.length ? ut(this.fragments[this.fragments.length - 1].programDateTime) : !1;
}
get levelTargetDuration() {
return this.averagetargetduration || this.targetduration || jE;
}
get drift() {
const t = this.driftEndTime - this.driftStartTime;
return t > 0 ? (this.driftEnd - this.driftStart) * 1e3 / t : 1;
}
get edge() {
return this.partEnd || this.fragmentEnd;
}
get partEnd() {
var t;
return (t = this.partList) != null && t.length ? this.partList[this.partList.length - 1].end : this.fragmentEnd;
}
get fragmentEnd() {
var t;
return (t = this.fragments) != null && t.length ? this.fragments[this.fragments.length - 1].end : 0;
}
get age() {
return this.advancedDateTime ? Math.max(Date.now() - this.advancedDateTime, 0) / 1e3 : 0;
}
get lastPartIndex() {
var t;
return (t = this.partList) != null && t.length ? this.partList[this.partList.length - 1].index : -1;
}
get lastPartSn() {
var t;
return (t = this.partList) != null && t.length ? this.partList[this.partList.length - 1].fragment.sn : this.endSN;
}
}
function fo(l) {
return Uint8Array.from(atob(l), (t) => t.charCodeAt(0));
}
function ZE(l) {
const t = ic(l).subarray(0, 16), e = new Uint8Array(16);
return e.set(t, 16 - t.length), e;
}
function JE(l) {
const t = function(i, r, s) {
const o = i[r];
i[r] = i[s], i[s] = o;
};
t(l, 0, 3), t(l, 1, 2), t(l, 4, 5), t(l, 6, 7);
}
function ty(l) {
const t = l.split(":");
let e = null;
if (t[0] === "data" && t.length === 2) {
const i = t[1].split(";"), r = i[i.length - 1].split(",");
if (r.length === 2) {
const s = r[0] === "base64", o = r[1];
s ? (i.splice(-1, 1), e = fo(o)) : e = ZE(o);
}
}
return e;
}
function ic(l) {
return Uint8Array.from(unescape(encodeURIComponent(l)), (t) => t.charCodeAt(0));
}
var Vt = {
CLEARKEY: "org.w3.clearkey",
FAIRPLAY: "com.apple.fps",
PLAYREADY: "com.microsoft.playready",
WIDEVINE: "com.widevine.alpha"
}, Se = {
CLEARKEY: "org.w3.clearkey",
FAIRPLAY: "com.apple.streamingkeydelivery",
PLAYREADY: "com.microsoft.playready",
WIDEVINE: "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
};
function ah(l) {
switch (l) {
case Se.FAIRPLAY:
return Vt.FAIRPLAY;
case Se.PLAYREADY:
return Vt.PLAYREADY;
case Se.WIDEVINE:
return Vt.WIDEVINE;
case Se.CLEARKEY:
return Vt.CLEARKEY;
}
}
var nc = {
WIDEVINE: "edef8ba979d64acea3c827dcd51d21ed"
};
function ey(l) {
if (l === nc.WIDEVINE)
return Vt.WIDEVINE;
}
function oh(l) {
switch (l) {
case Vt.FAIRPLAY:
return Se.FAIRPLAY;
case Vt.PLAYREADY:
return Se.PLAYREADY;
case Vt.WIDEVINE:
return Se.WIDEVINE;
case Vt.CLEARKEY:
return Se.CLEARKEY;
}
}
function ba(l) {
const {
drmSystems: t,
widevineLicenseUrl: e
} = l, i = t ? [Vt.FAIRPLAY, Vt.WIDEVINE, Vt.PLAYREADY, Vt.CLEARKEY].filter((r) => !!t[r]) : [];
return !i[Vt.WIDEVINE] && e && i.push(Vt.WIDEVINE), i;
}
const rc = function() {
return typeof self < "u" && self.navigator && self.navigator.requestMediaKeySystemAccess ? self.navigator.requestMediaKeySystemAccess.bind(self.navigator) : null;
}();
function iy(l, t, e, i) {
let r;
switch (l) {
case Vt.FAIRPLAY:
r = ["cenc", "sinf"];
break;
case Vt.WIDEVINE:
case Vt.PLAYREADY:
r = ["cenc"];
break;
case Vt.CLEARKEY:
r = ["cenc", "keyids"];
break;
default:
throw new Error(`Unknown key-system: ${l}`);
}
return ny(r, t, e, i);
}
function ny(l, t, e, i) {
return [{
initDataTypes: l,
persistentState: i.persistentState || "not-allowed",
distinctiveIdentifier: i.distinctiveIdentifier || "not-allowed",
sessionTypes: i.sessionTypes || [i.sessionType || "temporary"],
audioCapabilities: t.map((s) => ({
contentType: `audio/mp4; codecs="${s}"`,
robustness: i.audioRobustness || "",
encryptionScheme: i.audioEncryptionScheme || null
})),
videoCapabilities: e.map((s) => ({
contentType: `video/mp4; codecs="${s}"`,
robustness: i.videoRobustness || "",
encryptionScheme: i.videoEncryptionScheme || null
}))
}];
}
function Xi(l, t, e) {
return Uint8Array.prototype.slice ? l.slice(t, e) : new Uint8Array(Array.prototype.slice.call(l, t, e));
}
const go = (l, t) => t + 10 <= l.length && l[t] === 73 && l[t + 1] === 68 && l[t + 2] === 51 && l[t + 3] < 255 && l[t + 4] < 255 && l[t + 6] < 128 && l[t + 7] < 128 && l[t + 8] < 128 && l[t + 9] < 128, sc = (l, t) => t + 10 <= l.length && l[t] === 51 && l[t + 1] === 68 && l[t + 2] === 73 && l[t + 3] < 255 && l[t + 4] < 255 && l[t + 6] < 128 && l[t + 7] < 128 && l[t + 8] < 128 && l[t + 9] < 128, Qr = (l, t) => {
const e = t;
let i = 0;
for (; go(l, t); ) {
i += 10;
const r = ss(l, t + 6);
i += r, sc(l, t + 10) && (i += 10), t += i;
}
if (i > 0)
return l.subarray(e, e + i);
}, ss = (l, t) => {
let e = 0;
return e = (l[t] & 127) << 21, e |= (l[t + 1] & 127) << 14, e |= (l[t + 2] & 127) << 7, e |= l[t + 3] & 127, e;
}, ry = (l, t) => go(l, t) && ss(l, t + 6) + 10 <= l.length - t, sy = (l) => {
const t = oc(l);
for (let e = 0; e < t.length; e++) {
const i = t[e];
if (ac(i))
return cy(i);
}
}, ac = (l) => l && l.key === "PRIV" && l.info === "com.apple.streaming.transportStreamTimestamp", ay = (l) => {
const t = String.fromCharCode(l[0], l[1], l[2], l[3]), e = ss(l, 4), i = 10;
return {
type: t,
size: e,
data: l.subarray(i, i + e)
};
}, oc = (l) => {
let t = 0;
const e = [];
for (; go(l, t); ) {
const i = ss(l, t + 6);
t += 10;
const r = t + i;
for (; t + 8 < r; ) {
const s = ay(l.subarray(t)), o = oy(s);
o && e.push(o), t += s.size + 10;
}
sc(l, t) && (t += 10);
}
return e;
}, oy = (l) => l.type === "PRIV" ? ly(l) : l.type[0] === "W" ? hy(l) : uy(l), ly = (l) => {
if (l.size < 2)
return;
const t = li(l.data, !0), e = new Uint8Array(l.data.subarray(t.length + 1));
return {
key: l.type,
info: t,
data: e.buffer
};
}, uy = (l) => {
if (l.size < 2)
return;
if (l.type === "TXXX") {
let e = 1;
const i = li(l.data.subarray(e), !0);
e += i.length + 1;
const r = li(l.data.subarray(e));
return {
key: l.type,
info: i,
data: r
};
}
const t = li(l.data.subarray(1));
return {
key: l.type,
data: t
};
}, hy = (l) => {
if (l.type === "WXXX") {
if (l.size < 2)
return;
let e = 1;
const i = li(l.data.subarray(e), !0);
e += i.length + 1;
const r = li(l.data.subarray(e));
return {
key: l.type,
info: i,
data: r
};
}
const t = li(l.data);
return {
key: l.type,
data: t
};
}, cy = (l) => {
if (l.data.byteLength === 8) {
const t = new Uint8Array(l.data), e = t[3] & 1;
let i = (t[4] << 23) + (t[5] << 15) + (t[6] << 7) + t[7];
return i /= 45, e && (i += 4772185884e-2), Math.round(i);
}
}, li = (l, t = !1) => {
const e = fy();
if (e) {
const f = e.decode(l);
if (t) {
const d = f.indexOf("\0");
return d !== -1 ? f.substring(0, d) : f;
}
return f.replace(/\0/g, "");
}
const i = l.length;
let r, s, o, u = "", c = 0;
for (; c < i; ) {
if (r = l[c++], r === 0 && t)
return u;
if (r === 0 || r === 3)
continue;
switch (r >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
u += String.fromCharCode(r);
break;
case 12:
case 13:
s = l[c++], u += String.fromCharCode((r & 31) << 6 | s & 63);
break;
case 14:
s = l[c++], o = l[c++], u += String.fromCharCode((r & 15) << 12 | (s & 63) << 6 | (o & 63) << 0);
break;
}
}
return u;
};
let Ca;
function fy() {
return !Ca && typeof self.TextDecoder < "u" && (Ca = new self.TextDecoder("utf-8")), Ca;
}
const si = {
hexDump: function(l) {
let t = "";
for (let e = 0; e < l.length; e++) {
let i = l[e].toString(16);
i.length < 2 && (i = "0" + i), t += i;
}
return t;
}
}, Zr = Math.pow(2, 32) - 1, dy = [].push, lc = {
video: 1,
audio: 2,
id3: 3,
text: 4
};
function re(l) {
return String.fromCharCode.apply(null, l);
}
function uc(l, t) {
const e = l[t] << 8 | l[t + 1];
return e < 0 ? 65536 + e : e;
}
function Tt(l, t) {
const e = hc(l, t);
return e < 0 ? 4294967296 + e : e;
}
function hc(l, t) {
return l[t] << 24 | l[t + 1] << 16 | l[t + 2] << 8 | l[t + 3];
}
function wa(l, t, e) {
l[t] = e >> 24, l[t + 1] = e >> 16 & 255, l[t + 2] = e >> 8 & 255, l[t + 3] = e & 255;
}
function Ct(l, t) {
const e = [];
if (!t.length)
return e;
const i = l.byteLength;
for (let r = 0; r < i; ) {
const s = Tt(l, r), o = re(l.subarray(r + 4, r + 8)), u = s > 1 ? r + s : i;
if (o === t[0])
if (t.length === 1)
e.push(l.subarray(r + 8, u));
else {
const c = Ct(l.subarray(r + 8, u), t.slice(1));
c.length && dy.apply(e, c);
}
r = u;
}
return e;
}
function gy(l) {
const t = [], e = l[0];
let i = 8;
const r = Tt(l, i);
i += 4;
const s = 0, o = 0;
e === 0 ? i += 8 : i += 16, i += 2;
let u = l.length + o;
const c = uc(l, i);
i += 2;
for (let f = 0; f < c; f++) {
let d = i;
const g = Tt(l, d);
d += 4;
const p = g & 2147483647;
if ((g & 2147483648) >>> 31 === 1)
return G.warn("SIDX has hierarchical references (not supported)"), null;
const E = Tt(l, d);
d += 4, t.push({
referenceSize: p,
subsegmentDuration: E,
// unscaled
info: {
duration: E / r,
start: u,
end: u + p - 1
}
}), u += p, d += 4, i = d;
}
return {
earliestPresentationTime: s,
timescale: r,
version: e,
referencesCount: c,
references: t
};
}
function cc(l) {
const t = [], e = Ct(l, ["moov", "trak"]);
for (let r = 0; r < e.length; r++) {
const s = e[r], o = Ct(s, ["tkhd"])[0];
if (o) {
let u = o[0], c = u === 0 ? 12 : 20;
const f = Tt(o, c), d = Ct(s, ["mdia", "mdhd"])[0];
if (d) {
u = d[0], c = u === 0 ? 12 : 20;
const g = Tt(d, c), p = Ct(s, ["mdia", "hdlr"])[0];
if (p) {
const T = re(p.subarray(8, 12)), E = {
soun: Ft.AUDIO,
vide: Ft.VIDEO
}[T];
if (E) {
const L = Ct(s, ["mdia", "minf", "stbl", "stsd"])[0];
let S;
L && (S = re(L.subarray(12, 16))), t[f] = {
timescale: g,
type: E
}, t[E] = {
timescale: g,
id: f,
codec: S
};
}
}
}
}
}
return Ct(l, ["moov", "mvex", "trex"]).forEach((r) => {
const s = Tt(r, 4), o = t[s];
o && (o.default = {
duration: Tt(r, 12),
flags: Tt(r, 20)
});
}), t;
}
function my(l, t) {
if (!l || !t)
return l;
const e = t.keyId;
return e && t.isCommonEncryption && Ct(l, ["moov", "trak"]).forEach((r) => {
const o = Ct(r, ["mdia", "minf", "stbl", "stsd"])[0].subarray(8);
let u = Ct(o, ["enca"]);
const c = u.length > 0;
c || (u = Ct(o, ["encv"])), u.forEach((f) => {
const d = c ? f.subarray(28) : f.subarray(78);
Ct(d, ["sinf"]).forEach((p) => {
const T = fc(p);
if (T) {
const E = T.subarray(8, 24);
E.some((L) => L !== 0) || (G.log(`[eme] Patching keyId in 'enc${c ? "a" : "v"}>sinf>>tenc' box: ${si.hexDump(E)} -> ${si.hexDump(e)}`), T.set(e, 8));
}
});
});
}), l;
}
function fc(l) {
const t = Ct(l, ["schm"])[0];
if (t) {
const e = re(t.subarray(4, 8));
if (e === "cbcs" || e === "cenc")
return Ct(l, ["schi", "tenc"])[0];
}
return G.error("[eme] missing 'schm' box"), null;
}
function py(l, t) {
return Ct(t, ["moof", "traf"]).reduce((e, i) => {
const r = Ct(i, ["tfdt"])[0], s = r[0], o = Ct(i, ["tfhd"]).reduce((u, c) => {
const f = Tt(c, 4), d = l[f];
if (d) {
let g = Tt(r, 4);
if (s === 1) {
if (g === Zr)
return G.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"), u;
g *= Zr + 1, g += Tt(r, 8);
}
const p = d.timescale || 9e4, T = g / p;
if (isFinite(T) && (u === null || T < u))
return T;
}
return u;
}, null);
return o !== null && isFinite(o) && (e === null || o < e) ? o : e;
}, null);
}
function Ty(l, t) {
let e = 0, i = 0, r = 0;
const s = Ct(l, ["moof", "traf"]);
for (let o = 0; o < s.length; o++) {
const u = s[o], c = Ct(u, ["tfhd"])[0], f = Tt(c, 4), d = t[f];
if (!d)
continue;
const g = d.default, p = Tt(c, 0) | (g == null ? void 0 : g.flags);
let T = g == null ? void 0 : g.duration;
p & 8 && (p & 2 ? T = Tt(c, 12) : T = Tt(c, 8));
const E = d.timescale || 9e4, L = Ct(u, ["trun"]);
for (let S = 0; S < L.length; S++) {
if (e = Ey(L[S]), !e && T) {
const _ = Tt(L[S], 4);
e = T * _;
}
d.type === Ft.VIDEO ? i += e / E : d.type === Ft.AUDIO && (r += e / E);
}
}
if (i === 0 && r === 0) {
let o = 0;
const u = Ct(l, ["sidx"]);
for (let c = 0; c < u.length; c++) {
const f = gy(u[c]);
f != null && f.references && (o += f.references.reduce((d, g) => d + g.info.duration || 0, 0));
}
return o;
}
return i || r;
}
function Ey(l) {
const t = Tt(l, 0);
let e = 8;
t & 1 && (e += 4), t & 4 && (e += 4);
let i = 0;
const r = Tt(l, 4);
for (let s = 0; s < r; s++) {
if (t & 256) {
const o = Tt(l, e);
i += o, e += 4;
}
t & 512 && (e += 4), t & 1024 && (e += 4), t & 2048 && (e += 4);
}
return i;
}
function yy(l, t, e) {
Ct(t, ["moof", "traf"]).forEach((i) => {
Ct(i, ["tfhd"]).forEach((r) => {
const s = Tt(r, 4), o = l[s];
if (!o)
return;
const u = o.timescale || 9e4;
Ct(i, ["tfdt"]).forEach((c) => {
const f = c[0];
let d = Tt(c, 4);
if (f === 0)
d -= e * u, d = Math.max(d, 0), wa(c, 4, d);
else {
d *= Math.pow(2, 32), d += Tt(c, 8), d -= e * u, d = Math.max(d, 0);
const g = Math.floor(d / (Zr + 1)), p = Math.floor(d % (Zr + 1));
wa(c, 4, g), wa(c, 8, p);
}
});
});
});
}
function xy(l) {
const t = {
valid: null,
remainder: null
}, e = Ct(l, ["moof"]);
if (e) {
if (e.length < 2)
return t.remainder = l, t;
} else
return t;
const i = e[e.length - 1];
return t.valid = Xi(l, 0, i.byteOffset - 8), t.remainder = Xi(l, i.byteOffset - 8), t;
}
function ji(l, t) {
const e = new Uint8Array(l.length + t.length);
return e.set(l), e.set(t, l.length), e;
}
function lh(l, t) {
const e = [], i = t.samples, r = t.timescale, s = t.id;
let o = !1;
return Ct(i, ["moof"]).map((c) => {
const f = c.byteOffset - 8;
Ct(c, ["traf"]).map((g) => {
const p = Ct(g, ["tfdt"]).map((T) => {
const E = T[0];
let L = Tt(T, 4);
return E === 1 && (L *= Math.pow(2, 32), L += Tt(T, 8)), L / r;
})[0];
return p !== void 0 && (l = p), Ct(g, ["tfhd"]).map((T) => {
const E = Tt(T, 4), L = Tt(T, 0) & 16777215, S = (L & 1) !== 0, _ = (L & 2) !== 0, V = (L & 8) !== 0;
let k = 0;
const X = (L & 16) !== 0;
let H = 0;
const it = (L & 32) !== 0;
let x = 8;
E === s && (S && (x += 8), _ && (x += 4), V && (k = Tt(T, x), x += 4), X && (H = Tt(T, x), x += 4), it && (x += 4), t.type === "video" && (o = vy(t.codec)), Ct(g, ["trun"]).map((R) => {
const D = R[0], b = Tt(R, 0) & 16777215, w = (b & 1) !== 0;
let O = 0;
const W = (b & 4) !== 0, F = (b & 256) !== 0;
let N = 0;
const K = (b & 512) !== 0;
let M = 0;
const $ = (b & 1024) !== 0, J = (b & 2048) !== 0;
let nt = 0;
const st = Tt(R, 4);
let lt = 8;
w && (O = Tt(R, lt), lt += 4), W && (lt += 4);
let vt = O + f;
for (let mt = 0; mt < st; mt++) {
if (F ? (N = Tt(R, lt), lt += 4) : N = k, K ? (M = Tt(R, lt), lt += 4) : M = H, $ && (lt += 4), J && (D === 0 ? nt = Tt(R, lt) : nt = hc(R, lt), lt += 4), t.type === Ft.VIDEO) {
let pt = 0;
for (; pt < M; ) {
const Dt = Tt(i, vt);
if (vt += 4, Sy(o, i[vt])) {
const ce = i.subarray(vt, vt + Dt);
dc(ce, o ? 2 : 1, l + nt / r, e);
}
vt += Dt, pt += Dt + 4;
}
}
l += N / r;
}
}));
});
});
}), e;
}
function vy(l) {
if (!l)
return !1;
const t = l.indexOf("."), e = t < 0 ? l : l.substring(0, t);
return e === "hvc1" || e === "hev1" || // Dolby Vision
e === "dvh1" || e === "dvhe";
}
function Sy(l, t) {
if (l) {
const e = t >> 1 & 63;
return e === 39 || e === 40;
} else
return (t & 31) === 6;
}
function dc(l, t, e, i) {
const r = gc(l);
let s = 0;
s += t;
let o = 0, u = 0, c = !1, f = 0;
for (; s < r.length; ) {
o = 0;
do {
if (s >= r.length)
break;
f = r[s++], o += f;
} while (f === 255);
u = 0;
do {
if (s >= r.length)
break;
f = r[s++], u += f;
} while (f === 255);
const d = r.length - s;
if (!c && o === 4 && s < r.length) {
if (c = !0, r[s++] === 181) {
const p = uc(r, s);
if (s += 2, p === 49) {
const T = Tt(r, s);
if (s += 4, T === 1195456820) {
const E = r[s++];
if (E === 3) {
const L = r[s++], S = 31 & L, _ = 64 & L, V = _ ? 2 + S * 3 : 0, k = new Uint8Array(V);
if (_) {
k[0] = L;
for (let X = 1; X < V; X++)
k[X] = r[s++];
}
i.push({
type: E,
payloadType: o,
pts: e,
bytes: k
});
}
}
}
}
} else if (o === 5 && u < d) {
if (c = !0, u > 16) {
const g = [];
for (let E = 0; E < 16; E++) {
const L = r[s++].toString(16);
g.push(L.length == 1 ? "0" + L : L), (E === 3 || E === 5 || E === 7 || E === 9) && g.push("-");
}
const p = u - 16, T = new Uint8Array(p);
for (let E = 0; E < p; E++)
T[E] = r[s++];
i.push({
payloadType: o,
pts: e,
uuid: g.join(""),
userData: li(T),
userDataBytes: T
});
}
} else if (u < d)
s += u;
else if (u > d)
break;
}
}
function gc(l) {
const t = l.byteLength, e = [];
let i = 1;
for (; i < t - 2; )
l[i] === 0 && l[i + 1] === 0 && l[i + 2] === 3 ? (e.push(i + 2), i += 2) : i++;
if (e.length === 0)
return l;
const r = t - e.length, s = new Uint8Array(r);
let o = 0;
for (i = 0; i < r; o++, i++)
o === e[0] && (o++, e.shift()), s[i] = l[o];
return s;
}
function Ay(l) {
const t = l[0];
let e = "", i = "", r = 0, s = 0, o = 0, u = 0, c = 0, f = 0;
if (t === 0) {
for (; re(l.subarray(f, f + 1)) !== "\0"; )
e += re(l.subarray(f, f + 1)), f += 1;
for (e += re(l.subarray(f, f + 1)), f += 1; re(l.subarray(f, f + 1)) !== "\0"; )
i += re(l.subarray(f, f + 1)), f += 1;
i += re(l.subarray(f, f + 1)), f += 1, r = Tt(l, 12), s = Tt(l, 16), u = Tt(l, 20), c = Tt(l, 24), f = 28;
} else if (t === 1) {
f += 4, r = Tt(l, f), f += 4;
const g = Tt(l, f);
f += 4;
const p = Tt(l, f);
for (f += 4, o = 2 ** 32 * g + p, Number.isSafeInteger(o) || (o = Number.MAX_SAFE_INTEGER, G.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")), u = Tt(l, f), f += 4, c = Tt(l, f), f += 4; re(l.subarray(f, f + 1)) !== "\0"; )
e += re(l.subarray(f, f + 1)), f += 1;
for (e += re(l.subarray(f, f + 1)), f += 1; re(l.subarray(f, f + 1)) !== "\0"; )
i += re(l.subarray(f, f + 1)), f += 1;
i += re(l.subarray(f, f + 1)), f += 1;
}
const d = l.subarray(f, l.byteLength);
return {
schemeIdUri: e,
value: i,
timeScale: r,
presentationTime: o,
presentationTimeDelta: s,
eventDuration: u,
id: c,
payload: d
};
}
function Ly(l, ...t) {
const e = t.length;
let i = 8, r = e;
for (; r--; )
i += t[r].byteLength;
const s = new Uint8Array(i);
for (s[0] = i >> 24 & 255, s[1] = i >> 16 & 255, s[2] = i >> 8 & 255, s[3] = i & 255, s.set(l, 4), r = 0, i = 8; r < e; r++)
s.set(t[r], i), i += t[r].byteLength;
return s;
}
function Ry(l, t, e) {
if (l.byteLength !== 16)
throw new RangeError("Invalid system id");
let i, r;
if (t) {
i = 1, r = new Uint8Array(t.length * 16);
for (let u = 0; u < t.length; u++) {
const c = t[u];
if (c.byteLength !== 16)
throw new RangeError("Invalid key");
r.set(c, u * 16);
}
} else
i = 0, r = new Uint8Array();
let s;
i > 0 ? (s = new Uint8Array(4), t.length > 0 && new DataView(s.buffer).setUint32(0, t.length, !1)) : s = new Uint8Array();
const o = new Uint8Array(4);
return e && e.byteLength > 0 && new DataView(o.buffer).setUint32(0, e.byteLength, !1), Ly(
[112, 115, 115, 104],
new Uint8Array([
i,
0,
0,
0
// Flags
]),
l,
// 16 bytes
s,
r,
o,
e || new Uint8Array()
);
}
function Iy(l) {
if (!(l instanceof ArrayBuffer) || l.byteLength < 32)
return null;
const t = {
version: 0,
systemId: "",
kids: null,
data: null
}, e = new DataView(l), i = e.getUint32(0);
if (l.byteLength !== i && i > 44 || e.getUint32(4) !== 1886614376 || (t.version = e.getUint32(8) >>> 24, t.version > 1))
return null;
t.systemId = si.hexDump(new Uint8Array(l, 12, 16));
const s = e.getUint32(28);
if (t.version === 0) {
if (i - 32 < s)
return null;
t.data = new Uint8Array(l, 32, s);
} else if (t.version === 1) {
t.kids = [];
for (let o = 0; o < s; o++)
t.kids.push(new Uint8Array(l, 32 + o * 16, 16));
}
return t;
}
let Nr = {};
class Wn {
static clearKeyUriToKeyIdMap() {
Nr = {};
}
constructor(t, e, i, r = [1], s = null) {
this.uri = void 0, this.method = void 0, this.keyFormat = void 0, this.keyFormatVersions = void 0, this.encrypted = void 0, this.isCommonEncryption = void 0, this.iv = null, this.key = null, this.keyId = null, this.pssh = null, this.method = t, this.uri = e, this.keyFormat = i, this.keyFormatVersions = r, this.iv = s, this.encrypted = t ? t !== "NONE" : !1, this.isCommonEncryption = this.encrypted && t !== "AES-128";
}
isSupported() {
if (this.method) {
if (this.method === "AES-128" || this.method === "NONE")
return !0;
if (this.keyFormat === "identity")
return this.method === "SAMPLE-AES";
switch (this.keyFormat) {
case Se.FAIRPLAY:
case Se.WIDEVINE:
case Se.PLAYREADY:
case Se.CLEARKEY:
return ["ISO-23001-7", "SAMPLE-AES", "SAMPLE-AES-CENC", "SAMPLE-AES-CTR"].indexOf(this.method) !== -1;
}
}
return !1;
}
getDecryptData(t) {
if (!this.encrypted || !this.uri)
return null;
if (this.method === "AES-128" && this.uri && !this.iv) {
typeof t != "number" && (this.method === "AES-128" && !this.iv && G.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`), t = 0);
const i = _y(t);
return new Wn(this.method, this.uri, "identity", this.keyFormatVersions, i);
}
const e = ty(this.uri);
if (e)
switch (this.keyFormat) {
case Se.WIDEVINE:
this.pssh = e, e.length >= 22 && (this.keyId = e.subarray(e.length - 22, e.length - 6));
break;
case Se.PLAYREADY: {
const i = new Uint8Array([154, 4, 240, 121, 152, 64, 66, 134, 171, 146, 230, 91, 224, 136, 95, 149]);
this.pssh = Ry(i, null, e);
const r = new Uint16Array(e.buffer, e.byteOffset, e.byteLength / 2), s = String.fromCharCode.apply(null, Array.from(r)), o = s.substring(s.indexOf("<"), s.length), f = new DOMParser().parseFromString(o, "text/xml").getElementsByTagName("KID")[0];
if (f) {
const d = f.childNodes[0] ? f.childNodes[0].nodeValue : f.getAttribute("VALUE");
if (d) {
const g = fo(d).subarray(0, 16);
JE(g), this.keyId = g;
}
}
break;
}
default: {
let i = e.subarray(0, 16);
if (i.length !== 16) {
const r = new Uint8Array(16);
r.set(i, 16 - i.length), i = r;
}
this.keyId = i;
break;
}
}
if (!this.keyId || this.keyId.byteLength !== 16) {
let i = Nr[this.uri];
if (!i) {
const r = Object.keys(Nr).length % Number.MAX_SAFE_INTEGER;
i = new Uint8Array(16), new DataView(i.buffer, 12, 4).setUint32(0, r), Nr[this.uri] = i;
}
this.keyId = i;
}
return this;
}
}
function _y(l) {
const t = new Uint8Array(16);
for (let e = 12; e < 16; e++)
t[e] = l >> 8 * (15 - e) & 255;
return t;
}
const mc = /\{\$([a-zA-Z0-9-_]+)\}/g;
function uh(l) {
return mc.test(l);
}
function ye(l, t, e) {
if (l.variableList !== null || l.hasVariableRefs)
for (let i = e.length; i--; ) {
const r = e[i], s = t[r];
s && (t[r] = io(l, s));
}
}
function io(l, t) {
if (l.variableList !== null || l.hasVariableRefs) {
const e = l.variableList;
return t.replace(mc, (i) => {
const r = i.substring(2, i.length - 1), s = e == null ? void 0 : e[r];
return s === void 0 ? (l.playlistParsingError || (l.playlistParsingError = new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)), i) : s;
});
}
return t;
}
function hh(l, t, e) {
let i = l.variableList;
i || (l.variableList = i = {});
let r, s;
if ("QUERYPARAM" in t) {
r = t.QUERYPARAM;
try {
const o = new self.URL(e).searchParams;
if (o.has(r))
s = o.get(r);
else
throw new Error(`"${r}" does not match any query parameter in URI: "${e}"`);
} catch (o) {
l.playlistParsingError || (l.playlistParsingError = new Error(`EXT-X-DEFINE QUERYPARAM: ${o.message}`));
}
} else
r = t.NAME, s = t.VALUE;
r in i ? l.playlistParsingError || (l.playlistParsingError = new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)) : i[r] = s || "";
}
function Dy(l, t, e) {
const i = t.IMPORT;
if (e && i in e) {
let r = l.variableList;
r || (l.variableList = r = {}), r[i] = e[i];
} else
l.playlistParsingError || (l.playlistParsingError = new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`));
}
function as() {
if (!(typeof self > "u"))
return self.MediaSource || self.WebKitMediaSource;
}
const by = {
audio: {
a3ds: !0,
"ac-3": !0,
"ac-4": !0,
alac: !0,
alaw: !0,
dra1: !0,
"dts+": !0,
"dts-": !0,
dtsc: !0,
dtse: !0,
dtsh: !0,
"ec-