PageSourceSearch

https://cdn-web.gettr.com/static/js/hls.314c5918.chunk.js

js gettr.com collected 2026-10-01 08:41:28 UTC 364,940 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkgetter_fe=self.webpackChunkgetter_fe||[]).push([[4817],{61694:(t,e,s)=>{function i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}s.r(e),s.d(e,{default:()=>An});var r,n={exports:{}};r=n,function(t){var e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(t,e,i){if(i=i||{},t=t.trim(),!(e=e.trim())){if(!i.alwaysNormalize)return t;var r=a.parseURL(t);if(!r)throw new Error("Error trying to parse base URL.");return r.path=a.normalizePath(r.path),a.buildURLFromParts(r)}var n=a.parseURL(e);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return i.alwaysNormalize?(n.path=a.normalizePath(n.path),a.buildURLFromParts(n)):e;var o=a.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=s.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var c={scheme:o.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(c.netLoc=o.netLoc,"/"!==n.path[0]))if(n.path){var h=o.path,d=h.substring(0,h.lastIndexOf("/")+1)+n.path;c.path=a.normalizePath(d)}else c.path=o.path,n.params||(c.params=o.params,n.query||(c.query=o.query));return null===c.path&&(c.path=i.alwaysNormalize?a.normalizePath(n.path):n.path),a.buildURLFromParts(c)},parseURL:function(t){var s=e.exec(t);return s?{scheme:s[1]||"",netLoc:s[2]||"",path:s[3]||"",params:s[4]||"",query:s[5]||"",fragment:s[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(i,"");t.length!==(t=t.replace(n,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}};r.exports=a}();var a=n.exports;function o(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,i)}return s}function l(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?o(Object(s),!0).forEach((function(e){c(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):o(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}function c(t,e,s){return(e=function(t){var e=function(t,e){if("object"!==typeof t||null===t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,e||"default");if("object"!==typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function h(){return h=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},h.apply(this,arguments)}const d=Number.isFinite||function(t){return"number"===typeof t&&isFinite(t)};
1let u=function(t){return t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached",t}({}),f=function(t){return t.NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError",t}({}),g=function(t){return t.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",t.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",t.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",t.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_PARSING_ERROR="levelParsingError",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.FRAG_GAP="fragGap",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown",t}({});const m=function(){},p={trace:m,debug:m,log:m,warn:m,info:m,error:m};let y=p;function T(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];
vendor: 12,058 bytes, line 1
1s.forEach((function(e){y[e]=t[e]?t[e].bind(t):function(t){const e=self.console[t];return e?e.bind(self.console,"[".concat(t,"] >")):m}(e)}))}const v=y,E=/^(\d+)x(\d+)$/,S=/(.+?)=(".*?"|.*?)(?:,|$)/g;class L{constructor(t){"string"===typeof t&&(t=L.parseAttrList(t));for(const e in t)t.hasOwnProperty(e)&&("X-"===e.substring(0,2)&&(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=(1&e.length?"0":"")+e;const s=new Uint8Array(e.length/2);for(let t=0;t<e.length/2;t++)s[t]=parseInt(e.slice(2*t,2*t+2),16);return s}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 s=this[t];return s?parseFloat(s):e}enumeratedString(t){return this[t]}bool(t){return"YES"===this[t]}decimalResolution(t){const e=E.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const s={};for(S.lastIndex=0;null!==(e=S.exec(t));){let t=e[2];0===t.indexOf('"')&&t.lastIndexOf('"')===t.length-1&&(t=t.slice(1,-1));s[e[1].trim()]=t}return s}}function A(t){return"SCTE35-OUT"===t||"SCTE35-IN"===t}class R{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){const s=e.attr;for(const e in s)if(Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==s[e]){v.warn('DATERANGE tag attribute: "'.concat(e,'" does not match for tags with ID: "').concat(t.ID,'"')),this._badValueForSameId=e;break}t=h(new L({}),s,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const t=new Date(this.attr["END-DATE"]);d(t.getTime())&&(this._endDate=t)}}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 null!==t?new Date(this._startDate.getTime()+1e3*t):null}get duration(){if("DURATION"in this.attr){const t=this.attr.decimalFloatingPoint("DURATION");if(d(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&&d(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class b{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 k="audio",D="video",I="audiovideo";class w{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[k]:null,[D]:null,[I]:null},this.baseurl=t}setByteRange(t,e){const s=t.split("@",2),i=[];1===s.length?i[0]=e?e.byteRangeEndOffset:0:i[0]=parseInt(s[1]),i[1]=parseInt(s[0])+i[0],this._byteRange=i}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=a.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class C extends w{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 b,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 t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const t=Object.keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;if(!d(this.programDateTime))return null;const t=d(this.duration)?this.duration:0;return this.programDateTime+1e3*t}get encrypted(){var t;if(null!=(t=this._decryptdata)&&t.encrypted)return!0;if(this.levelkeys){const t=Object.keys(this.levelkeys),e=t.length;if(e>1||1===e&&this.levelkeys[t[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;null==(t=this.loader)||t.abort(),null==(e=this.keyLoader)||e.abort()}setElementaryStreamInfo(t,e,s,i,r){let n=arguments.length>5&&void 0!==arguments[5]&&arguments[5];const{elementaryStreams:a}=this,o=a[t];o?(o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,s),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,r)):a[t]={startPTS:e,endPTS:s,startDTS:i,endDTS:r,partial:n}}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[k]=null,t[D]=null,t[I]=null}}class _ extends w{constructor(t,e,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.stats=new b,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=i;const n=t.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:t}=this;return!!(t.audio||t.video||t.audiovideo)}}class P{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)return this.advanced=!0,void(this.updated=!0);const e=this.lastPartSn-t.lastPartSn,s=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!s||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||0===e&&s>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay}get hasProgramDateTime(){return!!this.fragments.length&&d(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const t=this.driftEndTime-this.driftStartTime;if(t>0){return 1e3*(this.driftEnd-this.driftStart)/t}return 1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var t;return null!=(t=this.fragments)&&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 null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function x(t){return Uint8Array.from(atob(t),(t=>t.charCodeAt(0)))}function F(t){const e=t.split(":");let s=null;if("data"===e[0]&&2===e.length){const t=e[1].split(";"),i=t[t.length-1].split(",");if(2===i.length){const e="base64"===i[0],r=i[1];e?(t.splice(-1,1),s=x(r)):s=function(t){const e=M(t).subarray(0,16),s=new Uint8Array(16);return s.set(e,16-e.length),s}(r)}}return s}function M(t){return Uint8Array.from(unescape(encodeURIComponent(t)),(t=>t.charCodeAt(0)))}var O={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},N="org.w3.clearkey",U="com.apple.streamingkeydelivery",B="com.microsoft.playready",G="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function K(t){switch(t){case U:return O.FAIRPLAY;case B:return O.PLAYREADY;case G:return O.WIDEVINE;case N:return O.CLEARKEY}}var H="edef8ba979d64acea3c827dcd51d21ed";function V(t){switch(t){case O.FAIRPLAY:return U;case O.PLAYREADY:return B;case O.WIDEVINE:return G;case O.CLEARKEY:return N}}function Y(t){const{drmSystems:e,widevineLicenseUrl:s}=t,i=e?[O.FAIRPLAY,O.WIDEVINE,O.PLAYREADY,O.CLEARKEY].filter((t=>!!e[t])):[];return!i[O.WIDEVINE]&&s&&i.push(O.WIDEVINE),i}const W="undefined"!==typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function q(t,e,s){return Uint8Array.prototype.slice?t.slice(e,s):new Uint8Array(Array.prototype.slice.call(t,e,s))}const j=(t,e)=>e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128,X=(t,e)=>e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128,z=(t,e)=>{const s=e;let i=0;for(;j(t,e);){i+=10;i+=Q(t,e+6),X(t,e+10)&&(i+=10),e+=i}if(i>0)return t.subarray(s,s+i)},Q=(t,e)=>{let s=0;return s=(127&t[e])<<21,s|=(127&t[e+1])<<14,s|=(127&t[e+2])<<7,s|=127&t[e+3],s},$=(t,e)=>j(t,e)&&Q(t,e+6)+10<=t.length-e,J=t=>t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info,Z=t=>{const e=String.fromCharCode(t[0],t[1],t[2],t[3]),s=Q(t,4);return{type:e,size:s,data:t.subarray(10,10+s)}},tt=t=>{let e=0;const s=[];for(;j(t,e);){const i=Q(t,e+6);e+=10;const r=e+i;for(;e+8<r;){const i=Z(t.subarray(e)),r=et(i);r&&s.push(r),e+=i.size+10}X(t,e)&&(e+=10)}return s},et=t=>"PRIV"===t.type?st(t):"W"===t.type[0]?rt(t):it(t),st=t=>{if(t.size<2)return;const e=at(t.data,!0),s=new Uint8Array(t.data.subarray(e.length+1));return{key:t.type,info:e,data:s.buffer}},it=t=>{if(t.size<2)return;if("TXXX"===t.type){let e=1;const s=at(t.data.subarray(e),!0);e+=s.length+1;const i=at(t.data.subarray(e));return{key:t.type,info:s,data:i}}const e=at(t.data.subarray(1));return{key:t.type,data:e}},rt=t=>{if("WXXX"===t.type){if(t.size<2)return;let e=1;const s=at(t.data.subarray(e),!0);e+=s.length+1;const i=at(t.data.subarray(e));return{key:t.type,info:s,data:i}}const e=at(t.data);return{key:t.type,data:e}},nt=t=>{if(8===t.data.byteLength){const e=new Uint8Array(t.data),s=1&e[3];let i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,s&&(i+=47721858.84),Math.round(i)}},at=function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const s=lt();if(s){const i=s.decode(t);if(e){const t=i.indexOf("\0");return-1!==t?i.substring(0,t):i}return i.replace(/\0/g,"")}const i=t.length;let r,n,a,o="",l=0;for(;l<i;){if(r=t[l++],0===r&&e)return o;if(0!==r&&3!==r)switch(r>>
14){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(r);break;case 12:case 13:n=t[l++],o+=String.fromCharCode((31&r)<<6|63&n);break;case 14:n=t[l++],a=t[l++],o+=String.fromCharCode((15&r)<<12|(63&n)<<6|(63&a)<<0)}}return o};let ot;function lt(){return ot||"undefined"===typeof self.TextDecoder||(ot=new self.TextDecoder("utf-8")),ot}const ct=function(t){let e="";for(let s=0;s<t.length;s++){let i=t[s].toString(16);i.length<2&&(i="0"+i),e+=i}return e},ht=Math.pow(2,32)-1,dt=[].push,ut={video:1,audio:2,id3:3,text:4};function ft(t){return String.fromCharCode.apply(null,t)}function gt(t,e){const s=t[e]<<8|t[e+1];return s<0?65536+s:s}function mt(t,e){const s=pt(t,e);return s<0?4294967296+s:s}function pt(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function yt(t,e,s){t[e]=s>>24,t[e+1]=s>>16&255,t[e+2]=s>>8&255,t[e+3]=255&s}function Tt(t,e){const s=[];if(!e.length)return s;const i=t.byteLength;for(let r=0;r<i;){const n=mt(t,r),a=n>1?r+n:i;if(ft(t.subarray(r+4,r+8))===e[0])if(1===e.length)s.push(t.subarray(r+8,a));else{const i=Tt(t.subarray(r+8,a),e.slice(1));i.length&&dt.apply(s,i)}r=a}return s}function vt(t){const e=[],s=t[0];let i=8;const r=mt(t,i);i+=4;i+=0===s?8:16,i+=2;let n=t.length+0;const a=gt(t,i);i+=2;for(let o=0;o<a;o++){let s=i;const a=mt(t,s);s+=4;const o=2147483647&a;if(1===(2147483648&a)>>>31)return v.warn("SIDX has hierarchical references (not supported)"),null;const l=mt(t,s);s+=4,e.push({referenceSize:o,subsegmentDuration:l,info:{duration:l/r,start:n,end:n+o-1}}),n+=o,s+=4,i=s}return{earliestPresentationTime:0,timescale:r,version:s,referencesCount:a,references:e}}function Et(t){const e=[],s=Tt(t,["moov","trak"]);for(let i=0;i<s.length;i++){const t=s[i],r=Tt(t,["tkhd"])[0];if(r){let s=r[0],i=0===s?12:20;const n=mt(r,i),a=Tt(t,["mdia","mdhd"])[0];if(a){s=a[0],i=0===s?12:20;const r=mt(a,i),o=Tt(t,["mdia","hdlr"])[0];if(o){const s=ft(o.subarray(8,12)),i={soun:k,vide:D}[s];if(i){const s=Tt(t,["mdia","minf","stbl","stsd"])[0];let a;s&&(a=ft(s.subarray(12,16))),e[n]={timescale:r,type:i},e[i]={timescale:r,id:n,codec:a}}}}}}return Tt(t,["moov","mvex","trex"]).forEach((t=>{const s=mt(t,4),i=e[s];i&&(i.default={duration:mt(t,12),flags:mt(t,20)})})),e}function St(t){const e=Tt(t,["schm"])[0];if(e){const s=ft(e.subarray(4,8));if("cbcs"===s||"cenc"===s)return Tt(t,["schi","tenc"])[0]}return v.error("[eme] missing 'schm' box"),null}function Lt(t){const e=mt(t,0);let s=8;1&e&&(s+=4),4&e&&(s+=4);let i=0;const r=mt(t,4);for(let n=0;n<r;n++){if(256&e){i+=mt(t,s),s+=4}512&e&&(s+=4),1024&e&&(s+=4),2048&e&&(s+=4)}return i}function At(t,e){const s=new Uint8Array(t.length+e.length);return s.set(t),s.set(e,t.length),s}function Rt(t,e){const s=[],i=e.samples,r=e.timescale,n=e.id;let a=!1;return Tt(i,["moof"]).map((o=>{const l=o.byteOffset-8;Tt(o,["traf"]).map((o=>{const c=Tt(o,["tfdt"]).map((t=>{const e=t[0];let s=mt(t,4);return 1===e&&(s*=Math.pow(2,32),s+=mt(t,8)),s/r}))[0];return void 0!==c&&(t=c),Tt(o,["tfhd"]).map((c=>{const h=mt(c,4),d=16777215&mt(c,0);let u=0;const f=0!==(16&d);let g=0;const m=0!==(32&d);let p=8;h===n&&(0!==(1&d)&&(p+=8),0!==(2&d)&&(p+=4),0!==(8&d)&&(u=mt(c,p),p+=4),f&&(g=mt(c,p),p+=4),m&&(p+=4),"video"===e.type&&(a=function(t){if(!t)return!1;const e=t.indexOf("."),s=e<0?t:t.substring(0,e);return"hvc1"===s||"hev1"===s||"dvh1"===s||"dvhe"===s}(e.codec)),Tt(o,["trun"]).map((n=>{const o=n[0],c=16777215&mt(n,0),h=0!==(1&c);let d=0;const f=0!==(4&c),m=0!==(256&c);let p=0;const y=0!==(512&c);let T=0;const v=0!==(1024&c),E=0!==(2048&c);let S=0;const L=mt(n,4);let A=8;h&&(d=mt(n,A),A+=4),f&&(A+=4);let R=d+l;for(let l=0;l<L;l++){if(m?(p=mt(n,A),A+=4):p=u,y?(T=mt(n,A),A+=4):T=g,v&&(A+=4),E&&(S=0===o?mt(n,A):pt(n,A),A+=4),e.type===D){let e=0;for(;e<T;){const n=mt(i,R);if(R+=4,bt(a,i[R])){kt(i.subarray(R,R+n),a?2:1,t+S/r,s)}R+=n,e+=n+4}}t+=p/r}})))}))}))})),s}function bt(t,e){if(t){const t=e>>1&63;return 39===t||40===t}return 6===(31&e)}function kt(t,e,s,i){const r=Dt(t);let n=0;n+=e;let a=0,o=0,l=!1,c=0;for(;n<r.length;){a=0;do{if(n>=r.length)break;c=r[n++],a+=c}while(255===c);o=0;do{if(n>=r.length)break;c=r[n++],o+=c}while(255===c);const t=r.length-n;if(!l&&4===a&&n<r.length){l=!0;if(181===r[n++]){const t=gt(r,n);if(n+=2,49===t){const t=mt(r,n);if(n+=4,1195456820===t){const t=r[n++];if(3===t){const e=r[n++],o=64&e,l=o?2+3*(31&e):0,c=new Uint8Array(l);if(o){c[0]=e;for(let t=1;t<l;t++)c[t]=r[n++]}i.push({type:t,payloadType:a,pts:s,bytes:c})}}}}}else if(5===a&&o<t){if(l=!0,o>16){const t=[];for(let s=0;s<16;s++){const e=r[n++].toString(16);t.push(1==e.length?"0"+e:e),3!==s&&5!==s&&7!==s&&9!==s||t.push("-")}const e=o-16,l=new Uint8Array(e);for(let s=0;s<e;s++)l[s]=r[n++];i.push({payloadType:a,pts:s,uuid:t.join(""),userData:at(l),userDataBytes:l})}}else if(o<t)n+=o;else if(o>t)break}}function Dt(t){const e=t.byteLength,s=[];let i=1;for(;i<e-2;)0===t[i]&&0===t[i+1]&&3===t[i+2]?(s.push(i+2),i+=2):i++;
1if(0===s.length)return t;const r=e-s.length,n=new Uint8Array(r);let a=0;for(i=0;i<r;a++,i++)a===s[0]&&(a++,s.shift()),n[i]=t[a];return n}function It(t,e,s){if(16!==t.byteLength)throw new RangeError("Invalid system id");let i,r,n;if(e){i=1,r=new Uint8Array(16*e.length);for(let t=0;t<e.length;t++){const s=e[t];if(16!==s.byteLength)throw new RangeError("Invalid key");r.set(s,16*t)}}else i=0,r=new Uint8Array;i>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;const a=new Uint8Array(4);return s&&s.byteLength>0&&new DataView(a.buffer).setUint32(0,s.byteLength,!1),function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];const r=s.length;let n=8,a=r;for(;a--;)n+=s[a].byteLength;const o=new Uint8Array(n);for(o[0]=n>>24&255,o[1]=n>>16&255,o[2]=n>>8&255,o[3]=255&n,o.set(t,4),a=0,n=8;a<r;a++)o.set(s[a],n),n+=s[a].byteLength;return o}([112,115,115,104],new Uint8Array([i,0,0,0]),t,n,r,a,s||new Uint8Array)}let wt={};class Ct{static clearKeyUriToKeyIdMap(){wt={}}constructor(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[1],r=arguments.length>4&&void 0!==arguments[4]?arguments[4]: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=s,this.keyFormatVersions=i,this.iv=r,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&"AES-128"!==t}isSupported(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case U:case G:case B:case N:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(t){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!==typeof t&&("AES-128"!==this.method||this.iv||v.warn('missing IV for initialization segment with method="'.concat(this.method,'" - compliance issue')),t=0);const e=function(t){const e=new Uint8Array(16);for(let s=12;s<16;s++)e[s]=t>>8*(15-s)&255;return e}(t);return new Ct(this.method,this.uri,"identity",this.keyFormatVersions,e)}const e=F(this.uri);if(e)switch(this.keyFormat){case G:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case B:{const t=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=It(t,null,e);const s=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),i=String.fromCharCode.apply(null,Array.from(s)),r=i.substring(i.indexOf("<"),i.length),n=(new DOMParser).parseFromString(r,"text/xml").getElementsByTagName("KID")[0];if(n){const t=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE");if(t){const e=x(t).subarray(0,16);!function(t){const e=function(t,e,s){const i=t[e];t[e]=t[s],t[s]=i};e(t,0,3),e(t,1,2),e(t,4,5),e(t,6,7)}(e),this.keyId=e}}break}default:{let t=e.subarray(0,16);if(16!==t.length){const e=new Uint8Array(16);e.set(t,16-t.length),t=e}this.keyId=t;break}}if(!this.keyId||16!==this.keyId.byteLength){let t=wt[this.uri];if(!t){const e=Object.keys(wt).length%Number.MAX_SAFE_INTEGER;t=new Uint8Array(16);new DataView(t.buffer,12,4).setUint32(0,e),wt[this.uri]=t}this.keyId=t}return this}}const _t=/\{\$([a-zA-Z0-9-_]+)\}/g;function Pt(t){return _t.test(t)}function xt(t,e,s){if(null!==t.variableList||t.hasVariableRefs)for(let i=s.length;i--;){const r=s[i],n=e[r];n&&(e[r]=Ft(t,n))}}function Ft(t,e){if(null!==t.variableList||t.hasVariableRefs){const s=t.variableList;return e.replace(_t,(e=>{const i=e.substring(2,e.length-1),r=null==s?void 0:s[i];return void 0===r?(t.playlistParsingError||(t.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'.concat(i,'"'))),e):r}))}return e}function Mt(t,e,s){let i,r,n=t.variableList;if(n||(t.variableList=n={}),"QUERYPARAM"in e){i=e.QUERYPARAM;try{const t=new self.URL(s).searchParams;if(!t.has(i))throw new Error('"'.concat(i,'" does not match any query parameter in URI: "').concat(s,'"'));r=t.get(i)}catch(a){t.playlistParsingError||(t.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: ".concat(a.message)))}}else i=e.NAME,r=e.VALUE;i in n?t.playlistParsingError||(t.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'.concat(i,'"'))):n[i]=r||""}function Ot(t,e,s){const i=e.IMPORT;if(s&&i in s){let e=t.variableList;e||(t.variableList=e={}),e[i]=s[i]}else t.playlistParsingError||(t.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'.concat(i,'"')))}function Nt(){if("undefined"!==typeof self)return self.MediaSource||self.WebKitMediaSource}const Ut={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-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},Bt=Nt();function Gt(t,e){var s;
vendor: 4,757 bytes, line 1
1return null!=(s=null==Bt?void 0:Bt.isTypeSupported("".concat(e||"video",'/mp4;codecs="').concat(t,'"')))&&s}const Kt=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Ht=/#EXT-X-MEDIA:(.*)/g,Vt=/^#EXT(?:INF|-X-TARGETDURATION):/m,Yt=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Wt=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class qt{static findGroup(t,e){for(let s=0;s<t.length;s++){const i=t[s];if(i.id===e)return i}}static convertAVC1ToAVCOTI(t){const e=t.split(".");if(e.length>2){let t=e.shift()+".";return t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4),t}return t}static resolve(t,e){return a.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return Vt.test(t)}static parseMasterPlaylist(t,e){const s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Pt(t)},i=[];let r;for(Kt.lastIndex=0;null!=(r=Kt.exec(t));)if(r[1]){var n;const t=new L(r[1]);xt(s,t,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const a=Ft(s,r[2]),o={attrs:t,bitrate:t.decimalInteger("AVERAGE-BANDWIDTH")||t.decimalInteger("BANDWIDTH"),name:t.NAME,url:qt.resolve(a,e)},l=t.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),zt((t.CODECS||"").split(/[ ,]+/).filter((t=>t)),o),o.videoCodec&&-1!==o.videoCodec.indexOf("avc1")&&(o.videoCodec=qt.convertAVC1ToAVCOTI(o.videoCodec)),null!=(n=o.unknownCodecs)&&n.length||i.push(o),s.levels.push(o)}else if(r[3]){const t=r[3],i=r[4];switch(t){case"SESSION-DATA":{const t=new L(i);xt(s,t,["DATA-ID","LANGUAGE","VALUE","URI"]);const e=t["DATA-ID"];e&&(null===s.sessionData&&(s.sessionData={}),s.sessionData[e]=t);break}case"SESSION-KEY":{const t=jt(i,e,s);t.encrypted&&t.isSupported()?(null===s.sessionKeys&&(s.sessionKeys=[]),s.sessionKeys.push(t)):v.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'.concat(i,'"'));break}case"DEFINE":{const t=new L(i);xt(s,t,["NAME","VALUE","QUERYPARAM"]),Mt(s,t,e)}break;case"CONTENT-STEERING":{const t=new L(i);xt(s,t,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:qt.resolve(t["SERVER-URI"],e),pathwayId:t["PATHWAY-ID"]||"."};break}case"START":s.startTimeOffset=Xt(i)}}const a=i.length>0&&i.length<s.levels.length;return s.levels=a?i:s.levels,0===s.levels.length&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(t,e,s){let i;const r={},n=s.levels,a={AUDIO:n.map((t=>({id:t.attrs.AUDIO,audioCodec:t.audioCodec}))),SUBTITLES:n.map((t=>({id:t.attrs.SUBTITLES,textCodec:t.textCodec}))),"CLOSED-CAPTIONS":[]};let o=0;for(Ht.lastIndex=0;null!==(i=Ht.exec(t));){const t=new L(i[1]),n=t.TYPE;if(n){const i=a[n],l=r[n]||[];r[n]=l,xt(s,t,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const c={attrs:t,bitrate:0,id:o++,groupId:t["GROUP-ID"]||"",instreamId:t["INSTREAM-ID"],name:t.NAME||t.LANGUAGE||"",type:n,default:t.bool("DEFAULT"),autoselect:t.bool("AUTOSELECT"),forced:t.bool("FORCED"),lang:t.LANGUAGE,url:t.URI?qt.resolve(t.URI,e):""};if(null!=i&&i.length){const t=qt.findGroup(i,c.groupId)||i[0];Qt(c,t,"audioCodec"),Qt(c,t,"textCodec")}l.push(c)}}return r}static parseLevelPlaylist(t,e,s,i,r,n){const a=new P(e),o=a.fragments;let l,c,u,f=null,g=0,m=0,p=0,y=0,T=null,E=new C(i,e),S=-1,A=!1;for(Yt.lastIndex=0,a.m3u8=t,a.hasVariableRefs=Pt(t);null!==(l=Yt.exec(t));){A&&(A=!1,E=new C(i,e),E.start=p,E.sn=g,E.cc=y,E.level=s,f&&(E.initSegment=f,E.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null));const t=l[1];if(t){E.duration=parseFloat(t);const e=(" "+l[2]).slice(1);E.title=e||null,E.tagList.push(e?["INF",t,e]:["INF",t])}else if(l[3]){if(d(E.duration)){E.start=p,u&&Zt(E,u,a),E.sn=g,E.level=s,E.cc=y,E.urlId=r,o.push(E);const t=(" "+l[3]).slice(1);E.relurl=Ft(a,t),$t(E,T),T=E,p+=E.duration,g++,m=0,A=!0}}else if(l[4]){const t=(" "+l[4]).slice(1);T?E.setByteRange(t,T):E.setByteRange(t)}else if(l[5])E.rawProgramDateTime=(" "+l[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),-1===S&&(S=o.length);
1else{if(l=l[0].match(Wt),!l){v.warn("No matches on slow regex match for level playlist!");continue}for(c=1;c<l.length&&"undefined"===typeof l[c];c++);const t=(" "+l[c]).slice(1),r=(" "+l[c+1]).slice(1),p=l[c+2]?(" "+l[c+2]).slice(1):"";switch(t){case"PLAYLIST-TYPE":a.type=r.toUpperCase();break;case"MEDIA-SEQUENCE":g=a.startSN=parseInt(r);break;case"SKIP":{const t=new L(r);xt(a,t,["RECENTLY-REMOVED-DATERANGES"]);const e=t.decimalInteger("SKIPPED-SEGMENTS");if(d(e)){a.skippedSegments=e;for(let t=e;t--;)o.unshift(null);g+=e}const s=t.enumeratedString("RECENTLY-REMOVED-DATERANGES");s&&(a.recentlyRemovedDateranges=s.split("\t"));break}case"TARGETDURATION":a.targetduration=Math.max(parseInt(r),1);break;case"VERSION":a.version=parseInt(r);break;case"EXTM3U":break;case"ENDLIST":a.live=!1;break;case"#":(r||p)&&E.tagList.push(p?[r,p]:[r]);break;case"DISCONTINUITY":y++,E.tagList.push(["DIS"]);break;case"GAP":E.gap=!0,E.tagList.push([t]);break;case"BITRATE":E.tagList.push([t,r]);break;case"DATERANGE":{const t=new L(r);xt(a,t,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),xt(a,t,t.clientAttrs);const e=new R(t,a.dateRanges[t.ID]);e.isValid||a.skippedSegments?a.dateRanges[e.id]=e:v.warn('Ignoring invalid DATERANGE tag: "'.concat(r,'"')),E.tagList.push(["EXT-X-DATERANGE",r]);break}case"DEFINE":{const t=new L(r);xt(a,t,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in t?Ot(a,t,n):Mt(a,t,e)}break;case"DISCONTINUITY-SEQUENCE":y=parseInt(r);break;case"KEY":{const t=jt(r,e,a);if(t.isSupported()){if("NONE"===t.method){u=void 0;break}u||(u={}),u[t.keyFormat]&&(u=h({},u)),u[t.keyFormat]=t}else v.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'.concat(r,'"'));break}case"START":a.startTimeOffset=Xt(r);break;case"MAP":{const t=new L(r);if(xt(a,t,["BYTERANGE","URI"]),E.duration){const r=new C(i,e);Jt(r,t,s,u),f=r,E.initSegment=f,f.rawProgramDateTime&&!E.rawProgramDateTime&&(E.rawProgramDateTime=f.rawProgramDateTime)}else Jt(E,t,s,u),f=E,A=!0;break}case"SERVER-CONTROL":{const t=new L(r);a.canBlockReload=t.bool("CAN-BLOCK-RELOAD"),a.canSkipUntil=t.optionalFloat("CAN-SKIP-UNTIL",0),a.canSkipDateRanges=a.canSkipUntil>0&&t.bool("CAN-SKIP-DATERANGES"),a.partHoldBack=t.optionalFloat("PART-HOLD-BACK",0),a.holdBack=t.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const t=new L(r);a.partTarget=t.decimalFloatingPoint("PART-TARGET");break}case"PART":{let t=a.partList;t||(t=a.partList=[]);const s=m>0?t[t.length-1]:void 0,i=m++,n=new L(r);xt(a,n,["BYTERANGE","URI"]);const o=new _(n,E,e,i,s);t.push(o),E.duration+=o.duration;break}case"PRELOAD-HINT":{const t=new L(r);xt(a,t,["URI"]),a.preloadHint=t;break}case"RENDITION-REPORT":{const t=new L(r);xt(a,t,["URI"]),a.renditionReports=a.renditionReports||[],a.renditionReports.push(t);break}default:v.warn("line parsed but not handled: ".concat(l))}}}T&&!T.relurl?(o.pop(),p-=T.duration,a.partList&&(a.fragmentHint=T)):a.partList&&($t(E,T),E.cc=y,a.fragmentHint=E,u&&Zt(E,u,a));const b=o.length,k=o[0],D=o[b-1];if(p+=a.skippedSegments*a.targetduration,p>0&&b&&D){a.averagetargetduration=p/b;const t=D.sn;a.endSN="initSegment"!==t?t:0,a.live||(D.endList=!0),k&&(a.startCC=k.cc)}else a.endSN=0,a.startCC=0;return a.fragmentHint&&(p+=a.fragmentHint.duration),a.totalduration=p,a.endCC=y,S>0&&function(t,e){let s=t[e];for(let i=e;i--;){const e=t[i];if(!e)return;e.programDateTime=s.programDateTime-1e3*e.duration,s=e}}(o,S),a}}function jt(t,e,s){var i,r;const n=new L(t);xt(s,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const a=null!=(i=n.METHOD)?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),c=n.KEYFORMATVERSIONS,h=null!=(r=n.KEYFORMAT)?r:"identity";o&&n.IV&&!l&&v.error("Invalid IV: ".concat(n.IV));const d=o?qt.resolve(o,e):"",u=(c||"1").split("/").map(Number).filter(Number.isFinite);return new Ct(a,d,h,u,l)}function Xt(t){const e=new L(t).decimalFloatingPoint("TIME-OFFSET");return d(e)?e:null}function zt(t,e){["video","audio","text"].forEach((s=>{const i=t.filter((t=>function(t,e){const s=Ut[e];return!!s&&!0===s[t.slice(0,4)]}(t,s)));if(i.length){const r=i.filter((t=>0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)));e["".concat(s,"Codec")]=r.length>0?r[0]:i[0],t=t.filter((t=>-1===i.indexOf(t)))}})),e.unknownCodecs=t}function Qt(t,e,s){const i=e[s];i&&(t[s]=i)}function $t(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),d(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function Jt(t,e,s,i){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=s,t.sn="initSegment",i&&(t.levelkeys=i),t.initSegment=null}function Zt(t,e,s){t.levelkeys=e;const{encryptedFragments:i}=s;i.length&&i[i.length-1].levelkeys===e||!Object.keys(e).some((t=>e[t].isCommonEncryption))||i.push(t)}var te="manifest",ee="level",se="audioTrack",ie="subtitleTrack",re="main",ne="audio",ae="subtitle";function oe(t){const{type:e}=t;switch(e){case se:return ne;case ie:return ae;default:return re}}function le(t,e){let s=t.url;return void 0!==s&&0!==s.indexOf("data:")||(s=e.url),s}class ce{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}
vendor: 4,688 bytes, line 1
1startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:t}=this;t.on(u.MANIFEST_LOADING,this.onManifestLoading,this),t.on(u.LEVEL_LOADING,this.onLevelLoading,this),t.on(u.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(u.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(u.MANIFEST_LOADING,this.onManifestLoading,this),t.off(u.LEVEL_LOADING,this.onLevelLoading,this),t.off(u.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(u.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){const e=this.hls.config,s=e.pLoader,i=e.loader,r=new(s||i)(e);return this.loaders[t.type]=r,r}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const t in this.loaders){const e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){const{url:s}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:te,url:s,deliveryDirectives:null})}onLevelLoading(t,e){const{id:s,level:i,url:r,deliveryDirectives:n}=e;this.load({id:s,level:i,responseType:"text",type:ee,url:r,deliveryDirectives:n})}onAudioTrackLoading(t,e){const{id:s,groupId:i,url:r,deliveryDirectives:n}=e;this.load({id:s,groupId:i,level:null,responseType:"text",type:se,url:r,deliveryDirectives:n})}onSubtitleTrackLoading(t,e){const{id:s,groupId:i,url:r,deliveryDirectives:n}=e;this.load({id:s,groupId:i,level:null,responseType:"text",type:ie,url:r,deliveryDirectives:n})}load(t){var e;const s=this.hls.config;let i,r=this.getInternalLoader(t);if(r){const e=r.context;if(e&&e.url===t.url)return void v.trace("[playlist-loader]: playlist request ongoing");v.log("[playlist-loader]: aborting previous loader for type: ".concat(t.type)),r.abort()}if(i=t.type===te?s.manifestLoadPolicy.default:h({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(t),null!=(e=t.deliveryDirectives)&&e.part){let e;if(t.type===ee&&null!==t.level?e=this.hls.levels[t.level].details:t.type===se&&null!==t.id?e=this.hls.audioTracks[t.id].details:t.type===ie&&null!==t.id&&(e=this.hls.subtitleTracks[t.id].details),e){const t=e.partTarget,s=e.targetduration;if(t&&s){const e=1e3*Math.max(3*t,.8*s);i=h({},i,{maxTimeToFirstByteMs:Math.min(e,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(e,i.maxTimeToFirstByteMs)})}}}const n=i.errorRetry||i.timeoutRetry||{},a={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0},o={onSuccess:(t,e,s,i)=>{const r=this.getInternalLoader(s);this.resetInternalLoader(s.type);const n=t.data;0===n.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),qt.isMediaPlaylist(n)?this.handleTrackOrLevelPlaylist(t,e,s,i||null,r):this.handleMasterPlaylist(t,e,s,i)):this.handleManifestParsingError(t,s,new Error("no EXTM3U delimiter"),i||null,e)},onError:(t,e,s,i)=>{this.handleNetworkError(e,s,!1,t,i)},onTimeout:(t,e,s)=>{this.handleNetworkError(e,s,!0,void 0,t)}};r.load(t,a,o)}handleMasterPlaylist(t,e,s,i){const r=this.hls,n=t.data,a=le(t,s),o=qt.parseMasterPlaylist(n,a);if(o.playlistParsingError)return void this.handleManifestParsingError(t,s,o.playlistParsingError,i,e);const{contentSteering:l,levels:c,sessionData:h,sessionKeys:d,startTimeOffset:f,variableList:g}=o;this.variableList=g;const{AUDIO:m=[],SUBTITLES:p,"CLOSED-CAPTIONS":y}=qt.parseMasterPlaylistMedia(n,a,o);if(m.length){m.some((t=>!t.url))||!c[0].audioCodec||c[0].attrs.AUDIO||(v.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new L({}),bitrate:0,url:""}))}r.trigger(u.MANIFEST_LOADED,{levels:c,audioTracks:m,subtitles:p,captions:y,contentSteering:l,url:a,stats:e,networkDetails:i,sessionData:h,sessionKeys:d,startTimeOffset:f,variableList:g})}handleTrackOrLevelPlaylist(t,e,s,i,r){const n=this.hls,{id:a,level:o,type:l}=s,c=le(t,s),h=d(a)?a:0,f=d(o)?o:h,g=oe(s),m=qt.parseLevelPlaylist(t.data,c,f,g,h,this.variableList);if(l===te){const t={attrs:new L({}),bitrate:0,details:m,name:"",url:c};n.trigger(u.MANIFEST_LOADED,{levels:[t],audioTracks:[],url:c,stats:e,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),s.levelDetails=m,this.handlePlaylistLoaded(m,t,e,s,i,r)}handleManifestParsingError(t,e,s,i,r){this.hls.trigger(u.ERROR,{type:f.NETWORK_E
1RROR,details:g.MANIFEST_PARSING_ERROR,fatal:e.type===te,url:t.url,err:s,error:s,reason:s.message,response:t,context:e,networkDetails:i,stats:r})}handleNetworkError(t,e){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0,n="A network ".concat(s?"timeout":"error"+(i?" (status "+i.code+")":"")," occurred while loading ").concat(t.type);t.type===ee?n+=": ".concat(t.level," id: ").concat(t.id):t.type!==se&&t.type!==ie||(n+=" id: ".concat(t.id,' group-id: "').concat(t.groupId,'"'));const a=new Error(n);v.warn("[playlist-loader]: ".concat(n));let o=g.UNKNOWN,c=!1;const h=this.getInternalLoader(t);switch(t.type){case te:o=s?g.MANIFEST_LOAD_TIMEOUT:g.MANIFEST_LOAD_ERROR,c=!0;break;case ee:o=s?g.LEVEL_LOAD_TIMEOUT:g.LEVEL_LOAD_ERROR,c=!1;break;case se:o=s?g.AUDIO_TRACK_LOAD_TIMEOUT:g.AUDIO_TRACK_LOAD_ERROR,c=!1;break;case ie:o=s?g.SUBTITLE_TRACK_LOAD_TIMEOUT:g.SUBTITLE_LOAD_ERROR,c=!1}h&&this.resetInternalLoader(t.type);const d={type:f.NETWORK_ERROR,details:o,fatal:c,url:t.url,loader:h,context:t,error:a,networkDetails:e,stats:r};if(i){const s=(null==e?void 0:e.url)||t.url;d.response=l({url:s,data:void 0},i)}this.hls.trigger(u.ERROR,d)}handlePlaylistLoaded(t,e,s,i,r,n){const a=this.hls,{type:o,level:l,id:c,groupId:h,deliveryDirectives:d}=i,m=le(e,i),p=oe(i),y="number"===typeof i.level&&p===re?l:void 0;if(!t.fragments.length){const t=new Error("No Segments found in Playlist");return void a.trigger(u.ERROR,{type:f.NETWORK_ERROR,details:g.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:t,reason:t.message,response:e,context:i,level:y,parent:p,networkDetails:r,stats:s})}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const T=t.playlistParsingError;if(T)a.trigger(u.ERROR,{type:f.NETWORK_ERROR,details:g.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:T,reason:T.message,response:e,context:i,level:y,parent:p,networkDetails:r,stats:s});else switch(t.live&&n&&(n.getCacheAge&&(t.ageHeader=n.getCacheAge()||0),n.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),o){case te:case ee:a.trigger(u.LEVEL_LOADED,{details:t,level:y||0,id:c||0,stats:s,networkDetails:r,deliveryDirectives:d});break;case se:a.trigger(u.AUDIO_TRACK_LOADED,{details:t,id:c||0,groupId:h||"",stats:s,networkDetails:r,deliveryDirectives:d});break;case ie:a.trigger(u.SUBTITLE_TRACK_LOADED,{details:t,id:c||0,groupId:h||"",stats:s,networkDetails:r,deliveryDirectives:d})}}}function he(t,e){let s;try{s=new Event("addtrack")}catch(i){s=document.createEvent("Event"),s.initEvent("addtrack",!1,!1)}s.track=t,e.dispatchEvent(s)}function de(t,e){const s=t.mode;if("disabled"===s&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw new Error("addCue is failed for: ".concat(e))}catch(i){v.debug("[texttrack-utils]: ".concat(i));try{const s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,t.addCue(s)}catch(r){v.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: ".concat(r))}}"disabled"===s&&(t.mode=s)}function ue(t){const e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(let s=t.cues.length;s--;)t.removeCue(t.cues[s]);"disabled"===e&&(t.mode=e)}function fe(t,e,s,i){const r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&t.cues.length>0){const r=function(t,e,s){const i=[],r=function(t,e){if(e<t[0].startTime)return 0;const s=t.length-1;if(e>t[s].endTime)return-1;let i=0,r=s;for(;i<=r;){const n=Math.floor((r+i)/2);if(e<t[n].startTime)r=n-1;else{if(!(e>t[n].startTime&&i<s))return n;i=n+1}}return t[i].startTime-e<e-t[r].startTime?i:r}(t,e);if(r>-1)for(let n=r,a=t.length;n<a;n++){const r=t[n];if(r.startTime>=e&&r.endTime<=s)i.push(r);else if(r.startTime>s)return i}return i}(t.cues,e,s);for(let e=0;e<r.length;e++)i&&!i(r[e])||t.removeCue(r[e])}"disabled"===r&&(t.mode=r)}var ge="org.id3",me="com.apple.quicktime.HLS",pe="https://aomedia.org/emsg/ID3";function ye(){if("undefined"!==typeof self)return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const Te=(()=>{const t=ye();try{new t(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function ve(t,e){return t.getTime()/1e3-e}class Ee{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:t}=this;
1t.on(u.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(u.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(u.MANIFEST_LOADING,this.onManifestLoading,this),t.on(u.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(u.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(u.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(u.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(u.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(u.MANIFEST_LOADING,this.onManifestLoading,this),t.off(u.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(u.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(u.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(ue(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){const e=this.getID3Track(t.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;e<t.length;e++){const s=t[e];if("metadata"===s.kind&&"id3"===s.label)return he(s,this.media),s}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:s,enableID3MetadataCues:i}}}=this;if(!s&&!i)return;const{samples:r}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const n=ye();for(let a=0;a<r.length;a++){const t=r[a].type;if(t===pe&&!s||!i)continue;const e=tt(r[a].data);if(e){const s=r[a].pts;let i=s+r[a].duration;i>Te&&(i=Te);i-s<=0&&(i=s+.25);for(let r=0;r<e.length;r++){const a=e[r];if(!J(a)){this.updateId3CueEnds(s,t);const e=new n(s,i,"");e.value=a,t&&(e.type=t),this.id3Track.addCue(e)}}}}}updateId3CueEnds(t,e){var s;const i=null==(s=this.id3Track)?void 0:s.cues;if(i)for(let r=i.length;r--;){const s=i[r];s.type===e&&s.startTime<t&&s.endTime===Te&&(s.endTime=t)}}onBufferFlushing(t,e){let{startOffset:s,endOffset:i,type:r}=e;const{id3Track:n,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let t;t="audio"===r?t=>t.type===ge&&l:"video"===r?t=>t.type===pe&&o:t=>t.type===ge&&l||t.type===pe&&o,fe(n,s,i,t)}}onLevelUpdated(t,e){let{details:s}=e;if(!this.media||!s.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:r}=this,{dateRanges:n}=s,a=Object.keys(n);if(r){const t=Object.keys(i).filter((t=>!a.includes(t)));for(let e=t.length;e--;){const s=t[e];Object.keys(i[s].cues).forEach((t=>{r.removeCue(i[s].cues[t])})),delete i[s]}}const o=s.fragments[s.fragments.length-1];if(0===a.length||!d(null==o?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=o.programDateTime/1e3-o.start,c=ye();for(let d=0;d<a.length;d++){const t=a[d],e=n[t],s=i[t],r=(null==s?void 0:s.cues)||{};let o=(null==s?void 0:s.durationKnown)||!1;const f=ve(e.startDate,l);let g=Te;const m=e.endDate;if(m)g=ve(m,l),o=!0;else if(e.endOnNext&&!o){const t=a.reduce(((t,s)=>{const i=n[s];return i.class===e.class&&i.id!==s&&i.startDate>e.startDate&&t.push(i),t}),[]).sort(((t,e)=>t.startDate.getTime()-e.startDate.getTime()))[0];t&&(g=ve(t.startDate,l),o=!0)}const p=Object.keys(e.attr);for(let i=0;i<p.length;i++){const n=p[i];if("ID"===(u=n)||"CLASS"===u||"START-DATE"===u||"DURATION"===u||"END-DATE"===u||"END-ON-NEXT"===u)continue;let a=r[n];if(a)o&&!s.durationKnown&&(a.endTime=g);else{let s=e.attr[n];a=new c(f,g,""),A(n)&&(h=s,s=Uint8Array.from(h.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),a.value={key:n,data:s},a.type=me,a.id=t,this.id3Track.addCue(a),r[n]=a}}i[t]={cues:r,dateRange:e,durationKnown:o}}var h,u}}class Se{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=t,this.config=t.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:t,levelDetails:e}=this;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){const{levelDetails:t}=this;if(null===t)return null;const{holdBack:e,partHoldBack:s,targetduration:i}=t,{liveSyncDuration:r,liveSyncDurationCount:n,lowLatencyMode:a}=this.config,o=this.hls.userConfig;let l=a&&s||e;(o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==r?r:n*i);const c=i;return l+Math.min(1*this.stallCount,c)}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency,s=this.levelDetails;if(null===t||null===e||null===s)return null;const i=s.edge,r=t-e-this.edgeStalled,n=i-s.totalduration,a=i-(this.config.lowLatencyMode&&s.partTarget||s.targetduration);return Math.min(Math.max(n,r),a)}get drift(){const{levelDetails:t}=this;return null===t?1:t.drift}get edgeStalled(){const{levelDetails:t}=this;if(null===t)return 0;const e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-e,0)}get forwardBufferLength(){const{media:t,levelDetails:e}=this;if(!t||!e)return 0;const s=t.buffered.length;return(s?t.buffered.end(s-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}
1registerListeners(){this.hls.on(u.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(u.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(u.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(u.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(u.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(u.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(u.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(u.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(u.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(u.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(t,e){let{details:s}=e;this.levelDetails=s,s.advanced&&this.timeupdate(),!s.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(t,e){var s;e.details===g.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(s=this.levelDetails)&&s.live&&v.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:t,levelDetails:e}=this;if(!t||!e)return;this.currentTime=t.currentTime;const s=this.computeLatency();if(null===s)return;this._latency=s;const{lowLatencyMode:i,maxLiveSyncPlaybackRate:r}=this.config;if(!i||1===r)return;const n=this.targetLatency;if(null===n)return;const a=s-n,o=a<Math.min(this.maxLatency,n+e.targetduration);if(e.live&&o&&a>.05&&this.forwardBufferLength>1){const e=Math.min(2,Math.max(1,r)),s=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20;t.playbackRate=Math.min(e,Math.max(1,s))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}estimateLiveEdge(){const{levelDetails:t}=this;return null===t?null:t.edge+t.age}computeLatency(){const t=this.estimateLiveEdge();return null===t?null:t-this.currentTime}}const Le=["NONE","TYPE-0","TYPE-1",null];var Ae="",Re="YES",be="v2";class ke{constructor(t,e,s){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=s}addDirectives(t){const e=new self.URL(t);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class De{constructor(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter((t=>t)).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(t){const e=t%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}get audioGroupId(){var t;return null==(t=this.audioGroupIds)?void 0:t[this.urlId]}get textGroupId(){var t;return null==(t=this.textGroupIds)?void 0:t[this.urlId]}addFallback(t){this.url.push(t.url),this._attrs.push(t.attrs)}}function Ie(t,e){const s=e.startPTS;if(d(s)){let i,r=0;e.sn>t.sn?(r=s-t.start,i=t):(r=t.start-s,i=e),i.duration!==r&&(i.duration=r)}else if(e.sn>t.sn){t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration}else e.start=Math.max(t.start-e.duration,0)}function we(t,e,s,i,r,n){i-s<=0&&(v.warn("Fragment should have a positive duration",e),i=s+e.duration,n=r+e.duration);let a=s,o=i;const l=e.startPTS,c=e.endPTS;if(d(l)){const t=Math.abs(l-s);d(e.deltaPTS)?e.deltaPTS=Math.max(t,e.deltaPTS):e.deltaPTS=t,a=Math.max(s,l),s=Math.min(s,l),r=Math.min(r,e.startDTS),o=Math.min(i,c),i=Math.max(i,c),n=Math.max(n,e.endDTS)}const h=s-e.start;0!==e.start&&(e.start=s),e.duration=i-e.start,e.startPTS=s,e.maxStartPTS=a,e.startDTS=r,e.endPTS=i,e.minEndPTS=o,e.endDTS=n;const u=e.sn;if(!t||u<t.startSN||u>t.endSN)return 0;let f;const g=u-t.startSN,m=t.fragments;for(m[g]=e,f=g;f>0;f--)Ie(m[f],m[f-1]);for(f=g;f<m.length-1;f++)Ie(m[f],m[f+1]);return t.fragmentHint&&Ie(m[m.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,h}function Ce(t,e){let s=null;const i=t.fragments;for(let l=i.length-1;l>=0;l--){const t=i[l].initSegment;if(t){s=t;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;let r,n=0;
1if(function(t,e,s){const i=e.skippedSegments,r=Math.max(t.startSN,e.startSN)-e.startSN,n=(t.fragmentHint?1:0)+(i?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,a=e.startSN-t.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;for(let c=r;c<=n;c++){const t=l[a+c];let r=o[c];i&&!r&&c<i&&(r=e.fragments[c]=t),t&&r&&s(t,r)}}(t,e,((t,i)=>{t.relurl&&(n=t.cc-i.cc),d(t.startPTS)&&d(t.endPTS)&&(i.start=i.startPTS=t.startPTS,i.startDTS=t.startDTS,i.maxStartPTS=t.maxStartPTS,i.endPTS=t.endPTS,i.endDTS=t.endDTS,i.minEndPTS=t.minEndPTS,i.duration=t.endPTS-t.startPTS,i.duration&&(r=i),e.PTSKnown=e.alignedSliding=!0),i.elementaryStreams=t.elementaryStreams,i.loader=t.loader,i.stats=t.stats,i.urlId=t.urlId,t.initSegment&&(i.initSegment=t.initSegment,s=t.initSegment)})),s){(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach((t=>{var e;t.initSegment&&t.initSegment.relurl!==(null==(e=s)?void 0:e.relurl)||(t.initSegment=s)}))}if(e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some((t=>!t)),e.deltaUpdateFailed){v.warn("[level-helper] Previous playlist missing segments ski
1pped in delta playlist");for(let t=e.skippedSegments;t--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=function(t,e,s){const i=h({},t);s&&s.forEach((t=>{delete i[t]}));return Object.keys(e).forEach((t=>{const s=new R(e[t].attr,i[t]);s.isValid?i[t]=s:v.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'.concat(JSON.stringify(e[t].attr),'"'))})),i}(t.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const a=e.fragments;if(n){v.warn("discontinuity sliding from playlist, take drift into account");for(let t=0;t<a.length;t++)a[t].cc+=n}e.skippedSegments&&(e.startCC=e.fragments[0].cc),function(t,e,s){if(t&&e){let i=0;for(let r=0,n=t.length;r<=n;r++){const n=t[r],a=e[r+i];n&&a&&n.index===a.index&&n.fragment.sn===a.fragment.sn?s(n,a):i--}}}(t.partList,e.partList,((t,e)=>{e.elementaryStreams=t.elementaryStreams,e.stats=t.stats})),r?we(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):_e(t,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=t.driftStartTime,e.driftStart=t.driftStart;const o=e.advancedDateTime;if(e.advanced&&o){const t=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=t),e.driftEndTime=o,e.driftEnd=t}else e.driftEndTime=t.driftEndTime,e.driftEnd=t.driftEnd,e.advancedDateTime=t.advancedDateTime}function _e(t,e){const s=e.startSN+e.skippedSegments-t.startSN,i=t.fragments;s<0||s>=i.length||Pe(e,i[s].start)}function Pe(t,e){if(e){const s=t.fragments;for(let i=t.skippedSegments;i<s.length;i++)s[i].start+=e;t.fragmentHint&&(t.fragmentHint.start+=e)}}function xe(t,e,s){var i;return null!=t&&t.details?Fe(null==(i=t.details)?void 0:i.partList,e,s):null}function Fe(t,e,s){if(t)for(let i=t.length;i--;){const r=t[i];if(r.index===s&&r.fragment.sn===e)return r}return null}function Me(t){switch(t.details){case g.FRAG_LOAD_TIMEOUT:case g.KEY_LOAD_TIMEOUT:case g.LEVEL_LOAD_TIMEOUT:case g.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Oe(t,e){const s=Me(e);return t.default["".concat(s?"timeout":"error","Retry")]}function Ne(t,e){const s="linear"===t.backoff?1:Math.pow(2,e);return Math.min(s*t.retryDelayMs,t.maxRetryDelayMs)}function Ue(t){return l(l({},t),{errorRetry:null,timeoutRetry:null})}function Be(t,e,s,i){return!!t&&e<t.maxNumRetry&&(function(t){return 0===t&&!1===navigator.onLine||!!t&&(t<400||t>499)}(i)||!!s)}const Ge={search:function(t,e){let s=0,i=t.length-1,r=null,n=null;for(;s<=i;){r=(s+i)/2|0,n=t[r];const a=e(n);if(a>0)s=r+1;else{if(!(a<0))return n;i=r-1}}return null}};function Ke(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=null;if(t?r=e[t.sn-e[0].sn+1]||null:0===s&&0===e[0].start&&(r=e[0]),r&&0===He(s,i,r))return r;const n=Ge.search(e,He.bind(null,s,i));return!n||n===t&&r?r:n}function He(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=arguments.length>2?arguments[2]:void 0;if(s.start<=t&&s.start+s.duration>t)return 0;const i=Math.min(e,s.duration+(s.deltaPTS?s.deltaPTS:0));return s.start+s.duration-i<=t?1:s.start-i>t&&s.start?-1:0}function Ve(t,e,s){const i=1e3*Math.min(e,s.duration+(s.deltaPTS?s.deltaPTS:0));return(s.endProgramDateTime||0)-i>t}var Ye=0,We=2,qe=5,je=0,Xe=1,ze=2;function Qe(t,e,s){if(performance.now()-t.lastErrorPerfMs>3e5)return!0;const i=t.details;if(e.details===g.FRAG_GAP&&i&&e.frag){const t=e.frag.start,s=Ke(null,i.fragments,t);if(s&&!s.gap)return!0}if(s&&t.errors.length<s.errors.length){const s=t.errors[t.errors.length-1];if(i&&s.frag&&e.frag&&Math.abs(s.frag.start-e.frag.start)>3*i.targetduration)return!0}return!1}class $e{constructor(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=v.log.bind(v,"".concat(e,":")),this.warn=v.warn.bind(v,"".concat(e,":")),this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(t,e){const s=null==e?void 0:e.renditionReports;if(s){let r=-1;for(let n=0;n<s.length;n++){const a=s[n];let o;try{o=new self.URL(a.URI,e.url).href}catch(i){v.warn("Could not construct new URL for Rendition Report: ".concat(i)),o=a.URI||""}if(o===t){r=n;break}o===t.substring(0,o.length)&&(r=n)}if(-1!==r){const t=s[r],i=parseInt(t["LAST-MSN"])||(null==e?void 0:e.lastPartSn);let n=parseInt(t["LAST-PART"])||(null==e?void 0:e.lastPartIndex);if(this.hls.config.lowLatencyMode){const t=Math.min(e.age-e.partTarget,e.targetduration);n>=0&&t>e.partTarget&&(n+=1)}return new ke(i,n>=0?n:void 0,Ae)}}}loadPlaylist(t){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}shouldReloadPlaylist(t){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(t)}
1playlistLoaded(t,e,s){const{details:i,stats:r}=e,n=self.performance.now(),a=r.loading.first?Math.max(0,n-r.loading.first):0;if(i.advancedDateTime=Date.now()-a,i.live||null!=s&&s.live){if(i.reloaded(s),s&&this.log("live playlist ".concat(t," ").concat(i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED")),s&&i.fragments.length>0&&Ce(s,i),!this.canLoad||!i.live)return;let a,o,l;if(i.canBlockReload&&i.endSN&&i.advanced){const t=this.hls.config.lowLatencyMode,r=i.lastPartSn,n=i.endSN,c=i.lastPartIndex,h=r===n;-1!==c?(o=h?n+1:r,l=h?t?0:c:c+1):o=n+1;const d=i.age,u=d+i.ageHeader;let f=Math.min(u-i.partTarget,1.5*i.targetduration);if(f>0){if(s&&f>s.tuneInGoal)this.warn("CDN Tune-in goal increased from: ".concat(s.tuneInGoal," to: ").concat(f," with playlist age: ").concat(i.age)),f=0;else{const t=Math.floor(f/i.targetduration);if(o+=t,void 0!==l){l+=Math.round(f%i.targetduration/i.partTarget)}this.log("CDN Tune-in age: ".concat(i.ageHeader,"s last advanced ").concat(d.toFixed(2),"s goal: ").concat(f," skip sn ").concat(t," to part ").concat(l))}i.tuneInGoal=f}if(a=this.getDeliveryDirectives(i,e.deliveryDirectives,o,l),t||!h)return void this.loadPlaylist(a)}else(i.canBlockReload||i.canSkipUntil)&&(a=this.getDeliveryDirectives(i,e.deliveryDirectives,o,l));const c=this.hls.mainForwardBufferInfo,h=c?c.end-c.len:0,d=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,s=1e3*t.targetduration;if(t.updated){const i=t.fragments,r=4;if(i.length&&s*r>e){const t=1e3*i[i.length-1].duration;t<s&&(s=t)}}else s/=2;return Math.round(s)}(i,1e3*(i.edge-h));i.updated&&n>this.requestScheduled+d&&(this.requestScheduled=r.loading.start),void 0!==o&&i.canBlockReload?this.requestScheduled=r.loading.first+d-(1e3*i.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+d<n?this.requestScheduled=n:this.requestScheduled-n<=0&&(this.requestScheduled+=d);let u=this.requestScheduled-n;u=Math.max(0,u),this.log("reload live playlist ".concat(t," in ").concat(Math.round(u)," ms")),this.timer=self.setTimeout((()=>this.loadPlaylist(a)),u)}else this.clearTimer()}getDeliveryDirectives(t,e,s,i){let r=function(t,e){const{canSkipUntil:s,canSkipDateRanges:i,endSN:r}=t;return s&&(void 0!==e?e-r:0)<s?i?be:Re:Ae}(t,s);return null!=e&&e.skip&&t.deltaUpdateFailed&&(s=e.msn,i=e.part,r=Ae),new ke(s,i,r)}checkRetry(t){const e=t.details,s=Me(t),i=t.errorAction,{action:r,retryCount:n=0,retryConfig:a}=i||{},o=!!i&&!!a&&(r===qe||!i.resolved&&r===We);if(o){var l;if(this.requestScheduled=-1,n>=a.maxNumRetry)return!1;if(s&&null!=(l=t.context)&&l.deliveryDirectives)this.warn("Retrying playlist loading ".concat(n+1,"/").concat(a.maxNumRetry,' after "').concat(e,'" without delivery-directives')),this.loadPlaylist();else{const t=Ne(a,n);this.timer=self.setTimeout((()=>this.loadPlaylist()),t),this.warn("Retrying playlist loading ".concat(n+1,"/").concat(a.maxNumRetry,' after "').concat(e,'" in ').concat(t,"ms"))}t.levelRetry=!0,i.resolved=!0}return o}}let Je;class Ze extends $e{constructor(t,e){super(t,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(u.MANIFEST_LOADING,this.onManifestLoading,this),t.on(u.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(u.LEVEL_LOADED,this.onLevelLoaded,this),t.on(u.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(u.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(u.FRAG_LOADED,this.onFragLoaded,this),t.on(u.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(u.MANIFEST_LOADING,this.onManifestLoading,this),t.off(u.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(u.LEVEL_LOADED,this.onLevelLoaded,this),t.off(u.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(u.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(u.FRAG_LOADED,this.onFragLoaded,this),t.off(u.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}
1startLoad(){this._levels.forEach((t=>{t.loadError=0,t.fragmentError=0})),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const s=[],i={};let r;e.levels.forEach((t=>{var e;const n=t.attrs;-1!==(null==(e=t.audioCodec)?void 0:e.indexOf("mp4a.40.34"))&&(Je||(Je=/chrome|firefox/i.test(navigator.userAgent)),Je&&(t.audioCodec=void 0));const{AUDIO:a,CODECS:o,"FRAME-RATE":l,"PATHWAY-ID":c,RESOLUTION:h,SUBTITLES:d}=n,u="".concat(c||".","-"),f="".concat(u).concat(t.bitrate,"-").concat(h,"-").concat(l,"-").concat(o);r=i[f],r?r.addFallback(t):(r=new De(t),i[f]=r,s.push(r)),ts(r,"audio",a),ts(r,"text",d)})),this.filterAndSortMediaOptions(s,e)}filterAndSortMediaOptions(t,e){let s=[],i=[],r=!1,n=!1,a=!1,o=t.filter((t=>{let{audioCodec:e,videoCodec:s,width:i,height:o,unknownCodecs:l}=t;return r||(r=!(!i||!o)),n||(n=!!s),a||(a=!!e),!(null!=l&&l.length)&&(!e||Gt(e,"audio"))&&(!s||Gt(s,"video"))}));if((r||n)&&a&&(o=o.filter((t=>{let{videoCodec:e,width:s,height:i}=t;return!!e||!(!s||!i)}))),0===o.length)return void Promise.resolve().then((()=>
1{if(this.hls){const t=new Error("no level with compatible codecs found in manifest");this.hls.trigger(u.ERROR,{type:f.MEDIA_ERROR,details:g.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:t,reason:t.message})}}));e.audioTracks&&(s=e.audioTracks.filter((t=>!t.audioCodec||Gt(t.audioCodec,"audio"))),es(s)),e.subtitles&&(i=e.subtitles,es(i));const l=o.slice(0);o.sort(((t,e)=>t.attrs["HDCP-LEVEL"]!==e.attrs["HDCP-LEVEL"]?(t.attrs["HDCP-LEVEL"]||"")>(e.attrs["HDCP-LEVEL"]||"")?1:-1:t.bitrate!==e.bitrate?t.bitrate-e.bitrate:t.attrs["FRAME-RATE"]!==e.attrs["FRAME-RATE"]?t.attrs.decimalFloatingPoint("FRAME-RATE")-e.attrs.decimalFloatingPoint("FRAME-RATE"):t.attrs.SCORE!==e.attrs.SCORE?t.attrs.decimalFloatingPoint("SCORE")-e.attrs.decimalFloatingPoint("SCORE"):r&&t.height!==e.height?t.height-e.height:0));let c=l[0];if(this.steering&&(o=this.steering.filterParsedLevels(o),o.length!==l.length))for(let u=0;u<l.length;u++)if(l[u].pathwayId===o[0].pathwayId){c=l[u];break}this._levels=o;for(let u=0;u<o.length;u++)if(o[u]===c){this._firstLevel=u,this.log("manifest loaded, ".concat(o.length," level(s) found, first bitrate: ").concat(c.bitrate));break}const h=a&&!n,d={levels:o,audioTracks:s,subtitleTracks:i,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:a,video:n,altAudio:!h&&s.some((t=>!!t.url))};this.hls.trigger(u.MANIFEST_PARSED,d),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return 0===this._levels.length?null:this._levels}get level(){return this.currentLevelIndex}set level(t){const e=this._levels;if(0===e.length)return;if(t<0||t>=e.length){const s=new Error("invalid level idx"),i=t<0;if(this.hls.trigger(u.ERROR,{type:f.OTHER_ERROR,details:g.LEVEL_SWITCH_ERROR,level:t,fatal:i,error:s,reason:s.message}),i)return;t=Math.min(t,e.length-1)}const s=this.currentLevelIndex,i=this.currentLevel,r=i?i.attrs["PATHWAY-ID"]:void 0,n=e[t],a=n.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=n,s===t&&n.details&&i&&r===a)return;this.log("Switching to level ".concat(t).concat(a?" with Pathway "+a:""," from level ").concat(s).concat(r?" with Pathway "+r:""));const o=h({},n,{level:t,maxBitrate:n.maxBitrate,attrs:n.attrs,uri:n.uri,urlId:n.urlId});delete o._attrs,delete o._urlId,this.hls.trigger(u.LEVEL_SWITCHING,o);const l=n.details;if(!l||l.live){const t=this.switchParams(n.uri,null==i?void 0:i.details);this.loadPlaylist(t)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){if(void 0===this._startLevel){const t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel}set startLevel(t){this._startLevel=t}onError(t,e){!e.fatal&&e.context&&e.context.type===ee&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,e){let{frag:s}=e;if(void 0!==s&&s.type===re){const t=this._levels[s.level];void 0!==t&&(t.loadError=0)}}onLevelLoaded(t,e){var s;const{level:i,details:r}=e,n=this._levels[i];var a;if(!n)return this.warn("Invalid level index ".concat(i)),void(null!=(a=e.deliveryDirectives)&&a.skip&&(r.deltaUpdateFailed=!0));i===this.currentLevelIndex?(0===n.fragmentError&&(n.loadError=0),this.playlistLoaded(i,e,n.details)):null!=(s=e.deliveryDirectives)&&s.skip&&(r.deltaUpdateFailed=!0)}onAudioTrackSwitched(t,e){const s=this.currentLevel;if(!s)return;const i=this.hls.audioTracks[e.id].groupId;if(s.audioGroupIds&&s.audioGroupId!==i){let t=-1;for(let e=0;e<s.audioGroupIds.length;e++)if(s.audioGroupIds[e]===i){t=e;break}-1!==t&&t!==s.urlId&&(s.urlId=t,this.canLoad&&this.startLoad())}}loadPlaylist(t){super.loadPlaylist();const e=this.currentLevelIndex,s=this.currentLevel;if(s&&this.shouldLoadPlaylist(s)){const r=s.urlId;let n=s.uri;if(t)try{n=t.addDirectives(n)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: ".concat(i))}const a=s.attrs["PATHWAY-ID"];this.log("Loading level index ".concat(e).concat(void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""," with").concat(a?" Pathway "+a:""," URI ").concat(r+1,"/").concat(s.url.length," ").concat(n)),this.clearTimer(),this.hls.trigger(u.LEVEL_LOADING,{url:n,level:e,id:r,deliveryDirectives:t||null})}}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}removeLevel(t,e){const s=(t,s)=>s!==e,i=this._levels.filter(((i,r)=>r!==t||(i.url.length>1&&void 0!==e?(i.url=i.url.filter(s),i.audioGroupIds&&(i.audioGroupIds=i.audioGroupIds.filter(s)),i.textGroupIds&&(i.textGroupIds=i.textGroupIds.filter(s)),i.urlId=0,!0):(this.steering&&this.steering.removeLevel(i),!1))));this.hls.trigger(u.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(t,e){let{levels:s}=e;
vendor: 4,694 bytes, line 1
1s.forEach(((t,e)=>{const{details:s}=t;null!=s&&s.fragments&&s.fragments.forEach((t=>{t.level=e}))})),this._levels=s}}function ts(t,e,s){s&&("audio"===e?(t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds[t.url.length-1]=s):"text"===e&&(t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds[t.url.length-1]=s))}function es(t){const e={};t.forEach((t=>{const s=t.groupId||"";t.id=e[s]=e[s]||0,e[s]++}))}var ss="NOT_LOADED",is="APPENDING",rs="PARTIAL",ns="OK";class as{constructor(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(u.BUFFER_APPENDED,this.onBufferAppended,this),t.on(u.FRAG_BUFFERED,this.onFragBuffered,this),t.on(u.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(u.BUFFER_APPENDED,this.onBufferAppended,this),t.off(u.FRAG_BUFFERED,this.onFragBuffered,this),t.off(u.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const s=this.activePartLists[e];if(s)for(let i=s.length;i--;){const e=s[i];if(!e)break;const r=e.end;if(e.start<=t&&null!==r&&t<=r)return e}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:s}=this,i=Object.keys(s);for(let r=i.length;r--;){const n=s[i[r]];if((null==n?void 0:n.body.type)===e&&n.buffered){const e=n.body;if(e.start<=t&&t<=e.end)return e}}return null}detectEvictedFragments(t,e,s,i){this.timeRanges&&(this.timeRanges[t]=e);const r=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach((i=>{const n=this.fragments[i];if(!n)return;if(r>=n.body.sn)return;if(!n.buffered&&!n.loaded)return void(n.body.type===s&&this.removeFragment(n.body));const a=n.range[t];a&&a.time.some((t=>{const s=!this.isTimeBuffered(t.startPTS,t.endPTS,e);return s&&this.removeFragment(n.body),s}))}))}detectPartialFragments(t){const e=this.timeRanges,{frag:s,part:i}=t;if(!e||"initSegment"===s.sn)return;const r=ls(s),n=this.fragments[r];if(!n||n.buffered&&s.gap)return;const a=!s.relurl;if(Object.keys(e).forEach((t=>{const r=s.elementaryStreams[t];if(!r)return;const o=e[t],l=a||!0===r.partial;n.range[t]=this.getBufferedTimes(s,i,l,o)})),n.loaded=null,Object.keys(n.range).length){n.buffered=!0;(n.body.endList=s.endList||n.body.endList)&&(this.endListFragments[n.body.type]=n),os(n)||this.removeParts(s.sn-1,s.type)}else this.removeFragment(n.body)}removeParts(t,e){const s=this.activePartLists[e];s&&(this.activePartLists[e]=s.filter((e=>e.fragment.sn>=t)))}fragBuffered(t,e){const s=ls(t);let i=this.fragments[s];!i&&e&&(i=this.fragments[s]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)}getBufferedTimes(t,e,s,i){const r={time:[],partial:s},n=t.start,a=t.end,o=t.minEndPTS||a,l=t.maxStartPTS||n;for(let c=0;c<i.length;c++){const t=i.start(c)-this.bufferPadding,e=i.end(c)+this.bufferPadding;if(l>=t&&o<=e){r.time.push({startPTS:Math.max(n,i.start(c)),endPTS:Math.min(a,i.end(c))});break}if(n<e&&a>t)r.partial=!0,r.time.push({startPTS:Math.max(n,i.start(c)),endPTS:Math.min(a,i.end(c))});else if(a<=t)break}return r}getPartialFragment(t){let e,s,i,r=null,n=0;const{bufferPadding:a,fragments:o}=this;return Object.keys(o).forEach((l=>{const c=o[l];c&&os(c)&&(s=c.body.start-a,i=c.body.end+a,t>=s&&t<=i&&(e=Math.min(t-s,i-t),n<=e&&(r=c.body,n=e)))})),r}isEndListAppended(t){const e=this.endListFragments[t];return void 0!==e&&(e.buffered||os(e))}getState(t){const e=ls(t),s=this.fragments[e];return s?s.buffered?os(s)?rs:ns:is:ss}isTimeBuffered(t,e,s){let i,r;for(let n=0;n<s.length;n++){if(i=s.start(n)-this.bufferPadding,r=s.end(n)+this.bufferPadding,t>=i&&e<=r)return!0;if(e<=i)return!1}return!1}onFragLoaded(t,e){const{frag:s,part:i}=e;if("initSegment"===s.sn||s.bitrateTest)return;const r=i?null:e,n=ls(s);this.fragments[n]={body:s,appendedPTS:null,loaded:r,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:s,part:i,timeRanges:r}=e;if("initSegment"===s.sn)return;const n=s.type;if(i){let t=this.activePartLists[n];t||(this.activePartLists[n]=t=[]),t.push(i)}this.timeRanges=r,Object.keys(r).forEach((t=>{const e=r[t];this.detectEvictedFragments(t,e,n,i)}))}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=ls(t);return!!this.fragments[e]}hasParts(t){var e;return!(null==(e=this.activePartLists[t])||!e.length)}removeFragmentsInRange(t,e,s,i,r){i&&!this.hasGaps||Object.keys(this.fragments).forEac
vendor: 4,210 bytes, line 1
1h((n=>{const a=this.fragments[n];if(!a)return;const o=a.body;o.type!==s||i&&!o.gap||o.start<e&&o.end>t&&(a.buffered||r)&&this.removeFragment(o)}))}removeFragment(t){const e=ls(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const s=this.activePartLists[t.type];if(s){const e=t.sn;this.activePartLists[t.type]=s.filter((t=>t.fragment.sn!==e))}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function os(t){var e,s,i;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(s=t.range.audio)?void 0:s.partial)||(null==(i=t.range.audiovideo)?void 0:i.partial))}function ls(t){return"".concat(t.type,"_").concat(t.level,"_").concat(t.urlId,"_").concat(t.sn)}const cs=Math.pow(2,17);class hs{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,e){const s=t.url;if(!s)return Promise.reject(new fs({type:f.NETWORK_ERROR,details:g.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a ".concat(s?"part list":"url")),networkDetails:null}));this.abort();const i=this.config,r=i.fLoader,n=i.loader;return new Promise(((a,o)=>{if(this.loader&&this.loader.destroy(),t.gap){if(t.tagList.some((t=>"GAP"===t[0])))return void o(us(t));t.gap=!1}const c=this.loader=t.loader=r?new r(i):new n(i),h=ds(t),d=Ue(i.fragLoadPolicy.default),u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===t.sn?1/0:cs};t.stats=c.stats,c.load(h,u,{onSuccess:(e,s,i,r)=>{this.resetLoader(t,c);let n=e.data;i.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(n.slice(0,16)),n=n.slice(16)),a({frag:t,part:null,payload:n,networkDetails:r})},onError:(e,i,r,n)=>{this.resetLoader(t,c),o(new fs({type:f.NETWORK_ERROR,details:g.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:l({url:s,data:void 0},e),error:new Error("HTTP Error ".concat(e.code," ").concat(e.text)),networkDetails:r,stats:n}))},onAbort:(e,s,i)=>{this.resetLoader(t,c),o(new fs({type:f.NETWORK_ERROR,details:g.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:i,stats:e}))},onTimeout:(e,s,i)=>{this.resetLoader(t,c),o(new fs({type:f.NETWORK_ERROR,details:g.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error("Timeout after ".concat(u.timeout,"ms")),networkDetails:i,stats:e}))},onProgress:(s,i,r,n)=>{e&&e({frag:t,part:null,payload:r,networkDetails:n})}})}))}loadPart(t,e,s){this.abort();const i=this.config,r=i.fLoader,n=i.loader;return new Promise(((a,o)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap)return void o(us(t,e));const c=this.loader=t.loader=r?new r(i):new n(i),h=ds(t,e),d=Ue(i.fragLoadPolicy.default),u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:cs};e.stats=c.stats,c.load(h,u,{onSuccess:(i,r,n,o)=>{this.resetLoader(t,c),this.updateStatsFromPart(t,e);const l={frag:t,part:e,payload:i.data,networkDetails:o};s(l),a(l)},onError:(s,i,r,n)=>{this.resetLoader(t,c),o(new fs({type:f.NETWORK_ERROR,details:g.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:l({url:h.url,data:void 0},s),error:new Error("HTTP Error ".concat(s.code," ").concat(s.text)),networkDetails:r,stats:n}))},onAbort:(s,i,r)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,c),o(new fs({type:f.NETWORK_ERROR,details:g.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:r,stats:s}))},onTimeout:(s,i,r)=>{this.resetLoader(t,c),o(new fs({type:f.NETWORK_ERROR,details:g.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error("Timeout after ".concat(u.timeout,"ms")),networkDetails:r,stats:s}))}})}))}updateStatsFromPart(t,e){const s=t.stats,i=e.stats,r=i.total;if(s.loaded+=i.loaded,r){const i=Math.round(t.duration/e.duration),n=Math.min(Math.round(s.loaded/r),i),a=(i-n)*Math.round(s.loaded/n);s.total=s.loaded+a}else s.total=Math.max(s.loaded,s.total);const n=s.loading,a=i.loading;n.start?n.first+=a.first-a.start:(n.start=a.start,n.first=a.first),n.end=a.end}
1resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function ds(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const s=e||t,i={frag:t,part:e,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},r=s.byteRangeStartOffset,n=s.byteRangeEndOffset;if(d(r)&&d(n)){var a;let e=r,s=n;if("initSegment"===t.sn&&"AES-128"===(null==(a=t.decryptdata)?void 0:a.method)){const t=n-r;t%16&&(s=n+(16-t%16)),0!==r&&(i.resetIV=!0,e=r-16)}i.rangeStart=e,i.rangeEnd=s}return i}function us(t,e){const s=new Error("GAP ".concat(t.gap?"tag":"attribute"," found")),i={type:f.MEDIA_ERROR,details:g.FRAG_GAP,fatal:!1,frag:t,error:s,networkDetails:null};return e&&(i.part=e),(e||t).stats.aborted=!0,new fs(i)}class fs extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class gs{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const e in this.keyUriToKeyInfo){const s=this.keyUriToKeyInfo[e].loader;if(s){if(t&&t!==s.context.frag.type)return;s.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:g.KEY_LOAD_ERROR,s=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;return new fs({type:f.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:r,error:s,networkDetails:i})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:s,cc:i}=t;for(let t=0;t<e.length;t++){const r=e[t];if(i<=r.cc&&("initSegment"===s||"initSegment"===r.sn||s<r.sn)){this.emeController.selectKeySystemFormat(r).then((t=>{r.setKeyFormat(t)}));break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then((e=>this.loadInternal(t,e))):this.loadInternal(t)}loadInternal(t,e){var s,i;e&&t.setKeyFormat(e);const r=t.decryptdata;if(!r){const s=new Error(e?"Expected frag.decryptdata to be defined after setting format ".concat(e):"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,g.KEY_LOAD_ERROR,s))}const n=r.uri;if(!n)return Promise.reject(this.createKeyLoadError(t,g.KEY_LOAD_ERROR,new Error('Invalid key URI: "'.concat(n,'"'))));let a=this.keyUriToKeyInfo[n];if(null!=(s=a)&&s.decryptdata.key)return r.key=a.decryptdata.key,Promise.resolve({frag:t,keyInfo:a});var o;if(null!=(i=a)&&i.keyLoadPromise)switch(null==(o=a.mediaKeySessionContext)?void 0:o.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return a.keyLoadPromise.then((e=>(r.key=e.keyInfo.decryptdata.key,{frag:t,keyInfo:a})))}switch(a=this.keyUriToKeyInfo[n]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===r.keyFormat?this.loadKeyHTTP(a,t):this.loadKeyEME(a,t);case"AES-128":return this.loadKeyHTTP(a,t);default:return Promise.reject(this.createKeyLoadError(t,g.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'.concat(r.method,'"'))))}}loadKeyEME(t,e){const s={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const e=this.emeController.loadKey(s);if(e)return(t.keyLoadPromise=e.then((e=>(t.mediaKeySessionContext=e,s)))).catch((e=>{throw t.keyLoadPromise=null,e}))}return Promise.resolve(s)}loadKeyHTTP(t,e){const s=this.config,i=new(0,s.loader)(s);return e.keyLoader=t.loader=i,t.keyLoadPromise=new Promise(((r,n)=>{const a={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},o=s.keyLoadPolicy.default,c={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(t,e,s,i)=>{const{frag:a,keyInfo:o,url:l}=s;if(!a.decryptdata||o!==this.keyUriToKeyInfo[l])return n(this.createKeyLoadError(a,g.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),i));o.decryptdata.key=a.decryptdata.key=new Uint8Array(t.data),a.keyLoader=null,o.loader=null,r({frag:a,keyInfo:o})},onError:(t,s,i,r)=>{this.resetLoader(s),n(this.createKeyLoadError(e,g.KEY_LOAD_ERROR,new Error("HTTP Error ".concat(t.code," loading key ").concat(t.text)),i,l({url:a.url,data:void 0},t)))}
1,onTimeout:(t,s,i)=>{this.resetLoader(s),n(this.createKeyLoadError(e,g.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(t,s,i)=>{this.resetLoader(s),n(this.createKeyLoadError(e,g.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};i.load(a,c,h)}))}resetLoader(t){const{frag:e,keyInfo:s,url:i}=t,r=s.loader;e.keyLoader===r&&(e.keyLoader=null,s.loader=null),delete this.keyUriToKeyInfo[i],r&&r.destroy()}}class ms{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}const ps={length:0,start:()=>0,end:()=>0};class ys{static isBuffered(t,e){try{if(t){const s=ys.getBuffered(t);for(let t=0;t<s.length;t++)if(e>=s.start(t)&&e<=s.end(t))return!0}}catch(s){}return!1}static bufferInfo(t,e,s){try{if(t){const i=ys.getBuffered(t),r=[];let n;for(n=0;n<i.length;n++)r.push({start:i.start(n),end:i.end(n)});return this.bufferedInfo(r,e,s)}}catch(i){}return{len:0,start:e,end:e,nextStart:void 0}}static bufferedInfo(t,e,s){e=Math.max(0,e),t.sort((function(t,e){const s=t.start-e.start;return s||e.end-t.end}));let i=[];if(s)for(let l=0;l<t.length;l++){const e=i.length;if(e){const r=i[e-1].end;t[l].start-r<s?t[l].end>r&&(i[e-1].end=t[l].end):i.push(t[l])}else i.push(t[l])}else i=t;let r,n=0,a=e,o=e;for(let l=0;l<i.length;l++){const t=i[l].start,c=i[l].end;if(e+s>=t&&e<c)a=t,o=c,n=o-e;else if(e+s<t){r=t;break}}return{len:n,start:a||0,end:o||0,nextStart:r}}static getBuffered(t){try{return t.buffered}catch(e){return v.log("failed to get media.buffered",e),ps}}}class Ts{constructor(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,n=arguments.length>5&&void 0!==arguments[5]&&arguments[5];this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=e,this.id=s,this.size=i,this.part=r,this.partial=n}}function vs(t,e){let s=null;for(let i=0,r=t.length;i<r;i++){const r=t[i];if(r&&r.cc===e){s=r;break}}return s}function Es(t,e){if(t){const s=t.start+e;t.start=t.startPTS=s,t.endPTS=s+t.duration}}function Ss(t,e){const s=e.fragments;for(let i=0,r=s.length;i<r;i++)Es(s[i],t);e.fragmentHint&&Es(e.fragmentHint,t),e.alignedSliding=!0}function Ls(t,e,s){e&&(!function(t,e,s){if(function(t,e,s){return!(!e.details||!(s.endCC>s.startCC||t&&t.cc<s.startCC))}(t,s,e)){const t=function(t,e){const s=t.fragments,i=e.fragments;if(!i.length||!s.length)return void v.log("No fragments to align");const r=vs(s,i[0].cc);if(r&&(!r||r.startPTS))return r;v.log("No frag in previous level to align on")}(s.details,e);t&&d(t.start)&&(v.log("Adjusting PTS using last level due to CC increase within current level ".concat(e.url)),Ss(t.start,e))}}(t,s,e),!s.alignedSliding&&e.details&&function(t,e){if(!e.fragments.length||!t.hasProgramDateTime||!e.hasProgramDateTime)return;const s=e.fragments[0].programDateTime,i=t.fragments[0].programDateTime,r=(i-s)/1e3+e.fragments[0].start;r&&d(r)&&(v.log("Adjusting PTS using programDateTime delta ".concat(i-s,"ms, sliding:").concat(r.toFixed(3)," ").concat(t.url," ")),Ss(r,t))}(s,e.details),s.alignedSliding||!e.details||s.skippedSegments||_e(e.details,s))}function As(t,e){if(!t.hasProgramDateTime||!e.hasProgramDateTime)return;const s=t.fragments,i=e.fragments;if(!s.length||!i.length)return;const r=i[Math.round(i.length/2)-1],n=vs(s,r.cc)||s[Math.round(s.length/2)-1],a=r.programDateTime,o=n.programDateTime;if(null===a||null===o)return;Ss((o-a)/1e3-(n.start-r.start),t)}class Rs{constructor(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}
vendor: 4,412 bytes, line 1
1decrypt(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)}}class bs{constructor(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}class ks{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(t){const e=new DataView(t),s=new Uint32Array(4);for(let i=0;i<4;i++)s[i]=e.getUint32(4*i);return s}initTable(){const t=this.sBox,e=this.invSBox,s=this.subMix,i=s[0],r=s[1],n=s[2],a=s[3],o=this.invSubMix,l=o[0],c=o[1],h=o[2],d=o[3],u=new Uint32Array(256);let f=0,g=0,m=0;for(m=0;m<256;m++)u[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){let s=g^g<<1^g<<2^g<<3^g<<4;s=s>>>8^255&s^99,t[f]=s,e[s]=f;const o=u[f],m=u[o],p=u[m];let y=257*u[s]^16843008*s;i[f]=y<<24|y>>>8,r[f]=y<<16|y>>>16,n[f]=y<<8|y>>>24,a[f]=y,y=16843009*p^65537*m^257*o^16843008*f,l[s]=y<<24|y>>>8,c[s]=y<<16|y>>>16,h[s]=y<<8|y>>>24,d[s]=y,f?(f=o^u[u[u[p^o]]],g^=u[u[g]]):f=g=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let s=!0,i=0;for(;i<e.length&&s;)s=e[i]===this.key[i],i++;if(s)return;this.key=e;const r=this.keySize=e.length;if(4!==r&&6!==r&&8!==r)throw new Error("Invalid aes key size="+r);const n=this.ksRows=4*(r+6+1);let a,o;const l=this.keySchedule=new Uint32Array(n),c=this.invKeySchedule=new Uint32Array(n),h=this.sBox,d=this.rcon,u=this.invSubMix,f=u[0],g=u[1],m=u[2],p=u[3];let y,T;for(a=0;a<n;a++)a<r?y=l[a]=e[a]:(T=y,a%r===0?(T=T<<8|T>>>24,T=h[T>>>24]<<24|h[T>>>16&255]<<16|h[T>>>8&255]<<8|h[255&T],T^=d[a/r|0]<<24):r>6&&a%r===4&&(T=h[T>>>24]<<24|h[T>>>16&255]<<16|h[T>>>8&255]<<8|h[255&T]),l[a]=y=(l[a-r]^T)>>>0);for(o=0;o<n;o++)a=n-o,T=3&o?l[a]:l[a-4],c[o]=o<4||a<=4?T:f[h[T>>>24]]^g[h[T>>>16&255]]^m[h[T>>>8&255]]^p[h[255&T]],c[o]=c[o]>>>0}networkToHostOrderSwap(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24}decrypt(t,e,s){const i=this.keySize+6,r=this.invKeySchedule,n=this.invSBox,a=this.invSubMix,o=a[0],l=a[1],c=a[2],h=a[3],d=this.uint8ArrayToUint32Array_(s);let u=d[0],f=d[1],g=d[2],m=d[3];const p=new Int32Array(t),y=new Int32Array(p.length);let T,v,E,S,L,A,R,b,k,D,I,w,C,_;const P=this.networkToHostOrderSwap;for(;e<p.length;){for(k=P(p[e]),D=P(p[e+1]),I=P(p[e+2]),w=P(p[e+3]),L=k^r[0],A=w^r[1],R=I^r[2],b=D^r[3],C=4,_=1;_<i;_++)T=o[L>>>24]^l[A>>16&255]^c[R>>8&255]^h[255&b]^r[C],v=o[A>>>24]^l[R>>16&255]^c[b>>8&255]^h[255&L]^r[C+1],E=o[R>>>24]^l[b>>16&255]^c[L>>8&255]^h[255&A]^r[C+2],S=o[b>>>24]^l[L>>16&255]^c[A>>8&255]^h[255&R]^r[C+3],L=T,A=v,R=E,b=S,C+=4;T=n[L>>>24]<<24^n[A>>16&255]<<16^n[R>>8&255]<<8^n[255&b]^r[C],v=n[A>>>24]<<24^n[R>>16&255]<<16^n[b>>8&255]<<8^n[255&L]^r[C+1],E=n[R>>>24]<<24^n[b>>16&255]<<16^n[L>>8&255]<<8^n[255&A]^r[C+2],S=n[b>>>24]<<24^n[L>>16&255]<<16^n[A>>8&255]<<8^n[255&R]^r[C+3],y[e]=P(T^u),y[e+1]=P(S^f),y[e+2]=P(E^g),y[e+3]=P(v^m),u=k,f=D,g=I,m=w,e+=4}return y.buffer}}class Ds{constructor(t){let{removePKCS7Padding:e=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=e,e)try{const t=self.crypto;t&&(this.subtle=t.subtle||t.webkitSubtle)}catch(s){}null===this.subtle&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:t,remainderData:e}=this;if(!t||e)return this.reset(),null;const s=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?function(t){const e=t.byteLength,s=e&&new DataView(t.buffer).getUint8(e-1);return s?q(t,0,e-s):t}(s):s}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(t,e,s){return this.useSoftware?new Promise(((i,r)=>
vendor: 7,603 bytes, line 1
1{this.softwareDecrypt(new Uint8Array(t),e,s);const n=this.flush();n?i(n.buffer):r(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(t),e,s)}softwareDecrypt(t,e,s){const{currentIV:i,currentResult:r,remainderData:n}=this;this.logOnce("JS AES decrypt"),n&&(t=At(n,t),this.remainderData=null);const a=this.getValidChunk(t);if(!a.length)return null;i&&(s=i);let o=this.softwareDecrypter;o||(o=this.softwareDecrypter=new ks),o.expandKey(e);const l=r;return this.currentResult=o.decrypt(a.buffer,0,s),this.currentIV=q(a,-16).buffer,l||null}webCryptoDecrypt(t,e,s){const i=this.subtle;return this.key===e&&this.fastAesKey||(this.key=e,this.fastAesKey=new bs(i,e)),this.fastAesKey.expandKey().then((e=>{if(!i)return Promise.reject(new Error("web crypto not initialized"));this.logOnce("WebCrypto AES decrypt");return new Rs(i,new Uint8Array(s)).decrypt(t.buffer,e)})).catch((i=>(v.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, ".concat(i.name,": ").concat(i.message)),this.onWebCryptoError(t,e,s))))}onWebCryptoError(t,e,s){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,s);const i=this.flush();if(i)return i.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const s=t.length-t.length%16;return s!==t.length&&(e=q(t,0,s),this.remainderData=q(t,s)),e}logOnce(t){this.logEnabled&&(v.log("[decrypter]: ".concat(t)),this.logEnabled=!1)}}const Is=function(t){let e="";const s=t.length;for(let i=0;i<s;i++)e+="[".concat(t.start(i).toFixed(3),"-").concat(t.end(i).toFixed(3),"]");return e},ws="STOPPED",Cs="IDLE",_s="KEY_LOADING",Ps="FRAG_LOADING",xs="FRAG_LOADING_WAITING_RETRY",Fs="WAITING_TRACK",Ms="PARSING",Os="PARSED",Ns="ENDED",Us="ERROR",Bs="WAITING_INIT_PTS",Gs="WAITING_LEVEL";class Ks extends ms{constructor(t,e,s,i,r){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=ws,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=r,this.logPrefix=i,this.log=v.log.bind(v,"".concat(i,":")),this.warn=v.warn.bind(v,"".concat(i,":")),this.hls=t,this.fragmentLoader=new hs(t.config),this.keyLoader=s,this.fragmentTracker=e,this.config=t.config,this.decrypter=new Ds(t.config),t.on(u.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;null!=t&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ws}_streamEnded(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;const s=e.partList;if(null!=s&&s.length){const t=s[s.length-1];return ys.isBuffered(this.media,t.start+t.duration/2)}const i=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(i)}getLevelDetails(){var t;if(this.levels&&null!==this.levelLastLoaded)return null==(t=this.levels[this.levelLastLoaded])?void 0:t.details}onMediaAttached(t,e){const s=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),s.addEventListener("seeking",this.onvseeking),s.addEventListener("ended",this.onvended);const i=this.config;this.levels&&i.autoStartLoad&&this.state===ws&&this.startLoad(i.startPosition)}onMediaDetaching(){const t=this.media;null!=t&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:t,fragCurrent:e,media:s,mediaBuffer:i,state:r}=this,n=s?s.currentTime:0,a=ys.bufferInfo(i||s,n,t.maxBufferHole);if(this.log("media seeking to ".concat(d(n)?n.toFixed(3):n,", state: ").concat(r)),this.state===Ns)this.resetLoadingState();else if(e){const s=t.maxFragLookUpTolerance,i=e.start-s,r=e.start+e.duration+s;if(!a.len||r<a.start||i>a.end){const t=n>r;(n<i||t)&&(t&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}s&&(this.fragmentTracker.removeFragmentsInRange(n,1/0,this.playlistType,!0),this.lastCurrentTime=n),this.loadedmetadata||a.len||(this.nextLoadPosition=this.startPosition=n),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(t,e){this.startTimeOffset=e.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=ws,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(t,e,s){this._loadFragForPlayback(t,e,s)}_loadFragForPlayback(t,e,s){this._doFragLoad(t,e,s,(e=>{if(this.fragContextChanged(t))return this.warn("Fragment ".concat(t.sn).concat(e.part?" p: "+e.part.index:""," of level ").concat(t.level," was dropped during download.")),void this.fragmentTracker.removeFragment(t);t.stats.chunkCount++,this._handleFragmentLoadProgress(e)})).then((e=>{if(!e)return;const s=this.state;this.fragContextChanged(t)?(s===Ps||!this.fragCurrent&&s===Ms)&&(this.fragmentTracker.removeFragment(t),this.state=Cs):("payload"in e&&(this.log("Loaded fragment ".concat(t.sn," of level ").concat(t.level)),this.hls.trigger(u.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))})).catch((e=>{this.state!==ws&&this.state!==Us&&(this.warn(e),this.resetFragmentLoading(t))}))}clearTrackerIfNeeded(t){var e;const{fragmentTracker:s}=this;if(s.getState(t)===is){const e=t.type,i=this.getFwdBufferInfo(this.mediaBuffer,e),r=Math.max(t.duration,i?i.len:this.config.maxBufferLength);this.reduceMaxBufferLength(r)&&s.removeFragment(t)}else 0===(null==(e=this.mediaBuffer)?void 0:e.buffered.length)?s.removeAllFragments():s.hasParts(t.type)&&(s.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),s.getState(t)===rs&&s.removeFragment(t))}checkLiveUpdate(t){if(t.updated&&!t.live){const e=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)}flushMainBuffer(t,e){if(!(t-e))return;const s={startOffset:t,endOffset:e,type:arguments.length>2&&void 0!==arguments[2]?arguments[2]:null};this.hls.trigger(u.BUFFER_FLUSHING,s)}_loadInitSegment(t,e){this._doFragLoad(t,e).then((e=>{if(!e||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return e})).then((e=>{const{hls:s}=this,{payload:i}=e,r=t.decryptdata;if(i&&i.byteLength>0&&r&&r.key&&r.iv&&"AES-128"===r.method){const n=self.performance.now();
1return this.decrypter.decrypt(new Uint8Array(i),r.key.buffer,r.iv.buffer).catch((e=>{throw s.trigger(u.ERROR,{type:f.MEDIA_ERROR,details:g.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e})).then((i=>{const r=self.performance.now();return s.trigger(u.FRAG_DECRYPTED,{frag:t,payload:i,stats:{tstart:n,tdecrypt:r}}),e.payload=i,e}))}return e})).then((s=>{const{fragCurrent:i,hls:r,levels:n}=this;if(!n)throw new Error("init load aborted, missing levels");const a=t.stats;this.state=Cs,e.fragmentError=0,t.data=new Uint8Array(s.payload),a.parsing.start=a.buffering.start=self.performance.now(),a.parsing.end=a.buffering.end=self.performance.now(),s.frag===i&&r.trigger(u.FRAG_BUFFERED,{stats:a,frag:i,part:null,id:t.type}),this.tick()})).catch((e=>{this.state!==ws&&this.state!==Us&&(this.warn(e),this.resetFragmentLoading(t))}))}fragContextChanged(t){const{fragCurrent:e}=this;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId}fragBufferedComplete(t,e){var s,i,r,n;const a=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered ".concat(t.type," sn: ").concat(t.sn).concat(e?" part: "+e.index:""," of ").concat(this.playlistType===re?"level":"track"," ").concat(t.level," (frag:[").concat((null!=(s=t.startPTS)?s:NaN).toFixed(3),"-").concat((null!=(i=t.endPTS)?i:NaN).toFixed(3),"] > buffer:").concat(a?Is(ys.getBuffered(a)):"(detached)",")")),this.state=Cs,a&&(!this.loadedmetadata&&t.type==re&&a.buffered.length&&(null==(r=this.fragCurrent)?void 0:r.sn)===(null==(n=this.fragPrevious)?void 0:n.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){const{transmuxer:e}=this;if(!e)return;const{frag:s,part:i,partsLoaded:r}=t,n=!r||0===r.length||r.some((t=>!t)),a=new Ts(s.level,s.sn,s.stats.chunkCount+1,0,i?i.index:-1,!n);e.flush(a)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3?arguments[3]:void 0;var r;const n=null==e?void 0:e.details;if(!this.levels||!n)throw new Error("frag load aborted, missing level".concat(n?"":" detail","s"));let a=null;if(!t.encrypted||null!=(r=t.decryptdata)&&r.key?!t.encrypted&&n.encryptedFragments.length&&this.keyLoader.loadClear(t,n.encryptedFragments):(this.log("Loading key for ".concat(t.sn," of [").concat(n.startSN,"-").concat(n.endSN,"], ").concat("[stream-controller]"===this.logPrefix?"level":"track"," ").concat(t.level)),this.state=_s,this.fragCurrent=t,a=this.keyLoader.load(t).then((t=>{if(!this.fragContextChanged(t.frag))return this.hls.trigger(u.KEY_LOADED,t),this.state===_s&&(this.state=Cs),t})),this.hls.trigger(u.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(a=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),s=Math.max(t.start,s||0),this.config.lowLatencyMode&&"initSegment"!==t.sn){const r=n.partList;if(r&&i){s>t.end&&n.fragmentHint&&(t=n.fragmentHint);const o=this.getNextPart(r,t,s);if(o>-1){const l=r[o];let c;return this.log("Loading part sn: ".concat(t.sn," p: ").concat(l.index," cc: ").concat(t.cc," of playlist [").concat(n.startSN,"-").concat(n.endSN,"] parts [0-").concat(o,"-").concat(r.length-1,"] ").concat("[stream-controller]"===this.logPrefix?"level":"track",": ").concat(t.level,", target: ").concat(parseFloat(s.toFixed(3)))),this.nextLoadPosition=l.start+l.duration,this.state=Ps,c=a?a.then((s=>!s||this.fragContextChanged(s.frag)?null:this.doFragPartsLoad(t,l,e,i))).catch((t=>this.handleFragLoadError(t))):this.doFragPartsLoad(t,l,e,i).catch((t=>this.handleFragLoadError(t))),this.hls.trigger(u.FRAG_LOADING,{frag:t,part:l,targetBufferTime:s}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!t.url||this.loadedEndOfParts(r,s))return Promise.resolve(null)}}this.log("Loading fragment ".concat(t.sn," cc: ").concat(t.cc," ").concat(n?"of ["+n.startSN+"-"+n.endSN+"] ":"").concat("[stream-controller]"===this.logPrefix?"level":"track",": ").concat(t.level,", target: ").concat(parseFloat(s.toFixed(3)))),d(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Ps;const o=this.config.progressive;let l;return l=o&&a?a.then((e=>!e||this.fragContextChanged(null==e?void 0:e.frag)?null:this.fragmentLoader.load(t,i))).catch((t=>this.handleFragLoadError(t))):Promise.all([this.fragmentLoader.load(t,o?i:void 0),a]).then((t=>{let[e]=t;return!o&&e&&i&&i(e),e})).catch((t=>this.handleFragLoadError(t))),this.hls.trigger(u.FRAG_LOADING,{frag:t,targetBufferTime:s}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):l}doFragPartsLoad(t,e,s,i){return new Promise(((r,n)=>{var a;const o=[],l=null==(a=s.details)?void 0:a.partList,c=e=>{this.fragmentLoader.loadPart(t,e,i).then((i=>{o[e.index]=i;const n=i.part;this.hls.trigger(u.FRAG_LOADED,i);const a=xe(s,t.sn,e.index+1)||Fe(l,t.sn,e.index+1);if(!a)return r({frag:t,part:n,partsLoaded:o});c(a)})).catch(n)};c(e)}))}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===g.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(u.ERROR,e)}else this.hls.trigger(u.ERROR,{type:f.OTHER_ERROR,details:g.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==Ms)return void(this.fragCurrent||this.state===ws||this.state===Us||(this.state=Cs));const{frag:s,part:i,level:r}=e,n=self.performance.now();s.stats.parsing.end=n,i&&(i.stats.parsing.end=n),this.updateLevelTiming(s,i,r,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:s}=this,{level:i,sn:r,part:n}=t;if(null==e||!e[i])return this.warn("Levels object was unset while buffering fragment ".concat(r," of level ").concat(i,". The current chunk will not be buffered.")),null;const a=e[i],o=n>-1?xe(a,r,n):null,l=o?o.fragment:function(t,e,s){if(null==t||!t.details)return null;const i=t.details;let r=i.fragments[e-i.startSN];return r||(r=i.fragmentHint,r&&r.sn===e?r:e<i.startSN&&s&&s.sn===e?s:null)}(a,r,s);return l?(s&&s!==l&&(l.stats=s.stats),{frag:l,part:o,level:a}):null}bufferFragmentData(t,e,s,i,r){var n;if(!t||this.state!==Ms)return;const{data1:a,data2:o}=t;let l=a;if(a&&o&&(l=At(a,o)),null==(n=l)||!n.length)return;const c={type:t.type,frag:e,part:s,chunkMeta:i,parent:e.type,data:l};if(this.hls.trigger(u.BUFFER_APPENDING,c),t.dropped&&t.independent&&!s){if(r)return;this.flushBufferGap(e)}}flushBufferGap(t){const e=this.media;if(!e)return;if(!ys.isBuffered(e,e.currentTime))return void this.flushMainBuffer(0,t.start);const s=e.currentTime,i=ys.bufferInfo(e,s,0),r=t.duration,n=Math.min(2*this.config.maxFragLookUpTolerance,.25*r),a=Math.max(Math.min(t.start-n,i.end-n),s+n);t.start-a>n&&this.flushMainBuffer(a,t.start)}getFwdBufferInfo(t,e){const s=this.getLoadPosition();return d(s)?this.getFwdBufferInfoAtPos(t,s,e):null}getFwdBufferInfoAtPos(t,e,s){const{config:{maxBufferHole:i}}=this,r=ys.bufferInfo(t,e,i);if(0===r.len&&void 0!==r.nextStart){const n=this.fragmentTracker.getBufferedFrag(e,s);
1if(n&&r.nextStart<n.end)return ys.bufferInfo(t,e,Math.max(r.nextStart,i))}return r}getMaxBufferLength(t){const{config:e}=this;let s;return s=t?Math.max(8*e.maxBufferSize/t,e.maxBufferLength):e.maxBufferLength,Math.min(s,e.maxMaxBufferLength)}reduceMaxBufferLength(t){const e=this.config,s=t||e.maxBufferLength;return e.maxMaxBufferLength>=s&&(e.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to ".concat(e.maxMaxBufferLength,"s")),!0)}getAppendedFrag(t){const e=this.fragmentTracker.getAppendedFrag(t,re);return e&&"fragment"in e?e.fragment:e}getNextFragment(t,e){const s=e.fragments,i=s.length;if(!i)return null;const{config:r}=this,n=s[0].start;let a;if(e.live){const n=r.initialLiveManifestSize;if(i<n)return this.warn("Not enough fragments to start playback (have: ".concat(i,", need: ").concat(n,")")),null;e.PTSKnown||this.startFragRequested||-1!==this.startPosition||(a=this.getInitialLiveFragment(e,s),this.startPosition=a?this.hls.liveSyncPosition||a.start:t)}else t<=n&&(a=s[0]);if(!a){const s=r.lowLatencyMode?e.partEnd:e.fragmentEnd;a=this.getFragmentAtPosition(t,s,e)}return this.mapToInitFragWhenRequired(a)}isLoopLoading(t,e){const s=this.fragmentTracker.getState(t);return(s===ns||s===rs&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,s,i,r){const n=t.gap,a=this.getNextFragment(this.nextLoadPosition,e);if(null===a)return a;if(t=a,n&&t&&!t.gap&&s.nextStart){const e=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,s.nextStart,i);if(null!==e&&s.len+e.len>=r)return this.log('buffer full after gaps in "'.concat(i,'" playlist starting at sn: ').concat(t.sn)),null}return t}mapToInitFragWhenRequired(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment}getNextPart(t,e,s){let i=-1,r=!1,n=!0;for(let a=0,o=t.length;a<o;a++){const o=t[a];if(n=n&&!o.independent,i>-1&&s<o.start)break;const l=o.loaded;l?i=-1:(r||o.independent||n)&&o.fragment===e&&(i=a),r=l}return i}loadedEndOfParts(t,e){const s=t[t.length-1];return s&&e>s.start&&s.loaded}getInitialLiveFragment(t,e){const s=this.fragPrevious;let i=null;if(s){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: ".concat(s.programDateTime)),i=function(t,e,s){if(null===e||!Array.isArray(t)||!t.length||!d(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;s=s||0;for(let i=0;i<t.length;++i){const r=t[i];if(Ve(e,s,r))return r}return null}(e,s.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){const r=s.sn+1;if(r>=t.startSN&&r<=t.endSN){const n=e[r-t.startSN];s.cc===n.cc&&(i=n,this.log("Live playlist, switching playlist, load frag with next SN: ".concat(i.sn)))}i||(i=function(t,e){return Ge.search(t,(t=>t.cc<e?1:t.cc>e?-1:0))}(e,s.cc),i&&this.log("Live playlist, switching playlist, load frag with same CC: ".concat(i.sn)))}}else{const e=this.hls.liveSyncPosition;null!==e&&(i=this.getFragmentAtPosition(e,this.bitrateTest?t.fragmentEnd:t.edge,t))}return i}getFragmentAtPosition(t,e,s){const{config:i}=this;let{fragPrevious:r}=this,{fragments:n,endSN:a}=s;const{fragmentHint:o}=s,l=i.maxFragLookUpTolerance,c=s.partList,h=!!(i.lowLatencyMode&&null!=c&&c.length&&o);let d;if(h&&o&&!this.bitrateTest&&(n=n.concat(o),a=o.sn),t<e){d=Ke(r,n,t,t>e-l?0:l)}else d=n[n.length-1];if(d){const t=d.sn-s.startSN,e=this.fragmentTracker.getState(d);if((e===ns||e===rs&&d.gap)&&(r=d),r&&d.sn===r.sn&&(!h||c[0].fragment.sn>d.sn)){if(r&&d.level===r.level){const e=n[t+1];d=d.sn<a&&this.fragmentTracker.getState(e)!==ns?e:null}}}return d}synchronizeToLiveEdge(t){const{config:e,media:s}=this;if(!s)return;const i=this.hls.liveSyncPosition,r=s.currentTime,n=t.fragments[0].start,a=t.edge,o=r>=n-e.maxFragLookUpTolerance&&r<=a;if(null!==i&&s.duration>i&&(r<i||!o)){const n=void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!o&&s.readyState<4||r<a-n)&&(this.loadedmetadata||(this.nextLoadPosition=i),s.readyState&&(this.warn("Playback: ".concat(r.toFixed(3)," is located too far from the end of live sliding playlist: ").concat(a,", reset currentTime to : ").concat(i.toFixed(3))),s.currentTime=i))}}alignPlaylists(t,e){const{levels:s,levelLastLoaded:i,fragPrevious:r}
vendor: 16,255 bytes, line 1
1=this,n=null!==i?s[i]:null,a=t.fragments.length;if(!a)return this.warn("No fragments in live playlist"),0;const o=t.fragments[0].start,l=!e,c=t.alignedSliding&&d(o);if(l||!c&&!o){Ls(r,n,t);const s=t.fragments[0].start;return this.log("Live playlist sliding: ".concat(s.toFixed(2)," start-sn: ").concat(e?e.startSN:"na","->").concat(t.startSN," prev-sn: ").concat(r?r.sn:"na"," fragments: ").concat(a)),s}return o}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)}setStartPosition(t,e){let s=this.startPosition;if(s<e&&(s=-1),-1===s||-1===this.lastCurrentTime){const i=null!==this.startTimeOffset,r=i?this.startTimeOffset:t.startTimeOffset;null!==r&&d(r)?(s=e+r,r<0&&(s+=t.totalduration),s=Math.min(Math.max(e,s),e+t.totalduration),this.log("Start time offset ".concat(r," found in ").concat(i?"multivariant":"media"," playlist, adjust startPosition to ").concat(s)),this.startPosition=s):t.live?s=this.hls.liveSyncPosition||e:this.startPosition=s=0,this.lastCurrentTime=s}this.nextLoadPosition=s}getLoadPosition(){const{media:t}=this;let e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e}handleFragLoadAborted(t,e){this.transmuxer&&"initSegment"!==t.sn&&t.stats.aborted&&(this.warn("Fragment ".concat(t.sn).concat(e?" part "+e.index:""," of level ").concat(t.level," was aborted")),this.resetFragmentLoading(t))}resetFragmentLoading(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===xs)||(this.state=Cs)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const t=this.getCurrentContext(e.chunkMeta);t&&(e.frag=t.frag)}const s=e.frag;if(!s||s.type!==t||!this.levels)return;var i;if(this.fragContextChanged(s))return void this.warn("Frag load error must match current frag to retry ".concat(s.url," > ").concat(null==(i=this.fragCurrent)?void 0:i.url));const r=e.details===g.FRAG_GAP;r&&this.fragmentTracker.fragBuffered(s,!0);const n=e.errorAction,{action:a,retryCount:o=0,retryConfig:l}=n||{};if(n&&a===qe&&l){var c;this.resetStartWhenNotLoaded(null!=(c=this.levelLastLoaded)?c:s.level);const i=Ne(l,o);this.warn("Fragment ".concat(s.sn," of ").concat(t," ").concat(s.level," errored with ").concat(e.details,", retrying loading ").concat(o+1,"/").concat(l.maxNumRetry," in ").concat(i,"ms")),n.resolved=!0,this.retryDate=self.performance.now()+i,this.state=xs}else l&&n?(this.resetFragmentErrors(t),o<l.maxNumRetry?r||(n.resolved=!0):v.warn("".concat(e.details," reached or exceeded max retry (").concat(o,")"))):(null==n?void 0:n.action)===We?this.state=Gs:this.state=Us;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===Ms||this.state===Os){const e=t.parent,s=this.getFwdBufferInfo(this.mediaBuffer,e),i=s&&s.len>.5;i&&this.reduceMaxBufferLength(s.len);const r=!i;return r&&this.warn("Buffer full error while media.currentTime is not buffered, flush ".concat(e," buffer")),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),r}return!1}resetFragmentErrors(t){t===ne&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==ws&&(this.state=Cs)}afterBufferFlushed(t,e,s){if(!t)return;const i=ys.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,i,s),this.state===Ns&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Cs}resetStartWhenNotLoaded(t){if(!this.loadedmetadata){this.startFragRequested=!1;const e=this.levels?this.levels[t].details:null;null!=e&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(t){var e;this.warn("The loading context changed while buffering fragment ".concat(t.sn," of level ").concat(t.level,". This chunk will not be buffered.")),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(null!=(e=this.levelLastLoaded)?e:t.level),this.resetLoadingState()}removeUnbufferedFrags(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(t,e,s,i){var r;const n=s.details;if(!n)return void this.warn("level.details undefined");if(Object.keys(t.elementaryStreams).reduce(((e,r)=>{const a=t.elementaryStreams[r];if(a){const o=a.endPTS-a.startPTS;if(o<=0)return this.warn("Could not parse fragment ".concat(t.sn," ").concat(r," duration reliably (").concat(o,")")),e||!1;const l=i?0:we(n,t,a.startPTS,a.endPTS,a.startDTS,a.endDTS);return this.hls.trigger(u.LEVEL_PTS_UPDATED,{details:n,level:s,drift:l,type:r,frag:t,start:a.startPTS,end:a.endPTS}),!0}return e}),!1))s.fragmentError=0;else if(null===(null==(r=this.transmuxer)?void 0:r.error)){const e=new Error("Found no media in fragment ".concat(t.sn," of level ").concat(t.level," resetting transmuxer to fallback to playlist timing"));if(0===s.fragmentError&&(s.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(e.message),this.hls.trigger(u.ERROR,{type:f.MEDIA_ERROR,details:g.FRAG_PARSING_ERROR,fatal:!1,error:e,frag:t,reason:"Found no media in msn ".concat(t.sn,' of level "').concat(s.url,'"')}),!this.hls)return;this.resetTransmuxer()}this.state=Os,this.hls.trigger(u.FRAG_PARSED,{frag:t,part:e})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(t){var e,s,i;"demuxerWorker"===t.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(e=null!=(s=this.levelLastLoaded)?s:null==(i=this.fragCurrent)?void 0:i.level)?e:0),this.resetLoadingState())}set state(t){const e=this._state;e!==t&&(this._state=t,this.log("".concat(e,"->").concat(t)))}get state(){return this._state}}function Hs(){return self.SourceBuffer||self.WebKitSourceBuffer}function Vs(){return{type:arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",id:-1,pid:-1,inputTimeScale:arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4,sequenceNumber:-1,samples:[],dropped:0}}class Ys{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(t,e,s,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,s){}demux(t,e){this.cachedData&&(t=At(this.cachedData,t),this.cachedData=null);let s,i=z(t,0),r=i?i.length:0;const n=this._audioTrack,a=this._id3Track,o=i?(t=>{const e=tt(t);for(let s=0;s<e.length;s++){const t=e[s];if(J(t))return nt(t)}})(i):void 0,l=t.length;for((null===this.basePTS||0===this.frameIndex&&d(o))&&(this.basePTS=Ws(o,e,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ge,duration:Number.POSITIVE_INFINITY});r<l;){if(this.canParse(t,r)){const e=this.appendFrame(n,t,r);e?(this.frameIndex++,this.lastPTS=e.sample.pts,r+=e.length,s=r):r=l}else $(t,r)?(i=z(t,r),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ge,duration:Number.POSITIVE_INFINITY}),r+=i.length,s=r):r++;if(r===l&&s!==l){const e=q(t,s);this.cachedData?this.cachedData=At(this.cachedData,e):this.cachedData=e}}return{audioTrack:n,videoTrack:Vs(),id3Track:a,textTrack:Vs()}}demuxSampleAes(t,e,s){return Promise.reject(new Error("[".concat(this,"] This demuxer does not support Sample-AES decryption")))}flush(t){const e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:Vs(),id3Track:this._id3Track,textTrack:Vs()}}destroy(){}}const Ws=(t,e,s)=>{if(d(t))return 90*t;return 9e4*e+(s?9e4*s.baseTime/s.timescale:0)};function qs(t,e){return 255===t[e]&&240===(246&t[e+1])}function js(t,e){return 1&t[e+1]?7:9}function Xs(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function zs(t,e){return e+1<t.length&&qs(t,e)}function Qs(t,e){if(zs(t,e)){const s=js(t,e);if(e+s>=t.length)return!1;const i=Xs(t,e);if(i<=s)return!1;const r=e+i;return r===t.length||zs(t,r)}return!1}function $s(t,e,s,i,r){if(!t.samplerate){const n=function(t,e,s,i){let r,n,a,o;const l=navigator.userAgent.toLowerCase(),c=i,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=1+((192&e[s+2])>>>6);const d=(60&e[s+2])>>>2;if(!(d>h.length-1))return a=(1&e[s+2])<<2,a|=(192&e[s+3])>>>6,v.log("manifest codec:".concat(i,", ADTS type:").concat(r,", samplingIndex:").concat(d)),/firefox/i.test(l)?d>=6?(r=5,o=new Array(4),n=d-3):(r=2,o=new Array(2),n=d):-1!==l.indexOf("android")?(r=2,o=new Array(2),n=d):(r=5,o=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&d>=6?n=d-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(d>=6&&1===a||/vivaldi/i.test(l))||!i&&1===a)&&(r=2,o=new Array(2)),n=d)),o[0]=r<<3,o[0]|=(14&d)>>1,o[1]|=(1&d)<<7,o[1]|=a<<3,5===r&&(o[1]|=(14&n)>>1,o[2]=(1&n)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:h[d],channelCount:a,codec:"mp4a.40."+r,manifestCodec:c};t.trigger(u.ERROR,{type:f.MEDIA_ERROR,details:g.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:".concat(d)})}(e,s,i,r);if(!n)return;t.config=n.config,t.samplerate=n.samplerate,t.channelCount=n.channelCount,t.codec=n.codec,t.manifestCodec=n.manifestCodec,v.log("parsed codec:".concat(t.codec,", rate:").concat(n.samplerate,", channels:").concat(n.channelCount))}}function Js(t){return 9216e4/t}function Zs(t,e,s,i,r){const n=i+r*Js(t.samplerate),a=function(t,e){const s=js(t,e);if(e+s<=t.length){const i=Xs(t,e)-s;if(i>0)return{headerLength:s,frameLength:i}}}(e,s);let o;if(a){const{frameLength:i,headerLength:r}=a,l=r+i,c=Math.max(0,s+l-e.length);c?(o=new Uint8Array(l-r),o.set(e.subarray(s+r,e.length),0)):o=e.subarray(s+r,s+l);const h={unit:o,pts:n};return c||t.samples.push(h),{sample:h,length:l,missing:c}}const l=e.length-s;o=new Uint8Array(l),o.set(e.subarray(s,e.length),0);return{sample:{unit:o,pts:n},length:l,missing:-1}}const ti=/\/emsg[-/]ID3/i;let ei=null;const si=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],ii=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],ri=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ni=[0,1,1,4];function ai(t,e,s,i,r){if(s+24>e.length)return;const n=oi(e,s);if(n&&s+n.frameLength<=e.length){const a=i+r*(9e4*n.samplesPerFrame/n.sampleRate),o={unit:e.subarray(s,s+n.frameLength),pts:a,dts:a};return t.config=[],t.channelCount=n.channelCount,t.samplerate=n.sampleRate,t.samples.push(o),{sample:o,length:n.frameLength,missing:0}}}function oi(t,e){const s=t[e+1]>>3&3,i=t[e+1]>>1&3,r=t[e+2]>>4&15,n=t[e+2]>>2&3;if(1!==s&&0!==r&&15!==r&&3!==n){const a=t[e+2]>>1&1,o=t[e+3]>>6,l=1e3*si[14*(3===s?3-i:3===i?3:4)+r-1],c=ii[3*(3===s?0:2===s?1:2)+n],h=3===o?1:2,d=ri[s][i],u=ni[i],f=8*d*u,g=Math.floor(d*l/c+a)*u;if(null===ei){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ei=t?parseInt(t[1]):0}return!!ei&&ei<=87&&2===i&&l>=224e3&&0===o&&(t[e+3]=128|t[e+3]),{sampleRate:c,channelCount:h,frameLength:g,samplesPerFrame:f}}}function li(t,e){return 255===t[e]&&224===(224&t[e+1])&&0!==(6&t[e+1])}function ci(t,e){return e+1<t.length&&li(t,e)}function hi(t,e){if(e+1<t.length&&li(t,e)){const s=4,i=oi(t,e);let r=s;null!=i&&i.frameLength&&(r=i.frameLength);const n=e+r;return n===t.length||ci(t,n)}return!1}class di{constructor(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const t=this.data,e=this.bytesAvailable,s=t.byteLength-e,i=new Uint8Array(4),r=Math.min(4,e);if(0===r)throw new Error("no bytes available");i.set(t.subarray(s,s+r)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*r,this.bytesAvailable-=r}skipBits(t){let e;t=Math.min(t,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(e=(t-=this.bitsAvailable)>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)}readBits(t){let e=Math.min(this.bitsAvailable,t);const s=this.word>>>32-e;if(t>32&&v.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return e=t-e,e>0&&this.bitsAvailable?s<<e|this.readBits(e):s}skipLZ(){let t;for(t=0;t<this.bitsAvailable;++t)if(0!==(this.word&2147483648>>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const t=this.skipLZ();return this.readBits(t+1)-1}readEG(){const t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(t){let e,s=8,i=8;for(let r=0;r<t;r++)0!==i&&(e=this.readEG(),i=(s+e+256)%256),s=0===i?s:i}readSPS(){let t,e,s,i=0,r=0,n=0,a=0;const o=this.readUByte.bind(this),l=this.readBits.bind(this),c=this.readUEG.bind(this),h=this.readBoolean.bind(this),d=this.skipBits.bind(this),u=this.skipEG.bind(this),f=this.skipUEG.bind(this),g=this.skipScalingList.bind(this);o();const m=o();if(l(5),d(3),o(),f(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){const t=c();if(3===t&&d(1),f(),f(),d(1),h())for(e=3!==t?8:12,s=0;s<e;s++)h()&&g(s<6?16:64)}f();const p=c();if(0===p)c();else if(1===p)for(d(1),u(),u(),t=c(),s=0;s<t;s++)u();f(),d(1);const y=c(),T=c(),v=l(1);0===v&&d(1),d(1),h()&&(i=c(),r=c(),n=c(),a=c());let E=[1,1];if(h()&&h()){switch(o()){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:E=[o()<<8|o(),o()<<8|o()]}}return{width:Math.ceil(16*(y+1)-2*i-2*r),height:(2-v)*(T+1)*16-(v?2:4)*(n+a),pixelRatio:E}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class ui{constructor(t,e,s){this.keyData=void 0,this.decrypter=void 0,this.keyData=s,this.decrypter=new Ds(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,s){const i=t[e].unit;if(i.length<=16)return;const r=i.subarray(16,i.length-i.length%16),n=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(n).then((r=>{const n=new Uint8Array(r);i.set(n,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,s)}))}decryptAacSamples(t,e,s){for(;;e++){if(e>=t.length)return void s();if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,s),!this.decrypter.isSync()))return}}getAvcEncryptedData(t){const e=16*Math.floor((t.length-48)/160)+16,s=new Int8Array(e);let i=0;for(let r=32;r<t.length-16;r+=160,i+=16)s.set(t.subarray(r,r+16),i);return s}getAvcDecryptedUnit(t,e){const s=new Uint8Array(e);let i=0;for(let r=32;r<t.length-16;r+=160,i+=16)t.set(s.subarray(i,i+16),r);return t}decryptAvcSample(t,e,s,i,r){const n=Dt(r.data),a=this.getAvcEncryptedData(n);this.decryptBuffer(a.buffer).then((a=>{r.data=this.getAvcDecryptedUnit(n,a),this.decrypter.isSync()||this.decryptAvcSamples(t,e,s+1,i)}))}decryptAvcSamples(t,e,s,i){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,s=0){if(e>=t.length)return void i();const r=t[e].units;for(;!(s>=r.length);s++){const n=r[s];if(!(n.data.length<=48||1!==n.type&&5!==n.type)&&(this.decryptAvcSample(t,e,s,i,n),!this.decrypter.isSync()))return}}}}const fi=188;class gi{constructor(t,e,s){this.observer=void 0,this.config=void 0,this.typeSupp
vendor: 6,067 bytes, line 1
1orted=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=s}static probe(t){const e=gi.syncOffset(t);return e>0&&v.warn("MPEG2-TS detected but first sync word found @ offset ".concat(e)),-1!==e}static syncOffset(t){const e=t.length;let s=Math.min(940,t.length-fi)+1,i=0;for(;i<s;){let r=!1,n=-1,a=0;for(let o=i;o<e;o+=fi){if(71!==t[o]){if(a)return-1;break}if(a++,-1===n&&(n=o,0!==n&&(s=Math.min(n+18612,t.length-fi)+1)),r||(r=0===pi(t,o)),r&&a>1&&(0===n&&a>2||o+fi>s))return n}i++}return-1}static createTrack(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:ut[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}}resetInitSegment(t,e,s,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=gi.createTrack("video"),this._audioTrack=gi.createTrack("audio",i),this._id3Track=gi.createTrack("id3"),this._txtTrack=gi.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=s,this._duration=i}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_avcTrack:e,_id3Track:s}=this;t&&(t.pesData=null),e&&(e.pesData=null),s&&(s.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(t,e){let s,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i||(this.sampleAes=null);const n=this._avcTrack,a=this._audioTrack,o=this._id3Track,l=this._txtTrack;let c=n.pid,h=n.pesData,d=a.pid,m=o.pid,p=a.pesData,y=o.pesData,T=null,E=this.pmtParsed,S=this._pmtId,L=t.length;if(this.remainderData&&(L=(t=At(this.remainderData,t)).length,this.remainderData=null),L<fi&&!r)return this.remainderData=t,{audioTrack:a,videoTrack:n,id3Track:o,textTrack:l};const A=Math.max(0,gi.syncOffset(t));L-=(L-A)%fi,L<t.byteLength&&!r&&(this.remainderData=new Uint8Array(t.buffer,L,t.buffer.byteLength-L));let R=0;for(let u=A;u<L;u+=fi)if(71===t[u]){const e=!!(64&t[u+1]),r=pi(t,u);let f;if((48&t[u+3])>>4>1){if(f=u+5+t[u+4],f===u+fi)continue}else f=u+4;switch(r){case c:e&&(h&&(s=vi(h))&&this.parseAVCPES(n,l,s,!1),h={data:[],size:0}),h&&(h.data.push(t.subarray(f,u+fi)),h.size+=u+fi-f);break;case d:if(e){if(p&&(s=vi(p)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,s);break;case"mp3":this.parseMPEGPES(a,s)}p={data:[],size:0}}p&&(p.data.push(t.subarray(f,u+fi)),p.size+=u+fi-f);break;case m:e&&(y&&(s=vi(y))&&this.parseID3PES(o,s),y={data:[],size:0}),y&&(y.data.push(t.subarray(f,u+fi)),y.size+=u+fi-f);break;case 0:e&&(f+=t[f]+1),S=this._pmtId=yi(t,f);break;case S:{e&&(f+=t[f]+1);const s=Ti(t,f,this.typeSupported,i);c=s.avc,c>0&&(n.pid=c),d=s.audio,d>0&&(a.pid=d,a.segmentCodec=s.segmentCodec),m=s.id3,m>0&&(o.pid=m),null===T||E||(v.warn("MPEG-TS PMT found at ".concat(u," after unknown PID '").concat(T,"'. Backtracking to sync byte @").concat(A," to parse all TS packets.")),T=null,u=A-188),E=this.pmtParsed=!0;break}case 17:case 8191:break;default:T=r}}else R++;if(R>0){const t=new Error("Found ".concat(R," TS packet/s that do not start with 0x47"));this.observer.emit(u.ERROR,u.ERROR,{type:f.MEDIA_ERROR,details:g.FRAG_PARSING_ERROR,fatal:!1,error:t,reason:t.message})}n.pesData=h,a.pesData=p,o.pesData=y;const b={audioTrack:a,videoTrack:n,id3Track:o,textTrack:l};return r&&this.extractRemainingSamples(b),b}flush(){const{remainderData:t}=this;let e;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(t){const{audioTrack:e,videoTrack:s,id3Track:i,textTrack:r}=t,n=s.pesData,a=e.pesData,o=i.pesData;let l;if(n&&(l=vi(n))?(this.parseAVCPES(s,r,l,!0),s.pesData=null):s.pesData=n,a&&(l=vi(a))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,l);break;case"mp3":this.parseMPEGPES(e,l)}e.pesData=null}else null!=a&&a.size&&v.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=a;o&&(l=vi(o))?(this.parseID3PES(i,l),i.pesData=null):i.pesData=o}demuxSampleAes(t,e,s){const i=this.demux(t,s,!0,!this.config.progressive),r=this.sampleAes=new ui(this.observer,this.config,e);return this.decrypt(i,r)}decrypt(t,e){return new Promise((s=>{const{audioTrack:i,videoTrack:r}=t;i.samples&&"aac"===i.segmentCodec?e.decryptAacSamples(i.samples,0,(()=>{r.samples?e.decryptAvcSamples(r.samples,0,0,(()=>{s(t)})):s(t)})):r.samples&&e.decryptAvcSamples(r.samples,0,0,(()=>{s(t)}))}))}destroy(){this._duration=0}parseAVCPES(t,e,s,i){const r=this.parseAVCNALu(t,s.data);let n,a=this.avcSample,o=!1;s.data=null,a&&r.length&&!t.audFound&&(Ei(a,t),a=this.avcSample=mi(!1,s.pts,s.dts,"")),r.forEach((i=>{var r;switch(i.type){case 1:{let e=!1;n=!0;const r=i.data;if(o&&r.length>4){const t=new di(r).readSliceType();2!==t&&4!==t&&7!==t&&9!==t||(e=!0)}var l;if(e)null!=(l=a)&&l.frame&&!a.key&&(Ei(a,t),a=this.avcSample=null);a||(a=this.avcSample=mi(!0,s.pts,s.dts,"")),a.frame=!0,a.key=e;break}case 5:n=!0,null!=(r=a)&&r.frame&&!a.key&&(Ei(a,t),a=this.avcSample=null),a||(a=this.avcSample=mi(!0,s.pts,s.dts,"")),a.key=!0,a.frame=!0;break;case 6:n=!0,kt(i.data,1,s.pts,e.samples);break;case 7:if(n=!0,o=!0,!t.sps){const e=i.data,s=new di(e).readSPS();t.width=s.width,t.height=s.height,t.pixelRatio=s.pixelRatio,t.sps=[e],t.duration=this._duration;const r=e.subarray(1,4);let n="avc1.";for(let t=0;t<3;t++){let e=r[t].toString(16);e.length<2&&(e="0"+e),n+=e}t.codec=n}break;case 8:n=!0,t.pps||(t.pps=[i.data]);break;case 9:n=!1,t.audFound=!0,a&&Ei(a,t),a=this.avcSample=mi(!1,s.pts,s.dts,"");break;case 12:n=!0;break;default:n=!1,a&&(a.debug+="unknown NAL "+i.type+" ")}if(a&&n){a.units.push(i)}})),i&&a&&(Ei(a,t),this.avcSample=null)}
1getLastNalUnit(t){var e;let s,i=this.avcSample;if(i&&0!==i.units.length||(i=t[t.length-1]),null!=(e=i)&&e.units){const t=i.units;s=t[t.length-1]}return s}parseAVCNALu(t,e){const s=e.byteLength;let i=t.naluState||0;const r=i,n=[];let a,o,l,c=0,h=-1,d=0;for(-1===i&&(h=0,d=31&e[0],i=0,c=1);c<s;)if(a=e[c++],i)if(1!==i)if(a)if(1===a){if(h>=0){const t={data:e.subarray(h,c-i-1),type:d};n.push(t)}else{const s=this.getLastNalUnit(t.samples);if(s&&(r&&c<=4-r&&s.state&&(s.data=s.data.subarray(0,s.data.byteLength-r)),o=c-i-1,o>0)){const t=new Uint8Array(s.data.byteLength+o);t.set(s.data,0),t.set(e.subarray(0,o),s.data.byteLength),s.data=t,s.state=0}}c<s?(l=31&e[c],h=c,d=l,i=0):i=-1}else i=0;else i=3;else i=a?0:2;else i=a?0:1;if(h>=0&&i>=0){const t={data:e.subarray(h,s),type:d,state:i};n.push(t)}if(0===n.length){const s=this.getLastNalUnit(t.samples);if(s){const t=new Uint8Array(s.data.byteLength+e.byteLength);t.set(s.data,0),t.set(e,s.data.byteLength),s.data=t}}return t.naluState=i,n}parseAACPES(t,e){let s=0;const i=this.aacOverFlow;let r,n,a,o=e.data;if(i){this.aacOverFlow=null;const e=i.missing,r=i.sample.unit.byteLength;if(-1===e){const t=new Uint8Array(r+o.byteLength);t.set(i.sample.unit,0),t.set(o,r),o=t}else{const n=r-e;i.sample.unit.set(o.subarray(0,e),n),t.samples.push(i.sample),s=i.missing}}for(r=s,n=o.length;r<n-1&&!zs(o,r);r++);if(r!==s){let t;const e=r<n-1;t=e?"AAC PES did not start with ADTS header,offset:".concat(r):"No ADTS header found in AAC PES";const s=new Error(t);if(v.warn("parsing error: ".concat(t)),this.observer.emit(u.ERROR,u.ERROR,{type:f.MEDIA_ERROR,details:g.FRAG_PARSING_ERROR,fatal:!1,levelRetry:e,error:s,reason:t}),!e)return}if($s(t,this.observer,o,r,this.audioCodec),void 0!==e.pts)a=e.pts;else{if(!i)return void v.warn("[tsdemuxer]: AAC PES unknown PTS");{const e=Js(t.samplerate);a=i.sample.pts+e}}let l,c=0;for(;r<n;){if(l=Zs(t,o,r,a,c),r+=l.length,l.missing){this.aacOverFlow=l;break}for(c++;r<n-1&&!zs(o,r);r++);}}parseMPEGPES(t,e){const s=e.data,i=s.length;let r=0,n=0;const a=e.pts;if(void 0!==a)for(;n<i;)if(ci(s,n)){const e=ai(t,s,n,a,r);if(!e)break;n+=e.length,r++}else n++;else v.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseID3PES(t,e){if(void 0===e.pts)return void v.warn("[tsdemuxer]: ID3 PES unknown PTS");const s=h({},e,{type:this._avcTrack?pe:ge,duration:Number.POSITIVE_INFINITY});t.samples.push(s)}}function mi(t,e,s,i){return{key:t,frame:!1,pts:e,dts:s,units:[],debug:i,length:0}}function pi(t,e){return((31&t[e+1])<<8)+t[e+2]}function yi(t,e){return(31&t[e+10])<<8|t[e+11]}function Ti(t,e,s,i){const r={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},n=e+3+((15&t[e+1])<<8|t[e+2])-4;for(e+=12+((15&t[e+10])<<8|t[e+11]);e<n;){const n=pi(t,e);switch(t[e]){case 207:if(!i){v.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===r.audio&&(r.audio=n);break;case 21:-1===r.id3&&(r.id3=n);break;case 219:if(!i){v.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===r.avc&&(r.avc=n);break;case 3:case 4:!0!==s.mpeg&&!0!==s.mp3?v.log("MPEG audio found, not supported in this browser"):-1===r.audio&&(r.audio=n,r.segmentCodec="mp3");break;case 36:v.warn("Unsupported HEVC stream type found")}e+=5+((15&t[e+3])<<8|t[e+4])}return r}function vi(t){let e,s,i,r,n,a=0;const o=t.data;if(!t||0===t.size)return null;for(;o[0].length<19&&o.length>1;){const t=new Uint8Array(o[0].length+o[1].length);t.set(o[0]),t.set(o[1],o[0].length),o[0]=t,o.splice(1,1)}e=o[0];if(1===(e[0]<<16)+(e[1]<<8)+e[2]){if(s=(e[4]<<8)+e[5],s&&s>t.size-6)return null;const l=e[7];192&l&&(r=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&l?(n=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2,r-n>54e5&&(v.warn("".concat(Math.round((r-n)/9e4),"s delta between PTS and DTS, align them")),r=n)):n=r),i=e[8];let c=i+9;if(t.size<=c)return null;t.size-=c;const h=new Uint8Array(t.size);for(let t=0,s=o.length;t<s;t++){e=o[t];let s=e.byteLength;if(c){if(c>s){c-=s;continue}e=e.subarray(c),s-=c,c=0}h.set(e,a),a+=s}return s&&(s-=i+3),{data:h,pts:r,dts:n,len:s}}return null}function Ei(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){const s=e.samples,i=s.length;if(!i)return void e.dropped++;{const e=s[i-1];t.pts=e.pts,t.dts=e.dts}}e.samples.push(t)}t.debug.length&&v.log(t.pts+"/"+t.dts+":"+t.debug)}class Si{static getSilentFrame(t,e){if("mp4a.40.2"===t){if(1===e)return new Uint8Array([0,200,0,128,35,128]);if(2===e)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===e)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}const Li=Math.pow(2,32)-1;class Ai{static init(){let t;for(t in Ai.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},Ai.types)Ai.types.hasOwnProperty(t)&&(Ai.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);const e=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),s=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);Ai.HDLR_TYPES={video:e,audio:s};const i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new 
vendor: 6,229 bytes, line 1
1Uint8Array([0,0,0,0,0,0,0,0]);Ai.STTS=Ai.STSC=Ai.STCO=r,Ai.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Ai.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Ai.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),Ai.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const n=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),o=new Uint8Array([0,0,0,1]);Ai.FTYP=Ai.box(Ai.types.ftyp,n,o,n,a),Ai.DINF=Ai.box(Ai.types.dinf,Ai.box(Ai.types.dref,i))}static box(t){let e=8;for(var s=arguments.length,i=new Array(s>1?s-1:0),r=1;r<s;r++)i[r-1]=arguments[r];let n=i.length;const a=n;for(;n--;)e+=i[n].byteLength;const o=new Uint8Array(e);for(o[0]=e>>24&255,o[1]=e>>16&255,o[2]=e>>8&255,o[3]=255&e,o.set(t,4),n=0,e=8;n<a;n++)o.set(i[n],e),e+=i[n].byteLength;return o}static hdlr(t){return Ai.box(Ai.types.hdlr,Ai.HDLR_TYPES[t])}static mdat(t){return Ai.box(Ai.types.mdat,t)}static mdhd(t,e){e*=t;const s=Math.floor(e/(Li+1)),i=Math.floor(e%(Li+1));return Ai.box(Ai.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,s>>24,s>>16&255,s>>8&255,255&s,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))}static mdia(t){return Ai.box(Ai.types.mdia,Ai.mdhd(t.timescale,t.duration),Ai.hdlr(t.type),Ai.minf(t))}static mfhd(t){return Ai.box(Ai.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}static minf(t){return"audio"===t.type?Ai.box(Ai.types.minf,Ai.box(Ai.types.smhd,Ai.SMHD),Ai.DINF,Ai.stbl(t)):Ai.box(Ai.types.minf,Ai.box(Ai.types.vmhd,Ai.VMHD),Ai.DINF,Ai.stbl(t))}static moof(t,e,s){return Ai.box(Ai.types.moof,Ai.mfhd(t),Ai.traf(s,e))}static moov(t){let e=t.length;const s=[];for(;e--;)s[e]=Ai.trak(t[e]);return Ai.box.apply(null,[Ai.types.moov,Ai.mvhd(t[0].timescale,t[0].duration)].concat(s).concat(Ai.mvex(t)))}static mvex(t){let e=t.length;const s=[];for(;e--;)s[e]=Ai.trex(t[e]);return Ai.box.apply(null,[Ai.types.mvex,...s])}static mvhd(t,e){e*=t;const s=Math.floor(e/(Li+1)),i=Math.floor(e%(Li+1)),r=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,s>>24,s>>16&255,s>>8&255,255&s,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return Ai.box(Ai.types.mvhd,r)}static sdtp(t){const e=t.samples||[],s=new Uint8Array(4+e.length);let i,r;for(i=0;i<e.length;i++)r=e[i].flags,s[i+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return Ai.box(Ai.types.sdtp,s)}static stbl(t){return Ai.box(Ai.types.stbl,Ai.stsd(t),Ai.box(Ai.types.stts,Ai.STTS),Ai.box(Ai.types.stsc,Ai.STSC),Ai.box(Ai.types.stsz,Ai.STSZ),Ai.box(Ai.types.stco,Ai.STCO))}static avc1(t){let e,s,i,r=[],n=[];for(e=0;e<t.sps.length;e++)s=t.sps[e],i=s.byteLength,r.push(i>>>8&255),r.push(255&i),r=r.concat(Array.prototype.slice.call(s));for(e=0;e<t.pps.length;e++)s=t.pps[e],i=s.byteLength,n.push(i>>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(s));const a=Ai.box(Ai.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|t.sps.length].concat(r).concat([t.pps.length]).concat(n))),o=t.width,l=t.height,c=t.pixelRatio[0],h=t.pixelRatio[1];return Ai.box(Ai.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a,Ai.box(Ai.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Ai.box(Ai.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,h>>24,h>>16&255,h>>8&255,255&h])))}static esds(t){const e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))}static mp4a(t){const e=t.samplerate;return Ai.box(Ai.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]),Ai.box(Ai.types.esds,Ai.esds(t)))}static mp3(t){const e=t.samplerate;return Ai.box(Ai.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]))}static stsd(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?Ai.box(Ai.types.stsd,Ai.STSD,Ai.mp3(t)):Ai.box(Ai.types.stsd,Ai.STSD,Ai.mp4a(t)):Ai.box(Ai.types.stsd,Ai.STSD,Ai.avc1(t))}static tkhd(t){const e=t.id,s=t.duration*t.timescale,i=t.width,r=t.height,n=Math.floor(s/(Li+1)),a=Math.floor(s%(Li+1));return Ai.box(Ai.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,r>>8&255,255&r,0,0]))}static traf(t,e){const s=Ai.sdtp(t),i=t.id,r=Math.floor(e/(Li+1)),n=Math.floor(e%(Li+1));return Ai.box(Ai.types.traf,Ai.box(Ai.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),Ai.box(Ai.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,n>>24,n>>16&255,n>>8&255,255&n])),Ai.trun(t,s.length+16+20+8+16+8+8),s)}static trak(t){return t.duration=t.duration||4294967295,Ai.box(Ai.types.trak,Ai.tkhd(t),Ai.mdia(t))}static trex(t){const e=t.id;return Ai.box(Ai.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){const s=t.samples||[],i=s.length,r=12+16*i,n=new Uint8Array(r);let a,o,l,c,h,d;for(e+=8+r,n.set(["video"===t.type?1:0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0),a=0;a<i;a++)o=s[a],l=o.duration,c=o.size,h=o.flags,d=o.cts,n.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,c>>>24&255,c>>>16&255,c>>>8&255,255&c,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,61440&h.degradPrio,15&h.degradPrio,d>>>24&255,d>>>16&255,d>>>8&255,255&d],12+16*a);return Ai.box(Ai.types.trun,n)}static initSegment(t){Ai.types||Ai.init();const e=Ai.moov(t),s=new Uint8Array(Ai.FTYP.byteLength+e.byteLength);return s.set(Ai.FTYP),s.set(e,Ai.FTYP.byteLength),s}}Ai.types=void 0,Ai.HDLR_TYPES=void 0,Ai.STTS=void 0,Ai.STSC=void 0,Ai.STCO=void 0,Ai.STSZ=void 0,Ai.VMHD=void 0,Ai.SMH
1D=void 0,Ai.STSD=void 0,Ai.FTYP=void 0,Ai.DINF=void 0;const Ri=9e4;function bi(t,e){const s=t*e*(arguments.length>2&&void 0!==arguments[2]?arguments[2]:1);return arguments.length>3&&void 0!==arguments[3]&&arguments[3]?Math.round(s):s}function ki(t){return bi(t,1e3,1/Ri,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}let Di,Ii=null,wi=null;class Ci{constructor(t,e,s){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=s,this.ISGenerated=!1,null===Ii){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ii=t?parseInt(t[1]):0}if(null===wi){const t=navigator.userAgent.match(/Safari\/(\d+)/i);wi=t?parseInt(t[1]):0}}destroy(){}resetTimeStamp(t){v.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){v.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){v.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const s=t.reduce(((t,s)=>{const i=s.pts-t;return i<-4294967296?(e=!0,_i(t,s.pts)):i>0?t:s.pts}),t[0].pts);return e&&v.debug("PTS rollover detected"),s}remux(t,e,s,i,r,n,a,o){let l,c,h,d,u,f,g=r,m=r;const p=t.pid>-1,y=e.pid>-1,T=e.samples.length,E=t.samples.length>0,S=a&&T>0||T>1;if((!p||E)&&(!y||S)||this.ISGenerated||a){this.ISGenerated||(h=this.generateIS(t,e,r,n));const s=this.isVideoContiguous;let i,a=-1;if(S&&(a=function(t){for(let e=0;e<t.length;e++)if(t[e].key)return e;return-1}(e.samples),!s&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,a>0){v.warn("[mp4-remuxer]: Dropped ".concat(a," out of ").concat(T," video samples due to a missing keyframe"));const t=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(a),e.dropped+=a,m+=(e.samples[0].pts-t)/e.inputTimeScale,i=m}else-1===a&&(v.warn("[mp4-remuxer]: No keyframe found out of ".concat(T," video samples")),f=!1);if(this.ISGenerated){if(E&&S){const s=this.getVideoStartPts(e.samples),i=(_i(t.samples[0].pts,s)-s)/e.inputTimeScale;g+=Math.max(0,i),m+=Math.max(0,-i)}if(E){if(t.samplerate||(v.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(t,e,r,n)),c=this.remuxAudio(t,g,this.isAudioContiguous,n,y||S||o===ne?m:void 0),S){const i=c?c.endPTS-c.startPTS:0;e.inputTimeScale||(v.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(t,e,r,n)),l=this.remuxVideo(e,m,s,i)}}else S&&(l=this.remuxVideo(e,m,s,0));l&&(l.firstKeyFrame=a,l.independent=-1!==a,l.firstKeyFramePTS=i)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(s.samples.length&&(u=Pi(s,r,this._initPTS,this._initDTS)),i.samples.length&&(d=xi(i,r,this._initPTS))),{audio:c,video:l,initSegment:h,independent:f,text:d,id3:u}}generateIS(t,e,s,i){const r=t.samples,n=e.samples,a=this.typeSupported,o={},l=this._initPTS;let c,h,d,u=!l||i,f="audio/mp4";if(u&&(c=h=1/0),t.config&&r.length){if(t.timescale=t.samplerate,"mp3"===t.segmentCodec)a.mpeg?(f="audio/mpeg",t.codec=""):a.mp3&&(t.codec="mp3");o.audio={id:"audio",container:f,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&a.mpeg?new Uint8Array(0):Ai.initSegment([t]),metadata:{channelCount:t.channelCount}},u&&(d=t.inputTimeScale,l&&d===l.timescale?u=!1:c=h=r[0].pts-Math.round(d*s))}if(e.sps&&e.pps&&n.length&&(e.timescale=e.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:Ai.initSegment([e]),metadata:{width:e.width,height:e.height}},u))if(d=e.inputTimeScale,l&&d===l.timescale)u=!1;else{const t=this.getVideoStartPts(n),e=Math.round(d*s);h=Math.min(h,_i(n[0].dts,t)-e),c=Math.min(c,t-e)}if(Object.keys(o).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:c,timescale:d},this._initDTS={baseTime:h,timescale:d}):c=d=void 0,{tracks:o,initPTS:c,timescale:d}}remuxVideo(t,e,s,i){const r=t.inputTimeScale,n=t.samples,a=[],o=n.length,l=this._initPTS;let c,d,m=this.nextAvcDts,p=8,y=this.videoSampleDuration,T=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY,S=!1;if(!s||null===m){m=e*r-(n[0].pts-_i(n[0].dts,n[0].pts))}const L=l.baseTime*r/l.timescale;for(let h=0;h<o;h++){const t=n[h];t.pts=_i(t.pts-L,m),t.dts=_i(t.dts-L,m),t.dts<n[h>0?h-1:h].dts&&(S=!0)}S&&n.sort((function(t,e){const s=t.dts-e.dts,i=t.pts-e.pts;return s||i})),c=n[0].dts,d=n[n.length-1].dts;const A=d-c,R=A?Math.round(A/(o-1)):y||t.inputTimeScale/30;if(s){const t=c-m,e=t>R,s=t<-1;if((e||s)&&(e?v.warn("AVC: ".concat(ki(t,!0)," ms (").concat(t,"dts) hole between fragments detected, filling it")):v.warn("AVC: ".concat(ki(-t,!0)," ms (").concat(t,"dts) overlapping between fragments detected")),!s||m>=n[0].pts)){c=m;const e=n[0].pts-t;n[0].dts=c,n[0].pts=e,v.log("Video: First PTS/DTS adjusted: ".concat(ki(e,!0),"/").concat(ki(c,!0),", delta: ").concat(ki(t,!0)," ms"))}}c=Math.max(0,c);let b=0,k=0;for(let h=0;h<o;h++){const t=n[h],e=t.units,s=e.length;let i=0;for(let r=0;r<s;r++)i+=e[r].data.length;k+=i,b+=s,t.length=i,t.dts=Math.max(t.dts,c),T=Math.min(t.pts,T),E=Math.max(t.pts,E)}d=n[o-1].dts;const D=k+4*b+8;let I;try{I=new Uint8Array(D)}catch(O){return void this.observer.emit(u.ERROR,u.ERROR,{type:f.MUX_ERROR,details:g.REMUX_ALLOC_ER
vendor: 4,850 bytes, line 1
1ROR,fatal:!1,error:O,bytes:D,reason:"fail allocating video mdat ".concat(D)})}const w=new DataView(I.buffer);w.setUint32(0,D),I.set(Ai.types.mdat,4);let C=!1,_=Number.POSITIVE_INFINITY,P=Number.POSITIVE_INFINITY,x=Number.NEGATIVE_INFINITY,F=Number.NEGATIVE_INFINITY;for(let h=0;h<o;h++){const t=n[h],e=t.units;let s,l=0;for(let i=0,r=e.length;i<r;i++){const t=e[i],s=t.data,r=t.data.byteLength;w.setUint32(p,r),p+=4,I.set(s,p),p+=r,l+=4+r}if(h<o-1)y=n[h+1].dts-t.dts,s=n[h+1].pts-t.pts;else{const e=this.config,a=h>0?t.dts-n[h-1].dts:R;if(s=h>0?t.pts-n[h-1].pts:R,e.stretchShortVideoTrack&&null!==this.nextAudioPts){const s=Math.floor(e.maxBufferHole*r),n=(i?T+i*r:this.nextAudioPts)-t.pts;n>s?(y=n-a,y<0?y=a:C=!0,v.log("[mp4-remuxer]: It is approximately ".concat(n/90," ms to the next segment; using duration ").concat(y/90," ms for the last video frame."))):y=a}else y=a}const c=Math.round(t.pts-t.dts);_=Math.min(_,y),x=Math.max(x,y),P=Math.min(P,s),F=Math.max(F,s),a.push(new Fi(t.key,y,l,c))}if(a.length)if(Ii){if(Ii<70){const t=a[0].flags;t.dependsOn=2,t.isNonSync=0}}else if(wi&&F-P<x-_&&R/x<.025&&0===a[0].cts){v.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let t=c;for(let e=0,s=a.length;e<s;e++){const i=t+a[e].duration,r=t+a[e].cts;if(e<s-1){const t=i+a[e+1].cts;a[e].duration=t-r}else a[e].duration=e?a[e-1].duration:R;a[e].cts=0,t=i}}y=C||!y?R:y,this.nextAvcDts=m=d+y,this.videoSampleDuration=y,this.isVideoContiguous=!0;const M={data1:Ai.moof(t.sequenceNumber++,c,h({},t,{samples:a})),data2:I,startPTS:T/r,endPTS:(E+y)/r,startDTS:c/r,endDTS:m/r,type:"video",hasAudio:!1,hasVideo:!0,nb:a.length,dropped:t.dropped};return t.samples=[],t.dropped=0,M}remuxAudio(t,e,s,i,r){const n=t.inputTimeScale,a=n/(t.samplerate?t.samplerate:n),o="aac"===t.segmentCodec?1024:1152,l=o*a,c=this._initPTS,d="mp3"===t.segmentCodec&&this.typeSupported.mpeg,m=[],p=void 0!==r;let y=t.samples,T=d?0:8,E=this.nextAudioPts||-1;const S=e*n,L=c.baseTime*n/c.timescale;if(this.isAudioContiguous=s=s||y.length&&E>0&&(i&&Math.abs(S-E)<9e3||Math.abs(_i(y[0].pts-L,S)-E)<20*l),y.forEach((function(t){t.pts=_i(t.pts-L,S)})),!s||E<0){if(y=y.filter((t=>t.pts>=0)),!y.length)return;E=0===r?0:i&&!p?Math.max(0,S):y[0].pts}if("aac"===t.segmentCodec){const e=this.config.maxAudioFramesDrift;for(let s=0,i=E;s<y.length;s++){const r=y[s],a=r.pts,o=a-i,c=Math.abs(1e3*o/n);if(o<=-e*l&&p)0===s&&(v.warn("Audio frame @ ".concat((a/n).toFixed(3),"s overlaps nextAudioPts by ").concat(Math.round(1e3*o/n)," ms.")),this.nextAudioPts=E=i=a);else if(o>=e*l&&c<1e4&&p){let e=Math.round(o/l);i=a-e*l,i<0&&(e--,i+=l),0===s&&(this.nextAudioPts=E=i),v.warn("[mp4-remuxer]: Injecting ".concat(e," audio frame @ ").concat((i/n).toFixed(3),"s due to ").concat(Math.round(1e3*o/n)," ms gap."));for(let n=0;n<e;n++){const e=Math.max(i,0);let n=Si.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);n||(v.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),n=r.unit.subarray()),y.splice(s,0,{unit:n,pts:e}),i+=l,s++}}r.pts=i,i+=l}}let A,R=null,b=null,k=0,D=y.length;for(;D--;)k+=y[D].unit.byteLength;for(let h=0,v=y.length;h<v;h++){const e=y[h],i=e.unit;let r=e.pts;if(null!==b){m[h-1].duration=Math.round((r-b)/a)}else{if(s&&"aac"===t.segmentCodec&&(r=E),R=r,!(k>0))return;k+=T;try{A=new Uint8Array(k)}catch(F){return void this.observer.emit(u.ERROR,u.ERROR,{type:f.MUX_ERROR,details:g.REMUX_ALLOC_ERROR,fatal:!1,error:F,bytes:k,reason:"fail allocating audio mdat ".concat(k)})}if(!d){new DataView(A.buffer).setUint32(0,k),A.set(Ai.types.mdat,4)}}A.set(i,T);const n=i.byteLength;T+=n,m.push(new Fi(!0,o,n,0)),b=r}const I=m.length;if(!I)return;const w=m[m.length-1];this.nextAudioPts=E=b+a*w.duration;const C=d?new Uint8Array(0):Ai.moof(t.sequenceNumber++,R/a,h({},t,{samples:m}));t.samples=[];const _=R/n,P=E/n,x={data1:C,data2:A,startPTS:_,endPTS:P,startDTS:_,endDTS:P,type:"audio",hasAudio:!0,hasVideo:!1,nb:I};return this.isAudioContiguous=!0,x}remuxEmptyAudio(t,e,s,i){const r=t.inputTimeScale,n=r/(t.samplerate?t.samplerate:r),a=this.nextAudioPts,o=this._initDTS,l=9e4*o.baseTime/o.timescale,c=(null!==a?a:i.startDTS*r)+l,h=i.endDTS*r+l,d=1024*n,u=Math.ceil((h-c)/d),f=Si.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(v.warn("[mp4-remuxer]: remux empty Audio"),!f)return void v.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");const g=[];for(let m=0;m<u;m++){const t=c+m*d;g.push({unit:f,pts:t,dts:t})}return t.samples=g,this.remuxAudio(t,e,s,!1)}}function _i(t,e){let s;if(null===e)return t;for(s=e<t?-8589934592:8589934592;Math.abs(t-e)>4294967296;)t+=s;return t}function Pi(t,e,s,i){const r=t.samples.length;if(!r)return;const n=t.inputTimeScale;for(let o=0;o<r;o++){const r=t.samples[o];
1r.pts=_i(r.pts-s.baseTime*n/s.timescale,e*n)/n,r.dts=_i(r.dts-i.baseTime*n/i.timescale,e*n)/n}const a=t.samples;return t.samples=[],{samples:a}}function xi(t,e,s){const i=t.samples.length;if(!i)return;const r=t.inputTimeScale;for(let a=0;a<i;a++){const i=t.samples[a];i.pts=_i(i.pts-s.baseTime*r/s.timescale,e*r)/r}t.samples.sort(((t,e)=>t.pts-e.pts));const n=t.samples;return t.samples=[],{samples:n}}class Fi{constructor(t,e,s,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=s,this.cts=i,this.flags=new Mi(t)}}class Mi{constructor(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}}function Oi(t,e){const s=null==t?void 0:t.codec;return s&&s.length>4?s:"hvc1"===s||"hev1"===s?"hvc1.1.6.L120.90":"av01"===s?"av01.0.04M.08":"avc1"===s||e===D?"avc1.42e01e":"mp4a.40.5"}try{Di=self.performance.now.bind(self.performance)}catch(Rn){v.debug("Unable to use Performance API on this environment"),Di="undefined"!==typeof self&&self.Date.now}const Ni=[{demux:class{constructor(t,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}resetTimeStamp(){}resetInitSegment(t,e,s,i){const r=this.videoTrack=Vs("video",1),n=this.audioTrack=Vs("audio",1),a=this.txtTrack=Vs("text",1);if(this.id3Track=Vs("id3",1),this.timeOffset=0,null==t||!t.byteLength)return;const o=Et(t);if(o.video){const{id:t,timescale:e,codec:s}=o.video;r.id=t,r.timescale=a.timescale=e,r.codec=s}if(o.audio){const{id:t,timescale:e,codec:s}=o.audio;n.id=t,n.timescale=e,n.codec=s}a.id=ut.text,r.sampleDuration=0,r.duration=n.duration=i}resetContiguity(){this.remainderData=null}static probe(t){return Tt(t=t.length>16384?t.subarray(0,16384):t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let s=t;const i=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(s=At(this.remainderData,t));const e=function(t){const e={valid:null,remainder:null},s=Tt(t,["moof"]);if(!s)return e;if(s.length<2)return e.remainder=t,e;const i=s[s.length-1];return e.valid=q(t,0,i.byteOffset-8),e.remainder=q(t,i.byteOffset-8),e}(s);this.remainderData=e.remainder,i.samples=e.valid||new Uint8Array}else i.samples=s;const n=this.extractID3Track(i,e);
vendor: 7,592 bytes, line 1
1return r.samples=Rt(e,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,s=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const i=this.extractID3Track(e,this.timeOffset);return s.samples=Rt(t,e),{videoTrack:e,audioTrack:Vs(),id3Track:i,textTrack:Vs()}}extractID3Track(t,e){const s=this.id3Track;if(t.samples.length){const i=Tt(t.samples,["emsg"]);i&&i.forEach((t=>{const i=function(t){const e=t[0];let s="",i="",r=0,n=0,a=0,o=0,l=0,c=0;if(0===e){for(;"\0"!==ft(t.subarray(c,c+1));)s+=ft(t.subarray(c,c+1)),c+=1;for(s+=ft(t.subarray(c,c+1)),c+=1;"\0"!==ft(t.subarray(c,c+1));)i+=ft(t.subarray(c,c+1)),c+=1;i+=ft(t.subarray(c,c+1)),c+=1,r=mt(t,12),n=mt(t,16),o=mt(t,20),l=mt(t,24),c=28}else if(1===e){c+=4,r=mt(t,c),c+=4;const e=mt(t,c);c+=4;const n=mt(t,c);for(c+=4,a=2**32*e+n,Number.isSafeInteger(a)||(a=Number.MAX_SAFE_INTEGER,v.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=mt(t,c),c+=4,l=mt(t,c),c+=4;"\0"!==ft(t.subarray(c,c+1));)s+=ft(t.subarray(c,c+1)),c+=1;for(s+=ft(t.subarray(c,c+1)),c+=1;"\0"!==ft(t.subarray(c,c+1));)i+=ft(t.subarray(c,c+1)),c+=1;i+=ft(t.subarray(c,c+1)),c+=1}return{schemeIdUri:s,value:i,timeScale:r,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:t.subarray(c,t.byteLength)}}(t);if(ti.test(i.schemeIdUri)){const t=d(i.presentationTime)?i.presentationTime/i.timeScale:e+i.presentationTimeDelta/i.timeScale;let r=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;r<=.001&&(r=Number.POSITIVE_INFINITY);const n=i.payload;s.samples.push({data:n,len:n.byteLength,dts:t,pts:t,type:pe,duration:r})}}))}return s}demuxSampleAes(t,e,s){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},remux:class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(t){this.initPTS=t,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(t,e,s,i){this.audioCodec=e,this.videoCodec=s,this.generateInitSegment(function(t,e){if(!t||!e)return t;const s=e.keyId;s&&e.isCommonEncryption&&Tt(t,["moov","trak"]).forEach((t=>{const e=Tt(t,["mdia","minf","stbl","stsd"])[0].subarray(8);let i=Tt(e,["enca"]);const r=i.length>0;r||(i=Tt(e,["encv"])),i.forEach((t=>{Tt(r?t.subarray(28):t.subarray(78),["sinf"]).forEach((t=>{const e=St(t);if(e){const t=e.subarray(8,24);t.some((t=>0!==t))||(v.log("[eme] Patching keyId in 'enc".concat(r?"a":"v",">sinf>>tenc' box: ").concat(ct(t)," -> ").concat(ct(s))),e.set(s,8))}}))}))}));return t}(t,i)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:s}=this;if(null==t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const i=this.initData=Et(t);e||(e=Oi(i.audio,k)),s||(s=Oi(i.video,D));const r={};i.audio&&i.video?r.audiovideo={container:"video/mp4",codec:e+","+s,initSegment:t,id:"main"}:i.audio?r.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:i.video?r.video={container:"video/mp4",codec:s,initSegment:t,id:"main"}:v.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=r}remux(t,e,s,i,r,n){var a,o;let{initPTS:l,lastEndTime:c}=this;const h={audio:void 0,video:void 0,text:i,id3:s,initSegment:void 0};d(c)||(c=this.lastEndTime=r||0);const u=e.samples;if(null==u||!u.length)return h;const f={initPTS:void 0,timescale:1};let g=this.initData;if(null!=(a=g)&&a.length||(this.generateInitSegment(u),g=this.initData),null==(o=g)||!o.length)return v.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const m=function(t,e){let s=0,i=0,r=0;const n=Tt(t,["moof","traf"]);for(let a=0;a<n.length;a++){const t=n[a],o=Tt(t,["tfhd"])[0],l=e[mt(o,4)];if(!l)continue;const c=l.default,h=mt(o,0)|(null==c?void 0:c.flags);let d=null==c?void 0:c.duration;8&h&&(d=mt(o,2&h?12:8));const u=l.timescale||9e4,f=Tt(t,["trun"]);for(let e=0;e<f.length;e++)s=Lt(f[e]),!s&&d&&(s=d*mt(f[e],4)),l.type===D?i+=s/u:l.type===k&&(r+=s/u)}if(0===i&&0===r){let e=0;const s=Tt(t,["sidx"]);for(let t=0;t<s.length;t++){const i=vt(s[t]);null!=i&&i.references&&(e+=i.references.reduce(((t,e)=>t+e.info.duration||0),0))}return e}return i||r}(u,g),p=function(t,e){return Tt(e,["moof","traf"]).reduce(((e,s)=>{const i=Tt(s,["tfdt"])[0],r=i[0],n=Tt(s,["tfhd"]).reduce(((e,s)=>{const n=mt(s,4),a=t[n];if(a){let t=mt(i,4);if(1===r){if(t===ht)return v.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),e;t*=ht+1,t+=mt(i,8)}const s=t/(a.timescale||9e4);if(isFinite(s)&&(null===e||s<e))return s}return e}),null);return null!==n&&isFinite(n)&&(null===e||n<e)?n:e}),null)}(g,u),y=null===p?r:p;(function(t,e,s,i){if(null===t)return!0;const r=Math.max(i,1),n=e-t.baseTime/t.timescale;return Math.abs(n-s)>r}(l,y,r,m)||f.timescale!==l.timescale&&n)&&(f.initPTS=y-r,l&&1===l.timescale&&v.warn("Adjusting initPTS by ".concat(f.initPTS-l.baseTime)),this.initPTS=l={baseTime:f.initPTS,timescale:1});const T=t?y-l.baseTime/l.timescale:c,E=T+m;!function(t,e,s){Tt(e,["moof","traf"]).forEach((e=>{Tt(e,["tfhd"]).forEach((i=>{const r=mt(i,4),n=t[r];if(!n)return;const a=n.timescale||9e4;Tt(e,["tfdt"]).forEach((t=>{const e=t[0];let i=mt(t,4);if(0===e)i-=s*a,i=Math.max(i,0),yt(t,4,i);else{i*=Math.pow(2,32),i+=mt(t,8),i-=s*a,i=Math.max(i,0);const e=Math.floor(i/(ht+1)),r=Math.floor(i%(ht+1));yt(t,4,e),yt(t,8,r)}}))}))}))}(g,u,l.baseTime/l.timescale),m>0?this.lastEndTime=E:(v.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const S=!!g.audio,L=!!g.video;let A="";S&&(A+="audio"),L&&(A+="video");const R={data1:u,startPTS:T,startDTS:T,endPTS:E,endDTS:E,type:A,hasAudio:S,hasVideo:L,nb:1,dropped:0};return h.audio="audio"===R.type?R:void 0,h.video="audio"!==R.type?R:void 0,h.initSegment=f,h.id3=Pi(s,r,l,l),i.samples.length&&(h.text=xi(i,r,l)),h}}},{demux:gi,remux:Ci},{demux:class extends Ys{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,s,i){super.resetInitSegment(t,e,s,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(z(t,0)||[]).length;for(let s=t.length;e<s;e++)if(Qs(t,e))return v.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return function(t,e){return function(t,e){return e+5<t.length}(t,e)&&qs(t,e)&&Xs(t,e)<=t.length-e}(t,e)}appendFrame(t,e,s){$s(t,this.observer,e,s,t.manifestCodec);const i=Zs(t,e,s,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}},remux:Ci},{demux:class extends Ys{resetInitSegment(t,e,s,i){super.resetInitSegment(t,e,s,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(z(t,0)||[]).length;for(let s=t.length;e<s;e++)if(hi(t,e))return v.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return function(t,e){return li(t,e)&&4<=t.length-e}(t,e)}appendFrame(t,e,s){if(null!==this.basePTS)return ai(t,e,s,this.basePTS,this.frameIndex)}},remux:Ci}];class Ui{constructor(t,e,s,i,r){this.async=!1,this.observer=void 0,this.typeSupp
vendor: 4,558 bytes, line 1
1orted=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=e,this.config=s,this.vendor=i,this.id=r}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,s,i){const r=s.transmuxing;r.executeStart=Di();let n=new Uint8Array(t);const{currentTransmuxState:a,transmuxConfig:o}=this;i&&(this.currentTransmuxState=i);const{contiguous:l,discontinuity:c,trackSwitch:h,accurateTimeOffset:d,timeOffset:m,initSegmentChange:p}=i||a,{audioCodec:y,videoCodec:T,defaultInitPts:E,duration:S,initSegmentData:L}=o,A=function(t,e){let s=null;t.byteLength>0&&null!=e&&null!=e.key&&null!==e.iv&&null!=e.method&&(s=e);return s}(n,e);if(A&&"AES-128"===A.method){const t=this.getDecrypter();if(!t.isSync())return this.decryptionPromise=t.webCryptoDecrypt(n,A.key.buffer,A.iv.buffer).then((t=>{const e=this.push(t,null,s);return this.decryptionPromise=null,e})),this.decryptionPromise;{let e=t.softwareDecrypt(n,A.key.buffer,A.iv.buffer);if(s.part>-1&&(e=t.flush()),!e)return r.executeEnd=Di(),Bi(s);n=new Uint8Array(e)}}const R=this.needsProbing(c,h);if(R){const t=this.configureTransmuxer(n);if(t)return v.warn("[transmuxer] ".concat(t.message)),this.observer.emit(u.ERROR,u.ERROR,{type:f.MEDIA_ERROR,details:g.FRAG_PARSING_ERROR,fatal:!1,error:t,reason:t.message}),r.executeEnd=Di(),Bi(s)}(c||h||p||R)&&this.resetInitSegment(L,y,T,S,e),(c||p||R)&&this.resetInitialTimestamp(E),l||this.resetContiguity();const b=this.transmux(n,A,m,d,s),k=this.currentTransmuxState;return k.contiguous=!0,k.discontinuity=!1,k.trackSwitch=!1,r.executeEnd=Di(),b}flush(t){const e=t.transmuxing;e.executeStart=Di();const{decrypter:s,currentTransmuxState:i,decryptionPromise:r}=this;if(r)return r.then((()=>this.flush(t)));const n=[],{timeOffset:a}=i;if(s){const e=s.flush();e&&n.push(this.push(e,null,t))}const{demuxer:o,remuxer:l}=this;if(!o||!l)return e.executeEnd=Di(),[Bi(t)];const c=o.flush(a);return Gi(c)?c.then((e=>(this.flushRemux(n,e,t),n))):(this.flushRemux(n,c,t),n)}flushRemux(t,e,s){const{audioTrack:i,videoTrack:r,id3Track:n,textTrack:a}=e,{accurateTimeOffset:o,timeOffset:l}=this.currentTransmuxState;v.log("[transmuxer.ts]: Flushed fragment ".concat(s.sn).concat(s.part>-1?" p: "+s.part:""," of level ").concat(s.level));const c=this.remuxer.remux(i,r,n,a,l,o,!0,this.id);t.push({remuxResult:c,chunkMeta:s}),s.transmuxing.executeEnd=Di()}resetInitialTimestamp(t){const{demuxer:e,remuxer:s}=this;e&&s&&(e.resetTimeStamp(t),s.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,s,i,r){const{demuxer:n,remuxer:a}=this;n&&a&&(n.resetInitSegment(t,e,s,i),a.resetInitSegment(t,e,s,r))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,s,i,r){let n;return n=e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,s,i,r):this.transmuxUnencrypted(t,s,i,r),n}transmuxUnencrypted(t,e,s,i){const{audioTrack:r,videoTrack:n,id3Track:a,textTrack:o}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,n,a,o,e,s,!1,this.id),chunkMeta:i}}transmuxSampleAes(t,e,s,i,r){return this.demuxer.demuxSampleAes(t,e,s).then((t=>({remuxResult:this.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,s,i,!1,this.id),chunkMeta:r})))}configureTransmuxer(t){const{config:e,observer:s,typeSupported:i,vendor:r}=this;let n;for(let h=0,d=Ni.length;h<d;h++)if(Ni[h].demux.probe(t)){n=Ni[h];break}if(!n)return new Error("Failed to find demuxer by probing fragment data");const a=this.demuxer,o=this.remuxer,l=n.remux,c=n.demux;o&&o instanceof l||(this.remuxer=new l(s,e,i,r)),a&&a instanceof c||(this.demuxer=new c(s,e,i),this.probe=c.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t||(t=this.decrypter=new Ds(this.config)),t}}const Bi=t=>({remuxResult:{},chunkMeta:t});function Gi(t){return"then"in t&&t.then instanceof Function}class Ki{constructor(t,e,s,i,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=s,this.duration=i,this.defaultInitPts=r||null}}class Hi{constructor(t,e,s,i,r,n){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOff
vendor: 4,877 bytes, line 1
1set=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=s,this.trackSwitch=i,this.timeOffset=r,this.initSegmentChange=n}}var Vi={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,s="~";function i(){}function r(t,e,s){this.fn=t,this.context=e,this.once=s||!1}function n(t,e,i,n,a){if("function"!==typeof i)throw new TypeError("The listener must be a function");var o=new r(i,n||t,a),l=s?s+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],o]:t._events[l].push(o):(t._events[l]=o,t._eventsCount++),t}function a(t,e){0===--t._eventsCount?t._events=new i:delete t._events[e]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(s=!1)),o.prototype.eventNames=function(){var t,i,r=[];if(0===this._eventsCount)return r;for(i in t=this._events)e.call(t,i)&&r.push(s?i.slice(1):i);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},o.prototype.listeners=function(t){var e=s?s+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,n=i.length,a=new Array(n);r<n;r++)a[r]=i[r].fn;return a},o.prototype.listenerCount=function(t){var e=s?s+t:t,i=this._events[e];return i?i.fn?1:i.length:0},o.prototype.emit=function(t,e,i,r,n,a){var o=s?s+t:t;if(!this._events[o])return!1;var l,c,h=this._events[o],d=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),d){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,i),!0;case 4:return h.fn.call(h.context,e,i,r),!0;case 5:return h.fn.call(h.context,e,i,r,n),!0;case 6:return h.fn.call(h.context,e,i,r,n,a),!0}for(c=1,l=new Array(d-1);c<d;c++)l[c-1]=arguments[c];h.fn.apply(h.context,l)}else{var u,f=h.length;for(c=0;c<f;c++)switch(h[c].once&&this.removeListener(t,h[c].fn,void 0,!0),d){case 1:h[c].fn.call(h[c].context);break;case 2:h[c].fn.call(h[c].context,e);break;case 3:h[c].fn.call(h[c].context,e,i);break;case 4:h[c].fn.call(h[c].context,e,i,r);break;default:if(!l)for(u=1,l=new Array(d-1);u<d;u++)l[u-1]=arguments[u];h[c].fn.apply(h[c].context,l)}}return!0},o.prototype.on=function(t,e,s){return n(this,t,e,s,!1)},o.prototype.once=function(t,e,s){return n(this,t,e,s,!0)},o.prototype.removeListener=function(t,e,i,r){var n=s?s+t:t;if(!this._events[n])return this;if(!e)return a(this,n),this;var o=this._events[n];if(o.fn)o.fn!==e||r&&!o.once||i&&o.context!==i||a(this,n);else{for(var l=0,c=[],h=o.length;l<h;l++)(o[l].fn!==e||r&&!o[l].once||i&&o[l].context!==i)&&c.push(o[l]);c.length?this._events[n]=1===c.length?c[0]:c:a(this,n)}return this},o.prototype.removeAllListeners=function(t){var e;return t?(e=s?s+t:t,this._events[e]&&a(this,e)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=s,o.EventEmitter=o,t.exports=o}(Vi);var Yi=i(Vi.exports);const Wi=Nt()||{isTypeSupported:()=>!1};class qi{constructor(t,e,s,i){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const r=t.config;this.hls=t,this.id=e,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=s,this.onFlush=i;const n=(t,e)=>{(e=e||{}).frag=this.frag,e.id=this.id,t===u.ERROR&&(this.error=e.error),this.hls.trigger(t,e)};this.observer=new Yi,this.observer.on(u.FRAG_DECRYPTED,n),this.observer.on(u.ERROR,n);const a={mp4:Wi.isTypeSupported("video/mp4"),mpeg:Wi.isTypeSupported("audio/mpeg"),mp3:Wi.isTypeSupported('audio/mp4; codecs="mp3"')},o=navigator.vendor;if(this.useWorker&&"undefined"!==typeof Worker){if(r.workerPath||"function"===typeof __HLS_WORKER_BUNDLE__){try{r.workerPath?(v.log("loading Web Worker ".concat(r.workerPath,' for "').concat(e,'"')),this.workerContext=function(t){const e=new self.URL(t,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}(r.workerPath)):(v.log('injecting Web Worker for "'.concat(e,'"')),this.workerContext=function(){const t=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(".concat(__HLS_WORKER_BUNDLE__.toString(),")(true);")],{type:"text/javascript"}),e=self.URL.createObjectURL(t);return{worker:new self.Worker(e),objectURL:e}}()),this.onwmsg=t=>this.onWorkerMessage(t);const{worker:t}=this.workerContext;t.addEventListener("message",this.onwmsg),t.onerror=t=>{const s=new Error("".concat(t.message,"  (").concat(t.filename,":").concat(t.lineno,")"));r.enableWorker=!1,v.warn('Error in "'.concat(e,'" Web Worker, fallback to inline')),this.hls.trigger(u.ERROR,{type:f.OTHER_ERROR,details:g.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:s})}
1,t.postMessage({cmd:"init",typeSupported:a,vendor:o,id:e,config:JSON.stringify(r)})}catch(Rn){v.warn('Error setting up "'.concat(e,'" Web Worker, fallback to inline'),Rn),this.resetWorker(),this.error=null,this.transmuxer=new Ui(this.observer,a,r,o,e)}return}}this.transmuxer=new Ui(this.observer,a,r,o,e)}resetWorker(){if(this.workerContext){const{worker:t,objectURL:e}=this.workerContext;e&&self.URL.revokeObjectURL(e),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(t,e,s,i,r,n,a,o,l,c){var h,d;l.transmuxing.start=self.performance.now();const{transmuxer:u}=this,f=n?n.start:r.start,g=r.decryptdata,m=this.frag,p=!(m&&r.cc===m.cc),y=!(m&&l.level===m.level),T=m?l.sn-m.sn:-1,E=this.part?l.part-this.part.index:-1,S=0===T&&l.id>1&&l.id===(null==m?void 0:m.stats.chunkCount),L=!y&&(1===T||0===T&&(1===E||S&&E<=0)),A=self.performance.now();(y||T||0===r.stats.parsing.start)&&(r.stats.parsing.start=A),!n||!E&&L||(n.stats.parsing.start=A);const R=!(m&&(null==(h=r.initSegment)?void 0:h.url)===(null==(d=m.initSegment)?void 0:d.url)),b=new Hi(p,L,o,y,f,R);if(!L||p||R){v.log("[transmuxer-interface, ".concat(r.type,"]: Starting new transmux session for sn: ").concat(l.sn," p: ").concat(l.part," level: ").concat(l.level," id: ").concat(l.id,"\n        discontinuity: ").concat(p,"\n        trackSwitch: ").concat(y,"\n        contiguous: ").concat(L,"\n        accurateTimeOffset: ").concat(o,"\n        timeOffset: ").concat(f,"\n        initSegmentChange: ").concat(R));const t=new Ki(s,i,e,a,c);this.configureTransmuxer(t)}if(this.frag=r,this.part=n,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:g,chunkMeta:l,state:b},t instanceof ArrayBuffer?[t]:[]);else if(u){const e=u.push(t,g,l,b);Gi(e)?(u.async=!0,e.then((t=>{this.handleTransmuxComplete(t)})).catch((t=>{this.transmuxerError(t,l,"transmuxer-interface push error")}))):(u.async=!1,this.handleTransmuxComplete(e))}}flush(t){t.transmuxing.start=self.performance.now();const{transmuxer:e}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(e){let s=e.flush(t);Gi(s)||e.async?(Gi(s)||(s=Promise.resolve(s)),s.then((e=>{this.handleFlushResult(e,t)})).catch((e=>{this.transmuxerError(e,t,"transmuxer-interface flush error")}))):this.handleFlushResult(s,t)}}transmuxerError(t,e,s){this.hls&&(this.error=t,this.hls.trigger(u.ERROR,{type:f.MEDIA_ERROR,details:g.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:s}))}handleFlushResult(t,e){t.forEach((t=>{this.handleTransmuxComplete(t)})),this.onFlush(e)}onWorkerMessage(t){const e=t.data,s=this.hls;switch(e.event){case"init":{var i;const t=null==(i=this.workerContext)?void 0:i.objectURL;t&&self.URL.revokeObjectURL(t);break}case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;case"workerLog":v[e.data.logType]&&v[e.data.logType](e.data.message);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,s.trigger(e.event,e.data)}}configureTransmuxer(t){const{transmuxer:e}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)}handleTransmuxComplete(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)}}class ji{constructor(t,e,s,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=e,this.fragmentTracker=s,this.hls=i}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){const{config:s,media:i,stalled:r}=this;if(null===i)return;const{currentTime:n,seeking:a}=i,o=this.seeking&&!a,l=!this.seeking&&a;if(this.seeking=a,n!==t){if(this.moved=!0,null!==r){if(this.stallReported){const t=self.performance.now()-r;v.warn("playback not stuck anymore @".concat(n,", after ").concat(Math.round(t),"ms")),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(l||o)return void(this.stalled=null);if(i.paused&&!a||i.ended||0===i.playbackRate||!ys.getBuffered(i).length)return;const c=ys.bufferInfo(i,n,0),h=c.len>0,d=c.nextStart||0;if(!h&&!d)return;if(a){const t=c.len>2,s=!d||e&&e.start<=n||d-n>2&&!this.fragmentTracker.getPartialFragment(n);if(t||s)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var u;
1const t=Math.max(d,c.start||0)-n,e=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,s=(null==e||null==(u=e.details)?void 0:u.live)?2*e.details.targetduration:2,i=this.fragmentTracker.getPartialFragment(n);if(t>0&&(t<=s||i))return void this._trySkipBufferHole(i)}const f=self.performance.now();if(null===r)return void(this.stalled=f);const g=f-r;if(!a&&g>=250&&(this._reportStall(c),!this.media))return;const m=ys.bufferInfo(i,n,s.maxBufferHole);this._tryFixBufferStall(m,g)}_tryFixBufferStall(t,e){const{config:s,fragmentTracker:i,media:r}=this;if(null===r)return;const n=r.currentTime,a=i.getPartialFragment(n);if(a){if(this._trySkipBufferHole(a)||!this.media)return}(t.len>s.maxBufferHole||t.nextStart&&t.nextStart-n<s.maxBufferHole)&&e>1e3*s.highBufferWatchdogPeriod&&(v.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:s,stallReported:i}=this;if(!i&&s){this.stallReported=!0;const i=new Error("Playback stalling at @".concat(s.currentTime," due to low buffer (").concat(JSON.stringify(t),")"));v.warn(i.message),e.trigger(u.ERROR,{type:f.MEDIA_ERROR,details:g.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:s,media:i}=this;if(null===i)return 0;const r=i.currentTime,n=ys.bufferInfo(i,r,0),a=r<n.start?n.start:n.nextStart;if(a){const o=n.len<=e.maxBufferHole,l=n.len>0&&n.len<1&&i.readyState<3,c=a-r;if(c>0&&(o||l)){if(c>e.maxBufferHole){const{fragmentTracker:e}=this;let s=!1;if(0===r){const t=e.getAppendedFrag(0,re);t&&a<t.end&&(s=!0)}if(!s){const s=t||e.getAppendedFrag(r,re);if(s){let t=!1,i=s.end;for(;i<a;){const s=e.getPartialFragment(i);if(!s){t=!0;break}i+=s.duration}if(t)return 0}}}const n=Math.max(a+.05,r+.1);if(v.warn("skipping hole, adjusting currentTime from ".concat(r," to ").concat(n)),this.moved=!0,this.stalled=null,i.currentTime=n,t&&!t.gap){const e=new Error("fragment loaded with buffer holes, seeking from ".concat(r," to ").concat(n));s.trigger(u.ERROR,{type:f.MEDIA_ERROR,details:g.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:e,reason:e.message,frag:t})}return n}}return 0}_tryNudgeBuffer(){const{config:t,hls:e,media:s,nudgeRetry:i}=this;if(null===s)return;const r=s.currentTime;if(this.nudgeRetry++,i<t.nudgeMaxRetry){const n=r+(i+1)*t.nudgeOffset,a=new Error("Nudging 'currentTime' from ".concat(r," to ").concat(n));v.warn(a.message),s.currentTime=n,e.trigger(u.ERROR,{type:f.MEDIA_ERROR,details:g.BUFFER_NUDGE_ON_STALL,error:a,fatal:!1})}else{const s=new Error("Playhead still not moving while enough data buffered @".concat(r," after ").concat(t.nudgeMaxRetry," nudges"));v.error(s.message),e.trigger(u.ERROR,{type:f.MEDIA_ERROR,details:g.BUFFER_STALLED_ERROR,error:s,fatal:!0})}}}class Xi extends Ks{constructor(t,e,s){super(t,e,s,"[stream-controller]",re),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:t}=this;
1t.on(u.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(u.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(u.MANIFEST_LOADING,this.onManifestLoading,this),t.on(u.MANIFEST_PARSED,this.onManifestParsed,this),t.on(u.LEVEL_LOADING,this.onLevelLoading,this),t.on(u.LEVEL_LOADED,this.onLevelLoaded,this),t.on(u.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(u.ERROR,this.onError,this),t.on(u.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(u.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(u.BUFFER_CREATED,this.onBufferCreated,this),t.on(u.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(u.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(u.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(u.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(u.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(u.MANIFEST_LOADING,this.onManifestLoading,this),t.off(u.MANIFEST_PARSED,this.onManifestParsed,this),t.off(u.LEVEL_LOADED,this.onLevelLoaded,this),t.off(u.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(u.ERROR,this.onError,this),t.off(u.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(u.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(u.BUFFER_CREATED,this.onBufferCreated,this),t.off(u.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(u.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(u.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(t){if(this.levels){const{lastCurrentTime:e,hls:s}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let t=s.startLevel;-1===t&&(s.config.testBandwidth&&this.levels.length>1?(t=0,this.bitrateTest=!0):t=s.nextAutoLevel),this.level=s.nextLoadLevel=t,this.loadedmetadata=!1}e>0&&-1===t&&(this.log("Override startPosition with lastCurrentTime @".concat(e.toFixed(3))),t=e),this.state=Cs,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=ws}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Gs:{var t;const{levels:e,level:s}=this,i=null==e||null==(t=e[s])?void 0:t.details;if(i&&(!i.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(i))break;this.state=Cs;break}if(this.hls.nextLoadLevel!==this.level){this.state=Cs;break}break}case xs:{var e;const t=self.performance.now(),s=this.retryDate;(!s||t>=s||null!=(e=this.media)&&e.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Cs)}}this.state===Cs&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:s,media:i}
1=this,{config:r,nextLoadLevel:n}=t;if(null===e||!i&&(this.startFragRequested||!r.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(null==s||!s[n])return;const a=s[n],o=this.getMainFwdBufferInfo();if(null===o)return;const l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){const t={};return this.altAudio&&(t.type="video"),this.hls.trigger(u.BUFFER_EOS,t),void(this.state=Ns)}t.loadLevel!==n&&-1===t.manualLevel&&this.log("Adapting to level ".concat(n," from level ").concat(this.level)),this.level=t.nextLoadLevel=n;const c=a.details;if(!c||this.state===Gs||c.live&&this.levelLastLoaded!==n)return this.level=n,void(this.state=Gs);const h=o.len,d=this.getMaxBufferLength(a.maxBitrate);if(h>=d)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const f=this.backtrackFragment?this.backtrackFragment.start:o.end;let g=this.getNextFragment(f,c);if(this.couldBacktrack&&!this.fragPrevious&&g&&"initSegment"!==g.sn&&this.fragmentTracker.getState(g)!==ns){var m;const t=(null!=(m=this.backtrackFragment)?m:g).sn-c.startSN,e=c.fragments[t-1];e&&g.cc===e.cc&&(g=e,this.fragmentTracker.removeFragment(e))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(g&&this.isLoopLoading(g,f)){if(!g.gap){const t=this.audioOnly&&!this.altAudio?k:D,e=(t===D?this.videoBuffer:this.mediaBuffer)||this.media;e&&this.afterBufferFlushed(e,t,re)}g=this.getNextFragmentLoopLoading(g,c,o,re,d)}g&&(!g.initSegment||g.initSegment.data||this.bitrateTest||(g=g.initSegment),this.loadFragment(g,a,f))}loadFragment(t,e,s){const i=this.fragmentTracker.getState(t);this.fragCurrent=t,i===ss||i===rs?"initSegment"===t.sn?this._loadInitSegment(t,e):this.bitrateTest?(this.log("Fragment ".concat(t.sn," of level ").concat(t.level," is being downloaded to test bitrate and will not be buffered")),this._loadBitrateTestFrag(t,e)):(this.startFragRequested=!0,super.loadFragment(t,e,s)):this.clearTrackerIfNeeded(t)}getBufferedFrag(t){return this.fragmentTracker.getBufferedFrag(t,re)}followingBufferedFrag(t){return t?this.getBufferedFrag(t.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:t,media:e}=this;if(null!=e&&e.readyState){let s;const i=this.getAppendedFrag(e.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);const r=this.getLevelDetails();if(null!=r&&r.live){const t=this.getMainFwdBufferInfo();if(!t||t.len<2*r.targetduration)return}if(!e.paused&&t){const e=t[this.hls.nextLoadLevel],i=this.fragLastKbps;s=i&&this.fragCurrent?this.fragCurrent.duration*e.maxBitrate/(1e3*i)+1:0}else s=0;const n=this.getBufferedFrag(e.currentTime+s);if(n){const t=this.followingBufferedFrag(n);if(t){this.abortCurrentFrag();const e=t.maxStartPTS?t.maxStartPTS:t.start,s=t.duration,i=Math.max(n.end,e+Math.min(Math.max(s-this.config.maxFragLookUpTolerance,.5*s),.75*s));this.flushMainBuffer(i,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case _s:case Ps:case xs:case Ms:case Os:this.state=Cs}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(t,e){super.flushMainBuffer(t,e,this.altAudio?"video":null)}onMediaAttached(t,e){super.onMediaAttached(t,e);const s=e.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),s.addEventListener("playing",this.onvplaying),s.addEventListener("seeked",this.onvseeked),this.gapController=new ji(this.config,s,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:t}=this;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const t=this.media,e=t?t.currentTime:null;d(e)&&this.log("Media seeked to ".concat(e.toFixed(3)));const s=this.getMainFwdBufferInfo();null!==s&&0!==s.len?this.tick():this.warn('Main forward buffer length on "seeked" event '.concat(s?s.len:"empty",")"))}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(u.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(t,e){let s,i=!1,r=!1;
1e.levels.forEach((t=>{s=t.audioCodec,s&&(-1!==s.indexOf("mp4a.40.2")&&(i=!0),-1!==s.indexOf("mp4a.40.5")&&(r=!0))})),this.audioCodecSwitch=i&&r&&!function(){var t;const e=Hs();return"function"===typeof(null==e||null==(t=e.prototype)?void 0:t.changeType)}(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1}onLevelLoading(t,e){const{levels:s}=this;if(!s||this.state!==Cs)return;const i=s[e.level];(!i.details||i.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(i.details))&&(this.state=Gs)}onLevelLoaded(t,e){var s;const{levels:i}=this,r=e.level,n=e.details,a=n.totalduration;if(!i)return void this.warn("Levels were reset while loading level ".concat(r));this.log("Level ".concat(r," loaded [").concat(n.startSN,",").concat(n.endSN,"]").concat(n.lastPartSn?"[part-".concat(n.lastPartSn,"-").concat(n.lastPartIndex,"]"):"",", cc [").concat(n.startCC,", ").concat(n.endCC,"] duration:").concat(a));const o=i[r],l=this.fragCurrent;!l||this.state!==Ps&&this.state!==xs||l.level===e.level&&l.urlId===o.urlId||!l.loader||this.abortCurrentFrag();let c=0;if(n.live||null!=(s=o.details)&&s.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;c=this.alignPlaylists(n,o.details)}if(o.details=n,this.levelLastLoaded=r,this.hls.trigger(u.LEVEL_UPDATED,{details:n,level:r}),this.state===Gs){if(this.waitForCdnTuneIn(n))return;this.state=Cs}this.startFragRequested?n.live&&this.synchronizeToLiveEdge(n):this.setStartPosition(n,c),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:s,part:i,payload:r}=t,{levels:n}=this;if(!n)return void this.warn("Levels were reset while fragment load was in progress. Fragment ".concat(s.sn," of level ").concat(s.level," will not be buffered"));const a=n[s.level],o=a.details;if(!o)return this.warn("Dropping fragment ".concat(s.sn," of level ").concat(s.level," after level details were reset")),void this.fragmentTracker.removeFragment(s);const l=a.videoCodec,c=o.PTSKnown||!o.live,h=null==(e=s.initSegment)?void 0:e.data,d=this._getAudioCodec(a),u=this.transmuxer=this.transmuxer||new qi(this.hls,re,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,g=-1!==f,m=new Ts(s.level,s.sn,s.stats.chunkCount,r.byteLength,f,g),p=this.initPTS[s.cc];u.push(r,h,d,l,s,i,o.totalduration,c,m,p)}onAudioTrackSwitching(t,e){const s=this.altAudio;if(!!!e.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const t=this.fragCurrent;t&&(this.log("Switching to main audio track, cancel main fragment load"),t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const t=this.hls;s&&(t.trigger(u.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),t.trigger(u.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const s=e.id,i=!!this.hls.audioTracks[s].url;if(i){const t=this.videoBuffer;t&&this.mediaBuffer!==t&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=t)}this.altAudio=i,this.tick()}onBufferCreated(t,e){const s=e.tracks;let i,r,n=!1;for(const a in s){const t=s[a];if("main"===t.id){if(r=a,i=t,"video"===a){const t=s[a];t&&(this.videoBuffer=t.buffer)}}else n=!0}n&&i?(this.log("Alternate track found, use ".concat(r,".buffered to schedule main fragment loading")),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:s,part:i}=e;if(s&&s.type!==re)return;if(this.fragContextChanged(s))return this.warn("Fragment ".concat(s.sn).concat(i?" p: "+i.index:""," of level ").concat(s.level," finished buffering, but was aborted. state: ").concat(this.state)),void(this.state===Os&&(this.state=Cs));const r=i?i.stats:s.stats;this.fragLastKbps=Math.round(8*r.total/(r.buffering.end-r.loading.first)),"initSegment"!==s.sn&&(this.fragPrevious=s),this.fragBufferedComplete(s,i)}onError(t,e){var s;if(e.fatal)this.state=Us;else switch(e.details){case g.FRAG_GAP:case g.FRAG_PARSING_ERROR:case g.FRAG_DECRYPT_ERROR:case g.FRAG_LOAD_ERROR:case g.FRAG_LOAD_TIMEOUT:case g.KEY_LOAD_ERROR:case g.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(re,e);break;case g.LEVEL_LOAD_ERROR:case g.LEVEL_LOAD_TIMEOUT:case g.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==Gs||(null==(s=e.context)?void 0:s.type)!==ee||(this.state=Cs);break;case g.BUFFER_FULL_ERROR:if(!e.parent||"main"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case g.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}checkBuffer(){const{media:t,gapController:e}=this;if(t&&e&&t.readyState){if(this.loadedmetadata||!ys.getBuffered(t).length){const t=this.state!==Cs?this.fragCurrent:null;e.poll(this.lastCurrentTime,t)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=Cs,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,e){let{type:s}=e;if(s!==k||this.audioOnly&&!this.altAudio){const t=(s===D?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(t,s,re)}}onLevelsUpdated(t,e){this.levels=e.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:t}=this;if(!t)return;const e=t.currentTime;let s=this.startPosition;if(s>=0&&e<s){if(t.seeking)return void this.log("could not seek to ".concat(s,", already seeking at ").concat(e));const i=ys.getBuffered(t),r=(i.length?i.start(0):0)-s;r>0&&(r<this.config.maxBufferHole||r<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by ".concat(r," to match buffer start")),s+=r,this.startPosition=s),this.log("seek to target start position ".concat(s," from current time ").concat(e)),t.currentTime=s}}_getAudioCodec(t){let e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e=-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),e}_loadBitrateTestFrag(t,e){t.bitrateTest=!0,this._doFragLoad(t,e).then((s=>{const{hls:i}=this;if(!s||this.fragContextChanged(t))return;e.fragmentError=0,this.state=Cs,this.startFragRequested=!1,this.bitrateTest=!1;const r=t.stats;r.parsing.start=r.parsing.end=r.buffering.start=r.buffering.end=self.performance.now(),i.trigger(u.FRAG_LOADED,s),t.bitrateTest=!1}))}_handleTransmuxComplete(t){var e;const s="main",{hls:i}=this,{remuxResult:r,chunkMeta:n}=t,a=this.getCurrentContext(n);if(!a)return void this.resetWhenMissingContext(n);const{frag:o,part:l,level:c}=a,{video:h,text:f,id3:g,initSegment:m}=r,{details:p}=c,y=this.altAudio?void 0:r.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=Ms,m){if(null!=m&&m.tracks){const t=o.initSegment||o;this._bufferInitSegment(c,m.tracks,t,n),i.trigger(u.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:s,tracks:m.tracks})}const t=m.initPTS,e=m.timescale;
1d(t)&&(this.initPTS[o.cc]={baseTime:t,timescale:e},i.trigger(u.INIT_PTS_FOUND,{frag:o,id:s,initPTS:t,timescale:e}))}if(h&&p&&"initSegment"!==o.sn){const t=p.fragments[o.sn-1-p.startSN],e=o.sn===p.startSN,s=!t||o.cc>t.cc;if(!1!==r.independent){const{startPTS:t,endPTS:i,startDTS:r,endDTS:a}=h;if(l)l.elementaryStreams[h.type]={startPTS:t,endPTS:i,startDTS:r,endDTS:a};else if(h.firstKeyFrame&&h.independent&&1===n.id&&!s&&(this.couldBacktrack=!0),h.dropped&&h.independent){const r=this.getMainFwdBufferInfo(),n=(r?r.end:this.getLoadPosition())+this.config.maxBufferHole,l=h.firstKeyFramePTS?h.firstKeyFramePTS:t;if(!e&&n<l-this.config.maxBufferHole&&!s)return void this.backtrack(o);s&&(o.gap=!0),o.setElementaryStreamInfo(h.type,o.start,i,o.start,a,!0)}o.setElementaryStreamInfo(h.type,t,i,r,a),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(h,o,l,n,e||s)}else{if(!e&&!s)return void this.backtrack(o);o.gap=!0}}if(y){const{startPTS:t,endPTS:e,startDTS:s,endDTS:i}=y;l&&(l.elementaryStreams[k]={startPTS:t,endPTS:e,startDTS:s,endDTS:i}),o.setElementaryStreamInfo(k,t,e,s,i),this.bufferFragmentData(y,o,l,n)}if(p&&null!=g&&null!=(e=g.samples)&&e.length){const t={id:s,frag:o,details:p,samples:g.samples};i.trigger(u.FRAG_PARSING_METADATA,t)}if(p&&f){const t={id:s,frag:o,details:p,samples:f.samples};i.trigger(u.FRAG_PARSING_USERDATA,t)}}}_bufferInitSegment(t,e,s,i){if(this.state!==Ms)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;const{audio:r,video:n,audiovideo:a}=e;if(r){let e=t.audioCodec;const s=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(e&&(e=-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==r.metadata.channelCount&&-1===s.indexOf("firefox")&&(e="mp4a.40.5")),-1!==s.indexOf("android")&&"audio/mpeg"!==r.container&&(e="mp4a.40.2",this.log("Android: force audio codec to ".concat(e))),t.audioCodec&&t.audioCodec!==e&&this.log('Swapping manifest audio codec "'.concat(t.audioCodec,'" for "').concat(e,'"')),r.levelCodec=e,r.id="main",this.log("Init audio buffer, container:".concat(r.container,", codecs[selected/level/parsed]=[").concat(e||"","/").concat(t.audioCodec||"","/").concat(r.codec,"]"))}n&&(n.levelCodec=t.videoCodec,n.id="main",this.log("Init video buffer, container:".concat(n.container,", codecs[level/parsed]=[").concat(t.videoCodec||"","/").concat(n.codec,"]"))),a&&this.log("Init audiovideo buffer, container:".concat(a.container,", codecs[level/parsed]=[").concat(t.attrs.CODECS||"","/").concat(a.codec,"]")),this.hls.trigger(u.BUFFER_CODECS,e),Object.keys(e).forEach((t=>{const r=e[t].initSegment;null!=r&&r.byteLength&&this.hls.trigger(u.BUFFER_APPENDING,{type:t,data:r,frag:s,part:null,chunkMeta:i,parent:s.type})})),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,re)}backtrack(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=Cs}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&!1===t.seeking){const s=t.currentTime;if(ys.isBuffered(t,s)?e=this.getAppendedFrag(s):ys.isBuffered(t,s+.1)&&
1(e=this.getAppendedFrag(s+.1)),e){this.backtrackFragment=null;const t=this.fragPlaying,s=e.level;t&&e.sn===t.sn&&t.level===s&&e.urlId===t.urlId||(this.fragPlaying=e,this.hls.trigger(u.FRAG_CHANGED,{frag:e}),t&&t.level===s||this.hls.trigger(u.LEVEL_SWITCHED,{level:s}))}}}get nextLevel(){const t=this.nextBufferedFrag;return t?t.level:-1}get currentFrag(){const t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}get currentProgramDateTime(){const t=this.media;if(t){const e=t.currentTime,s=this.currentFrag;if(s&&d(e)&&d(s.programDateTime)){const t=s.programDateTime+1e3*(e-s.start);return new Date(t)}}return null}get currentLevel(){const t=this.currentFrag;return t?t.level:-1}get nextBufferedFrag(){const t=this.currentFrag;return t?this.followingBufferedFrag(t):null}get forceStartLoad(){return this._forceStartLoad}}class zi{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=s}sample(t,e){const s=Math.pow(this.alpha_,t);this.estimate_=e*(1-s)+s*this.estimate_,this.totalWeight_+=t}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_}}class Qi{constructor(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]: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_=.001,this.minDelayMs_=50,this.slow_
1=new zi(t),this.fast_=new zi(e),this.defaultTTFB_=i,this.ttfb_=new zi(t)}update(t,e){const{slow_:s,fast_:i,ttfb_:r}=this;s.halfLife!==t&&(this.slow_=new zi(t,s.getEstimate(),s.getTotalWeight())),i.halfLife!==e&&(this.fast_=new zi(e,i.getEstimate(),i.getTotalWeight())),r.halfLife!==t&&(this.ttfb_=new zi(t,r.getEstimate(),r.getTotalWeight()))}sample(t,e){const s=(t=Math.max(t,this.minDelayMs_))/1e3,i=8*e/s;this.fast_.sample(s,i),this.slow_.sample(s,i)}sampleTTFB(t){const e=t/1e3,s=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(s,Math.max(t,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_}destroy(){}}class $i{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){const{chunks:t,dataLength:e}=this;let s;return t.length?(s=1===t.length?t[0]:function(t,e){const s=new Uint8Array(e);let i=0;for(let r=0;r<t.length;r++){const e=t[r];s.set(e,i),i+=e.length}return s}(t,e),this.reset(),s):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}function Ji(t,e){if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(!Zi(t[s].attrs,e[s].attrs))return!1;return!0}function Zi(t,e){const s=t["STABLE-RENDITION-ID"];return s?s===e["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some((s=>t[s]!==e[s]))}class tr{constructor(t){this.buffered=void 0;const e=(e,s,i)=>{if((s>>>=0)>i-1)throw new DOMException("Failed to execute '".concat(e,"' on 'TimeRanges': The index provided (").concat(s,") is greater than the maximum bound (").concat(i,")"));return t[s][e]};this.buffered={get length(){return t.length},end:s=>e("end",s,t.length),start:s=>e("start",s,t.length)}}}function er(t){const e=[];for(let s=0;s<t.length;s++){const i=t[s];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||e.push(t[s])}return e}class sr{constructor(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}append(t,e){const s=this.queues[e];s.push(t),1===s.length&&this.buffers[e]&&this.executeNext(e)}insertAbort(t,e){this.queues[e].unshift(t),this.executeNext(e)}appendBlocker(t){let e;const s=new Promise((t=>{e=t})),i={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(i,t),s}executeNext(t){const{buffers:e,queues:s}=this,i=e[t],r=s[t];if(r.length){const e=r[0];try{e.execute()}catch(n){v.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),e.onError(n),null!=i&&i.updating||(r.shift(),this.executeNext(t))}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const ir=Nt(),rr=/([ha]vc.)(?:\.[^.,]+)+/;const nr={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},ar=function(t){let e=t;return nr.hasOwnProperty(t)&&(e=nr[t]),String.fromCharCode(e)},or=15,lr=100,cr={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},hr={17:2,18:4,21:6,22:8,23:10,19:13,20:15},dr={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},ur={25:2,26:4,29:6,30:8,31:10,27:13,28:15},fr=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class gr{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const s="function"===typeof e?e():e;v.log("".concat(this.time," [").concat(t,"] ").concat(s))}}}const mr=function(t){const e=[];for(let s=0;s<t.length;s++)e.push(t[s].toString(16));return e};class pr{constructor(t,e,s,i,r){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=e||!1,this.italics=s||!1,this.background=i||"black",this.flash=r||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(t){const e=["foreground","underline","italics","background","flash"];for(let s=0;s<e.length;s++){const i=e[s];t.hasOwnProperty(i)&&(this[i]=t[i])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash}copy(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class yr{constructor(t,e,s,i,r,n){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new pr(e,s,i,r,n)}reset(){this.uchar=" ",this.penState.reset()}setChar(t,e){this.uchar=t,this.penState.copy(e)}setPenState(t){this.penState.copy(t)}equals(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)}copy(t){this.uchar=t.uchar,this.penState.copy(t.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class Tr{constructor(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let e=0;e<lr;e++)this.chars.push(new yr);this.logger=t,this.pos=0,this.currPenState=new pr}equals(t){let e=!0;for(let s=0;s<lr;
vendor: 6,007 bytes, line 1
1s++)if(!this.chars[s].equals(t.chars[s])){e=!1;break}return e}copy(t){for(let e=0;e<lr;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<lr;e++)if(!this.chars[e].isEmpty()){t=!1;break}return t}setCursor(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>lr&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=lr)}moveCursor(t){const e=this.pos+t;if(t>1)for(let s=this.pos+1;s<e+1;s++)this.chars[s].setPenState(this.currPenState);this.setCursor(e)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(t){t>=144&&this.backSpace();const e=ar(t);this.pos>=lr?this.logger.log(0,(()=>"Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!")):(this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1))}clearFromPos(t){let e;for(e=t;e<lr;e++)this.chars[e].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const t=[];let e=!0;for(let s=0;s<lr;s++){const i=this.chars[s].uchar;" "!==i&&(e=!1),t.push(i)}return e?"":t.join("")}setPenStyles(t){this.currPenState.setStyles(t);this.chars[this.pos].setPenState(this.currPenState)}}class vr{constructor(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let e=0;e<or;e++)this.rows.push(new Tr(t));this.logger=t,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let t=0;t<or;t++)this.rows[t].clear();this.currRow=14}equals(t){let e=!0;for(let s=0;s<or;s++)if(!this.rows[s].equals(t.rows[s])){e=!1;break}return e}copy(t){for(let e=0;e<or;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<or;e++)if(!this.rows[e].isEmpty()){t=!1;break}return t}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(t){this.rows[this.currRow].insertChar(t)}setPen(t){this.rows[this.currRow].setPenStyles(t)}moveCursor(t){this.rows[this.currRow].moveCursor(t)}setCursor(t){this.logger.log(2,"setCursor: "+t);this.rows[this.currRow].setCursor(t)}setPAC(t){this.logger.log(2,(()=>"pacData = "+JSON.stringify(t)));let e=t.row-1;if(this.nrRollUpRows&&e<this.nrRollUpRows-1&&(e=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==e){for(let e=0;e<or;e++)this.rows[e].clear();const t=this.currRow+1-this.nrRollUpRows,s=this.lastOutputScreen;if(s){const i=s.rows[t].cueStartTime,r=this.logger.time;if(i&&null!==r&&i<r)for(let n=0;n<this.nrRollUpRows;n++)this.rows[e-this.nrRollUpRows+n+1].copy(s.rows[t+n])}}this.currRow=e;const s=this.rows[this.currRow];if(null!==t.indent){const e=t.indent,i=Math.max(e-1,0);s.setCursor(t.indent),t.color=s.chars[i].penState.foreground}const i={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(i)}setBkgData(t){this.logger.log(2,(()=>"bkgData = "+JSON.stringify(t))),this.backSpace(),this.setPen(t),this.insertChar(32)}setRollUpRows(t){this.nrRollUpRows=t}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,(()=>this.getDisplayText()));const t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),this.logger.log(2,"Rolling up")}getDisplayText(t){t=t||!1;const e=[];let s="",i=-1;for(let r=0;r<or;r++){const s=this.rows[r].getTextString();s&&(i=r+1,t?e.push("Row "+i+": '"+s+"'"):e.push(s.trim()))}return e.length>0&&(s=t?"["+e.join(" | ")+"]":e.join("\n")),s}getTextAndFormat(){return this.rows}}class Er{constructor(t,e,s){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new vr(s),this.nonDisplayedMemory=new vr(s),this.lastOutputScreen=new vr(s),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=s}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(t){this.outputFilter=t}setPAC(t){this.writeScreen.setPAC(t)}setBkgData(t){this.writeScreen.setBkgData(t)}setMode(t){t!==this.mode&&(this.mode=t,this.logger.log(2,(()=>"MODE="+t)),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)}insertChars(t){for(let s=0;s<t.length;s++)this.writeScreen.insertChar(t[s]);const e=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(()=>e+": "+this.writeScreen.getDisplayText(!0))),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,(()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0))),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(t){this.logger.log(2,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}
1ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,(()=>"DISP: "+this.displayedMemory.getDisplayText()))}this.outputDataUpdate(!0)}ccTO(t){this.logger.log(2,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)}ccMIDROW(t){const e={flash:!1};if(e.underline=t%2===1,e.italics=t>=46,e.italics)e.foreground="white";else{const s=Math.floor(t/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=i[s]}this.logger.log(2,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)}outputDataUpdate(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=this.logger.time;null!==e&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))}}class Sr{constructor(t,e,s){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const i=new gr;this.channels=[null,new Er(t,e,i),new Er(t+1,s,i)],this.cmdHistory={a:null,b:null},this.logger=i}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){let s,i,r,n=!1;this.logger.time=t;for(let a=0;a<e.length;a+=2)if(i=127&e[a],r=127&e[a+1],0!==i||0!==r){if(this.logger.log(3,"["+mr([e[a],e[a+1]])+"] -> ("+mr([i,r])+")"),s=this.parseCmd(i,r),s||(s=this.parseMidrow(i,r)),s||(s=this.parsePAC(i,r)),s||(s=this.parseBackgroundAttributes(i,r)),!s&&(n=this.parseChars(i,r),n)){const t=this.currentChannel;if(t&&t>0){this.channels[t].insertChars(n)}else this.logger.log(2,"No channel found yet. TEXT-MODE?")}s||n||this.logger.log(2,"Couldn't parse cleaned data "+mr([i,r])+" orig: "+mr([e[a],e[a+1]]))}}parseCmd(t,e){const{cmdHistory:s}=this;if(!((20===t||28===t||21===t||29===t)&&e>=32&&e<=47)&&!((23===t||31===t)&&e>=33&&e<=35))return!1;if(Ar(t,e,s))return Lr(null,null,s),this.logger.log(3,"Repeated command ("+mr([t,e])+") is dropped"),!0;const i=20===t||21===t||23===t?1:2,r=this.channels[i];return 20===t||21===t||28===t||29===t?32===e?r.ccRCL():33===e?r.ccBS():34===e?r.ccAOF():35===e?r.ccAON():36===e?r.ccDER():37===e?r.ccRU(2):38===e?r.ccRU(3):39===e?r.ccRU(4):40===e?r.ccFON():41===e?r.ccRDC():42===e?r.ccTR():43===e?r.ccRTD():44===e?r.ccEDM():45===e?r.ccCR():46===e?r.ccENM():47===e&&r.ccEOC():r.ccTO(e-32),Lr(t,e,s),this.currentChannel=i,!0}parseMidrow(t,e){let s=0;if((17===t||25===t)&&e>=32&&e<=47){if(s=17===t?1:2,s!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const i=this.channels[s];return!!i&&(i.ccMIDROW(e),this.logger.log(3,"MIDROW ("+mr([t,e])+")"),!0)}return!1}parsePAC(t,e){let s;const i=this.cmdHistory;if(!((t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127)&&!((16===t||24===t)&&e>=64&&e<=95))return!1;if(Ar(t,e,i))return Lr(null,null,i),!0;const r=t<=23?1:2;s=e>=64&&e<=95?1===r?cr[t]:dr[t]:1===r?hr[t]:ur[t];const n=this.channels[r];return!!n&&(n.setPAC(this.interpretPAC(s,e)),Lr(t,e,i),this.currentChannel=r,!0)}interpretPAC(t,e){let s;const i={color:null,italics:!1,indent:null,underline:!1,row:t};return s=e>95?e-96:e-64,i.underline=1===(1&s),s<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(s/2)]:s<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((s-16)/2),i}parseChars(t,e){let s,i=null,r=null;if(t>=25?(s=2,r=t-8):(s=1,r=t),r>=17&&r<=19){let t;
vendor: 5,419 bytes, line 1
1t=17===r?e+80:18===r?e+112:e+144,this.logger.log(2,"Special char '"+ar(t)+"' in channel "+s),i=[t]}else t>=32&&t<=127&&(i=0===e?[t]:[t,e]);if(i){const s=mr(i);this.logger.log(3,"Char codes =  "+s.join(",")),Lr(t,e,this.cmdHistory)}return i}parseBackgroundAttributes(t,e){if(!((16===t||24===t)&&e>=32&&e<=47)&&!((23===t||31===t)&&e>=45&&e<=47))return!1;let s;const i={};16===t||24===t?(s=Math.floor((e-32)/2),i.background=fr[s],e%2===1&&(i.background=i.background+"_semi")):45===e?i.background="transparent":(i.foreground="black",47===e&&(i.underline=!0));const r=t<=23?1:2;return this.channels[r].setBkgData(i),Lr(t,e,this.cmdHistory),!0}reset(){for(let t=0;t<Object.keys(this.channels).length;t++){const e=this.channels[t];e&&e.reset()}this.cmdHistory={a:null,b:null}}cueSplitAtTime(t){for(let e=0;e<this.channels.length;e++){const s=this.channels[e];s&&s.cueSplitAtTime(t)}}}function Lr(t,e,s){s.a=t,s.b=e}function Ar(t,e,s){return s.a===t&&s.b===e}class Rr{constructor(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(t,e,s){(null===this.startTime||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=s,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var br=function(){if("undefined"!==typeof self&&self.VTTCue)return self.VTTCue;const t=["","lr","rl"],e=["start","middle","end","left","right"];function s(t,e){if("string"!==typeof e)return!1;if(!Array.isArray(t))return!1;const s=e.toLowerCase();return!!~t.indexOf(s)&&s}function i(t){return s(e,t)}function r(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];let r=1;for(;r<arguments.length;r++){const e=arguments[r];for(const s in e)t[s]=e[s]}return t}function n(e,n,a){const o=this,l={enumerable:!0};o.hasBeenReset=!1;let c="",h=!1,d=e,u=n,f=a,g=null,m="",p=!0,y="auto",T="start",v=50,E="middle",S=50,L="middle";Object.defineProperty(o,"id",r({},l,{get:function(){return c},set:function(t){c=""+t}})),Object.defineProperty(o,"pauseOnExit",r({},l,{get:function(){return h},set:function(t){h=!!t}})),Object.defineProperty(o,"startTime",r({},l,{get:function(){return d},set:function(t){if("number"!==typeof t)throw new TypeError("Start time must be set to a number.");d=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",r({},l,{get:function(){return u},set:function(t){if("number"!==typeof t)throw new TypeError("End time must be set to a number.");u=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",r({},l,{get:function(){return f},set:function(t){f=""+t,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",r({},l,{get:function(){return g},set:function(t){g=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",r({},l,{get:function(){return m},set:function(e){const i=function(e){return s(t,e)}(e);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");m=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",r({},l,{get:function(){return p},set:function(t){p=!!t,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",r({},l,{get:function(){return y},set:function(t){if("number"!==typeof t&&"auto"!==t)throw new SyntaxError("An invalid number or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",r({},l,{get:function(){return T},set:function(t){const e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");T=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",r({},l,{get:function(){return v},set:function(t){if(t<0||t>100)throw new Error("Position must be between 0 and 100.");v=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",r({},l,{get:function(){return E},set:function(t){const e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");E=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",r({},l,{get:function(){return S},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");S=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",r({},l,{get:function(){return L},set:function(t){const e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");L=e,this.hasBeenReset=!0}})),o.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n}();class kr{decode(t,e){if(!t)return"";if("string"!==typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function Dr(t){function e(t,e,s,i){return 3600*(0|t)+60*(0|e)+(0|s)+parseFloat(i||0)}const s=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return s?parseFloat(s[2])>59?e(s[2],s[3],0,s[4]):e(s[1],s[2],s[3],s[4]):null}class Ir{constructor(){this.values=Object.create(null)}set(t,e){this.get(t)||""===e||(this.values[t]=e)}get(t,e,s){return s?this.has(t)?this.values[t]:e[s]:this.has(t)?this.values[t]:e}has(t){return t in this.values}alt(t,e,s){for(let i=0;i<s.length;++i)if(e===s[i]){this.set(t,e);break}}integer(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))}percent(t,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){const s=parseFloat(e);
vendor: 9,013 bytes, line 1
1if(s>=0&&s<=100)return this.set(t,s),!0}return!1}}function wr(t,e,s,i){const r=i?t.split(i):[t];for(const n in r){if("string"!==typeof r[n])continue;const t=r[n].split(s);if(2!==t.length)continue;e(t[0],t[1])}}const Cr=new br(0,0,""),_r="middle"===Cr.align?"middle":"center";function Pr(t,e,s){const i=t;function r(){const e=Dr(t);if(null===e)throw new Error("Malformed timestamp: "+i);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function n(){t=t.replace(/^\s+/,"")}if(n(),e.startTime=r(),n(),"--\x3e"!==t.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);t=t.slice(3),n(),e.endTime=r(),n(),function(t,e){const i=new Ir;wr(t,(function(t,e){let r;switch(t){case"region":for(let r=s.length-1;r>=0;r--)if(s[r].id===e){i.set(t,s[r].region);break}break;case"vertical":i.alt(t,e,["rl","lr"]);break;case"line":r=e.split(","),i.integer(t,r[0]),i.percent(t,r[0])&&i.set("snapToLines",!1),i.alt(t,r[0],["auto"]),2===r.length&&i.alt("lineAlign",r[1],["start",_r,"end"]);break;case"position":r=e.split(","),i.percent(t,r[0]),2===r.length&&i.alt("positionAlign",r[1],["start",_r,"end","line-left","line-right","auto"]);break;case"size":i.percent(t,e);break;case"align":i.alt(t,e,["start",_r,"end","left","right"])}}),/:/,/\s/),e.region=i.get("region",null),e.vertical=i.get("vertical","");let r=i.get("line","auto");"auto"===r&&-1===Cr.line&&(r=-1),e.line=r,e.lineAlign=i.get("lineAlign","start"),e.snapToLines=i.get("snapToLines",!0),e.size=i.get("size",100),e.align=i.get("align",_r);let n=i.get("position","auto");"auto"===n&&50===Cr.position&&(n="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=n}(t,e)}function xr(t){return t.replace(/<br(?: \/)?>/gi,"\n")}class Fr{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new kr,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const e=this;function s(){let t=e.buffer,s=0;for(t=xr(t);s<t.length&&"\r"!==t[s]&&"\n"!==t[s];)++s;const i=t.slice(0,s);return"\r"===t[s]&&++s,"\n"===t[s]&&++s,e.buffer=t.slice(s),i}t&&(e.buffer+=e.decoder.decode(t,{stream:!0}));try{let t="";if("INITIAL"===e.state){if(!/\r\n|\n/.test(e.buffer))return this;t=s();const i=t.match(/^(\xef\xbb\xbf)?WEBVTT([ \t].*)?$/);if(null==i||!i[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}let r=!1;for(;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(r?r=!1:t=s(),e.state){case"HEADER":/:/.test(t)?wr(t,(function(t,e){}),/:/):t||(e.state="ID");continue;case"NOTE":t||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(t)){e.state="NOTE";break}if(!t)continue;if(e.cue=new br(0,0,""),e.state="CUE",-1===t.indexOf("--\x3e")){e.cue.id=t;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{Pr(t,e.cue,e.regionList)}catch(i){e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{const s=-1!==t.indexOf("--\x3e");if(!t||s&&(r=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(null===e.cue)continue;e.cue.text&&(e.cue.text+="\n"),e.cue.text+=t}continue;case"BADCUE":t||(e.state="ID")}}}catch(i){"CUETEXT"===e.state&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state="INITIAL"===e.state?"BADWEBVTT":"BADCUE"}return this}flush(){const t=this;try{if((t.cue||"HEADER"===t.state)&&(t.buffer+="\n\n",t.parse()),"INITIAL"===t.state||"BADWEBVTT"===t.state)throw new Error("Malformed WebVTT signature.")}catch(e){t.onparsingerror&&t.onparsingerror(e)}return t.onflush&&t.onflush(),this}}const Mr=/\r\n|\n\r|\n|\r/g,Or=function(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return t.slice(s,s+e.length)===e},Nr=function(t){let e=5381,s=t.length;for(;s;)e=33*e^t.charCodeAt(--s);return(e>>>0).toString()};function Ur(t,e,s){return Nr(t.toString())+Nr(e.toString())+Nr(s)}function Br(t,e,s,i,r,n,a){const o=new Fr,l=at(new Uint8Array(t)).trim().replace(Mr,"\n").split("\n"),c=[],h=e?function(t){return bi(t,Ri,1/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1))}(e.baseTime,e.timescale):0;let u,f="00:00.000",g=0,m=0,p=!0;o.oncue=function(t){const n=s[i];let a=s.ccOffset;const o=(g-h)/9e4;if(null!=n&&n.new&&(void 0!==m?a=s.ccOffset=n.start:function(t,e,s){let i=t[e],r=t[i.prevCC];if(!r||!r.new&&i.new)return t.ccOffset=t.presentationOffset=i.start,void(i.new=!1);for(;null!=(n=r)&&n.new;){var n;t.ccOffset+=i.start-r.start,i.new=!1,i=r,r=t[i.prevCC]}t.presentationOffset=s}(s,i,o)),o){if(!e)return void(u=new Error("Missing initPTS for VTT MPEGTS"));a=o-s.presentationOffset}const l=t.endTime-t.startTime,d=_i(9e4*(t.startTime+a-m),9e4*r)/9e4;t.startTime=Math.max(d,0),t.endTime=Math.max(d+l,0);const f=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(f)),t.id||(t.id=Ur(t.startTime,t.endTime,f)),t.endTime>0&&c.push(t)},o.onparsingerror=function(t){u=t},o.onflush=function(){u?a(u):n(c)},l.forEach((t=>{if(p){if(Or(t,"X-TIMESTAMP-MAP=")){p=!1,t.slice(16).split(",").forEach((t=>{Or(t,"LOCAL:")?f=t.slice(6):Or(t,"MPEGTS:")&&(g=parseInt(t.slice(7)))}));try{m=function(t){let e=parseInt(t.slice(-3));const s=parseInt(t.slice(-6,-4)),i=parseInt(t.slice(-9,-7)),r=t.length>9?parseInt(t.substring(0,t.indexOf(":"))):0;if(!d(e)||!d(s)||!d(i)||!d(r))throw Error("Malformed X-TIMESTAMP-MAP: Local:".concat(t));return e+=1e3*s,e+=6e4*i,e+=36e5*r,e}(f)/1e3}catch(e){u=e}return}""===t&&(p=!1)}o.parse(t+"\n")})),o.flush()}const Gr="stpp.ttml.im1t",Kr=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Hr=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Vr={left:"start",center:"center",right:"end",start:"start",end:"end"};function Yr(t,e,s,i){const r=Tt(new Uint8Array(t),["mdat"]);if(0===r.length)return void i(new Error("Could not parse IMSC1 mdat"));const n=r.map((t=>at(t))),a=function(t,e){return bi(t,e,1/(arguments.length>2&&void 0!==arguments[2]?arguments[2]:1),arguments.length>3&&void 0!==arguments[3]&&arguments[3])}(e.baseTime,1,e.timescale);try{n.forEach((t=>s(function(t,e){const s=(new DOMParser).parseFromString(t,"text/xml"),i=s.getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(r).reduce(((t,e)=>(t[e]=i.getAttribute("ttp:".concat(e))||r[e],t)),{}),a="preserve"!==i.getAttribute("xml:space"),o=qr(Wr(i,"styling","style")),l=qr(Wr(i,"layout","region")),c=Wr(i,"body","[begin]");return[].map.call(c,(t=>{const s=jr(t,a);if(!s||!t.hasAttribute("begin"))return null;const i=Qr(t.getAttribute("begin"),n),r=Qr(t.getAttribute("dur"),n);let c=Qr(t.getAttribute("end"),n);if(null===i)throw zr(t);if(null===c){if(null===r)throw zr(t);c=i+r}const d=new br(i-e,c-e,s);d.id=Ur(d.startTime,d.endTime,d.text);const u=function(t,e,s){const i="http://www.w3.org/ns/ttml#styling";let r=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=null!=t&&t.hasAttribute("style")?t.getAttribute("style"):null;a&&s.hasOwnProperty(a)&&(r=s[a]);return n.reduce(((s,n)=>{const a=Xr(e,i,n)||Xr(t,i,n)||Xr(r,i,n);return a&&(s[n]=a),s}),{})}(l[t.getAttribute("region")],o[t.getAttribute("style")],o),{textAlign:f}=u;if(f){const t=Vr[f];t&&(d.lineAlign=t),d.align=f}return h(d,u),d})).filter((t=>null!==t))}(t,a))))}catch(o){i(o)}}function Wr(t,e,s){const i=t.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(s)):[]}function qr(t){return t.reduce(((t,e)=>{const s=e.getAttribute("xml:id");return s&&(t[s]=e),t}),{})}function jr(t,e){return[].slice.call(t.childNodes).reduce(((t,s,i)=>{var r;return"br"===s.nodeName&&i?t+"\n":null!=(r=s.childNodes)&&r.length?jr(s,e):e?t+s.textContent.trim().replace(/\s+/g," "):t+s.textContent}),"")}function Xr(t,e,s){return t&&t.hasAttributeNS(e,s)?t.getAttributeNS(e,s):null}function zr(t){return new Error("Could not parse ttml timestamp ".concat(t))}function Qr(t,e){if(!t)return null;let s=Dr(t);return null===s&&(Kr.test(t)?s=function(t,e){const s=Kr.exec(t),i=(0|s[4])+(0|s[5])/e.subFrameRate;return 3600*(0|s[1])+60*(0|s[2])+(0|s[3])+i/e.frameRate}(t,e):Hr.test(t)&&(s=function(t,e){const s=Hr.exec(t),i=Number(s[1]);switch(s[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}(t,e))),s}function $r(t,e){return!!t&&t.label===e.name&&!(t.textTrack1||t.textTrack2)}class Jr{constructor(t){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(t){this.streamController=t}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:t}=this;t.on(u.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(u.MEDIA_ATTA
1CHING,this.onMediaAttaching,this),t.on(u.MANIFEST_PARSED,this.onManifestParsed,this),t.on(u.BUFFER_CODECS,this.onBufferCodecs,this),t.on(u.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(u.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(u.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(u.MANIFEST_PARSED,this.onManifestParsed,this),t.off(u.BUFFER_CODECS,this.onBufferCodecs,this),t.off(u.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){const s=this.hls.levels[e.droppedLevel];this.isLevelAllowed(s)&&this.restrictedLevels.push({bitrate:s.bitrate,height:s.height,width:s.width})}onMediaAttaching(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null}onManifestParsed(t,e){const s=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,s.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onBufferCodecs(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const t=this.hls.levels;if(t.length){const e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}}getMaxLevel(t){const e=this.hls.levels;if(!e.length)return-1;const s=e.filter(((e,s)=>this.isLevelAllowed(e)&&s<=t));return this.clientRect=null,Jr.getMaxLevelByMediaSize(s,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const t=this.media,e={width:0,height:0};if(t){const s=t.getBoundingClientRect();e.width=s.width,e.height=s.height,e.width||e.height||(e.width=s.right-s.left||t.width||0,e.height=s.bottom-s.top||t.height||0)}return this.clientRect=e,e}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch(e){}return t}isLevelAllowed(t){return!this.restrictedLevels.some((e=>t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height))}static getMaxLevelByMediaSize(t,e,s){if(null==t||!t.length)return-1;let i=t.length-1;for(let a=0;a<t.length;a+=1){const o=t[a];if((o.width>=e||o.height>=s)&&(r=o,!(n=t[a+1])||r.width!==n.width||r.height!==n.height)){i=a;break}}var r,n;return i}}const Zr="[eme]";class tn{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=tn.CDMCleanupPromise?[tn.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=v.debug.bind(v,Zr),this.log=v.log.bind(v,Zr),this.warn=v.warn.bind(v,Zr),this.error=v.error.bind(v,Zr),this.hls=t,this.config=t.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}
1registerListeners(){this.hls.on(u.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(u.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(u.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(u.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(u.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(u.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(u.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(u.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:s}=this.config,i=e[t];if(i)return i.licenseUrl;if(t===O.WIDEVINE&&s)return s;throw new Error('no license server URL configured for key-system "'.concat(t,'"'))}getServerCertificateUrl(t){const{drmSystems:e}=this.config,s=e[t];if(s)return s.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'.concat(t,'"]'))}attemptKeySystemAccess(t){const e=this.hls.levels,s=(t,e,s)=>!!t&&s.indexOf(t)===e,i=e.map((t=>t.audioCodec)).filter(s),r=e.map((t=>t.videoCodec)).filter(s);return i.length+r.length===0&&r.push("avc1.42e01e"),new Promise(((e,s)=>{const n=t=>{const a=t.shift();this.getMediaKeysPromise(a,i,r).then((t=>e({keySystem:a,mediaKeys:t}))).catch((e=>{t.length?n(t):s(e instanceof en?e:new en({type:f.KEY_SYSTEM_ERROR,details:g.KEY_SYSTEM_NO_ACCESS,error:e,fatal:!0},e.message))}))};n(t)}))}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:s}=this.config;if("function"!==typeof s){let t="Configured requestMediaKeySystemAccess is not a function ".concat(s);return null===W&&"http:"===self.location.protocol&&(t="navigator.requestMediaKeySystemAccess is not available over insecure protocol ".concat(location.protocol)),Promise.reject(new Error(t))}return s(t,e)}getMediaKeysPromise(t,e,s){const i=function(t,e,s,i){let r;switch(t){case O.FAIRPLAY:r=["cenc","sinf"];break;case O.WIDEVINE:case O.PLAYREADY:r=["cenc"];break;case O.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error("Unknown key-system: ".concat(t))}return function(t,e,s,i){return[{initDataTypes:t,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map((t=>({contentType:'audio/mp4; codecs="'.concat(t,'"'),robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null}))),videoCapabilities:s.map((t=>({contentType:'video/mp4; codecs="'.concat(t,'"'),robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null})))}]}(r,e,s,i)}(t,e,s,this.config.drmSystemOptions),r=this.keySystemAccessPromises[t];let n=null==r?void 0:r.keySystemAccess;if(!n){this.log('Requesting encrypted media "'.concat(t,'" key-system access with config: ').concat(JSON.stringify(i))),n=this.requestMediaKeySystemAccess(t,i);const e=this.keySystemAccessPromises[t]={keySystemAccess:n};return n.catch((e=>{this.log('Failed to obtain access to key-system "'.concat(t,'": ').concat(e))})),n.then((s=>{this.log('Access for key-system "'.concat(s.keySystem,'" obtained'));const i=this.fetchServerCertificate(t);return this.log('Create media-keys for "'.concat(t,'"')),e.mediaKeys=s.createMediaKeys().then((e=>(this.log('Media-keys created for "'.concat(t,'"')),i.then((s=>s?this.setMediaKeysServerCertificate(e,t,s):e))))),e.mediaKeys.catch((e=>{this.error('Failed to create media-keys for "'.concat(t,'"}: ').concat(e))})),e.mediaKeys}))}return n.then((()=>r.mediaKeys))}createMediaKeySessionContext(t){let{decryptdata:e,keySystem:s,mediaKeys:i}=t;this.log('Creating key-system session "'.concat(s,'" keyId: ').concat(ct(e.keyId||[])));const r=i.createSession(),n={decryptdata:e,keySystem:s,mediaKeys:i,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const s=this.createMediaKeySessionContext(t),i=this.getKeyIdString(e),r="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(s,r,e.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)}getKeyIdString(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(null===t.keyId)throw new Error("keyId is null");return ct(t.keyId)}updateKeySession(t,e){var s;const i=t.mediaKeysSession;return this.log('Updating key-session "'.concat(i.sessionId,'" for keyID ').concat(ct((null==(s=t.decryptdata)?void 0:s.keyId)||[]),"\n      } (data length: ").concat(e?e.byteLength:e,")")),i.update(e)}selectKeySystemFormat(t){const e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: ".concat(t.sn," ").concat(t.type,": ").concat(t.level,") key formats ").concat(e.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise}getKeyFormatPromise(t){return new Promise(((e,s)=>{const i=Y(this.config),r=t.map(K).filter((t=>!!t&&-1!==i.indexOf(t)));return this.getKeySystemSelectionPromise(r).then((t=>{let{keySystem:i}=t;const r=V(i);r?e(r):s(new Error('Unable to find format for key-system "'.concat(i,'"')))})).catch(s)}))}loadKey(t){const e=t.keyInfo.decryptdata,s=this.getKeyIdString(e),i="(keyId: ".concat(s,' format: "').concat(e.keyFormat,'" method: ').concat(e.method," uri: ").concat(e.uri,")");this.log("Starting session for key ".concat(i));let r=this.keyIdToKeySessionPromise[s];return r||(r=this.keyIdToKeySessionPromise[s]=this.getKeySystemForKeyPromise(e).then((s=>{let{keySystem:r,mediaKeys:n}=s;return this.throwIfDestroyed(),this.log("Handle encrypted media sn: ".concat(t.frag.sn," ").concat(t.frag.type,": ").concat(t.frag.level," using key ").concat(i)),this.attemptSetMediaKeys(r,n).then((()=>{this.throwIfDestroyed();const t=this.createMediaKeySessionContext({keySystem:r,mediaKeys:n,decryptdata:e});return this.generateRequestWithPreferredKeySession(t,"cenc",e.pssh,"playlist-key")}))}
1)),r.catch((t=>this.handleError(t)))),r}throwIfDestroyed(){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof en?this.hls.trigger(u.ERROR,t.data):this.hls.trigger(u.ERROR,{type:f.KEY_SYSTEM_ERROR,details:g.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),s=this.keyIdToKeySessionPromise[e];if(!s){const e=K(t.keyFormat),s=e?[e]:Y(this.config);return this.attemptKeySystemAccess(s)}return s}getKeySystemSelectionPromise(t){if(t.length||(t=Y(this.config)),0===t.length)throw new en({type:f.KEY_SYSTEM_ERROR,details:g.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options ".concat(JSON.stringify({drmSystems:this.config.drmSystems})));return this.attemptKeySystemAccess(t)}_onMediaEncrypted(t){const{initDataType:e,initData:s}=t;if(this.debug('"'.concat(t.type,'" event: init data type: "').concat(e,'"')),null===s)return;let i,r;if("sinf"===e&&this.config.drmSystems[O.FAIRPLAY]){const t=ft(new Uint8Array(s));try{const e=x(JSON.parse(t).sinf),s=St(new Uint8Array(e));if(!s)return;i=s.subarray(8,24),r=O.FAIRPLAY}catch(c){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{const t=function(t){if(!(t instanceof ArrayBuffer)||t.byteLength<32)return null;const e={version:0,systemId:"",kids:null,data:null},s=new DataView(t),i=s.getUint32(0);if(t.byteLength!==i&&i>44)return null;if(1886614376!==s.getUint32(4))return null;if(e.version=s.getUint32(8)>>>24,e.version>1)return null;e.systemId=ct(new Uint8Array(t,12,16));const r=s.getUint32(28);if(0===e.version){if(i-32<r)return null;e.data=new Uint8Array(t,32,r)}else if(1===e.version){e.kids=[];for(let s=0;s<r;s++)e.kids.push(new Uint8Array(t,32+16*s,16))}return e}(s);if(null===t)return;0===t.version&&t.systemId===H&&t.data&&(i=t.data.subarray(8,24)),r=function(t){if(t===H)return O.WIDEVINE}(t.systemId)}if(!r||!i)return;const n=ct(i),{keyIdToKeySessionPromise:a,mediaKeySessions:o}=this;let l=a[n];for(let h=0;h<o.length;h++){const t=o[h],r=t.decryptdata;if(r.pssh||!r.keyId)continue;const c=ct(r.keyId);if(n===c||-1!==r.uri.replace(/-/g,"").indexOf(n)){l=a[c],delete a[c],r.pssh=new Uint8Array(s),r.keyId=i,l=a[n]=l.then((()=>this.generateRequestWithPreferredKeySession(t,e,s,"encrypted-event-key-match")));break}}l||(l=a[n]=this.getKeySystemSelectionPromise([r]).then((t=>{let{keySystem:r,mediaKeys:a}=t;var o;this.throwIfDestroyed();const l=new Ct("ISO-23001-7",n,null!=(o=V(r))?o:"");return l.pssh=new Uint8Array(s),l.keyId=i,this.attemptSetMediaKeys(r,a).then((()=>{this.throwIfDestroyed();const t=this.createMediaKeySessionContext({decryptdata:l,keySystem:r,mediaKeys:a});return this.generateRequestWithPreferredKeySession(t,e,s,"encrypted-event-no-match")}))}))),l.catch((t=>this.handleError(t)))}_onWaitingForKey(t){this.log('"'.concat(t.type,'" event'))}attemptSetMediaKeys(t,e){const s=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'.concat(t,'"'));const i=Promise.all(s).then((()=>
1{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(e)}));return this.setMediaKeysQueue.push(i),i.then((()=>{this.log('Media-keys set for "'.concat(t,'"')),s.push(i),this.setMediaKeysQueue=this.setMediaKeysQueue.filter((t=>-1===s.indexOf(t)))}))}generateRequestWithPreferredKeySession(t,e,s,i){var r,n;const a=null==(r=this.config.drmSystems)||null==(n=r[t.keySystem])?void 0:n.generateRequest;if(a)try{const i=a.call(this.hls,e,s,t);if(!i)throw new Error("Invalid response from configured generateRequest filter");e=i.initDataType,s=t.decryptdata.pssh=i.initData?new Uint8Array(i.initData):null}catch(d){var o;if(this.warn(d.message),null!=(o=this.hls)&&o.config.debug)throw d}if(null===s)return this.log('Skipping key-session request for "'.concat(i,'" (no initData)')),Promise.resolve(t);const l=this.getKeyIdString(t.decryptdata);this.log('Generating key-session request for "'.concat(i,'": ').concat(l," (init data type: ").concat(e," length: ").concat(s?s.byteLength:null,")"));const c=new Yi;t.mediaKeysSession.onmessage=e=>{const s=t.mediaKeysSession;if(!s)return void c.emit("error",new Error("invalid state"));const{messageType:i,message:r}=e;this.log('"'.concat(i,'" message event for session "').concat(s.sessionId,'" message size: ').concat(r.byteLength)),"license-request"===i||"license-renewal"===i?this.renewLicense(t,r).catch((t=>{this.handleError(t),c.emit("error",t)})):"license-release"===i?t.keySystem===O.FAIRPLAY&&(this.updateKeySession(t,M("acknowledged")),this.removeSession(t)):this.warn('unhandled media key message type "'.concat(i,'"'))},t.mediaKeysSession.onkeystatuseschange=e=>{if(!t.mediaKeysSession)return void c.emit("error",new Error("invalid state"));this.onKeyStatusChange(t);const s=t.keyStatus;c.emit("keyStatus",s),"expired"===s&&(this.warn("".concat(t.keySystem," expired for key ").concat(l)),this.renewKeySession(t))};const h=new Promise(((t,e)=>{c.on("error",e),c.on("keyStatus",(s=>{s.startsWith("usable")?t():"output-restricted"===s?e(new en({type:f.KEY_SYSTEM_ERROR,details:g.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===s?e(new en({type:f.KEY_SYSTEM_ERROR,details:g.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'.concat(s,'"'))):"expired"===s?e(new Error("key expired while generating request")):this.warn('unhandled key status change "'.concat(s,'"'))}))}));return t.mediaKeysSession.generateRequest(e,s).then((()=>{var e;this.log('Request generated for key-session "'.concat(null==(e=t.mediaKeysSession)?void 0:e.sessionId,'" keyId: ').concat(l))})).catch((t=>{throw new en({type:f.KEY_SYSTEM_ERROR,details:g.KEY_SYSTEM_NO_SESSION,error:t,fatal:!1},"Error generating key-session request: ".concat(t))})).then((()=>h)).catch((e=>{throw c.removeAllListeners(),this.removeSession(t),e})).then((()=>(c.removeAllListeners(),t)))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach(((e,s)=>{this.log('key status change "'.concat(e,'" for keyStatuses keyId: ').concat(ct("buffer"in s?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s))," session keyId: ").concat(ct(new Uint8Array(t.decryptdata.keyId||[]))," uri: ").concat(t.decryptdata.uri)),t.keyStatus=e}))}fetchServerCertificate(t){const e=this.config,s=new(0,e.loader)(e),i=this.getServerCertificateUrl(t);return i?(this.log('Fetching serverCertificate for "'.concat(t,'"')),new Promise(((r,n)=>{const a={responseType:"arraybuffer",url:i},o=e.certLoadPolicy.default,c={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(t,e,s,i)=>{r(t.data)},onError:(e,s,r,o)=>{n(new en({type:f.KEY_SYSTEM_ERROR,details:g.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:l({url:a.url,data:void 0},e)},'"'.concat(t,'" certificate request failed (').concat(i,"). Status: ").concat(e.code," (").concat(e.text,")")))},onTimeout:(e,s,r)=>{n(new en({type:f.KEY_SYSTEM_ERROR,details:g.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:{url:a.url,data:void 0}},'"'.concat(t,'" certificate request timed out (').concat(i,")")))},onAbort:(t,e,s)=>{n(new Error("aborted"))}};s.load(a,c,h)}))):Promise.resolve()}setMediaKeysServerCertificate(t,e,s){return new Promise(((i,r)=>{t.setServerCertificate(s).then((r=>{this.log("setServerCertificate ".concat(r?"success":"not supported by CDM"," (").concat(null==s?void 0:s.byteLength,') on "').concat(e,'"')),i(t)})).catch((t=>{r(new en({type:f.KEY_SYSTEM_ERROR,details:g.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:t,fatal:!0},t.message))}))}))}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then((e=>this.updateKeySession(t,new Uint8Array(e)).catch((t=>{throw new en({type:f.KEY_SYSTEM_ERROR,details:g.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:t,fatal:!0},t.message)}))))}setupLicenseXHR(t,e,s,i){const r=this.config.licenseXhrSetup;return r?Promise.resolve().then((()=>
1{if(!s.decryptdata)throw new Error("Key removed");return r.call(this.hls,t,e,s,i)})).catch((n=>{if(!s.decryptdata)throw n;return t.open("POST",e,!0),r.call(this.hls,t,e,s,i)})).then((s=>{t.readyState||t.open("POST",e,!0);return{xhr:t,licenseChallenge:s||i}})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:i}))}requestLicense(t,e){const s=this.config.keyLoadPolicy.default;return new Promise(((i,r)=>{const n=this.getLicenseServerUrl(t.keySystem);this.log("Sending license request to URL: ".concat(n));const a=new XMLHttpRequest;a.responseType="arraybuffer",a.onreadystatechange=()=>{if(!this.hls||!t.mediaKeysSession)return r(new Error("invalid state"));if(4===a.readyState)if(200===a.status){this._requestLicenseFailureCount=0;let e=a.response;this.log("License received ".concat(e instanceof ArrayBuffer?e.byteLength:e));const s=this.config.licenseResponseCallback;if(s)try{e=s.call(this.hls,a,n,t)}catch(o){this.error(o)}i(e)}else{const o=s.errorRetry,l=o?o.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||a.status>=400&&a.status<500)r(new en({type:f.KEY_SYSTEM_ERROR,details:g.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:n,data:void 0,code:a.status,text:a.statusText}},"License Request XHR failed (".concat(n,"). Status: ").concat(a.status," (").concat(a.statusText,")")));else{const s=l-this._requestLicenseFailureCount+1;this.warn("Retrying license request, ".concat(s," attempts left")),this.requestLicense(t,e).then(i,r)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=a,this.setupLicenseXHR(a,n,t,e).then((t=>{let{xhr:e,licenseChallenge:s}=t;e.send(s)}))}))}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const s=e.media;this.media=s,s.addEventListener("encrypted",this.onMediaEncrypted),s.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const t=this.media,e=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Ct.clearKeyUriToKeyIdMap();const s=e.length;tn.CDMCleanupPromise=Promise.all(e.map((t=>this.removeSession(t))).concat(null==t?void 0:t.setMediaKeys(null).catch((e=>{this.log("Could not clear media keys: ".concat(e,". media.src: ").concat(null==t?void 0:t.src))})))).then((()=>{s&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)})).catch((e=>{this.log("Could not close sessions and clear media keys: ".concat(e,". media.src: ").concat(null==t?void 0:t.src))}))}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(t,e){let{sessionKeys:s}=e;if(s&&this.config.emeEnabled&&!this.keyFormatPromise){const t=s.reduce(((t,e)=>(-1===t.indexOf(e.keyFormat)&&t.push(e.keyFormat),t)),[]);this.log("Selecting key-system from session-keys ".concat(t.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(t)}}removeSession(t){const{mediaKeysSession:e,licenseXhr:s}=t;if(e){this.log("Remove licenses and keys and close session ".concat(e.sessionId)),e.onmessage=null,e.onkeystatuseschange=null,s&&s.readyState!==XMLHttpRequest.DONE&&s.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;const i=this.mediaKeySessions.indexOf(t);return i>-1&&this.mediaKeySessions.splice(i,1),e.remove().catch((t=>{this.log("Could not remove session: ".concat(t))})).then((()=>e.close())).catch((t=>{this.log("Could not close session: ".concat(t))}))}}}tn.CDMCleanupPromise=void 0;class en extends Error{constructor(t,e){super(e),this.data=void 0,t.error||(t.error=new Error(e)),this.data=t,t.err=t.error}}var sn="m",rn="a",nn="v",an="av",on="i",ln="tt";class cn{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=t=>{try{this.apply(t,{ot:sn,su:!this.initialized})}catch(e){v.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=t=>{try{const e=t.frag,s=this.hls.levels[e.level],i=this.getObjectType(e),r={d:1e3*e.duration,ot:i};i!==nn&&i!==rn&&i!=an||(r.br=s.bitrate/1e3,r.tb=this.getTopBandwidth(i)/1e3,r.bl=this.getBufferLength(i)),this.apply(t,r)}catch(e){v.warn("Could not generate segment CMCD data.",e)}},this.hls=t;const e=this.config=t.config,{cmcd:s}=e;null!=s&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=s.sessionId||cn.uuid(),this.cid=s.contentId,this.useHeaders=!0===s.useHeaders,this.registerListeners())}registerListeners(){const t=this.hls;
1t.on(u.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(u.MEDIA_DETACHED,this.onMediaDetached,this),t.on(u.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(u.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(u.MEDIA_DETACHED,this.onMediaDetached,this),t.off(u.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(t,e){var s,i;this.audioBuffer=null==(s=e.tracks.audio)?void 0:s.buffer,this.videoBuffer=null==(i=e.tracks.video)?void 0:i.buffer}createData(){var t;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:null==(t=this.media)?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};h(e,this.createData());const s=e.ot===on||e.ot===nn||e.ot===an;if(this.starved&&s&&(e.bs=!0,e.su=!0,this.starved=!1),null==e.su&&(e.su=this.buffering),this.useHeaders){const s=cn.toHeaders(e);if(!Object.keys(s).length)return;t.headers||(t.headers={}),h(t.headers,s)}else{const s=cn.toQuery(e);if(!s)return;t.url=cn.appendQueryToUri(t.url,s)}}getObjectType(t){const{type:e}=t;return"subtitle"===e?ln:"initSegment"===t.sn?on:"audio"===e?rn:"main"===e?this.hls.audioTracks.length?nn:an:void 0}getTopBandwidth(t){let e,s=0;const i=this.hls;if(t===rn)e=i.audioTracks;else{const t=i.maxAutoLevel,s=t>-1?t+1:i.levels.length;e=i.levels.slice(0,s)}for(const r of e)r.bitrate>s&&(s=r.bitrate);return s>0?s:NaN}getBufferLength(t){const e=this.hls.media,s=t===rn?this.audioBuffer:this.videoBuffer;if(!s||!e)return NaN;return 1e3*ys.bufferInfo(s,e.currentTime,this.config.maxBufferHole).len}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,s=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new s(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,s,i){e(t),this.loader.load(t,s,i)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,s=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new s(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,s,i){e(t),this.loader.load(t,s,i)}}}static uuid(){const t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)}static serialize(t){const e=[],s=t=>!Number.isNaN(t)&&null!=t&&""!==t&&!1!==t,i=t=>Math.round(t),r=t=>100*i(t/100),n={br:i,d:i,bl:r,dl:r,mtp:r,nor:t=>encodeURIComponent(t),rtp:r,tb:i},a=Object.keys(t||{}).sort();for(const o of a){let i=t[o];if(!s(i))continue;if("v"===o&&1===i)continue;if("pr"==o&&1===i)continue;const r=n[o];r&&(i=r(i));const a=typeof i;let l;l="ot"===o||"sf"===o||"st"===o?"".concat(o,"=").concat(i):"boolean"===a?o:"number"===a?"".concat(o,"=").concat(i):"".concat(o,"=").concat(JSON.stringify(i)),e.push(l)}return e.join(",")}static toHeaders(t){const e=Object.keys(t),s={},i=["Object","Request","Session","Status"],r=[{},{},{},{}],n={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const a of e){r[null!=n[a]?n[a]:1][a]=t[a]}for(let a=0;a<r.length;a++){const t=cn.serialize(r[a]);t&&(s["CMCD-".concat(i[a])]=t)}return s}static toQuery(t){return"CMCD=".concat(encodeURIComponent(cn.serialize(t)))}static appendQueryToUri(t,e){if(!e)return t;const s=t.includes("?")?"&":"?";return"".concat(t).concat(s).concat(e)}}function hn(t,e,s,i){t&&Object.keys(e).forEach((r=>{const n=t.filter((t=>t.groupId===r)).map((t=>{const n=h({},t);return n.details=void 0,n.attrs=new L(n.attrs),n.url=n.attrs.URI=dn(t.url,t.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",s),n.groupId=n.attrs["GROUP-ID"]=e[r],n.attrs["PATHWAY-ID"]=i,n}));t.push(...n)}))}function dn(t,e,s,i){const{HOST:r,PARAMS:n,[s]:a}=i;let o;e&&(o=null==a?void 0:a[e],o&&(t=o));const l=new self.URL(t);
vendor: 3,120 bytes, line 1
1return r&&!o&&(l.host=r),n&&Object.keys(n).sort().forEach((t=>{t&&l.searchParams.set(t,n[t])})),l.href}const un=/^age:\s*[\d.]+\s*$/im;class fn{constructor(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new b,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))}abort(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(t,e,s){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=s,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(!t)return;const s=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;const r=this.xhrSetup;r?Promise.resolve().then((()=>{if(!this.stats.aborted)return r(s,e.url)})).catch((t=>(s.open("GET",e.url,!0),r(s,e.url)))).then((()=>{this.stats.aborted||this.openAndSendXhr(s,e,t)})).catch((t=>{this.callbacks.onError({code:s.status,text:t.message},e,s,i)})):this.openAndSendXhr(s,e,t)}openAndSendXhr(t,e,s){t.readyState||t.open("GET",e.url,!0);const i=this.context.headers,{maxTimeToFirstByteMs:r,maxLoadTimeMs:n}=s.loadPolicy;if(i)for(const a in i)t.setRequestHeader(a,i[a]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),s.timeout=r&&d(r)?r:n,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:s}=this;if(!t||!e)return;const i=e.readyState,r=this.config;if(!s.aborted&&i>=2&&(0===s.loading.first&&(s.loading.first=Math.max(self.performance.now(),s.loading.start),r.timeout!==r.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),r.timeout=r.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.loadPolicy.maxLoadTimeMs-(s.loading.first-s.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const i=e.status,n="text"!==e.responseType;if(i>=200&&i<300&&(n&&e.response||null!==e.responseText)){s.loading.end=Math.max(self.performance.now(),s.loading.first);const r=n?e.response:e.responseText,a="arraybuffer"===e.responseType?r.byteLength:r.length;if(s.loaded=s.total=a,s.bwEstimate=8e3*s.total/(s.loading.end-s.loading.first),!this.callbacks)return;const o=this.callbacks.onProgress;if(o&&o(s,t,r,e),!this.callbacks)return;const l={url:e.responseURL,data:r,code:i};this.callbacks.onSuccess(l,s,t,e)}
1else{const n=r.loadPolicy.errorRetry;Be(n,s.retry,!1,i)?this.retry(n):(v.error("".concat(i," while loading ").concat(t.url)),this.callbacks.onError({code:i,text:e.statusText},t,e,s))}}}loadtimeout(){var t;const e=null==(t=this.config)?void 0:t.loadPolicy.timeoutRetry;if(Be(e,this.stats.retry,!0))this.retry(e);else{v.warn("timeout while loading ".concat(this.context.url));const t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:s}=this;this.retryDelay=Ne(t,s.retry),s.retry++,v.warn("".concat(status?"HTTP Status "+status:"Timeout"," while loading ").concat(e.url,", retrying ").concat(s.retry,"/").concat(t.maxNumRetry," in ").concat(this.retryDelay,"ms")),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(t){const e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)}getCacheAge(){let t=null;if(this.loader&&un.test(this.loader.getAllResponseHeaders())){const e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.loader&&new RegExp("^".concat(t,":\\s*[\\d.]+\\s*$"),"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}const gn=/(\d+)-(\d+)\/(\d+)/;class mn{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||pn,this.controller=new self.AbortController,this.stats=new b}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const t=this.response;null!=t&&t.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(t,e,s){const i=this.stats;if(i.loading.start)throw new Error("Loader can only be used once.");i.loading.start=self.performance.now();const r=function(t,e){const s={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(h({},t.headers))};t.rangeEnd&&s.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1));return s}(t,this.controller.signal),n=s.onProgress,a="arraybuffer"===t.responseType,o=a?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:c}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=s,this.request=this.fetchSetup(t,r),self.clearTimeout(this.requestTimeout),e.timeout=l&&d(l)?l:c,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),s.onTimeout(i,t,this.response)}),e.timeout),self.fetch(this.request).then((r=>{this.response=this.loader=r;const o=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=c,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),s.onTimeout(i,t,this.response)}),c-(o-i.loading.start)),!r.ok){const{status:t,statusText:e}=r;throw new yn(e||"fetch, bad network response",t,r)}return i.loading.first=o,i.total=function(t){const e=t.get("Content-Range");if(e){const t=function(t){const e=gn.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}(e);if(d(t))return t}const s=t.get("Content-Length");if(s)return parseInt(s)}(r.headers)||i.total,n&&d(e.highWaterMark)?this.loadProgressively(r,i,t,e.highWaterMark,n):a?r.arrayBuffer():"json"===t.responseType?r.json():r.text()})).then((r=>{const{response:a}=this;self.clearTimeout(this.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);const l=r[o];l&&(i.loaded=i.total=l);const c={url:a.url,data:r,code:a.status};n&&!d(e.highWaterMark)&&n(i,t,r,a),s.onSuccess(c,i,t,a)})).catch((e=>{if(self.clearTimeout(this.requestTimeout),i.aborted)return;const r=e&&e.code||0,n=e?e.message:null;s.onError({code:r,text:n},t,e?e.details:null,i)}))}getCacheAge(){let t=null;if(this.response){const e=this.response.headers.get("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4?arguments[4]:void 0;const n=new $i,a=t.body.getReader(),o=()=>a.read().then((a=>
1{if(a.done)return n.dataLength&&r(e,s,n.flush(),t),Promise.resolve(new ArrayBuffer(0));const l=a.value,c=l.length;return e.loaded+=c,c<i||n.dataLength?(n.push(l),n.dataLength>=i&&r(e,s,n.flush(),t)):r(e,s,l,t),o()})).catch((()=>Promise.reject()));return o()}}function pn(t,e){return new self.Request(t.url,e)}class yn extends Error{constructor(t,e,s){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=s}}const Tn=/\s/,vn={newCue(t,e,s,i){const r=[];let n,a,o,l,c;const h=self.VTTCue||self.TextTrackCue;for(let u=0;u<i.rows.length;u++)if(n=i.rows[u],o=!0,l=0,c="",!n.isEmpty()){var d;for(let t=0;t<n.chars.length;t++)Tn.test(n.chars[t].uchar)&&o?l++:(c+=n.chars[t].uchar,o=!1);n.cueStartTime=e,e===s&&(s+=1e-4),l>=16?l--:l++;const i=xr(c.trim()),f=Ur(e,s,i);null!=t&&null!=(d=t.cues)&&d.getCueById(f)||(a=new h(e,s,i),a.id=f,a.line=u+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*l/32)),r.push(a))}return t&&r.length&&(r.sort(((t,e)=>"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line)),r.forEach((e=>de(t,e)))),r}},En=l(l({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:fn,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class{constructor(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;const e=t.config;this.bwEstimator=new Qi(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(u.FRAG_LOADING,this.onFragLoading,this),t.on(u.FRAG_LOADED,this.onFragLoaded,this),t.on(u.FRAG_BUFFERED,this.onFragBuffered,this),t.on(u.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(u.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:t}=this;t.off(u.FRAG_LOADING,this.onFragLoading,this),t.off(u.FRAG_LOADED,this.onFragLoaded,this),t.off(u.FRAG_BUFFERED,this.onFragBuffered,this),t.off(u.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(u.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(t,e){var s;const i=e.frag;this.ignoreFragment(i)||(this.fragCurrent=i,this.partCurrent=null!=(s=e.part)?s:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(t,e){this.clearTimer()}getTimeToLoadFrag(t,e,s,i){return t+s/e+(i?this.lastLevelLoadSec:0)}onLevelLoaded(t,e){const s=this.hls.config,{total:i,bwEstimate:r}=e.stats;d(i)&&d(r)&&(this.lastLevelLoadSec=8*i/r),e.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:t,partCurrent:e,hls:s}=this,{autoLevelEnabled:i,media:r}=s;if(!t||!r)return;const n=performance.now(),a=e?e.stats:t.stats,o=e?e.duration:t.duration,l=n-a.loading.start;if(a.aborted||a.loaded&&a.loaded===a.total||0===t.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!i||r.paused||!r.playbackRate||!r.readyState)return;const c=s.mainForwardBufferInfo;if(null===c)return;const h=this.bwEstimator.getEstimateTTFB(),f=Math.abs(r.playbackRate);if(l<=Math.max(h,o/(2*f)*1e3))return;const g=c.len/f;if(g>=2*o/f)return;const m=a.loading.first?a.loading.first-a.loading.start:-1,p=a.loaded&&m>-1,y=this.bwEstimator.getEstimate(),{levels:T,minAutoLevel:E}=s,S=T[t.level],L=a.total||Math.max(a.loaded,Math.round(o*S.maxBitrate/8));let A=l-m;A<1&&p&&(A=Math.min(l,8*a.loaded/y));const R=p?1e3*a.loaded/A:0,b=R?(L-a.loaded)/R:8*L/y+h/1e3;if(b<=g)return;const k=R?8*R:y;let D,I=Number.POSITIVE_INFINITY;for(D=t.level-1;D>E;D--){const t=T[D].maxBitrate;if(I=this.getTimeToLoadFrag(h/1e3,k,o*t,!T[D].details),I<g)break}I>=b||I>10*o||(s.nextLoadLevel=D,p?this.bwEstimator.sample(l-Math.min(h,m),a.loaded):this.bwEstimator.sampleTTFB(l),this.clearTimer(),v.warn("[abr] Fragment ".concat(t.sn).concat(e?" part "+e.index:""," of level ").concat(t.level," is loading too slowly;\n      Time to underbuffer: ").concat(g.toFixed(3)," s\n      Estimated load time for current fragment: ").concat(b.toFixed(3)," s\n      Estimated load time for down switch fragment: ").concat(I.toFixed(3)," s\n      TTFB estimate: ").concat(m,"\n      Current BW estimate: ").concat(d(y)?(y/1024).toFixed(3):"Unknown"," Kb/s\n      New BW estimate: ").concat((this.bwEstimator.getEstimate()/1024).toFixed(3)," Kb/s\n      Aborting and switching to level ").concat(D)),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),s.trigger(u.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:a}))}onFragLoaded(t,e){let{frag:s,part:i}=e;const r=i?i.stats:s.stats;if(s.type===re&&this.bwEstimator.sampleTTFB(r.loading.first-r.loading.start),!this.ignoreFragment(s)){if
1(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const t=i?i.duration:s.duration,e=this.hls.levels[s.level],n=(e.loaded?e.loaded.bytes:0)+r.loaded,a=(e.loaded?e.loaded.duration:0)+t;e.loaded={bytes:n,duration:a},e.realBitrate=Math.round(8*n/a)}if(s.bitrateTest){const t={stats:r,frag:s,part:i,id:s.type};this.onFragBuffered(u.FRAG_BUFFERED,t),s.bitrateTest=!1}}}onFragBuffered(t,e){const{frag:s,part:i}=e,r=null!=i&&i.stats.loaded?i.stats:s.stats;if(r.aborted)return;if(this.ignoreFragment(s))return;const n=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,r.loaded),r.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==re||"initSegment"===t.sn}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const t=this._nextAutoLevel,e=this.bwEstimator;if(-1!==t&&!e.canEstimate())return t;let s=this.getNextABRAutoLevel();if(-1!==t){const e=this.hls.levels;if(e.length>Math.max(t,s)&&e[t].loadError<=e[s].loadError)return t}return-1!==t&&(s=Math.min(t,s)),s}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:s}=this,{maxAutoLevel:i,config:r,minAutoLevel:n,media:a}=s,o=e?e.duration:t?t.duration:0,l=a&&0!==a.playbackRate?Math.abs(a.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():r.abrEwmaDefaultEstimate,h=s.mainForwardBufferInfo,d=(h?h.len:0)/l;let u=this.findBestLevel(c,n,i,d,r.abrBandWidthFactor,r.abrBandWidthUpFactor);if(u>=0)return u;v.trace("[abr] ".concat(d?"rebuffering expected":"buffer is empty",", finding optimal quality level"));let f=o?Math.min(o,r.maxStarvationDelay):r.maxStarvationDelay,g=r.abrBandWidthFactor,m=r.abrBandWidthUpFactor;if(!d){const t=this.bitrateTestDelay;if(t){f=(o?Math.min(o,r.maxLoadingDelay):r.maxLoadingDelay)-t,v.trace("[abr] bitrate test took ".concat(Math.round(1e3*t),"ms, set first fragment max fetchDuration to ").concat(Math.round(1e3*f)," ms")),g=m=1}}return u=this.findBestLevel(c,n,i,d+f,g,m),Math.max(u,0)}findBestLevel(t,e,s,i,r,n){var a;const{fragCurrent:o,partCurrent:l,lastLoadedFragLevel:c}=this,{levels:h}=this.hls,u=h[c],f=!(null==u||null==(a=u.details)||!a.live),g=null==u?void 0:u.codecSet,m=l?l.duration:o?o.duration:0,p=this.bwEstimator.getEstimateTTFB()/1e3;let y=e,T=-1;for(let E=s;E>=e;E--){const e=h[E];if(!e||g&&e.codecSet!==g){e&&(y=Math.min(E,y),T=Math.max(E,T));continue}-1!==T&&v.trace("[abr] Skipped level(s) ".concat(y,"-").concat(T,' with CODECS:"').concat(h[T].attrs.CODECS,'"; not compatible with "').concat(u.attrs.CODECS,'"'));const s=e.details,a=(l?null==s?void 0:s.partTarget:null==s?void 0:s.averagetargetduration)||m;let o;o=E<=c?r*t:n*t;const S=h[E].maxBitrate,L=this.getTimeToLoadFrag(p,o,S*a,void 0===s);if(v.trace("[abr] level:".concat(E," adjustedbw-bitrate:").concat(Math.round(o-S)," avgDuration:").concat(a.toFixed(1)," maxFetchDuration:").concat(i.toFixed(1)," fetchDuration:").concat(L.toFixed(1))),o>S&&(0===L||!d(L)||f&&!this.bitrateTestDelay||L<i))return E}return-1}set nextAutoLevel(t){this._nextAutoLevel=t}},bufferController:class{constructor(t){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{const{media:t,mediaSource:e}=this;v.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(u.MEDIA_ATTA
1CHED,{media:t})),e&&e.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{v.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{v.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:t,_objectUrl:e}=this;t&&t.src!==e&&v.error("Media element src was set while attaching MediaSource (".concat(e," > ").concat(t.src,")"))},this.hls=t,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){const{hls:t}=this;t.on(u.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(u.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(u.MANIFEST_LOADING,this.onManifestLoading,this),t.on(u.MANIFEST_PARSED,this.onManifestParsed,this),t.on(u.BUFFER_RESET,this.onBufferReset,this),t.on(u.BUFFER_APPENDING,this.onBufferAppending,this),t.on(u.BUFFER_CODECS,this.onBufferCodecs,this),t.on(u.BUFFER_EOS,this.onBufferEos,this),t.on(u.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(u.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(u.FRAG_PARSED,this.onFragParsed,this),t.on(u.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:t}=this;
1t.off(u.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(u.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(u.MANIFEST_LOADING,this.onManifestLoading,this),t.off(u.MANIFEST_PARSED,this.onManifestParsed,this),t.off(u.BUFFER_RESET,this.onBufferReset,this),t.off(u.BUFFER_APPENDING,this.onBufferAppending,this),t.off(u.BUFFER_CODECS,this.onBufferCodecs,this),t.off(u.BUFFER_EOS,this.onBufferEos,this),t.off(u.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(u.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(u.FRAG_PARSED,this.onFragParsed,this),t.off(u.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new sr(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(t,e){let s=2;(e.audio&&!e.video||!e.altAudio)&&(s=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=s,v.log("".concat(this.bufferCodecEventsExpected," bufferCodec event(s) expected"))}onMediaAttaching(t,e){const s=this.media=e.media;if(s&&ir){const t=this.mediaSource=new ir;t.addEventListener("sourceopen",this._onMediaSourceOpen),t.addEventListener("sourceended",this._onMediaSourceEnded),t.addEventListener("sourceclose",this._onMediaSourceClose),s.src=self.URL.createObjectURL(t),this._objectUrl=s.src,s.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:s}=this;if(e){if(v.log("[buffer-controller]: media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(Rn){v.warn("[buffer-controller]: onMediaDetaching: ".concat(Rn.message," while calling endOfStream"))}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),s&&self.URL.revokeObjectURL(s),t.src===s?(t.removeAttribute("src"),t.load()):v.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(u.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach((t=>{const e=this.sourceBuffer[t];try{e&&(this.removeBufferListeners(t),this.mediaSource&&this.mediaSource.removeSourceBuffer(e),this.sourceBuffer[t]=void 0)}catch(Rn){v.warn("[buffer-controller]: Failed to reset the ".concat(t," buffer"),Rn)}})),this._initSourceBuffer()}onBufferCodecs(t,e){const s=this.getSourceBufferTypes().length;Object.keys(e).forEach((t=>{if(s){const s=this.tracks[t];if(s&&"function"===typeof s.buffer.changeType){const{id:i,codec:r,levelCodec:n,container:a,metadata:o}=e[t],l=(s.levelCodec||s.codec).replace(rr,"$1"),c=(n||r).replace(rr,"$1");if(l!==c){const e="".concat(a,";
1codecs=").concat(n||r);this.appendChangeType(t,e),v.log("[buffer-controller]: switching codec ".concat(l," to ").concat(c)),this.tracks[t]={buffer:s.buffer,codec:r,container:a,levelCodec:n,metadata:o,id:i}}}}else this.pendingTracks[t]=e[t]})),s||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())}appendChangeType(t,e){const{operationQueue:s}=this,i={execute:()=>{const i=this.sourceBuffer[t];i&&(v.log("[buffer-controller]: changing ".concat(t," sourceBuffer type to ").concat(e)),i.changeType(e)),s.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:e=>{v.warn("[buffer-controller]: Failed to change ".concat(t," SourceBuffer type"),e)}};s.append(i,t)}onBufferAppending(t,e){const{hls:s,operationQueue:i,tracks:r}=this,{data:n,type:a,frag:o,part:l,chunkMeta:c}=e,h=c.buffering[a],d=self.performance.now();h.start=d;const m=o.stats.buffering,p=l?l.stats.buffering:null;0===m.start&&(m.start=d),p&&0===p.start&&(p.start=d);const y=r.audio;let T=!1;"audio"===a&&"audio/mpeg"===(null==y?void 0:y.container)&&(T=!this.lastMpegAudioChunk||1===c.id||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);const E=o.start,S={execute:()=>{if(h.executeStart=self.performance.now(),T){const t=this.sourceBuffer[a];if(t){const e=E-t.timestampOffset;Math.abs(e)>=.1&&(v.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to ".concat(E," (delta: ").concat(e,") sn: ").concat(o.sn,")")),t.timestampOffset=E)}}this.appendExecutor(n,a)},onStart:()=>{},onComplete:()=>{const t=self.performance.now();h.executeEnd=h.end=t,0===m.first&&(m.first=t),p&&0===p.first&&(p.first=t);const{sourceBuffer:e}=this,s={};for(const i in e)s[i]=ys.getBuffered(e[i]);this.appendError=0,this.hls.trigger(u.BUFFER_APPENDED,{type:a,frag:o,part:l,chunkMeta:c,parent:o.type,timeRanges:s})},onError:t=>{v.error("[buffer-controller]: Error encountered while trying to append to the ".concat(a," SourceBuffer"),t);const e={type:f.MEDIA_ERROR,parent:o.type,details:g.BUFFER_APPEND_ERROR,frag:o,part:l,chunkMeta:c,error:t,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=g.BUFFER_FULL_ERROR:(this.appendError++,e.details=g.BUFFER_APPEND_ERROR,this.appendError>s.config.appendErrorMaxRetry&&(v.error("[buffer-controller]: Failed ".concat(s.config.appendErrorMaxRetry," times to append segment in sourceBuffer")),e.fatal=!0)),s.trigger(u.ERROR,e)}};i.append(S,a)}onBufferFlushing(t,e){const{operationQueue:s}=this,i=t=>({execute:this.removeExecutor.bind(this,t,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(u.BUFFER_FLUSHED,{type:t})},onError:e=>{v.warn("[buffer-controller]: Failed to remove from ".concat(t," SourceBuffer"),e)}});e.type?s.append(i(e.type),e.type):this.getSourceBufferTypes().forEach((t=>{s.append(i(t),t)}))}onFragParsed(t,e){const{frag:s,part:i}=e,r=[],n=i?i.elementaryStreams:s.elementaryStreams;n[I]?r.push("audiovideo"):(n[k]&&r.push("audio"),n[D]&&r.push("video"));0===r.length&&v.warn("Fragments must have at least one ElementaryStreamType set. type: ".concat(s.type," level: ").concat(s.level," sn: ").concat(s.sn)),this.blockBuffers((()=>{const t=self.performance.now();s.stats.buffering.end=t,i&&(i.stats.buffering.end=t);const e=i?i.stats:s.stats;this.hls.trigger(u.FRAG_BUFFERED,{frag:s,part:i,stats:e,id:s.type})}),r)}onFragChanged(t,e){this.flushBackBuffer()}onBufferEos(t,e){this.getSourceBufferTypes().reduce(((t,s)=>{const i=this.sourceBuffer[s];return!i||e.type&&e.type!==s||(i.ending=!0,i.ended||(i.ended=!0,v.log("[buffer-controller]: ".concat(s," sourceBuffer now EOS")))),t&&!(i&&!i.ended)}),!0)&&(v.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers((()=>{this.getSourceBufferTypes().forEach((t=>{const e=this.sourceBuffer[t];e&&(e.ending=!1)}));const{mediaSource:t}=this;t&&"open"===t.readyState?(v.log("[buffer-controller]: Calling mediaSource.endOfStream()"),t.endOfStream()):t&&v.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ".concat(t.readyState))})))}onLevelUpdated(t,e){let{details:s}=e;
1s.fragments.length&&(this.details=s,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:t,details:e,media:s,sourceBuffer:i}=this;if(!s||null===e)return;const r=this.getSourceBufferTypes();if(!r.length)return;const n=e.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if(!d(n)||n<0)return;const a=s.currentTime,o=e.levelTargetDuration,l=Math.max(n,o),c=Math.floor(a/o)*o-l;r.forEach((s=>{const r=i[s];if(r){const i=ys.getBuffered(r);if(i.length>0&&c>i.start(0)){if(t.trigger(u.BACK_BUFFER_REACHED,{bufferEnd:c}),e.live)t.trigger(u.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(r.ended&&i.end(i.length-1)-a<2*o)return void v.info("[buffer-controller]: Cannot flush ".concat(s," back buffer while SourceBuffer is in ended state"));t.trigger(u.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:s})}}}))}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||"open"!==this.mediaSource.readyState)return;const{details:t,hls:e,media:s,mediaSource:i}=this,r=t.fragments[0].start+t.totalduration,n=s.duration,a=d(i.duration)?i.duration:0;t.live&&e.config.liveDurationInfinity?(v.log("[buffer-controller]: Media Source duration is set to Infinity"),i.duration=1/0,this.updateSeekableRange(t)):(r>a&&r>n||!d(n))&&(v.log("[buffer-controller]: Updating Media Source duration to ".concat(r.toFixed(3))),i.duration=r)}updateSeekableRange(t){const e=this.mediaSource,s=t.fragments;if(s.length&&t.live&&null!=e&&e.setLiveSeekableRange){const i=Math.max(0,s[0].start),r=Math.max(i,i+t.totalduration);e.setLiveSeekableRange(i,r)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:s}=this,i=Object.keys(s).length;if(i&&!t||2===i){this.createSourceBuffers(s),this.pendingTracks={};const t=this.getSourceBufferTypes();if(t.length)this.hls.trigger(u.BUFFER_CREATED,{tracks:this.tracks}),t.forEach((t=>{e.executeNext(t)}));else{const t=new Error("could not create source buffer for media codec(s)");this.hls.trigger(u.ERROR,{type:f.MEDIA_ERROR,details:g.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}}createSourceBuffers(t){const{sourceBuffer:e,mediaSource:s}=this;if(!s)throw Error("createSourceBuffers called when mediaSource was null");for(const i in t)if(!e[i]){const r=t[i];if(!r)throw Error("source buffer exists for track ".concat(i,", however track does not"));const n=r.levelCodec||r.codec,a="".concat(r.container,";codecs=").concat(n);v.log("[buffer-controller]: creating sourceBuffer(".concat(a,")"));try{const t=e[i]=s.addSourceBuffer(a),o=i;this.addBufferListener(o,"updatestart",this._onSBUpdateStart),this.addBufferListener(o,"updateend",this._onSBUpdateEnd),this.addBufferListener(o,"error",this._onSBUpdateError),this.tracks[i]={buffer:t,codec:n,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id}}catch(Rn){v.error("[buffer-controller]: error while trying to add sourceBuffer: ".concat(Rn.message)),this.hls.trigger(u.ERROR,{type:f.MEDIA_ERROR,details:g.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:Rn,mimeType:a})}}}_onSBUpdateStart(t){const{operationQueue:e}=this;e.current(t).onStart()}_onSBUpdateEnd(t){const{operationQueue:e}=this;e.current(t).onComplete(),e.shiftAndExecuteNext(t)}_onSBUpdateError(t,e){const s=new Error("".concat(t," SourceBuffer error"));v.error("[buffer-controller]: ".concat(s),e),this.hls.trigger(u.ERROR,{type:f.MEDIA_ERROR,details:g.BUFFER_APPENDING_ERROR,error:s,fatal:!1});const i=this.operationQueue.current(t);i&&i.onError(e)}removeExecutor(t,e,s){const{media:i,mediaSource:r,operationQueue:n,sourceBuffer:a}=this,o=a[t];if(!i||!r||!o)return v.warn("[buffer-controller]: Attempting to remove from the ".concat(t," SourceBuffer, but it does not exist")),void n.shiftAndExecuteNext(t);const l=d(i.duration)?i.duration:1/0,c=d(r.duration)?r.duration:1/0,h=Math.max(0,e),u=Math.min(s,l,c);u>h&&!o.ending?(o.ended=!1,v.log("[buffer-controller]: Removing [".concat(h,",").concat(u,"] from the ").concat(t," SourceBuffer")),o.remove(h,u)):n.shiftAndExecuteNext(t)}appendExecutor(t,e){const{operationQueue:s,sourceBuffer:i}=this,r=i[e];if(!r)return v.warn("[buffer-controller]: Attempting to append to the ".concat(e," SourceBuffer, but it does not exist")),void s.shiftAndExecuteNext(e);r.ended=!1,r.appendBuffer(t)}blockBuffers(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.getSourceBufferTypes();if(!e.length)return v.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(t);const{operationQueue:s}=this,i=e.map((t=>s.appendBlocker(t)));Promise.all(i).then((()=>{t(),e.forEach((t=>{const e=this.sourceBuffer[t];null!=e&&e.updating||s.shiftAndExecuteNext(t)}))}
1))}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,s){const i=this.sourceBuffer[t];if(!i)return;const r=s.bind(this,t);this.listeners[t].push({event:e,listener:r}),i.addEventListener(e,r)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach((t=>{e.removeEventListener(t.event,t.listener)}))}},capLevelController:Jr,errorController:class{constructor(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=v.log.bind(v,"[info]:"),this.warn=v.warn.bind(v,"[warning]:"),this.error=v.error.bind(v,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(u.ERROR,this.onError,this),t.on(u.MANIFEST_LOADING,this.onManifestLoading,this),t.on(u.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(u.ERROR,this.onError,this),t.off(u.ERROR,this.onErrorOut,this),t.off(u.MANIFEST_LOADING,this.onManifestLoading,this),t.off(u.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){this.playlistError=0}stopLoad(){}getVariantLevelIndex(t){return(null==t?void 0:t.type)===re?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var s,i;if(e.fatal)return;const r=this.hls,n=e.context;switch(e.details){case g.FRAG_LOAD_ERROR:case g.FRAG_LOAD_TIMEOUT:case g.KEY_LOAD_ERROR:case g.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case g.FRAG_PARSING_ERROR:if(null!=(s=e.frag)&&s.gap)return void(e.errorAction={action:Ye,flags:je});case g.FRAG_GAP:case g.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=We);case g.LEVEL_EMPTY_ERROR:case g.LEVEL_PARSING_ERROR:{var a,o;const t=e.parent===re?e.level:r.loadLevel;e.details===g.LEVEL_EMPTY_ERROR&&null!=(a=e.context)&&null!=(o=a.levelDetails)&&o.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,t):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t))}return;case g.LEVEL_LOAD_ERROR:case g.LEVEL_LOAD_TIMEOUT:return void("number"===typeof(null==n?void 0:n.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,n.level)));case g.AUDIO_TRACK_LOAD_ERROR:case g.AUDIO_TRACK_LOAD_TIMEOUT:case g.SUBTITLE_LOAD_ERROR:case g.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const t=r.levels[r.loadLevel];if(t&&(n.type===se&&n.groupId===t.audioGroupId||n.type===ie&&n.groupId===t.textGroupId))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,r.loadLevel),e.errorAction.action=We,void(e.errorAction.flags=Xe)}return;case g.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const t=r.levels[r.loadLevel],s=null==t?void 0:t.attrs["HDCP-LEVEL"];s&&(e.errorAction={action:We,flags:ze,hdcpLevel:s})}return;case g.BUFFER_ADD_CODEC_ERROR:case g.REMUX_ALLOC_ERROR:return void(e.errorAction=this.getLevelSwitchAction(e,null!=(i=e.level)?i:r.loadLevel));case g.INTERNAL_EXCEPTION:case g.BUFFER_APPENDING_ERROR:case g.BUFFER_APPEND_ERROR:case g.BUFFER_FULL_ERROR:case g.LEVEL_SWITCH_ERROR:case g.BUFFER_STALLED_ERROR:case g.BUFFER_SEEK_OVER_HOLE:case g.BUFFER_NUDGE_ON_STALL:return void(e.errorAction={action:Ye,flags:je})}if(e.type===f.KEY_SYSTEM_ERROR){const t=this.getVariantLevelIndex(e.frag);return e.levelRetry=!1,void(e.errorAction=this.getLevelSwitchAction(e,t))}}getPlaylistRetryOrSwitchAction(t,e){var s;const i=Oe(this.hls.config.playlistLoadPolicy,t),r=this.playlistError++,n=null==(s=t.response)?void 0:s.code;if(Be(i,r,Me(t),n))return{action:qe,flags:je,retryConfig:i,retryCount:r};const a=this.getLevelSwitchAction(t,e);return i&&(a.retryConfig=i,a.retryCount=r),a}getFragRetryOrSwitchAction(t){const e=this.hls,s=this.getVariantLevelIndex(t.frag),i=e.levels[s],{fragLoadPolicy:r,keyLoadPolicy:n}=e.config,a=Oe(t.details.startsWith("key")?n:r,t),o=e.levels.reduce(((t,e)=>t+e.fragmentError),0);if(i){var l;t.details!==g.FRAG_GAP&&i.fragmentError++;const e=null==(l=t.response)?void 0:l.code;if(Be(a,o,Me(t),e))return{action:qe,flags:je,retryConfig:a,retryCount:o}}const c=this.getLevelSwitchAction(t,s);return a&&(c.retryConfig=a,c.retryCount=o),c}getLevelSwitchAction(t,e){const s=this.hls;null!==e&&void 0!==e||(e=s.loadLevel);const i=this.hls.levels[e];if(i&&(i.loadError++,s.autoLevelEnabled)){var r,n;let e=-1;const{levels:a,loadLevel:o,minAutoLevel:l,maxAutoLevel:c}=s,h=null==(r=t.frag)?void 0:r.type,{type:d,groupId:u}=null!=(n=t.context)?n:{};for(let s=a.length;s--;){const r=(s+o)%a.length;if(r!==o&&r>=l&&r<=c&&0===a[r].loadError){const s=a[r];if(t.details===g.FRAG_GAP&&t.frag){const e=a[r].details;if(e){const s=Ke(t.frag,e.fragments,t.frag.start);if(null!=s&&s.gap)continue}}else{if(d===se&&u===s.audioGroupId||d===ie&&u===s.textGroupId)continue;if(h===ne&&i.audioGroupId===s.audioGroupId||h===ae&&i.textGroupId===s.textGroupId)continue}e=r;break}}if(e>-1&&s.loadLevel!==e)return t.levelRetry=!0,this.playlistError=0,{action:We,flags:je,nextAutoLevel:e}}return{action:We,flags:Xe}}onErrorOut(t,e){var s;switch(null==(s=e.errorAction)?void 0:s.action){case Ye:break;case We:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===g.FRAG_GAP||(e.fatal=!0)}e.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(t){const e=this.hls,s=t.errorAction;if(!s)return;const{flags:i,hdcpLevel:r,nextAutoLevel:n}=s;switch(i){case je:this.switchLevel(t,n);break;case Xe:s.resolved||(s.resolved=this.redundantFailover(t));break;case ze:r&&(e.maxHdcpLevel=Le[Le.indexOf(r)-1],s.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'.concat(e.maxHdcpLevel,'" or lower'))}s.resolved||this.switchLevel(t,n)}switchLevel(t,e){void 0!==e&&t.errorAction&&(this.warn("switching to level ".concat(e," after ").concat(t.details)),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(t){const{hls:e,penalizedRenditions:s}=this,i=t.parent===re?t.level:e.loadLevel,r=e.levels[i],n=r.url.length,a=t.frag?t.frag.urlId:r.urlId;r.urlId!==a||t.frag&&!r.details||this.penalizeRendition(r,t);for(let o=1;o<n;o++){const l=(a+o)%n,c=s[l];if(!c||Qe(c,t,s[a]))return this.warn("Switching to Redundant Stream ".concat(l+1,"/").concat(n,': "').concat(r.url[l],'" after ').concat(t.details)),this.playlistError=0,e.levels.forEac
1h((t=>{t.urlId=l})),e.nextLoadLevel=i,!0}return!1}penalizeRendition(t,e){const{penalizedRenditions:s}=this,i=s[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};i.lastErrorPerfMs=performance.now(),i.errors.push(e),i.details=t.details,s[t.urlId]=i}},fpsController:class{constructor(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on(u.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(u.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){const s=this.hls.config;if(s.capLevelOnFPSDrop){const t=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=t,t&&"function"===typeof t.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),s.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,s){const i=performance.now();if(e){if(this.lastTime){const t=i-this.lastTime,r=s-this.lastDroppedFrames,n=e-this.lastDecodedFrames,a=1e3*r/t,o=this.hls;if(o.trigger(u.FPS_DROP,{currentDropped:r,currentDecoded:n,totalDroppedFrames:s}),a>0&&r>o.config.fpsDroppedMonitoringThreshold*n){let t=o.currentLevel;v.warn("drop FPS ratio greater than max allowed value for currentLevel: "+t),t>0&&(-1===o.autoLevelCapping||o.autoLevelCapping>=t)&&(t-=1,o.trigger(u.FPS_DROP_LEVEL_CAPPING,{level:t,droppedLevel:o.currentLevel}),o.autoLevelCapping=t,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=s,this.lastDecodedFrames=e}}checkFPSInterval(){const t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){const e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:W,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:vn,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends Ks{constructor(t,e,s){super(t,e,s,"[subtitle-stream-controller]",ae),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){const{hls:t}=this;
1t.on(u.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(u.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(u.MANIFEST_LOADING,this.onManifestLoading,this),t.on(u.LEVEL_LOADED,this.onLevelLoaded,this),t.on(u.ERROR,this.onError,this),t.on(u.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(u.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(u.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(u.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(u.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(u.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(u.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(u.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(u.MANIFEST_LOADING,this.onManifestLoading,this),t.off(u.LEVEL_LOADED,this.onLevelLoaded,this),t.off(u.ERROR,this.onError,this),t.off(u.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(u.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(u.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(u.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(u.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(u.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=Cs,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(t,e){this.mainDetails=e.details}onSubtitleFragProcessed(t,e){const{frag:s,success:i}=e;if(this.fragPrevious=s,this.state=Cs,!i)return;const r=this.tracksBuffered[this.currentTrackId];if(!r)return;let n;const a=s.start;for(let l=0;l<r.length;l++)if(a>=r[l].start&&a<=r[l].end){n=r[l];break}const o=s.start+s.duration;n?n.end=o:(n={start:a,end:o},r.push(n)),this.fragmentTracker.fragBuffered(s)}onBufferFlushing(t,e){const{startOffset:s,endOffset:i}=e;if(0===s&&i!==Number.POSITIVE_INFINITY){const t=i-1;if(t<=0)return;e.endOffsetSubtitles=Math.max(0,t),this.tracksBuffered.forEach((e=>{for(let s=0;s<e.length;)if(e[s].end<=t)e.shift();else{if(!(e[s].start<t))break;e[s].start=t,s++}})),this.fragmentTracker.removeFragmentsInRange(s,t,ae)}}onFragBuffered(t,e){var s;this.loadedmetadata||e.frag.type!==re||null!=(s=this.media)&&s.buffered.length&&(this.loadedmetadata=!0)}onError(t,e){const s=e.frag;(null==s?void 0:s.type)===ae&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==ws&&(this.state=Cs))}onSubtitleTracksUpdated(t,e){let{subtitleTracks:s}=e;Ji(this.levels,s)?this.levels=s.map((t=>new De(t))):(this.tracksBuffered=[],this.levels=s.map((t=>{const e=new De(t);return this.tracksBuffered[e.id]=[],e})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,ae),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(t,e){if(this.currentTrackId=e.id,!this.levels.length||-1===this.currentTrackId)return void this.clearInterval();const s=this.levels[this.currentTrackId];null!=s&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.setInterval(500)}onSubtitleTrackLoaded(t,e){var s;const{details:i,id:r}=e,{currentTrackId:n,levels:a}=this;if(!a.length)return;const o=a[n];if(r>=a.length||r!==n||!o)return;this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(i.live||null!=(s=o.details)&&s.live){const t=this.mainDetails;if(i.deltaUpdateFailed||!t)return;const e=t.fragments[0];o.details?(l=this.alignPlaylists(i,o.details),0===l&&e&&(l=e.start,Pe(i,l))):i.hasProgramDateTime&&t.hasProgramDateTime?(As(i,t),l=i.fragments[0].start):e&&(l=e.start,Pe(i,l))}if(o.details=i,this.levelLastLoaded=r,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(o.details,l),this.tick(),i.live&&!this.fragCurrent&&this.media&&this.state===Cs){Ke(null,i.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)}}_handleFragmentLoadComplete(t){const{frag:e,payload:s}=t,i=e.decryptdata,r=this.hls;if(!this.fragContextChanged(e)&&s&&s.byteLength>0&&i&&i.key&&i.iv&&"AES-128"===i.method){const t=performance.now();
vendor: 2,373 bytes, line 1
1this.decrypter.decrypt(new Uint8Array(s),i.key.buffer,i.iv.buffer).catch((t=>{throw r.trigger(u.ERROR,{type:f.MEDIA_ERROR,details:g.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((s=>{const i=performance.now();r.trigger(u.FRAG_DECRYPTED,{frag:e,payload:s,stats:{tstart:t,tdecrypt:i}})})).catch((t=>{this.warn("".concat(t.name,": ").concat(t.message)),this.state=Cs}))}}doTick(){if(this.media){if(this.state===Cs){const{currentTrackId:t,levels:e}=this,s=e[t];if(!e.length||!s||!s.details)return;const{config:i}=this,r=this.getLoadPosition(),n=ys.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,i.maxBufferHole),{end:a,len:o}=n,l=this.getFwdBufferInfo(this.media,re),c=s.details;if(o>this.getMaxBufferLength(null==l?void 0:l.len)+c.levelTargetDuration)return;const h=c.fragments,d=h.length,u=c.edge;let f=null;const g=this.fragPrevious;if(a<u){const t=i.maxFragLookUpTolerance,e=a>u-t?0:t;f=Ke(g,h,Math.max(h[0].start,a),e),!f&&g&&g.start<h[0].start&&(f=h[0])}else f=h[d-1];if(!f)return;if(f=this.mapToInitFragWhenRequired(f),"initSegment"!==f.sn){const t=h[f.sn-c.startSN-1];t&&t.cc===f.cc&&this.fragmentTracker.getState(t)===ss&&(f=t)}this.fragmentTracker.getState(f)===ss&&this.loadFragment(f,s,a)}}else this.state=Cs}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.max(e,t):e}loadFragment(t,e,s){this.fragCurrent=t,"initSegment"===t.sn?this._loadInitSegment(t,e):(this.startFragRequested=!0,super.loadFragment(t,e,s))}get mediaBufferTimeRanges(){return new tr(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends $e{constructor(t){super(t,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){const{hls:t}=this;
vendor: 1,598 bytes, line 1
1t.on(u.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(u.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(u.MANIFEST_LOADING,this.onManifestLoading,this),t.on(u.MANIFEST_PARSED,this.onManifestParsed,this),t.on(u.LEVEL_LOADING,this.onLevelLoading,this),t.on(u.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(u.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(u.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(u.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(u.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(u.MANIFEST_LOADING,this.onManifestLoading,this),t.off(u.MANIFEST_PARSED,this.onManifestParsed,this),t.off(u.LEVEL_LOADING,this.onLevelLoading,this),t.off(u.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(u.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(u.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);
1er(this.media.textTracks).forEach((t=>{ue(t)})),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.subtitleTracks}onSubtitleTrackLoaded(t,e){const{id:s,details:i}=e,{trackId:r}=this,n=this.tracksInGroup[r];if(!n)return void this.warn("Invalid subtitle track id ".concat(s));const a=n.details;n.details=e.details,this.log("subtitle track ".concat(s," loaded [").concat(i.startSN,"-").concat(i.endSN,"]")),s===this.trackId&&this.playlistLoaded(s,e,a)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(null==e||!e.textGroupIds)return;const s=e.textGroupIds[e.urlId],i=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==s){const t=this.tracks.filter((t=>!s||t.groupId===s));this.tracksInGroup=t;const e=this.findTrackId(null==i?void 0:i.name)||this.findTrackId();this.groupId=s||null;const r={subtitleTracks:t};this.log("Updating subtitle tracks, ".concat(t.length,' track(s) found in "').concat(s,'" group-id')),this.hls.trigger(u.SUBTITLE_TRACKS_UPDATED,r),-1!==e&&this.setSubtitleTrack(e,i)}else this.shouldReloadPlaylist(i)&&this.setSubtitleTrack(this.trackId,i)}findTrackId(t){const e=this.tracksInGroup;for(let s=0;s<e.length;s++){const i=e[s];if((!this.selectDefaultTrack||i.default)&&(!t||t===i.name))return i.id}return-1}onError(t,e){!e.fatal&&e.context&&e.context.type===ie&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.checkRetry(e)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(t){this.selectDefaultTrack=!1;const e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,e)}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const i=e.id,r=e.groupId;let n=e.url;if(t)try{n=t.addDirectives(n)}catch(s){this.warn("Could not construct new URL with HLS Delivery Directives: ".concat(s))}this.log("Loading subtitle playlist for id ".concat(i)),this.hls.trigger(u.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:t||null})}}toggleTrackModes(t){const{media:e,trackId:s}=this;if(!e)return;const i=er(e.textTracks),r=i.filter((t=>t.groupId===this.groupId));if(-1===t)[].slice.call(i).forEach((t=>{t.mode="disabled"}));else{const t=r[s];t&&(t.mode="disabled")}const n=r[t];n&&(n.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(t,e){var s;const i=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=t);if(this.trackId!==t&&this.toggleTrackModes(t),this.trackId===t&&(-1===t||null!=(s=i[t])&&s.details)||t<-1||t>=i.length)return;this.clearTimer();const r=i[t];if(this.log("Switching to subtitle-track ".concat(t)+(r?' "'.concat(r.name,'" lang:').concat(r.lang," group:").concat(r.groupId):"")),this.trackId=t,r){const{id:t,groupId:s="",name:i,type:n,url:a}=r;this.hls.trigger(u.SUBTITLE_TRACK_SWITCH,{id:t,groupId:s,name:i,type:n,url:a});const o=this.switchParams(r.url,null==e?void 0:e.details);this.loadPlaylist(o)}else this.hls.trigger(u.SUBTITLE_TRACK_SWITCH,{id:t})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=-1;const e=er(this.media.textTracks);for(let s=0;s<e.length;s++)if("hidden"===e[s].mode)t=s;else if("showing"===e[s].mode){t=s;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}},timelineController:class{constructor(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){const t=new Rr(this,"textTrack1"),e=new Rr(this,"textTrack2"),s=new Rr(this,"textTrack3"),i=new Rr(this,"textTrack4");this.cea608Parser1=new Sr(1,t,e),this.cea608Parser2=new Sr(3,s,i)}
1t.on(u.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(u.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(u.MANIFEST_LOADING,this.onManifestLoading,this),t.on(u.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(u.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(u.FRAG_LOADING,this.onFragLoading,this),t.on(u.FRAG_LOADED,this.onFragLoaded,this),t.on(u.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(u.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(u.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(u.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(u.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(u.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(u.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(u.MANIFEST_LOADING,this.onManifestLoading,this),t.off(u.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(u.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(u.FRAG_LOADING,this.onFragLoading,this),t.off(u.FRAG_LOADED,this.onFragLoaded,this),t.off(u.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(u.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(u.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(u.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(u.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(t,e,s,i,r){let n=!1;for(let h=r.length;h--;){const t=r[h],i=(a=t[0],o=t[1],l=e,c=s,Math.min(o,c)-Math.max(a,l));if(i>=0&&(t[0]=Math.min(t[0],e),t[1]=Math.max(t[1],s),n=!0,i/(s-e)>.5))return}var a,o,l,c;if(n||r.push([e,s]),this.config.renderTextTracksNatively){const r=this.captionsTracks[t];this.Cues.newCue(r,e,s,i)}else{const r=this.Cues.newCue(null,e,s,i);this.hls.trigger(u.CUES_PARSED,{type:"captions",cues:r,track:t})}}onInitPtsFound(t,e){let{frag:s,id:i,initPTS:r,timescale:n}=e;const{unparsedVttFrags:a}=this;"main"===i&&(this.initPTS[s.cc]={baseTime:r,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach((t=>{this.onFragLoaded(u.FRAG_LOADED,t)})))}getExistingTrack(t){const{media:e}=this;if(e)for(let s=0;s<e.textTracks.length;s++){const i=e.textTracks[s];if(i[t])return i}return null}createCaptionsTrack(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)}createNativeTrack(t){if(this.captionsTracks[t])return;const{captionsProperties:e,captionsTracks:s,media:i}=this,{label:r,languageCode:n}=e[t],a=this.getExistingTrack(t);if(a)s[t]=a,ue(s[t]),he(s[t],i);else{const e=this.createTextTrack("captions",r,n);e&&(e[t]=!0,s[t]=e)}}createNonNativeTrack(t){if(this.nonNativeCaptionsTracks[t])return;const e=this.captionsProperties[t];if(!e)return;const s={_id:t,label:e.label,kind:"captions",default:!!e.media&&!!e.media.default,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=s,this.hls.trigger(u.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(t,e,s){const i=this.media;if(i)return i.addTextTrack(t,e,s)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:t}=this;Object.keys(t).forEach((e=>{ue(t[e]),delete t[e]})),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:t}=this;if(!t)return;const e=t.textTracks;if(e)for(let s=0;s<e.length;s++)ue(e[s])}onSubtitleTracksUpdated(t,e){const s=e.subtitleTracks||[],i=s.some((t=>t.textCodec===Gr));if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(Ji(this.tracks,s))return void(this.tracks=s);if(this.textTracks=[],this.tracks=s,this.config.renderTextTracksNatively){const t=this.media?this.media.textTracks:null;this.tracks.forEach(((e,s)=>{let i;if(t&&s<t.length){let s=null;for(let i=0;i<t.length;i++)if($r(t[i],e)){s=t[i];break}s&&(i=s)}if(i)ue(i);else{const t=this._captionsOrSubtitlesFromCharacteristics(e);i=this.createTextTrack(t,e.name,e.lang),i&&(i.mode="disabled")}i&&(i.groupId=e.groupId,this.textTracks.push(i))}))}else if(this.tracks.length){const t=this.tracks.map((t=>
1({label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t})));this.hls.trigger(u.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:t})}}}_captionsOrSubtitlesFromCharacteristics(t){if(t.attrs.CHARACTERISTICS){const e=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),s=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(e&&s)return"captions"}return"subtitles"}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach((t=>{const e=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(!e)return;const s="textTrack".concat(e[1]),i=this.captionsProperties[s];i&&(i.label=t.name,t.lang&&(i.languageCode=t.lang),i.media=t)}))}closedCaptionsForLevel(t){const e=this.hls.levels[t.level];return null==e?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){const{cea608Parser1:s,cea608Parser2:i,lastSn:r,lastPartIndex:n}=this;if(this.enabled&&s&&i&&e.frag.type===re){var a,o;const t=e.frag.sn,l=null!=(a=null==e||null==(o=e.part)?void 0:o.index)?a:-1;t===r+1||t===r&&l===n+1||(s.reset(),i.reset()),this.lastSn=t,this.lastPartIndex=l}}onFragLoaded(t,e){const{frag:s,payload:i}=e;if(s.type===ae)if(i.byteLength){const t=s.decryptdata,r="stats"in e;if(null==t||!t.encrypted||r){const t=this.tracks[s.level],r=this.vttCCs;r[s.cc]||(r[s.cc]={start:s.start,prevCC:this.prevCC,new:!0},this.prevCC=s.cc),t&&t.textCodec===Gr?this._parseIMSC1(s,i):this._parseVTTs(e)}}else this.hls.trigger(u.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const s=this.hls;Yr(e,this.initPTS[t.cc],(e=>{this._appendCues(e,t.level),s.trigger(u.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(e=>{v.log("Failed to parse IMSC1: ".concat(e)),s.trigger(u.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})}))}_parseVTTs(t){var e;const{frag:s,payload:i}=t,{initPTS:r,unparsedVttFrags:n}=this,a=r.length-1;if(!r[s.cc]&&-1===a)return void n.push(t);const o=this.hls;Br(null!=(e=s.initSegment)&&e.data?At(s.initSegment.data,new Uint8Array(i)):i,this.initPTS[s.cc],this.vttCCs,s.cc,s.start,(t=>{this._appendCues(t,s.level),o.trigger(u.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:s})}),(e=>{const r="Missing initPTS for VTT MPEGTS"===e.message;r?n.push(t):this._fallbackToIMSC1(s,i),v.log("Failed to parse VTT cue: ".concat(e)),r&&a>s.cc||o.trigger(u.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:e})}))}_fallbackToIMSC1(t,e){const s=this.tracks[t.level];s.textCodec||Yr(e,this.initPTS[t.cc],(()=>{s.textCodec=Gr,this._parseIMSC1(t,e)}),(()=>{s.textCodec="wvtt"}))}_appendCues(t,e){const s=this.hls;if(this.config.renderTextTracksNatively){const s=this.textTracks[e];if(!s||"disabled"===s.mode)return;t.forEach((t=>de(s,t)))}else{const i=this.tracks[e];if(!i)return;const r=i.default?"default":"subtitles"+e;s.trigger(u.CUES_PARSED,{type:"subtitles",cues:t,track:r})}}onFragDecrypted(t,e){const{frag:s}=e;s.type===ae&&this.onFragLoaded(u.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){const{cea608Parser1:s,cea608Parser2:i}=this;if(!this.enabled||!s||!i)return;const{frag:r,samples:n}=e;if(r.type!==re||"NONE"!==this.closedCaptionsForLevel(r))for(let a=0;a<n.length;a++){const t=n[a].bytes;if(t){const e=this.extractCea608Data(t);s.addData(n[a].pts,e[0]),i.addData(n[a].pts,e[1])}}}onBufferFlushing(t,e){let{startOffset:s,endOffset:i,endOffsetSubtitles:r,type:n}=e;const{media:a}=this;if(a&&!(a.currentTime<i)){if(!n||"video"===n){const{captionsTracks:t}=this;Object.keys(t).forEach((e=>fe(t[e],s,i)))}if(this.config.renderTextTracksNatively&&0===s&&void 0!==r){const{textTracks:t}=this;Object.keys(t).forEach((e=>fe(t[e],s,r)))}}}extractCea608Data(t){const e=[[],[]],s=31&t[0];let i=2;for(let r=0;r<s;r++){const s=t[i++],r=127&t[i++],n=127&t[i++];if(0===r&&0===n)continue;if(0!==(4&s)){const t=3&s;0!==t&&1!==t||(e[t].push(r),e[t].push(n))}}return e}},audioStreamController:class extends Ks{constructor(t,e,s){super(t,e,s,"[audio-stream-controller]",ne),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:t}=this;
1t.on(u.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(u.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(u.MANIFEST_LOADING,this.onManifestLoading,this),t.on(u.LEVEL_LOADED,this.onLevelLoaded,this),t.on(u.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(u.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(u.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(u.ERROR,this.onError,this),t.on(u.BUFFER_RESET,this.onBufferReset,this),t.on(u.BUFFER_CREATED,this.onBufferCreated,this),t.on(u.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(u.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(u.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(u.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(u.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(u.MANIFEST_LOADING,this.onManifestLoading,this),t.off(u.LEVEL_LOADED,this.onLevelLoaded,this),t.off(u.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(u.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(u.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(u.ERROR,this.onError,this),t.off(u.BUFFER_RESET,this.onBufferReset,this),t.off(u.BUFFER_CREATED,this.onBufferCreated,this),t.off(u.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(u.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(u.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(t,e){let{frag:s,id:i,initPTS:r,timescale:n}=e;if("main"===i){const t=s.cc;this.initPTS[s.cc]={baseTime:r,timescale:n},this.log("InitPTS for cc: ".concat(t," found from main: ").concat(r)),this.videoTrackCC=t,this.state===Bs&&this.tick()}}startLoad(t){if(!this.levels)return this.startPosition=t,void(this.state=ws);const e=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),e>0&&-1===t?(this.log("Override startPosition with lastCurrentTime @".concat(e.toFixed(3))),t=e,this.state=Cs):(this.loadedmetadata=!1,this.state=Fs),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case Cs:this.doTickIdle();break;case Fs:{var t;const{levels:e,trackId:s}=this,i=null==e||null==(t=e[s])?void 0:t.details;if(i){if(this.waitForCdnTuneIn(i))break;this.state=Bs}break}case xs:{var e;const t=performance.now(),s=this.retryDate;(!s||t>=s||null!=(e=this.media)&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Cs);break}case Bs:{const t=this.waitingData;if(t){const{frag:e,part:s,cache:i,complete:r}=t;if(void 0!==this.initPTS[e.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=Ps;const t={frag:e,part:s,payload:i.flush(),networkDetails:null};this._handleFragmentLoadProgress(t),r&&super._handleFragmentLoadComplete(t)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc (".concat(e.cc,") cancelled because video is at cc ").concat(this.videoTrackCC)),this.clearWaitingFragment();else{const t=this.getLoadPosition(),s=ys.bufferInfo(this.mediaBuffer,t,this.config.maxBufferHole);He(s.end,this.config.maxFragLookUpTolerance,e)<0&&(this.log("Waiting fragment cc (".concat(e.cc,") @ ").concat(e.start," cancelled because another fragment at ").concat(s.end," is needed")),this.clearWaitingFragment())}}else this.state=Cs}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Cs)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:t}=this;null!=t&&t.readyState&&(this.lastCurrentTime=t.currentTime)}doTickIdle(){const{hls:t,levels:e,media:s,trackId:i}=this,r=t.config;if(null==e||!e[i])return;if(!s&&(this.startFragRequested||!r.startFragPrefetch))return;const n=e[i],a=n.details;if(!a||a.live&&this.levelLastLoaded!==i||this.waitForCdnTuneIn(a))return void(this.state=Fs);const o=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,k,ne));const l=this.getFwdBufferInfo(o,ne);if(null===l)return;const{bufferedTrack:c,switchingTrack:h}=this;if(!h&&this._streamEnded(l,a))return t.trigger(u.BUFFER_EOS,{type:"audio"}),void(this.state=Ns);const d=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,re),f=l.len,g=this.getMaxBufferLength(null==d?void 0:d.len);if(f>=g&&!h)return;const m=a.fragments[0].start;let p=l.end;if(h&&s){const t=this.getLoadPosition();c&&h.attrs!==c.attrs&&(p=t),a.PTSKnown&&t<m&&(l.end>m||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=m+.05)}let y=this.getNextFragment(p,a),T=!1;if(y&&this.isLoopLoading(y,p)&&(T=!!y.gap,y=this.getNextFragmentLoopLoading(y,a,l,re,g)),!y)return void(this.bufferFlushed=!0);const v=d&&y.start>d.end+a.targetduration;if(v||(null==d||!d.len)&&l.len){const t=this.getAppendedFrag(y.start,re);if(null===t)return;if(T||(T=!!t.gap||!!v&&0===d.len),v&&!T||T&&l.nextStart&&l.nextStart<t.end)return}this.loadFragment(y,n,p)}getMaxBufferLength(t){const e=super.getMaxBufferLength();
1return t?Math.min(Math.max(e,t),this.config.maxMaxBufferLength):e}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(t,e){let{audioTracks:s}=e;this.resetTransmuxer(),this.levels=s.map((t=>new De(t)))}onAudioTrackSwitching(t,e){const s=!!e.url;this.trackId=e.id;const{fragCurrent:i}=this;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),s?this.setInterval(100):this.resetTransmuxer(),s?(this.switchingTrack=e,this.state=Cs):(this.switchingTrack=null,this.bufferedTrack=e,this.state=ws),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(t,e){this.mainDetails=e.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(u.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(t,e){var s;if(null==this.mainDetails)return void(this.cachedTrackLoadedData=e);const{levels:i}=this,{details:r,id:n}=e;if(!i)return void this.warn("Audio tracks were reset while loading level ".concat(n));this.log("Track ".concat(n," loaded [").concat(r.startSN,",").concat(r.endSN,"]").concat(r.lastPartSn?"[part-".concat(r.lastPartSn,"-").concat(r.lastPartIndex,"]"):"",",duration:").concat(r.totalduration));const a=i[n];let o=0;if(r.live||null!=(s=a.details)&&s.live){this.checkLiveUpdate(r);const t=this.mainDetails;if(r.deltaUpdateFailed||!t)return;!a.details&&r.hasProgramDateTime&&t.hasProgramDateTime?(As(r,t),o=r.fragments[0].start):o=this.alignPlaylists(r,a.details)}a.details=r,this.levelLastLoaded=n,this.startFragRequested||!this.mainDetails&&r.live||this.setStartPosition(a.details,o),this.state!==Fs||this.waitForCdnTuneIn(r)||(this.state=Cs),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:s,part:i,payload:r}=t,{config:n,trackId:a,levels:o}=this;if(!o)return void this.warn("Audio tracks were reset while fragment load was in progress. Fragment ".concat(s.sn," of level ").concat(s.level," will not be buffered"));const l=o[a];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const c=l.details;if(!c)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(s.start);const h=n.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let d=this.transmuxer;d||(d=this.transmuxer=new qi(this.hls,ne,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const u=this.initPTS[s.cc],f=null==(e=s.initSegment)?void 0:e.data;if(void 0!==u){const t=!1,e=i?i.index:-1,n=-1!==e,a=new Ts(s.level,s.sn,s.stats.chunkCount,r.byteLength,e,n);d.push(r,f,h,"",s,i,c.totalduration,t,a,u)}else{this.log("Unknown video PTS for cc ".concat(s.cc,", waiting for video PTS before demuxing audio frag ").concat(s.sn," of [").concat(c.startSN," ,").concat(c.endSN,"],track ").concat(a));const{cache:t}=this.waitingData=this.waitingData||{frag:s,part:i,cache:new $i,complete:!1};t.push(new Uint8Array(r)),this.waitingVideoCC=this.videoTrackCC,this.state=Bs}}_handleFragmentLoadComplete(t){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(t,e){const s=e.tracks.audio;s&&(this.mediaBuffer=s.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)}onFragBuffered(t,e){const{frag:s,part:i}=e;if(s.type===ne)if(this.fragContextChanged(s))this.warn("Fragment ".concat(s.sn).concat(i?" p: "+i.index:""," of level ").concat(s.level," finished buffering, but was aborted. state: ").concat(this.state,", audioSwitch: ").concat(this.switchingTrack?this.switchingTrack.name:"false"));else{if("initSegment"!==s.sn){this.fragPrevious=s;const t=this.switchingTrack;t&&(this.bufferedTrack=t,this.switchingTrack=null,this.hls.trigger(u.AUDIO_TRACK_SWITCHED,l({},t)))}this.fragBufferedComplete(s,i)}else if(!this.loadedmetadata&&s.type===re){const t=this.videoBuffer||this.media;if(t){ys.getBuffered(t).length&&(this.loadedmetadata=!0)}}}onError(t,e){var s;if(e.fatal)this.state=Us;else switch(e.details){case g.FRAG_GAP:case g.FRAG_PARSING_ERROR:case g.FRAG_DECRYPT_ERROR:case g.FRAG_LOAD_ERROR:case g.FRAG_LOAD_TIMEOUT:case g.KEY_LOAD_ERROR:case g.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ne,e);break;case g.AUDIO_TRACK_LOAD_ERROR:case g.AUDIO_TRACK_LOAD_TIMEOUT:case g.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==Fs||(null==(s=e.context)?void 0:s.type)!==se||(this.state=Cs);break;case g.BUFFER_FULL_ERROR:if(!e.parent||"audio"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case g.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}onBufferFlushed(t,e){let{type:s}=e;s===k&&(this.bufferFlushed=!0,this.state===Ns&&(this.state=Cs))}_handleTransmuxComplete(t){var e;const s="audio",{hls:i}=this,{remuxResult:r,chunkMeta:n}=t,a=this.getCurrentContext(n);if(!a)return void this.resetWhenMissingContext(n);const{frag:o,part:l,level:c}=a,{details:d}=c,{audio:f,text:g,id3:m,initSegment:p}=r;if(!this.fragContextChanged(o)&&d){if(this.state=Ms,this.switchingTrack&&f&&this.completeAudioSwitch(this.switchingTrack),null!=p&&p.tracks){const t=o.initSegment||o;this._bufferInitSegment(p.tracks,t,n),i.trigger(u.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:s,tracks:p.tracks})}if(f){const{startPTS:t,endPTS:e,startDTS:s,endDTS:i}=f;l&&(l.elementaryStreams[k]={startPTS:t,endPTS:e,startDTS:s,endDTS:i}
1),o.setElementaryStreamInfo(k,t,e,s,i),this.bufferFragmentData(f,o,l,n)}if(null!=m&&null!=(e=m.samples)&&e.length){const t=h({id:s,frag:o,details:d},m);i.trigger(u.FRAG_PARSING_METADATA,t)}if(g){const t=h({id:s,frag:o,details:d},g);i.trigger(u.FRAG_PARSING_USERDATA,t)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(t,e,s){if(this.state!==Ms)return;t.video&&delete t.video;const i=t.audio;if(!i)return;i.levelCodec=i.codec,i.id="audio",this.log("Init audio buffer, container:".concat(i.container,", codecs[parsed]=[").concat(i.codec,"]")),this.hls.trigger(u.BUFFER_CODECS,t);const r=i.initSegment;if(null!=r&&r.byteLength){const t={type:"audio",frag:e,part:null,chunkMeta:s,parent:e.type,data:r};this.hls.trigger(u.BUFFER_APPENDING,t)}this.tick()}loadFragment(t,e,s){const i=this.fragmentTracker.getState(t);var r;(this.fragCurrent=t,this.switchingTrack||i===ss||i===rs)?"initSegment"===t.sn?this._loadInitSegment(t,e):null!=(r=e.details)&&r.live&&!this.initPTS[t.cc]?(this.log("Waiting for video PTS in continuity counter ".concat(t.cc," of live stream before loading audio fragment ").concat(t.sn," of level ").concat(this.trackId)),this.state=Bs):(this.startFragRequested=!0,super.loadFragment(t,e,s)):this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){const{hls:e,media:s,bufferedTrack:i}=this,r=null==i?void 0:i.attrs,n=t.attrs;s&&r&&(r.CHANNELS!==n.CHANNELS||r.NAME!==n.NAME||r.LANGUAGE!==n.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,e.trigger(u.AUDIO_TRACK_SWITCHED,l({},t))}},audioTrackController:class extends $e{constructor(t){super(t,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(u.MANIFEST_LOADING,this.onManifestLoading,this),t.on(u.MANIFEST_PARSED,this.onManifestParsed,this),t.on(u.LEVEL_LOADING,this.onLevelLoading,this),t.on(u.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(u.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(u.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(u.MANIFEST_LOADING,this.onManifestLoading,this),t.off(u.MANIFEST_PARSED,this.onManifestParsed,this),t.off(u.LEVEL_LOADING,this.onLevelLoading,this),t.off(u.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(u.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(u.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.audioTracks||[]}onAudioTrackLoaded(t,e){const{id:s,groupId:i,details:r}=e,n=this.tracksInGroup[s];if(!n||n.groupId!==i)return void this.warn("Track with id:".concat(s," and group:").concat(i," not found in active group ").concat(n.groupId));const a=n.details;n.details=e.details,this.log("audio-track ".concat(s,' "').concat(n.name,'" lang:').concat(n.lang," group:").concat(i," loaded [").concat(r.startSN,"-").concat(r.endSN,"]")),s===this.trackId&&this.playlistLoaded(s,e,a)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(null==e||!e.audioGroupIds)return;const s=e.audioGroupIds[e.urlId];if(this.groupId!==s){this.groupId=s||null;const t=this.tracks.filter((t=>!s||t.groupId===s));this.selectDefaultTrack&&!t.some((t=>t.default))&&(this.selectDefaultTrack=!1),this.tracksInGroup=t;const e={audioTracks:t};this.log("Updating audio tracks, ".concat(t.length," track(s) found in group:").concat(s)),this.hls.trigger(u.AUDIO_TRACKS_UPDATED,e),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(t,e){!e.fatal&&e.context&&e.context.type===se&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(e))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioTrack(t){const e=this.tracksInGroup;if(t<0||t>=e.length)return void this.warn("Invalid id passed to audio-track controller");this.clearTimer();const s=this.currentTrack;e[this.trackId];const i=e[t],{groupId:r,name:n}=i;if(this.log("Switching to audio-track ".concat(t,' "').concat(n,'" lang:').concat(i.lang," group:").concat(r)),this.trackId=t,this.currentTrack=i,this.selectDefaultTrack=!1,this.hls.trigger(u.AUDIO_TRACK_SWITCHING,l({},i)),i.details&&!i.details.live)return;const a=this.switchParams(i.url,null==s?void 0:s.details);this.loadPlaylist(a)}selectInitialTrack(){const t=this.tracksInGroup,e=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(-1!==e)this.setAudioTrack(e);else{const e=new Error("No track found for running audio group-ID: ".concat(this.groupId," track count: ").concat(t.length));this.warn(e.message),this.hls.trigger(u.ERROR,{type:f.MEDIA_ERROR,details:g.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:e})}}findTrackId(t){const e=this.tracksInGroup;for(let s=0;s<e.length;s++){const i=e[s];if(!this.selectDefaultTrack||i.default){if(!t||void 0!==t.attrs["STABLE-RENDITION-ID"]&&t.attrs["STABLE-RENDITION-ID"]===i.attrs["STABLE-RENDITION-ID"])return i.id;if(t.name===i.name&&t.lang===i.lang)return i.id}}return-1}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const i=e.id,r=e.groupId;let n=e.url;if(t)try{n=t.addDirectives(n)}catch(s){this.warn("Could not construct new URL with HLS Delivery Directives: ".concat(s))}this.log("loading audio-track playlist ".concat(i,' "').concat(e.name,'" lang:').concat(e.lang," group:").concat(r)),this.clearTimer(),this.hls.trigger(u.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:t||null})}}},emeController:tn,cmcdController:cn,contentSteeringController:class{constructor(t){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=t,this.log=v.log.bind(v,"[content-steering]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(u.MANIFEST_LOADING,this.onManifestLoading,this),t.on(u.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(u.MANIFEST_PARSED,this.onManifestParsed,this),t.on(u.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(u.MANIFEST_LOADING,this.onManifestLoading,this),t.off(u.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(u.MANIFEST_PARSED,this.onManifestParsed,this),t.off(u.ERROR,this.onError,this))}
1startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){const t=Math.max(1e3*this.timeToLoad-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,t)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(t){const e=this.levels;e&&(this.levels=e.filter((e=>e!==t)))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(t,e){const{contentSteering:s}=e;null!==s&&(this.pathwayId=s.pathwayId,this.uri=s.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:s}=e;if((null==s?void 0:s.action)===We&&s.flags===Xe){let t=this.pathwayPriority;const e=this.pathwayId;this.penalizedPathways[e]||(this.penalizedPathways[e]=performance.now()),!t&&this.levels&&(t=this.levels.reduce(((t,e)=>(-1===t.indexOf(e.pathwayId)&&t.push(e.pathwayId),t)),[])),t&&t.length>1&&(this.updatePathwayPriority(t),s.resolved=this.pathwayId!==e)}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);if(0===e.length){const s=t[0].pathwayId;this.log("No levels found in Pathway ".concat(this.pathwayId,'. Setting initial Pathway to "').concat(s,'"')),e=this.getLevelsForPathway(s),this.pathwayId=s}return e.length!==t.length?(this.log("Found ".concat(e.length,"/").concat(t.length,' levels in Pathway "').concat(this.pathwayId,'"')),e):t}getLevelsForPathway(t){return null===this.levels?[]:this.levels.filter((e=>t===e.pathwayId))}updatePathwayPriority(t){let e;this.pathwayPriority=t;const s=this.penalizedPathways,i=performance.now();Object.keys(s).forEach((t=>{i-s[t]>3e5&&delete s[t]}));for(let r=0;r<t.length;r++){const i=t[r];if(s[i])continue;if(i===this.pathwayId)return;const n=this.hls.nextLoadLevel,a=this.hls.levels[n];if(e=this.getLevelsForPathway(i),e.length>0){this.log('Setting Pathway to "'.concat(i,'"')),this.pathwayId=i,this.hls.trigger(u.LEVELS_UPDATED,{levels:e});const t=this.hls.levels[n];a&&t&&this.levels&&(t.attrs["STABLE-VARIANT-ID"]!==a.attrs["STABLE-VARIANT-ID"]&&t.bitrate!==a.bitrate&&this.log("Unstable Pathways change from bitrate ".concat(a.bitrate," to ").concat(t.bitrate)),this.hls.nextLoadLevel=n);break}}}clonePathways(t){const e=this.levels;if(!e)return;const s={},i={};t.forEach((t=>{const{ID:r,"BASE-ID":n,"URI-REPLACEMENT":a}=t;if(e.some((t=>t.pathwayId===r)))return;const o=this.getLevelsForPathway(n).map((t=>{const e=h({},t);e.details=void 0,e.url=dn(t.uri,t.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a);const n=new L(t.attrs);n["PATHWAY-ID"]=r;const o=n.AUDIO&&"".concat(n.AUDIO,"_clone_").concat(r),l=n.SUBTITLES&&"".concat(n.SUBTITLES,"_clone_").concat(r);o&&(s[n.AUDIO]=o,n.AUDIO=o),l&&(i[n.SUBTITLES]=l,n.SUBTITLES=l),e.attrs=n;const c=new De(e);return ts(c,"audio",o),ts(c,"text",l),c}));e.push(...o),hn(this.audioTracks,s,a,r),hn(this.subtitleTracks,i,a,r)}))}loadSteeringManifest(t){const e=this.hls.config,s=e.loader;let i;this.loader&&this.loader.destroy(),this.loader=new s(e);try{i=new self.URL(t)}catch(c){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: ".concat(t))}if("data:"!==i.protocol){const t=0|(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate);i.searchParams.set("_HLS_pathway",this.pathwayId),i.searchParams.set("_HLS_throughput",""+t)}const r={responseType:"json",url:i.href},n=e.steeringManifestLoadPolicy.default,a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(t,e,s,r)=>{this.log('Loaded steering manifest: "'.concat(i,'"'));const n=t.data;if(1!==n.VERSION)return void this.log("Steering VERSION ".concat(n.
1VERSION," not supported!"));this.updated=performance.now(),this.timeToLoad=n.TTL;const{"RELOAD-URI":a,"PATHWAY-CLONES":o,"PATHWAY-PRIORITY":l}=n;if(a)try{this.uri=new self.URL(a,i).href}catch(c){return this.enabled=!1,void this.log("Failed to parse Steering Manifest RELOAD-URI: ".concat(a))}this.scheduleRefresh(this.uri||s.url),o&&this.clonePathways(o),l&&this.updatePathwayPriority(l)},onError:(t,e,s,i)=>{if(this.log("Error loading steering manifest: ".concat(t.code," ").concat(t.text," (").concat(e.url,")")),this.stopLoad(),410===t.code)return this.enabled=!1,void this.log("Steering manifest ".concat(e.url," no longer available"));let r=1e3*this.timeToLoad;if(429!==t.code)this.scheduleRefresh(this.uri||e.url,r);else{const t=this.loader;if("function"===typeof(null==t?void 0:t.getResponseHeader)){const e=t.getResponseHeader("Retry-After");e&&(r=1e3*parseFloat(e))}this.log("Steering manifest ".concat(e.url," rate limited"))}},onTimeout:(t,e,s)=>{this.log("Timeout loading steering manifest (".concat(e.url,")")),this.scheduleRefresh(this.uri||e.url)}};this.log("Requesting steering manifest: ".concat(i)),this.loader.load(r,o,l)}scheduleRefresh(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3*this.timeToLoad;self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout((()=>{this.loadSteeringManifest(t)}),e)}}});function Sn(t){return t&&"object"===typeof t?Array.isArray(t)?t.map(Sn):Object.keys(t).reduce(((e,s)=>(e[s]=Sn(t[s]),e)),{}):t}function Ln(t){const e=t.loader;if(e!==mn&&e!==fn)v.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1;else{(function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1})()&&(t.loader=mn,t.progressive=!0,t.enableSoftwareAES=!0,v.log("[config]: Progressive streaming enabled, using FetchLoader"))}}class An{static get version(){return"1.4.12"}static isSupported(){return function(){const t=Nt();if(!t)return!1;const e=Hs(),s=t&&"function"===typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!e||e.prototype&&"function"===typeof e.prototype.appendBuffer&&"function"===typeof e.prototype.remove;return!!s&&!!i}()}static get Events(){return u}static get ErrorTypes(){return f}static get ErrorDetails(){return g}static get DefaultConfig(){return An.defaultConfig?An.defaultConfig:En}static set DefaultConfig(t){An.defaultConfig=t}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Yi,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,function(t,e){if(self.console&&!0===t||"object"===typeof t){T(t,"debug","log","info","warn","error");try{y.log('Debug logs enabled for "'.concat(e,'" in hls.js version ',"1.4.12"))}catch(s){y=p}}else y=p}(t.debug||!1,"Hls instance");const e=this.config=function(t,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const s=Sn(t),i=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((t=>{const r="".concat("level"===t?"playlist":t,"LoadPolicy"),n=void 0===e[r],a=[];
1i.forEach((i=>{const o="".concat(t,"Loading").concat(i),l=e[o];if(void 0!==l&&n){a.push(o);const t=s[r].default;switch(e[r]={default:t},i){case"TimeOut":t.maxLoadTimeMs=l,t.maxTimeToFirstByteMs=l;break;case"MaxRetry":t.errorRetry.maxNumRetry=l,t.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":t.errorRetry.retryDelayMs=l,t.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":t.errorRetry.maxRetryDelayMs=l,t.timeoutRetry.maxRetryDelayMs=l}}})),a.length&&v.warn('hls.js config: "'.concat(a.join('", "'),'" setting(s) are deprecated, use "').concat(r,'": ').concat(JSON.stringify(e[r])))})),l(l({},s),e)}(An.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&Ln(e);const{abrController:s,bufferController:i,capLevelController:r,errorController:n,fpsController:a}=e,o=new n(this),c=this.abrController=new s(this),h=this.bufferController=new i(this),d=this.capLevelController=new r(this),f=new a(this),g=new ce(this),m=new Ee(this),E=e.contentSteeringController,S=E?new E(this):null,L=this.levelController=new Ze(this,S),A=new as(this),R=new gs(this.config),b=this.streamController=new Xi(this,A,R);d.setStreamController(b),f.setStreamController(b);const k=[g,L,b];S&&k.splice(1,0,S),this.networkControllers=k;const D=[c,h,d,f,m,A];this.audioTrackController=this.createController(e.audioTrackController,k);const I=e.audioStreamController;I&&k.push(new I(this,A,R)),this.subtitleTrackController=this.createController(e.subtitleTrackController,k);const w=e.subtitleStreamController;w&&k.push(new w(this,A,R)),this.createController(e.timelineController,D),R.emeController=this.emeController=this.createController(e.emeController,D),this.cmcdController=this.createController(e.cmcdController,D),this.latencyController=this.createController(Se,D),this.coreComponents=D,k.push(o);const C=o.onErrorOut;"function"===typeof C&&this.on(u.ERROR,C,o)}createController(t,e){if(t){const s=new t(this);return e&&e.push(s),s}return null}on(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;this._emitter.on(t,e,s)}once(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;this._emitter.once(t,e,s)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this,i=arguments.length>3?arguments[3]:void 0;this._emitter.off(t,e,s,i)}listeners(t){return this._emitter.listeners(t)}emit(t,e,s){return this._emitter.emit(t,e,s)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(s){v.error("An internal error happened while handling event "+t+'. Error message: "'+s.message+'". Here is a stacktrace:',s),this.trigger(u.ERROR,{type:f.OTHER_ERROR,details:g.INTERNAL_EXCEPTION,fatal:!1,event:t,error:s})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){v.log("destroy"),this.trigger(u.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((t=>t.destroy())),this.networkControllers.length=0,this.coreComponents.forEach((t=>t.destroy())),this.coreComponents.length=0;const t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){v.log("attachMedia"),this._media=t,this.trigger(u.MEDIA_ATTA
1CHING,{media:t})}detachMedia(){v.log("detachMedia"),this.trigger(u.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,s=this.url,i=this.url=a.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});v.log("loadSource:".concat(i)),e&&s&&(s!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(u.MANIFEST_LOADING,{url:t})}startLoad(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;v.log("startLoad(".concat(t,")")),this.networkControllers.forEach((e=>{e.startLoad(t)}))}stopLoad(){v.log("stopLoad"),this.networkControllers.forEach((t=>{t.stopLoad()}))}swapAudioCodec(){v.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){v.log("recoverMediaError");const t=this._media;this.detachMedia(),t&&this.attachMedia(t)}removeLevel(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.levelController.removeLevel(t,e)}get levels(){const t=this.levelController.levels;return t||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){v.log("set currentLevel:".concat(t)),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){v.log("set nextLevel:".concat(t)),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){v.log("set loadLevel:".concat(t)),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){v.log("set firstLevel:".concat(t)),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){v.log("set startLevel:".concat(t)),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){const e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(v.log("set autoLevelCapping:".concat(t)),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){Le.indexOf(t)>-1&&(this._maxHdcpLevel=t)}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:t,config:{minAutoBitrate:e}}=this;if(!t)return 0;const s=t.length;for(let i=0;i<s;i++)if(t[i].maxBitrate>=e)return i;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:s}=this;let i;if(i=-1===e&&t&&t.length?t.length-1:e,s)for(let r=i;r--;){const e=t[r].attrs["HDCP-LEVEL"];if(e&&e<=s)return r}return i}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){const t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){const e=this.audioTrackController;e&&(e.audioTrack=t)}get subtitleTracks(){const t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){const t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){const e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){const t=this.subtitleTrackController;return!!t&&t.subtitleDisplay}set subtitleDisplay(t){const e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}An.defaultConfig=void 0}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.