lemon-mse 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build.config.ts +22 -0
- package/dist/hls.d.mts +1 -0
- package/dist/hls.d.ts +1 -0
- package/dist/hls.mjs +14 -14
- package/dist/xg-flv-hls.d.mts +9 -0
- package/dist/xg-flv-hls.d.ts +9 -0
- package/dist/xg-flv.d.mts +1 -0
- package/dist/xg-flv.d.ts +1 -0
- package/dist/xg-flv.mjs +5 -5
- package/dist/xg-hls.d.mts +1 -0
- package/dist/xg-hls.d.ts +1 -0
- package/dist/xg-hls.mjs +5 -5
- package/package.json +16 -3
- package/src/hls.ts +2 -0
- package/src/xg-flv-hls.ts +4 -0
- package/src/xg-flv.ts +1 -0
- package/src/xg-hls.ts +1 -0
- package/tsconfig.json +28 -0
package/dist/hls.mjs
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
function Jn(Gt){return Gt&&Gt.__esModule&&Object.prototype.hasOwnProperty.call(Gt,"default")?Gt.default:Gt}var da={exports:{}};(function(Gt,ts){(function fa(br){var kr;kr=function(){function Dr(s,a){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(s);a&&(e=e.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),t.push.apply(t,e)}return t}function yt(s){for(var a=1;a<arguments.length;a++){var t=arguments[a]!=null?arguments[a]:{};a%2?Dr(Object(t),!0).forEach(function(e){var r,i,n;r=s,i=e,n=t[e],(i=_r(i))in r?Object.defineProperty(r,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[i]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Dr(Object(t)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(t,e))})}return s}function _r(s){var a=function(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var i=r.call(t,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}(s,"string");return typeof a=="symbol"?a:String(a)}function wr(s,a){for(var t=0;t<a.length;t++){var e=a[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(s,_r(e.key),e)}}function ct(s,a,t){return a&&wr(s.prototype,a),t&&wr(s,t),Object.defineProperty(s,"prototype",{writable:!1}),s}function gt(){return gt=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(s[e]=t[e])}return s},gt.apply(this,arguments)}function At(s,a){s.prototype=Object.create(a.prototype),s.prototype.constructor=s,re(s,a)}function Be(s){return Be=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},Be(s)}function re(s,a){return re=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},re(s,a)}function Ue(s,a,t){return Ue=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}()?Reflect.construct.bind():function(e,r,i){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(e,n));return i&&re(o,i.prototype),o},Ue.apply(null,arguments)}function pe(s){var a=typeof Map=="function"?new Map:void 0;return pe=function(t){if(t===null||!function(r){try{return Function.toString.call(r).indexOf("[native code]")!==-1}catch{return typeof r=="function"}}(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(a!==void 0){if(a.has(t))return a.get(t);a.set(t,e)}function e(){return Ue(t,arguments,Be(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),re(e,t)},pe(s)}function xr(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Cr={exports:{}};(function(s,a){var t,e,r,i,n;t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,e=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,n={buildAbsoluteURL:function(o,l,d){if(d=d||{},o=o.trim(),!(l=l.trim())){if(!d.alwaysNormalize)return o;var u=n.parseURL(o);if(!u)throw new Error("Error trying to parse base URL.");return u.path=n.normalizePath(u.path),n.buildURLFromParts(u)}var h=n.parseURL(l);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return d.alwaysNormalize?(h.path=n.normalizePath(h.path),n.buildURLFromParts(h)):l;var f=n.parseURL(o);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var c=e.exec(f.path);f.netLoc=c[1],f.path=c[2]}f.netLoc&&!f.path&&(f.path="/");var m={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(m.netLoc=f.netLoc,h.path[0]!=="/"))if(h.path){var g=f.path,y=g.substring(0,g.lastIndexOf("/")+1)+h.path;m.path=n.normalizePath(y)}else m.path=f.path,h.params||(m.params=f.params,h.query||(m.query=f.query));return m.path===null&&(m.path=d.alwaysNormalize?n.normalizePath(h.path):h.path),n.buildURLFromParts(m)},parseURL:function(o){var l=t.exec(o);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(o){for(o=o.split("").reverse().join("").replace(r,"");o.length!==(o=o.replace(i,"")).length;);return o.split("").reverse().join("")},buildURLFromParts:function(o){return o.scheme+o.netLoc+o.path+o.params+o.query+o.fragment}},s.exports=n})(Cr);var Ge=Cr.exports,N=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},ca=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=va},va=Number.MAX_SAFE_INTEGER||9007199254740991,E=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",s}({}),W=function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s}({}),D=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.UNKNOWN="unknown",s}({}),Ht=function(){},He={trace:Ht,debug:Ht,log:Ht,warn:Ht,info:Ht,error:Ht},ie=He;function ga(s){for(var a=arguments.length,t=new Array(a>1?a-1:0),e=1;e<a;e++)t[e-1]=arguments[e];t.forEach(function(r){ie[r]=s[r]?s[r].bind(s):function(i){var n=self.console[i];return n?n.bind(self.console,"["+i+"] >"):Ht}(r)})}function Ir(s,a){if(typeof console=="object"&&s===!0||typeof s=="object"){ga(s,"debug","log","info","warn","error");try{ie.log('Debug logs enabled for "'+a+'" in hls.js version 1.5.8')}catch{ie=He}}else ie=He}var A=ie,ma=/^(\d+)x(\d+)$/,Pr=/(.+?)=(".*?"|.*?)(?:,|$)/g,lt=function(){function s(t){typeof t=="string"&&(t=s.parseAttrList(t)),gt(this,t)}var a=s.prototype;return a.decimalInteger=function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},a.hexadecimalInteger=function(t){if(this[t]){var e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var r=new Uint8Array(e.length/2),i=0;i<e.length/2;i++)r[i]=parseInt(e.slice(2*i,2*i+2),16);return r}return null},a.hexadecimalIntegerAsNumber=function(t){var e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e},a.decimalFloatingPoint=function(t){return parseFloat(this[t])},a.optionalFloat=function(t,e){var r=this[t];return r?parseFloat(r):e},a.enumeratedString=function(t){return this[t]},a.bool=function(t){return this[t]==="YES"},a.decimalResolution=function(t){var e=ma.exec(this[t]);if(e!==null)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},s.parseAttrList=function(t){var e,r={};for(Pr.lastIndex=0;(e=Pr.exec(t))!==null;){var i=e[2];i.indexOf('"')===0&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[e[1].trim()]=i}return r},ct(s,[{key:"clientAttrs",get:function(){return Object.keys(this).filter(function(t){return t.substring(0,2)==="X-"})}}]),s}();function pa(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}var Fr=function(){function s(a,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var e=t.attr;for(var r in e)if(Object.prototype.hasOwnProperty.call(a,r)&&a[r]!==e[r]){A.warn('DATERANGE tag attribute: "'+r+'" does not match for tags with ID: "'+a.ID+'"'),this._badValueForSameId=r;break}a=gt(new lt({}),e,a)}if(this.attr=a,this._startDate=new Date(a["START-DATE"]),"END-DATE"in this.attr){var i=new Date(this.attr["END-DATE"]);N(i.getTime())&&(this._endDate=i)}}return ct(s,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var a=this.duration;return a!==null?new Date(this._startDate.getTime()+1e3*a):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var a=this.attr.decimalFloatingPoint("DURATION");if(N(a))return a}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&N(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),s}(),ye=function(){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}},Tt="audio",bt="video",Ve="audiovideo",Or=function(){function s(a){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[Tt]=null,t[bt]=null,t[Ve]=null,t),this.baseurl=a}return s.prototype.setByteRange=function(a,t){var e,r=a.split("@",2);e=r.length===1?t?.byteRangeEndOffset||0:parseInt(r[1]),this._byteRange=[e,parseInt(r[0])+e]},ct(s,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Ge.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(a){this._url=a}}]),s}(),Ke=function(s){function a(e,r){var i;return(i=s.call(this,r)||this)._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkeys=void 0,i.type=void 0,i.loader=null,i.keyLoader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new ye,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.gap=void 0,i.urlId=0,i.type=e,i}At(a,s);var t=a.prototype;return t.setKeyFormat=function(e){if(this.levelkeys){var r=this.levelkeys[e];r&&!this._decryptdata&&(this._decryptdata=r.getDecryptData(this.sn))}},t.abortRequests=function(){var e,r;(e=this.loader)==null||e.abort(),(r=this.keyLoader)==null||r.abort()},t.setElementaryStreamInfo=function(e,r,i,n,o,l){l===void 0&&(l=!1);var d=this.elementaryStreams,u=d[e];u?(u.startPTS=Math.min(u.startPTS,r),u.endPTS=Math.max(u.endPTS,i),u.startDTS=Math.min(u.startDTS,n),u.endDTS=Math.max(u.endDTS,o)):d[e]={startPTS:r,endPTS:i,startDTS:n,endDTS:o,partial:l}},t.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[Tt]=null,e[bt]=null,e[Ve]=null},ct(a,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{var r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!N(this.programDateTime))return null;var e=N(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){var r=Object.keys(this.levelkeys),i=r.length;if(i>1||i===1&&this.levelkeys[r[0]].encrypted)return!0}return!1}}]),a}(Or),ya=function(s){function a(t,e,r,i,n){var o;(o=s.call(this,r)||this).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.stats=new ye,o.duration=t.decimalFloatingPoint("DURATION"),o.gap=t.bool("GAP"),o.independent=t.bool("INDEPENDENT"),o.relurl=t.enumeratedString("URI"),o.fragment=e,o.index=i;var l=t.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,n),n&&(o.fragOffset=n.fragOffset+n.duration),o}return At(a,s),ct(a,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}]),a}(Or),Ea=function(){function s(a){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=a}return s.prototype.reloaded=function(a){if(!a)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-a.lastPartSn,e=this.lastPartIndex-a.lastPartIndex;this.updated=this.endSN!==a.endSN||!!e||!!t||!this.live,this.advanced=this.endSN>a.endSN||t>0||t===0&&e>0,this.updated||this.advanced?this.misses=Math.floor(.6*a.misses):this.misses=a.misses+1,this.availabilityDelay=a.availabilityDelay},ct(s,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&N(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var a=this.driftEndTime-this.driftStartTime;return a>0?1e3*(this.driftEnd-this.driftStart)/a:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var a;return(a=this.partList)!=null&&a.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var a;return(a=this.fragments)!=null&&a.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var a;return(a=this.partList)!=null&&a.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var a;return(a=this.partList)!=null&&a.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),s}(),Ta=xr(void 0);function Vt(s,a,t){return Uint8Array.prototype.slice?s.slice(a,t):new Uint8Array(Array.prototype.slice.call(s,a,t))}var je,We=function(s,a){return a+10<=s.length&&s[a]===73&&s[a+1]===68&&s[a+2]===51&&s[a+3]<255&&s[a+4]<255&&s[a+6]<128&&s[a+7]<128&&s[a+8]<128&&s[a+9]<128},Mr=function(s,a){return a+10<=s.length&&s[a]===51&&s[a+1]===68&&s[a+2]===73&&s[a+3]<255&&s[a+4]<255&&s[a+6]<128&&s[a+7]<128&&s[a+8]<128&&s[a+9]<128},Ee=function(s,a){for(var t=a,e=0;We(s,a);)e+=10,e+=Te(s,a+6),Mr(s,a+10)&&(e+=10),a+=e;if(e>0)return s.subarray(t,t+e)},Te=function(s,a){var t=0;return t=(127&s[a])<<21,t|=(127&s[a+1])<<14,t|=(127&s[a+2])<<7,t|=127&s[a+3]},Sa=function(s,a){return We(s,a)&&Te(s,a+6)+10<=s.length-a},Nr=function(s){for(var a=Ur(s),t=0;t<a.length;t++){var e=a[t];if(Br(e))return Da(e)}},Br=function(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"},La=function(s){var a=String.fromCharCode(s[0],s[1],s[2],s[3]),t=Te(s,4);return{type:a,size:t,data:s.subarray(10,10+t)}},Ur=function(s){for(var a=0,t=[];We(s,a);){for(var e=Te(s,a+6),r=(a+=10)+e;a+8<r;){var i=La(s.subarray(a)),n=Ra(i);n&&t.push(n),a+=i.size+10}Mr(s,a)&&(a+=10)}return t},Ra=function(s){return s.type==="PRIV"?Aa(s):s.type[0]==="W"?ka(s):ba(s)},Aa=function(s){if(!(s.size<2)){var a=Bt(s.data,!0),t=new Uint8Array(s.data.subarray(a.length+1));return{key:s.type,info:a,data:t.buffer}}},ba=function(s){if(!(s.size<2)){if(s.type==="TXXX"){var a=1,t=Bt(s.data.subarray(a),!0);a+=t.length+1;var e=Bt(s.data.subarray(a));return{key:s.type,info:t,data:e}}var r=Bt(s.data.subarray(1));return{key:s.type,data:r}}},ka=function(s){if(s.type==="WXXX"){if(s.size<2)return;var a=1,t=Bt(s.data.subarray(a),!0);a+=t.length+1;var e=Bt(s.data.subarray(a));return{key:s.type,info:t,data:e}}var r=Bt(s.data);return{key:s.type,data:r}},Da=function(s){if(s.data.byteLength===8){var a=new Uint8Array(s.data),t=1&a[3],e=(a[4]<<23)+(a[5]<<15)+(a[6]<<7)+a[7];return e/=45,t&&(e+=4772185884e-2),Math.round(e)}},Bt=function(s,a){a===void 0&&(a=!1);var t=_a();if(t){var e=t.decode(s);if(a){var r=e.indexOf("\0");return r!==-1?e.substring(0,r):e}return e.replace(/\0/g,"")}for(var i,n,o,l=s.length,d="",u=0;u<l;){if((i=s[u++])===0&&a)return d;if(i!==0&&i!==3)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(i);break;case 12:case 13:n=s[u++],d+=String.fromCharCode((31&i)<<6|63&n);break;case 14:n=s[u++],o=s[u++],d+=String.fromCharCode((15&i)<<12|(63&n)<<6|(63&o)<<0)}}return d};function _a(){if(!navigator.userAgent.includes("PlayStation 4"))return je||self.TextDecoder===void 0||(je=new self.TextDecoder("utf-8")),je}var Gr=function(s){for(var a="",t=0;t<s.length;t++){var e=s[t].toString(16);e.length<2&&(e="0"+e),a+=e}return a},Se=Math.pow(2,32)-1,wa=[].push,Hr={video:1,audio:2,id3:3,text:4};function dt(s){return String.fromCharCode.apply(null,s)}function Vr(s,a){var t=s[a]<<8|s[a+1];return t<0?65536+t:t}function U(s,a){var t=jr(s,a);return t<0?4294967296+t:t}function Kr(s,a){var t=U(s,a);return t*=Math.pow(2,32),t+=U(s,a+4)}function jr(s,a){return s[a]<<24|s[a+1]<<16|s[a+2]<<8|s[a+3]}function Ye(s,a,t){s[a]=t>>24,s[a+1]=t>>16&255,s[a+2]=t>>8&255,s[a+3]=255&t}function K(s,a){var t=[];if(!a.length)return t;for(var e=s.byteLength,r=0;r<e;){var i=U(s,r),n=i>1?r+i:e;if(dt(s.subarray(r+4,r+8))===a[0])if(a.length===1)t.push(s.subarray(r+8,n));else{var o=K(s.subarray(r+8,n),a.slice(1));o.length&&wa.apply(t,o)}r=n}return t}function xa(s){var a=[],t=s[0],e=8,r=U(s,e);e+=4;var i=0,n=0;t===0?(i=U(s,e),n=U(s,e+4),e+=8):(i=Kr(s,e),n=Kr(s,e+8),e+=16),e+=2;var o=s.length+n,l=Vr(s,e);e+=2;for(var d=0;d<l;d++){var u=e,h=U(s,u);u+=4;var f=2147483647&h;if((2147483648&h)>>>31==1)return A.warn("SIDX has hierarchical references (not supported)"),null;var c=U(s,u);u+=4,a.push({referenceSize:f,subsegmentDuration:c,info:{duration:c/r,start:o,end:o+f-1}}),o+=f,e=u+=4}return{earliestPresentationTime:i,timescale:r,version:t,referencesCount:l,references:a}}function Wr(s){for(var a=[],t=K(s,["moov","trak"]),e=0;e<t.length;e++){var r=t[e],i=K(r,["tkhd"])[0];if(i){var n=i[0],o=U(i,n===0?12:20),l=K(r,["mdia","mdhd"])[0];if(l){var d=U(l,(n=l[0])===0?12:20),u=K(r,["mdia","hdlr"])[0];if(u){var h=dt(u.subarray(8,12)),f={soun:Tt,vide:bt}[h];if(f){var c=Ca(K(r,["mdia","minf","stbl","stsd"])[0]);a[o]={timescale:d,type:f},a[f]=yt({timescale:d,id:o},c)}}}}}return K(s,["moov","mvex","trex"]).forEach(function(m){var g=U(m,4),y=a[g];y&&(y.default={duration:U(m,12),flags:U(m,20)})}),a}function Ca(s){var a=s.subarray(8),t=a.subarray(86),e=dt(a.subarray(4,8)),r=e,i=e==="enca"||e==="encv";if(i){var n=K(a,[e])[0];K(n.subarray(e==="enca"?28:78),["sinf"]).forEach(function(Z){var j=K(Z,["schm"])[0];if(j){var q=dt(j.subarray(4,8));if(q==="cbcs"||q==="cenc"){var J=K(Z,["frma"])[0];J&&(r=dt(J))}}})}switch(r){case"avc1":case"avc2":case"avc3":case"avc4":var o=K(t,["avcC"])[0];r+="."+Le(o[1])+Le(o[2])+Le(o[3]);break;case"mp4a":var l=K(a,[e])[0],d=K(l.subarray(28),["esds"])[0];if(d&&d.length>12){var u=4;if(d[u++]!==3)break;u=qe(d,u),u+=2;var h=d[u++];if(128&h&&(u+=2),64&h&&(u+=d[u++]),d[u++]!==4)break;u=qe(d,u);var f=d[u++];if(f!==64||(r+="."+Le(f),u+=12,d[u++]!==5))break;u=qe(d,u);var c=d[u++],m=(248&c)>>3;m===31&&(m+=1+((7&c)<<3)+((224&d[u])>>5)),r+="."+m}break;case"hvc1":case"hev1":var g=K(t,["hvcC"])[0],y=g[1],v=["","A","B","C"][y>>6],p=31&y,S=U(g,2),T=(32&y)>>5?"H":"L",R=g[12],b=g.subarray(6,12);r+="."+v+p,r+="."+S.toString(16).toUpperCase(),r+="."+T+R;for(var L="",_=b.length;_--;){var x=b[_];(x||L)&&(L="."+x.toString(16).toUpperCase()+L)}r+=L;break;case"dvh1":case"dvhe":var w=K(t,["dvcC"])[0],k=w[2]>>1&127,C=w[2]<<5&32|w[3]>>3&31;r+="."+kt(k)+"."+kt(C);break;case"vp09":var I=K(t,["vpcC"])[0],P=I[4],O=I[5],B=I[6]>>4&15;r+="."+kt(P)+"."+kt(O)+"."+kt(B);break;case"av01":var F=K(t,["av1C"])[0],M=F[1]>>>5,H=31&F[1],G=F[2]>>>7?"H":"M",V=(64&F[2])>>6,$=(32&F[2])>>5,nt=M===2&&V?$?12:10:V?10:8,rt=(16&F[2])>>4,tt=(8&F[2])>>3,et=(4&F[2])>>2,z=3&F[2];r+="."+M+"."+kt(H)+G+"."+kt(nt)+"."+rt+"."+tt+et+z+"."+kt(1)+"."+kt(1)+"."+kt(1)+".0"}return{codec:r,encrypted:i}}function qe(s,a){for(var t=a+5;128&s[a++]&&a<t;);return a}function Le(s){return("0"+s.toString(16).toUpperCase()).slice(-2)}function kt(s){return(s<10?"0":"")+s}function Ia(s,a){if(!s||!a)return s;var t=a.keyId;return t&&a.isCommonEncryption&&K(s,["moov","trak"]).forEach(function(e){var r=K(e,["mdia","minf","stbl","stsd"])[0].subarray(8),i=K(r,["enca"]),n=i.length>0;n||(i=K(r,["encv"])),i.forEach(function(o){K(n?o.subarray(28):o.subarray(78),["sinf"]).forEach(function(l){var d=function(h){var f=K(h,["schm"])[0];if(f){var c=dt(f.subarray(4,8));if(c==="cbcs"||c==="cenc")return K(h,["schi","tenc"])[0]}return A.error("[eme] missing 'schm' box"),null}(l);if(d){var u=d.subarray(8,24);u.some(function(h){return h!==0})||(A.log("[eme] Patching keyId in 'enc"+(n?"a":"v")+">sinf>>tenc' box: "+Gr(u)+" -> "+Gr(t)),d.set(t,8))}})})}),s}function Pa(s){var a=U(s,0),t=8;1&a&&(t+=4),4&a&&(t+=4);for(var e=0,r=U(s,4),i=0;i<r;i++)256&a&&(e+=U(s,t),t+=4),512&a&&(t+=4),1024&a&&(t+=4),2048&a&&(t+=4);return e}function St(s,a){var t=new Uint8Array(s.length+a.length);return t.set(s),t.set(a,s.length),t}function Yr(s,a){var t=[],e=a.samples,r=a.timescale,i=a.id,n=!1;return K(e,["moof"]).map(function(o){var l=o.byteOffset-8;K(o,["traf"]).map(function(d){var u=K(d,["tfdt"]).map(function(h){var f=h[0],c=U(h,4);return f===1&&(c*=Math.pow(2,32),c+=U(h,8)),c/r})[0];return u!==void 0&&(s=u),K(d,["tfhd"]).map(function(h){var f=U(h,4),c=16777215&U(h,0),m=0,g=(16&c)!=0,y=0,v=(32&c)!=0,p=8;f===i&&(1&c&&(p+=8),2&c&&(p+=4),8&c&&(m=U(h,p),p+=4),g&&(y=U(h,p),p+=4),v&&(p+=4),a.type==="video"&&(n=function(S){if(!S)return!1;var T=S.indexOf("."),R=T<0?S:S.substring(0,T);return R==="hvc1"||R==="hev1"||R==="dvh1"||R==="dvhe"}(a.codec)),K(d,["trun"]).map(function(S){var T=S[0],R=16777215&U(S,0),b=(1&R)!=0,L=0,_=(4&R)!=0,x=(256&R)!=0,w=0,k=(512&R)!=0,C=0,I=(1024&R)!=0,P=(2048&R)!=0,O=0,B=U(S,4),F=8;b&&(L=U(S,F),F+=4),_&&(F+=4);for(var M=L+l,H=0;H<B;H++){if(x?(w=U(S,F),F+=4):w=m,k?(C=U(S,F),F+=4):C=y,I&&(F+=4),P&&(O=T===0?U(S,F):jr(S,F),F+=4),a.type===bt)for(var G=0;G<C;){var V=U(e,M);Fa(n,e[M+=4])&&qr(e.subarray(M,M+V),n?2:1,s+O/r,t),M+=V,G+=V+4}s+=w/r}}))})})}),t}function Fa(s,a){if(s){var t=a>>1&63;return t===39||t===40}return(31&a)==6}function qr(s,a,t,e){var r=zr(s),i=0;i+=a;for(var n=0,o=0,l=0;i<r.length;){n=0;do{if(i>=r.length)break;n+=l=r[i++]}while(l===255);o=0;do{if(i>=r.length)break;o+=l=r[i++]}while(l===255);var d=r.length-i,u=i;if(o<d)i+=o;else if(o>d){A.error("Malformed SEI payload. "+o+" is too small, only "+d+" bytes left to parse.");break}if(n===4){if(r[u++]===181){var h=Vr(r,u);if(u+=2,h===49){var f=U(r,u);if(u+=4,f===1195456820){var c=r[u++];if(c===3){var m=r[u++],g=64&m,y=g?2+3*(31&m):0,v=new Uint8Array(y);if(g){v[0]=m;for(var p=1;p<y;p++)v[p]=r[u++]}e.push({type:c,payloadType:n,pts:t,bytes:v})}}}}}else if(n===5&&o>16){for(var S=[],T=0;T<16;T++){var R=r[u++].toString(16);S.push(R.length==1?"0"+R:R),T!==3&&T!==5&&T!==7&&T!==9||S.push("-")}for(var b=o-16,L=new Uint8Array(b),_=0;_<b;_++)L[_]=r[u++];e.push({payloadType:n,pts:t,uuid:S.join(""),userData:Bt(L),userDataBytes:L})}}}function zr(s){for(var a=s.byteLength,t=[],e=1;e<a-2;)s[e]===0&&s[e+1]===0&&s[e+2]===3?(t.push(e+2),e+=2):e++;if(t.length===0)return s;var r=a-t.length,i=new Uint8Array(r),n=0;for(e=0;e<r;n++,e++)n===t[0]&&(n++,t.shift()),i[e]=s[n];return i}var Oa=function(){function s(t,e,r,i,n){i===void 0&&(i=[1]),n===void 0&&(n=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=r,this.keyFormatVersions=i,this.iv=n,this.encrypted=!!t&&t!=="NONE",this.isCommonEncryption=this.encrypted&&t!=="AES-128"}s.clearKeyUriToKeyIdMap=function(){};var a=s.prototype;return a.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES"}return!1},a.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof t!="number"&&(this.method!=="AES-128"||this.iv||A.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0);var e=function(r){for(var i=new Uint8Array(16),n=12;n<16;n++)i[n]=r>>8*(15-n)&255;return i}(t);return new s(this.method,this.uri,"identity",this.keyFormatVersions,e)}return this},s}();function Kt(s){if(s===void 0&&(s=!0),typeof self<"u")return(s||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}var Re={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function ze(s,a,t){return t===void 0&&(t=!0),!s.split(",").some(function(e){return!Xr(e,a,t)})}function Xr(s,a,t){var e;t===void 0&&(t=!0);var r=Kt(t);return(e=r?.isTypeSupported(Xe(s,a)))!=null&&e}function Xe(s,a){return a+'/mp4;codecs="'+s+'"'}function Qr(s){if(s){var a=s.substring(0,4);return Re.video[a]}return 2}function Ae(s){return s.split(",").reduce(function(a,t){var e=Re.video[t];return e?(2*e+a)/(a?3:2):(Re.audio[t]+a)/(a?2:1)},0)}var Qe={},Ma=/flac|opus/i;function be(s,a){return a===void 0&&(a=!0),s.replace(Ma,function(t){return function(e,r){if(r===void 0&&(r=!0),Qe[e])return Qe[e];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[e],n=0;n<i.length;n++)if(Xr(i[n],"audio",r))return Qe[e]=i[n],i[n];return e}(t.toLowerCase(),a)})}function Zr(s,a){return s&&s!=="mp4a"?s:a&&a.split(",")[0]}var Jr=/#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,$r=/#EXT-X-MEDIA:(.*)/g,Na=/^#EXT(?:INF|-X-TARGETDURATION):/m,ti=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Ba=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|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),ae=function(){function s(){}return s.findGroup=function(a,t){for(var e=0;e<a.length;e++){var r=a[e];if(r.id===t)return r}},s.resolve=function(a,t){return Ge.buildAbsoluteURL(t,a,{alwaysNormalize:!0})},s.isMediaPlaylist=function(a){return Na.test(a)},s.parseMasterPlaylist=function(a,t){var e,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:!1},i=[];for(Jr.lastIndex=0;(e=Jr.exec(a))!=null;)if(e[1]){var n,o=new lt(e[1]),l=e[2],d={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:s.resolve(l,t)},u=o.decimalResolution("RESOLUTION");u&&(d.width=u.width,d.height=u.height),Ua(o.CODECS,d),(n=d.unknownCodecs)!=null&&n.length||i.push(d),r.levels.push(d)}else if(e[3]){var h=e[3],f=e[4];switch(h){case"SESSION-DATA":var c=new lt(f),m=c["DATA-ID"];m&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[m]=c);break;case"SESSION-KEY":var g=ei(f,t);g.encrypted&&g.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(g)):A.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+f+'"');break;case"DEFINE":break;case"CONTENT-STEERING":var y=new lt(f);r.contentSteering={uri:s.resolve(y["SERVER-URI"],t),pathwayId:y["PATHWAY-ID"]||"."};break;case"START":r.startTimeOffset=ri(f)}}var v=i.length>0&&i.length<r.levels.length;return r.levels=v?i:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},s.parseMasterPlaylistMedia=function(a,t,e){var r,i={},n=e.levels,o={AUDIO:n.map(function(T){return{id:T.attrs.AUDIO,audioCodec:T.audioCodec}}),SUBTITLES:n.map(function(T){return{id:T.attrs.SUBTITLES,textCodec:T.textCodec}}),"CLOSED-CAPTIONS":[]},l=0;for($r.lastIndex=0;(r=$r.exec(a))!==null;){var d=new lt(r[1]),u=d.TYPE;if(u){var h=o[u],f=i[u]||[];i[u]=f;var c=d.LANGUAGE,m=d["ASSOC-LANGUAGE"],g=d.CHANNELS,y=d.CHARACTERISTICS,v=d["INSTREAM-ID"],p={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",name:d.NAME||c||"",type:u,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:c,url:d.URI?s.resolve(d.URI,t):""};if(m&&(p.assocLang=m),g&&(p.channels=g),y&&(p.characteristics=y),v&&(p.instreamId=v),h!=null&&h.length){var S=s.findGroup(h,p.groupId)||h[0];ii(p,S,"audioCodec"),ii(p,S,"textCodec")}f.push(p)}}return i},s.parseLevelPlaylist=function(a,t,e,r,i,n){var o,l,d,u=new Ea(t),h=u.fragments,f=null,c=0,m=0,g=0,y=0,v=null,p=new Ke(r,t),S=-1,T=!1,R=null;for(ti.lastIndex=0,u.m3u8=a,u.hasVariableRefs=!1;(o=ti.exec(a))!==null;){T&&(T=!1,(p=new Ke(r,t)).start=g,p.sn=c,p.cc=y,p.level=e,f&&(p.initSegment=f,p.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null,R&&(p.setByteRange(R),R=null)));var b=o[1];if(b){p.duration=parseFloat(b);var L=(" "+o[2]).slice(1);p.title=L||null,p.tagList.push(L?["INF",b,L]:["INF",b])}else if(o[3]){if(N(p.duration)){p.start=g,d&&si(p,d,u),p.sn=c,p.level=e,p.cc=y,h.push(p);var _=(" "+o[3]).slice(1);p.relurl=_,ai(p,v),v=p,g+=p.duration,c++,m=0,T=!0}}else if(o[4]){var x=(" "+o[4]).slice(1);v?p.setByteRange(x,v):p.setByteRange(x)}else if(o[5])p.rawProgramDateTime=(" "+o[5]).slice(1),p.tagList.push(["PROGRAM-DATE-TIME",p.rawProgramDateTime]),S===-1&&(S=h.length);else{if(!(o=o[0].match(Ba))){A.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<o.length&&o[l]===void 0;l++);var w=(" "+o[l]).slice(1),k=(" "+o[l+1]).slice(1),C=o[l+2]?(" "+o[l+2]).slice(1):"";switch(w){case"PLAYLIST-TYPE":u.type=k.toUpperCase();break;case"MEDIA-SEQUENCE":c=u.startSN=parseInt(k);break;case"SKIP":var I=new lt(k),P=I.decimalInteger("SKIPPED-SEGMENTS");if(N(P)){u.skippedSegments=P;for(var O=P;O--;)h.unshift(null);c+=P}var B=I.enumeratedString("RECENTLY-REMOVED-DATERANGES");B&&(u.recentlyRemovedDateranges=B.split(" "));break;case"TARGETDURATION":u.targetduration=Math.max(parseInt(k),1);break;case"VERSION":u.version=parseInt(k);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":case"DEFINE":break;case"ENDLIST":u.live=!1;break;case"#":(k||C)&&p.tagList.push(C?[k,C]:[k]);break;case"DISCONTINUITY":y++,p.tagList.push(["DIS"]);break;case"GAP":p.gap=!0,p.tagList.push([w]);break;case"BITRATE":p.tagList.push([w,k]);break;case"DATERANGE":var F=new lt(k),M=new Fr(F,u.dateRanges[F.ID]);M.isValid||u.skippedSegments?u.dateRanges[M.id]=M:A.warn('Ignoring invalid DATERANGE tag: "'+k+'"'),p.tagList.push(["EXT-X-DATERANGE",k]);break;case"DISCONTINUITY-SEQUENCE":y=parseInt(k);break;case"KEY":var H=ei(k,t);if(H.isSupported()){if(H.method==="NONE"){d=void 0;break}d||(d={}),d[H.keyFormat]&&(d=gt({},d)),d[H.keyFormat]=H}else A.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+k+'"');break;case"START":u.startTimeOffset=ri(k);break;case"MAP":var G=new lt(k);if(p.duration){var V=new Ke(r,t);ni(V,G,e,d),f=V,p.initSegment=f,f.rawProgramDateTime&&!p.rawProgramDateTime&&(p.rawProgramDateTime=f.rawProgramDateTime)}else{var $=p.byteRangeEndOffset;if($){var nt=p.byteRangeStartOffset;R=$-nt+"@"+nt}else R=null;ni(p,G,e,d),f=p,T=!0}break;case"SERVER-CONTROL":var rt=new lt(k);u.canBlockReload=rt.bool("CAN-BLOCK-RELOAD"),u.canSkipUntil=rt.optionalFloat("CAN-SKIP-UNTIL",0),u.canSkipDateRanges=u.canSkipUntil>0&&rt.bool("CAN-SKIP-DATERANGES"),u.partHoldBack=rt.optionalFloat("PART-HOLD-BACK",0),u.holdBack=rt.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var tt=new lt(k);u.partTarget=tt.decimalFloatingPoint("PART-TARGET");break;case"PART":var et=u.partList;et||(et=u.partList=[]);var z=m>0?et[et.length-1]:void 0,Z=m++,j=new lt(k),q=new ya(j,p,t,Z,z);et.push(q),p.duration+=q.duration;break;case"PRELOAD-HINT":var J=new lt(k);u.preloadHint=J;break;case"RENDITION-REPORT":var X=new lt(k);u.renditionReports=u.renditionReports||[],u.renditionReports.push(X);break;default:A.warn("line parsed but not handled: "+o)}}}v&&!v.relurl?(h.pop(),g-=v.duration,u.partList&&(u.fragmentHint=v)):u.partList&&(ai(p,v),p.cc=y,u.fragmentHint=p,d&&si(p,d,u));var Y=h.length,mt=h[0],Mt=h[Y-1];if((g+=u.skippedSegments*u.targetduration)>0&&Y&&Mt){u.averagetargetduration=g/Y;var Nt=Mt.sn;u.endSN=Nt!=="initSegment"?Nt:0,u.live||(Mt.endList=!0),mt&&(u.startCC=mt.cc)}else u.endSN=0,u.startCC=0;return u.fragmentHint&&(g+=u.fragmentHint.duration),u.totalduration=g,u.endCC=y,S>0&&function(Rt,pt){for(var Et=Rt[pt],_t=pt;_t--;){var vt=Rt[_t];if(!vt)return;vt.programDateTime=Et.programDateTime-1e3*vt.duration,Et=vt}}(h,S),u},s}();function ei(s,a,t){var e,r,i=new lt(s),n=(e=i.METHOD)!=null?e:"",o=i.URI,l=i.hexadecimalInteger("IV"),d=i.KEYFORMATVERSIONS,u=(r=i.KEYFORMAT)!=null?r:"identity";o&&i.IV&&!l&&A.error("Invalid IV: "+i.IV);var h=o?ae.resolve(o,a):"",f=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Oa(n,h,u,f,l)}function ri(s){var a=new lt(s).decimalFloatingPoint("TIME-OFFSET");return N(a)?a:null}function Ua(s,a){var t=(s||"").split(/[ ,]+/).filter(function(e){return e});["video","audio","text"].forEach(function(e){var r=t.filter(function(i){return function(n,o){var l=Re[o];return!!l&&!!l[n.slice(0,4)]}(i,e)});r.length&&(a[e+"Codec"]=r.join(","),t=t.filter(function(i){return r.indexOf(i)===-1}))}),a.unknownCodecs=t}function ii(s,a,t){var e=a[t];e&&(s[t]=e)}function ai(s,a){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):a!=null&&a.programDateTime&&(s.programDateTime=a.endProgramDateTime),N(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function ni(s,a,t,e){s.relurl=a.URI,a.BYTERANGE&&s.setByteRange(a.BYTERANGE),s.level=t,s.sn="initSegment",e&&(s.levelkeys=e),s.initSegment=null}function si(s,a,t){s.levelkeys=a;var e=t.encryptedFragments;e.length&&e[e.length-1].levelkeys===a||!Object.keys(a).some(function(r){return a[r].isCommonEncryption})||e.push(s)}var zt="manifest",jt="level",wt="audioTrack",xt="subtitleTrack",at="main",ne="audio",Ze="subtitle";function oi(s){switch(s.type){case wt:return ne;case xt:return Ze;default:return at}}function Je(s,a){var t=s.url;return t!==void 0&&t.indexOf("data:")!==0||(t=a.url),t}var Ga=function(){function s(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}var a=s.prototype;return a.startLoad=function(t){},a.stopLoad=function(){this.destroyInternalLoaders()},a.registerListeners=function(){var t=this.hls;t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.LEVEL_LOADING,this.onLevelLoading,this),t.on(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},a.unregisterListeners=function(){var t=this.hls;t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.LEVEL_LOADING,this.onLevelLoading,this),t.off(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},a.createInternalLoader=function(t){var e=this.hls.config,r=e.pLoader,i=e.loader,n=new(r||i)(e);return this.loaders[t.type]=n,n},a.getInternalLoader=function(t){return this.loaders[t.type]},a.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},a.destroyInternalLoaders=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}},a.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},a.onManifestLoading=function(t,e){var r=e.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:zt,url:r,deliveryDirectives:null})},a.onLevelLoading=function(t,e){var r=e.id,i=e.level,n=e.pathwayId,o=e.url,l=e.deliveryDirectives;this.load({id:r,level:i,pathwayId:n,responseType:"text",type:jt,url:o,deliveryDirectives:l})},a.onAudioTrackLoading=function(t,e){var r=e.id,i=e.groupId,n=e.url,o=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:wt,url:n,deliveryDirectives:o})},a.onSubtitleTrackLoading=function(t,e){var r=e.id,i=e.groupId,n=e.url,o=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:xt,url:n,deliveryDirectives:o})},a.load=function(t){var e,r,i,n=this,o=this.hls.config,l=this.getInternalLoader(t);if(l){var d=l.context;if(d&&d.url===t.url&&d.level===t.level)return void A.trace("[playlist-loader]: playlist request ongoing");A.log("[playlist-loader]: aborting previous loader for type: "+t.type),l.abort()}if(r=t.type===zt?o.manifestLoadPolicy.default:gt({},o.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),l=this.createInternalLoader(t),N((e=t.deliveryDirectives)==null?void 0:e.part)&&(t.type===jt&&t.level!==null?i=this.hls.levels[t.level].details:t.type===wt&&t.id!==null?i=this.hls.audioTracks[t.id].details:t.type===xt&&t.id!==null&&(i=this.hls.subtitleTracks[t.id].details),i)){var u=i.partTarget,h=i.targetduration;if(u&&h){var f=1e3*Math.max(3*u,.8*h);r=gt({},r,{maxTimeToFirstByteMs:Math.min(f,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(f,r.maxTimeToFirstByteMs)})}}var c=r.errorRetry||r.timeoutRetry||{},m={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},g={onSuccess:function(y,v,p,S){var T=n.getInternalLoader(p);n.resetInternalLoader(p.type);var R=y.data;R.indexOf("#EXTM3U")===0?(v.parsing.start=performance.now(),ae.isMediaPlaylist(R)?n.handleTrackOrLevelPlaylist(y,v,p,S||null,T):n.handleMasterPlaylist(y,v,p,S)):n.handleManifestParsingError(y,p,new Error("no EXTM3U delimiter"),S||null,v)},onError:function(y,v,p,S){n.handleNetworkError(v,p,!1,y,S)},onTimeout:function(y,v,p){n.handleNetworkError(v,p,!0,void 0,y)}};l.load(t,m,g)},a.handleMasterPlaylist=function(t,e,r,i){var n=this.hls,o=t.data,l=Je(t,r),d=ae.parseMasterPlaylist(o,l);if(d.playlistParsingError)this.handleManifestParsingError(t,r,d.playlistParsingError,i,e);else{var u=d.contentSteering,h=d.levels,f=d.sessionData,c=d.sessionKeys,m=d.startTimeOffset,g=d.variableList;this.variableList=g;var y=ae.parseMasterPlaylistMedia(o,l,d),v=y.AUDIO,p=v===void 0?[]:v,S=y.SUBTITLES,T=y["CLOSED-CAPTIONS"];p.length&&(p.some(function(R){return!R.url})||!h[0].audioCodec||h[0].attrs.AUDIO||(A.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new lt({}),bitrate:0,url:""}))),n.trigger(E.MANIFEST_LOADED,{levels:h,audioTracks:p,subtitles:S,captions:T,contentSteering:u,url:l,stats:e,networkDetails:i,sessionData:f,sessionKeys:c,startTimeOffset:m,variableList:g})}},a.handleTrackOrLevelPlaylist=function(t,e,r,i,n){var o=this.hls,l=r.id,d=r.level,u=r.type,h=Je(t,r),f=N(d)?d:N(l)?l:0,c=oi(r),m=ae.parseLevelPlaylist(t.data,h,f,c,0,this.variableList);if(u===zt){var g={attrs:new lt({}),bitrate:0,details:m,name:"",url:h};o.trigger(E.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:h,stats:e,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),r.levelDetails=m,this.handlePlaylistLoaded(m,t,e,r,i,n)},a.handleManifestParsingError=function(t,e,r,i,n){this.hls.trigger(E.ERROR,{type:W.NETWORK_ERROR,details:D.MANIFEST_PARSING_ERROR,fatal:e.type===zt,url:t.url,err:r,error:r,reason:r.message,response:t,context:e,networkDetails:i,stats:n})},a.handleNetworkError=function(t,e,r,i,n){r===void 0&&(r=!1);var o="A network "+(r?"timeout":"error"+(i?" (status "+i.code+")":""))+" occurred while loading "+t.type;t.type===jt?o+=": "+t.level+" id: "+t.id:t.type!==wt&&t.type!==xt||(o+=" id: "+t.id+' group-id: "'+t.groupId+'"');var l=new Error(o);A.warn("[playlist-loader]: "+o);var d=D.UNKNOWN,u=!1,h=this.getInternalLoader(t);switch(t.type){case zt:d=r?D.MANIFEST_LOAD_TIMEOUT:D.MANIFEST_LOAD_ERROR,u=!0;break;case jt:d=r?D.LEVEL_LOAD_TIMEOUT:D.LEVEL_LOAD_ERROR,u=!1;break;case wt:d=r?D.AUDIO_TRACK_LOAD_TIMEOUT:D.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case xt:d=r?D.SUBTITLE_TRACK_LOAD_TIMEOUT:D.SUBTITLE_LOAD_ERROR,u=!1}h&&this.resetInternalLoader(t.type);var f={type:W.NETWORK_ERROR,details:d,fatal:u,url:t.url,loader:h,context:t,error:l,networkDetails:e,stats:n};if(i){var c=e?.url||t.url;f.response=yt({url:c,data:void 0},i)}this.hls.trigger(E.ERROR,f)},a.handlePlaylistLoaded=function(t,e,r,i,n,o){var l=this.hls,d=i.type,u=i.level,h=i.id,f=i.groupId,c=i.deliveryDirectives,m=Je(e,i),g=oi(i),y=typeof i.level=="number"&&g===at?u:void 0;if(t.fragments.length){t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));var v=t.playlistParsingError;if(v)l.trigger(E.ERROR,{type:W.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:v,reason:v.message,response:e,context:i,level:y,parent:g,networkDetails:n,stats:r});else switch(t.live&&o&&(o.getCacheAge&&(t.ageHeader=o.getCacheAge()||0),o.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),d){case zt:case jt:l.trigger(E.LEVEL_LOADED,{details:t,level:y||0,id:h||0,stats:r,networkDetails:n,deliveryDirectives:c});break;case wt:l.trigger(E.AUDIO_TRACK_LOADED,{details:t,id:h||0,groupId:f||"",stats:r,networkDetails:n,deliveryDirectives:c});break;case xt:l.trigger(E.SUBTITLE_TRACK_LOADED,{details:t,id:h||0,groupId:f||"",stats:r,networkDetails:n,deliveryDirectives:c})}}else{var p=new Error("No Segments found in Playlist");l.trigger(E.ERROR,{type:W.NETWORK_ERROR,details:D.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:p,reason:p.message,response:e,context:i,level:y,parent:g,networkDetails:n,stats:r})}},s}();function Ha(s,a){var t;try{t=new Event("addtrack")}catch{(t=document.createEvent("Event")).initEvent("addtrack",!1,!1)}t.track=s,a.dispatchEvent(t)}function Va(s,a,t,e){var r=s.mode;if(r==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0)for(var i=function(o,l,d){var u=[],h=function(g,y){if(y<g[0].startTime)return 0;var v=g.length-1;if(y>g[v].endTime)return-1;for(var p=0,S=v;p<=S;){var T=Math.floor((S+p)/2);if(y<g[T].startTime)S=T-1;else{if(!(y>g[T].startTime&&p<v))return T;p=T+1}}return g[p].startTime-y<y-g[S].startTime?p:S}(o,l);if(h>-1)for(var f=h,c=o.length;f<c;f++){var m=o[f];if(m.startTime>=l&&m.endTime<=d)u.push(m);else if(m.startTime>d)return u}return u}(s.cues,a,t),n=0;n<i.length;n++)e&&!e(i[n])||s.removeCue(i[n]);r==="disabled"&&(s.mode=r)}var se="org.id3",Ka="com.apple.quicktime.HLS",oe="https://aomedia.org/emsg/ID3";function $e(){if(typeof self<"u")return self.VTTCue||self.TextTrackCue}function li(s,a,t,e,r){var i=new s(a,t,"");try{i.value=e,r&&(i.type=r)}catch{i=new s(a,t,JSON.stringify(r?yt({type:r},e):e))}return i}var ke=function(){var s=$e();try{s&&new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function tr(s,a){return s.getTime()/1e3-a}var ja=function(){function s(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}var a=s.prototype;return a.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},a._registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)},a._unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(E.LEVEL_UPDATED,this.onLevelUpdated,this)},a.onMediaAttached=function(t,e){this.media=e.media},a.onMediaDetaching=function(){this.id3Track&&(function(t){var e=t.mode;if(e==="disabled"&&(t.mode="hidden"),t.cues)for(var r=t.cues.length;r--;)t.removeCue(t.cues[r]);e==="disabled"&&(t.mode=e)}(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},a.onManifestLoading=function(){this.dateRangeCuesAppended={}},a.createTrack=function(t){var e=this.getID3Track(t.textTracks);return e.mode="hidden",e},a.getID3Track=function(t){if(this.media){for(var e=0;e<t.length;e++){var r=t[e];if(r.kind==="metadata"&&r.label==="id3")return Ha(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},a.onFragParsingMetadata=function(t,e){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,n=r.enableID3MetadataCues;if(i||n){var o=e.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var l=$e();if(l)for(var d=0;d<o.length;d++){var u=o[d].type;if((u!==oe||i)&&n){var h=Ur(o[d].data);if(h){var f=o[d].pts,c=f+o[d].duration;c>ke&&(c=ke),c-f<=0&&(c=f+.25);for(var m=0;m<h.length;m++){var g=h[m];if(!Br(g)){this.updateId3CueEnds(f,u);var y=li(l,f,c,g,u);y&&this.id3Track.addCue(y)}}}}}}}},a.updateId3CueEnds=function(t,e){var r,i=(r=this.id3Track)==null?void 0:r.cues;if(i)for(var n=i.length;n--;){var o=i[n];o.type===e&&o.startTime<t&&o.endTime===ke&&(o.endTime=t)}},a.onBufferFlushing=function(t,e){var r=e.startOffset,i=e.endOffset,n=e.type,o=this.id3Track,l=this.hls;if(l){var d=l.config,u=d.enableEmsgMetadataCues,h=d.enableID3MetadataCues;o&&(u||h)&&Va(o,r,i,n==="audio"?function(f){return f.type===se&&h}:n==="video"?function(f){return f.type===oe&&u}:function(f){return f.type===se&&h||f.type===oe&&u})}},a.onLevelUpdated=function(t,e){var r=this,i=e.details;if(this.media&&i.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var n=this.dateRangeCuesAppended,o=this.id3Track,l=i.dateRanges,d=Object.keys(l);if(o)for(var u=Object.keys(n).filter(function(p){return!d.includes(p)}),h=function(){var p=u[f];Object.keys(n[p].cues).forEach(function(S){o.removeCue(n[p].cues[S])}),delete n[p]},f=u.length;f--;)h();var c=i.fragments[i.fragments.length-1];if(d.length!==0&&N(c?.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var m=c.programDateTime/1e3-c.start,g=$e(),y=function(){var p=d[v],S=l[p],T=tr(S.startDate,m),R=n[p],b=R?.cues||{},L=R?.durationKnown||!1,_=ke,x=S.endDate;if(x)_=tr(x,m),L=!0;else if(S.endOnNext&&!L){var w=d.reduce(function(H,G){if(G!==S.id){var V=l[G];if(V.class===S.class&&V.startDate>S.startDate&&(!H||S.startDate<H.startDate))return V}return H},null);w&&(_=tr(w.startDate,m),L=!0)}for(var k,C,I=Object.keys(S.attr),P=0;P<I.length;P++){var O=I[P];if((C=O)!=="ID"&&C!=="CLASS"&&C!=="START-DATE"&&C!=="DURATION"&&C!=="END-DATE"&&C!=="END-ON-NEXT"){var B=b[O];if(B)L&&!R.durationKnown&&(B.endTime=_);else if(g){var F=S.attr[O];pa(O)&&(k=F,F=Uint8Array.from(k.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);var M=li(g,T,_,{key:O,data:F},Ka);M&&(M.id=p,r.id3Track.addCue(M),b[O]=M)}}}n[p]={cues:b,dateRange:S,durationKnown:L}},v=0;v<d.length;v++)y()}}},s}(),Wa=function(){function s(t){var e=this;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=function(){return e.timeupdate()},this.hls=t,this.config=t.config,this.registerListeners()}var a=s.prototype;return a.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},a.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(E.ERROR,this.onError,this)},a.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(E.ERROR,this.onError,this)},a.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},a.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},a.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},a.onLevelUpdated=function(t,e){var r=e.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},a.onError=function(t,e){var r;e.details===D.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&A.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},a.timeupdate=function(){var t=this.media,e=this.levelDetails;if(t&&e){this.currentTime=t.currentTime;var r=this.computeLatency();if(r!==null){this._latency=r;var i=this.config,n=i.lowLatencyMode,o=i.maxLiveSyncPlaybackRate;if(n&&o!==1&&e.live){var l=this.targetLatency;if(l!==null){var d=r-l;if(d<Math.min(this.maxLatency,l+e.targetduration)&&d>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,o)),h=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;t.playbackRate=Math.min(u,Math.max(1,h))}else t.playbackRate!==1&&t.playbackRate!==0&&(t.playbackRate=1)}}}}},a.estimateLiveEdge=function(){var t=this.levelDetails;return t===null?null:t.edge+t.age},a.computeLatency=function(){var t=this.estimateLiveEdge();return t===null?null:t-this.currentTime},ct(s,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config,e=this.levelDetails;return t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(t===null)return null;var e=t.holdBack,r=t.partHoldBack,i=t.targetduration,n=this.config,o=n.liveSyncDuration,l=n.liveSyncDurationCount,d=n.lowLatencyMode,u=this.hls.userConfig,h=d&&r||e;(u.liveSyncDuration||u.liveSyncDurationCount||h===0)&&(h=o!==void 0?o:l*i);var f=i;return h+Math.min(1*this.stallCount,f)}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),e=this.targetLatency,r=this.levelDetails;if(t===null||e===null||r===null)return null;var i=r.edge,n=t-e-this.edgeStalled,o=i-r.totalduration,l=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(o,n),l)}},{key:"drift",get:function(){var t=this.levelDetails;return t===null?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;if(t===null)return 0;var e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-e,0)}},{key:"forwardBufferLength",get:function(){var t=this.media,e=this.levelDetails;if(!t||!e)return 0;var r=t.buffered.length;return(r?t.buffered.end(r-1):e.edge)-this.currentTime}}]),s}(),er=["NONE","TYPE-0","TYPE-1",null],De=["SDR","PQ","HLG"],ui="",Ya="YES",qa="v2";function di(s){var a=s.canSkipUntil,t=s.canSkipDateRanges,e=s.age;return a&&e<a/2?t?qa:Ya:ui}var hi=function(){function s(a,t,e){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=a,this.part=t,this.skip=e}return s.prototype.addDirectives=function(a){var t=new self.URL(a);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},s}(),rr=function(){function s(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=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.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=[t.videoCodec,t.audioCodec].filter(function(e){return!!e}).map(function(e){return e.substring(0,4)}).join(","),this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)}var a=s.prototype;return a.hasAudioGroup=function(t){return fi(this._audioGroups,t)},a.hasSubtitleGroup=function(t){return fi(this._subtitleGroups,t)},a.addGroupId=function(t,e){if(e){if(t==="audio"){var r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(e)===-1&&r.push(e)}else if(t==="text"){var i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),i.indexOf(e)===-1&&i.push(e)}}},a.addFallback=function(){},ct(s,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"urlId",get:function(){return 0},set:function(t){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var t;return(t=this.audioGroups)==null?void 0:t[0]}},{key:"textGroupId",get:function(){var t;return(t=this.subtitleGroups)==null?void 0:t[0]}}]),s}();function fi(s,a){return!(!a||!s)&&s.indexOf(a)!==-1}function ir(s,a){var t=a.startPTS;if(N(t)){var e,r=0;a.sn>s.sn?(r=t-s.start,e=s):(r=s.start-t,e=a),e.duration!==r&&(e.duration=r)}else a.sn>s.sn?s.cc===a.cc&&s.minEndPTS?a.start=s.start+(s.minEndPTS-s.start):a.start=s.start+s.duration:a.start=Math.max(s.start-a.duration,0)}function ci(s,a,t,e,r,i){e-t<=0&&(A.warn("Fragment should have a positive duration",a),e=t+a.duration,i=r+a.duration);var n=t,o=e,l=a.startPTS,d=a.endPTS;if(N(l)){var u=Math.abs(l-t);N(a.deltaPTS)?a.deltaPTS=Math.max(u,a.deltaPTS):a.deltaPTS=u,n=Math.max(t,l),t=Math.min(t,l),r=Math.min(r,a.startDTS),o=Math.min(e,d),e=Math.max(e,d),i=Math.max(i,a.endDTS)}var h=t-a.start;a.start!==0&&(a.start=t),a.duration=e-a.start,a.startPTS=t,a.maxStartPTS=n,a.startDTS=r,a.endPTS=e,a.minEndPTS=o,a.endDTS=i;var f,c=a.sn;if(!s||c<s.startSN||c>s.endSN)return 0;var m=c-s.startSN,g=s.fragments;for(g[m]=a,f=m;f>0;f--)ir(g[f],g[f-1]);for(f=m;f<g.length-1;f++)ir(g[f],g[f+1]);return s.fragmentHint&&ir(g[g.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,h}function za(s,a){for(var t=null,e=s.fragments,r=e.length-1;r>=0;r--){var i=e[r].initSegment;if(i){t=i;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;var n,o,l,d,u,h=0;if(function(v,p,S){for(var T=p.skippedSegments,R=Math.max(v.startSN,p.startSN)-p.startSN,b=(v.fragmentHint?1:0)+(T?p.endSN:Math.min(v.endSN,p.endSN))-p.startSN,L=p.startSN-v.startSN,_=p.fragmentHint?p.fragments.concat(p.fragmentHint):p.fragments,x=v.fragmentHint?v.fragments.concat(v.fragmentHint):v.fragments,w=R;w<=b;w++){var k=x[L+w],C=_[w];T&&!C&&w<T&&(C=p.fragments[w]=k),k&&C&&S(k,C)}}(s,a,function(v,p){v.relurl&&(h=v.cc-p.cc),N(v.startPTS)&&N(v.endPTS)&&(p.start=p.startPTS=v.startPTS,p.startDTS=v.startDTS,p.maxStartPTS=v.maxStartPTS,p.endPTS=v.endPTS,p.endDTS=v.endDTS,p.minEndPTS=v.minEndPTS,p.duration=v.endPTS-v.startPTS,p.duration&&(n=p),a.PTSKnown=a.alignedSliding=!0),p.elementaryStreams=v.elementaryStreams,p.loader=v.loader,p.stats=v.stats,v.initSegment&&(p.initSegment=v.initSegment,t=v.initSegment)}),t&&(a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments).forEach(function(v){var p;!v||v.initSegment&&v.initSegment.relurl!==((p=t)==null?void 0:p.relurl)||(v.initSegment=t)}),a.skippedSegments)if(a.deltaUpdateFailed=a.fragments.some(function(v){return!v}),a.deltaUpdateFailed){A.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var f=a.skippedSegments;f--;)a.fragments.shift();a.startSN=a.fragments[0].sn,a.startCC=a.fragments[0].cc}else a.canSkipDateRanges&&(a.dateRanges=(o=s.dateRanges,l=a.dateRanges,d=a.recentlyRemovedDateranges,u=gt({},o),d&&d.forEach(function(v){delete u[v]}),Object.keys(l).forEach(function(v){var p=new Fr(l[v].attr,u[v]);p.isValid?u[v]=p:A.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(l[v].attr)+'"')}),u));var c=a.fragments;if(h){A.warn("discontinuity sliding from playlist, take drift into account");for(var m=0;m<c.length;m++)c[m].cc+=h}a.skippedSegments&&(a.startCC=a.fragments[0].cc),function(v,p,S){if(v&&p)for(var T=0,R=0,b=v.length;R<=b;R++){var L=v[R],_=p[R+T];L&&_&&L.index===_.index&&L.fragment.sn===_.fragment.sn?S(L,_):T--}}(s.partList,a.partList,function(v,p){p.elementaryStreams=v.elementaryStreams,p.stats=v.stats}),n?ci(a,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):vi(s,a),c.length&&(a.totalduration=a.edge-c[0].start),a.driftStartTime=s.driftStartTime,a.driftStart=s.driftStart;var g=a.advancedDateTime;if(a.advanced&&g){var y=a.edge;a.driftStart||(a.driftStartTime=g,a.driftStart=y),a.driftEndTime=g,a.driftEnd=y}else a.driftEndTime=s.driftEndTime,a.driftEnd=s.driftEnd,a.advancedDateTime=s.advancedDateTime}function vi(s,a){var t=a.startSN+a.skippedSegments-s.startSN,e=s.fragments;t<0||t>=e.length||function(r,i){if(i){for(var n=r.fragments,o=r.skippedSegments;o<n.length;o++)n[o].start+=i;r.fragmentHint&&(r.fragmentHint.start+=i)}}(a,e[t].start)}function gi(s,a,t){var e;return s!=null&&s.details?mi((e=s.details)==null?void 0:e.partList,a,t):null}function mi(s,a,t){if(s)for(var e=s.length;e--;){var r=s[e];if(r.index===t&&r.fragment.sn===a)return r}return null}function pi(s){s.forEach(function(a,t){var e=a.details;e!=null&&e.fragments&&e.fragments.forEach(function(r){r.level=t})})}function _e(s){switch(s.details){case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_TIMEOUT:case D.LEVEL_LOAD_TIMEOUT:case D.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function yi(s,a){var t=_e(a);return s.default[(t?"timeout":"error")+"Retry"]}function ar(s,a){var t=s.backoff==="linear"?1:Math.pow(2,a);return Math.min(t*s.retryDelayMs,s.maxRetryDelayMs)}function Ei(s){return yt(yt({},s),{errorRetry:null,timeoutRetry:null})}function we(s,a,t,e){if(!s)return!1;var r=e?.code,i=a<s.maxNumRetry&&(function(n){return n===0&&navigator.onLine===!1||!!n&&(n<400||n>499)}(r)||!!t);return s.shouldRetry?s.shouldRetry(s,a,t,e,i):i}var Ti=function(s,a){for(var t=0,e=s.length-1,r=null,i=null;t<=e;){var n=a(i=s[r=(t+e)/2|0]);if(n>0)t=r+1;else{if(!(n<0))return i;e=r-1}}return null};function Si(s,a,t,e){t===void 0&&(t=0),e===void 0&&(e=0);var r=null;if(s){r=a[s.sn-a[0].sn+1]||null;var i=s.endDTS-t;i>0&&i<15e-7&&(t+=15e-7)}else t===0&&a[0].start===0&&(r=a[0]);if(r&&(!s||s.level===r.level)&&Li(t,e,r)===0)return r;var n=Ti(a,Li.bind(null,t,e));return!n||n===s&&r?r:n}function Li(s,a,t){if(s===void 0&&(s=0),a===void 0&&(a=0),t.start<=s&&t.start+t.duration>s)return 0;var e=Math.min(a,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-e<=s?1:t.start-e>s&&t.start?-1:0}function Xa(s,a,t){var e=1e3*Math.min(a,t.duration+(t.deltaPTS?t.deltaPTS:0));return(t.endProgramDateTime||0)-e>s}var nr=0,Ct=2,Qa=3,xe=5,Xt=0,sr=1,Ri=2,Za=function(){function s(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=A.log.bind(A,"[info]:"),this.warn=A.warn.bind(A,"[warning]:"),this.error=A.error.bind(A,"[error]:"),this.registerListeners()}var a=s.prototype;return a.registerListeners=function(){var t=this.hls;t.on(E.ERROR,this.onError,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)},a.unregisterListeners=function(){var t=this.hls;t&&(t.off(E.ERROR,this.onError,this),t.off(E.ERROR,this.onErrorOut,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.LEVEL_UPDATED,this.onLevelUpdated,this))},a.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},a.startLoad=function(t){},a.stopLoad=function(){this.playlistError=0},a.getVariantLevelIndex=function(t){return t?.type===at?t.level:this.hls.loadLevel},a.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},a.onLevelUpdated=function(){this.playlistError=0},a.onError=function(t,e){var r,i;if(!e.fatal){var n=this.hls,o=e.context;switch(e.details){case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case D.FRAG_PARSING_ERROR:if((r=e.frag)!=null&&r.gap)return void(e.errorAction={action:nr,flags:Xt});case D.FRAG_GAP:case D.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=Ct);case D.LEVEL_EMPTY_ERROR:case D.LEVEL_PARSING_ERROR:var l,d,u=e.parent===at?e.level:n.loadLevel;return void(e.details===D.LEVEL_EMPTY_ERROR&&(l=e.context)!=null&&(d=l.levelDetails)!=null&&d.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,u):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,u)));case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:return void(typeof o?.level=="number"&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o.level)));case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.SUBTITLE_LOAD_ERROR:case D.SUBTITLE_TRACK_LOAD_TIMEOUT:if(o){var h=n.levels[n.loadLevel];if(h&&(o.type===wt&&h.hasAudioGroup(o.groupId)||o.type===xt&&h.hasSubtitleGroup(o.groupId)))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,n.loadLevel),e.errorAction.action=Ct,void(e.errorAction.flags=sr)}return;case D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var f=n.levels[n.loadLevel],c=f?.attrs["HDCP-LEVEL"];return void(c?e.errorAction={action:Ct,flags:Ri,hdcpLevel:c}:this.keySystemError(e));case D.BUFFER_ADD_CODEC_ERROR:case D.REMUX_ALLOC_ERROR:case D.BUFFER_APPEND_ERROR:return void(e.errorAction=this.getLevelSwitchAction(e,(i=e.level)!=null?i:n.loadLevel));case D.INTERNAL_EXCEPTION:case D.BUFFER_APPENDING_ERROR:case D.BUFFER_FULL_ERROR:case D.LEVEL_SWITCH_ERROR:case D.BUFFER_STALLED_ERROR:case D.BUFFER_SEEK_OVER_HOLE:case D.BUFFER_NUDGE_ON_STALL:return void(e.errorAction={action:nr,flags:Xt})}e.type===W.KEY_SYSTEM_ERROR&&this.keySystemError(e)}},a.keySystemError=function(t){var e=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e)},a.getPlaylistRetryOrSwitchAction=function(t,e){var r=yi(this.hls.config.playlistLoadPolicy,t),i=this.playlistError++;if(we(r,i,_e(t),t.response))return{action:xe,flags:Xt,retryConfig:r,retryCount:i};var n=this.getLevelSwitchAction(t,e);return r&&(n.retryConfig=r,n.retryCount=i),n},a.getFragRetryOrSwitchAction=function(t){var e=this.hls,r=this.getVariantLevelIndex(t.frag),i=e.levels[r],n=e.config,o=n.fragLoadPolicy,l=n.keyLoadPolicy,d=yi(t.details.startsWith("key")?l:o,t),u=e.levels.reduce(function(f,c){return f+c.fragmentError},0);if(i&&(t.details!==D.FRAG_GAP&&i.fragmentError++,we(d,u,_e(t),t.response)))return{action:xe,flags:Xt,retryConfig:d,retryCount:u};var h=this.getLevelSwitchAction(t,r);return d&&(h.retryConfig=d,h.retryCount=u),h},a.getLevelSwitchAction=function(t,e){var r=this.hls;e==null&&(e=r.loadLevel);var i=this.hls.levels[e];if(i){var n,o,l=t.details;i.loadError++,l===D.BUFFER_APPEND_ERROR&&i.fragmentError++;var d=-1,u=r.levels,h=r.loadLevel,f=r.minAutoLevel,c=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var m,g=(n=t.frag)==null?void 0:n.type,y=(g===ne&&l===D.FRAG_PARSING_ERROR||t.sourceBufferName==="audio"&&(l===D.BUFFER_ADD_CODEC_ERROR||l===D.BUFFER_APPEND_ERROR))&&u.some(function(L){var _=L.audioCodec;return i.audioCodec!==_}),v=t.sourceBufferName==="video"&&(l===D.BUFFER_ADD_CODEC_ERROR||l===D.BUFFER_APPEND_ERROR)&&u.some(function(L){var _=L.codecSet,x=L.audioCodec;return i.codecSet!==_&&i.audioCodec===x}),p=(o=t.context)!=null?o:{},S=p.type,T=p.groupId,R=function(){var L=(b+h)%u.length;if(L!==h&&L>=f&&L<=c&&u[L].loadError===0){var _,x,w=u[L];if(l===D.FRAG_GAP&&t.frag){var k=u[L].details;if(k){var C=Si(t.frag,k.fragments,t.frag.start);if(C!=null&&C.gap)return 0}}else if(S===wt&&w.hasAudioGroup(T)||S===xt&&w.hasSubtitleGroup(T)||g===ne&&(_=i.audioGroups)!=null&&_.some(function(I){return w.hasAudioGroup(I)})||g===Ze&&(x=i.subtitleGroups)!=null&&x.some(function(I){return w.hasSubtitleGroup(I)})||y&&i.audioCodec===w.audioCodec||!y&&i.audioCodec!==w.audioCodec||v&&i.codecSet===w.codecSet)return 0;return d=L,1}},b=u.length;b--&&((m=R())===0||m!==1););if(d>-1&&r.loadLevel!==d)return t.levelRetry=!0,this.playlistError=0,{action:Ct,flags:Xt,nextAutoLevel:d}}return{action:Ct,flags:sr}},a.onErrorOut=function(t,e){var r;switch((r=e.errorAction)==null?void 0:r.action){case nr:break;case Ct:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===D.FRAG_GAP?/MediaSource readyState: ended/.test(e.error.message)&&(this.warn('MediaSource ended after "'+e.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError()):e.fatal=!0}e.fatal&&this.hls.stopLoad()},a.sendAlternateToPenaltyBox=function(t){var e=this.hls,r=t.errorAction;if(r){var i=r.flags,n=r.hdcpLevel,o=r.nextAutoLevel;switch(i){case Xt:this.switchLevel(t,o);break;case Ri:n&&(e.maxHdcpLevel=er[er.indexOf(n)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+e.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(t,o)}},a.switchLevel=function(t,e){e!==void 0&&t.errorAction&&(this.warn("switching to level "+e+" after "+t.details),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},s}(),Ja=function(){function s(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=A.log.bind(A,e+":"),this.warn=A.warn.bind(A,e+":"),this.hls=t}var a=s.prototype;return a.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},a.clearTimer=function(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)},a.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},a.stopLoad=function(){this.canLoad=!1,this.clearTimer()},a.switchParams=function(t,e,r){var i=e?.renditionReports;if(i){for(var n=-1,o=0;o<i.length;o++){var l=i[o],d=void 0;try{d=new self.URL(l.URI,e.url).href}catch(g){A.warn("Could not construct new URL for Rendition Report: "+g),d=l.URI||""}if(d===t){n=o;break}d===t.substring(0,d.length)&&(n=o)}if(n!==-1){var u=i[n],h=parseInt(u["LAST-MSN"])||e?.lastPartSn,f=parseInt(u["LAST-PART"])||e?.lastPartIndex;if(this.hls.config.lowLatencyMode){var c=Math.min(e.age-e.partTarget,e.targetduration);f>=0&&c>e.partTarget&&(f+=1)}var m=r&&di(r);return new hi(h,f>=0?f:void 0,m)}}},a.loadPlaylist=function(t){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},a.shouldLoadPlaylist=function(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)},a.shouldReloadPlaylist=function(t){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(t)},a.playlistLoaded=function(t,e,r){var i=this,n=e.details,o=e.stats,l=self.performance.now(),d=o.loading.first?Math.max(0,l-o.loading.first):0;if(n.advancedDateTime=Date.now()-d,n.live||r!=null&&r.live){if(n.reloaded(r),r&&this.log("live playlist "+t+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED")),r&&n.fragments.length>0&&za(r,n),!this.canLoad||!n.live)return;var u,h=void 0,f=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var c=this.hls.config.lowLatencyMode,m=n.lastPartSn,g=n.endSN,y=n.lastPartIndex,v=m===g;y!==-1?(h=v?g+1:m,f=v?c?0:y:y+1):h=g+1;var p=n.age,S=p+n.ageHeader,T=Math.min(S-n.partTarget,1.5*n.targetduration);if(T>0){if(r&&T>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+T+" with playlist age: "+n.age),T=0;else{var R=Math.floor(T/n.targetduration);h+=R,f!==void 0&&(f+=Math.round(T%n.targetduration/n.partTarget)),this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+p.toFixed(2)+"s goal: "+T+" skip sn "+R+" to part "+f)}n.tuneInGoal=T}if(u=this.getDeliveryDirectives(n,e.deliveryDirectives,h,f),c||!v)return void this.loadPlaylist(u)}else(n.canBlockReload||n.canSkipUntil)&&(u=this.getDeliveryDirectives(n,e.deliveryDirectives,h,f));var b=this.hls.mainForwardBufferInfo,L=b?b.end-b.len:0,_=function(w,k){k===void 0&&(k=1/0);var C=1e3*w.targetduration;if(w.updated){var I=w.fragments;if(I.length&&4*C>k){var P=1e3*I[I.length-1].duration;P<C&&(C=P)}}else C/=2;return Math.round(C)}(n,1e3*(n.edge-L));n.updated&&l>this.requestScheduled+_&&(this.requestScheduled=o.loading.start),h!==void 0&&n.canBlockReload?this.requestScheduled=o.loading.first+_-(1e3*n.partTarget||1e3):this.requestScheduled===-1||this.requestScheduled+_<l?this.requestScheduled=l:this.requestScheduled-l<=0&&(this.requestScheduled+=_);var x=this.requestScheduled-l;x=Math.max(0,x),this.log("reload live playlist "+t+" in "+Math.round(x)+" ms"),this.timer=self.setTimeout(function(){return i.loadPlaylist(u)},x)}else this.clearTimer()},a.getDeliveryDirectives=function(t,e,r,i){var n=di(t);return e!=null&&e.skip&&t.deltaUpdateFailed&&(r=e.msn,i=e.part,n=ui),new hi(r,i,n)},a.checkRetry=function(t){var e=this,r=t.details,i=_e(t),n=t.errorAction,o=n||{},l=o.action,d=o.retryCount,u=d===void 0?0:d,h=o.retryConfig,f=!!n&&!!h&&(l===xe||!n.resolved&&l===Ct);if(f){var c;if(this.requestScheduled=-1,u>=h.maxNumRetry)return!1;if(i&&(c=t.context)!=null&&c.deliveryDirectives)this.warn("Retrying playlist loading "+(u+1)+"/"+h.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var m=ar(h,u);this.timer=self.setTimeout(function(){return e.loadPlaylist()},m),this.warn("Retrying playlist loading "+(u+1)+"/"+h.maxNumRetry+' after "'+r+'" in '+m+"ms")}t.levelRetry=!0,n.resolved=!0}return f},s}(),Qt=function(){function s(t,e,r){e===void 0&&(e=0),r===void 0&&(r=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_=r}var a=s.prototype;return a.sample=function(t,e){var r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t},a.getTotalWeight=function(){return this.totalWeight_},a.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},s}(),$a=function(){function s(t,e,r,i){i===void 0&&(i=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Qt(t),this.fast_=new Qt(e),this.defaultTTFB_=i,this.ttfb_=new Qt(t)}var a=s.prototype;return a.update=function(t,e){var r=this.slow_,i=this.fast_,n=this.ttfb_;r.halfLife!==t&&(this.slow_=new Qt(t,r.getEstimate(),r.getTotalWeight())),i.halfLife!==e&&(this.fast_=new Qt(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==t&&(this.ttfb_=new Qt(t,n.getEstimate(),n.getTotalWeight()))},a.sample=function(t,e){var r=(t=Math.max(t,this.minDelayMs_))/1e3,i=8*e/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},a.sampleTTFB=function(t){var e=t/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(r,Math.max(t,5))},a.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},a.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},a.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},a.destroy=function(){},s}();function tn(s,a){var t=!1,e=[];return s&&(t=s!=="SDR",e=[s]),a&&(e=a.allowedVideoRanges||De.slice(0),e=(t=a.preferHDR!==void 0?a.preferHDR:function(){if(typeof matchMedia=="function"){var r=matchMedia("(dynamic-range: high)"),i=matchMedia("bad query");if(r.media!==i.media)return r.matches===!0}return!1}())?e.filter(function(r){return r!=="SDR"}):["SDR"]),{preferHDR:t,allowedVideoRanges:e}}function It(s,a){A.log('[abr] start candidates with "'+s+'" ignored because '+a)}var en=function(){function s(t){var e=this;this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=function(){var r=e.fragCurrent,i=e.partCurrent,n=e.hls,o=n.autoLevelEnabled,l=n.media;if(r&&l){var d=performance.now(),u=i?i.stats:r.stats,h=i?i.duration:r.duration,f=d-u.loading.start,c=n.minAutoLevel;if(u.aborted||u.loaded&&u.loaded===u.total||r.level<=c)return e.clearTimer(),void(e._nextAutoLevel=-1);if(o&&!l.paused&&l.playbackRate&&l.readyState){var m=n.mainForwardBufferInfo;if(m!==null){var g=e.bwEstimator.getEstimateTTFB(),y=Math.abs(l.playbackRate);if(!(f<=Math.max(g,h/(2*y)*1e3))){var v=m.len/y,p=u.loading.first?u.loading.first-u.loading.start:-1,S=u.loaded&&p>-1,T=e.getBwEstimate(),R=n.levels,b=R[r.level],L=u.total||Math.max(u.loaded,Math.round(h*b.averageBitrate/8)),_=S?f-p:f;_<1&&S&&(_=Math.min(f,8*u.loaded/T));var x=S?1e3*u.loaded/_:0,w=x?(L-u.loaded)/x:8*L/T+g/1e3;if(!(w<=v)){var k,C=x?8*x:T,I=Number.POSITIVE_INFINITY;for(k=r.level-1;k>c;k--){var P=R[k].maxBitrate;if((I=e.getTimeToLoadFrag(g/1e3,C,h*P,!R[k].details))<v)break}if(!(I>=w||I>10*h)){n.nextLoadLevel=n.nextAutoLevel=k,S?e.bwEstimator.sample(f-Math.min(g,p),u.loaded):e.bwEstimator.sampleTTFB(f);var O=R[k].maxBitrate;e.getBwEstimate()*e.hls.config.abrBandWidthUpFactor>O&&e.resetEstimator(O),e.clearTimer(),A.warn("[abr] Fragment "+r.sn+(i?" part "+i.index:"")+" of level "+r.level+` is loading too slowly;
|
2
|
-
Time to underbuffer:
|
3
|
-
Estimated load time for current fragment:
|
4
|
-
Estimated load time for down switch fragment:
|
5
|
-
TTFB estimate:
|
6
|
-
Current BW estimate:
|
7
|
-
New BW estimate:
|
8
|
-
Switching to level `+k+" @ "+(0|O)+" bps"),n.trigger(E.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:i,stats:u})}}}}}}},this.hls=t,this.bwEstimator=this.initEstimator(),this.registerListeners()}var a=s.prototype;return a.resetEstimator=function(t){t&&(A.log("setting initial bwe to "+t),this.hls.config.abrEwmaDefaultEstimate=t),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},a.initEstimator=function(){var t=this.hls.config;return new $a(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate)},a.registerListeners=function(){var t=this.hls;t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.FRAG_LOADING,this.onFragLoading,this),t.on(E.FRAG_LOADED,this.onFragLoaded,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this),t.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.on(E.ERROR,this.onError,this)},a.unregisterListeners=function(){var t=this.hls;t&&(t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.FRAG_LOADING,this.onFragLoading,this),t.off(E.FRAG_LOADED,this.onFragLoaded,this),t.off(E.FRAG_BUFFERED,this.onFragBuffered,this),t.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.off(E.ERROR,this.onError,this))},a.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},a.onManifestLoading=function(t,e){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},a.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},a.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},a.onFragLoading=function(t,e){var r,i=e.frag;this.ignoreFragment(i)||(i.bitrateTest||(this.fragCurrent=i,this.partCurrent=(r=e.part)!=null?r:null),this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100))},a.onLevelSwitching=function(t,e){this.clearTimer()},a.onError=function(t,e){if(!e.fatal)switch(e.details){case D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case D.FRAG_LOAD_TIMEOUT:var r=e.frag,i=this.fragCurrent,n=this.partCurrent;if(r&&i&&r.sn===i.sn&&r.level===i.level){var o=performance.now(),l=n?n.stats:r.stats,d=o-l.loading.start,u=l.loading.first?l.loading.first-l.loading.start:-1;if(l.loaded&&u>-1){var h=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(d-Math.min(h,u),l.loaded)}else this.bwEstimator.sampleTTFB(d)}}},a.getTimeToLoadFrag=function(t,e,r,i){return t+r/e+(i?this.lastLevelLoadSec:0)},a.onLevelLoaded=function(t,e){var r=this.hls.config,i=e.stats.loading,n=i.end-i.start;N(n)&&(this.lastLevelLoadSec=n/1e3),e.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},a.onFragLoaded=function(t,e){var r=e.frag,i=e.part,n=i?i.stats:r.stats;if(r.type===at&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var o=i?i.duration:r.duration,l=this.hls.levels[r.level],d=(l.loaded?l.loaded.bytes:0)+n.loaded,u=(l.loaded?l.loaded.duration:0)+o;l.loaded={bytes:d,duration:u},l.realBitrate=Math.round(8*d/u)}if(r.bitrateTest){var h={stats:n,frag:r,part:i,id:r.type};this.onFragBuffered(E.FRAG_BUFFERED,h),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}},a.onFragBuffered=function(t,e){var r=e.frag,i=e.part,n=i!=null&&i.stats.loaded?i.stats:r.stats;if(!n.aborted&&!this.ignoreFragment(r)){var o=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(o,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=o/1e3:this.bitrateTestDelay=0}},a.ignoreFragment=function(t){return t.type!==at||t.sn==="initSegment"},a.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},a.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},a.getNextABRAutoLevel=function(){var t=this.fragCurrent,e=this.partCurrent,r=this.hls,i=r.maxAutoLevel,n=r.config,o=r.minAutoLevel,l=e?e.duration:t?t.duration:0,d=this.getBwEstimate(),u=this.getStarvationDelay(),h=n.abrBandWidthFactor,f=n.abrBandWidthUpFactor;if(u){var c=this.findBestLevel(d,o,i,u,0,h,f);if(c>=0)return c}var m=l?Math.min(l,n.maxStarvationDelay):n.maxStarvationDelay;if(!u){var g=this.bitrateTestDelay;g&&(m=(l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay)-g,A.info("[abr] bitrate test took "+Math.round(1e3*g)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*m)+" ms"),h=f=1)}var y=this.findBestLevel(d,o,i,u,m,h,f);if(A.info("[abr] "+(u?"rebuffering expected":"buffer is empty")+", optimal quality level "+y),y>-1)return y;var v=r.levels[o],p=r.levels[r.loadLevel];return v?.bitrate<p?.bitrate?o:r.loadLevel},a.getStarvationDelay=function(){var t=this.hls,e=t.media;if(!e)return 1/0;var r=e&&e.playbackRate!==0?Math.abs(e.playbackRate):1,i=t.mainForwardBufferInfo;return(i?i.len:0)/r},a.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},a.findBestLevel=function(t,e,r,i,n,o,l){var d,u=this,h=i+n,f=this.lastLoadedFragLevel,c=f===-1?this.hls.firstLevel:f,m=this.fragCurrent,g=this.partCurrent,y=this.hls,v=y.levels,p=y.allAudioTracks,S=y.loadLevel,T=y.config;if(v.length===1)return 0;var R,b=v[c],L=!(b==null||(d=b.details)==null||!d.live),_=S===-1||f===-1,x="SDR",w=b?.frameRate||0,k=T.audioPreference,C=T.videoPreference;if(this.audioTracksByGroup||(this.audioTracksByGroup=function(et){return et.reduce(function(z,Z){var j=z.groups[Z.groupId];j||(j=z.groups[Z.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),j.tracks.push(Z);var q=Z.channels||"2";return j.channels[q]=(j.channels[q]||0)+1,j.hasDefault=j.hasDefault||Z.default,j.hasAutoSelect=j.hasAutoSelect||Z.autoselect,j.hasDefault&&(z.hasDefaultAudio=!0),j.hasAutoSelect&&(z.hasAutoSelectAudio=!0),z},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}(p)),_){if(this.firstSelection!==-1)return this.firstSelection;var I=this.codecTiers||(this.codecTiers=function(et,z,Z,j){return et.slice(Z,j+1).reduce(function(q,J){if(!J.codecSet)return q;var X=J.audioGroups,Y=q[J.codecSet];Y||(q[J.codecSet]=Y={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!X,fragmentError:0}),Y.minBitrate=Math.min(Y.minBitrate,J.bitrate);var mt=Math.min(J.height,J.width);return Y.minHeight=Math.min(Y.minHeight,mt),Y.minFramerate=Math.min(Y.minFramerate,J.frameRate),Y.maxScore=Math.max(Y.maxScore,J.score),Y.fragmentError+=J.fragmentError,Y.videoRanges[J.videoRange]=(Y.videoRanges[J.videoRange]||0)+1,q},{})}(v,0,e,r)),P=function(et,z,Z,j,q){for(var J=Object.keys(et),X=j?.channels,Y=j?.audioCodec,mt=X&&parseInt(X)===2,Mt=!0,Nt=!1,Rt=1/0,pt=1/0,Et=1/0,_t=0,vt=[],ve=tn(z,q),te=ve.preferHDR,Rr=ve.allowedVideoRanges,ge=function(){var Q=et[J[Me]];Mt=Q.channels[2]>0,Rt=Math.min(Rt,Q.minHeight),pt=Math.min(pt,Q.minFramerate),Et=Math.min(Et,Q.minBitrate);var st=Rr.filter(function(ot){return Q.videoRanges[ot]>0});st.length>0&&(Nt=!0,vt=st)},Me=J.length;Me--;)ge();Rt=N(Rt)?Rt:0,pt=N(pt)?pt:0;var me=Math.max(1080,Rt),ee=Math.max(30,pt);return Et=N(Et)?Et:Z,Z=Math.max(Et,Z),Nt||(z=void 0,vt=[]),{codecSet:J.reduce(function(Q,st){var ot=et[st];if(st===Q)return Q;if(ot.minBitrate>Z)return It(st,"min bitrate of "+ot.minBitrate+" > current estimate of "+Z),Q;if(!ot.hasDefaultAudio)return It(st,"no renditions with default or auto-select sound found"),Q;if(Y&&st.indexOf(Y.substring(0,4))%5!=0)return It(st,'audio codec preference "'+Y+'" not found'),Q;if(X&&!mt){if(!ot.channels[X])return It(st,"no renditions with "+X+" channel sound found (channels options: "+Object.keys(ot.channels)+")"),Q}else if((!Y||mt)&&Mt&&ot.channels[2]===0)return It(st,"no renditions with stereo sound found"),Q;return ot.minHeight>me?(It(st,"min resolution of "+ot.minHeight+" > maximum of "+me),Q):ot.minFramerate>ee?(It(st,"min framerate of "+ot.minFramerate+" > maximum of "+ee),Q):vt.some(function(Ar){return ot.videoRanges[Ar]>0})?ot.maxScore<_t?(It(st,"max score of "+ot.maxScore+" < selected max of "+_t),Q):Q&&(Ae(st)>=Ae(Q)||ot.fragmentError>et[Q].fragmentError)?Q:(_t=ot.maxScore,st):(It(st,"no variants with VIDEO-RANGE of "+JSON.stringify(vt)+" found"),Q)},void 0),videoRanges:vt,preferHDR:te,minFramerate:pt,minBitrate:Et}}(I,x,t,k,C),O=P.codecSet,B=P.videoRanges,F=P.minFramerate,M=P.minBitrate,H=P.preferHDR;R=O,x=H?B[B.length-1]:B[0],w=F,t=Math.max(t,M),A.log("[abr] picked start tier "+JSON.stringify(P))}else R=b?.codecSet,x=b?.videoRange;for(var G,V=g?g.duration:m?m.duration:0,$=this.bwEstimator.getEstimateTTFB()/1e3,nt=[],rt=function(){var et,z=v[tt],Z=tt>c;if(!z)return 0;if(R&&z.codecSet!==R||x&&z.videoRange!==x||Z&&w>z.frameRate||!Z&&w>0&&w<z.frameRate||z.supportedResult&&((et=z.supportedResult.decodingInfoResults)==null||!et[0].smooth))return nt.push(tt),0;var j,q=z.details,J=(g?q?.partTarget:q?.averagetargetduration)||V;j=Z?l*t:o*t;var X=V&&i>=2*V&&n===0?v[tt].averageBitrate:v[tt].maxBitrate,Y=u.getTimeToLoadFrag($,j,X*J,q===void 0);if(j>=X&&(tt===f||z.loadError===0&&z.fragmentError===0)&&(Y<=$||!N(Y)||L&&!u.bitrateTestDelay||Y<h)){var mt=u.forcedAutoLevel;return tt===S||mt!==-1&&mt===S||(nt.length&&A.trace("[abr] Skipped level(s) "+nt.join(",")+" of "+r+' max with CODECS and VIDEO-RANGE:"'+v[nt[0]].codecs+'" '+v[nt[0]].videoRange+'; not compatible with "'+b.codecs+'" '+x),A.info("[abr] switch candidate:"+c+"->"+tt+" adjustedbw("+Math.round(j)+")-bitrate="+Math.round(j-X)+" ttfb:"+$.toFixed(1)+" avgDuration:"+J.toFixed(1)+" maxFetchDuration:"+h.toFixed(1)+" fetchDuration:"+Y.toFixed(1)+" firstSelection:"+_+" codecSet:"+R+" videoRange:"+x+" hls.loadLevel:"+S)),_&&(u.firstSelection=tt),{v:tt}}},tt=r;tt>=e;tt--)if((G=rt())!==0&&G)return G.v;return-1},ct(s,[{key:"firstAutoLevel",get:function(){var t=this.hls,e=t.maxAutoLevel,r=t.minAutoLevel,i=this.getBwEstimate(),n=this.hls.config.maxStarvationDelay,o=this.findBestLevel(i,r,e,0,n,1,1);if(o>-1)return o;var l=this.hls.firstLevel,d=Math.min(Math.max(l,r),e);return A.warn("[abr] Could not find best starting auto level. Defaulting to first in playlist "+l+" clamped to "+d),d}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var t=this.forcedAutoLevel,e=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(t===-1||e&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return t;var i=e&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(t!==-1){var n=this.hls.levels;if(n.length>Math.max(t,i)&&n[t].loadError<=n[i].loadError)return t}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i},set:function(t){var e=this.hls,r=e.maxAutoLevel,i=e.minAutoLevel,n=Math.min(Math.max(t,i),r);this._nextAutoLevel!==n&&(this.nextAutoLevelKey="",this._nextAutoLevel=n)}}]),s}(),rn={length:0,start:function(){return 0},end:function(){return 0}},ut=function(){function s(){}return s.isBuffered=function(a,t){try{if(a){for(var e=s.getBuffered(a),r=0;r<e.length;r++)if(t>=e.start(r)&&t<=e.end(r))return!0}}catch{}return!1},s.bufferInfo=function(a,t,e){try{if(a){var r,i=s.getBuffered(a),n=[];for(r=0;r<i.length;r++)n.push({start:i.start(r),end:i.end(r)});return this.bufferedInfo(n,t,e)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}},s.bufferedInfo=function(a,t,e){t=Math.max(0,t),a.sort(function(g,y){var v=g.start-y.start;return v||y.end-g.end});var r=[];if(e)for(var i=0;i<a.length;i++){var n=r.length;if(n){var o=r[n-1].end;a[i].start-o<e?a[i].end>o&&(r[n-1].end=a[i].end):r.push(a[i])}else r.push(a[i])}else r=a;for(var l,d=0,u=t,h=t,f=0;f<r.length;f++){var c=r[f].start,m=r[f].end;if(t+e>=c&&t<m)u=c,d=(h=m)-t;else if(t+e<c){l=c;break}}return{len:d,start:u||0,end:h||0,nextStart:l}},s.getBuffered=function(a){try{return a.buffered}catch(t){return A.log("failed to get media.buffered",t),rn}},s}(),an=function(){function s(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}var a=s.prototype;return a.append=function(t,e,r){var i=this.queues[e];i.push(t),i.length!==1||r||this.executeNext(e)},a.insertAbort=function(t,e){this.queues[e].unshift(t),this.executeNext(e)},a.appendBlocker=function(t){var e,r=new Promise(function(n){e=n}),i={execute:e,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,t),r},a.executeNext=function(t){var e=this.queues[t];if(e.length){var r=e[0];try{r.execute()}catch(n){A.warn('[buffer-operation-queue]: Exception executing "'+t+'" SourceBuffer operation: '+n),r.onError(n);var i=this.buffers[t];i!=null&&i.updating||this.shiftAndExecuteNext(t)}}},a.shiftAndExecuteNext=function(t){this.queues[t].shift(),this.executeNext(t)},a.current=function(t){return this.queues[t][0]},s}(),Ai=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,nn=function(){function s(t){var e=this;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.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=function(n){e.hls&&e.hls.pauseBuffering()},this._onStartStreaming=function(n){e.hls&&e.hls.resumeBuffering()},this._onMediaSourceOpen=function(){var n=e.media,o=e.mediaSource;e.log("Media source opened"),n&&(n.removeEventListener("emptied",e._onMediaEmptied),e.updateMediaElementDuration(),e.hls.trigger(E.MEDIA_ATTACHED,{media:n,mediaSource:o})),o&&o.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){e.log("Media source closed")},this._onMediaSourceEnded=function(){e.log("Media source ended")},this._onMediaEmptied=function(){var n=e.mediaSrc,o=e._objectUrl;n!==o&&A.error("Media element src was set while attaching MediaSource ("+o+" > "+n+")")},this.hls=t;var r,i="[buffer-controller]";this.appendSource=(r=Kt(t.config.preferManagedMediaSource),typeof self<"u"&&r===self.ManagedMediaSource),this.log=A.log.bind(A,i),this.warn=A.warn.bind(A,i),this.error=A.error.bind(A,i),this._initSourceBuffer(),this.registerListeners()}var a=s.prototype;return a.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},a.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null},a.registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.BUFFER_RESET,this.onBufferReset,this),t.on(E.BUFFER_APPENDING,this.onBufferAppending,this),t.on(E.BUFFER_CODECS,this.onBufferCodecs,this),t.on(E.BUFFER_EOS,this.onBufferEos,this),t.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(E.FRAG_PARSED,this.onFragParsed,this),t.on(E.FRAG_CHANGED,this.onFragChanged,this)},a.unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.BUFFER_RESET,this.onBufferReset,this),t.off(E.BUFFER_APPENDING,this.onBufferAppending,this),t.off(E.BUFFER_CODECS,this.onBufferCodecs,this),t.off(E.BUFFER_EOS,this.onBufferEos,this),t.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(E.FRAG_PARSED,this.onFragParsed,this),t.off(E.FRAG_CHANGED,this.onFragChanged,this)},a._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new an(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null},a.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},a.onManifestParsed=function(t,e){var r=2;e.audio&&!e.video||e.altAudio,r=1,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},a.onMediaAttaching=function(t,e){var r=this.media=e.media,i=Kt(this.appendSource);if(r&&i){var n,o=this.mediaSource=new i;this.log("created media source: "+((n=o.constructor)==null?void 0:n.name)),o.addEventListener("sourceopen",this._onMediaSourceOpen),o.addEventListener("sourceended",this._onMediaSourceEnded),o.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(o.addEventListener("startstreaming",this._onStartStreaming),o.addEventListener("endstreaming",this._onEndStreaming));var l=this._objectUrl=self.URL.createObjectURL(o);if(this.appendSource)try{r.removeAttribute("src");var d=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||d&&o instanceof d,bi(r),function(u,h){var f=self.document.createElement("source");f.type="video/mp4",f.src=h,u.appendChild(f)}(r,l),r.load()}catch{r.src=l}else r.src=l;r.addEventListener("emptied",this._onMediaEmptied)}},a.onMediaDetaching=function(){var t=this.media,e=this.mediaSource,r=this._objectUrl;if(e){if(this.log("media source detaching"),e.readyState==="open")try{e.endOfStream()}catch(i){this.warn("onMediaDetaching: "+i.message+" while calling endOfStream")}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.removeEventListener("startstreaming",this._onStartStreaming),e.removeEventListener("endstreaming",this._onEndStreaming)),t&&(t.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(t.removeAttribute("src"),this.appendSource&&bi(t),t.load()):this.warn("media|source.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(E.MEDIA_DETACHED,void 0)},a.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach(function(e){t.resetBuffer(e)}),this._initSourceBuffer()},a.resetBuffer=function(t){var e=this.sourceBuffer[t];try{var r;e&&(this.removeBufferListeners(t),this.sourceBuffer[t]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(e))}catch(i){this.warn("onBufferReset "+t,i)}},a.onBufferCodecs=function(t,e){var r=this,i=this.getSourceBufferTypes().length,n=Object.keys(e);if(n.forEach(function(l){if(i){var d=r.tracks[l];if(d&&typeof d.buffer.changeType=="function"){var u,h=e[l],f=h.id,c=h.codec,m=h.levelCodec,g=h.container,y=h.metadata,v=Zr(d.codec,d.levelCodec),p=v?.replace(Ai,"$1"),S=Zr(c,m),T=(u=S)==null?void 0:u.replace(Ai,"$1");if(S&&p!==T){l.slice(0,5)==="audio"&&(S=be(S,r.appendSource));var R=g+";codecs="+S;r.appendChangeType(l,R),r.log("switching codec "+v+" to "+S),r.tracks[l]={buffer:d.buffer,codec:c,container:g,levelCodec:m,metadata:y,id:f}}}}else r.pendingTracks[l]=e[l]}),!i){var o=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==o&&(this.log(o+" bufferCodec event(s) expected "+n.join(",")),this.bufferCodecEventsExpected=o),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}},a.appendChangeType=function(t,e){var r=this,i=this.operationQueue,n={execute:function(){var o=r.sourceBuffer[t];o&&(r.log("changing "+t+" sourceBuffer type to "+e),o.changeType(e)),i.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(o){r.warn("Failed to change "+t+" SourceBuffer type",o)}};i.append(n,t,!!this.pendingTracks[t])},a.onBufferAppending=function(t,e){var r=this,i=this.hls,n=this.operationQueue,o=this.tracks,l=e.data,d=e.type,u=e.frag,h=e.part,f=e.chunkMeta,c=f.buffering[d],m=self.performance.now();c.start=m;var g=u.stats.buffering,y=h?h.stats.buffering:null;g.start===0&&(g.start=m),y&&y.start===0&&(y.start=m);var v=o.audio,p=!1;d==="audio"&&v?.container==="audio/mpeg"&&(p=!this.lastMpegAudioChunk||f.id===1||this.lastMpegAudioChunk.sn!==f.sn,this.lastMpegAudioChunk=f);var S=u.start,T={execute:function(){if(c.executeStart=self.performance.now(),p){var R=r.sourceBuffer[d];if(R){var b=S-R.timestampOffset;Math.abs(b)>=.1&&(r.log("Updating audio SourceBuffer timestampOffset to "+S+" (delta: "+b+") sn: "+u.sn+")"),R.timestampOffset=S)}}r.appendExecutor(l,d)},onStart:function(){},onComplete:function(){var R=self.performance.now();c.executeEnd=c.end=R,g.first===0&&(g.first=R),y&&y.first===0&&(y.first=R);var b=r.sourceBuffer,L={};for(var _ in b)L[_]=ut.getBuffered(b[_]);r.appendErrors[d]=0,d==="audio"||d==="video"?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(E.BUFFER_APPENDED,{type:d,frag:u,part:h,chunkMeta:f,parent:u.type,timeRanges:L})},onError:function(R){var b={type:W.MEDIA_ERROR,parent:u.type,details:D.BUFFER_APPEND_ERROR,sourceBufferName:d,frag:u,part:h,chunkMeta:f,error:R,err:R,fatal:!1};if(R.code===DOMException.QUOTA_EXCEEDED_ERR)b.details=D.BUFFER_FULL_ERROR;else{var L=++r.appendErrors[d];b.details=D.BUFFER_APPEND_ERROR,r.warn("Failed "+L+"/"+i.config.appendErrorMaxRetry+' times to append segment in "'+d+'" sourceBuffer'),L>=i.config.appendErrorMaxRetry&&(b.fatal=!0)}i.trigger(E.ERROR,b)}};n.append(T,d,!!this.pendingTracks[d])},a.onBufferFlushing=function(t,e){var r=this,i=this.operationQueue,n=function(o){return{execute:r.removeExecutor.bind(r,o,e.startOffset,e.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(E.BUFFER_FLUSHED,{type:o})},onError:function(l){r.warn("Failed to remove from "+o+" SourceBuffer",l)}}};e.type?i.append(n(e.type),e.type):this.getSourceBufferTypes().forEach(function(o){i.append(n(o),o)})},a.onFragParsed=function(t,e){var r=this,i=e.frag,n=e.part,o=[],l=n?n.elementaryStreams:i.elementaryStreams;l[Ve]?o.push("audiovideo"):(l[Tt]&&o.push("audio"),l[bt]&&o.push("video")),o.length===0&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers(function(){var d=self.performance.now();i.stats.buffering.end=d,n&&(n.stats.buffering.end=d);var u=n?n.stats:i.stats;r.hls.trigger(E.FRAG_BUFFERED,{frag:i,part:n,stats:u,id:i.type})},o)},a.onFragChanged=function(t,e){this.trimBuffers()},a.onBufferEos=function(t,e){var r=this;this.getSourceBufferTypes().reduce(function(i,n){var o=r.sourceBuffer[n];return!o||e.type&&e.type!==n||(o.ending=!0,o.ended||(o.ended=!0,r.log(n+" sourceBuffer now EOS"))),i&&!(o&&!o.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){r.getSourceBufferTypes().forEach(function(n){var o=r.sourceBuffer[n];o&&(o.ending=!1)});var i=r.mediaSource;i&&i.readyState==="open"?(r.log("Calling mediaSource.endOfStream()"),i.endOfStream()):i&&r.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+i.readyState)}))},a.onLevelUpdated=function(t,e){var r=e.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},a.trimBuffers=function(){var t=this.hls,e=this.details,r=this.media;if(r&&e!==null&&this.getSourceBufferTypes().length){var i=t.config,n=r.currentTime,o=e.levelTargetDuration,l=e.live&&i.liveBackBufferLength!==null?i.liveBackBufferLength:i.backBufferLength;if(N(l)&&l>0){var d=Math.max(l,o),u=Math.floor(n/o)*o-d;this.flushBackBuffer(n,o,u)}if(N(i.frontBufferFlushThreshold)&&i.frontBufferFlushThreshold>0){var h=Math.max(i.maxBufferLength,i.frontBufferFlushThreshold),f=Math.max(h,o),c=Math.floor(n/o)*o+f;this.flushFrontBuffer(n,o,c)}}},a.flushBackBuffer=function(t,e,r){var i=this,n=this.details,o=this.sourceBuffer;this.getSourceBufferTypes().forEach(function(l){var d=o[l];if(d){var u=ut.getBuffered(d);if(u.length>0&&r>u.start(0)){if(i.hls.trigger(E.BACK_BUFFER_REACHED,{bufferEnd:r}),n!=null&&n.live)i.hls.trigger(E.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(d.ended&&u.end(u.length-1)-t<2*e)return void i.log("Cannot flush "+l+" back buffer while SourceBuffer is in ended state");i.hls.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:l})}}})},a.flushFrontBuffer=function(t,e,r){var i=this,n=this.sourceBuffer;this.getSourceBufferTypes().forEach(function(o){var l=n[o];if(l){var d=ut.getBuffered(l),u=d.length;if(u<2)return;var h=d.start(u-1),f=d.end(u-1);if(r>h||t>=h&&t<=f)return;if(l.ended&&t-f<2*e)return void i.log("Cannot flush "+o+" front buffer while SourceBuffer is in ended state");i.hls.trigger(E.BUFFER_FLUSHING,{startOffset:h,endOffset:1/0,type:o})}})},a.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&this.mediaSource.readyState==="open"){var t=this.details,e=this.hls,r=this.media,i=this.mediaSource,n=t.fragments[0].start+t.totalduration,o=r.duration,l=N(i.duration)?i.duration:0;t.live&&e.config.liveDurationInfinity?(i.duration=1/0,this.updateSeekableRange(t)):(n>l&&n>o||!N(o))&&(this.log("Updating Media Source duration to "+n.toFixed(3)),i.duration=n)}},a.updateSeekableRange=function(t){var e=this.mediaSource,r=t.fragments;if(r.length&&t.live&&e!=null&&e.setLiveSeekableRange){var i=Math.max(0,r[0].start),n=Math.max(i,i+t.totalduration);this.log("Media Source duration is set to "+e.duration+". Setting seekable range to "+i+"-"+n+"."),e.setLiveSeekableRange(i,n)}},a.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,e=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&(!t||i===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};var n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(E.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(function(l){e.executeNext(l)});else{var o=new Error("could not create source buffer for media codec(s)");this.hls.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:D.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:o,reason:o.message})}}},a.createSourceBuffers=function(t){var e=this,r=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");var n=function(l){if(!r[l]){var d,u=t[l];if(!u)throw Error("source buffer exists for track "+l+", however track does not");var h=((d=u.levelCodec)==null?void 0:d.indexOf(","))===-1?u.levelCodec:u.codec;h&&l.slice(0,5)==="audio"&&(h=be(h,e.appendSource));var f=u.container+";codecs="+h;e.log("creating sourceBuffer("+f+")");try{var c=r[l]=i.addSourceBuffer(f),m=l;e.addBufferListener(m,"updatestart",e._onSBUpdateStart),e.addBufferListener(m,"updateend",e._onSBUpdateEnd),e.addBufferListener(m,"error",e._onSBUpdateError),e.appendSource&&e.addBufferListener(m,"bufferedchange",function(g,y){var v=y.removedRanges;v!=null&&v.length&&e.hls.trigger(E.BUFFER_FLUSHED,{type:l})}),e.tracks[l]={buffer:c,codec:h,container:u.container,levelCodec:u.levelCodec,metadata:u.metadata,id:u.id}}catch(g){e.error("error while trying to add sourceBuffer: "+g.message),e.hls.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:D.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:g,sourceBufferName:l,mimeType:f})}}};for(var o in t)n(o)},a._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},a._onSBUpdateEnd=function(t){var e;if(((e=this.mediaSource)==null?void 0:e.readyState)!=="closed"){var r=this.operationQueue;r.current(t).onComplete(),r.shiftAndExecuteNext(t)}else this.resetBuffer(t)},a._onSBUpdateError=function(t,e){var r,i=new Error(t+" SourceBuffer error. MediaSource readyState: "+((r=this.mediaSource)==null?void 0:r.readyState));this.error(""+i,e),this.hls.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:D.BUFFER_APPENDING_ERROR,sourceBufferName:t,error:i,fatal:!1});var n=this.operationQueue.current(t);n&&n.onError(i)},a.removeExecutor=function(t,e,r){var i=this.media,n=this.mediaSource,o=this.operationQueue,l=this.sourceBuffer[t];if(!i||!n||!l)return this.warn("Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(t);var d=N(i.duration)?i.duration:1/0,u=N(n.duration)?n.duration:1/0,h=Math.max(0,e),f=Math.min(r,d,u);f>h&&(!l.ending||l.ended)?(l.ended=!1,this.log("Removing ["+h+","+f+"] from the "+t+" SourceBuffer"),l.remove(h,f)):o.shiftAndExecuteNext(t)},a.appendExecutor=function(t,e){var r=this.sourceBuffer[e];if(r)r.ended=!1,r.appendBuffer(t);else if(!this.pendingTracks[e])throw new Error("Attempting to append to the "+e+" SourceBuffer, but it does not exist")},a.blockBuffers=function(t,e){var r=this;if(e===void 0&&(e=this.getSourceBufferTypes()),!e.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(t);var i=this.operationQueue,n=e.map(function(o){return i.appendBlocker(o)});Promise.all(n).then(function(){t(),e.forEach(function(o){var l=r.sourceBuffer[o];l!=null&&l.updating||i.shiftAndExecuteNext(o)})})},a.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},a.addBufferListener=function(t,e,r){var i=this.sourceBuffer[t];if(i){var n=r.bind(this,t);this.listeners[t].push({event:e,listener:n}),i.addEventListener(e,n)}},a.removeBufferListeners=function(t){var e=this.sourceBuffer[t];e&&this.listeners[t].forEach(function(r){e.removeEventListener(r.event,r.listener)})},ct(s,[{key:"mediaSrc",get:function(){var t,e=((t=this.media)==null?void 0:t.firstChild)||this.media;return e?.src}}]),s}();function bi(s){var a=s.querySelectorAll("source");[].slice.call(a).forEach(function(t){s.removeChild(t)})}var sn=function(){function s(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()}var a=s.prototype;return a.setStreamController=function(t){this.streamController=t},a.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},a.registerListeners=function(){var t=this.hls;t.on(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(E.BUFFER_CODECS,this.onBufferCodecs,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this)},a.unregisterListener=function(){var t=this.hls;t.off(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(E.BUFFER_CODECS,this.onBufferCodecs,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this)},a.onFpsDropLevelCapping=function(t,e){var r=this.hls.levels[e.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},a.onMediaAttaching=function(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},a.onManifestParsed=function(t,e){var r=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,r.config.capLevelToPlayerSize&&e.video&&this.startCapping()},a.onLevelsUpdated=function(t,e){this.timer&&N(this.autoLevelCapping)&&this.detectPlayerSize()},a.onBufferCodecs=function(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()},a.onMediaDetaching=function(){this.stopCapping()},a.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var t=this.hls.levels;if(t.length){var e=this.hls,r=this.getMaxLevel(t.length-1);r!==this.autoLevelCapping&&A.log("Setting autoLevelCapping to "+r+": "+t[r].height+"p@"+t[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),e.autoLevelCapping=r,e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},a.getMaxLevel=function(t){var e=this,r=this.hls.levels;if(!r.length)return-1;var i=r.filter(function(n,o){return e.isLevelAllowed(n)&&o<=t});return this.clientRect=null,s.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},a.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},a.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},a.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,e={width:0,height:0};if(t){var r=t.getBoundingClientRect();e.width=r.width,e.height=r.height,e.width||e.height||(e.width=r.right-r.left||t.width||0,e.height=r.bottom-r.top||t.height||0)}return this.clientRect=e,e},a.isLevelAllowed=function(t){return!this.restrictedLevels.some(function(e){return t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height})},s.getMaxLevelByMediaSize=function(t,e,r){if(t==null||!t.length)return-1;for(var i,n,o=t.length-1,l=Math.max(e,r),d=0;d<t.length;d+=1){var u=t[d];if((u.width>=l||u.height>=l)&&(i=u,!(n=t[d+1])||i.width!==n.width||i.height!==n.height)){o=d;break}}return o},ct(s,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch{}return t}}]),s}(),on=function(){function s(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()}var a=s.prototype;return a.setStreamController=function(t){this.streamController=t},a.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this)},a.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this)},a.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},a.onMediaAttaching=function(t,e){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=i,i&&typeof i.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},a.checkFPS=function(t,e,r){var i=performance.now();if(e){if(this.lastTime){var n=i-this.lastTime,o=r-this.lastDroppedFrames,l=e-this.lastDecodedFrames,d=1e3*o/n,u=this.hls;if(u.trigger(E.FPS_DROP,{currentDropped:o,currentDecoded:l,totalDroppedFrames:r}),d>0&&o>u.config.fpsDroppedMonitoringThreshold*l){var h=u.currentLevel;A.warn("drop FPS ratio greater than max allowed value for currentLevel: "+h),h>0&&(u.autoLevelCapping===-1||u.autoLevelCapping>=h)&&(h-=1,u.trigger(E.FPS_DROP_LEVEL_CAPPING,{level:h,droppedLevel:u.currentLevel}),u.autoLevelCapping=h,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},a.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},s}(),ln=function(){function s(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=A.log.bind(A,"[content-steering]:"),this.registerListeners()}var a=s.prototype;return a.registerListeners=function(){var t=this.hls;t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.ERROR,this.onError,this)},a.unregisterListeners=function(){var t=this.hls;t&&(t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.ERROR,this.onError,this))},a.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var t=1e3*this.timeToLoad-(performance.now()-this.updated);if(t>0)return void this.scheduleRefresh(this.uri,t)}this.loadSteeringManifest(this.uri)}},a.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},a.clearTimeout=function(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},a.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},a.removeLevel=function(t){var e=this.levels;e&&(this.levels=e.filter(function(r){return r!==t}))},a.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},a.onManifestLoaded=function(t,e){var r=e.contentSteering;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},a.onManifestParsed=function(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks},a.onError=function(t,e){var r=e.errorAction;if(r?.action===Ct&&r.flags===sr){var i=this.levels,n=this.pathwayPriority,o=this.pathwayId;if(e.context){var l=e.context,d=l.groupId,u=l.pathwayId,h=l.type;d&&i?o=this.getPathwayForGroupId(d,h,o):u&&(o=u)}o in this.penalizedPathways||(this.penalizedPathways[o]=performance.now()),!n&&i&&(n=i.reduce(function(f,c){return f.indexOf(c.pathwayId)===-1&&f.push(c.pathwayId),f},[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==o),r.resolved||A.warn("Could not resolve "+e.details+' ("'+e.error.message+'") with content-steering for Pathway: '+o+" levels: "+(i&&i.length)+" priorities: "+JSON.stringify(n)+" penalized: "+JSON.stringify(this.penalizedPathways))}},a.filterParsedLevels=function(t){this.levels=t;var e=this.getLevelsForPathway(this.pathwayId);if(e.length===0){var r=t[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),e=this.getLevelsForPathway(r),this.pathwayId=r}return e.length!==t.length?(this.log("Found "+e.length+"/"+t.length+' levels in Pathway "'+this.pathwayId+'"'),e):t},a.getLevelsForPathway=function(t){return this.levels===null?[]:this.levels.filter(function(e){return t===e.pathwayId})},a.updatePathwayPriority=function(t){var e;this.pathwayPriority=t;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(function(h){i-r[h]>3e5&&delete r[h]});for(var n=0;n<t.length;n++){var o=t[n];if(!(o in r)){if(o===this.pathwayId)return;var l=this.hls.nextLoadLevel,d=this.hls.levels[l];if((e=this.getLevelsForPathway(o)).length>0){this.log('Setting Pathway to "'+o+'"'),this.pathwayId=o,pi(e),this.hls.trigger(E.LEVELS_UPDATED,{levels:e});var u=this.hls.levels[l];d&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==d.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==d.bitrate&&this.log("Unstable Pathways change from bitrate "+d.bitrate+" to "+u.bitrate),this.hls.nextLoadLevel=l);break}}}},a.getPathwayForGroupId=function(t,e,r){for(var i=this.getLevelsForPathway(r).concat(this.levels||[]),n=0;n<i.length;n++)if(e===wt&&i[n].hasAudioGroup(t)||e===xt&&i[n].hasSubtitleGroup(t))return i[n].pathwayId;return r},a.clonePathways=function(t){var e=this,r=this.levels;if(r){var i={},n={};t.forEach(function(o){var l=o.ID,d=o["BASE-ID"],u=o["URI-REPLACEMENT"];if(!r.some(function(f){return f.pathwayId===l})){var h=e.getLevelsForPathway(d).map(function(f){var c=new lt(f.attrs);c["PATHWAY-ID"]=l;var m=c.AUDIO&&c.AUDIO+"_clone_"+l,g=c.SUBTITLES&&c.SUBTITLES+"_clone_"+l;m&&(i[c.AUDIO]=m,c.AUDIO=m),g&&(n[c.SUBTITLES]=g,c.SUBTITLES=g);var y=Di(f.uri,c["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",u),v=new rr({attrs:c,audioCodec:f.audioCodec,bitrate:f.bitrate,height:f.height,name:f.name,url:y,videoCodec:f.videoCodec,width:f.width});if(f.audioGroups)for(var p=1;p<f.audioGroups.length;p++)v.addGroupId("audio",f.audioGroups[p]+"_clone_"+l);if(f.subtitleGroups)for(var S=1;S<f.subtitleGroups.length;S++)v.addGroupId("text",f.subtitleGroups[S]+"_clone_"+l);return v});r.push.apply(r,h),ki(e.audioTracks,i,u,l),ki(e.subtitleTracks,n,u,l)}})}},a.loadSteeringManifest=function(t){var e,r=this,i=this.hls.config,n=i.loader;this.loader&&this.loader.destroy(),this.loader=new n(i);try{e=new self.URL(t)}catch{return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+t)}if(e.protocol!=="data:"){var o=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);e.searchParams.set("_HLS_pathway",this.pathwayId),e.searchParams.set("_HLS_throughput",""+o)}var l={responseType:"json",url:e.href},d=i.steeringManifestLoadPolicy.default,u=d.errorRetry||d.timeoutRetry||{},h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:u.maxNumRetry||0,retryDelay:u.retryDelayMs||0,maxRetryDelay:u.maxRetryDelayMs||0},f={onSuccess:function(c,m,g,y){r.log('Loaded steering manifest: "'+e+'"');var v=c.data;if(v.VERSION===1){r.updated=performance.now(),r.timeToLoad=v.TTL;var p=v["RELOAD-URI"],S=v["PATHWAY-CLONES"],T=v["PATHWAY-PRIORITY"];if(p)try{r.uri=new self.URL(p,e).href}catch{return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+p)}r.scheduleRefresh(r.uri||g.url),S&&r.clonePathways(S);var R={steeringManifest:v,url:e.toString()};r.hls.trigger(E.STEERING_MANIFEST_LOADED,R),T&&r.updatePathwayPriority(T)}else r.log("Steering VERSION "+v.VERSION+" not supported!")},onError:function(c,m,g,y){if(r.log("Error loading steering manifest: "+c.code+" "+c.text+" ("+m.url+")"),r.stopLoad(),c.code===410)return r.enabled=!1,void r.log("Steering manifest "+m.url+" no longer available");var v=1e3*r.timeToLoad;if(c.code!==429)r.scheduleRefresh(r.uri||m.url,v);else{var p=r.loader;if(typeof p?.getResponseHeader=="function"){var S=p.getResponseHeader("Retry-After");S&&(v=1e3*parseFloat(S))}r.log("Steering manifest "+m.url+" rate limited")}},onTimeout:function(c,m,g){r.log("Timeout loading steering manifest ("+m.url+")"),r.scheduleRefresh(r.uri||m.url)}};this.log("Requesting steering manifest: "+e),this.loader.load(l,h,f)},a.scheduleRefresh=function(t,e){var r=this;e===void 0&&(e=1e3*this.timeToLoad),this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var i,n=(i=r.hls)==null?void 0:i.media;!n||n.ended?r.scheduleRefresh(t,1e3*r.timeToLoad):r.loadSteeringManifest(t)},e)},s}();function ki(s,a,t,e){s&&Object.keys(a).forEach(function(r){var i=s.filter(function(n){return n.groupId===r}).map(function(n){var o=gt({},n);return o.details=void 0,o.attrs=new lt(o.attrs),o.url=o.attrs.URI=Di(n.url,n.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=a[r],o.attrs["PATHWAY-ID"]=e,o});s.push.apply(s,i)})}function Di(s,a,t,e){var r,i=e.HOST,n=e.PARAMS,o=e[t];a&&(r=o?.[a])&&(s=r);var l=new self.URL(s);return i&&!r&&(l.host=i),n&&Object.keys(n).sort().forEach(function(d){d&&l.searchParams.set(d,n[d])}),l.href}var un=/^age:\s*[\d.]+\s*$/im,_i=function(){function s(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=null,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new ye,this.retryDelay=0}var a=s.prototype;return a.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null,this.stats=null},a.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,t.readyState!==4&&(this.stats.aborted=!0,t.abort()))},a.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},a.load=function(t,e,r){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=r,this.loadInternal()},a.loadInternal=function(){var t=this,e=this.config,r=this.context;if(e&&r){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;var o=this.xhrSetup;o?Promise.resolve().then(function(){if(!t.stats.aborted)return o(i,r.url)}).catch(function(l){return i.open("GET",r.url,!0),o(i,r.url)}).then(function(){t.stats.aborted||t.openAndSendXhr(i,r,e)}).catch(function(l){t.callbacks.onError({code:i.status,text:l.message},r,i,n)}):this.openAndSendXhr(i,r,e)}},a.openAndSendXhr=function(t,e,r){t.readyState||t.open("GET",e.url,!0);var i=e.headers,n=r.loadPolicy,o=n.maxTimeToFirstByteMs,l=n.maxLoadTimeMs;if(i)for(var d in i)t.setRequestHeader(d,i[d]);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),r.timeout=o&&N(o)?o:l,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),t.send()},a.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(t&&e){var i=e.readyState,n=this.config;if(!r.aborted&&i>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),i===4)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;var o=e.status,l=e.responseType!=="text";if(o>=200&&o<300&&(l&&e.response||e.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var d=l?e.response:e.responseText,u=e.responseType==="arraybuffer"?d.byteLength:d.length;if(r.loaded=r.total=u,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var h=this.callbacks.onProgress;if(h&&h(r,t,d,e),!this.callbacks)return;var f={url:e.responseURL,data:d,code:o};this.callbacks.onSuccess(f,r,t,e)}else{var c=n.loadPolicy.errorRetry;we(c,r.retry,!1,{url:t.url,data:void 0,code:o})?this.retry(c):(A.error(o+" while loading "+t.url),this.callbacks.onError({code:o,text:e.statusText},t,e,r))}}}},a.loadtimeout=function(){var t,e=(t=this.config)==null?void 0:t.loadPolicy.timeoutRetry;if(we(e,this.stats.retry,!0))this.retry(e);else{var r;A.warn("timeout while loading "+((r=this.context)==null?void 0:r.url));var i=this.callbacks;i&&(this.abortInternal(),i.onTimeout(this.stats,this.context,this.loader))}},a.retry=function(t){var e=this.context,r=this.stats;this.retryDelay=ar(t,r.retry),r.retry++,A.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+e?.url+", retrying "+r.retry+"/"+t.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},a.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},a.getCacheAge=function(){var t=null;if(this.loader&&un.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},a.getResponseHeader=function(t){return this.loader&&new RegExp("^"+t+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null},s}(),dn=function(){function s(){this.chunks=[],this.dataLength=0}var a=s.prototype;return a.push=function(t){this.chunks.push(t),this.dataLength+=t.length},a.flush=function(){var t,e=this.chunks,r=this.dataLength;return e.length?(t=e.length===1?e[0]:function(i,n){for(var o=new Uint8Array(n),l=0,d=0;d<i.length;d++){var u=i[d];o.set(u,l),l+=u.length}return o}(e,r),this.reset(),t):new Uint8Array(0)},a.reset=function(){this.chunks.length=0,this.dataLength=0},s}(),hn=/(\d+)-(\d+)\/(\d+)/,wi=function(){function s(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||fn,this.controller=new self.AbortController,this.stats=new ye}var a=s.prototype;return a.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},a.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},a.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},a.load=function(t,e,r){var i=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var o=function(m,g){var y={method:"GET",mode:"cors",credentials:"same-origin",signal:g,headers:new self.Headers(gt({},m.headers))};return m.rangeEnd&&y.headers.set("Range","bytes="+m.rangeStart+"-"+String(m.rangeEnd-1)),y}(t,this.controller.signal),l=r.onProgress,d=t.responseType==="arraybuffer",u=d?"byteLength":"length",h=e.loadPolicy,f=h.maxTimeToFirstByteMs,c=h.maxLoadTimeMs;this.context=t,this.config=e,this.callbacks=r,this.request=this.fetchSetup(t,o),self.clearTimeout(this.requestTimeout),e.timeout=f&&N(f)?f:c,this.requestTimeout=self.setTimeout(function(){i.abortInternal(),r.onTimeout(n,t,i.response)},e.timeout),self.fetch(this.request).then(function(m){i.response=i.loader=m;var g=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(i.requestTimeout),e.timeout=c,i.requestTimeout=self.setTimeout(function(){i.abortInternal(),r.onTimeout(n,t,i.response)},c-(g-n.loading.start)),!m.ok){var y=m.status,v=m.statusText;throw new cn(v||"fetch, bad network response",y,m)}return n.loading.first=g,n.total=function(p){var S=p.get("Content-Range");if(S){var T=function(b){var L=hn.exec(b);if(L)return parseInt(L[2])-parseInt(L[1])+1}(S);if(N(T))return T}var R=p.get("Content-Length");if(R)return parseInt(R)}(m.headers)||n.total,l&&N(e.highWaterMark)?i.loadProgressively(m,n,t,e.highWaterMark,l):d?m.arrayBuffer():t.responseType==="json"?m.json():m.text()}).then(function(m){var g=i.response;if(!g)throw new Error("loader destroyed");self.clearTimeout(i.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var y=m[u];y&&(n.loaded=n.total=y);var v={url:g.url,data:m,code:g.status};l&&!N(e.highWaterMark)&&l(n,t,m,g),r.onSuccess(v,n,t,g)}).catch(function(m){if(self.clearTimeout(i.requestTimeout),!n.aborted){var g=m&&m.code||0,y=m?m.message:null;r.onError({code:g,text:y},t,m?m.details:null,n)}})},a.getCacheAge=function(){var t=null;if(this.response){var e=this.response.headers.get("age");t=e?parseFloat(e):null}return t},a.getResponseHeader=function(t){return this.response?this.response.headers.get(t):null},a.loadProgressively=function(t,e,r,i,n){i===void 0&&(i=0);var o=new dn,l=t.body.getReader();return function d(){return l.read().then(function(u){if(u.done)return o.dataLength&&n(e,r,o.flush(),t),Promise.resolve(new ArrayBuffer(0));var h=u.value,f=h.length;return e.loaded+=f,f<i||o.dataLength?(o.push(h),o.dataLength>=i&&n(e,r,o.flush(),t)):n(e,r,h,t),d()}).catch(function(){return Promise.reject()})}()},s}();function fn(s,a){return new self.Request(s.url,a)}var or,cn=function(s){function a(t,e,r){var i;return(i=s.call(this,t)||this).code=void 0,i.details=void 0,i.code=e,i.details=r,i}return At(a,s),a}(pe(Error)),xi=yt(yt({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold: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:_i,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:en,bufferController:nn,capLevelController:sn,errorController:Za,fpsController:on,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!1,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:Ta,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:ln});function lr(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(lr):Object.keys(s).reduce(function(a,t){return a[t]=lr(s[t]),a},{}):s}function vn(s){var a=s.loader;a!==wi&&a!==_i?(A.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}()&&(s.loader=wi,s.progressive=!0,s.enableSoftwareAES=!0,A.log("[config]: Progressive streaming enabled, using FetchLoader"))}var gn=function(s){function a(e,r){var i;return(i=s.call(this,e,"[level-controller]")||this)._levels=[],i._firstLevel=-1,i._maxAutoLevel=-1,i._startLevel=void 0,i.currentLevel=null,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.steering=void 0,i.onParsedComplete=void 0,i.steering=r,i._registerListeners(),i}At(a,s);var t=a.prototype;return t._registerListeners=function(){var e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.ERROR,this.onError,this)},t._unregisterListeners=function(){var e=this.hls;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.ERROR,this.onError,this)},t.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),s.prototype.destroy.call(this)},t.stopLoad=function(){this._levels.forEach(function(e){e.loadError=0,e.fragmentError=0}),s.prototype.stopLoad.call(this)},t.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},t.onManifestLoading=function(e,r){this.resetLevels()},t.onManifestLoaded=function(e,r){var i=this.hls.config.preferManagedMediaSource,n=[],o={},l={},d=!1,u=!1,h=!1;r.levels.forEach(function(f){var c,m,g=f.attrs,y=f.audioCodec,v=f.videoCodec;((c=y)==null?void 0:c.indexOf("mp4a.40.34"))!==-1&&(or||(or=/chrome|firefox/i.test(navigator.userAgent)),or&&(f.audioCodec=y=void 0)),y&&(f.audioCodec=y=be(y,i)),((m=v)==null?void 0:m.indexOf("avc1"))===0&&(v=f.videoCodec=function(O){var B=O.split(".");if(B.length>2){var F=B.shift()+".";return(F+=parseInt(B.shift()).toString(16))+("000"+parseInt(B.shift()).toString(16)).slice(-4)}return O}(v));var p=f.width,S=f.height,T=f.unknownCodecs;if(d||(d=!(!p||!S)),u||(u=!!v),h||(h=!!y),!(T!=null&&T.length||y&&!ze(y,"audio",i)||v&&!ze(v,"video",i))){var R=g.CODECS,b=g["FRAME-RATE"],L=g["HDCP-LEVEL"],_=g["PATHWAY-ID"],x=g.RESOLUTION,w=g["VIDEO-RANGE"],k=(_||".")+"-"+f.bitrate+"-"+x+"-"+b+"-"+R+"-"+w+"-"+L;if(o[k])if(o[k].uri===f.url||f.attrs["PATHWAY-ID"])o[k].addGroupId("audio",g.AUDIO),o[k].addGroupId("text",g.SUBTITLES);else{var C=l[k]+=1;f.attrs["PATHWAY-ID"]=new Array(C+1).join(".");var I=new rr(f);o[k]=I,n.push(I)}else{var P=new rr(f);o[k]=P,l[k]=1,n.push(P)}}}),this.filterAndSortMediaOptions(n,r,d,u,h)},t.filterAndSortMediaOptions=function(e,r,i,n,o){var l=this,d=[],u=[],h=e;if((i||n)&&o&&(h=h.filter(function(L){var _,x=L.videoCodec,w=L.videoRange,k=L.width,C=L.height;return(!!x||!(!k||!C))&&!!(_=w)&&De.indexOf(_)>-1})),h.length!==0){if(r.audioTracks){var f=this.hls.config.preferManagedMediaSource;Ci(d=r.audioTracks.filter(function(L){return!L.audioCodec||ze(L.audioCodec,"audio",f)}))}r.subtitles&&Ci(u=r.subtitles);var c=h.slice(0);h.sort(function(L,_){if(L.attrs["HDCP-LEVEL"]!==_.attrs["HDCP-LEVEL"])return(L.attrs["HDCP-LEVEL"]||"")>(_.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&L.height!==_.height)return L.height-_.height;if(L.frameRate!==_.frameRate)return L.frameRate-_.frameRate;if(L.videoRange!==_.videoRange)return De.indexOf(L.videoRange)-De.indexOf(_.videoRange);if(L.videoCodec!==_.videoCodec){var x=Qr(L.videoCodec),w=Qr(_.videoCodec);if(x!==w)return w-x}if(L.uri===_.uri&&L.codecSet!==_.codecSet){var k=Ae(L.codecSet),C=Ae(_.codecSet);if(k!==C)return C-k}return L.averageBitrate!==_.averageBitrate?L.averageBitrate-_.averageBitrate:0});var m=c[0];if(this.steering&&(h=this.steering.filterParsedLevels(h)).length!==c.length){for(var g=0;g<c.length;g++)if(c[g].pathwayId===h[0].pathwayId){m=c[g];break}}this._levels=h;for(var y=0;y<h.length;y++)if(h[y]===m){var v;this._firstLevel=y;var p=m.bitrate,S=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+h.length+" level(s) found, first bitrate: "+p),((v=this.hls.userConfig)==null?void 0:v.abrEwmaDefaultEstimate)===void 0){var T=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);T>S&&S===xi.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=T)}break}var R=o&&!n,b={levels:h,audioTracks:d,subtitleTracks:u,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:o,video:n,altAudio:!R&&d.some(function(L){return!!L.url})};this.hls.trigger(E.MANIFEST_PARSED,b),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then(function(){if(l.hls){r.levels.length&&l.warn("One or more CODECS in variant not supported: "+JSON.stringify(r.levels[0].attrs));var L=new Error("no level with compatible codecs found in manifest");l.hls.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:L,reason:L.message})}})},t.onError=function(e,r){!r.fatal&&r.context&&r.context.type===jt&&r.context.level===this.level&&this.checkRetry(r)},t.onFragBuffered=function(e,r){var i=r.frag;if(i!==void 0&&i.type===at){var n=i.elementaryStreams;if(!Object.keys(n).some(function(l){return!!n[l]}))return;var o=this._levels[i.level];o!=null&&o.loadError&&(this.log("Resetting level error count of "+o.loadError+" on frag buffered"),o.loadError=0)}},t.onLevelLoaded=function(e,r){var i,n,o=r.level,l=r.details,d=this._levels[o];if(!d)return this.warn("Invalid level index "+o),void((n=r.deliveryDirectives)!=null&&n.skip&&(l.deltaUpdateFailed=!0));o===this.currentLevelIndex?(d.fragmentError===0&&(d.loadError=0),this.playlistLoaded(o,r,d.details)):(i=r.deliveryDirectives)!=null&&i.skip&&(l.deltaUpdateFailed=!0)},t.loadPlaylist=function(e){s.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var n=i.uri;if(e)try{n=e.addDirectives(n)}catch(l){this.warn("Could not construct new URL with HLS Delivery Directives: "+l)}var o=i.attrs["PATHWAY-ID"];this.log("Loading level index "+r+(e?.msn!==void 0?" at sn "+e.msn+" part "+e.part:"")+" with"+(o?" Pathway "+o:"")+" "+n),this.clearTimer(),this.hls.trigger(E.LEVEL_LOADING,{url:n,level:r,pathwayId:i.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}},t.removeLevel=function(e){var r,i=this,n=this._levels.filter(function(o,l){return l!==e||(i.steering&&i.steering.removeLevel(o),o===i.currentLevel&&(i.currentLevel=null,i.currentLevelIndex=-1,o.details&&o.details.fragments.forEach(function(d){return d.level=-1})),!1)});pi(n),this._levels=n,this.currentLevelIndex>-1&&(r=this.currentLevel)!=null&&r.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(E.LEVELS_UPDATED,{levels:n})},t.onLevelsUpdated=function(e,r){var i=r.levels;this._levels=i},t.checkMaxAutoUpdated=function(){var e=this.hls,r=e.autoLevelCapping,i=e.maxAutoLevel,n=e.maxHdcpLevel;this._maxAutoLevel!==i&&(this._maxAutoLevel=i,this.hls.trigger(E.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:r,levels:this.levels,maxAutoLevel:i,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:n}))},ct(a,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var r=this._levels;if(r.length!==0){if(e<0||e>=r.length){var i=new Error("invalid level idx"),n=e<0;if(this.hls.trigger(E.ERROR,{type:W.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:e,fatal:n,error:i,reason:i.message}),n)return;e=Math.min(e,r.length-1)}var o=this.currentLevelIndex,l=this.currentLevel,d=l?l.attrs["PATHWAY-ID"]:void 0,u=r[e],h=u.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=u,o!==e||!u.details||!l||d!==h){this.log("Switching to level "+e+" ("+(u.height?u.height+"p ":"")+(u.videoRange?u.videoRange+" ":"")+(u.codecSet?u.codecSet+" ":"")+"@"+u.bitrate+")"+(h?" with Pathway "+h:"")+" from level "+o+(d?" with Pathway "+d:""));var f={level:e,attrs:u.attrs,details:u.details,bitrate:u.bitrate,averageBitrate:u.averageBitrate,maxBitrate:u.maxBitrate,realBitrate:u.realBitrate,width:u.width,height:u.height,codecSet:u.codecSet,audioCodec:u.audioCodec,videoCodec:u.videoCodec,audioGroups:u.audioGroups,subtitleGroups:u.subtitleGroups,loaded:u.loaded,loadError:u.loadError,fragmentError:u.fragmentError,name:u.name,id:u.id,uri:u.uri,url:u.url,urlId:0,audioGroupIds:u.audioGroupIds,textGroupIds:u.textGroupIds};this.hls.trigger(E.LEVEL_SWITCHING,f);var c=u.details;if(!c||c.live){var m=this.switchParams(u.uri,l?.details,c);this.loadPlaylist(m)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}}]),a}(Ja);function Ci(s){var a={};s.forEach(function(t){var e=t.groupId||"";t.id=a[e]=a[e]||0,a[e]++})}var Ii="NOT_LOADED",Pi="APPENDING",le="PARTIAL",ue="OK",mn=function(){function s(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()}var a=s.prototype;return a._registerListeners=function(){var t=this.hls;t.on(E.BUFFER_APPENDED,this.onBufferAppended,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this),t.on(E.FRAG_LOADED,this.onFragLoaded,this)},a._unregisterListeners=function(){var t=this.hls;t.off(E.BUFFER_APPENDED,this.onBufferAppended,this),t.off(E.FRAG_BUFFERED,this.onFragBuffered,this),t.off(E.FRAG_LOADED,this.onFragLoaded,this)},a.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},a.getAppendedFrag=function(t,e){var r=this.activePartLists[e];if(r)for(var i=r.length;i--;){var n=r[i];if(!n)break;var o=n.end;if(n.start<=t&&o!==null&&t<=o)return n}return this.getBufferedFrag(t,e)},a.getBufferedFrag=function(t,e){for(var r=this.fragments,i=Object.keys(r),n=i.length;n--;){var o=r[i[n]];if(o?.body.type===e&&o.buffered){var l=o.body;if(l.start<=t&&t<=l.end)return l}}return null},a.detectEvictedFragments=function(t,e,r,i){var n=this;this.timeRanges&&(this.timeRanges[t]=e);var o=i?.fragment.sn||-1;Object.keys(this.fragments).forEach(function(l){var d=n.fragments[l];if(d&&!(o>=d.body.sn))if(d.buffered||d.loaded){var u=d.range[t];u&&u.time.some(function(h){var f=!n.isTimeBuffered(h.startPTS,h.endPTS,e);return f&&n.removeFragment(d.body),f})}else d.body.type===r&&n.removeFragment(d.body)})},a.detectPartialFragments=function(t){var e=this,r=this.timeRanges,i=t.frag,n=t.part;if(r&&i.sn!=="initSegment"){var o=Zt(i),l=this.fragments[o];if(!(!l||l.buffered&&i.gap)){var d=!i.relurl;Object.keys(r).forEach(function(u){var h=i.elementaryStreams[u];if(h){var f=r[u],c=d||h.partial===!0;l.range[u]=e.getBufferedTimes(i,n,c,f)}}),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,(l.body.endList=i.endList||l.body.endList)&&(this.endListFragments[l.body.type]=l),Ce(l)||this.removeParts(i.sn-1,i.type)):this.removeFragment(l.body)}}},a.removeParts=function(t,e){var r=this.activePartLists[e];r&&(this.activePartLists[e]=r.filter(function(i){return i.fragment.sn>=t}))},a.fragBuffered=function(t,e){var r=Zt(t),i=this.fragments[r];!i&&e&&(i=this.fragments[r]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)},a.getBufferedTimes=function(t,e,r,i){for(var n={time:[],partial:r},o=t.start,l=t.end,d=t.minEndPTS||l,u=t.maxStartPTS||o,h=0;h<i.length;h++){var f=i.start(h)-this.bufferPadding,c=i.end(h)+this.bufferPadding;if(u>=f&&d<=c){n.time.push({startPTS:Math.max(o,i.start(h)),endPTS:Math.min(l,i.end(h))});break}if(o<c&&l>f){var m=Math.max(o,i.start(h)),g=Math.min(l,i.end(h));g>m&&(n.partial=!0,n.time.push({startPTS:m,endPTS:g}))}else if(l<=f)break}return n},a.getPartialFragment=function(t){var e,r,i,n=null,o=0,l=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(u){var h=d[u];h&&Ce(h)&&(r=h.body.start-l,i=h.body.end+l,t>=r&&t<=i&&(e=Math.min(t-r,i-t),o<=e&&(n=h.body,o=e)))}),n},a.isEndListAppended=function(t){var e=this.endListFragments[t];return e!==void 0&&(e.buffered||Ce(e))},a.getState=function(t){var e=Zt(t),r=this.fragments[e];return r?r.buffered?Ce(r)?le:ue:Pi:Ii},a.isTimeBuffered=function(t,e,r){for(var i,n,o=0;o<r.length;o++){if(i=r.start(o)-this.bufferPadding,n=r.end(o)+this.bufferPadding,t>=i&&e<=n)return!0;if(e<=i)return!1}return!1},a.onFragLoaded=function(t,e){var r=e.frag,i=e.part;if(r.sn!=="initSegment"&&!r.bitrateTest){var n=i?null:e,o=Zt(r);this.fragments[o]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}},a.onBufferAppended=function(t,e){var r=this,i=e.frag,n=e.part,o=e.timeRanges;if(i.sn!=="initSegment"){var l=i.type;if(n){var d=this.activePartLists[l];d||(this.activePartLists[l]=d=[]),d.push(n)}this.timeRanges=o,Object.keys(o).forEach(function(u){var h=o[u];r.detectEvictedFragments(u,h,l,n)})}},a.onFragBuffered=function(t,e){this.detectPartialFragments(e)},a.hasFragment=function(t){var e=Zt(t);return!!this.fragments[e]},a.hasParts=function(t){var e;return!((e=this.activePartLists[t])==null||!e.length)},a.removeFragmentsInRange=function(t,e,r,i,n){var o=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach(function(l){var d=o.fragments[l];if(d){var u=d.body;u.type!==r||i&&!u.gap||u.start<e&&u.end>t&&(d.buffered||n)&&o.removeFragment(u)}})},a.removeFragment=function(t){var e=Zt(t);t.stats.loaded=0,t.clearElementaryStreamInfo();var r=this.activePartLists[t.type];if(r){var i=t.sn;this.activePartLists[t.type]=r.filter(function(n){return n.fragment.sn!==i})}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]},a.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},s}();function Ce(s){var a,t,e;return s.buffered&&(s.body.gap||((a=s.range.video)==null?void 0:a.partial)||((t=s.range.audio)==null?void 0:t.partial)||((e=s.range.audiovideo)==null?void 0:e.partial))}function Zt(s){return s.type+"_"+s.level+"_"+s.sn}var Fi=Math.pow(2,17),pn=function(){function s(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var a=s.prototype;return a.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},a.abort=function(){this.loader&&this.loader.abort()},a.load=function(t,e){var r=this,i=t.url;if(!i)return Promise.reject(new Pt({type:W.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();var n=this.config,o=n.fLoader,l=n.loader;return new Promise(function(d,u){if(r.loader&&r.loader.destroy(),t.gap){if(t.tagList.some(function(g){return g[0]==="GAP"}))return void u(Mi(t));t.gap=!1}var h=r.loader=t.loader=o?new o(n):new l(n),f=Oi(t),c=Ei(n.fragLoadPolicy.default),m={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:Fi};t.stats=h.stats,h.load(f,m,{onSuccess:function(g,y,v,p){r.resetLoader(t,h);var S=g.data;v.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(S.slice(0,16)),S=S.slice(16)),d({frag:t,part:null,payload:S,networkDetails:p})},onError:function(g,y,v,p){r.resetLoader(t,h),u(new Pt({type:W.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:yt({url:i,data:void 0},g),error:new Error("HTTP Error "+g.code+" "+g.text),networkDetails:v,stats:p}))},onAbort:function(g,y,v){r.resetLoader(t,h),u(new Pt({type:W.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:v,stats:g}))},onTimeout:function(g,y,v){r.resetLoader(t,h),u(new Pt({type:W.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error("Timeout after "+m.timeout+"ms"),networkDetails:v,stats:g}))},onProgress:function(g,y,v,p){e&&e({frag:t,part:null,payload:v,networkDetails:p})}})})},a.loadPart=function(t,e,r){var i=this;this.abort();var n=this.config,o=n.fLoader,l=n.loader;return new Promise(function(d,u){if(i.loader&&i.loader.destroy(),t.gap||e.gap)u(Mi(t,e));else{var h=i.loader=t.loader=o?new o(n):new l(n),f=Oi(t,e),c=Ei(n.fragLoadPolicy.default),m={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Fi};e.stats=h.stats,h.load(f,m,{onSuccess:function(g,y,v,p){i.resetLoader(t,h),i.updateStatsFromPart(t,e);var S={frag:t,part:e,payload:g.data,networkDetails:p};r(S),d(S)},onError:function(g,y,v,p){i.resetLoader(t,h),u(new Pt({type:W.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:yt({url:f.url,data:void 0},g),error:new Error("HTTP Error "+g.code+" "+g.text),networkDetails:v,stats:p}))},onAbort:function(g,y,v){t.stats.aborted=e.stats.aborted,i.resetLoader(t,h),u(new Pt({type:W.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:v,stats:g}))},onTimeout:function(g,y,v){i.resetLoader(t,h),u(new Pt({type:W.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error("Timeout after "+m.timeout+"ms"),networkDetails:v,stats:g}))}})}})},a.updateStatsFromPart=function(t,e){var r=t.stats,i=e.stats,n=i.total;if(r.loaded+=i.loaded,n){var o=Math.round(t.duration/e.duration),l=Math.min(Math.round(r.loaded/n),o),d=(o-l)*Math.round(r.loaded/l);r.total=r.loaded+d}else r.total=Math.max(r.loaded,r.total);var u=r.loading,h=i.loading;u.start?u.first+=h.first-h.start:(u.start=h.start,u.first=h.first),u.end=h.end},a.resetLoader=function(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()},s}();function Oi(s,a){a===void 0&&(a=null);var t=a||s,e={frag:s,part:a,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},r=t.byteRangeStartOffset,i=t.byteRangeEndOffset;if(N(r)&&N(i)){var n,o=r,l=i;if(s.sn==="initSegment"&&((n=s.decryptdata)==null?void 0:n.method)==="AES-128"){var d=i-r;d%16&&(l=i+(16-d%16)),r!==0&&(e.resetIV=!0,o=r-16)}e.rangeStart=o,e.rangeEnd=l}return e}function Mi(s,a){var t=new Error("GAP "+(s.gap?"tag":"attribute")+" found"),e={type:W.MEDIA_ERROR,details:D.FRAG_GAP,fatal:!1,frag:s,error:t,networkDetails:null};return a&&(e.part=a),(a||s).stats.aborted=!0,new Pt(e)}var Pt=function(s){function a(t){var e;return(e=s.call(this,t.error.message)||this).data=void 0,e.data=t,e}return At(a,s),a}(pe(Error)),yn=function(){function s(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}var a=s.prototype;return a.abort=function(t){for(var e in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[e].loader;if(r){var i;if(t&&t!==((i=r.context)==null?void 0:i.frag.type))return;r.abort()}}},a.detach=function(){for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}},a.destroy=function(){for(var t in this.detach(),this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}},a.createKeyLoadError=function(t,e,r,i,n){return e===void 0&&(e=D.KEY_LOAD_ERROR),new Pt({type:W.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:n,error:r,networkDetails:i})},a.loadClear=function(t,e){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=t.sn,n=t.cc,o=function(){var d=e[l];if(n<=d.cc&&(i==="initSegment"||d.sn==="initSegment"||i<d.sn))return r.emeController.selectKeySystemFormat(d).then(function(u){d.setKeyFormat(u)}),1},l=0;l<e.length&&!o();l++);},a.load=function(t){var e=this;return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then(function(r){return e.loadInternal(t,r)}):this.loadInternal(t)},a.loadInternal=function(t,e){var r,i;e&&t.setKeyFormat(e);var n=t.decryptdata;if(!n){var o=new Error(e?"Expected frag.decryptdata to be defined after setting format "+e:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,o))}var l=n.uri;if(!l)return Promise.reject(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+l+'"')));var d,u=this.keyUriToKeyInfo[l];if((r=u)!=null&&r.decryptdata.key)return n.key=u.decryptdata.key,Promise.resolve({frag:t,keyInfo:u});if((i=u)!=null&&i.keyLoadPromise)switch((d=u.mediaKeySessionContext)==null?void 0:d.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return u.keyLoadPromise.then(function(h){return n.key=h.keyInfo.decryptdata.key,{frag:t,keyInfo:u}})}switch(u=this.keyUriToKeyInfo[l]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(u,t):this.loadKeyEME(u,t);case"AES-128":return this.loadKeyHTTP(u,t);default:return Promise.reject(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+n.method+'"')))}},a.loadKeyEME=function(t,e){var r={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(t.keyLoadPromise=i.then(function(n){return t.mediaKeySessionContext=n,r})).catch(function(n){throw t.keyLoadPromise=null,n})}return Promise.resolve(r)},a.loadKeyHTTP=function(t,e){var r=this,i=this.config,n=new i.loader(i);return e.keyLoader=t.loader=n,t.keyLoadPromise=new Promise(function(o,l){var d={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},u=i.keyLoadPolicy.default,h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:function(c,m,g,y){var v=g.frag,p=g.keyInfo,S=g.url;if(!v.decryptdata||p!==r.keyUriToKeyInfo[S])return l(r.createKeyLoadError(v,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),y));p.decryptdata.key=v.decryptdata.key=new Uint8Array(c.data),v.keyLoader=null,p.loader=null,o({frag:v,keyInfo:p})},onError:function(c,m,g,y){r.resetLoader(m),l(r.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error("HTTP Error "+c.code+" loading key "+c.text),g,yt({url:d.url,data:void 0},c)))},onTimeout:function(c,m,g){r.resetLoader(m),l(r.createKeyLoadError(e,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),g))},onAbort:function(c,m,g){r.resetLoader(m),l(r.createKeyLoadError(e,D.INTERNAL_ABORTED,new Error("key loading aborted"),g))}};n.load(d,h,f)})},a.resetLoader=function(t){var e=t.frag,r=t.keyInfo,i=t.url,n=r.loader;e.keyLoader===n&&(e.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],n&&n.destroy()},s}(),En=function(){function s(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var a=s.prototype;return a.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},a.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},a.onHandlerDestroyed=function(){},a.hasInterval=function(){return!!this._tickInterval},a.hasNextTick=function(){return!!this._tickTimer},a.setInterval=function(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)},a.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},a.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},a.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},a.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},a.doTick=function(){},s}(),Ni=function(s,a,t,e,r,i){e===void 0&&(e=0),r===void 0&&(r=-1),i===void 0&&(i=!1),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=s,this.sn=a,this.id=t,this.size=e,this.part=r,this.partial=i};function Ie(s,a){for(var t=0,e=s.length;t<e;t++){var r;if(((r=s[t])==null?void 0:r.cc)===a)return s[t]}return null}function Bi(s,a){if(s){var t=s.start+a;s.start=s.startPTS=t,s.endPTS=t+s.duration}}function Ui(s,a){for(var t=a.fragments,e=0,r=t.length;e<r;e++)Bi(t[e],s);a.fragmentHint&&Bi(a.fragmentHint,s),a.alignedSliding=!0}function Tn(s,a,t){a&&(function(e,r,i){if(function(o,l,d){return!(!l||!(d.endCC>d.startCC||o&&o.cc<d.startCC))}(e,i,r)){var n=function(o,l){var d=o.fragments,u=l.fragments;if(u.length&&d.length){var h=Ie(d,u[0].cc);if(h&&(!h||h.startPTS))return h;A.log("No frag in previous level to align on")}else A.log("No fragments to align")}(i,r);n&&N(n.start)&&(A.log("Adjusting PTS using last level due to CC increase within current level "+r.url),Ui(n.start,r))}}(s,t,a),!t.alignedSliding&&a&&function(e,r){if(e.hasProgramDateTime&&r.hasProgramDateTime){var i,n,o=e.fragments,l=r.fragments;if(o.length&&l.length){var d=Math.min(r.endCC,e.endCC);r.startCC<d&&e.startCC<d&&(i=Ie(l,d),n=Ie(o,d)),i&&n||(n=Ie(o,(i=l[Math.floor(l.length/2)]).cc)||o[Math.floor(o.length/2)]);var u=i.programDateTime,h=n.programDateTime;u&&h&&Ui((h-u)/1e3-(n.start-i.start),e)}}}(t,a),t.alignedSliding||!a||t.skippedSegments||vi(a,t))}var Sn=function(){function s(a,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=a,this.aesIV=t}return s.prototype.decrypt=function(a,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,a)},s}(),Ln=function(){function s(a,t){this.subtle=void 0,this.key=void 0,this.subtle=a,this.key=t}return s.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},s}(),Rn=function(){function s(){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()}var a=s.prototype;return a.uint8ArrayToUint32Array_=function(t){for(var e=new DataView(t),r=new Uint32Array(4),i=0;i<4;i++)r[i]=e.getUint32(4*i);return r},a.initTable=function(){var t=this.sBox,e=this.invSBox,r=this.subMix,i=r[0],n=r[1],o=r[2],l=r[3],d=this.invSubMix,u=d[0],h=d[1],f=d[2],c=d[3],m=new Uint32Array(256),g=0,y=0,v=0;for(v=0;v<256;v++)m[v]=v<128?v<<1:v<<1^283;for(v=0;v<256;v++){var p=y^y<<1^y<<2^y<<3^y<<4;p=p>>>8^255&p^99,t[g]=p,e[p]=g;var S=m[g],T=m[S],R=m[T],b=257*m[p]^16843008*p;i[g]=b<<24|b>>>8,n[g]=b<<16|b>>>16,o[g]=b<<8|b>>>24,l[g]=b,b=16843009*R^65537*T^257*S^16843008*g,u[p]=b<<24|b>>>8,h[p]=b<<16|b>>>16,f[p]=b<<8|b>>>24,c[p]=b,g?(g=S^m[m[m[R^S]]],y^=m[m[y]]):g=y=1}},a.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),r=!0,i=0;i<e.length&&r;)r=e[i]===this.key[i],i++;if(!r){this.key=e;var n=this.keySize=e.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);var o,l,d,u,h=this.ksRows=4*(n+6+1),f=this.keySchedule=new Uint32Array(h),c=this.invKeySchedule=new Uint32Array(h),m=this.sBox,g=this.rcon,y=this.invSubMix,v=y[0],p=y[1],S=y[2],T=y[3];for(o=0;o<h;o++)o<n?d=f[o]=e[o]:(u=d,o%n==0?(u=m[(u=u<<8|u>>>24)>>>24]<<24|m[u>>>16&255]<<16|m[u>>>8&255]<<8|m[255&u],u^=g[o/n|0]<<24):n>6&&o%n==4&&(u=m[u>>>24]<<24|m[u>>>16&255]<<16|m[u>>>8&255]<<8|m[255&u]),f[o]=d=(f[o-n]^u)>>>0);for(l=0;l<h;l++)o=h-l,u=3&l?f[o]:f[o-4],c[l]=l<4||o<=4?u:v[m[u>>>24]]^p[m[u>>>16&255]]^S[m[u>>>8&255]]^T[m[255&u]],c[l]=c[l]>>>0}},a.networkToHostOrderSwap=function(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24},a.decrypt=function(t,e,r){for(var i,n,o,l,d,u,h,f,c,m,g,y,v,p,S=this.keySize+6,T=this.invKeySchedule,R=this.invSBox,b=this.invSubMix,L=b[0],_=b[1],x=b[2],w=b[3],k=this.uint8ArrayToUint32Array_(r),C=k[0],I=k[1],P=k[2],O=k[3],B=new Int32Array(t),F=new Int32Array(B.length),M=this.networkToHostOrderSwap;e<B.length;){for(c=M(B[e]),m=M(B[e+1]),g=M(B[e+2]),y=M(B[e+3]),d=c^T[0],u=y^T[1],h=g^T[2],f=m^T[3],v=4,p=1;p<S;p++)i=L[d>>>24]^_[u>>16&255]^x[h>>8&255]^w[255&f]^T[v],n=L[u>>>24]^_[h>>16&255]^x[f>>8&255]^w[255&d]^T[v+1],o=L[h>>>24]^_[f>>16&255]^x[d>>8&255]^w[255&u]^T[v+2],l=L[f>>>24]^_[d>>16&255]^x[u>>8&255]^w[255&h]^T[v+3],d=i,u=n,h=o,f=l,v+=4;i=R[d>>>24]<<24^R[u>>16&255]<<16^R[h>>8&255]<<8^R[255&f]^T[v],n=R[u>>>24]<<24^R[h>>16&255]<<16^R[f>>8&255]<<8^R[255&d]^T[v+1],o=R[h>>>24]<<24^R[f>>16&255]<<16^R[d>>8&255]<<8^R[255&u]^T[v+2],l=R[f>>>24]<<24^R[d>>16&255]<<16^R[u>>8&255]<<8^R[255&h]^T[v+3],F[e]=M(i^C),F[e+1]=M(l^I),F[e+2]=M(o^P),F[e+3]=M(n^O),C=c,I=m,P=g,O=y,e+=4}return F.buffer},s}(),ur=function(){function s(t,e){var r=(e===void 0?{}:e).removePKCS7Padding,i=r===void 0||r;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=i,i)try{var n=self.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var a=s.prototype;return a.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},a.isSync=function(){return this.useSoftware},a.flush=function(){var t=this.currentResult,e=this.remainderData;if(!t||e)return this.reset(),null;var r,i,n,o=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?(i=(r=o).byteLength,(n=i&&new DataView(r.buffer).getUint8(i-1))?Vt(r,0,i-n):r):o},a.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},a.decrypt=function(t,e,r){var i=this;return this.useSoftware?new Promise(function(n,o){i.softwareDecrypt(new Uint8Array(t),e,r);var l=i.flush();l?n(l.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,r)},a.softwareDecrypt=function(t,e,r){var i=this.currentIV,n=this.currentResult,o=this.remainderData;this.logOnce("JS AES decrypt"),o&&(t=St(o,t),this.remainderData=null);var l=this.getValidChunk(t);if(!l.length)return null;i&&(r=i);var d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new Rn),d.expandKey(e);var u=n;return this.currentResult=d.decrypt(l.buffer,0,r),this.currentIV=Vt(l,-16).buffer,u||null},a.webCryptoDecrypt=function(t,e,r){var i=this,n=this.subtle;return this.key===e&&this.fastAesKey||(this.key=e,this.fastAesKey=new Ln(n,e)),this.fastAesKey.expandKey().then(function(o){return n?(i.logOnce("WebCrypto AES decrypt"),new Sn(n,new Uint8Array(r)).decrypt(t.buffer,o)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(o){return A.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+o.name+": "+o.message),i.onWebCryptoError(t,e,r)})},a.onWebCryptoError=function(t,e,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,r);var i=this.flush();if(i)return i.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},a.getValidChunk=function(t){var e=t,r=t.length-t.length%16;return r!==t.length&&(e=Vt(t,0,r),this.remainderData=Vt(t,r)),e},a.logOnce=function(t){this.logEnabled&&(A.log("[decrypter]: "+t),this.logEnabled=!1)},s}(),An=function(s){for(var a="",t=s.length,e=0;e<t;e++)a+="["+s.start(e).toFixed(3)+"-"+s.end(e).toFixed(3)+"]";return a},Ft="STOPPED",it="IDLE",dr="KEY_LOADING",de="FRAG_LOADING",he="FRAG_LOADING_WAITING_RETRY",Wt="PARSING",Pe="PARSED",hr="ENDED",fe="ERROR",Yt="WAITING_LEVEL",bn=function(s){function a(e,r,i,n,o){var l;return(l=s.call(this)||this).hls=void 0,l.fragPrevious=null,l.fragCurrent=null,l.fragmentTracker=void 0,l.transmuxer=null,l._state=Ft,l.playlistType=void 0,l.media=null,l.mediaBuffer=null,l.config=void 0,l.bitrateTest=!1,l.lastCurrentTime=0,l.nextLoadPosition=0,l.startPosition=0,l.startTimeOffset=null,l.loadedmetadata=!1,l.retryDate=0,l.levels=null,l.fragmentLoader=void 0,l.keyLoader=void 0,l.levelLastLoaded=null,l.startFragRequested=!1,l.decrypter=void 0,l.initPTS=[],l.onvseeking=null,l.onvended=null,l.logPrefix="",l.log=void 0,l.warn=void 0,l.playlistType=o,l.logPrefix=n,l.log=A.log.bind(A,n+":"),l.warn=A.warn.bind(A,n+":"),l.hls=e,l.fragmentLoader=new pn(e.config),l.keyLoader=i,l.fragmentTracker=r,l.config=e.config,l.decrypter=new ur(e.config),e.on(E.MANIFEST_LOADED,l.onManifestLoaded,function(d){if(d===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d}(l)),l}At(a,s);var t=a.prototype;return t.doTick=function(){this.onTickEnd()},t.onTickEnd=function(){},t.startLoad=function(e){},t.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Ft},t._streamEnded=function(e,r){if(r.live||e.nextStart||!e.end||!this.media)return!1;var i=r.partList;if(i!=null&&i.length){var n=i[i.length-1];return ut.isBuffered(this.media,n.start+n.duration/2)}var o=r.fragments[r.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(o)},t.getLevelDetails=function(){var e;if(this.levels&&this.levelLastLoaded!==null)return(e=this.levelLastLoaded)==null?void 0:e.details},t.onMediaAttached=function(e,r){var i=this.media=this.mediaBuffer=r.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);var n=this.config;this.levels&&n.autoStartLoad&&this.state===Ft&&this.startLoad(n.startPosition)},t.onMediaDetaching=function(){var e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.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()},t.onMediaSeeking=function(){var e=this.config,r=this.fragCurrent,i=this.media,n=this.mediaBuffer,o=this.state,l=i?i.currentTime:0,d=ut.bufferInfo(n||i,l,e.maxBufferHole);if(this.log("media seeking to "+(N(l)?l.toFixed(3):l)+", state: "+o),this.state===hr)this.resetLoadingState();else if(r){var u=e.maxFragLookUpTolerance,h=r.start-u,f=r.start+r.duration+u;if(!d.len||f<d.start||h>d.end){var c=l>f;(l<h||c)&&(c&&r.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),r.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(l,1/0,this.playlistType,!0),this.lastCurrentTime=l),this.loadedmetadata||d.len||(this.nextLoadPosition=this.startPosition=l),this.tickImmediate()},t.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},t.onManifestLoaded=function(e,r){this.startTimeOffset=r.startTimeOffset,this.initPTS=[]},t.onHandlerDestroying=function(){this.hls.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),s.prototype.onHandlerDestroying.call(this),this.hls=null},t.onHandlerDestroyed=function(){this.state=Ft,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,s.prototype.onHandlerDestroyed.call(this)},t.loadFragment=function(e,r,i){this._loadFragForPlayback(e,r,i)},t._loadFragForPlayback=function(e,r,i){var n=this;this._doFragLoad(e,r,i,function(o){if(n.fragContextChanged(e))return n.warn("Fragment "+e.sn+(o.part?" p: "+o.part.index:"")+" of level "+e.level+" was dropped during download."),void n.fragmentTracker.removeFragment(e);e.stats.chunkCount++,n._handleFragmentLoadProgress(o)}).then(function(o){if(o){var l=n.state;n.fragContextChanged(e)?(l===de||!n.fragCurrent&&l===Wt)&&(n.fragmentTracker.removeFragment(e),n.state=it):("payload"in o&&(n.log("Loaded fragment "+e.sn+" of level "+e.level),n.hls.trigger(E.FRAG_LOADED,o)),n._handleFragmentLoadComplete(o))}}).catch(function(o){n.state!==Ft&&n.state!==fe&&(n.warn(o),n.resetFragmentLoading(e))})},t.clearTrackerIfNeeded=function(e){var r,i=this.fragmentTracker;if(i.getState(e)===Pi){var n=e.type,o=this.getFwdBufferInfo(this.mediaBuffer,n),l=Math.max(e.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(l)&&i.removeFragment(e)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===le&&i.removeFragment(e))},t.checkLiveUpdate=function(e){if(e.updated&&!e.live){var r=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:r,part:null,stats:r.stats,id:r.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)},t.flushMainBuffer=function(e,r,i){if(i===void 0&&(i=null),e-r){var n={startOffset:e,endOffset:r,type:i};this.hls.trigger(E.BUFFER_FLUSHING,n)}},t._loadInitSegment=function(e,r){var i=this;this._doFragLoad(e,r).then(function(n){if(!n||i.fragContextChanged(e)||!i.levels)throw new Error("init load aborted");return n}).then(function(n){var o=i.hls,l=n.payload,d=e.decryptdata;if(l&&l.byteLength>0&&d!=null&&d.key&&d.iv&&d.method==="AES-128"){var u=self.performance.now();return i.decrypter.decrypt(new Uint8Array(l),d.key.buffer,d.iv.buffer).catch(function(h){throw o.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:h,reason:h.message,frag:e}),h}).then(function(h){var f=self.performance.now();return o.trigger(E.FRAG_DECRYPTED,{frag:e,payload:h,stats:{tstart:u,tdecrypt:f}}),n.payload=h,i.completeInitSegmentLoad(n)})}return i.completeInitSegmentLoad(n)}).catch(function(n){i.state!==Ft&&i.state!==fe&&(i.warn(n),i.resetFragmentLoading(e))})},t.completeInitSegmentLoad=function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var r=e.frag.stats;this.state=it,e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()},t.fragContextChanged=function(e){var r=this.fragCurrent;return!e||!r||e.sn!==r.sn||e.level!==r.level},t.fragBufferedComplete=function(e,r){var i,n,o,l,d=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+e.type+" sn: "+e.sn+(r?" part: "+r.index:"")+" of "+(this.playlistType===at?"level":"track")+" "+e.level+" (frag:["+((i=e.startPTS)!=null?i:NaN).toFixed(3)+"-"+((n=e.endPTS)!=null?n:NaN).toFixed(3)+"] > buffer:"+(d?An(ut.getBuffered(d)):"(detached)")+")"),e.sn!=="initSegment"){var u;if(e.type!==Ze){var h=e.elementaryStreams;if(!Object.keys(h).some(function(c){return!!h[c]}))return void(this.state=it)}var f=(u=this.levels)==null?void 0:u[e.level];f!=null&&f.fragmentError&&(this.log("Resetting level fragment error count of "+f.fragmentError+" on frag buffered"),f.fragmentError=0)}this.state=it,d&&(!this.loadedmetadata&&e.type==at&&d.buffered.length&&((o=this.fragCurrent)==null?void 0:o.sn)===((l=this.fragPrevious)==null?void 0:l.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},t.seekToStartPos=function(){},t._handleFragmentLoadComplete=function(e){var r=this.transmuxer;if(r){var i=e.frag,n=e.part,o=e.partsLoaded,l=!o||o.length===0||o.some(function(u){return!u}),d=new Ni(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!l);r.flush(d)}},t._handleFragmentLoadProgress=function(e){},t._doFragLoad=function(e,r,i,n){var o,l=this;i===void 0&&(i=null);var d=r?.details;if(!this.levels||!d)throw new Error("frag load aborted, missing level"+(d?"":" detail")+"s");var u=null;if(!e.encrypted||(o=e.decryptdata)!=null&&o.key?!e.encrypted&&d.encryptedFragments.length&&this.keyLoader.loadClear(e,d.encryptedFragments):(this.log("Loading key for "+e.sn+" of ["+d.startSN+"-"+d.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+e.level),this.state=dr,this.fragCurrent=e,u=this.keyLoader.load(e).then(function(v){if(!l.fragContextChanged(v.frag))return l.hls.trigger(E.KEY_LOADED,v),l.state===dr&&(l.state=it),v}),this.hls.trigger(E.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(u=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),i=Math.max(e.start,i||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){var h=d.partList;if(h&&n){i>e.end&&d.fragmentHint&&(e=d.fragmentHint);var f=this.getNextPart(h,e,i);if(f>-1){var c,m=h[f];return this.log("Loading part sn: "+e.sn+" p: "+m.index+" cc: "+e.cc+" of playlist ["+d.startSN+"-"+d.endSN+"] parts [0-"+f+"-"+(h.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+e.level+", target: "+parseFloat(i.toFixed(3))),this.nextLoadPosition=m.start+m.duration,this.state=de,c=u?u.then(function(v){return!v||l.fragContextChanged(v.frag)?null:l.doFragPartsLoad(e,m,r,n)}).catch(function(v){return l.handleFragLoadError(v)}):this.doFragPartsLoad(e,m,r,n).catch(function(v){return l.handleFragLoadError(v)}),this.hls.trigger(E.FRAG_LOADING,{frag:e,part:m,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!e.url||this.loadedEndOfParts(h,i))return Promise.resolve(null)}}this.log("Loading fragment "+e.sn+" cc: "+e.cc+" "+(d?"of ["+d.startSN+"-"+d.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+e.level+", target: "+parseFloat(i.toFixed(3))),N(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=de;var g,y=this.config.progressive;return g=y&&u?u.then(function(v){return!v||l.fragContextChanged(v?.frag)?null:l.fragmentLoader.load(e,n)}).catch(function(v){return l.handleFragLoadError(v)}):Promise.all([this.fragmentLoader.load(e,y?n:void 0),u]).then(function(v){var p=v[0];return!y&&p&&n&&n(p),p}).catch(function(v){return l.handleFragLoadError(v)}),this.hls.trigger(E.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):g},t.doFragPartsLoad=function(e,r,i,n){var o=this;return new Promise(function(l,d){var u,h=[],f=(u=i.details)==null?void 0:u.partList;(function c(m){o.fragmentLoader.loadPart(e,m,n).then(function(g){h[m.index]=g;var y=g.part;o.hls.trigger(E.FRAG_LOADED,g);var v=gi(i,e.sn,m.index+1)||mi(f,e.sn,m.index+1);if(!v)return l({frag:e,part:y,partsLoaded:h});c(v)}).catch(d)})(r)})},t.handleFragLoadError=function(e){if("data"in e){var r=e.data;e.data&&r.details===D.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(E.ERROR,r)}else this.hls.trigger(E.ERROR,{type:W.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null},t._handleTransmuxerFlush=function(e){var r=this.getCurrentContext(e);if(r&&this.state===Wt){var i=r.frag,n=r.part,o=r.level,l=self.performance.now();i.stats.parsing.end=l,n&&(n.stats.parsing.end=l),this.updateLevelTiming(i,n,o,e.partial)}else this.fragCurrent||this.state===Ft||this.state===fe||(this.state=it)},t.getCurrentContext=function(e){var r=this.levels,i=this.fragCurrent,n=e.level,o=e.sn,l=e.part;if(r==null||!r[n])return this.warn("Levels object was unset while buffering fragment "+o+" of level "+n+". The current chunk will not be buffered."),null;var d=r[n],u=l>-1?gi(d,o,l):null,h=u?u.fragment:function(f,c,m){if(f==null||!f.details)return null;var g=f.details,y=g.fragments[c-g.startSN];return y||((y=g.fragmentHint)&&y.sn===c?y:c<g.startSN&&m&&m.sn===c?m:null)}(d,o,i);return h?(i&&i!==h&&(h.stats=i.stats),{frag:h,part:u,level:d}):null},t.bufferFragmentData=function(e,r,i,n,o){var l;if(e&&this.state===Wt){var d=e.data1,u=e.data2,h=d;if(d&&u&&(h=St(d,u)),(l=h)!=null&&l.length){var f={type:e.type,frag:r,part:i,chunkMeta:n,parent:r.type,data:h};if(this.hls.trigger(E.BUFFER_APPENDING,f),e.dropped&&e.independent&&!i){if(o)return;this.flushBufferGap(r)}}}},t.flushBufferGap=function(e){var r=this.media;if(r)if(ut.isBuffered(r,r.currentTime)){var i=r.currentTime,n=ut.bufferInfo(r,i,0),o=e.duration,l=Math.min(2*this.config.maxFragLookUpTolerance,.25*o),d=Math.max(Math.min(e.start-l,n.end-l),i+l);e.start-d>l&&this.flushMainBuffer(d,e.start)}else this.flushMainBuffer(0,e.start)},t.getFwdBufferInfo=function(e,r){var i=this.getLoadPosition();return N(i)?this.getFwdBufferInfoAtPos(e,i,r):null},t.getFwdBufferInfoAtPos=function(e,r,i){var n=this.config.maxBufferHole,o=ut.bufferInfo(e,r,n);if(o.len===0&&o.nextStart!==void 0){var l=this.fragmentTracker.getBufferedFrag(r,i);if(l&&o.nextStart<l.end)return ut.bufferInfo(e,r,Math.max(o.nextStart,n))}return o},t.getMaxBufferLength=function(e){var r,i=this.config;return r=e?Math.max(8*i.maxBufferSize/e,i.maxBufferLength):i.maxBufferLength,Math.min(r,i.maxMaxBufferLength)},t.reduceMaxBufferLength=function(e){var r=this.config,i=e||r.maxBufferLength;return r.maxMaxBufferLength>=i&&(r.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+r.maxMaxBufferLength+"s"),!0)},t.getAppendedFrag=function(e,r){var i=this.fragmentTracker.getAppendedFrag(e,at);return i&&"fragment"in i?i.fragment:i},t.getNextFragment=function(e,r){var i=r.fragments,n=i.length;if(!n)return null;var o,l=this.config,d=i[0].start;if(r.live){var u=l.initialLiveManifestSize;if(n<u)return this.warn("Not enough fragments to start playback (have: "+n+", need: "+u+")"),null;(!r.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<d)&&(o=this.getInitialLiveFragment(r,i),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=d&&(o=i[0]);if(!o){var h=l.lowLatencyMode?r.partEnd:r.fragmentEnd;o=this.getFragmentAtPosition(e,h,r)}return this.mapToInitFragWhenRequired(o)},t.isLoopLoading=function(e,r){var i=this.fragmentTracker.getState(e);return(i===ue||i===le&&!!e.gap)&&this.nextLoadPosition>r},t.getNextFragmentLoopLoading=function(e,r,i,n,o){var l=e.gap,d=this.getNextFragment(this.nextLoadPosition,r);if(d===null)return d;if(e=d,l&&e&&!e.gap&&i.nextStart){var u=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,n);if(u!==null&&i.len+u.len>=o)return this.log('buffer full after gaps in "'+n+'" playlist starting at sn: '+e.sn),null}return e},t.mapToInitFragWhenRequired=function(e){return e==null||!e.initSegment||e!=null&&e.initSegment.data||this.bitrateTest?e:e.initSegment},t.getNextPart=function(e,r,i){for(var n=-1,o=!1,l=!0,d=0,u=e.length;d<u;d++){var h=e[d];if(l=l&&!h.independent,n>-1&&i<h.start)break;var f=h.loaded;f?n=-1:(o||h.independent||l)&&h.fragment===r&&(n=d),o=f}return n},t.loadedEndOfParts=function(e,r){var i=e[e.length-1];return i&&r>i.start&&i.loaded},t.getInitialLiveFragment=function(e,r){var i=this.fragPrevious,n=null;if(i){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),n=function(u,h,f){if(h===null||!Array.isArray(u)||!u.length||!N(h)||h<(u[0].programDateTime||0)||h>=(u[u.length-1].endProgramDateTime||0))return null;f=f||0;for(var c=0;c<u.length;++c){var m=u[c];if(Xa(h,f,m))return m}return null}(r,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){var o=i.sn+1;if(o>=e.startSN&&o<=e.endSN){var l=r[o-e.startSN];i.cc===l.cc&&(n=l,this.log("Live playlist, switching playlist, load frag with next SN: "+n.sn))}n||(n=function(u,h){return Ti(u,function(f){return f.cc<h?1:f.cc>h?-1:0})}(r,i.cc),n&&this.log("Live playlist, switching playlist, load frag with same CC: "+n.sn))}}else{var d=this.hls.liveSyncPosition;d!==null&&(n=this.getFragmentAtPosition(d,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n},t.getFragmentAtPosition=function(e,r,i){var n,o=this.config,l=this.fragPrevious,d=i.fragments,u=i.endSN,h=i.fragmentHint,f=o.maxFragLookUpTolerance,c=i.partList,m=!!(o.lowLatencyMode&&c!=null&&c.length&&h);if(m&&h&&!this.bitrateTest&&(d=d.concat(h),u=h.sn),n=e<r?Si(l,d,e,e>r-f?0:f):d[d.length-1]){var g=n.sn-i.startSN,y=this.fragmentTracker.getState(n);if((y===ue||y===le&&n.gap)&&(l=n),l&&n.sn===l.sn&&(!m||c[0].fragment.sn>n.sn)&&l&&n.level===l.level){var v=d[g+1];n=n.sn<u&&this.fragmentTracker.getState(v)!==ue?v:null}}return n},t.synchronizeToLiveEdge=function(e){var r=this.config,i=this.media;if(i){var n=this.hls.liveSyncPosition,o=i.currentTime,l=e.fragments[0].start,d=e.edge,u=o>=l-r.maxFragLookUpTolerance&&o<=d;if(n!==null&&i.duration>n&&(o<n||!u)){var h=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*e.targetduration;(!u&&i.readyState<4||o<d-h)&&(this.loadedmetadata||(this.nextLoadPosition=n),i.readyState&&(this.warn("Playback: "+o.toFixed(3)+" is located too far from the end of live sliding playlist: "+d+", reset currentTime to : "+n.toFixed(3)),i.currentTime=n))}}},t.alignPlaylists=function(e,r,i){var n=e.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;var o=e.fragments[0].start,l=!r,d=e.alignedSliding&&N(o);if(l||!d&&!o){var u=this.fragPrevious;Tn(u,i,e);var h=e.fragments[0].start;return this.log("Live playlist sliding: "+h.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+e.startSN+" prev-sn: "+(u?u.sn:"na")+" fragments: "+n),h}return o},t.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},t.setStartPosition=function(e,r){var i=this.startPosition;if(i<r&&(i=-1),i===-1||this.lastCurrentTime===-1){var n=this.startTimeOffset!==null,o=n?this.startTimeOffset:e.startTimeOffset;o!==null&&N(o)?(i=r+o,o<0&&(i+=e.totalduration),i=Math.min(Math.max(r,i),r+e.totalduration),this.log("Start time offset "+o+" found in "+(n?"multivariant":"media")+" playlist, adjust startPosition to "+i),this.startPosition=i):e.live?i=this.hls.liveSyncPosition||r:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i},t.getLoadPosition=function(){var e=this.media,r=0;return this.loadedmetadata&&e?r=e.currentTime:this.nextLoadPosition&&(r=this.nextLoadPosition),r},t.handleFragLoadAborted=function(e,r){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(r?" part "+r.index:"")+" of level "+e.level+" was aborted"),this.resetFragmentLoading(e))},t.resetFragmentLoading=function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===he)||(this.state=it)},t.onFragmentOrKeyLoadError=function(e,r){if(r.chunkMeta&&!r.frag){var i=this.getCurrentContext(r.chunkMeta);i&&(r.frag=i.frag)}var n=r.frag;if(n&&n.type===e&&this.levels)if(this.fragContextChanged(n)){var o;this.warn("Frag load error must match current frag to retry "+n.url+" > "+((o=this.fragCurrent)==null?void 0:o.url))}else{var l=r.details===D.FRAG_GAP;l&&this.fragmentTracker.fragBuffered(n,!0);var d=r.errorAction,u=d||{},h=u.action,f=u.retryCount,c=f===void 0?0:f,m=u.retryConfig;if(d&&h===xe&&m){this.resetStartWhenNotLoaded(this.levelLastLoaded);var g=ar(m,c);this.warn("Fragment "+n.sn+" of "+e+" "+n.level+" errored with "+r.details+", retrying loading "+(c+1)+"/"+m.maxNumRetry+" in "+g+"ms"),d.resolved=!0,this.retryDate=self.performance.now()+g,this.state=he}else if(m&&d){if(this.resetFragmentErrors(e),!(c<m.maxNumRetry))return void A.warn(r.details+" reached or exceeded max retry ("+c+")");l||h===Qa||(d.resolved=!0)}else d?.action===Ct?this.state=Yt:this.state=fe;this.tickImmediate()}},t.reduceLengthAndFlushBuffer=function(e){if(this.state===Wt||this.state===Pe){var r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len);var o=!n;return o&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+r+" buffer"),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),o}return!1},t.resetFragmentErrors=function(e){e===ne&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Ft&&(this.state=it)},t.afterBufferFlushed=function(e,r,i){if(e){var n=ut.getBuffered(e);this.fragmentTracker.detectEvictedFragments(r,n,i),this.state===hr&&this.resetLoadingState()}},t.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=it},t.resetStartWhenNotLoaded=function(e){if(!this.loadedmetadata){this.startFragRequested=!1;var r=e?e.details:null;r!=null&&r.live?(this.startPosition=-1,this.setStartPosition(r,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},t.resetWhenMissingContext=function(e){this.warn("The loading context changed while buffering fragment "+e.sn+" of level "+e.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},t.removeUnbufferedFrags=function(e){e===void 0&&(e=0),this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)},t.updateLevelTiming=function(e,r,i,n){var o,l=this,d=i.details;if(d){if(!Object.keys(e.elementaryStreams).reduce(function(h,f){var c=e.elementaryStreams[f];if(c){var m=c.endPTS-c.startPTS;if(m<=0)return l.warn("Could not parse fragment "+e.sn+" "+f+" duration reliably ("+m+")"),h||!1;var g=n?0:ci(d,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS);return l.hls.trigger(E.LEVEL_PTS_UPDATED,{details:d,level:i,drift:g,type:f,frag:e,start:c.startPTS,end:c.endPTS}),!0}return h},!1)&&((o=this.transmuxer)==null?void 0:o.error)===null){var u=new Error("Found no media in fragment "+e.sn+" of level "+e.level+" resetting transmuxer to fallback to playlist timing");if(i.fragmentError===0&&(i.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(u.message),this.hls.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:u,frag:e,reason:"Found no media in msn "+e.sn+' of level "'+i.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=Pe,this.hls.trigger(E.FRAG_PARSED,{frag:e,part:r})}else this.warn("level.details undefined")},t.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},t.recoverWorkerError=function(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},ct(a,[{key:"state",get:function(){return this._state},set:function(e){var r=this._state;r!==e&&(this._state=e,this.log(r+"->"+e))}}]),a}(En);function Gi(){return self.SourceBuffer||self.WebKitSourceBuffer}function Hi(){if(!Kt())return!1;var s=Gi();return!s||s.prototype&&typeof s.prototype.appendBuffer=="function"&&typeof s.prototype.remove=="function"}function Dt(s,a){return s===void 0&&(s=""),a===void 0&&(a=9e4),{type:s,id:-1,pid:-1,inputTimeScale:a,sequenceNumber:-1,samples:[],dropped:0}}var Vi=function(){function s(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var a=s.prototype;return a.resetInitSegment=function(t,e,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},a.resetTimeStamp=function(t){this.initPTS=t,this.resetContiguity()},a.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},a.canParse=function(t,e){return!1},a.appendFrame=function(t,e,r){},a.demux=function(t,e){this.cachedData&&(t=St(this.cachedData,t),this.cachedData=null);var r,i=Ee(t,0),n=i?i.length:0,o=this._audioTrack,l=this._id3Track,d=i?Nr(i):void 0,u=t.length;for((this.basePTS===null||this.frameIndex===0&&N(d))&&(this.basePTS=kn(d,e,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:se,duration:Number.POSITIVE_INFINITY});n<u;){if(this.canParse(t,n)){var h=this.appendFrame(o,t,n);h?(this.frameIndex++,this.lastPTS=h.sample.pts,r=n+=h.length):n=u}else Sa(t,n)?(i=Ee(t,n),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:se,duration:Number.POSITIVE_INFINITY}),r=n+=i.length):n++;if(n===u&&r!==u){var f=Vt(t,r);this.cachedData?this.cachedData=St(this.cachedData,f):this.cachedData=f}}return{audioTrack:o,videoTrack:Dt(),id3Track:l,textTrack:Dt()}},a.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},a.flush=function(t){var e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:Dt(),id3Track:this._id3Track,textTrack:Dt()}},a.destroy=function(){},s}(),kn=function(s,a,t){return N(s)?90*s:9e4*a+(t?9e4*t.baseTime/t.timescale:0)};function Ki(s,a){return s[a]===255&&(246&s[a+1])==240}function ji(s,a){return 1&s[a+1]?7:9}function fr(s,a){return(3&s[a+3])<<11|s[a+4]<<3|(224&s[a+5])>>>5}function Fe(s,a){return a+1<s.length&&Ki(s,a)}function Dn(s,a){if(Fe(s,a)){var t=ji(s,a);if(a+t>=s.length)return!1;var e=fr(s,a);if(e<=t)return!1;var r=a+e;return r===s.length||Fe(s,r)}return!1}function Wi(s,a,t,e,r){if(!s.samplerate){var i=function(n,o,l,d){var u,h,f,c,m=navigator.userAgent.toLowerCase(),g=d,y=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];u=1+((192&o[l+2])>>>6);var v=(60&o[l+2])>>>2;if(!(v>y.length-1))return f=(1&o[l+2])<<2,f|=(192&o[l+3])>>>6,A.log("manifest codec:"+d+", ADTS type:"+u+", samplingIndex:"+v),/firefox/i.test(m)?v>=6?(u=5,c=new Array(4),h=v-3):(u=2,c=new Array(2),h=v):m.indexOf("android")!==-1?(u=2,c=new Array(2),h=v):(u=5,c=new Array(4),d&&(d.indexOf("mp4a.40.29")!==-1||d.indexOf("mp4a.40.5")!==-1)||!d&&v>=6?h=v-3:((d&&d.indexOf("mp4a.40.2")!==-1&&(v>=6&&f===1||/vivaldi/i.test(m))||!d&&f===1)&&(u=2,c=new Array(2)),h=v)),c[0]=u<<3,c[0]|=(14&v)>>1,c[1]|=(1&v)<<7,c[1]|=f<<3,u===5&&(c[1]|=(14&h)>>1,c[2]=(1&h)<<7,c[2]|=8,c[3]=0),{config:c,samplerate:y[v],channelCount:f,codec:"mp4a.40."+u,manifestCodec:g};var p=new Error("invalid ADTS sampling index:"+v);n.emit(E.ERROR,E.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!0,error:p,reason:p.message})}(a,t,e,r);if(!i)return;s.config=i.config,s.samplerate=i.samplerate,s.channelCount=i.channelCount,s.codec=i.codec,s.manifestCodec=i.manifestCodec,A.log("parsed codec:"+s.codec+", rate:"+i.samplerate+", channels:"+i.channelCount)}}function Yi(s){return 9216e4/s}function qi(s,a,t,e,r){var i,n=e+r*Yi(s.samplerate),o=function(m,g){var y=ji(m,g);if(g+y<=m.length){var v=fr(m,g)-y;if(v>0)return{headerLength:y,frameLength:v}}}(a,t);if(o){var l=o.frameLength,d=o.headerLength,u=d+l,h=Math.max(0,t+u-a.length);h?(i=new Uint8Array(u-d)).set(a.subarray(t+d,a.length),0):i=a.subarray(t+d,t+u);var f={unit:i,pts:n};return h||s.samples.push(f),{sample:f,length:u,missing:h}}var c=a.length-t;return(i=new Uint8Array(c)).set(a.subarray(t,a.length),0),{sample:{unit:i,pts:n},length:c,missing:-1}}var Oe=null,_n=[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],wn=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],xn=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Cn=[0,1,1,4];function zi(s,a,t,e,r){if(!(t+24>a.length)){var i=Xi(a,t);if(i&&t+i.frameLength<=a.length){var n=e+r*(9e4*i.samplesPerFrame/i.sampleRate),o={unit:a.subarray(t,t+i.frameLength),pts:n,dts:n};return s.config=[],s.channelCount=i.channelCount,s.samplerate=i.sampleRate,s.samples.push(o),{sample:o,length:i.frameLength,missing:0}}}}function Xi(s,a){var t=s[a+1]>>3&3,e=s[a+1]>>1&3,r=s[a+2]>>4&15,i=s[a+2]>>2&3;if(t!==1&&r!==0&&r!==15&&i!==3){var n=s[a+2]>>1&1,o=s[a+3]>>6,l=1e3*_n[14*(t===3?3-e:e===3?3:4)+r-1],d=wn[3*(t===3?0:t===2?1:2)+i],u=o===3?1:2,h=xn[t][e],f=Cn[e],c=8*h*f,m=Math.floor(h*l/d+n)*f;if(Oe===null){var g=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Oe=g?parseInt(g[1]):0}return Oe&&Oe<=87&&e===2&&l>=224e3&&o===0&&(s[a+3]=128|s[a+3]),{sampleRate:d,channelCount:u,frameLength:m,samplesPerFrame:c}}}function cr(s,a){return s[a]===255&&(224&s[a+1])==224&&(6&s[a+1])!=0}function Qi(s,a){return a+1<s.length&&cr(s,a)}function Zi(s,a){if(a+1<s.length&&cr(s,a)){var t=Xi(s,a),e=4;t!=null&&t.frameLength&&(e=t.frameLength);var r=a+e;return r===s.length||Qi(s,r)}return!1}var In=function(s){function a(e,r){var i;return(i=s.call(this)||this).observer=void 0,i.config=void 0,i.observer=e,i.config=r,i}At(a,s);var t=a.prototype;return t.resetInitSegment=function(e,r,i,n){s.prototype.resetInitSegment.call(this,e,r,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},a.probe=function(e){if(!e)return!1;var r=Ee(e,0),i=r?.length||0;if(Zi(e,i))return!1;for(var n=e.length;i<n;i++)if(Dn(e,i))return A.log("ADTS sync word found !"),!0;return!1},t.canParse=function(e,r){return function(i,n){return function(o,l){return l+5<o.length}(i,n)&&Ki(i,n)&&fr(i,n)<=i.length-n}(e,r)},t.appendFrame=function(e,r,i){Wi(e,this.observer,r,i,e.manifestCodec);var n=qi(e,r,i,this.basePTS,this.frameIndex);if(n&&n.missing===0)return n},a}(Vi),Pn=/\/emsg[-/]ID3/i,Fn=function(){function s(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}var a=s.prototype;return a.resetTimeStamp=function(){},a.resetInitSegment=function(t,e,r,i){var n=this.videoTrack=Dt("video",1),o=this.audioTrack=Dt("audio",1),l=this.txtTrack=Dt("text",1);if(this.id3Track=Dt("id3",1),this.timeOffset=0,t!=null&&t.byteLength){var d=Wr(t);if(d.video){var u=d.video,h=u.id,f=u.timescale,c=u.codec;n.id=h,n.timescale=l.timescale=f,n.codec=c}if(d.audio){var m=d.audio,g=m.id,y=m.timescale,v=m.codec;o.id=g,o.timescale=y,o.codec=v}l.id=Hr.text,n.sampleDuration=0,n.duration=o.duration=i}},a.resetContiguity=function(){this.remainderData=null},s.probe=function(t){return function(e){for(var r=e.byteLength,i=0;i<r;){var n=U(e,i);if(n>8&&e[i+4]===109&&e[i+5]===111&&e[i+6]===111&&e[i+7]===102)return!0;i=n>1?i+n:r}return!1}(t)},a.demux=function(t,e){this.timeOffset=e;var r=t,i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=St(this.remainderData,t));var o=function(d){var u={valid:null,remainder:null},h=K(d,["moof"]);if(h.length<2)return u.remainder=d,u;var f=h[h.length-1];return u.valid=Vt(d,0,f.byteOffset-8),u.remainder=Vt(d,f.byteOffset-8),u}(r);this.remainderData=o.remainder,i.samples=o.valid||new Uint8Array}else i.samples=r;var l=this.extractID3Track(i,e);return n.samples=Yr(e,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:l,textTrack:this.txtTrack}},a.flush=function(){var t=this.timeOffset,e=this.videoTrack,r=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(e,this.timeOffset);return r.samples=Yr(t,e),{videoTrack:e,audioTrack:Dt(),id3Track:i,textTrack:Dt()}},a.extractID3Track=function(t,e){var r=this.id3Track;if(t.samples.length){var i=K(t.samples,["emsg"]);i&&i.forEach(function(n){var o=function(h){var f=h[0],c="",m="",g=0,y=0,v=0,p=0,S=0,T=0;if(f===0){for(;dt(h.subarray(T,T+1))!=="\0";)c+=dt(h.subarray(T,T+1)),T+=1;for(c+=dt(h.subarray(T,T+1)),T+=1;dt(h.subarray(T,T+1))!=="\0";)m+=dt(h.subarray(T,T+1)),T+=1;m+=dt(h.subarray(T,T+1)),T+=1,g=U(h,12),y=U(h,16),p=U(h,20),S=U(h,24),T=28}else if(f===1){g=U(h,T+=4);var R=U(h,T+=4),b=U(h,T+=4);for(T+=4,v=Math.pow(2,32)*R+b,ca(v)||(v=Number.MAX_SAFE_INTEGER,A.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),p=U(h,T),S=U(h,T+=4),T+=4;dt(h.subarray(T,T+1))!=="\0";)c+=dt(h.subarray(T,T+1)),T+=1;for(c+=dt(h.subarray(T,T+1)),T+=1;dt(h.subarray(T,T+1))!=="\0";)m+=dt(h.subarray(T,T+1)),T+=1;m+=dt(h.subarray(T,T+1)),T+=1}return{schemeIdUri:c,value:m,timeScale:g,presentationTime:v,presentationTimeDelta:y,eventDuration:p,id:S,payload:h.subarray(T,h.byteLength)}}(n);if(Pn.test(o.schemeIdUri)){var l=N(o.presentationTime)?o.presentationTime/o.timeScale:e+o.presentationTimeDelta/o.timeScale,d=o.eventDuration===4294967295?Number.POSITIVE_INFINITY:o.eventDuration/o.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);var u=o.payload;r.samples.push({data:u,len:u.byteLength,dts:l,pts:l,type:oe,duration:d})}})}return r},a.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},a.destroy=function(){},s}(),On=function(){function s(){this.VideoSample=null}var a=s.prototype;return a.createVideoSample=function(t,e,r,i){return{key:t,frame:!1,pts:e,dts:r,units:[],debug:i,length:0}},a.getLastNalUnit=function(t){var e,r,i=this.VideoSample;if(i&&i.units.length!==0||(i=t[t.length-1]),(e=i)!=null&&e.units){var n=i.units;r=n[n.length-1]}return r},a.pushAccessUnit=function(t,e){if(t.units.length&&t.frame){if(t.pts===void 0){var r=e.samples,i=r.length;if(!i)return void e.dropped++;var n=r[i-1];t.pts=n.pts,t.dts=n.dts}e.samples.push(t)}t.debug.length&&A.log(t.pts+"/"+t.dts+":"+t.debug)},s}(),Ji=function(){function s(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}var a=s.prototype;return a.loadWord=function(){var t=this.data,e=this.bytesAvailable,r=t.byteLength-e,i=new Uint8Array(4),n=Math.min(4,e);if(n===0)throw new Error("no bytes available");i.set(t.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n},a.skipBits=function(t){var e;t=Math.min(t,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,t-=(e=t>>3)<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},a.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;if(t>32&&A.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)>0&&this.bitsAvailable?r<<e|this.readBits(e):r},a.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if(this.word&2147483648>>>t)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},a.skipUEG=function(){this.skipBits(1+this.skipLZ())},a.skipEG=function(){this.skipBits(1+this.skipLZ())},a.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},a.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},a.readBoolean=function(){return this.readBits(1)===1},a.readUByte=function(){return this.readBits(8)},a.readUShort=function(){return this.readBits(16)},a.readUInt=function(){return this.readBits(32)},a.skipScalingList=function(t){for(var e=8,r=8,i=0;i<t;i++)r!==0&&(r=(e+this.readEG()+256)%256),e=r===0?e:r},a.readSPS=function(){var t,e,r,i=0,n=0,o=0,l=0,d=this.readUByte.bind(this),u=this.readBits.bind(this),h=this.readUEG.bind(this),f=this.readBoolean.bind(this),c=this.skipBits.bind(this),m=this.skipEG.bind(this),g=this.skipUEG.bind(this),y=this.skipScalingList.bind(this);d();var v=d();if(u(5),c(3),d(),g(),v===100||v===110||v===122||v===244||v===44||v===83||v===86||v===118||v===128){var p=h();if(p===3&&c(1),g(),g(),c(1),f())for(e=p!==3?8:12,r=0;r<e;r++)f()&&y(r<6?16:64)}g();var S=h();if(S===0)h();else if(S===1)for(c(1),m(),m(),t=h(),r=0;r<t;r++)m();g(),c(1);var T=h(),R=h(),b=u(1);b===0&&c(1),c(1),f()&&(i=h(),n=h(),o=h(),l=h());var L=[1,1];if(f()&&f())switch(d()){case 1:L=[1,1];break;case 2:L=[12,11];break;case 3:L=[10,11];break;case 4:L=[16,11];break;case 5:L=[40,33];break;case 6:L=[24,11];break;case 7:L=[20,11];break;case 8:L=[32,11];break;case 9:L=[80,33];break;case 10:L=[18,11];break;case 11:L=[15,11];break;case 12:L=[64,33];break;case 13:L=[160,99];break;case 14:L=[4,3];break;case 15:L=[3,2];break;case 16:L=[2,1];break;case 255:L=[d()<<8|d(),d()<<8|d()]}return{width:Math.ceil(16*(T+1)-2*i-2*n),height:(2-b)*(R+1)*16-(b?2:4)*(o+l),pixelRatio:L}},a.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},s}(),Mn=function(s){function a(){return s.apply(this,arguments)||this}At(a,s);var t=a.prototype;return t.parseAVCPES=function(e,r,i,n,o){var l,d=this,u=this.parseAVCNALu(e,i.data),h=this.VideoSample,f=!1;i.data=null,h&&u.length&&!e.audFound&&(this.pushAccessUnit(h,e),h=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts,"")),u.forEach(function(c){var m;switch(c.type){case 1:var g=!1;l=!0;var y,v=c.data;if(f&&v.length>4){var p=new Ji(v).readSliceType();p!==2&&p!==4&&p!==7&&p!==9||(g=!0)}g&&(y=h)!=null&&y.frame&&!h.key&&(d.pushAccessUnit(h,e),h=d.VideoSample=null),h||(h=d.VideoSample=d.createVideoSample(!0,i.pts,i.dts,"")),h.frame=!0,h.key=g;break;case 5:l=!0,(m=h)!=null&&m.frame&&!h.key&&(d.pushAccessUnit(h,e),h=d.VideoSample=null),h||(h=d.VideoSample=d.createVideoSample(!0,i.pts,i.dts,"")),h.key=!0,h.frame=!0;break;case 6:l=!0,qr(c.data,1,i.pts,r.samples);break;case 7:var S,T;l=!0,f=!0;var R=c.data,b=new Ji(R).readSPS();if(!e.sps||e.width!==b.width||e.height!==b.height||((S=e.pixelRatio)==null?void 0:S[0])!==b.pixelRatio[0]||((T=e.pixelRatio)==null?void 0:T[1])!==b.pixelRatio[1]){e.width=b.width,e.height=b.height,e.pixelRatio=b.pixelRatio,e.sps=[R],e.duration=o;for(var L=R.subarray(1,4),_="avc1.",x=0;x<3;x++){var w=L[x].toString(16);w.length<2&&(w="0"+w),_+=w}e.codec=_}break;case 8:l=!0,e.pps=[c.data];break;case 9:l=!0,e.audFound=!0,h&&d.pushAccessUnit(h,e),h=d.VideoSample=d.createVideoSample(!1,i.pts,i.dts,"");break;case 12:l=!0;break;default:l=!1,h&&(h.debug+="unknown NAL "+c.type+" ")}h&&l&&h.units.push(c)}),n&&h&&(this.pushAccessUnit(h,e),this.VideoSample=null)},t.parseAVCNALu=function(e,r){var i,n,o=r.byteLength,l=e.naluState||0,d=l,u=[],h=0,f=-1,c=0;for(l===-1&&(f=0,c=31&r[0],l=0,h=1);h<o;)if(i=r[h++],l)if(l!==1)if(i)if(i===1){if(n=h-l-1,f>=0){var m={data:r.subarray(f,n),type:c};u.push(m)}else{var g=this.getLastNalUnit(e.samples);g&&(d&&h<=4-d&&g.state&&(g.data=g.data.subarray(0,g.data.byteLength-d)),n>0&&(g.data=St(g.data,r.subarray(0,n)),g.state=0))}h<o?(f=h,c=31&r[h],l=0):l=-1}else l=0;else l=3;else l=i?0:2;else l=i?0:1;if(f>=0&&l>=0){var y={data:r.subarray(f,o),type:c,state:l};u.push(y)}if(u.length===0){var v=this.getLastNalUnit(e.samples);v&&(v.data=St(v.data,r))}return e.naluState=l,u},a}(On),Nn=function(){function s(t,e,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new ur(e,{removePKCS7Padding:!1})}var a=s.prototype;return a.decryptBuffer=function(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)},a.decryptAacSample=function(t,e,r){var i=this,n=t[e].unit;if(!(n.length<=16)){var o=n.subarray(16,n.length-n.length%16),l=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(l).then(function(d){var u=new Uint8Array(d);n.set(u,16),i.decrypter.isSync()||i.decryptAacSamples(t,e+1,r)})}},a.decryptAacSamples=function(t,e,r){for(;;e++){if(e>=t.length)return void r();if(!(t[e].unit.length<32||(this.decryptAacSample(t,e,r),this.decrypter.isSync())))return}},a.getAvcEncryptedData=function(t){for(var e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e),i=0,n=32;n<t.length-16;n+=160,i+=16)r.set(t.subarray(n,n+16),i);return r},a.getAvcDecryptedUnit=function(t,e){for(var r=new Uint8Array(e),i=0,n=32;n<t.length-16;n+=160,i+=16)t.set(r.subarray(i,i+16),n);return t},a.decryptAvcSample=function(t,e,r,i,n){var o=this,l=zr(n.data),d=this.getAvcEncryptedData(l);this.decryptBuffer(d.buffer).then(function(u){n.data=o.getAvcDecryptedUnit(l,u),o.decrypter.isSync()||o.decryptAvcSamples(t,e,r+1,i)})},a.decryptAvcSamples=function(t,e,r,i){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,r=0){if(e>=t.length)return void i();for(var n=t[e].units;!(r>=n.length);r++){var o=n[r];if(!(o.data.length<=48||o.type!==1&&o.type!==5||(this.decryptAvcSample(t,e,r,i,o),this.decrypter.isSync())))return}}},s}(),ft=188,Bn=function(){function s(t,e,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=t,this.config=e,this.typeSupported=r,this.videoParser=new Mn}s.probe=function(t){var e=s.syncOffset(t);return e>0&&A.warn("MPEG2-TS detected but first sync word found @ offset "+e),e!==-1},s.syncOffset=function(t){for(var e=t.length,r=Math.min(940,e-ft)+1,i=0;i<r;){for(var n=!1,o=-1,l=0,d=i;d<e;d+=ft){if(t[d]!==71||e-d!==ft&&t[d+ft]!==71){if(l)return-1;break}if(l++,o===-1&&(o=d)!==0&&(r=Math.min(o+18612,t.length-ft)+1),n||(n=vr(t,d)===0),n&&l>1&&(o===0&&l>2||d+ft>r))return o}i++}return-1},s.createTrack=function(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:Hr[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}};var a=s.prototype;return a.resetInitSegment=function(t,e,r,i){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=s.createTrack("video"),this._audioTrack=s.createTrack("audio",i),this._id3Track=s.createTrack("id3"),this._txtTrack=s.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=r,this._duration=i},a.resetTimeStamp=function(){},a.resetContiguity=function(){var t=this._audioTrack,e=this._videoTrack,r=this._id3Track;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},a.demux=function(t,e,r,i){var n;r===void 0&&(r=!1),i===void 0&&(i=!1),r||(this.sampleAes=null);var o=this._videoTrack,l=this._audioTrack,d=this._id3Track,u=this._txtTrack,h=o.pid,f=o.pesData,c=l.pid,m=d.pid,g=l.pesData,y=d.pesData,v=null,p=this.pmtParsed,S=this._pmtId,T=t.length;if(this.remainderData&&(T=(t=St(this.remainderData,t)).length,this.remainderData=null),T<ft&&!i)return this.remainderData=t,{audioTrack:l,videoTrack:o,id3Track:d,textTrack:u};var R=Math.max(0,s.syncOffset(t));(T-=(T-R)%ft)<t.byteLength&&!i&&(this.remainderData=new Uint8Array(t.buffer,T,t.buffer.byteLength-T));for(var b=0,L=R;L<T;L+=ft)if(t[L]===71){var _=!!(64&t[L+1]),x=vr(t,L),w=void 0;if((48&t[L+3])>>4>1){if((w=L+5+t[L+4])===L+ft)continue}else w=L+4;switch(x){case h:_&&(f&&(n=Jt(f))&&this.videoParser.parseAVCPES(o,u,n,!1,this._duration),f={data:[],size:0}),f&&(f.data.push(t.subarray(w,L+ft)),f.size+=L+ft-w);break;case c:if(_){if(g&&(n=Jt(g)))switch(l.segmentCodec){case"aac":this.parseAACPES(l,n);break;case"mp3":this.parseMPEGPES(l,n)}g={data:[],size:0}}g&&(g.data.push(t.subarray(w,L+ft)),g.size+=L+ft-w);break;case m:_&&(y&&(n=Jt(y))&&this.parseID3PES(d,n),y={data:[],size:0}),y&&(y.data.push(t.subarray(w,L+ft)),y.size+=L+ft-w);break;case 0:_&&(w+=t[w]+1),S=this._pmtId=Un(t,w);break;case S:_&&(w+=t[w]+1);var k=Gn(t,w,this.typeSupported,r);(h=k.videoPid)>0&&(o.pid=h,o.segmentCodec=k.segmentVideoCodec),(c=k.audioPid)>0&&(l.pid=c,l.segmentCodec=k.segmentAudioCodec),(m=k.id3Pid)>0&&(d.pid=m),v===null||p||(A.warn("MPEG-TS PMT found at "+L+" after unknown PID '"+v+"'. Backtracking to sync byte @"+R+" to parse all TS packets."),v=null,L=R-188),p=this.pmtParsed=!0;break;case 17:case 8191:break;default:v=x}}else b++;if(b>0){var C=new Error("Found "+b+" TS packet/s that do not start with 0x47");this.observer.emit(E.ERROR,E.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:C,reason:C.message})}o.pesData=f,l.pesData=g,d.pesData=y;var I={audioTrack:l,videoTrack:o,id3Track:d,textTrack:u};return i&&this.extractRemainingSamples(I),I},a.flush=function(){var t,e=this.remainderData;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},a.extractRemainingSamples=function(t){var e,r=t.audioTrack,i=t.videoTrack,n=t.id3Track,o=t.textTrack,l=i.pesData,d=r.pesData,u=n.pesData;if(l&&(e=Jt(l))?(this.videoParser.parseAVCPES(i,o,e,!0,this._duration),i.pesData=null):i.pesData=l,d&&(e=Jt(d))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,e);break;case"mp3":this.parseMPEGPES(r,e)}r.pesData=null}else d!=null&&d.size&&A.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=d;u&&(e=Jt(u))?(this.parseID3PES(n,e),n.pesData=null):n.pesData=u},a.demuxSampleAes=function(t,e,r){var i=this.demux(t,r,!0,!this.config.progressive),n=this.sampleAes=new Nn(this.observer,this.config,e);return this.decrypt(i,n)},a.decrypt=function(t,e){return new Promise(function(r){var i=t.audioTrack,n=t.videoTrack;i.samples&&i.segmentCodec==="aac"?e.decryptAacSamples(i.samples,0,function(){n.samples?e.decryptAvcSamples(n.samples,0,0,function(){r(t)}):r(t)}):n.samples&&e.decryptAvcSamples(n.samples,0,0,function(){r(t)})})},a.destroy=function(){this._duration=0},a.parseAACPES=function(t,e){var r,i,n,o=0,l=this.aacOverFlow,d=e.data;if(l){this.aacOverFlow=null;var u=l.missing,h=l.sample.unit.byteLength;if(u===-1)d=St(l.sample.unit,d);else{var f=h-u;l.sample.unit.set(d.subarray(0,u),f),t.samples.push(l.sample),o=l.missing}}for(r=o,i=d.length;r<i-1&&!Fe(d,r);r++);if(r!==o){var c,m=r<i-1;c=m?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES";var g=new Error(c);if(A.warn("parsing error: "+c),this.observer.emit(E.ERROR,E.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,levelRetry:m,error:g,reason:c}),!m)return}if(Wi(t,this.observer,d,r,this.audioCodec),e.pts!==void 0)n=e.pts;else{if(!l)return void A.warn("[tsdemuxer]: AAC PES unknown PTS");var y=Yi(t.samplerate);n=l.sample.pts+y}for(var v,p=0;r<i;){if(r+=(v=qi(t,d,r,n,p)).length,v.missing){this.aacOverFlow=v;break}for(p++;r<i-1&&!Fe(d,r);r++);}},a.parseMPEGPES=function(t,e){var r=e.data,i=r.length,n=0,o=0,l=e.pts;if(l!==void 0)for(;o<i;)if(Qi(r,o)){var d=zi(t,r,o,l,n);if(!d)break;o+=d.length,n++}else o++;else A.warn("[tsdemuxer]: MPEG PES unknown PTS")},a.parseAC3PES=function(t,e){},a.parseID3PES=function(t,e){if(e.pts!==void 0){var r=gt({},e,{type:this._videoTrack?oe:se,duration:Number.POSITIVE_INFINITY});t.samples.push(r)}else A.warn("[tsdemuxer]: ID3 PES unknown PTS")},s}();function vr(s,a){return((31&s[a+1])<<8)+s[a+2]}function Un(s,a){return(31&s[a+10])<<8|s[a+11]}function Gn(s,a,t,e){var r={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},i=a+3+((15&s[a+1])<<8|s[a+2])-4;for(a+=12+((15&s[a+10])<<8|s[a+11]);a<i;){var n=vr(s,a),o=(15&s[a+3])<<8|s[a+4];switch(s[a]){case 207:if(!e){gr("ADTS AAC");break}case 15:r.audioPid===-1&&(r.audioPid=n);break;case 21:r.id3Pid===-1&&(r.id3Pid=n);break;case 219:if(!e){gr("H.264");break}case 27:r.videoPid===-1&&(r.videoPid=n,r.segmentVideoCodec="avc");break;case 3:case 4:t.mpeg||t.mp3?r.audioPid===-1&&(r.audioPid=n,r.segmentAudioCodec="mp3"):A.log("MPEG audio found, not supported in this browser");break;case 193:if(!e){gr("AC-3");break}case 129:A.warn("AC-3 in M2TS support not included in build");break;case 6:if(r.audioPid===-1&&o>0)for(var l=a+5,d=o;d>2;){s[l]===106&&A.warn("AC-3 in M2TS support not included in build");var u=s[l+1]+2;l+=u,d-=u}break;case 194:case 135:A.warn("Unsupported EC-3 in M2TS found");break;case 36:A.warn("Unsupported HEVC in M2TS found")}a+=o+5}return r}function gr(s){A.log(s+" with AES-128-CBC encryption found in unencrypted stream")}function Jt(s){var a,t,e,r,i,n=0,o=s.data;if(!s||s.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=St(o[0],o[1]),o.splice(1,1);if(((a=o[0])[0]<<16)+(a[1]<<8)+a[2]===1){if((t=(a[4]<<8)+a[5])&&t>s.size-6)return null;var l=a[7];192&l&&(r=536870912*(14&a[9])+4194304*(255&a[10])+16384*(254&a[11])+128*(255&a[12])+(254&a[13])/2,64&l?r-(i=536870912*(14&a[14])+4194304*(255&a[15])+16384*(254&a[16])+128*(255&a[17])+(254&a[18])/2)>54e5&&(A.warn(Math.round((r-i)/9e4)+"s delta between PTS and DTS, align them"),r=i):i=r);var d=(e=a[8])+9;if(s.size<=d)return null;s.size-=d;for(var u=new Uint8Array(s.size),h=0,f=o.length;h<f;h++){var c=(a=o[h]).byteLength;if(d){if(d>c){d-=c;continue}a=a.subarray(d),c-=d,d=0}u.set(a,n),n+=c}return t&&(t-=e+3),{data:u,pts:r,dts:i,len:t}}return null}var Hn=function(s){function a(){return s.apply(this,arguments)||this}At(a,s);var t=a.prototype;return t.resetInitSegment=function(e,r,i,n){s.prototype.resetInitSegment.call(this,e,r,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},a.probe=function(e){if(!e)return!1;var r=Ee(e,0),i=r?.length||0;if(r&&e[i]===11&&e[i+1]===119&&Nr(r)!==void 0&&function(o,l){var d=0,u=5;l+=u;for(var h=new Uint32Array(1),f=new Uint32Array(1),c=new Uint8Array(1);u>0;){c[0]=o[l];var m=Math.min(u,8),g=8-m;f[0]=4278190080>>>24+g<<g,h[0]=(c[0]&f[0])>>g,d=d?d<<m|h[0]:h[0],l+=1,u-=m}return d}(e,i)<=16)return!1;for(var n=e.length;i<n;i++)if(Zi(e,i))return A.log("MPEG Audio sync word found !"),!0;return!1},t.canParse=function(e,r){return function(i,n){return cr(i,n)&&4<=i.length-n}(e,r)},t.appendFrame=function(e,r,i){if(this.basePTS!==null)return zi(e,r,i,this.basePTS,this.frameIndex)},a}(Vi),$i=function(){function s(){}return s.getSilentFrame=function(a,t){if(a==="mp4a.40.2"){if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)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(t===6)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(t===1)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(t===2)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(t===3)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])}},s}(),Ut=Math.pow(2,32)-1,ht=function(){function s(){}return s.init=function(){var a;for(a in s.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},s.types)s.types.hasOwnProperty(a)&&(s.types[a]=[a.charCodeAt(0),a.charCodeAt(1),a.charCodeAt(2),a.charCodeAt(3)]);var t=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]),e=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]);s.HDLR_TYPES={video:t,audio:e};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);s.STTS=s.STSC=s.STCO=i,s.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),s.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),s.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),s.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var n=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);s.FTYP=s.box(s.types.ftyp,n,l,n,o),s.DINF=s.box(s.types.dinf,s.box(s.types.dref,r))},s.box=function(a){for(var t=8,e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];for(var n=r.length,o=n;n--;)t+=r[n].byteLength;var l=new Uint8Array(t);for(l[0]=t>>24&255,l[1]=t>>16&255,l[2]=t>>8&255,l[3]=255&t,l.set(a,4),n=0,t=8;n<o;n++)l.set(r[n],t),t+=r[n].byteLength;return l},s.hdlr=function(a){return s.box(s.types.hdlr,s.HDLR_TYPES[a])},s.mdat=function(a){return s.box(s.types.mdat,a)},s.mdhd=function(a,t){t*=a;var e=Math.floor(t/(Ut+1)),r=Math.floor(t%(Ut+1));return s.box(s.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,a>>24&255,a>>16&255,a>>8&255,255&a,e>>24,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,85,196,0,0]))},s.mdia=function(a){return s.box(s.types.mdia,s.mdhd(a.timescale,a.duration),s.hdlr(a.type),s.minf(a))},s.mfhd=function(a){return s.box(s.types.mfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a]))},s.minf=function(a){return a.type==="audio"?s.box(s.types.minf,s.box(s.types.smhd,s.SMHD),s.DINF,s.stbl(a)):s.box(s.types.minf,s.box(s.types.vmhd,s.VMHD),s.DINF,s.stbl(a))},s.moof=function(a,t,e){return s.box(s.types.moof,s.mfhd(a),s.traf(e,t))},s.moov=function(a){for(var t=a.length,e=[];t--;)e[t]=s.trak(a[t]);return s.box.apply(null,[s.types.moov,s.mvhd(a[0].timescale,a[0].duration)].concat(e).concat(s.mvex(a)))},s.mvex=function(a){for(var t=a.length,e=[];t--;)e[t]=s.trex(a[t]);return s.box.apply(null,[s.types.mvex].concat(e))},s.mvhd=function(a,t){t*=a;var e=Math.floor(t/(Ut+1)),r=Math.floor(t%(Ut+1)),i=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,a>>24&255,a>>16&255,a>>8&255,255&a,e>>24,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,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 s.box(s.types.mvhd,i)},s.sdtp=function(a){var t,e,r=a.samples||[],i=new Uint8Array(4+r.length);for(t=0;t<r.length;t++)e=r[t].flags,i[t+4]=e.dependsOn<<4|e.isDependedOn<<2|e.hasRedundancy;return s.box(s.types.sdtp,i)},s.stbl=function(a){return s.box(s.types.stbl,s.stsd(a),s.box(s.types.stts,s.STTS),s.box(s.types.stsc,s.STSC),s.box(s.types.stsz,s.STSZ),s.box(s.types.stco,s.STCO))},s.avc1=function(a){var t,e,r,i=[],n=[];for(t=0;t<a.sps.length;t++)r=(e=a.sps[t]).byteLength,i.push(r>>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(e));for(t=0;t<a.pps.length;t++)r=(e=a.pps[t]).byteLength,n.push(r>>>8&255),n.push(255&r),n=n.concat(Array.prototype.slice.call(e));var o=s.box(s.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|a.sps.length].concat(i).concat([a.pps.length]).concat(n))),l=a.width,d=a.height,u=a.pixelRatio[0],h=a.pixelRatio[1];return s.box(s.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,l>>8&255,255&l,d>>8&255,255&d,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]),o,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,h>>24,h>>16&255,h>>8&255,255&h])))},s.esds=function(a){var t=a.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(a.config).concat([6,1,2]))},s.audioStsd=function(a){var t=a.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,a.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0])},s.mp4a=function(a){return s.box(s.types.mp4a,s.audioStsd(a),s.box(s.types.esds,s.esds(a)))},s.mp3=function(a){return s.box(s.types[".mp3"],s.audioStsd(a))},s.ac3=function(a){return s.box(s.types["ac-3"],s.audioStsd(a),s.box(s.types.dac3,a.config))},s.stsd=function(a){return a.type==="audio"?a.segmentCodec==="mp3"&&a.codec==="mp3"?s.box(s.types.stsd,s.STSD,s.mp3(a)):a.segmentCodec==="ac3"?s.box(s.types.stsd,s.STSD,s.ac3(a)):s.box(s.types.stsd,s.STSD,s.mp4a(a)):s.box(s.types.stsd,s.STSD,s.avc1(a))},s.tkhd=function(a){var t=a.id,e=a.duration*a.timescale,r=a.width,i=a.height,n=Math.floor(e/(Ut+1)),o=Math.floor(e%(Ut+1));return s.box(s.types.tkhd,new Uint8Array([1,0,0,7,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,0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,o>>24,o>>16&255,o>>8&255,255&o,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,r>>8&255,255&r,0,0,i>>8&255,255&i,0,0]))},s.traf=function(a,t){var e=s.sdtp(a),r=a.id,i=Math.floor(t/(Ut+1)),n=Math.floor(t%(Ut+1));return s.box(s.types.traf,s.box(s.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),s.box(s.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n])),s.trun(a,e.length+16+20+8+16+8+8),e)},s.trak=function(a){return a.duration=a.duration||4294967295,s.box(s.types.trak,s.tkhd(a),s.mdia(a))},s.trex=function(a){var t=a.id;return s.box(s.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},s.trun=function(a,t){var e,r,i,n,o,l,d=a.samples||[],u=d.length,h=12+16*u,f=new Uint8Array(h);for(t+=8+h,f.set([a.type==="video"?1:0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),e=0;e<u;e++)i=(r=d[e]).duration,n=r.size,o=r.flags,l=r.cts,f.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,n>>>24&255,n>>>16&255,n>>>8&255,255&n,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*e);return s.box(s.types.trun,f)},s.initSegment=function(a){s.types||s.init();var t=s.moov(a);return St(s.FTYP,t)},s}();function ce(s,a){return a===void 0&&(a=!1),function(t,e,r,i){r===void 0&&(r=1),i===void 0&&(i=!1);var n=t*e*r;return i?Math.round(n):n}(s,1e3,1/9e4,a)}ht.types=void 0,ht.HDLR_TYPES=void 0,ht.STTS=void 0,ht.STSC=void 0,ht.STCO=void 0,ht.STSZ=void 0,ht.VMHD=void 0,ht.SMHD=void 0,ht.STSD=void 0,ht.FTYP=void 0,ht.DINF=void 0;var $t=null,mr=null,pr=function(){function s(t,e,r,i){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.videoTrackConfig=void 0,this.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,$t===null){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);$t=n?parseInt(n[1]):0}if(mr===null){var o=navigator.userAgent.match(/Safari\/(\d+)/i);mr=o?parseInt(o[1]):0}}var a=s.prototype;return a.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},a.resetTimeStamp=function(t){A.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},a.resetNextTimestamp=function(){A.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},a.resetInitSegment=function(){A.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},a.getVideoStartPts=function(t){var e=!1,r=t.reduce(function(i,n){var o=n.pts-i;return o<-4294967296?(e=!0,Lt(i,n.pts)):o>0?i:n.pts},t[0].pts);return e&&A.debug("PTS rollover detected"),r},a.remux=function(t,e,r,i,n,o,l,d){var u,h,f,c,m,g,y=n,v=n,p=t.pid>-1,S=e.pid>-1,T=e.samples.length,R=t.samples.length>0,b=l&&T>0||T>1;if((!p||R)&&(!S||b)||this.ISGenerated||l){if(this.ISGenerated){var L,_,x,w,k=this.videoTrackConfig;!k||e.width===k.width&&e.height===k.height&&((L=e.pixelRatio)==null?void 0:L[0])===((_=k.pixelRatio)==null?void 0:_[0])&&((x=e.pixelRatio)==null?void 0:x[1])===((w=k.pixelRatio)==null?void 0:w[1])||this.resetInitSegment()}else f=this.generateIS(t,e,n,o);var C,I=this.isVideoContiguous,P=-1;if(b&&(P=function(H){for(var G=0;G<H.length;G++)if(H[G].key)return G;return-1}(e.samples),!I&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,P>0){A.warn("[mp4-remuxer]: Dropped "+P+" out of "+T+" video samples due to a missing keyframe");var O=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(P),e.dropped+=P,C=v+=(e.samples[0].pts-O)/e.inputTimeScale}else P===-1&&(A.warn("[mp4-remuxer]: No keyframe found out of "+T+" video samples"),g=!1);if(this.ISGenerated){if(R&&b){var B=this.getVideoStartPts(e.samples),F=(Lt(t.samples[0].pts,B)-B)/e.inputTimeScale;y+=Math.max(0,F),v+=Math.max(0,-F)}if(R){if(t.samplerate||(A.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),f=this.generateIS(t,e,n,o)),h=this.remuxAudio(t,y,this.isAudioContiguous,o,S||b||d===ne?v:void 0),b){var M=h?h.endPTS-h.startPTS:0;e.inputTimeScale||(A.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),f=this.generateIS(t,e,n,o)),u=this.remuxVideo(e,v,I,M)}}else b&&(u=this.remuxVideo(e,v,I,0));u&&(u.firstKeyFrame=P,u.independent=P!==-1,u.firstKeyFramePTS=C)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(m=ta(r,n,this._initPTS,this._initDTS)),i.samples.length&&(c=ea(i,n,this._initPTS))),{audio:h,video:u,initSegment:f,independent:g,text:c,id3:m}},a.generateIS=function(t,e,r,i){var n,o,l,d=t.samples,u=e.samples,h=this.typeSupported,f={},c=this._initPTS,m=!c||i,g="audio/mp4";if(m&&(n=o=1/0),t.config&&d.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":h.mpeg?(g="audio/mpeg",t.codec=""):h.mp3&&(t.codec="mp3");break;case"ac3":t.codec="ac-3"}f.audio={id:"audio",container:g,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&h.mpeg?new Uint8Array(0):ht.initSegment([t]),metadata:{channelCount:t.channelCount}},m&&(l=t.inputTimeScale,c&&l===c.timescale?m=!1:n=o=d[0].pts-Math.round(l*r))}if(e.sps&&e.pps&&u.length){if(e.timescale=e.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:ht.initSegment([e]),metadata:{width:e.width,height:e.height}},m)if(l=e.inputTimeScale,c&&l===c.timescale)m=!1;else{var y=this.getVideoStartPts(u),v=Math.round(l*r);o=Math.min(o,Lt(u[0].dts,y)-v),n=Math.min(n,y-v)}this.videoTrackConfig={width:e.width,height:e.height,pixelRatio:e.pixelRatio}}if(Object.keys(f).length)return this.ISGenerated=!0,m?(this._initPTS={baseTime:n,timescale:l},this._initDTS={baseTime:o,timescale:l}):n=l=void 0,{tracks:f,initPTS:n,timescale:l}},a.remuxVideo=function(t,e,r,i){var n,o,l=t.inputTimeScale,d=t.samples,u=[],h=d.length,f=this._initPTS,c=this.nextAvcDts,m=8,g=this.videoSampleDuration,y=Number.POSITIVE_INFINITY,v=Number.NEGATIVE_INFINITY,p=!1;if(!r||c===null){var S=e*l,T=d[0].pts-Lt(d[0].dts,d[0].pts);$t&&c!==null&&Math.abs(S-T-c)<15e3?r=!0:c=S-T}for(var R=f.baseTime*l/f.timescale,b=0;b<h;b++){var L=d[b];L.pts=Lt(L.pts-R,c),L.dts=Lt(L.dts-R,c),L.dts<d[b>0?b-1:b].dts&&(p=!0)}p&&d.sort(function(Ne,ua){var Qn=Ne.dts-ua.dts,Zn=Ne.pts-ua.pts;return Qn||Zn}),n=d[0].dts;var _=(o=d[d.length-1].dts)-n,x=_?Math.round(_/(h-1)):g||t.inputTimeScale/30;if(r){var w=n-c,k=w>x,C=w<-1;if((k||C)&&(k?A.warn("AVC: "+ce(w,!0)+" ms ("+w+"dts) hole between fragments detected at "+e.toFixed(3)):A.warn("AVC: "+ce(-w,!0)+" ms ("+w+"dts) overlapping between fragments detected at "+e.toFixed(3)),!C||c>=d[0].pts||$t)){n=c;var I=d[0].pts-w;if(k)d[0].dts=n,d[0].pts=I;else for(var P=0;P<d.length&&!(d[P].dts>I);P++)d[P].dts-=w,d[P].pts-=w;A.log("Video: Initial PTS/DTS adjusted: "+ce(I,!0)+"/"+ce(n,!0)+", delta: "+ce(w,!0)+" ms")}}for(var O=0,B=0,F=n=Math.max(0,n),M=0;M<h;M++){for(var H=d[M],G=H.units,V=G.length,$=0,nt=0;nt<V;nt++)$+=G[nt].data.length;B+=$,O+=V,H.length=$,H.dts<F?(H.dts=F,F+=x/4|0||1):F=H.dts,y=Math.min(H.pts,y),v=Math.max(H.pts,v)}o=d[h-1].dts;var rt,tt=B+4*O+8;try{rt=new Uint8Array(tt)}catch(Ne){return void this.observer.emit(E.ERROR,E.ERROR,{type:W.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:Ne,bytes:tt,reason:"fail allocating video mdat "+tt})}var et=new DataView(rt.buffer);et.setUint32(0,tt),rt.set(ht.types.mdat,4);for(var z=!1,Z=Number.POSITIVE_INFINITY,j=Number.POSITIVE_INFINITY,q=Number.NEGATIVE_INFINITY,J=Number.NEGATIVE_INFINITY,X=0;X<h;X++){for(var Y=d[X],mt=Y.units,Mt=0,Nt=0,Rt=mt.length;Nt<Rt;Nt++){var pt=mt[Nt],Et=pt.data,_t=pt.data.byteLength;et.setUint32(m,_t),m+=4,rt.set(Et,m),m+=_t,Mt+=4+_t}var vt=void 0;if(X<h-1)g=d[X+1].dts-Y.dts,vt=d[X+1].pts-Y.pts;else{var ve=this.config,te=X>0?Y.dts-d[X-1].dts:x;if(vt=X>0?Y.pts-d[X-1].pts:x,ve.stretchShortVideoTrack&&this.nextAudioPts!==null){var Rr=Math.floor(ve.maxBufferHole*l),ge=(i?y+i*l:this.nextAudioPts)-Y.pts;ge>Rr?((g=ge-te)<0?g=te:z=!0,A.log("[mp4-remuxer]: It is approximately "+ge/90+" ms to the next segment; using duration "+g/90+" ms for the last video frame.")):g=te}else g=te}var Me=Math.round(Y.pts-Y.dts);Z=Math.min(Z,g),q=Math.max(q,g),j=Math.min(j,vt),J=Math.max(J,vt),u.push(new ra(Y.key,g,Mt,Me))}if(u.length){if($t){if($t<70){var me=u[0].flags;me.dependsOn=2,me.isNonSync=0}}else if(mr&&J-j<q-Z&&x/q<.025&&u[0].cts===0){A.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ee=n,Q=0,st=u.length;Q<st;Q++){var ot=ee+u[Q].duration,Ar=ee+u[Q].cts;if(Q<st-1){var zn=ot+u[Q+1].cts;u[Q].duration=zn-Ar}else u[Q].duration=Q?u[Q-1].duration:x;u[Q].cts=0,ee=ot}}}g=z||!g?x:g,this.nextAvcDts=c=o+g,this.videoSampleDuration=g,this.isVideoContiguous=!0;var Xn={data1:ht.moof(t.sequenceNumber++,n,gt({},t,{samples:u})),data2:rt,startPTS:y/l,endPTS:(v+g)/l,startDTS:n/l,endDTS:c/l,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:t.dropped};return t.samples=[],t.dropped=0,Xn},a.getSamplesPerFrame=function(t){switch(t.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}},a.remuxAudio=function(t,e,r,i,n){var o=t.inputTimeScale,l=o/(t.samplerate?t.samplerate:o),d=this.getSamplesPerFrame(t),u=d*l,h=this._initPTS,f=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,c=[],m=n!==void 0,g=t.samples,y=f?0:8,v=this.nextAudioPts||-1,p=e*o,S=h.baseTime*o/h.timescale;if(this.isAudioContiguous=r=r||g.length&&v>0&&(i&&Math.abs(p-v)<9e3||Math.abs(Lt(g[0].pts-S,p)-v)<20*u),g.forEach(function(X){X.pts=Lt(X.pts-S,p)}),!r||v<0){if(g=g.filter(function(X){return X.pts>=0}),!g.length)return;v=n===0?0:i&&!m?Math.max(0,p):g[0].pts}if(t.segmentCodec==="aac")for(var T=this.config.maxAudioFramesDrift,R=0,b=v;R<g.length;R++){var L=g[R],_=L.pts,x=_-b,w=Math.abs(1e3*x/o);if(x<=-T*u&&m)R===0&&(A.warn("Audio frame @ "+(_/o).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*x/o)+" ms."),this.nextAudioPts=v=b=_);else if(x>=T*u&&w<1e4&&m){var k=Math.round(x/u);(b=_-k*u)<0&&(k--,b+=u),R===0&&(this.nextAudioPts=v=b),A.warn("[mp4-remuxer]: Injecting "+k+" audio frame @ "+(b/o).toFixed(3)+"s due to "+Math.round(1e3*x/o)+" ms gap.");for(var C=0;C<k;C++){var I=Math.max(b,0),P=$i.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);P||(A.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),P=L.unit.subarray()),g.splice(R,0,{unit:P,pts:I}),b+=u,R++}}L.pts=b,b+=u}for(var O,B=null,F=null,M=0,H=g.length;H--;)M+=g[H].unit.byteLength;for(var G=0,V=g.length;G<V;G++){var $=g[G],nt=$.unit,rt=$.pts;if(F!==null)c[G-1].duration=Math.round((rt-F)/l);else{if(r&&t.segmentCodec==="aac"&&(rt=v),B=rt,!(M>0))return;M+=y;try{O=new Uint8Array(M)}catch(X){return void this.observer.emit(E.ERROR,E.ERROR,{type:W.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:X,bytes:M,reason:"fail allocating audio mdat "+M})}f||(new DataView(O.buffer).setUint32(0,M),O.set(ht.types.mdat,4))}O.set(nt,y);var tt=nt.byteLength;y+=tt,c.push(new ra(!0,d,tt,0)),F=rt}var et=c.length;if(et){var z=c[c.length-1];this.nextAudioPts=v=F+l*z.duration;var Z=f?new Uint8Array(0):ht.moof(t.sequenceNumber++,B/l,gt({},t,{samples:c}));t.samples=[];var j=B/o,q=v/o,J={data1:Z,data2:O,startPTS:j,endPTS:q,startDTS:j,endDTS:q,type:"audio",hasAudio:!0,hasVideo:!1,nb:et};return this.isAudioContiguous=!0,J}},a.remuxEmptyAudio=function(t,e,r,i){var n=t.inputTimeScale,o=n/(t.samplerate?t.samplerate:n),l=this.nextAudioPts,d=this._initDTS,u=9e4*d.baseTime/d.timescale,h=(l!==null?l:i.startDTS*n)+u,f=i.endDTS*n+u,c=1024*o,m=Math.ceil((f-h)/c),g=$i.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(A.warn("[mp4-remuxer]: remux empty Audio"),g){for(var y=[],v=0;v<m;v++){var p=h+v*c;y.push({unit:g,pts:p,dts:p})}return t.samples=y,this.remuxAudio(t,e,r,!1)}A.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},s}();function Lt(s,a){var t;if(a===null)return s;for(t=a<s?-8589934592:8589934592;Math.abs(s-a)>4294967296;)s+=t;return s}function ta(s,a,t,e){var r=s.samples.length;if(r){for(var i=s.inputTimeScale,n=0;n<r;n++){var o=s.samples[n];o.pts=Lt(o.pts-t.baseTime*i/t.timescale,a*i)/i,o.dts=Lt(o.dts-e.baseTime*i/e.timescale,a*i)/i}var l=s.samples;return s.samples=[],{samples:l}}}function ea(s,a,t){var e=s.samples.length;if(e){for(var r=s.inputTimeScale,i=0;i<e;i++){var n=s.samples[i];n.pts=Lt(n.pts-t.baseTime*r/t.timescale,a*r)/r}s.samples.sort(function(l,d){return l.pts-d.pts});var o=s.samples;return s.samples=[],{samples:o}}}var ra=function(s,a,t,e){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=a,this.size=t,this.cts=e,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:s?2:1,isNonSync:s?0:1}},Vn=function(){function s(){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}var a=s.prototype;return a.destroy=function(){},a.resetTimeStamp=function(t){this.initPTS=t,this.lastEndTime=null},a.resetNextTimestamp=function(){this.lastEndTime=null},a.resetInitSegment=function(t,e,r,i){this.audioCodec=e,this.videoCodec=r,this.generateInitSegment(Ia(t,i)),this.emitInitSegment=!0},a.generateInitSegment=function(t){var e=this.audioCodec,r=this.videoCodec;if(t==null||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=Wr(t);i.audio&&(e=ia(i.audio,Tt)),i.video&&(r=ia(i.video,bt));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:A.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n},a.remux=function(t,e,r,i,n,o){var l,d,u=this.initPTS,h=this.lastEndTime,f={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};N(h)||(h=this.lastEndTime=n||0);var c=e.samples;if(c==null||!c.length)return f;var m={initPTS:void 0,timescale:1},g=this.initData;if((l=g)!=null&&l.length||(this.generateInitSegment(c),g=this.initData),(d=g)==null||!d.length)return A.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),f;this.emitInitSegment&&(m.tracks=this.initTracks,this.emitInitSegment=!1);var y=function(x,w){for(var k=0,C=0,I=0,P=K(x,["moof","traf"]),O=0;O<P.length;O++){var B=P[O],F=K(B,["tfhd"])[0],M=w[U(F,4)];if(M){var H=M.default,G=U(F,0)|H?.flags,V=H?.duration;8&G&&(V=U(F,2&G?12:8));for(var $=M.timescale||9e4,nt=K(B,["trun"]),rt=0;rt<nt.length;rt++)!(k=Pa(nt[rt]))&&V&&(k=V*U(nt[rt],4)),M.type===bt?C+=k/$:M.type===Tt&&(I+=k/$)}}if(C===0&&I===0){for(var tt=1/0,et=0,z=0,Z=K(x,["sidx"]),j=0;j<Z.length;j++){var q=xa(Z[j]);if(q!=null&&q.references){tt=Math.min(tt,q.earliestPresentationTime/q.timescale);var J=q.references.reduce(function(X,Y){return X+Y.info.duration||0},0);z=(et=Math.max(et,J+q.earliestPresentationTime/q.timescale))-tt}}if(z&&N(z))return z}return C||I}(c,g),v=function(x,w){return K(w,["moof","traf"]).reduce(function(k,C){var I=K(C,["tfdt"])[0],P=I[0],O=K(C,["tfhd"]).reduce(function(B,F){var M=U(F,4),H=x[M];if(H){var G=U(I,4);if(P===1){if(G===Se)return A.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),B;G*=Se+1,G+=U(I,8)}var V=G/(H.timescale||9e4);if(N(V)&&(B===null||V<B))return V}return B},null);return O!==null&&N(O)&&(k===null||O<k)?O:k},null)}(g,c),p=v===null?n:v;(function(x,w,k,C){if(x===null)return!0;var I=Math.max(C,1),P=w-x.baseTime/x.timescale;return Math.abs(P-k)>I}(u,p,n,y)||m.timescale!==u.timescale&&o)&&(m.initPTS=p-n,u&&u.timescale===1&&A.warn("Adjusting initPTS by "+(m.initPTS-u.baseTime)),this.initPTS=u={baseTime:m.initPTS,timescale:1});var S=t?p-u.baseTime/u.timescale:h,T=S+y;(function(x,w,k){K(w,["moof","traf"]).forEach(function(C){K(C,["tfhd"]).forEach(function(I){var P=U(I,4),O=x[P];if(O){var B=O.timescale||9e4;K(C,["tfdt"]).forEach(function(F){var M=F[0],H=k*B;if(H){var G=U(F,4);if(M===0)G-=H,Ye(F,4,G=Math.max(G,0));else{G*=Math.pow(2,32),G+=U(F,8),G-=H,G=Math.max(G,0);var V=Math.floor(G/(Se+1)),$=Math.floor(G%(Se+1));Ye(F,4,V),Ye(F,8,$)}}})}})})})(g,c,u.baseTime/u.timescale),y>0?this.lastEndTime=T:(A.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var R=!!g.audio,b=!!g.video,L="";R&&(L+="audio"),b&&(L+="video");var _={data1:c,startPTS:S,startDTS:S,endPTS:T,endDTS:T,type:L,hasAudio:R,hasVideo:b,nb:1,dropped:0};return f.audio=_.type==="audio"?_:void 0,f.video=_.type!=="audio"?_:void 0,f.initSegment=m,f.id3=ta(r,n,u,u),i.samples.length&&(f.text=ea(i,n,u)),f},s}();function ia(s,a){var t=s?.codec;if(t&&t.length>4)return t;if(a===Tt){if(t==="ec-3"||t==="ac-3"||t==="alac")return t;if(t==="fLaC"||t==="Opus")return be(t,!1);var e="mp4a.40.5";return A.info('Parsed audio codec "'+t+'" or audio object type not handled. Using "'+e+'"'),e}return A.warn('Unhandled video codec "'+t+'"'),t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":"avc1.42e01e"}var Ot,aa=typeof self<"u"?self:void 0;try{Ot=self.performance.now.bind(self.performance)}catch{A.debug("Unable to use Performance API on this environment"),Ot=aa?.Date.now}var yr=[{demux:Fn,remux:Vn},{demux:Bn,remux:pr},{demux:In,remux:pr},{demux:Hn,remux:pr}],Er=function(){function s(t,e,r,i,n){this.async=!1,this.observer=void 0,this.typeSupported=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=r,this.vendor=i,this.id=n}var a=s.prototype;return a.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},a.push=function(t,e,r,i){var n=this,o=r.transmuxing;o.executeStart=Ot();var l=new Uint8Array(t),d=this.currentTransmuxState,u=this.transmuxConfig;i&&(this.currentTransmuxState=i);var h=i||d,f=h.contiguous,c=h.discontinuity,m=h.trackSwitch,g=h.accurateTimeOffset,y=h.timeOffset,v=h.initSegmentChange,p=u.audioCodec,S=u.videoCodec,T=u.defaultInitPts,R=u.duration,b=u.initSegmentData,L=function(P,O){var B=null;return P.byteLength>0&&O?.key!=null&&O.iv!==null&&O.method!=null&&(B=O),B}(l,e);if(L&&L.method==="AES-128"){var _=this.getDecrypter();if(!_.isSync())return this.decryptionPromise=_.webCryptoDecrypt(l,L.key.buffer,L.iv.buffer).then(function(P){var O=n.push(P,null,r);return n.decryptionPromise=null,O}),this.decryptionPromise;var x=_.softwareDecrypt(l,L.key.buffer,L.iv.buffer);if(r.part>-1&&(x=_.flush()),!x)return o.executeEnd=Ot(),Tr(r);l=new Uint8Array(x)}var w=this.needsProbing(c,m);if(w){var k=this.configureTransmuxer(l);if(k)return A.warn("[transmuxer] "+k.message),this.observer.emit(E.ERROR,E.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:k,reason:k.message}),o.executeEnd=Ot(),Tr(r)}(c||m||v||w)&&this.resetInitSegment(b,p,S,R,e),(c||v||w)&&this.resetInitialTimestamp(T),f||this.resetContiguity();var C=this.transmux(l,L,y,g,r),I=this.currentTransmuxState;return I.contiguous=!0,I.discontinuity=!1,I.trackSwitch=!1,o.executeEnd=Ot(),C},a.flush=function(t){var e=this,r=t.transmuxing;r.executeStart=Ot();var i=this.decrypter,n=this.currentTransmuxState,o=this.decryptionPromise;if(o)return o.then(function(){return e.flush(t)});var l=[],d=n.timeOffset;if(i){var u=i.flush();u&&l.push(this.push(u,null,t))}var h=this.demuxer,f=this.remuxer;if(!h||!f)return r.executeEnd=Ot(),[Tr(t)];var c=h.flush(d);return qt(c)?c.then(function(m){return e.flushRemux(l,m,t),l}):(this.flushRemux(l,c,t),l)},a.flushRemux=function(t,e,r){var i=e.audioTrack,n=e.videoTrack,o=e.id3Track,l=e.textTrack,d=this.currentTransmuxState,u=d.accurateTimeOffset,h=d.timeOffset;A.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var f=this.remuxer.remux(i,n,o,l,h,u,!0,this.id);t.push({remuxResult:f,chunkMeta:r}),r.transmuxing.executeEnd=Ot()},a.resetInitialTimestamp=function(t){var e=this.demuxer,r=this.remuxer;e&&r&&(e.resetTimeStamp(t),r.resetTimeStamp(t))},a.resetContiguity=function(){var t=this.demuxer,e=this.remuxer;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())},a.resetInitSegment=function(t,e,r,i,n){var o=this.demuxer,l=this.remuxer;o&&l&&(o.resetInitSegment(t,e,r,i),l.resetInitSegment(t,e,r,n))},a.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},a.transmux=function(t,e,r,i,n){return e&&e.method==="SAMPLE-AES"?this.transmuxSampleAes(t,e,r,i,n):this.transmuxUnencrypted(t,r,i,n)},a.transmuxUnencrypted=function(t,e,r,i){var n=this.demuxer.demux(t,e,!1,!this.config.progressive),o=n.audioTrack,l=n.videoTrack,d=n.id3Track,u=n.textTrack;return{remuxResult:this.remuxer.remux(o,l,d,u,e,r,!1,this.id),chunkMeta:i}},a.transmuxSampleAes=function(t,e,r,i,n){var o=this;return this.demuxer.demuxSampleAes(t,e,r).then(function(l){return{remuxResult:o.remuxer.remux(l.audioTrack,l.videoTrack,l.id3Track,l.textTrack,r,i,!1,o.id),chunkMeta:n}})},a.configureTransmuxer=function(t){for(var e,r=this.config,i=this.observer,n=this.typeSupported,o=this.vendor,l=0,d=yr.length;l<d;l++){var u;if((u=yr[l].demux)!=null&&u.probe(t)){e=yr[l];break}}if(!e)return new Error("Failed to find demuxer by probing fragment data");var h=this.demuxer,f=this.remuxer,c=e.remux,m=e.demux;f&&f instanceof c||(this.remuxer=new c(i,r,n,o)),h&&h instanceof m||(this.demuxer=new m(i,r,n),this.probe=m.probe)},a.needsProbing=function(t,e){return!this.demuxer||!this.remuxer||t||e},a.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new ur(this.config)),t},s}(),Tr=function(s){return{remuxResult:{},chunkMeta:s}};function qt(s){return"then"in s&&s.then instanceof Function}var Kn=function(s,a,t,e,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=s,this.videoCodec=a,this.initSegmentData=t,this.duration=e,this.defaultInitPts=r||null},jn=function(s,a,t,e,r,i){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=s,this.contiguous=a,this.accurateTimeOffset=t,this.trackSwitch=e,this.timeOffset=r,this.initSegmentChange=i},na={exports:{}};(function(s){var a=Object.prototype.hasOwnProperty,t="~";function e(){}function r(l,d,u){this.fn=l,this.context=d,this.once=u||!1}function i(l,d,u,h,f){if(typeof u!="function")throw new TypeError("The listener must be a function");var c=new r(u,h||l,f),m=t?t+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],c]:l._events[m].push(c):(l._events[m]=c,l._eventsCount++),l}function n(l,d){--l._eventsCount==0?l._events=new e:delete l._events[d]}function o(){this._events=new e,this._eventsCount=0}Object.create&&(e.prototype=Object.create(null),new e().__proto__||(t=!1)),o.prototype.eventNames=function(){var l,d,u=[];if(this._eventsCount===0)return u;for(d in l=this._events)a.call(l,d)&&u.push(t?d.slice(1):d);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(l)):u},o.prototype.listeners=function(l){var d=t?t+l:l,u=this._events[d];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,f=u.length,c=new Array(f);h<f;h++)c[h]=u[h].fn;return c},o.prototype.listenerCount=function(l){var d=t?t+l:l,u=this._events[d];return u?u.fn?1:u.length:0},o.prototype.emit=function(l,d,u,h,f,c){var m=t?t+l:l;if(!this._events[m])return!1;var g,y,v=this._events[m],p=arguments.length;if(v.fn){switch(v.once&&this.removeListener(l,v.fn,void 0,!0),p){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,d),!0;case 3:return v.fn.call(v.context,d,u),!0;case 4:return v.fn.call(v.context,d,u,h),!0;case 5:return v.fn.call(v.context,d,u,h,f),!0;case 6:return v.fn.call(v.context,d,u,h,f,c),!0}for(y=1,g=new Array(p-1);y<p;y++)g[y-1]=arguments[y];v.fn.apply(v.context,g)}else{var S,T=v.length;for(y=0;y<T;y++)switch(v[y].once&&this.removeListener(l,v[y].fn,void 0,!0),p){case 1:v[y].fn.call(v[y].context);break;case 2:v[y].fn.call(v[y].context,d);break;case 3:v[y].fn.call(v[y].context,d,u);break;case 4:v[y].fn.call(v[y].context,d,u,h);break;default:if(!g)for(S=1,g=new Array(p-1);S<p;S++)g[S-1]=arguments[S];v[y].fn.apply(v[y].context,g)}}return!0},o.prototype.on=function(l,d,u){return i(this,l,d,u,!1)},o.prototype.once=function(l,d,u){return i(this,l,d,u,!0)},o.prototype.removeListener=function(l,d,u,h){var f=t?t+l:l;if(!this._events[f])return this;if(!d)return n(this,f),this;var c=this._events[f];if(c.fn)c.fn!==d||h&&!c.once||u&&c.context!==u||n(this,f);else{for(var m=0,g=[],y=c.length;m<y;m++)(c[m].fn!==d||h&&!c[m].once||u&&c[m].context!==u)&&g.push(c[m]);g.length?this._events[f]=g.length===1?g[0]:g:n(this,f)}return this},o.prototype.removeAllListeners=function(l){var d;return l?(d=t?t+l:l,this._events[d]&&n(this,d)):(this._events=new e,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,s.exports=o})(na);var Sr=xr(na.exports);function Lr(s,a){if(!((t=a.remuxResult).audio||t.video||t.text||t.id3||t.initSegment))return!1;var t,e=[],r=a.remuxResult,i=r.audio,n=r.video;return i&&sa(e,i),n&&sa(e,n),s.postMessage({event:"transmuxComplete",data:a},e),!0}function sa(s,a){a.data1&&s.push(a.data1.buffer),a.data2&&s.push(a.data2.buffer)}function oa(s,a,t){a.reduce(function(e,r){return Lr(s,r)||e},!1)||s.postMessage({event:"transmuxComplete",data:a[0]}),s.postMessage({event:"flush",data:t})}br!==void 0&&br&&function(s){var a=new Sr,t=function(r,i){s.postMessage({event:r,data:i})};a.on(E.FRAG_DECRYPTED,t),a.on(E.ERROR,t);var e=function(){var r=function(n){var o=function(l){t("workerLog",{logType:n,message:l})};A[n]=o};for(var i in A)r(i)};s.addEventListener("message",function(r){var i=r.data;switch(i.cmd){case"init":var n=JSON.parse(i.config);s.transmuxer=new Er(a,i.typeSupported,n,i.vendor,i.id),Ir(n.debug,i.id),e(),t("init",null);break;case"configure":s.transmuxer.configure(i.config);break;case"demux":var o=s.transmuxer.push(i.data,i.decryptdata,i.chunkMeta,i.state);qt(o)?(s.transmuxer.async=!0,o.then(function(u){Lr(s,u)}).catch(function(u){t(E.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:u,err:u,reason:"transmuxer-worker push error"})})):(s.transmuxer.async=!1,Lr(s,o));break;case"flush":var l=i.chunkMeta,d=s.transmuxer.flush(l);qt(d)||s.transmuxer.async?(qt(d)||(d=Promise.resolve(d)),d.then(function(u){oa(s,u,l)}).catch(function(u){t(E.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:u,err:u,reason:"transmuxer-worker flush error"})})):oa(s,d,l)}})}(self);var Wn=function(){function s(t,e,r,i){var n=this;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;var o=t.config;this.hls=t,this.id=e,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;var l=function(v,p){(p=p||{}).frag=n.frag,p.id=n.id,v===E.ERROR&&(n.error=p.error),n.hls.trigger(v,p)};this.observer=new Sr,this.observer.on(E.FRAG_DECRYPTED,l),this.observer.on(E.ERROR,l);var d,u,h,f,c=Kt(o.preferManagedMediaSource)||{isTypeSupported:function(){return!1}},m={mpeg:c.isTypeSupported("audio/mpeg"),mp3:c.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1},g=navigator.vendor;if(!this.useWorker||typeof Worker>"u"||(o.workerPath,0))this.transmuxer=new Er(this.observer,m,o,g,e);else try{o.workerPath?(A.log("loading Web Worker "+o.workerPath+' for "'+e+'"'),this.workerContext=(h=o.workerPath,f=new self.URL(h,self.location.href).href,{worker:new self.Worker(f),scriptURL:f})):(A.log('injecting Web Worker for "'+e+'"'),this.workerContext=(d=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+fa.toString()+")(true);"],{type:"text/javascript"}),u=self.URL.createObjectURL(d),{worker:new self.Worker(u),objectURL:u})),this.onwmsg=function(v){return n.onWorkerMessage(v)};var y=this.workerContext.worker;y.addEventListener("message",this.onwmsg),y.onerror=function(v){var p=new Error(v.message+" ("+v.filename+":"+v.lineno+")");o.enableWorker=!1,A.warn('Error in "'+e+'" Web Worker, fallback to inline'),n.hls.trigger(E.ERROR,{type:W.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:p})},y.postMessage({cmd:"init",typeSupported:m,vendor:g,id:e,config:JSON.stringify(o)})}catch(v){A.warn('Error setting up "'+e+'" Web Worker, fallback to inline',v),this.resetWorker(),this.error=null,this.transmuxer=new Er(this.observer,m,o,g,e)}}var a=s.prototype;return a.resetWorker=function(){if(this.workerContext){var t=this.workerContext,e=t.worker,r=t.objectURL;r&&self.URL.revokeObjectURL(r),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}},a.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}var e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},a.push=function(t,e,r,i,n,o,l,d,u,h){var f,c,m=this;u.transmuxing.start=self.performance.now();var g=this.transmuxer,y=o?o.start:n.start,v=n.decryptdata,p=this.frag,S=!(p&&n.cc===p.cc),T=!(p&&u.level===p.level),R=p?u.sn-p.sn:-1,b=this.part?u.part-this.part.index:-1,L=R===0&&u.id>1&&u.id===p?.stats.chunkCount,_=!T&&(R===1||R===0&&(b===1||L&&b<=0)),x=self.performance.now();(T||R||n.stats.parsing.start===0)&&(n.stats.parsing.start=x),!o||!b&&_||(o.stats.parsing.start=x);var w=!(p&&((f=n.initSegment)==null?void 0:f.url)===((c=p.initSegment)==null?void 0:c.url)),k=new jn(S,_,d,T,y,w);if(!_||S||w){A.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+`
|
9
|
-
discontinuity:
|
10
|
-
trackSwitch:
|
11
|
-
contiguous:
|
12
|
-
accurateTimeOffset:
|
13
|
-
timeOffset:
|
14
|
-
initSegmentChange: `+w);var C=new Kn(r,i,e,l,h);this.configureTransmuxer(C)}if(this.frag=n,this.part=o,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:v,chunkMeta:u,state:k},t instanceof ArrayBuffer?[t]:[]);else if(g){var I=g.push(t,v,u,k);qt(I)?(g.async=!0,I.then(function(P){m.handleTransmuxComplete(P)}).catch(function(P){m.transmuxerError(P,u,"transmuxer-interface push error")})):(g.async=!1,this.handleTransmuxComplete(I))}},a.flush=function(t){var e=this;t.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(r){var i=r.flush(t);qt(i)||r.async?(qt(i)||(i=Promise.resolve(i)),i.then(function(n){e.handleFlushResult(n,t)}).catch(function(n){e.transmuxerError(n,t,"transmuxer-interface flush error")})):this.handleFlushResult(i,t)}},a.transmuxerError=function(t,e,r){this.hls&&(this.error=t,this.hls.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:r}))},a.handleFlushResult=function(t,e){var r=this;t.forEach(function(i){r.handleTransmuxComplete(i)}),this.onFlush(e)},a.onWorkerMessage=function(t){var e=t.data,r=this.hls;switch(e.event){case"init":var i,n=(i=this.workerContext)==null?void 0:i.objectURL;n&&self.URL.revokeObjectURL(n);break;case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;case"workerLog":A[e.data.logType]&&A[e.data.logType](e.data.message);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,r.trigger(e.event,e.data)}},a.configureTransmuxer=function(t){var e=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)},a.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},s}(),Yn=function(){function s(t,e,r,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=r,this.hls=i}var a=s.prototype;return a.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},a.poll=function(t,e){var r=this.config,i=this.media,n=this.stalled;if(i!==null){var o=i.currentTime,l=i.seeking,d=this.seeking&&!l,u=!this.seeking&&l;if(this.seeking=l,o===t)if(u||d)this.stalled=null;else if(i.paused&&!l||i.ended||i.playbackRate===0||!ut.getBuffered(i).length)this.nudgeRetry=0;else{var h=ut.bufferInfo(i,o,0),f=h.nextStart||0;if(l){var c=h.len>2,m=!f||e&&e.start<=o||f-o>2&&!this.fragmentTracker.getPartialFragment(o);if(c||m)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var g;if(!(h.len>0||f))return;var y=Math.max(f,h.start||0)-o,v=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,p=!(v==null||(g=v.details)==null)&&g.live?2*v.details.targetduration:2,S=this.fragmentTracker.getPartialFragment(o);if(y>0&&(y<=p||S))return void(i.paused||this._trySkipBufferHole(S))}var T=self.performance.now();if(n!==null){var R=T-n;if(l||!(R>=250)||(this._reportStall(h),this.media)){var b=ut.bufferInfo(i,o,r.maxBufferHole);this._tryFixBufferStall(b,R)}}else this.stalled=T}else if(this.moved=!0,l||(this.nudgeRetry=0),n!==null){if(this.stallReported){var L=self.performance.now()-n;A.warn("playback not stuck anymore @"+o+", after "+Math.round(L)+"ms"),this.stallReported=!1}this.stalled=null}}},a._tryFixBufferStall=function(t,e){var r=this.config,i=this.fragmentTracker,n=this.media;if(n!==null){var o=n.currentTime,l=i.getPartialFragment(o);if(l&&(this._trySkipBufferHole(l)||!this.media))return;(t.len>r.maxBufferHole||t.nextStart&&t.nextStart-o<r.maxBufferHole)&&e>1e3*r.highBufferWatchdogPeriod&&(A.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},a._reportStall=function(t){var e=this.hls,r=this.media;if(!this.stallReported&&r){this.stallReported=!0;var i=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(t)+")");A.warn(i.message),e.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:t.len})}},a._trySkipBufferHole=function(t){var e=this.config,r=this.hls,i=this.media;if(i===null)return 0;var n=i.currentTime,o=ut.bufferInfo(i,n,0),l=n<o.start?o.start:o.nextStart;if(l){var d=o.len<=e.maxBufferHole,u=o.len>0&&o.len<1&&i.readyState<3,h=l-n;if(h>0&&(d||u)){if(h>e.maxBufferHole){var f=this.fragmentTracker,c=!1;if(n===0){var m=f.getAppendedFrag(0,at);m&&l<m.end&&(c=!0)}if(!c){var g=t||f.getAppendedFrag(n,at);if(g){for(var y=!1,v=g.end;v<l;){var p=f.getPartialFragment(v);if(!p){y=!0;break}v+=p.duration}if(y)return 0}}}var S=Math.max(l+.05,n+.1);if(A.warn("skipping hole, adjusting currentTime from "+n+" to "+S),this.moved=!0,this.stalled=null,i.currentTime=S,t&&!t.gap){var T=new Error("fragment loaded with buffer holes, seeking from "+n+" to "+S);r.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:T,reason:T.message,frag:t})}return S}}return 0},a._tryNudgeBuffer=function(){var t=this.config,e=this.hls,r=this.media,i=this.nudgeRetry;if(r!==null){var n=r.currentTime;if(this.nudgeRetry++,i<t.nudgeMaxRetry){var o=n+(i+1)*t.nudgeOffset,l=new Error("Nudging 'currentTime' from "+n+" to "+o);A.warn(l.message),r.currentTime=o,e.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:D.BUFFER_NUDGE_ON_STALL,error:l,fatal:!1})}else{var d=new Error("Playhead still not moving while enough data buffered @"+n+" after "+t.nudgeMaxRetry+" nudges");A.error(d.message),e.trigger(E.ERROR,{type:W.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,error:d,fatal:!0})}}},s}(),qn=function(s){function a(e,r,i){var n;return(n=s.call(this,e,r,i,"[stream-controller]",at)||this).audioCodecSwap=!1,n.gapController=null,n.level=-1,n._forceStartLoad=!1,n.altAudio=!1,n.audioOnly=!1,n.fragPlaying=null,n.onvplaying=null,n.onvseeked=null,n.fragLastKbps=0,n.couldBacktrack=!1,n.backtrackFragment=null,n.audioCodecSwitch=!1,n.videoBuffer=null,n._registerListeners(),n}At(a,s);var t=a.prototype;return t._registerListeners=function(){var e=this.hls;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(E.ERROR,this.onError,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this)},t._unregisterListeners=function(){var e=this.hls;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(E.ERROR,this.onError,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)},t.onHandlerDestroying=function(){this._unregisterListeners(),s.prototype.onHandlerDestroying.call(this)},t.startLoad=function(e){if(this.levels){var r=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var n=i.startLevel;n===-1&&(i.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=i.firstAutoLevel),i.nextLoadLevel=n,this.level=i.loadLevel,this.loadedmetadata=!1}r>0&&e===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),e=r),this.state=it,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=Ft},t.stopLoad=function(){this._forceStartLoad=!1,s.prototype.stopLoad.call(this)},t.doTick=function(){switch(this.state){case Yt:var e=this.levels,r=this.level,i=e?.[r],n=i?.details;if(n&&(!n.live||this.levelLastLoaded===i)){if(this.waitForCdnTuneIn(n))break;this.state=it;break}if(this.hls.nextLoadLevel!==this.level){this.state=it;break}break;case he:var o,l=self.performance.now(),d=this.retryDate;if(!d||l>=d||(o=this.media)!=null&&o.seeking){var u=this.levels,h=this.level,f=u?.[h];this.resetStartWhenNotLoaded(f||null),this.state=it}}this.state===it&&this.doTickIdle(),this.onTickEnd()},t.onTickEnd=function(){s.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},t.doTickIdle=function(){var e=this.hls,r=this.levelLastLoaded,i=this.levels,n=this.media;if(r!==null&&(n||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var o=e.nextLoadLevel;if(i!=null&&i[o]){var l=i[o],d=this.getMainFwdBufferInfo();if(d!==null){var u=this.getLevelDetails();if(u&&this._streamEnded(d,u)){var h={};return this.altAudio&&(h.type="video"),this.hls.trigger(E.BUFFER_EOS,h),void(this.state=hr)}e.loadLevel!==o&&e.manualLevel===-1&&this.log("Adapting to level "+o+" from level "+this.level),this.level=e.nextLoadLevel=o;var f=l.details;if(!f||this.state===Yt||f.live&&this.levelLastLoaded!==l)return this.level=o,void(this.state=Yt);var c=d.len,m=this.getMaxBufferLength(l.maxBitrate);if(!(c>=m)){this.backtrackFragment&&this.backtrackFragment.start>d.end&&(this.backtrackFragment=null);var g=this.backtrackFragment?this.backtrackFragment.start:d.end,y=this.getNextFragment(g,f);if(this.couldBacktrack&&!this.fragPrevious&&y&&y.sn!=="initSegment"&&this.fragmentTracker.getState(y)!==ue){var v,p=((v=this.backtrackFragment)!=null?v:y).sn-f.startSN,S=f.fragments[p-1];S&&y.cc===S.cc&&(y=S,this.fragmentTracker.removeFragment(S))}else this.backtrackFragment&&d.len&&(this.backtrackFragment=null);if(y&&this.isLoopLoading(y,g)){if(!y.gap){var T=this.audioOnly&&!this.altAudio?Tt:bt,R=(T===bt?this.videoBuffer:this.mediaBuffer)||this.media;R&&this.afterBufferFlushed(R,T,at)}y=this.getNextFragmentLoopLoading(y,f,d,at,m)}y&&(!y.initSegment||y.initSegment.data||this.bitrateTest||(y=y.initSegment),this.loadFragment(y,l,g))}}}}},t.loadFragment=function(e,r,i){var n=this.fragmentTracker.getState(e);this.fragCurrent=e,n===Ii||n===le?e.sn==="initSegment"?this._loadInitSegment(e,r):this.bitrateTest?(this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e,r)):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,e,r,i)):this.clearTrackerIfNeeded(e)},t.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,at)},t.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},t.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},t.nextLevelSwitch=function(){var e=this.levels,r=this.media;if(r!=null&&r.readyState){var i,n=this.getAppendedFrag(r.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);var o=this.getLevelDetails();if(o!=null&&o.live){var l=this.getMainFwdBufferInfo();if(!l||l.len<2*o.targetduration)return}if(!r.paused&&e){var d=e[this.hls.nextLoadLevel],u=this.fragLastKbps;i=u&&this.fragCurrent?this.fragCurrent.duration*d.maxBitrate/(1e3*u)+1:0}else i=0;var h=this.getBufferedFrag(r.currentTime+i);if(h){var f=this.followingBufferedFrag(h);if(f){this.abortCurrentFrag();var c=f.maxStartPTS?f.maxStartPTS:f.start,m=f.duration,g=Math.max(h.end,c+Math.min(Math.max(m-this.config.maxFragLookUpTolerance,m*(this.couldBacktrack?.5:.125)),m*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(g,Number.POSITIVE_INFINITY)}}}},t.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case dr:case de:case he:case Wt:case Pe:this.state=it}this.nextLoadPosition=this.getLoadPosition()},t.flushMainBuffer=function(e,r){s.prototype.flushMainBuffer.call(this,e,r,this.altAudio?"video":null)},t.onMediaAttached=function(e,r){s.prototype.onMediaAttached.call(this,e,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new Yn(this.config,i,this.fragmentTracker,this.hls)},t.onMediaDetaching=function(){var e=this.media;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),s.prototype.onMediaDetaching.call(this)},t.onMediaPlaying=function(){this.tick()},t.onMediaSeeked=function(){var e=this.media,r=e?e.currentTime:null;N(r)&&this.log("Media seeked to "+r.toFixed(3));var i=this.getMainFwdBufferInfo();i!==null&&i.len!==0?this.tick():this.warn('Main forward buffer length on "seeked" event '+(i?i.len:"empty")+")")},t.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(E.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1},t.onManifestParsed=function(e,r){var i,n,o=!1,l=!1;r.levels.forEach(function(d){var u=d.audioCodec;u&&(o=o||u.indexOf("mp4a.40.2")!==-1,l=l||u.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=o&&l&&typeof((n=Gi())==null||(i=n.prototype)==null?void 0:i.changeType)!="function",this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},t.onLevelLoading=function(e,r){var i=this.levels;if(i&&this.state===it){var n=i[r.level];(!n.details||n.details.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(n.details))&&(this.state=Yt)}},t.onLevelLoaded=function(e,r){var i,n=this.levels,o=r.level,l=r.details,d=l.totalduration;if(n){this.log("Level "+o+" loaded ["+l.startSN+","+l.endSN+"]"+(l.lastPartSn?"[part-"+l.lastPartSn+"-"+l.lastPartIndex+"]":"")+", cc ["+l.startCC+", "+l.endCC+"] duration:"+d);var u=n[o],h=this.fragCurrent;!h||this.state!==de&&this.state!==he||h.level!==r.level&&h.loader&&this.abortCurrentFrag();var f=0;if(l.live||(i=u.details)!=null&&i.live){var c;if(this.checkLiveUpdate(l),l.deltaUpdateFailed)return;f=this.alignPlaylists(l,u.details,(c=this.levelLastLoaded)==null?void 0:c.details)}if(u.details=l,this.levelLastLoaded=u,this.hls.trigger(E.LEVEL_UPDATED,{details:l,level:o}),this.state===Yt){if(this.waitForCdnTuneIn(l))return;this.state=it}this.startFragRequested?l.live&&this.synchronizeToLiveEdge(l):this.setStartPosition(l,f),this.tick()}else this.warn("Levels were reset while loading level "+o)},t._handleFragmentLoadProgress=function(e){var r,i=e.frag,n=e.part,o=e.payload,l=this.levels;if(l){var d=l[i.level],u=d.details;if(!u)return this.warn("Dropping fragment "+i.sn+" of level "+i.level+" after level details were reset"),void this.fragmentTracker.removeFragment(i);var h=d.videoCodec,f=u.PTSKnown||!u.live,c=(r=i.initSegment)==null?void 0:r.data,m=this._getAudioCodec(d),g=this.transmuxer=this.transmuxer||new Wn(this.hls,at,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),y=n?n.index:-1,v=y!==-1,p=new Ni(i.level,i.sn,i.stats.chunkCount,o.byteLength,y,v),S=this.initPTS[i.cc];g.push(o,c,m,h,i,n,u.totalduration,f,p,S)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},t.onAudioTrackSwitching=function(e,r){var i=this.altAudio;if(!r.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var n=this.fragCurrent;n&&(this.log("Switching to main audio track, cancel main fragment load"),n.abortRequests(),this.fragmentTracker.removeFragment(n)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var o=this.hls;i&&(o.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),o.trigger(E.AUDIO_TRACK_SWITCHED,r)}},t.onAudioTrackSwitched=function(e,r){var i=r.id,n=!!this.hls.audioTracks[i].url;if(n){var o=this.videoBuffer;o&&this.mediaBuffer!==o&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=o)}this.altAudio=n,this.tick()},t.onBufferCreated=function(e,r){var i,n,o=r.tracks,l=!1;for(var d in o){var u=o[d];if(u.id==="main"){if(n=d,i=u,d==="video"){var h=o[d];h&&(this.videoBuffer=h.buffer)}}else l=!0}l&&i?(this.log("Alternate track found, use "+n+".buffered to schedule main fragment loading"),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media},t.onFragBuffered=function(e,r){var i=r.frag,n=r.part;if(!i||i.type===at){if(this.fragContextChanged(i))return this.warn("Fragment "+i.sn+(n?" p: "+n.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===Pe&&(this.state=it));var o=n?n.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,n)}},t.onError=function(e,r){var i;if(r.fatal)this.state=fe;else switch(r.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(at,r);break;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==Yt||((i=r.context)==null?void 0:i.type)!==jt||(this.state=it);break;case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="main")return;if(r.details===D.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},t.checkBuffer=function(){var e=this.media,r=this.gapController;if(e&&r&&e.readyState){if(this.loadedmetadata||!ut.getBuffered(e).length){var i=this.state!==it?this.fragCurrent:null;r.poll(this.lastCurrentTime,i)}this.lastCurrentTime=e.currentTime}},t.onFragLoadEmergencyAborted=function(){this.state=it,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},t.onBufferFlushed=function(e,r){var i=r.type;if(i!==Tt||this.audioOnly&&!this.altAudio){var n=(i===bt?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(n,i,at),this.tick()}},t.onLevelsUpdated=function(e,r){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=r.levels},t.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},t.seekToStartPos=function(){var e=this.media;if(e){var r=e.currentTime,i=this.startPosition;if(i>=0&&r<i){if(e.seeking)return void this.log("could not seek to "+i+", already seeking at "+r);var n=ut.getBuffered(e),o=(n.length?n.start(0):0)-i;o>0&&(o<this.config.maxBufferHole||o<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+o+" to match buffer start"),i+=o,this.startPosition=i),this.log("seek to target start position "+i+" from current time "+r),e.currentTime=i}}},t._getAudioCodec=function(e){var r=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r=r.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),r},t._loadBitrateTestFrag=function(e,r){var i=this;e.bitrateTest=!0,this._doFragLoad(e,r).then(function(n){var o=i.hls;if(n&&!i.fragContextChanged(e)){r.fragmentError=0,i.state=it,i.startFragRequested=!1,i.bitrateTest=!1;var l=e.stats;l.parsing.start=l.parsing.end=l.buffering.start=l.buffering.end=self.performance.now(),o.trigger(E.FRAG_LOADED,n),e.bitrateTest=!1}})},t._handleTransmuxComplete=function(e){var r,i="main",n=this.hls,o=e.remuxResult,l=e.chunkMeta,d=this.getCurrentContext(l);if(d){var u=d.frag,h=d.part,f=d.level,c=o.video,m=o.text,g=o.id3,y=o.initSegment,v=f.details,p=this.altAudio?void 0:o.audio;if(this.fragContextChanged(u))this.fragmentTracker.removeFragment(u);else{if(this.state=Wt,y){if(y!=null&&y.tracks){var S=u.initSegment||u;this._bufferInitSegment(f,y.tracks,S,l),n.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:S,id:i,tracks:y.tracks})}var T=y.initPTS,R=y.timescale;N(T)&&(this.initPTS[u.cc]={baseTime:T,timescale:R},n.trigger(E.INIT_PTS_FOUND,{frag:u,id:i,initPTS:T,timescale:R}))}if(c&&v&&u.sn!=="initSegment"){var b=v.fragments[u.sn-1-v.startSN],L=u.sn===v.startSN,_=!b||u.cc>b.cc;if(o.independent!==!1){var x=c.startPTS,w=c.endPTS,k=c.startDTS,C=c.endDTS;if(h)h.elementaryStreams[c.type]={startPTS:x,endPTS:w,startDTS:k,endDTS:C};else if(c.firstKeyFrame&&c.independent&&l.id===1&&!_&&(this.couldBacktrack=!0),c.dropped&&c.independent){var I=this.getMainFwdBufferInfo(),P=(I?I.end:this.getLoadPosition())+this.config.maxBufferHole,O=c.firstKeyFramePTS?c.firstKeyFramePTS:x;if(!L&&P<O-this.config.maxBufferHole&&!_)return void this.backtrack(u);_&&(u.gap=!0),u.setElementaryStreamInfo(c.type,u.start,w,u.start,C,!0)}else L&&x>2&&(u.gap=!0);u.setElementaryStreamInfo(c.type,x,w,k,C),this.backtrackFragment&&(this.backtrackFragment=u),this.bufferFragmentData(c,u,h,l,L||_)}else{if(!L&&!_)return void this.backtrack(u);u.gap=!0}}if(p){var B=p.startPTS,F=p.endPTS,M=p.startDTS,H=p.endDTS;h&&(h.elementaryStreams[Tt]={startPTS:B,endPTS:F,startDTS:M,endDTS:H}),u.setElementaryStreamInfo(Tt,B,F,M,H),this.bufferFragmentData(p,u,h,l)}if(v&&g!=null&&(r=g.samples)!=null&&r.length){var G={id:i,frag:u,details:v,samples:g.samples};n.trigger(E.FRAG_PARSING_METADATA,G)}if(v&&m){var V={id:i,frag:u,details:v,samples:m.samples};n.trigger(E.FRAG_PARSING_USERDATA,V)}}}else this.resetWhenMissingContext(l)},t._bufferInitSegment=function(e,r,i,n){var o=this;if(this.state===Wt){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var l=r.audio,d=r.video,u=r.audiovideo;if(l){var h=e.audioCodec,f=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(h&&(h=h.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),l.metadata.channelCount!==1&&f.indexOf("firefox")===-1&&(h="mp4a.40.5")),h&&h.indexOf("mp4a.40.5")!==-1&&f.indexOf("android")!==-1&&l.container!=="audio/mpeg"&&(h="mp4a.40.2",this.log("Android: force audio codec to "+h)),e.audioCodec&&e.audioCodec!==h&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+h+'"'),l.levelCodec=h,l.id="main",this.log("Init audio buffer, container:"+l.container+", codecs[selected/level/parsed]=["+(h||"")+"/"+(e.audioCodec||"")+"/"+l.codec+"]")}d&&(d.levelCodec=e.videoCodec,d.id="main",this.log("Init video buffer, container:"+d.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+d.codec+"]")),u&&this.log("Init audiovideo buffer, container:"+u.container+", codecs[level/parsed]=["+e.codecs+"/"+u.codec+"]"),this.hls.trigger(E.BUFFER_CODECS,r),Object.keys(r).forEach(function(c){var m=r[c].initSegment;m!=null&&m.byteLength&&o.hls.trigger(E.BUFFER_APPENDING,{type:c,data:m,frag:i,part:null,chunkMeta:n,parent:i.type})}),this.tickImmediate()}},t.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,at)},t.backtrack=function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=it},t.checkFragmentChanged=function(){var e=this.media,r=null;if(e&&e.readyState>1&&e.seeking===!1){var i=e.currentTime;if(ut.isBuffered(e,i)?r=this.getAppendedFrag(i):ut.isBuffered(e,i+.1)&&(r=this.getAppendedFrag(i+.1)),r){this.backtrackFragment=null;var n=this.fragPlaying,o=r.level;n&&r.sn===n.sn&&n.level===o||(this.fragPlaying=r,this.hls.trigger(E.FRAG_CHANGED,{frag:r}),n&&n.level===o||this.hls.trigger(E.LEVEL_SWITCHED,{level:o}))}}},ct(a,[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function(){var e=this.media;if(e){var r=e.currentTime,i=this.currentFrag;if(i&&N(r)&&N(i.programDateTime)){var n=i.programDateTime+1e3*(r-i.start);return new Date(n)}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),a}(bn),la=function(){function s(t){t===void 0&&(t={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new Sr,this._autoLevelCapping=-1,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,this.triggeringException=void 0,Ir(t.debug||!1,"Hls instance");var e=this.config=function(k,C){if((C.liveSyncDurationCount||C.liveMaxLatencyDurationCount)&&(C.liveSyncDuration||C.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(C.liveMaxLatencyDurationCount!==void 0&&(C.liveSyncDurationCount===void 0||C.liveMaxLatencyDurationCount<=C.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(C.liveMaxLatencyDuration!==void 0&&(C.liveSyncDuration===void 0||C.liveMaxLatencyDuration<=C.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var I=lr(k),P=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(O){var B=(O==="level"?"playlist":O)+"LoadPolicy",F=C[B]===void 0,M=[];P.forEach(function(H){var G=O+"Loading"+H,V=C[G];if(V!==void 0&&F){M.push(G);var $=I[B].default;switch(C[B]={default:$},H){case"TimeOut":$.maxLoadTimeMs=V,$.maxTimeToFirstByteMs=V;break;case"MaxRetry":$.errorRetry.maxNumRetry=V,$.timeoutRetry.maxNumRetry=V;break;case"RetryDelay":$.errorRetry.retryDelayMs=V,$.timeoutRetry.retryDelayMs=V;break;case"MaxRetryTimeout":$.errorRetry.maxRetryDelayMs=V,$.timeoutRetry.maxRetryDelayMs=V}}}),M.length&&A.warn('hls.js config: "'+M.join('", "')+'" setting(s) are deprecated, use "'+B+'": '+JSON.stringify(C[B]))}),yt(yt({},I),C)}(s.DefaultConfig,t);this.userConfig=t,e.progressive&&vn(e);var r=e.abrController,i=e.bufferController,n=e.capLevelController,o=e.errorController,l=e.fpsController,d=new o(this),u=this.abrController=new r(this),h=this.bufferController=new i(this),f=this.capLevelController=new n(this),c=new l(this),m=new Ga(this),g=new ja(this),y=e.contentSteeringController,v=y?new y(this):null,p=this.levelController=new gn(this,v),S=new mn(this),T=new yn(this.config),R=this.streamController=new qn(this,S,T);f.setStreamController(R),c.setStreamController(R);var b=[m,p,R];v&&b.splice(1,0,v),this.networkControllers=b;var L=[u,h,f,c,g,S];this.audioTrackController=this.createController(e.audioTrackController,b);var _=e.audioStreamController;_&&b.push(new _(this,S,T)),this.subtitleTrackController=this.createController(e.subtitleTrackController,b);var x=e.subtitleStreamController;x&&b.push(new x(this,S,T)),this.createController(e.timelineController,L),T.emeController=this.emeController=this.createController(e.emeController,L),this.cmcdController=this.createController(e.cmcdController,L),this.latencyController=this.createController(Wa,L),this.coreComponents=L,b.push(d);var w=d.onErrorOut;typeof w=="function"&&this.on(E.ERROR,w,d)}s.isMSESupported=function(){return Hi()},s.isSupported=function(){return function(){if(!Hi())return!1;var t=Kt();return typeof t?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(e){return t.isTypeSupported(Xe(e,"video"))})||["mp4a.40.2","fLaC"].some(function(e){return t.isTypeSupported(Xe(e,"audio"))}))}()},s.getMediaSource=function(){return Kt()};var a=s.prototype;return a.createController=function(t,e){if(t){var r=new t(this);return e&&e.push(r),r}return null},a.on=function(t,e,r){r===void 0&&(r=this),this._emitter.on(t,e,r)},a.once=function(t,e,r){r===void 0&&(r=this),this._emitter.once(t,e,r)},a.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},a.off=function(t,e,r,i){r===void 0&&(r=this),this._emitter.off(t,e,r,i)},a.listeners=function(t){return this._emitter.listeners(t)},a.emit=function(t,e,r){return this._emitter.emit(t,e,r)},a.trigger=function(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(i){if(A.error("An internal error happened while handling event "+t+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=!0;var r=t===E.ERROR;this.trigger(E.ERROR,{type:W.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:r,event:t,error:i}),this.triggeringException=!1}}return!1},a.listenerCount=function(t){return this._emitter.listenerCount(t)},a.destroy=function(){A.log("destroy"),this.trigger(E.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(e){return e.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(e){return e.destroy()}),this.coreComponents.length=0;var t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null},a.attachMedia=function(t){A.log("attachMedia"),this._media=t,this.trigger(E.MEDIA_ATTACHING,{media:t})},a.detachMedia=function(){A.log("detachMedia"),this.trigger(E.MEDIA_DETACHING,void 0),this._media=null},a.loadSource=function(t){this.stopLoad();var e=this.media,r=this.url,i=this.url=Ge.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,A.log("loadSource:"+i),e&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(E.MANIFEST_LOADING,{url:t})},a.startLoad=function(t){t===void 0&&(t=-1),A.log("startLoad("+t+")"),this.started=!0,this.networkControllers.forEach(function(e){e.startLoad(t)})},a.stopLoad=function(){A.log("stopLoad"),this.started=!1,this.networkControllers.forEach(function(t){t.stopLoad()})},a.resumeBuffering=function(){this.started&&this.networkControllers.forEach(function(t){"fragmentLoader"in t&&t.startLoad(-1)})},a.pauseBuffering=function(){this.networkControllers.forEach(function(t){"fragmentLoader"in t&&t.stopLoad()})},a.swapAudioCodec=function(){A.log("swapAudioCodec"),this.streamController.swapAudioCodec()},a.recoverMediaError=function(){A.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},a.removeLevel=function(t){this.levelController.removeLevel(t)},a.setAudioOption=function(t){var e;return(e=this.audioTrackController)==null?void 0:e.setAudioOption(t)},a.setSubtitleOption=function(t){var e;return(e=this.subtitleTrackController)==null||e.setSubtitleOption(t),null},ct(s,[{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){A.log("set currentLevel:"+t),this.levelController.manualLevel=t,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){A.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){A.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){A.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){var t=this.levelController.startLevel;return t===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:t},set:function(t){A.log("set startLevel:"+t),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(A.log("set autoLevelCapping:"+t),this._autoLevelCapping=t,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN},set:function(t){this.abrController.resetEstimator(t)}},{key:"ttfbEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(t){(function(e){return er.indexOf(e)>-1})(t)&&this._maxHdcpLevel!==t&&(this._maxHdcpLevel=t,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,e=this.config.minAutoBitrate;if(!t)return 0;for(var r=t.length,i=0;i<r;i++)if(t[i].maxBitrate>=e)return i;return 0}},{key:"maxAutoLevel",get:function(){var t,e=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(t=r===-1&&e!=null&&e.length?e.length-1:r,i)for(var n=t;n--;){var o=e[n].attrs["HDCP-LEVEL"];if(o&&o<=i)return n}return t}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(t){this.abrController.nextAutoLevel=t}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"allAudioTracks",get:function(){var t=this.audioTrackController;return t?t.allAudioTracks:[]}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"allSubtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.5.8"}},{key:"Events",get:function(){return E}},{key:"ErrorTypes",get:function(){return W}},{key:"ErrorDetails",get:function(){return D}},{key:"DefaultConfig",get:function(){return s.defaultConfig?s.defaultConfig:xi},set:function(t){s.defaultConfig=t}}]),s}();return la.defaultConfig=void 0,la},Gt.exports=kr()})(!1)})(da);var $n=da.exports;const ha=Jn($n);export{ha as Hls,ha as default};
|
1
|
+
function Pt(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Ft={exports:{}};(function(a,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,h){if(h=h||{},l=l.trim(),d=d.trim(),!d){if(!h.alwaysNormalize)return l;var c=o.parseURL(l);if(!c)throw new Error("Error trying to parse base URL.");return c.path=o.normalizePath(c.path),o.buildURLFromParts(c)}var u=o.parseURL(d);if(!u)throw new Error("Error trying to parse relative URL.");if(u.scheme)return h.alwaysNormalize?(u.path=o.normalizePath(u.path),o.buildURLFromParts(u)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var m=s.exec(f.path);f.netLoc=m[1],f.path=m[2]}f.netLoc&&!f.path&&(f.path="/");var g={scheme:f.scheme,netLoc:u.netLoc,path:null,params:u.params,query:u.query,fragment:u.fragment};if(!u.netLoc&&(g.netLoc=f.netLoc,u.path[0]!=="/"))if(!u.path)g.path=f.path,u.params||(g.params=f.params,u.query||(g.query=f.query));else{var p=f.path,v=p.substring(0,p.lastIndexOf("/")+1)+u.path;g.path=o.normalizePath(v)}return g.path===null&&(g.path=h.alwaysNormalize?o.normalizePath(u.path):u.path),o.buildURLFromParts(g)},parseURL:function(l){var d=i.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(r,"");l.length!==(l=l.replace(n,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};a.exports=o})()})(Ft);var it=Ft.exports;function Ot(a,e){var t=Object.keys(a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(a);e&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(a,s).enumerable})),t.push.apply(t,i)}return t}function oe(a){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ot(Object(t),!0).forEach(function(i){ds(a,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(t)):Ot(Object(t)).forEach(function(i){Object.defineProperty(a,i,Object.getOwnPropertyDescriptor(t,i))})}return a}function os(a,e){if(typeof a!="object"||!a)return a;var t=a[Symbol.toPrimitive];if(t!==void 0){var i=t.call(a,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(a)}function ls(a){var e=os(a,"string");return typeof e=="symbol"?e:String(e)}function ds(a,e,t){return e=ls(e),e in a?Object.defineProperty(a,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):a[e]=t,a}function ae(){return ae=Object.assign?Object.assign.bind():function(a){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(a[i]=t[i])}return a},ae.apply(this,arguments)}const k=Number.isFinite||function(a){return typeof a=="number"&&isFinite(a)},hs=Number.isSafeInteger||function(a){return typeof a=="number"&&Math.abs(a)<=cs},cs=Number.MAX_SAFE_INTEGER||9007199254740991;let x=function(a){return a.MEDIA_ATTACHING="hlsMediaAttaching",a.MEDIA_ATTACHED="hlsMediaAttached",a.MEDIA_DETACHING="hlsMediaDetaching",a.MEDIA_DETACHED="hlsMediaDetached",a.BUFFER_RESET="hlsBufferReset",a.BUFFER_CODECS="hlsBufferCodecs",a.BUFFER_CREATED="hlsBufferCreated",a.BUFFER_APPENDING="hlsBufferAppending",a.BUFFER_APPENDED="hlsBufferAppended",a.BUFFER_EOS="hlsBufferEos",a.BUFFER_FLUSHING="hlsBufferFlushing",a.BUFFER_FLUSHED="hlsBufferFlushed",a.MANIFEST_LOADING="hlsManifestLoading",a.MANIFEST_LOADED="hlsManifestLoaded",a.MANIFEST_PARSED="hlsManifestParsed",a.LEVEL_SWITCHING="hlsLevelSwitching",a.LEVEL_SWITCHED="hlsLevelSwitched",a.LEVEL_LOADING="hlsLevelLoading",a.LEVEL_LOADED="hlsLevelLoaded",a.LEVEL_UPDATED="hlsLevelUpdated",a.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",a.LEVELS_UPDATED="hlsLevelsUpdated",a.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",a.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",a.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",a.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",a.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",a.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",a.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",a.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",a.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",a.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",a.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",a.CUES_PARSED="hlsCuesParsed",a.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",a.INIT_PTS_FOUND="hlsInitPtsFound",a.FRAG_LOADING="hlsFragLoading",a.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",a.FRAG_LOADED="hlsFragLoaded",a.FRAG_DECRYPTED="hlsFragDecrypted",a.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",a.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",a.FRAG_PARSING_METADATA="hlsFragParsingMetadata",a.FRAG_PARSED="hlsFragParsed",a.FRAG_BUFFERED="hlsFragBuffered",a.FRAG_CHANGED="hlsFragChanged",a.FPS_DROP="hlsFpsDrop",a.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",a.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",a.ERROR="hlsError",a.DESTROYING="hlsDestroying",a.KEY_LOADING="hlsKeyLoading",a.KEY_LOADED="hlsKeyLoaded",a.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",a.BACK_BUFFER_REACHED="hlsBackBufferReached",a.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",a}({}),K=function(a){return a.NETWORK_ERROR="networkError",a.MEDIA_ERROR="mediaError",a.KEY_SYSTEM_ERROR="keySystemError",a.MUX_ERROR="muxError",a.OTHER_ERROR="otherError",a}({}),R=function(a){return a.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",a.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",a.KEY_SYSTEM_NO_SESSION="keySystemNoSession",a.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",a.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",a.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",a.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",a.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",a.MANIFEST_LOAD_ERROR="manifestLoadError",a.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",a.MANIFEST_PARSING_ERROR="manifestParsingError",a.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",a.LEVEL_EMPTY_ERROR="levelEmptyError",a.LEVEL_LOAD_ERROR="levelLoadError",a.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",a.LEVEL_PARSING_ERROR="levelParsingError",a.LEVEL_SWITCH_ERROR="levelSwitchError",a.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",a.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",a.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",a.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",a.FRAG_LOAD_ERROR="fragLoadError",a.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",a.FRAG_DECRYPT_ERROR="fragDecryptError",a.FRAG_PARSING_ERROR="fragParsingError",a.FRAG_GAP="fragGap",a.REMUX_ALLOC_ERROR="remuxAllocError",a.KEY_LOAD_ERROR="keyLoadError",a.KEY_LOAD_TIMEOUT="keyLoadTimeOut",a.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",a.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",a.BUFFER_APPEND_ERROR="bufferAppendError",a.BUFFER_APPENDING_ERROR="bufferAppendingError",a.BUFFER_STALLED_ERROR="bufferStalledError",a.BUFFER_FULL_ERROR="bufferFullError",a.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",a.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",a.INTERNAL_EXCEPTION="internalException",a.INTERNAL_ABORTED="aborted",a.UNKNOWN="unknown",a}({});const Le=function(){},st={trace:Le,debug:Le,log:Le,warn:Le,info:Le,error:Le};let Pe=st;function us(a){const e=self.console[a];return e?e.bind(self.console,`[${a}] >`):Le}function fs(a,...e){e.forEach(function(t){Pe[t]=a[t]?a[t].bind(a):us(t)})}function ms(a,e){if(typeof console=="object"&&a===!0||typeof a=="object"){fs(a,"debug","log","info","warn","error");try{Pe.log(`Debug logs enabled for "${e}" in hls.js version 1.5.8`)}catch{Pe=st}}else Pe=st}const S=Pe,gs=/^(\d+)x(\d+)$/,kt=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Z{constructor(e){typeof e=="string"&&(e=Z.parseAttrList(e)),ae(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;const i=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)i[s]=parseInt(t.slice(s*2,s*2+2),16);return i}else return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){const t=gs.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const i={},s='"';for(kt.lastIndex=0;(t=kt.exec(e))!==null;){let r=t[2];r.indexOf(s)===0&&r.lastIndexOf(s)===r.length-1&&(r=r.slice(1,-1));const n=t[1].trim();i[n]=r}return i}}function ps(a){return a!=="ID"&&a!=="CLASS"&&a!=="START-DATE"&&a!=="DURATION"&&a!=="END-DATE"&&a!=="END-ON-NEXT"}function xs(a){return a==="SCTE35-OUT"||a==="SCTE35-IN"}class Mt{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const i=t.attr;for(const s in i)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==i[s]){S.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=ae(new Z({}),i,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const i=new Date(this.attr["END-DATE"]);k(i.getTime())&&(this._endDate=i)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(k(e))return e}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&&k(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class ke{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 Q={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Nt{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Q.AUDIO]:null,[Q.VIDEO]:null,[Q.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){const i=e.split("@",2);let s;i.length===1?s=t?.byteRangeEndOffset||0:s=parseInt(i[1]),this._byteRange=[s,parseInt(i[0])+s]}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=it.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class rt extends Nt{constructor(e,t){super(t),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 ke,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!k(this.programDateTime))return null;const e=k(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){const t=Object.keys(this.levelkeys),i=t.length;if(i>1||i===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,i,s,r,n=!1){const{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:i,startDTS:s,endDTS:r,partial:n};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,i),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,r)}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[Q.AUDIO]=null,e[Q.VIDEO]=null,e[Q.AUDIOVIDEO]=null}}class vs extends Nt{constructor(e,t,i,s,r){super(i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new ke,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;const n=e.enumeratedString("BYTERANGE");n&&this.setByteRange(n,r),r&&(this.fragOffset=r.fragOffset+r.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}const ys=10;class Es{constructor(e){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=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?k(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||ys}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.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 e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}var Fe=void 0,Ts=Pt(Fe);function Ae(a,e,t){return Uint8Array.prototype.slice?a.slice(e,t):new Uint8Array(Array.prototype.slice.call(a,e,t))}const nt=(a,e)=>e+10<=a.length&&a[e]===73&&a[e+1]===68&&a[e+2]===51&&a[e+3]<255&&a[e+4]<255&&a[e+6]<128&&a[e+7]<128&&a[e+8]<128&&a[e+9]<128,Bt=(a,e)=>e+10<=a.length&&a[e]===51&&a[e+1]===68&&a[e+2]===73&&a[e+3]<255&&a[e+4]<255&&a[e+6]<128&&a[e+7]<128&&a[e+8]<128&&a[e+9]<128,Me=(a,e)=>{const t=e;let i=0;for(;nt(a,e);){i+=10;const s=Ne(a,e+6);i+=s,Bt(a,e+10)&&(i+=10),e+=i}if(i>0)return a.subarray(t,t+i)},Ne=(a,e)=>{let t=0;return t=(a[e]&127)<<21,t|=(a[e+1]&127)<<14,t|=(a[e+2]&127)<<7,t|=a[e+3]&127,t},Ss=(a,e)=>nt(a,e)&&Ne(a,e+6)+10<=a.length-e,Ut=a=>{const e=Gt(a);for(let t=0;t<e.length;t++){const i=e[t];if($t(i))return Ds(i)}},$t=a=>a&&a.key==="PRIV"&&a.info==="com.apple.streaming.transportStreamTimestamp",Ls=a=>{const e=String.fromCharCode(a[0],a[1],a[2],a[3]),t=Ne(a,4),i=10;return{type:e,size:t,data:a.subarray(i,i+t)}},Gt=a=>{let e=0;const t=[];for(;nt(a,e);){const i=Ne(a,e+6);e+=10;const s=e+i;for(;e+8<s;){const r=Ls(a.subarray(e)),n=As(r);n&&t.push(n),e+=r.size+10}Bt(a,e)&&(e+=10)}return t},As=a=>a.type==="PRIV"?Rs(a):a.type[0]==="W"?Is(a):bs(a),Rs=a=>{if(a.size<2)return;const e=ye(a.data,!0),t=new Uint8Array(a.data.subarray(e.length+1));return{key:a.type,info:e,data:t.buffer}},bs=a=>{if(a.size<2)return;if(a.type==="TXXX"){let t=1;const i=ye(a.data.subarray(t),!0);t+=i.length+1;const s=ye(a.data.subarray(t));return{key:a.type,info:i,data:s}}const e=ye(a.data.subarray(1));return{key:a.type,data:e}},Is=a=>{if(a.type==="WXXX"){if(a.size<2)return;let t=1;const i=ye(a.data.subarray(t),!0);t+=i.length+1;const s=ye(a.data.subarray(t));return{key:a.type,info:i,data:s}}const e=ye(a.data);return{key:a.type,data:e}},Ds=a=>{if(a.data.byteLength===8){const e=new Uint8Array(a.data),t=e[3]&1;let i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}},ye=(a,e=!1)=>{const t=Cs();if(t){const d=t.decode(a);if(e){const h=d.indexOf("\0");return h!==-1?d.substring(0,h):d}return d.replace(/\0/g,"")}const i=a.length;let s,r,n,o="",l=0;for(;l<i;){if(s=a[l++],s===0&&e)return o;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:r=a[l++],o+=String.fromCharCode((s&31)<<6|r&63);break;case 14:r=a[l++],n=a[l++],o+=String.fromCharCode((s&15)<<12|(r&63)<<6|(n&63)<<0);break}}return o};let at;function Cs(){if(!navigator.userAgent.includes("PlayStation 4"))return!at&&typeof self.TextDecoder<"u"&&(at=new self.TextDecoder("utf-8")),at}const Vt={hexDump:function(a){let e="";for(let t=0;t<a.length;t++){let i=a[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}},Be=Math.pow(2,32)-1,_s=[].push,Ht={video:1,audio:2,id3:3,text:4};function ee(a){return String.fromCharCode.apply(null,a)}function Kt(a,e){const t=a[e]<<8|a[e+1];return t<0?65536+t:t}function N(a,e){const t=Yt(a,e);return t<0?4294967296+t:t}function Wt(a,e){let t=N(a,e);return t*=Math.pow(2,32),t+=N(a,e+4),t}function Yt(a,e){return a[e]<<24|a[e+1]<<16|a[e+2]<<8|a[e+3]}function ot(a,e,t){a[e]=t>>24,a[e+1]=t>>16&255,a[e+2]=t>>8&255,a[e+3]=t&255}function ws(a){const e=a.byteLength;for(let t=0;t<e;){const i=N(a,t);if(i>8&&a[t+4]===109&&a[t+5]===111&&a[t+6]===111&&a[t+7]===102)return!0;t=i>1?t+i:e}return!1}function G(a,e){const t=[];if(!e.length)return t;const i=a.byteLength;for(let s=0;s<i;){const r=N(a,s),n=ee(a.subarray(s+4,s+8)),o=r>1?s+r:i;if(n===e[0])if(e.length===1)t.push(a.subarray(s+8,o));else{const l=G(a.subarray(s+8,o),e.slice(1));l.length&&_s.apply(t,l)}s=o}return t}function Ps(a){const e=[],t=a[0];let i=8;const s=N(a,i);i+=4;let r=0,n=0;t===0?(r=N(a,i),n=N(a,i+4),i+=8):(r=Wt(a,i),n=Wt(a,i+8),i+=16),i+=2;let o=a.length+n;const l=Kt(a,i);i+=2;for(let d=0;d<l;d++){let h=i;const c=N(a,h);h+=4;const u=c&2147483647;if((c&2147483648)>>>31===1)return S.warn("SIDX has hierarchical references (not supported)"),null;const m=N(a,h);h+=4,e.push({referenceSize:u,subsegmentDuration:m,info:{duration:m/s,start:o,end:o+u-1}}),o+=u,h+=4,i=h}return{earliestPresentationTime:r,timescale:s,version:t,referencesCount:l,references:e}}function jt(a){const e=[],t=G(a,["moov","trak"]);for(let s=0;s<t.length;s++){const r=t[s],n=G(r,["tkhd"])[0];if(n){let o=n[0];const l=N(n,o===0?12:20),d=G(r,["mdia","mdhd"])[0];if(d){o=d[0];const h=N(d,o===0?12:20),c=G(r,["mdia","hdlr"])[0];if(c){const u=ee(c.subarray(8,12)),f={soun:Q.AUDIO,vide:Q.VIDEO}[u];if(f){const m=G(r,["mdia","minf","stbl","stsd"])[0],g=Fs(m);e[l]={timescale:h,type:f},e[f]=oe({timescale:h,id:l},g)}}}}}return G(a,["moov","mvex","trex"]).forEach(s=>{const r=N(s,4),n=e[r];n&&(n.default={duration:N(s,12),flags:N(s,20)})}),e}function Fs(a){const e=a.subarray(8),t=e.subarray(86),i=ee(e.subarray(4,8));let s=i;const r=i==="enca"||i==="encv";if(r){const o=G(e,[i])[0].subarray(i==="enca"?28:78);G(o,["sinf"]).forEach(d=>{const h=G(d,["schm"])[0];if(h){const c=ee(h.subarray(4,8));if(c==="cbcs"||c==="cenc"){const u=G(d,["frma"])[0];u&&(s=ee(u))}}})}switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const n=G(t,["avcC"])[0];s+="."+Ue(n[1])+Ue(n[2])+Ue(n[3]);break}case"mp4a":{const n=G(e,[i])[0],o=G(n.subarray(28),["esds"])[0];if(o&&o.length>12){let l=4;if(o[l++]!==3)break;l=lt(o,l),l+=2;const d=o[l++];if(d&128&&(l+=2),d&64&&(l+=o[l++]),o[l++]!==4)break;l=lt(o,l);const h=o[l++];if(h===64)s+="."+Ue(h);else break;if(l+=12,o[l++]!==5)break;l=lt(o,l);const c=o[l++];let u=(c&248)>>3;u===31&&(u+=1+((c&7)<<3)+((o[l]&224)>>5)),s+="."+u}break}case"hvc1":case"hev1":{const n=G(t,["hvcC"])[0],o=n[1],l=["","A","B","C"][o>>6],d=o&31,h=N(n,2),c=(o&32)>>5?"H":"L",u=n[12],f=n.subarray(6,12);s+="."+l+d,s+="."+h.toString(16).toUpperCase(),s+="."+c+u;let m="";for(let g=f.length;g--;){const p=f[g];(p||m)&&(m="."+p.toString(16).toUpperCase()+m)}s+=m;break}case"dvh1":case"dvhe":{const n=G(t,["dvcC"])[0],o=n[2]>>1&127,l=n[2]<<5&32|n[3]>>3&31;s+="."+fe(o)+"."+fe(l);break}case"vp09":{const n=G(t,["vpcC"])[0],o=n[4],l=n[5],d=n[6]>>4&15;s+="."+fe(o)+"."+fe(l)+"."+fe(d);break}case"av01":{const n=G(t,["av1C"])[0],o=n[1]>>>5,l=n[1]&31,d=n[2]>>>7?"H":"M",h=(n[2]&64)>>6,c=(n[2]&32)>>5,u=o===2&&h?c?12:10:h?10:8,f=(n[2]&16)>>4,m=(n[2]&8)>>3,g=(n[2]&4)>>2,p=n[2]&3;s+="."+o+"."+fe(l)+d+"."+fe(u)+"."+f+"."+m+g+p+"."+fe(1)+"."+fe(1)+"."+fe(1)+"."+0;break}}return{codec:s,encrypted:r}}function lt(a,e){const t=e+5;for(;a[e++]&128&&e<t;);return e}function Ue(a){return("0"+a.toString(16).toUpperCase()).slice(-2)}function fe(a){return(a<10?"0":"")+a}function Os(a,e){if(!a||!e)return a;const t=e.keyId;return t&&e.isCommonEncryption&&G(a,["moov","trak"]).forEach(s=>{const n=G(s,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=G(n,["enca"]);const l=o.length>0;l||(o=G(n,["encv"])),o.forEach(d=>{const h=l?d.subarray(28):d.subarray(78);G(h,["sinf"]).forEach(u=>{const f=ks(u);if(f){const m=f.subarray(8,24);m.some(g=>g!==0)||(S.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Vt.hexDump(m)} -> ${Vt.hexDump(t)}`),f.set(t,8))}})})}),a}function ks(a){const e=G(a,["schm"])[0];if(e){const t=ee(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return G(a,["schi","tenc"])[0]}return S.error("[eme] missing 'schm' box"),null}function Ms(a,e){return G(e,["moof","traf"]).reduce((t,i)=>{const s=G(i,["tfdt"])[0],r=s[0],n=G(i,["tfhd"]).reduce((o,l)=>{const d=N(l,4),h=a[d];if(h){let c=N(s,4);if(r===1){if(c===Be)return S.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;c*=Be+1,c+=N(s,8)}const u=h.timescale||9e4,f=c/u;if(k(f)&&(o===null||f<o))return f}return o},null);return n!==null&&k(n)&&(t===null||n<t)?n:t},null)}function Ns(a,e){let t=0,i=0,s=0;const r=G(a,["moof","traf"]);for(let n=0;n<r.length;n++){const o=r[n],l=G(o,["tfhd"])[0],d=N(l,4),h=e[d];if(!h)continue;const c=h.default,u=N(l,0)|c?.flags;let f=c?.duration;u&8&&(u&2?f=N(l,12):f=N(l,8));const m=h.timescale||9e4,g=G(o,["trun"]);for(let p=0;p<g.length;p++){if(t=Bs(g[p]),!t&&f){const v=N(g[p],4);t=f*v}h.type===Q.VIDEO?i+=t/m:h.type===Q.AUDIO&&(s+=t/m)}}if(i===0&&s===0){let n=1/0,o=0,l=0;const d=G(a,["sidx"]);for(let h=0;h<d.length;h++){const c=Ps(d[h]);if(c!=null&&c.references){n=Math.min(n,c.earliestPresentationTime/c.timescale);const u=c.references.reduce((f,m)=>f+m.info.duration||0,0);o=Math.max(o,u+c.earliestPresentationTime/c.timescale),l=o-n}}if(l&&k(l))return l}return i||s}function Bs(a){const e=N(a,0);let t=8;e&1&&(t+=4),e&4&&(t+=4);let i=0;const s=N(a,4);for(let r=0;r<s;r++){if(e&256){const n=N(a,t);i+=n,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return i}function Us(a,e,t){G(e,["moof","traf"]).forEach(i=>{G(i,["tfhd"]).forEach(s=>{const r=N(s,4),n=a[r];if(!n)return;const o=n.timescale||9e4;G(i,["tfdt"]).forEach(l=>{const d=l[0],h=t*o;if(h){let c=N(l,4);if(d===0)c-=h,c=Math.max(c,0),ot(l,4,c);else{c*=Math.pow(2,32),c+=N(l,8),c-=h,c=Math.max(c,0);const u=Math.floor(c/(Be+1)),f=Math.floor(c%(Be+1));ot(l,4,u),ot(l,8,f)}}})})})}function $s(a){const e={valid:null,remainder:null},t=G(a,["moof"]);if(t.length<2)return e.remainder=a,e;const i=t[t.length-1];return e.valid=Ae(a,0,i.byteOffset-8),e.remainder=Ae(a,i.byteOffset-8),e}function de(a,e){const t=new Uint8Array(a.length+e.length);return t.set(a),t.set(e,a.length),t}function zt(a,e){const t=[],i=e.samples,s=e.timescale,r=e.id;let n=!1;return G(i,["moof"]).map(l=>{const d=l.byteOffset-8;G(l,["traf"]).map(c=>{const u=G(c,["tfdt"]).map(f=>{const m=f[0];let g=N(f,4);return m===1&&(g*=Math.pow(2,32),g+=N(f,8)),g/s})[0];return u!==void 0&&(a=u),G(c,["tfhd"]).map(f=>{const m=N(f,4),g=N(f,0)&16777215,p=(g&1)!==0,v=(g&2)!==0,L=(g&8)!==0;let y=0;const b=(g&16)!==0;let T=0;const I=(g&32)!==0;let A=8;m===r&&(p&&(A+=8),v&&(A+=4),L&&(y=N(f,A),A+=4),b&&(T=N(f,A),A+=4),I&&(A+=4),e.type==="video"&&(n=Gs(e.codec)),G(c,["trun"]).map(D=>{const P=D[0],_=N(D,0)&16777215,C=(_&1)!==0;let $=0;const M=(_&4)!==0,U=(_&256)!==0;let B=0;const V=(_&512)!==0;let W=0;const X=(_&1024)!==0,O=(_&2048)!==0;let F=0;const Y=N(D,4);let H=8;C&&($=N(D,H),H+=4),M&&(H+=4);let q=$+d;for(let se=0;se<Y;se++){if(U?(B=N(D,H),H+=4):B=y,V?(W=N(D,H),H+=4):W=T,X&&(H+=4),O&&(P===0?F=N(D,H):F=Yt(D,H),H+=4),e.type===Q.VIDEO){let le=0;for(;le<W;){const re=N(i,q);if(q+=4,Vs(n,i[q])){const be=i.subarray(q,q+re);qt(be,n?2:1,a+F/s,t)}q+=re,le+=re+4}}a+=B/s}}))})})}),t}function Gs(a){if(!a)return!1;const e=a.indexOf("."),t=e<0?a:a.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function Vs(a,e){if(a){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function qt(a,e,t,i){const s=Xt(a);let r=0;r+=e;let n=0,o=0,l=0;for(;r<s.length;){n=0;do{if(r>=s.length)break;l=s[r++],n+=l}while(l===255);o=0;do{if(r>=s.length)break;l=s[r++],o+=l}while(l===255);const d=s.length-r;let h=r;if(o<d)r+=o;else if(o>d){S.error(`Malformed SEI payload. ${o} is too small, only ${d} bytes left to parse.`);break}if(n===4){if(s[h++]===181){const u=Kt(s,h);if(h+=2,u===49){const f=N(s,h);if(h+=4,f===1195456820){const m=s[h++];if(m===3){const g=s[h++],p=31&g,v=64&g,L=v?2+p*3:0,y=new Uint8Array(L);if(v){y[0]=g;for(let b=1;b<L;b++)y[b]=s[h++]}i.push({type:m,payloadType:n,pts:t,bytes:y})}}}}}else if(n===5&&o>16){const c=[];for(let m=0;m<16;m++){const g=s[h++].toString(16);c.push(g.length==1?"0"+g:g),(m===3||m===5||m===7||m===9)&&c.push("-")}const u=o-16,f=new Uint8Array(u);for(let m=0;m<u;m++)f[m]=s[h++];i.push({payloadType:n,pts:t,uuid:c.join(""),userData:ye(f),userDataBytes:f})}}}function Xt(a){const e=a.byteLength,t=[];let i=1;for(;i<e-2;)a[i]===0&&a[i+1]===0&&a[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return a;const s=e-t.length,r=new Uint8Array(s);let n=0;for(i=0;i<s;n++,i++)n===t[0]&&(n++,t.shift()),r[i]=a[n];return r}function Hs(a){const e=a[0];let t="",i="",s=0,r=0,n=0,o=0,l=0,d=0;if(e===0){for(;ee(a.subarray(d,d+1))!=="\0";)t+=ee(a.subarray(d,d+1)),d+=1;for(t+=ee(a.subarray(d,d+1)),d+=1;ee(a.subarray(d,d+1))!=="\0";)i+=ee(a.subarray(d,d+1)),d+=1;i+=ee(a.subarray(d,d+1)),d+=1,s=N(a,12),r=N(a,16),o=N(a,20),l=N(a,24),d=28}else if(e===1){d+=4,s=N(a,d),d+=4;const c=N(a,d);d+=4;const u=N(a,d);for(d+=4,n=2**32*c+u,hs(n)||(n=Number.MAX_SAFE_INTEGER,S.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=N(a,d),d+=4,l=N(a,d),d+=4;ee(a.subarray(d,d+1))!=="\0";)t+=ee(a.subarray(d,d+1)),d+=1;for(t+=ee(a.subarray(d,d+1)),d+=1;ee(a.subarray(d,d+1))!=="\0";)i+=ee(a.subarray(d,d+1)),d+=1;i+=ee(a.subarray(d,d+1)),d+=1}const h=a.subarray(d,a.byteLength);return{schemeIdUri:t,value:i,timeScale:s,presentationTime:n,presentationTimeDelta:r,eventDuration:o,id:l,payload:h}}class _t{static clearKeyUriToKeyIdMap(){}constructor(e,t,i,s=[1],r=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=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=s,this.iv=r,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES"}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&S.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const t=Ks(e);return new _t(this.method,this.uri,"identity",this.keyFormatVersions,t)}return this}}function Ks(a){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=a>>8*(15-t)&255;return e}function Re(a=!0){return typeof self>"u"?void 0:(a||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function Ws(a){return typeof self<"u"&&a===self.ManagedMediaSource}const $e={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Ys(a,e){const t=$e[e];return!!t&&!!t[a.slice(0,4)]}function dt(a,e,t=!0){return!a.split(",").some(i=>!Qt(i,e,t))}function Qt(a,e,t=!0){var i;const s=Re(t);return(i=s?.isTypeSupported(ht(a,e)))!=null?i:!1}function ht(a,e){return`${e}/mp4;codecs="${a}"`}function Jt(a){if(a){const e=a.substring(0,4);return $e.video[e]}return 2}function Ge(a){return a.split(",").reduce((e,t)=>{const i=$e.video[t];return i?(i*2+e)/(e?3:2):($e.audio[t]+e)/(e?2:1)},0)}const ct={};function js(a,e=!0){if(ct[a])return ct[a];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[a];for(let i=0;i<t.length;i++)if(Qt(t[i],"audio",e))return ct[a]=t[i],t[i];return a}const zs=/flac|opus/i;function Ve(a,e=!0){return a.replace(zs,t=>js(t.toLowerCase(),e))}function Zt(a,e){return a&&a!=="mp4a"?a:e&&e.split(",")[0]}function qs(a){const e=a.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 a}const ei=/#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,ti=/#EXT-X-MEDIA:(.*)/g,Xs=/^#EXT(?:INF|-X-TARGETDURATION):/m,ii=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Qs=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|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class ge{static findGroup(e,t){for(let i=0;i<e.length;i++){const s=e[i];if(s.id===t)return s}}static resolve(e,t){return it.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Xs.test(e)}static parseMasterPlaylist(e,t){const s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:!1},r=[];ei.lastIndex=0;let n;for(;(n=ei.exec(e))!=null;)if(n[1]){var o;const d=new Z(n[1]),h=n[2],c={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:ge.resolve(h,t)},u=d.decimalResolution("RESOLUTION");u&&(c.width=u.width,c.height=u.height),Js(d.CODECS,c),(o=c.unknownCodecs)!=null&&o.length||r.push(c),s.levels.push(c)}else if(n[3]){const d=n[3],h=n[4];switch(d){case"SESSION-DATA":{const c=new Z(h),u=c["DATA-ID"];u&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[u]=c);break}case"SESSION-KEY":{const c=si(h,t);c.encrypted&&c.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(c)):S.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${h}"`);break}case"DEFINE":break;case"CONTENT-STEERING":{const c=new Z(h);s.contentSteering={uri:ge.resolve(c["SERVER-URI"],t),pathwayId:c["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=ri(h);break}}}const l=r.length>0&&r.length<s.levels.length;return s.levels=l?r:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,i){let s;const r={},n=i.levels,o={AUDIO:n.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:n.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]};let l=0;for(ti.lastIndex=0;(s=ti.exec(e))!==null;){const d=new Z(s[1]),h=d.TYPE;if(h){const c=o[h],u=r[h]||[];r[h]=u;const f=d.LANGUAGE,m=d["ASSOC-LANGUAGE"],g=d.CHANNELS,p=d.CHARACTERISTICS,v=d["INSTREAM-ID"],L={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",name:d.NAME||f||"",type:h,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:f,url:d.URI?ge.resolve(d.URI,t):""};if(m&&(L.assocLang=m),g&&(L.channels=g),p&&(L.characteristics=p),v&&(L.instreamId=v),c!=null&&c.length){const y=ge.findGroup(c,L.groupId)||c[0];ni(L,y,"audioCodec"),ni(L,y,"textCodec")}u.push(L)}}return r}static parseLevelPlaylist(e,t,i,s,r,n){const o=new Es(t),l=o.fragments;let d=null,h=0,c=0,u=0,f=0,m=null,g=new rt(s,t),p,v,L,y=-1,b=!1,T=null;for(ii.lastIndex=0,o.m3u8=e,o.hasVariableRefs=!1;(p=ii.exec(e))!==null;){b&&(b=!1,g=new rt(s,t),g.start=u,g.sn=h,g.cc=f,g.level=i,d&&(g.initSegment=d,g.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null,T&&(g.setByteRange(T),T=null)));const P=p[1];if(P){g.duration=parseFloat(P);const _=(" "+p[2]).slice(1);g.title=_||null,g.tagList.push(_?["INF",P,_]:["INF",P])}else if(p[3]){if(k(g.duration)){g.start=u,L&&li(g,L,o),g.sn=h,g.level=i,g.cc=f,l.push(g);const _=(" "+p[3]).slice(1);g.relurl=_,ai(g,m),m=g,u+=g.duration,h++,c=0,b=!0}}else if(p[4]){const _=(" "+p[4]).slice(1);m?g.setByteRange(_,m):g.setByteRange(_)}else if(p[5])g.rawProgramDateTime=(" "+p[5]).slice(1),g.tagList.push(["PROGRAM-DATE-TIME",g.rawProgramDateTime]),y===-1&&(y=l.length);else{if(p=p[0].match(Qs),!p){S.warn("No matches on slow regex match for level playlist!");continue}for(v=1;v<p.length&&!(typeof p[v]<"u");v++);const _=(" "+p[v]).slice(1),C=(" "+p[v+1]).slice(1),$=p[v+2]?(" "+p[v+2]).slice(1):"";switch(_){case"PLAYLIST-TYPE":o.type=C.toUpperCase();break;case"MEDIA-SEQUENCE":h=o.startSN=parseInt(C);break;case"SKIP":{const M=new Z(C),U=M.decimalInteger("SKIPPED-SEGMENTS");if(k(U)){o.skippedSegments=U;for(let V=U;V--;)l.unshift(null);h+=U}const B=M.enumeratedString("RECENTLY-REMOVED-DATERANGES");B&&(o.recentlyRemovedDateranges=B.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(C),1);break;case"VERSION":o.version=parseInt(C);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(C||$)&&g.tagList.push($?[C,$]:[C]);break;case"DISCONTINUITY":f++,g.tagList.push(["DIS"]);break;case"GAP":g.gap=!0,g.tagList.push([_]);break;case"BITRATE":g.tagList.push([_,C]);break;case"DATERANGE":{const M=new Z(C),U=new Mt(M,o.dateRanges[M.ID]);U.isValid||o.skippedSegments?o.dateRanges[U.id]=U:S.warn(`Ignoring invalid DATERANGE tag: "${C}"`),g.tagList.push(["EXT-X-DATERANGE",C]);break}case"DEFINE":break;case"DISCONTINUITY-SEQUENCE":f=parseInt(C);break;case"KEY":{const M=si(C,t);if(M.isSupported()){if(M.method==="NONE"){L=void 0;break}L||(L={}),L[M.keyFormat]&&(L=ae({},L)),L[M.keyFormat]=M}else S.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${C}"`);break}case"START":o.startTimeOffset=ri(C);break;case"MAP":{const M=new Z(C);if(g.duration){const U=new rt(s,t);oi(U,M,i,L),d=U,g.initSegment=d,d.rawProgramDateTime&&!g.rawProgramDateTime&&(g.rawProgramDateTime=d.rawProgramDateTime)}else{const U=g.byteRangeEndOffset;if(U){const B=g.byteRangeStartOffset;T=`${U-B}@${B}`}else T=null;oi(g,M,i,L),d=g,b=!0}break}case"SERVER-CONTROL":{const M=new Z(C);o.canBlockReload=M.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=M.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&M.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=M.optionalFloat("PART-HOLD-BACK",0),o.holdBack=M.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const M=new Z(C);o.partTarget=M.decimalFloatingPoint("PART-TARGET");break}case"PART":{let M=o.partList;M||(M=o.partList=[]);const U=c>0?M[M.length-1]:void 0,B=c++,V=new Z(C),W=new vs(V,g,t,B,U);M.push(W),g.duration+=W.duration;break}case"PRELOAD-HINT":{const M=new Z(C);o.preloadHint=M;break}case"RENDITION-REPORT":{const M=new Z(C);o.renditionReports=o.renditionReports||[],o.renditionReports.push(M);break}default:S.warn(`line parsed but not handled: ${p}`);break}}}m&&!m.relurl?(l.pop(),u-=m.duration,o.partList&&(o.fragmentHint=m)):o.partList&&(ai(g,m),g.cc=f,o.fragmentHint=g,L&&li(g,L,o));const I=l.length,A=l[0],D=l[I-1];if(u+=o.skippedSegments*o.targetduration,u>0&&I&&D){o.averagetargetduration=u/I;const P=D.sn;o.endSN=P!=="initSegment"?P:0,o.live||(D.endList=!0),A&&(o.startCC=A.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(u+=o.fragmentHint.duration),o.totalduration=u,o.endCC=f,y>0&&Zs(l,y),o}}function si(a,e,t){var i,s;const r=new Z(a),n=(i=r.METHOD)!=null?i:"",o=r.URI,l=r.hexadecimalInteger("IV"),d=r.KEYFORMATVERSIONS,h=(s=r.KEYFORMAT)!=null?s:"identity";o&&r.IV&&!l&&S.error(`Invalid IV: ${r.IV}`);const c=o?ge.resolve(o,e):"",u=(d||"1").split("/").map(Number).filter(Number.isFinite);return new _t(n,c,h,u,l)}function ri(a){const t=new Z(a).decimalFloatingPoint("TIME-OFFSET");return k(t)?t:null}function Js(a,e){let t=(a||"").split(/[ ,]+/).filter(i=>i);["video","audio","text"].forEach(i=>{const s=t.filter(r=>Ys(r,i));s.length&&(e[`${i}Codec`]=s.join(","),t=t.filter(r=>s.indexOf(r)===-1))}),e.unknownCodecs=t}function ni(a,e,t){const i=e[t];i&&(a[t]=i)}function Zs(a,e){let t=a[e];for(let i=e;i--;){const s=a[i];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function ai(a,e){a.rawProgramDateTime?a.programDateTime=Date.parse(a.rawProgramDateTime):e!=null&&e.programDateTime&&(a.programDateTime=e.endProgramDateTime),k(a.programDateTime)||(a.programDateTime=null,a.rawProgramDateTime=null)}function oi(a,e,t,i){a.relurl=e.URI,e.BYTERANGE&&a.setByteRange(e.BYTERANGE),a.level=t,a.sn="initSegment",i&&(a.levelkeys=i),a.initSegment=null}function li(a,e,t){a.levelkeys=e;const{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&i.push(a)}var j={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},z={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function di(a){const{type:e}=a;switch(e){case j.AUDIO_TRACK:return z.AUDIO;case j.SUBTITLE_TRACK:return z.SUBTITLE;default:return z.MAIN}}function ut(a,e){let t=a.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class er{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.LEVEL_LOADING,this.onLevelLoading,this),e.on(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.LEVEL_LOADING,this.onLevelLoading,this),e.off(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,i=t.pLoader,s=t.loader,r=i||s,n=new r(t);return this.loaders[e.type]=n,n}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:j.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(e,t){const{id:i,level:s,pathwayId:r,url:n,deliveryDirectives:o}=t;this.load({id:i,level:s,pathwayId:r,responseType:"text",type:j.LEVEL,url:n,deliveryDirectives:o})}onAudioTrackLoading(e,t){const{id:i,groupId:s,url:r,deliveryDirectives:n}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:j.AUDIO_TRACK,url:r,deliveryDirectives:n})}onSubtitleTrackLoading(e,t){const{id:i,groupId:s,url:r,deliveryDirectives:n}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:j.SUBTITLE_TRACK,url:r,deliveryDirectives:n})}load(e){var t;const i=this.hls.config;let s=this.getInternalLoader(e);if(s){const d=s.context;if(d&&d.url===e.url&&d.level===e.level){S.trace("[playlist-loader]: playlist request ongoing");return}S.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let r;if(e.type===j.MANIFEST?r=i.manifestLoadPolicy.default:r=ae({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),k((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===j.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===j.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===j.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){const h=d.partTarget,c=d.targetduration;if(h&&c){const u=Math.max(h*3,c*.8)*1e3;r=ae({},r,{maxTimeToFirstByteMs:Math.min(u,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(u,r.maxTimeToFirstByteMs)})}}}const n=r.errorRetry||r.timeoutRetry||{},o={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0},l={onSuccess:(d,h,c,u)=>{const f=this.getInternalLoader(c);this.resetInternalLoader(c.type);const m=d.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,c,new Error("no EXTM3U delimiter"),u||null,h);return}h.parsing.start=performance.now(),ge.isMediaPlaylist(m)?this.handleTrackOrLevelPlaylist(d,h,c,u||null,f):this.handleMasterPlaylist(d,h,c,u)},onError:(d,h,c,u)=>{this.handleNetworkError(h,c,!1,d,u)},onTimeout:(d,h,c)=>{this.handleNetworkError(h,c,!0,void 0,d)}};s.load(e,o,l)}handleMasterPlaylist(e,t,i,s){const r=this.hls,n=e.data,o=ut(e,i),l=ge.parseMasterPlaylist(n,o);if(l.playlistParsingError){this.handleManifestParsingError(e,i,l.playlistParsingError,s,t);return}const{contentSteering:d,levels:h,sessionData:c,sessionKeys:u,startTimeOffset:f,variableList:m}=l;this.variableList=m;const{AUDIO:g=[],SUBTITLES:p,"CLOSED-CAPTIONS":v}=ge.parseMasterPlaylistMedia(n,o,l);g.length&&!g.some(y=>!y.url)&&h[0].audioCodec&&!h[0].attrs.AUDIO&&(S.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Z({}),bitrate:0,url:""})),r.trigger(x.MANIFEST_LOADED,{levels:h,audioTracks:g,subtitles:p,captions:v,contentSteering:d,url:o,stats:t,networkDetails:s,sessionData:c,sessionKeys:u,startTimeOffset:f,variableList:m})}handleTrackOrLevelPlaylist(e,t,i,s,r){const n=this.hls,{id:o,level:l,type:d}=i,h=ut(e,i),c=0,u=k(l)?l:k(o)?o:0,f=di(i),m=ge.parseLevelPlaylist(e.data,h,u,f,c,this.variableList);if(d===j.MANIFEST){const g={attrs:new Z({}),bitrate:0,details:m,name:"",url:h};n.trigger(x.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:h,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=m,this.handlePlaylistLoaded(m,e,t,i,s,r)}handleManifestParsingError(e,t,i,s,r){this.hls.trigger(x.ERROR,{type:K.NETWORK_ERROR,details:R.MANIFEST_PARSING_ERROR,fatal:t.type===j.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:s,stats:r})}handleNetworkError(e,t,i=!1,s,r){let n=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===j.LEVEL?n+=`: ${e.level} id: ${e.id}`:(e.type===j.AUDIO_TRACK||e.type===j.SUBTITLE_TRACK)&&(n+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(n);S.warn(`[playlist-loader]: ${n}`);let l=R.UNKNOWN,d=!1;const h=this.getInternalLoader(e);switch(e.type){case j.MANIFEST:l=i?R.MANIFEST_LOAD_TIMEOUT:R.MANIFEST_LOAD_ERROR,d=!0;break;case j.LEVEL:l=i?R.LEVEL_LOAD_TIMEOUT:R.LEVEL_LOAD_ERROR,d=!1;break;case j.AUDIO_TRACK:l=i?R.AUDIO_TRACK_LOAD_TIMEOUT:R.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case j.SUBTITLE_TRACK:l=i?R.SUBTITLE_TRACK_LOAD_TIMEOUT:R.SUBTITLE_LOAD_ERROR,d=!1;break}h&&this.resetInternalLoader(e.type);const c={type:K.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:h,context:e,error:o,networkDetails:t,stats:r};if(s){const u=t?.url||e.url;c.response=oe({url:u,data:void 0},s)}this.hls.trigger(x.ERROR,c)}handlePlaylistLoaded(e,t,i,s,r,n){const o=this.hls,{type:l,level:d,id:h,groupId:c,deliveryDirectives:u}=s,f=ut(t,s),m=di(s),g=typeof s.level=="number"&&m===z.MAIN?d:void 0;if(!e.fragments.length){const v=new Error("No Segments found in Playlist");o.trigger(x.ERROR,{type:K.NETWORK_ERROR,details:R.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:v,reason:v.message,response:t,context:s,level:g,parent:m,networkDetails:r,stats:i});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const p=e.playlistParsingError;if(p){o.trigger(x.ERROR,{type:K.NETWORK_ERROR,details:R.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:p,reason:p.message,response:t,context:s,level:g,parent:m,networkDetails:r,stats:i});return}switch(e.live&&n&&(n.getCacheAge&&(e.ageHeader=n.getCacheAge()||0),(!n.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case j.MANIFEST:case j.LEVEL:o.trigger(x.LEVEL_LOADED,{details:e,level:g||0,id:h||0,stats:i,networkDetails:r,deliveryDirectives:u});break;case j.AUDIO_TRACK:o.trigger(x.AUDIO_TRACK_LOADED,{details:e,id:h||0,groupId:c||"",stats:i,networkDetails:r,deliveryDirectives:u});break;case j.SUBTITLE_TRACK:o.trigger(x.SUBTITLE_TRACK_LOADED,{details:e,id:h||0,groupId:c||"",stats:i,networkDetails:r,deliveryDirectives:u});break}}}function tr(a,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=a,e.dispatchEvent(t)}function ir(a){const e=a.mode;if(e==="disabled"&&(a.mode="hidden"),a.cues)for(let t=a.cues.length;t--;)a.removeCue(a.cues[t]);e==="disabled"&&(a.mode=e)}function sr(a,e,t,i){const s=a.mode;if(s==="disabled"&&(a.mode="hidden"),a.cues&&a.cues.length>0){const r=nr(a.cues,e,t);for(let n=0;n<r.length;n++)(!i||i(r[n]))&&a.removeCue(r[n])}s==="disabled"&&(a.mode=s)}function rr(a,e){if(e<a[0].startTime)return 0;const t=a.length-1;if(e>a[t].endTime)return-1;let i=0,s=t;for(;i<=s;){const r=Math.floor((s+i)/2);if(e<a[r].startTime)s=r-1;else if(e>a[r].startTime&&i<t)i=r+1;else return r}return a[i].startTime-e<e-a[s].startTime?i:s}function nr(a,e,t){const i=[],s=rr(a,e);if(s>-1)for(let r=s,n=a.length;r<n;r++){const o=a[r];if(o.startTime>=e&&o.endTime<=t)i.push(o);else if(o.startTime>t)return i}return i}var he={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const ar=.25;function ft(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function hi(a,e,t,i,s){let r=new a(e,t,"");try{r.value=i,s&&(r.type=s)}catch{r=new a(e,t,JSON.stringify(s?oe({type:s},i):i))}return r}const He=(()=>{const a=ft();try{a&&new a(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function mt(a,e){return a.getTime()/1e3-e}function or(a){return Uint8Array.from(a.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class lr{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(ir(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const i=e[t];if(i.kind==="metadata"&&i.label==="id3")return tr(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:s}}}=this;if(!i&&!s)return;const{samples:r}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const n=ft();if(n)for(let o=0;o<r.length;o++){const l=r[o].type;if(l===he.emsg&&!i||!s)continue;const d=Gt(r[o].data);if(d){const h=r[o].pts;let c=h+r[o].duration;c>He&&(c=He),c-h<=0&&(c=h+ar);for(let f=0;f<d.length;f++){const m=d[f];if(!$t(m)){this.updateId3CueEnds(h,l);const g=hi(n,h,c,m,l);g&&this.id3Track.addCue(g)}}}}}updateId3CueEnds(e,t){var i;const s=(i=this.id3Track)==null?void 0:i.cues;if(s)for(let r=s.length;r--;){const n=s[r];n.type===t&&n.startTime<e&&n.endTime===He&&(n.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:s}){const{id3Track:r,hls:n}=this;if(!n)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=n;if(r&&(o||l)){let d;s==="audio"?d=h=>h.type===he.audioId3&&l:s==="video"?d=h=>h.type===he.emsg&&o:d=h=>h.type===he.audioId3&&l||h.type===he.emsg&&o,sr(r,t,i,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:s}=this,{dateRanges:r}=t,n=Object.keys(r);if(s){const h=Object.keys(i).filter(c=>!n.includes(c));for(let c=h.length;c--;){const u=h[c];Object.keys(i[u].cues).forEach(f=>{s.removeCue(i[u].cues[f])}),delete i[u]}}const o=t.fragments[t.fragments.length-1];if(n.length===0||!k(o?.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=o.programDateTime/1e3-o.start,d=ft();for(let h=0;h<n.length;h++){const c=n[h],u=r[c],f=mt(u.startDate,l),m=i[c],g=m?.cues||{};let p=m?.durationKnown||!1,v=He;const L=u.endDate;if(L)v=mt(L,l),p=!0;else if(u.endOnNext&&!p){const b=n.reduce((T,I)=>{if(I!==u.id){const A=r[I];if(A.class===u.class&&A.startDate>u.startDate&&(!T||u.startDate<T.startDate))return A}return T},null);b&&(v=mt(b.startDate,l),p=!0)}const y=Object.keys(u.attr);for(let b=0;b<y.length;b++){const T=y[b];if(!ps(T))continue;const I=g[T];if(I)p&&!m.durationKnown&&(I.endTime=v);else if(d){let A=u.attr[T];xs(T)&&(A=or(A));const D=hi(d,f,v,{key:T,data:A},he.dateRange);D&&(D.id=c,this.id3Track.addCue(D),g[T]=D)}}i[c]={cues:g,dateRange:u,durationKnown:p}}}}class dr{constructor(e){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=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(e===null)return null;const{holdBack:t,partHoldBack:i,targetduration:s}=e,{liveSyncDuration:r,liveSyncDurationCount:n,lowLatencyMode:o}=this.config,l=this.hls.userConfig;let d=o&&i||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=r!==void 0?r:n*s);const h=s;return d+Math.min(this.stallCount*1,h)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency,i=this.levelDetails;if(e===null||t===null||i===null)return null;const s=i.edge,r=e-t-this.edgeStalled,n=s-i.totalduration,o=s-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(n,r),o)}get drift(){const{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e,levelDetails:t}=this;if(!e||!t)return 0;const i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(x.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(x.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.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(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var i;t.details===R.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&S.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;const i=this.computeLatency();if(i===null)return;this._latency=i;const{lowLatencyMode:s,maxLiveSyncPlaybackRate:r}=this.config;if(!s||r===1||!t.live)return;const n=this.targetLatency;if(n===null)return;const o=i-n,l=Math.min(this.maxLatency,n+t.targetduration);if(o<l&&o>.05&&this.forwardBufferLength>1){const h=Math.min(2,Math.max(1,r)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(h,Math.max(1,c))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}const gt=["NONE","TYPE-0","TYPE-1",null];function hr(a){return gt.indexOf(a)>-1}const Ke=["SDR","PQ","HLG"];function cr(a){return!!a&&Ke.indexOf(a)>-1}var We={No:"",Yes:"YES",v2:"v2"};function ci(a){const{canSkipUntil:e,canSkipDateRanges:t,age:i}=a,s=i<e/2;return e&&s?t?We.v2:We.Yes:We.No}class ui{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class pt{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>!!t).map(t=>t.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return fi(this._audioGroups,e)}hasSubtitleGroup(e){return fi(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let i=this._audioGroups;i||(i=this._audioGroups=[]),i.indexOf(t)===-1&&i.push(t)}else if(e==="text"){let i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),i.indexOf(t)===-1&&i.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function fi(a,e){return!e||!a?!1:a.indexOf(e)!==-1}function xt(a,e){const t=e.startPTS;if(k(t)){let i=0,s;e.sn>a.sn?(i=t-a.start,s=a):(i=a.start-t,s=e),s.duration!==i&&(s.duration=i)}else e.sn>a.sn?a.cc===e.cc&&a.minEndPTS?e.start=a.start+(a.minEndPTS-a.start):e.start=a.start+a.duration:e.start=Math.max(a.start-e.duration,0)}function mi(a,e,t,i,s,r){i-t<=0&&(S.warn("Fragment should have a positive duration",e),i=t+e.duration,r=s+e.duration);let o=t,l=i;const d=e.startPTS,h=e.endPTS;if(k(d)){const p=Math.abs(d-t);k(e.deltaPTS)?e.deltaPTS=Math.max(p,e.deltaPTS):e.deltaPTS=p,o=Math.max(t,d),t=Math.min(t,d),s=Math.min(s,e.startDTS),l=Math.min(i,h),i=Math.max(i,h),r=Math.max(r,e.endDTS)}const c=t-e.start;e.start!==0&&(e.start=t),e.duration=i-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=i,e.minEndPTS=l,e.endDTS=r;const u=e.sn;if(!a||u<a.startSN||u>a.endSN)return 0;let f;const m=u-a.startSN,g=a.fragments;for(g[m]=e,f=m;f>0;f--)xt(g[f],g[f-1]);for(f=m;f<g.length-1;f++)xt(g[f],g[f+1]);return a.fragmentHint&&xt(g[g.length-1],a.fragmentHint),a.PTSKnown=a.alignedSliding=!0,c}function ur(a,e){let t=null;const i=a.fragments;for(let l=i.length-1;l>=0;l--){const d=i[l].initSegment;if(d){t=d;break}}a.fragmentHint&&delete a.fragmentHint.endPTS;let s=0,r;if(gr(a,e,(l,d)=>{l.relurl&&(s=l.cc-d.cc),k(l.startPTS)&&k(l.endPTS)&&(d.start=d.startPTS=l.startPTS,d.startDTS=l.startDTS,d.maxStartPTS=l.maxStartPTS,d.endPTS=l.endPTS,d.endDTS=l.endDTS,d.minEndPTS=l.minEndPTS,d.duration=l.endPTS-l.startPTS,d.duration&&(r=d),e.PTSKnown=e.alignedSliding=!0),d.elementaryStreams=l.elementaryStreams,d.loader=l.loader,d.stats=l.stats,l.initSegment&&(d.initSegment=l.initSegment,t=l.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(d=>{var h;d&&(!d.initSegment||d.initSegment.relurl===((h=t)==null?void 0:h.relurl))&&(d.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){S.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=fr(a.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const n=e.fragments;if(s){S.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<n.length;l++)n[l].cc+=s}e.skippedSegments&&(e.startCC=e.fragments[0].cc),mr(a.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats}),r?mi(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):gi(a,e),n.length&&(e.totalduration=e.edge-n[0].start),e.driftStartTime=a.driftStartTime,e.driftStart=a.driftStart;const o=e.advancedDateTime;if(e.advanced&&o){const l=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=l),e.driftEndTime=o,e.driftEnd=l}else e.driftEndTime=a.driftEndTime,e.driftEnd=a.driftEnd,e.advancedDateTime=a.advancedDateTime}function fr(a,e,t){const i=ae({},a);return t&&t.forEach(s=>{delete i[s]}),Object.keys(e).forEach(s=>{const r=new Mt(e[s].attr,i[s]);r.isValid?i[s]=r:S.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),i}function mr(a,e,t){if(a&&e){let i=0;for(let s=0,r=a.length;s<=r;s++){const n=a[s],o=e[s+i];n&&o&&n.index===o.index&&n.fragment.sn===o.fragment.sn?t(n,o):i--}}}function gr(a,e,t){const i=e.skippedSegments,s=Math.max(a.startSN,e.startSN)-e.startSN,r=(a.fragmentHint?1:0)+(i?e.endSN:Math.min(a.endSN,e.endSN))-e.startSN,n=e.startSN-a.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments;for(let d=s;d<=r;d++){const h=l[n+d];let c=o[d];i&&!c&&d<i&&(c=e.fragments[d]=h),h&&c&&t(h,c)}}function gi(a,e){const t=e.startSN+e.skippedSegments-a.startSN,i=a.fragments;t<0||t>=i.length||pr(e,i[t].start)}function pr(a,e){if(e){const t=a.fragments;for(let i=a.skippedSegments;i<t.length;i++)t[i].start+=e;a.fragmentHint&&(a.fragmentHint.start+=e)}}function xr(a,e=1/0){let t=1e3*a.targetduration;if(a.updated){const i=a.fragments;if(i.length&&t*4>e){const r=i[i.length-1].duration*1e3;r<t&&(t=r)}}else t/=2;return Math.round(t)}function vr(a,e,t){if(!(a!=null&&a.details))return null;const i=a.details;let s=i.fragments[e-i.startSN];return s||(s=i.fragmentHint,s&&s.sn===e)?s:e<i.startSN&&t&&t.sn===e?t:null}function pi(a,e,t){var i;return a!=null&&a.details?xi((i=a.details)==null?void 0:i.partList,e,t):null}function xi(a,e,t){if(a)for(let i=a.length;i--;){const s=a[i];if(s.index===t&&s.fragment.sn===e)return s}return null}function vi(a){a.forEach((e,t)=>{const{details:i}=e;i!=null&&i.fragments&&i.fragments.forEach(s=>{s.level=t})})}function Ye(a){switch(a.details){case R.FRAG_LOAD_TIMEOUT:case R.KEY_LOAD_TIMEOUT:case R.LEVEL_LOAD_TIMEOUT:case R.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function yi(a,e){const t=Ye(e);return a.default[`${t?"timeout":"error"}Retry`]}function vt(a,e){const t=a.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*a.retryDelayMs,a.maxRetryDelayMs)}function Ei(a){return oe(oe({},a),{errorRetry:null,timeoutRetry:null})}function je(a,e,t,i){if(!a)return!1;const s=i?.code,r=e<a.maxNumRetry&&(yr(s)||!!t);return a.shouldRetry?a.shouldRetry(a,e,t,i,r):r}function yr(a){return a===0&&navigator.onLine===!1||!!a&&(a<400||a>499)}const Ti={search:function(a,e){let t=0,i=a.length-1,s=null,r=null;for(;t<=i;){s=(t+i)/2|0,r=a[s];const n=e(r);if(n>0)t=s+1;else if(n<0)i=s-1;else return r}return null}};function Er(a,e,t){if(e===null||!Array.isArray(a)||!a.length||!k(e))return null;const i=a[0].programDateTime;if(e<(i||0))return null;const s=a[a.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let r=0;r<a.length;++r){const n=a[r];if(Tr(e,t,n))return n}return null}function Si(a,e,t=0,i=0){let s=null;if(a){s=e[a.sn-e[0].sn+1]||null;const n=a.endDTS-t;n>0&&n<15e-7&&(t+=15e-7)}else t===0&&e[0].start===0&&(s=e[0]);if(s&&(!a||a.level===s.level)&&Li(t,i,s)===0)return s;const r=Ti.search(e,Li.bind(null,t,i));return r&&(r!==a||!s)?r:s}function Li(a=0,e=0,t){if(t.start<=a&&t.start+t.duration>a)return 0;const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=a?1:t.start-i>a&&t.start?-1:0}function Tr(a,e,t){const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>a}function Sr(a,e){return Ti.search(a,t=>t.cc<e?1:t.cc>e?-1:0)}var ie={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},ce={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class Lr{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=S.log.bind(S,"[info]:"),this.warn=S.warn.bind(S,"[warning]:"),this.error=S.error.bind(S,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(x.ERROR,this.onError,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(x.ERROR,this.onError,this),e.off(x.ERROR,this.onErrorOut,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return e?.type===z.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var i,s;if(t.fatal)return;const r=this.hls,n=t.context;switch(t.details){case R.FRAG_LOAD_ERROR:case R.FRAG_LOAD_TIMEOUT:case R.KEY_LOAD_ERROR:case R.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case R.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap){t.errorAction={action:ie.DoNothing,flags:ce.None};return}case R.FRAG_GAP:case R.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=ie.SendAlternateToPenaltyBox;return}case R.LEVEL_EMPTY_ERROR:case R.LEVEL_PARSING_ERROR:{var o,l;const d=t.parent===z.MAIN?t.level:r.loadLevel;t.details===R.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case R.LEVEL_LOAD_ERROR:case R.LEVEL_LOAD_TIMEOUT:typeof n?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level));return;case R.AUDIO_TRACK_LOAD_ERROR:case R.AUDIO_TRACK_LOAD_TIMEOUT:case R.SUBTITLE_LOAD_ERROR:case R.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const d=r.levels[r.loadLevel];if(d&&(n.type===j.AUDIO_TRACK&&d.hasAudioGroup(n.groupId)||n.type===j.SUBTITLE_TRACK&&d.hasSubtitleGroup(n.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.loadLevel),t.errorAction.action=ie.SendAlternateToPenaltyBox,t.errorAction.flags=ce.MoveAllAlternatesMatchingHost;return}}return;case R.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const d=r.levels[r.loadLevel],h=d?.attrs["HDCP-LEVEL"];h?t.errorAction={action:ie.SendAlternateToPenaltyBox,flags:ce.MoveAllAlternatesMatchingHDCP,hdcpLevel:h}:this.keySystemError(t)}return;case R.BUFFER_ADD_CODEC_ERROR:case R.REMUX_ALLOC_ERROR:case R.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:r.loadLevel);return;case R.INTERNAL_EXCEPTION:case R.BUFFER_APPENDING_ERROR:case R.BUFFER_FULL_ERROR:case R.LEVEL_SWITCH_ERROR:case R.BUFFER_STALLED_ERROR:case R.BUFFER_SEEK_OVER_HOLE:case R.BUFFER_NUDGE_ON_STALL:t.errorAction={action:ie.DoNothing,flags:ce.None};return}t.type===K.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){const t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){const i=this.hls,s=yi(i.config.playlistLoadPolicy,e),r=this.playlistError++;if(je(s,r,Ye(e),e.response))return{action:ie.RetryRequest,flags:ce.None,retryConfig:s,retryCount:r};const o=this.getLevelSwitchAction(e,t);return s&&(o.retryConfig=s,o.retryCount=r),o}getFragRetryOrSwitchAction(e){const t=this.hls,i=this.getVariantLevelIndex(e.frag),s=t.levels[i],{fragLoadPolicy:r,keyLoadPolicy:n}=t.config,o=yi(e.details.startsWith("key")?n:r,e),l=t.levels.reduce((h,c)=>h+c.fragmentError,0);if(s&&(e.details!==R.FRAG_GAP&&s.fragmentError++,je(o,l,Ye(e),e.response)))return{action:ie.RetryRequest,flags:ce.None,retryConfig:o,retryCount:l};const d=this.getLevelSwitchAction(e,i);return o&&(d.retryConfig=o,d.retryCount=l),d}getLevelSwitchAction(e,t){const i=this.hls;t==null&&(t=i.loadLevel);const s=this.hls.levels[t];if(s){var r,n;const d=e.details;s.loadError++,d===R.BUFFER_APPEND_ERROR&&s.fragmentError++;let h=-1;const{levels:c,loadLevel:u,minAutoLevel:f,maxAutoLevel:m}=i;i.autoLevelEnabled||(i.loadLevel=-1);const g=(r=e.frag)==null?void 0:r.type,v=(g===z.AUDIO&&d===R.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===R.BUFFER_ADD_CODEC_ERROR||d===R.BUFFER_APPEND_ERROR))&&c.some(({audioCodec:I})=>s.audioCodec!==I),y=e.sourceBufferName==="video"&&(d===R.BUFFER_ADD_CODEC_ERROR||d===R.BUFFER_APPEND_ERROR)&&c.some(({codecSet:I,audioCodec:A})=>s.codecSet!==I&&s.audioCodec===A),{type:b,groupId:T}=(n=e.context)!=null?n:{};for(let I=c.length;I--;){const A=(I+u)%c.length;if(A!==u&&A>=f&&A<=m&&c[A].loadError===0){var o,l;const D=c[A];if(d===R.FRAG_GAP&&e.frag){const P=c[A].details;if(P){const _=Si(e.frag,P.fragments,e.frag.start);if(_!=null&&_.gap)continue}}else{if(b===j.AUDIO_TRACK&&D.hasAudioGroup(T)||b===j.SUBTITLE_TRACK&&D.hasSubtitleGroup(T))continue;if(g===z.AUDIO&&(o=s.audioGroups)!=null&&o.some(P=>D.hasAudioGroup(P))||g===z.SUBTITLE&&(l=s.subtitleGroups)!=null&&l.some(P=>D.hasSubtitleGroup(P))||v&&s.audioCodec===D.audioCodec||!v&&s.audioCodec!==D.audioCodec||y&&s.codecSet===D.codecSet)continue}h=A;break}}if(h>-1&&i.loadLevel!==h)return e.levelRetry=!0,this.playlistError=0,{action:ie.SendAlternateToPenaltyBox,flags:ce.None,nextAutoLevel:h}}return{action:ie.SendAlternateToPenaltyBox,flags:ce.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case ie.DoNothing:break;case ie.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==R.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,i=e.errorAction;if(!i)return;const{flags:s,hdcpLevel:r,nextAutoLevel:n}=i;switch(s){case ce.None:this.switchLevel(e,n);break;case ce.MoveAllAlternatesMatchingHDCP:r&&(t.maxHdcpLevel=gt[gt.indexOf(r)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(e,n)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}}class Ar{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=S.log.bind(S,`${t}:`),this.warn=S.warn.bind(S,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,i){const s=t?.renditionReports;if(s){let r=-1;for(let n=0;n<s.length;n++){const o=s[n];let l;try{l=new self.URL(o.URI,t.url).href}catch(d){S.warn(`Could not construct new URL for Rendition Report: ${d}`),l=o.URI||""}if(l===e){r=n;break}else l===e.substring(0,l.length)&&(r=n)}if(r!==-1){const n=s[r],o=parseInt(n["LAST-MSN"])||t?.lastPartSn;let l=parseInt(n["LAST-PART"])||t?.lastPartIndex;if(this.hls.config.lowLatencyMode){const h=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&h>t.partTarget&&(l+=1)}const d=i&&ci(i);return new ui(o,l>=0?l:void 0,d)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,i){const{details:s,stats:r}=t,n=self.performance.now(),o=r.loading.first?Math.max(0,n-r.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||i!=null&&i.live){if(s.reloaded(i),i&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),i&&s.fragments.length>0&&ur(i,s),!this.canLoad||!s.live)return;let l,d,h;if(s.canBlockReload&&s.endSN&&s.advanced){const p=this.hls.config.lowLatencyMode,v=s.lastPartSn,L=s.endSN,y=s.lastPartIndex,b=y!==-1,T=v===L,I=p?0:y;b?(d=T?L+1:v,h=T?I:y+1):d=L+1;const A=s.age,D=A+s.ageHeader;let P=Math.min(D-s.partTarget,s.targetduration*1.5);if(P>0){if(i&&P>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${P} with playlist age: ${s.age}`),P=0;else{const _=Math.floor(P/s.targetduration);if(d+=_,h!==void 0){const C=Math.round(P%s.targetduration/s.partTarget);h+=C}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${A.toFixed(2)}s goal: ${P} skip sn ${_} to part ${h}`)}s.tuneInGoal=P}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,h),p||!T){this.loadPlaylist(l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,h));const c=this.hls.mainForwardBufferInfo,u=c?c.end-c.len:0,f=(s.edge-u)*1e3,m=xr(s,f);s.updated&&n>this.requestScheduled+m&&(this.requestScheduled=r.loading.start),d!==void 0&&s.canBlockReload?this.requestScheduled=r.loading.first+m-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+m<n?this.requestScheduled=n:this.requestScheduled-n<=0&&(this.requestScheduled+=m);let g=this.requestScheduled-n;g=Math.max(0,g),this.log(`reload live playlist ${e} in ${Math.round(g)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),g)}else this.clearTimer()}getDeliveryDirectives(e,t,i,s){let r=ci(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,s=t.part,r=We.No),new ui(i,s,r)}checkRetry(e){const t=e.details,i=Ye(e),s=e.errorAction,{action:r,retryCount:n=0,retryConfig:o}=s||{},l=!!s&&!!o&&(r===ie.RetryRequest||!s.resolved&&r===ie.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,n>=o.maxNumRetry)return!1;if(i&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${n+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const h=vt(o,n);this.timer=self.setTimeout(()=>this.loadPlaylist(),h),this.warn(`Retrying playlist loading ${n+1}/${o.maxNumRetry} after "${t}" in ${h}ms`)}e.levelRetry=!0,s.resolved=!0}return l}}class Ie{constructor(e,t=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}sample(e,t){const i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class Rr{constructor(e,t,i,s=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_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Ie(e),this.fast_=new Ie(t),this.defaultTTFB_=s,this.ttfb_=new Ie(e)}update(e,t){const{slow_:i,fast_:s,ttfb_:r}=this;i.halfLife!==e&&(this.slow_=new Ie(e,i.getEstimate(),i.getTotalWeight())),s.halfLife!==t&&(this.fast_=new Ie(t,s.getEstimate(),s.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new Ie(e,r.getEstimate(),r.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const i=8*t,s=e/1e3,r=i/s;this.fast_.sample(s,r),this.slow_.sample(s,r)}sampleTTFB(e){const t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}function br(){if(typeof matchMedia=="function"){const a=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(a.media!==e.media)return a.matches===!0}return!1}function Ir(a,e){let t=!1,i=[];return a&&(t=a!=="SDR",i=[a]),e&&(i=e.allowedVideoRanges||Ke.slice(0),t=e.preferHDR!==void 0?e.preferHDR:br(),t?i=i.filter(s=>s!=="SDR"):i=["SDR"]),{preferHDR:t,allowedVideoRanges:i}}function Dr(a,e,t,i,s){const r=Object.keys(a),n=i?.channels,o=i?.audioCodec,l=n&&parseInt(n)===2;let d=!0,h=!1,c=1/0,u=1/0,f=1/0,m=0,g=[];const{preferHDR:p,allowedVideoRanges:v}=Ir(e,s);for(let T=r.length;T--;){const I=a[r[T]];d=I.channels[2]>0,c=Math.min(c,I.minHeight),u=Math.min(u,I.minFramerate),f=Math.min(f,I.minBitrate);const A=v.filter(D=>I.videoRanges[D]>0);A.length>0&&(h=!0,g=A)}c=k(c)?c:0,u=k(u)?u:0;const L=Math.max(1080,c),y=Math.max(30,u);return f=k(f)?f:t,t=Math.max(f,t),h||(e=void 0,g=[]),{codecSet:r.reduce((T,I)=>{const A=a[I];if(I===T)return T;if(A.minBitrate>t)return pe(I,`min bitrate of ${A.minBitrate} > current estimate of ${t}`),T;if(!A.hasDefaultAudio)return pe(I,"no renditions with default or auto-select sound found"),T;if(o&&I.indexOf(o.substring(0,4))%5!==0)return pe(I,`audio codec preference "${o}" not found`),T;if(n&&!l){if(!A.channels[n])return pe(I,`no renditions with ${n} channel sound found (channels options: ${Object.keys(A.channels)})`),T}else if((!o||l)&&d&&A.channels[2]===0)return pe(I,"no renditions with stereo sound found"),T;return A.minHeight>L?(pe(I,`min resolution of ${A.minHeight} > maximum of ${L}`),T):A.minFramerate>y?(pe(I,`min framerate of ${A.minFramerate} > maximum of ${y}`),T):g.some(D=>A.videoRanges[D]>0)?A.maxScore<m?(pe(I,`max score of ${A.maxScore} < selected max of ${m}`),T):T&&(Ge(I)>=Ge(T)||A.fragmentError>a[T].fragmentError)?T:(m=A.maxScore,I):(pe(I,`no variants with VIDEO-RANGE of ${JSON.stringify(g)} found`),T)},void 0),videoRanges:g,preferHDR:p,minFramerate:u,minBitrate:f}}function pe(a,e){S.log(`[abr] start candidates with "${a}" ignored because ${e}`)}function Cr(a){return a.reduce((e,t)=>{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);const s=t.channels||"2";return i.channels[s]=(i.channels[s]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function _r(a,e,t,i){return a.slice(t,i+1).reduce((s,r)=>{if(!r.codecSet)return s;const n=r.audioGroups;let o=s[r.codecSet];o||(s[r.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!n,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,r.bitrate);const l=Math.min(r.height,r.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,r.frameRate),o.maxScore=Math.max(o.maxScore,r.score),o.fragmentError+=r.fragmentError,o.videoRanges[r.videoRange]=(o.videoRanges[r.videoRange]||0)+1,s},{})}class wr{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{const{fragCurrent:t,partCurrent:i,hls:s}=this,{autoLevelEnabled:r,media:n}=s;if(!t||!n)return;const o=performance.now(),l=i?i.stats:t.stats,d=i?i.duration:t.duration,h=o-l.loading.start,c=s.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||t.level<=c){this.clearTimer(),this._nextAutoLevel=-1;return}if(!r||n.paused||!n.playbackRate||!n.readyState)return;const u=s.mainForwardBufferInfo;if(u===null)return;const f=this.bwEstimator.getEstimateTTFB(),m=Math.abs(n.playbackRate);if(h<=Math.max(f,1e3*(d/(m*2))))return;const g=u.len/m,p=l.loading.first?l.loading.first-l.loading.start:-1,v=l.loaded&&p>-1,L=this.getBwEstimate(),y=s.levels,b=y[t.level],T=l.total||Math.max(l.loaded,Math.round(d*b.averageBitrate/8));let I=v?h-p:h;I<1&&v&&(I=Math.min(h,l.loaded*8/L));const A=v?l.loaded*1e3/I:0,D=A?(T-l.loaded)/A:T*8/L+f/1e3;if(D<=g)return;const P=A?A*8:L;let _=Number.POSITIVE_INFINITY,C;for(C=t.level-1;C>c;C--){const M=y[C].maxBitrate;if(_=this.getTimeToLoadFrag(f/1e3,P,d*M,!y[C].details),_<g)break}if(_>=D||_>d*10)return;s.nextLoadLevel=s.nextAutoLevel=C,v?this.bwEstimator.sample(h-Math.min(f,p),l.loaded):this.bwEstimator.sampleTTFB(h);const $=y[C].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>$&&this.resetEstimator($),this.clearTimer(),S.warn(`[abr] Fragment ${t.sn}${i?" part "+i.index:""} of level ${t.level} is loading too slowly;
|
2
|
+
Time to underbuffer: ${g.toFixed(3)} s
|
3
|
+
Estimated load time for current fragment: ${D.toFixed(3)} s
|
4
|
+
Estimated load time for down switch fragment: ${_.toFixed(3)} s
|
5
|
+
TTFB estimate: ${p|0} ms
|
6
|
+
Current BW estimate: ${k(L)?L|0:"Unknown"} bps
|
7
|
+
New BW estimate: ${this.getBwEstimate()|0} bps
|
8
|
+
Switching to level ${C} @ ${$|0} bps`),s.trigger(x.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:i,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(S.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new Rr(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.FRAG_LOADING,this.onFragLoading,this),e.on(x.FRAG_LOADED,this.onFragLoaded,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this),e.on(x.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(x.LEVEL_LOADED,this.onLevelLoaded,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(x.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.FRAG_LOADING,this.onFragLoading,this),e.off(x.FRAG_LOADED,this.onFragLoaded,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this),e.off(x.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(x.LEVEL_LOADED,this.onLevelLoaded,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(x.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const i=t.frag;if(!this.ignoreFragment(i)){if(!i.bitrateTest){var s;this.fragCurrent=i,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case R.BUFFER_ADD_CODEC_ERROR:case R.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case R.FRAG_LOAD_TIMEOUT:{const i=t.frag,{fragCurrent:s,partCurrent:r}=this;if(i&&s&&i.sn===s.sn&&i.level===s.level){const n=performance.now(),o=r?r.stats:i.stats,l=n-o.loading.start,d=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&d>-1){const c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(c,d),o.loaded)}else this.bwEstimator.sampleTTFB(l)}break}}}getTimeToLoadFrag(e,t,i,s){const r=e+i/t,n=s?this.lastLevelLoadSec:0;return r+n}onLevelLoaded(e,t){const i=this.hls.config,{loading:s}=t.stats,r=s.end-s.start;k(r)&&(this.lastLevelLoadSec=r/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}onFragLoaded(e,{frag:t,part:i}){const s=i?i.stats:t.stats;if(t.type===z.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const r=i?i.duration:t.duration,n=this.hls.levels[t.level],o=(n.loaded?n.loaded.bytes:0)+s.loaded,l=(n.loaded?n.loaded.duration:0)+r;n.loaded={bytes:o,duration:l},n.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){const r={stats:s,frag:t,part:i,id:t.type};this.onFragBuffered(x.FRAG_BUFFERED,r),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:i,part:s}=t,r=s!=null&&s.stats.loaded?s.stats:i.stats;if(r.aborted||this.ignoreFragment(i))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.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==z.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,i=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,r=this.findBestLevel(i,t,e,0,s,1,1);if(r>-1)return r;const n=this.hls.firstLevel,o=Math.min(Math.max(n,t),e);return S.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${n} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,i=this.bwEstimator.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!i||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const r=i&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const n=this.hls.levels;if(n.length>Math.max(e,r)&&n[e].loadError<=n[r].loadError)return e}return this._nextAutoLevel=r,this.nextAutoLevelKey=this.getAutoLevelKey(),r}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:i}=this,{maxAutoLevel:s,config:r,minAutoLevel:n}=i,o=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),d=this.getStarvationDelay();let h=r.abrBandWidthFactor,c=r.abrBandWidthUpFactor;if(d){const p=this.findBestLevel(l,n,s,d,0,h,c);if(p>=0)return p}let u=o?Math.min(o,r.maxStarvationDelay):r.maxStarvationDelay;if(!d){const p=this.bitrateTestDelay;p&&(u=(o?Math.min(o,r.maxLoadingDelay):r.maxLoadingDelay)-p,S.info(`[abr] bitrate test took ${Math.round(1e3*p)}ms, set first fragment max fetchDuration to ${Math.round(1e3*u)} ms`),h=c=1)}const f=this.findBestLevel(l,n,s,d,u,h,c);if(S.info(`[abr] ${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`),f>-1)return f;const m=i.levels[n],g=i.levels[i.loadLevel];return m?.bitrate<g?.bitrate?n:i.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const i=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/i}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,i,s,r,n,o){var l;const d=s+r,h=this.lastLoadedFragLevel,c=h===-1?this.hls.firstLevel:h,{fragCurrent:u,partCurrent:f}=this,{levels:m,allAudioTracks:g,loadLevel:p,config:v}=this.hls;if(m.length===1)return 0;const L=m[c],y=!!(L!=null&&(l=L.details)!=null&&l.live),b=p===-1||h===-1;let T,I="SDR",A=L?.frameRate||0;const{audioPreference:D,videoPreference:P}=v,_=this.audioTracksByGroup||(this.audioTracksByGroup=Cr(g));if(b){if(this.firstSelection!==-1)return this.firstSelection;const B=this.codecTiers||(this.codecTiers=_r(m,_,t,i)),V=Dr(B,I,e,D,P),{codecSet:W,videoRanges:X,minFramerate:O,minBitrate:F,preferHDR:Y}=V;T=W,I=Y?X[X.length-1]:X[0],A=O,e=Math.max(e,F),S.log(`[abr] picked start tier ${JSON.stringify(V)}`)}else T=L?.codecSet,I=L?.videoRange;const C=f?f.duration:u?u.duration:0,$=this.bwEstimator.getEstimateTTFB()/1e3,M=[];for(let B=i;B>=t;B--){var U;const V=m[B],W=B>c;if(!V)continue;if(T&&V.codecSet!==T||I&&V.videoRange!==I||W&&A>V.frameRate||!W&&A>0&&A<V.frameRate||V.supportedResult&&!((U=V.supportedResult.decodingInfoResults)!=null&&U[0].smooth)){M.push(B);continue}const X=V.details,O=(f?X?.partTarget:X?.averagetargetduration)||C;let F;W?F=o*e:F=n*e;const Y=C&&s>=C*2&&r===0?m[B].averageBitrate:m[B].maxBitrate,H=this.getTimeToLoadFrag($,F,Y*O,X===void 0);if(F>=Y&&(B===h||V.loadError===0&&V.fragmentError===0)&&(H<=$||!k(H)||y&&!this.bitrateTestDelay||H<d)){const se=this.forcedAutoLevel;return B!==p&&(se===-1||se!==p)&&(M.length&&S.trace(`[abr] Skipped level(s) ${M.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${m[M[0]].codecs}" ${m[M[0]].videoRange}; not compatible with "${L.codecs}" ${I}`),S.info(`[abr] switch candidate:${c}->${B} adjustedbw(${Math.round(F)})-bitrate=${Math.round(F-Y)} ttfb:${$.toFixed(1)} avgDuration:${O.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${H.toFixed(1)} firstSelection:${b} codecSet:${T} videoRange:${I} hls.loadLevel:${p}`)),b&&(this.firstSelection=B),B}}return-1}set nextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:i}=this.hls,s=Math.min(Math.max(e,i),t);this._nextAutoLevel!==s&&(this.nextAutoLevelKey="",this._nextAutoLevel=s)}}const Pr={length:0,start:()=>0,end:()=>0};class J{static isBuffered(e,t){try{if(e){const i=J.getBuffered(e);for(let s=0;s<i.length;s++)if(t>=i.start(s)&&t<=i.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,i){try{if(e){const s=J.getBuffered(e),r=[];let n;for(n=0;n<s.length;n++)r.push({start:s.start(n),end:s.end(n)});return this.bufferedInfo(r,t,i)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.sort(function(d,h){const c=d.start-h.start;return c||h.end-d.end});let s=[];if(i)for(let d=0;d<e.length;d++){const h=s.length;if(h){const c=s[h-1].end;e[d].start-c<i?e[d].end>c&&(s[h-1].end=e[d].end):s.push(e[d])}else s.push(e[d])}else s=e;let r=0,n,o=t,l=t;for(let d=0;d<s.length;d++){const h=s[d].start,c=s[d].end;if(t+i>=h&&t<c)o=h,l=c,r=l-t;else if(t+i<h){n=h;break}}return{len:r,start:o||0,end:l||0,nextStart:n}}static getBuffered(e){try{return e.buffered}catch(t){return S.log("failed to get media.buffered",t),Pr}}}class Fr{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,i){const s=this.queues[t];s.push(e),s.length===1&&!i&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t;const i=new Promise(r=>{t=r}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),i}executeNext(e){const t=this.queues[e];if(t.length){const i=t[0];try{i.execute()}catch(s){S.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${s}`),i.onError(s);const r=this.buffers[e];r!=null&&r.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const Ai=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;class Or{constructor(e){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.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=i=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=i=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{const{media:i,mediaSource:s}=this;this.log("Media source opened"),i&&(i.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(x.MEDIA_ATTACHED,{media:i,mediaSource:s})),s&&s.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:i,_objectUrl:s}=this;i!==s&&S.error(`Media element src was set while attaching MediaSource (${s} > ${i})`)},this.hls=e;const t="[buffer-controller]";this.appendSource=Ws(Re(e.config.preferManagedMediaSource)),this.log=S.log.bind(S,t),this.warn=S.warn.bind(S,t),this.error=S.error.bind(S,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,this.hls=null}registerListeners(){const{hls:e}=this;e.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.BUFFER_RESET,this.onBufferReset,this),e.on(x.BUFFER_APPENDING,this.onBufferAppending,this),e.on(x.BUFFER_CODECS,this.onBufferCodecs,this),e.on(x.BUFFER_EOS,this.onBufferEos,this),e.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(x.FRAG_PARSED,this.onFragParsed,this),e.on(x.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.BUFFER_RESET,this.onBufferReset,this),e.off(x.BUFFER_APPENDING,this.onBufferAppending,this),e.off(x.BUFFER_CODECS,this.onBufferCodecs,this),e.off(x.BUFFER_EOS,this.onBufferEos,this),e.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(x.FRAG_PARSED,this.onFragParsed,this),e.off(x.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Fr(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let i=2;t.audio&&!t.video||t.altAudio,i=1,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){const i=this.media=t.media,s=Re(this.appendSource);if(i&&s){var r;const n=this.mediaSource=new s;this.log(`created media source: ${(r=n.constructor)==null?void 0:r.name}`),n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(n.addEventListener("startstreaming",this._onStartStreaming),n.addEventListener("endstreaming",this._onEndStreaming));const o=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{i.removeAttribute("src");const l=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||l&&n instanceof l,Ri(i),kr(i,o),i.load()}catch{i.src=o}else i.src=o;i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:e,mediaSource:t,_objectUrl:i}=this;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){this.warn(`onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),i&&self.URL.revokeObjectURL(i),this.mediaSrc===i?(e.removeAttribute("src"),this.appendSource&&Ri(e),e.load()):this.warn("media|source.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(x.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e)}),this._initSourceBuffer()}resetBuffer(e){const t=this.sourceBuffer[e];try{if(t){var i;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(i=this.mediaSource)!=null&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(s){this.warn(`onBufferReset ${e}`,s)}}onBufferCodecs(e,t){const i=this.getSourceBufferTypes().length,s=Object.keys(t);if(s.forEach(n=>{if(i){const l=this.tracks[n];if(l&&typeof l.buffer.changeType=="function"){var o;const{id:d,codec:h,levelCodec:c,container:u,metadata:f}=t[n],m=Zt(l.codec,l.levelCodec),g=m?.replace(Ai,"$1");let p=Zt(h,c);const v=(o=p)==null?void 0:o.replace(Ai,"$1");if(p&&g!==v){n.slice(0,5)==="audio"&&(p=Ve(p,this.appendSource));const L=`${u};codecs=${p}`;this.appendChangeType(n,L),this.log(`switching codec ${m} to ${p}`),this.tracks[n]={buffer:l.buffer,codec:h,container:u,levelCodec:c,metadata:f,id:d}}}}else this.pendingTracks[n]=t[n]}),i)return;const r=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==r&&(this.log(`${r} bufferCodec event(s) expected ${s.join(",")}`),this.bufferCodecEventsExpected=r),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}appendChangeType(e,t){const{operationQueue:i}=this,s={execute:()=>{const r=this.sourceBuffer[e];r&&(this.log(`changing ${e} sourceBuffer type to ${t}`),r.changeType(t)),i.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:r=>{this.warn(`Failed to change ${e} SourceBuffer type`,r)}};i.append(s,e,!!this.pendingTracks[e])}onBufferAppending(e,t){const{hls:i,operationQueue:s,tracks:r}=this,{data:n,type:o,frag:l,part:d,chunkMeta:h}=t,c=h.buffering[o],u=self.performance.now();c.start=u;const f=l.stats.buffering,m=d?d.stats.buffering:null;f.start===0&&(f.start=u),m&&m.start===0&&(m.start=u);const g=r.audio;let p=!1;o==="audio"&&g?.container==="audio/mpeg"&&(p=!this.lastMpegAudioChunk||h.id===1||this.lastMpegAudioChunk.sn!==h.sn,this.lastMpegAudioChunk=h);const v=l.start,L={execute:()=>{if(c.executeStart=self.performance.now(),p){const y=this.sourceBuffer[o];if(y){const b=v-y.timestampOffset;Math.abs(b)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${v} (delta: ${b}) sn: ${l.sn})`),y.timestampOffset=v)}}this.appendExecutor(n,o)},onStart:()=>{},onComplete:()=>{const y=self.performance.now();c.executeEnd=c.end=y,f.first===0&&(f.first=y),m&&m.first===0&&(m.first=y);const{sourceBuffer:b}=this,T={};for(const I in b)T[I]=J.getBuffered(b[I]);this.appendErrors[o]=0,o==="audio"||o==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(x.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:h,parent:l.type,timeRanges:T})},onError:y=>{const b={type:K.MEDIA_ERROR,parent:l.type,details:R.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:d,chunkMeta:h,error:y,err:y,fatal:!1};if(y.code===DOMException.QUOTA_EXCEEDED_ERR)b.details=R.BUFFER_FULL_ERROR;else{const T=++this.appendErrors[o];b.details=R.BUFFER_APPEND_ERROR,this.warn(`Failed ${T}/${i.config.appendErrorMaxRetry} times to append segment in "${o}" sourceBuffer`),T>=i.config.appendErrorMaxRetry&&(b.fatal=!0)}i.trigger(x.ERROR,b)}};s.append(L,o,!!this.pendingTracks[o])}onBufferFlushing(e,t){const{operationQueue:i}=this,s=r=>({execute:this.removeExecutor.bind(this,r,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(x.BUFFER_FLUSHED,{type:r})},onError:n=>{this.warn(`Failed to remove from ${r} SourceBuffer`,n)}});t.type?i.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(r=>{i.append(s(r),r)})}onFragParsed(e,t){const{frag:i,part:s}=t,r=[],n=s?s.elementaryStreams:i.elementaryStreams;n[Q.AUDIOVIDEO]?r.push("audiovideo"):(n[Q.AUDIO]&&r.push("audio"),n[Q.VIDEO]&&r.push("video"));const o=()=>{const l=self.performance.now();i.stats.buffering.end=l,s&&(s.stats.buffering.end=l);const d=s?s.stats:i.stats;this.hls.trigger(x.FRAG_BUFFERED,{frag:i,part:s,stats:d,id:i.type})};r.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(o,r)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((s,r)=>{const n=this.sourceBuffer[r];return n&&(!t.type||t.type===r)&&(n.ending=!0,n.ended||(n.ended=!0,this.log(`${r} sourceBuffer now EOS`))),s&&!!(!n||n.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(r=>{const n=this.sourceBuffer[r];n&&(n.ending=!1)});const{mediaSource:s}=this;if(!s||s.readyState!=="open"){s&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${s.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),s.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){const{hls:e,details:t,media:i}=this;if(!i||t===null||!this.getSourceBufferTypes().length)return;const r=e.config,n=i.currentTime,o=t.levelTargetDuration,l=t.live&&r.liveBackBufferLength!==null?r.liveBackBufferLength:r.backBufferLength;if(k(l)&&l>0){const d=Math.max(l,o),h=Math.floor(n/o)*o-d;this.flushBackBuffer(n,o,h)}if(k(r.frontBufferFlushThreshold)&&r.frontBufferFlushThreshold>0){const d=Math.max(r.maxBufferLength,r.frontBufferFlushThreshold),h=Math.max(d,o),c=Math.floor(n/o)*o+h;this.flushFrontBuffer(n,o,c)}}flushBackBuffer(e,t,i){const{details:s,sourceBuffer:r}=this;this.getSourceBufferTypes().forEach(o=>{const l=r[o];if(l){const d=J.getBuffered(l);if(d.length>0&&i>d.start(0)){if(this.hls.trigger(x.BACK_BUFFER_REACHED,{bufferEnd:i}),s!=null&&s.live)this.hls.trigger(x.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(l.ended&&d.end(d.length-1)-e<t*2){this.log(`Cannot flush ${o} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:o})}}})}flushFrontBuffer(e,t,i){const{sourceBuffer:s}=this;this.getSourceBufferTypes().forEach(n=>{const o=s[n];if(o){const l=J.getBuffered(o),d=l.length;if(d<2)return;const h=l.start(d-1),c=l.end(d-1);if(i>h||e>=h&&e<=c)return;if(o.ended&&e-c<2*t){this.log(`Cannot flush ${n} front buffer while SourceBuffer is in ended state`);return}this.hls.trigger(x.BUFFER_FLUSHING,{startOffset:h,endOffset:1/0,type:n})}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:e,hls:t,media:i,mediaSource:s}=this,r=e.fragments[0].start+e.totalduration,n=i.duration,o=k(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(s.duration=1/0,this.updateSeekableRange(e)):(r>o&&r>n||!k(n))&&(this.log(`Updating Media Source duration to ${r.toFixed(3)}`),s.duration=r)}updateSeekableRange(e){const t=this.mediaSource,i=e.fragments;if(i.length&&e.live&&t!=null&&t.setLiveSeekableRange){const r=Math.max(0,i[0].start),n=Math.max(r,r+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${r}-${n}.`),t.setLiveSeekableRange(r,n)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:i}=this,s=Object.keys(i).length;if(s&&(!e||s===2||"audiovideo"in i)){this.createSourceBuffers(i),this.pendingTracks={};const r=this.getSourceBufferTypes();if(r.length)this.hls.trigger(x.BUFFER_CREATED,{tracks:this.tracks}),r.forEach(n=>{t.executeNext(n)});else{const n=new Error("could not create source buffer for media codec(s)");this.hls.trigger(x.ERROR,{type:K.MEDIA_ERROR,details:R.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:n,reason:n.message})}}}createSourceBuffers(e){const{sourceBuffer:t,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(const r in e)if(!t[r]){var s;const n=e[r];if(!n)throw Error(`source buffer exists for track ${r}, however track does not`);let o=((s=n.levelCodec)==null?void 0:s.indexOf(","))===-1?n.levelCodec:n.codec;o&&r.slice(0,5)==="audio"&&(o=Ve(o,this.appendSource));const l=`${n.container};codecs=${o}`;this.log(`creating sourceBuffer(${l})`);try{const d=t[r]=i.addSourceBuffer(l),h=r;this.addBufferListener(h,"updatestart",this._onSBUpdateStart),this.addBufferListener(h,"updateend",this._onSBUpdateEnd),this.addBufferListener(h,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(h,"bufferedchange",(c,u)=>{const f=u.removedRanges;f!=null&&f.length&&this.hls.trigger(x.BUFFER_FLUSHED,{type:r})}),this.tracks[r]={buffer:d,codec:o,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id}}catch(d){this.error(`error while trying to add sourceBuffer: ${d.message}`),this.hls.trigger(x.ERROR,{type:K.MEDIA_ERROR,details:R.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,sourceBufferName:r,mimeType:l})}}}get mediaSrc(){var e;const t=((e=this.media)==null?void 0:e.firstChild)||this.media;return t?.src}_onSBUpdateStart(e){const{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const{operationQueue:i}=this;i.current(e).onComplete(),i.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var i;const s=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(i=this.mediaSource)==null?void 0:i.readyState}`);this.error(`${s}`,t),this.hls.trigger(x.ERROR,{type:K.MEDIA_ERROR,details:R.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});const r=this.operationQueue.current(e);r&&r.onError(s)}removeExecutor(e,t,i){const{media:s,mediaSource:r,operationQueue:n,sourceBuffer:o}=this,l=o[e];if(!s||!r||!l){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),n.shiftAndExecuteNext(e);return}const d=k(s.duration)?s.duration:1/0,h=k(r.duration)?r.duration:1/0,c=Math.max(0,t),u=Math.min(i,d,h);u>c&&(!l.ending||l.ended)?(l.ended=!1,this.log(`Removing [${c},${u}] from the ${e} SourceBuffer`),l.remove(c,u)):n.shiftAndExecuteNext(e)}appendExecutor(e,t){const i=this.sourceBuffer[t];if(!i){if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);return}i.ended=!1,i.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}const{operationQueue:i}=this,s=t.map(r=>i.appendBlocker(r));Promise.all(s).then(()=>{e(),t.forEach(r=>{const n=this.sourceBuffer[r];n!=null&&n.updating||i.shiftAndExecuteNext(r)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,i){const s=this.sourceBuffer[e];if(!s)return;const r=i.bind(this,e);this.listeners[e].push({event:t,listener:r}),s.addEventListener(t,r)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(i=>{t.removeEventListener(i.event,i.listener)})}}function Ri(a){const e=a.querySelectorAll("source");[].slice.call(e).forEach(t=>{a.removeChild(t)})}function kr(a,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,a.appendChild(t)}class wt{constructor(e){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=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.BUFFER_CODECS,this.onBufferCodecs,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.BUFFER_CODECS,this.onBufferCodecs,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&k(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}const e=this.hls.levels;if(e.length){const t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&S.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const i=t.filter((s,r)=>this.isLevelAllowed(s)&&r<=e);return this.clientRect=null,wt.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,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 e=this.media,t={width:0,height:0};if(e){const i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return-1;const s=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0;let r=e.length-1;const n=Math.max(t,i);for(let o=0;o<e.length;o+=1){const l=e[o];if((l.width>=n||l.height>=n)&&s(l,e[o+1])){r=o;break}}return r}}class Mr{constructor(e){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=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const i=this.hls.config;if(i.capLevelOnFPSDrop){const s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,i){const s=performance.now();if(t){if(this.lastTime){const r=s-this.lastTime,n=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*n/r,d=this.hls;if(d.trigger(x.FPS_DROP,{currentDropped:n,currentDecoded:o,totalDroppedFrames:i}),l>0&&n>d.config.fpsDroppedMonitoringThreshold*o){let h=d.currentLevel;S.warn("drop FPS ratio greater than max allowed value for currentLevel: "+h),h>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=h)&&(h=h-1,d.trigger(x.FPS_DROP_LEVEL_CAPPING,{level:h,droppedLevel:d.currentLevel}),d.autoLevelCapping=h,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}const Nr=3e5;class Br{constructor(e){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=e,this.log=S.log.bind(S,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(i=>i!==e))}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(e,t){const{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:i}=t;if(i?.action===ie.SendAlternateToPenaltyBox&&i.flags===ce.MoveAllAlternatesMatchingHost){const s=this.levels;let r=this.pathwayPriority,n=this.pathwayId;if(t.context){const{groupId:o,pathwayId:l,type:d}=t.context;o&&s?n=this.getPathwayForGroupId(o,d,n):l&&(n=l)}n in this.penalizedPathways||(this.penalizedPathways[n]=performance.now()),!r&&s&&(r=s.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),r&&r.length>1&&(this.updatePathwayPriority(r),i.resolved=this.pathwayId!==n),i.resolved||S.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${n} levels: ${s&&s.length} priorities: ${JSON.stringify(r)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t;const i=this.penalizedPathways,s=performance.now();Object.keys(i).forEach(r=>{s-i[r]>Nr&&delete i[r]});for(let r=0;r<e.length;r++){const n=e[r];if(n in i)continue;if(n===this.pathwayId)return;const o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(n),t.length>0){this.log(`Setting Pathway to "${n}"`),this.pathwayId=n,vi(t),this.hls.trigger(x.LEVELS_UPDATED,{levels:t});const d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,i){const s=this.getLevelsForPathway(i).concat(this.levels||[]);for(let r=0;r<s.length;r++)if(t===j.AUDIO_TRACK&&s[r].hasAudioGroup(e)||t===j.SUBTITLE_TRACK&&s[r].hasSubtitleGroup(e))return s[r].pathwayId;return i}clonePathways(e){const t=this.levels;if(!t)return;const i={},s={};e.forEach(r=>{const{ID:n,"BASE-ID":o,"URI-REPLACEMENT":l}=r;if(t.some(h=>h.pathwayId===n))return;const d=this.getLevelsForPathway(o).map(h=>{const c=new Z(h.attrs);c["PATHWAY-ID"]=n;const u=c.AUDIO&&`${c.AUDIO}_clone_${n}`,f=c.SUBTITLES&&`${c.SUBTITLES}_clone_${n}`;u&&(i[c.AUDIO]=u,c.AUDIO=u),f&&(s[c.SUBTITLES]=f,c.SUBTITLES=f);const m=Ii(h.uri,c["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),g=new pt({attrs:c,audioCodec:h.audioCodec,bitrate:h.bitrate,height:h.height,name:h.name,url:m,videoCodec:h.videoCodec,width:h.width});if(h.audioGroups)for(let p=1;p<h.audioGroups.length;p++)g.addGroupId("audio",`${h.audioGroups[p]}_clone_${n}`);if(h.subtitleGroups)for(let p=1;p<h.subtitleGroups.length;p++)g.addGroupId("text",`${h.subtitleGroups[p]}_clone_${n}`);return g});t.push(...d),bi(this.audioTracks,i,l,n),bi(this.subtitleTracks,s,l,n)})}loadSteeringManifest(e){const t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){const h=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+h)}const r={responseType:"json",url:s.href},n=t.steeringManifestLoadPolicy.default,o=n.errorRetry||n.timeoutRetry||{},l={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(h,c,u,f)=>{this.log(`Loaded steering manifest: "${s}"`);const m=h.data;if(m.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;const{"RELOAD-URI":g,"PATHWAY-CLONES":p,"PATHWAY-PRIORITY":v}=m;if(g)try{this.uri=new self.URL(g,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${g}`);return}this.scheduleRefresh(this.uri||u.url),p&&this.clonePathways(p);const L={steeringManifest:m,url:s.toString()};this.hls.trigger(x.STEERING_MANIFEST_LOADED,L),v&&this.updatePathwayPriority(v)},onError:(h,c,u,f)=>{if(this.log(`Error loading steering manifest: ${h.code} ${h.text} (${c.url})`),this.stopLoad(),h.code===410){this.enabled=!1,this.log(`Steering manifest ${c.url} no longer available`);return}let m=this.timeToLoad*1e3;if(h.code===429){const g=this.loader;if(typeof g?.getResponseHeader=="function"){const p=g.getResponseHeader("Retry-After");p&&(m=parseFloat(p)*1e3)}this.log(`Steering manifest ${c.url} rate limited`);return}this.scheduleRefresh(this.uri||c.url,m)},onTimeout:(h,c,u)=>{this.log(`Timeout loading steering manifest (${c.url})`),this.scheduleRefresh(this.uri||c.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(r,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var i;const s=(i=this.hls)==null?void 0:i.media;if(s&&!s.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function bi(a,e,t,i){a&&Object.keys(e).forEach(s=>{const r=a.filter(n=>n.groupId===s).map(n=>{const o=ae({},n);return o.details=void 0,o.attrs=new Z(o.attrs),o.url=o.attrs.URI=Ii(n.url,n.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=i,o});a.push(...r)})}function Ii(a,e,t,i){const{HOST:s,PARAMS:r,[t]:n}=i;let o;e&&(o=n?.[e],o&&(a=o));const l=new self.URL(a);return s&&!o&&(l.host=s),r&&Object.keys(r).sort().forEach(d=>{d&&l.searchParams.set(d,r[d])}),l.href}const Ur=/^age:\s*[\d.]+\s*$/im;class Di{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new ke,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null,this.stats=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const i=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const r=this.xhrSetup;r?Promise.resolve().then(()=>{if(!this.stats.aborted)return r(i,t.url)}).catch(n=>(i.open("GET",t.url,!0),r(i,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(n=>{this.callbacks.onError({code:i.status,text:n.message},t,i,s)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);const s=t.headers,{maxTimeToFirstByteMs:r,maxLoadTimeMs:n}=i.loadPolicy;if(s)for(const o in s)e.setRequestHeader(o,s[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=r&&k(r)?r:n,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:i}=this;if(!e||!t)return;const s=t.readyState,r=this.config;if(!i.aborted&&s>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.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-(i.loading.first-i.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const n=t.status,o=t.responseType!=="text";if(n>=200&&n<300&&(o&&t.response||t.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const l=o?t.response:t.responseText,d=t.responseType==="arraybuffer"?l.byteLength:l.length;if(i.loaded=i.total=d,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;const h=this.callbacks.onProgress;if(h&&h(i,e,l,t),!this.callbacks)return;const c={url:t.responseURL,data:l,code:n};this.callbacks.onSuccess(c,i,e,t)}else{const l=r.loadPolicy.errorRetry,d=i.retry,h={url:e.url,data:void 0,code:n};je(l,d,!1,h)?this.retry(l):(S.error(`${n} while loading ${e.url}`),this.callbacks.onError({code:n,text:t.statusText},e,t,i))}}}loadtimeout(){var e;const t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,i=this.stats.retry;if(je(t,i,!0))this.retry(t);else{var s;S.warn(`timeout while loading ${(s=this.context)==null?void 0:s.url}`);const r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:i}=this;this.retryDelay=vt(e,i.retry),i.retry++,S.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t?.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&Ur.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}class $r{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let i;if(e.length)e.length===1?i=e[0]:i=Gr(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function Gr(a,e){const t=new Uint8Array(e);let i=0;for(let s=0;s<a.length;s++){const r=a[s];t.set(r,i),i+=r.length}return t}function Vr(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const Hr=/(\d+)-(\d+)\/(\d+)/;class Ci{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||jr,this.controller=new self.AbortController,this.stats=new ke}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,i){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();const r=Kr(e,this.controller.signal),n=i.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:h}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,r),self.clearTimeout(this.requestTimeout),t.timeout=d&&k(d)?d:h,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,e,this.response)},t.timeout),self.fetch(this.request).then(c=>{this.response=this.loader=c;const u=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=h,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,e,this.response)},h-(u-s.loading.start)),!c.ok){const{status:f,statusText:m}=c;throw new zr(m||"fetch, bad network response",f,c)}return s.loading.first=u,s.total=Yr(c.headers)||s.total,n&&k(t.highWaterMark)?this.loadProgressively(c,s,e,t.highWaterMark,n):o?c.arrayBuffer():e.responseType==="json"?c.json():c.text()}).then(c=>{const u=this.response;if(!u)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const f=c[l];f&&(s.loaded=s.total=f);const m={url:u.url,data:c,code:u.status};n&&!k(t.highWaterMark)&&n(s,e,c,u),i.onSuccess(m,s,e,u)}).catch(c=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;const u=c&&c.code||0,f=c?c.message:null;i.onError({code:u,text:f},e,c?c.details:null,s)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,s=0,r){const n=new $r,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return n.dataLength&&r(t,i,n.flush(),e),Promise.resolve(new ArrayBuffer(0));const h=d.value,c=h.length;return t.loaded+=c,c<s||n.dataLength?(n.push(h),n.dataLength>=s&&r(t,i,n.flush(),e)):r(t,i,h,e),l()}).catch(()=>Promise.reject());return l()}}function Kr(a,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(ae({},a.headers))};return a.rangeEnd&&t.headers.set("Range","bytes="+a.rangeStart+"-"+String(a.rangeEnd-1)),t}function Wr(a){const e=Hr.exec(a);if(e)return parseInt(e[2])-parseInt(e[1])+1}function Yr(a){const e=a.get("Content-Range");if(e){const i=Wr(e);if(k(i))return i}const t=a.get("Content-Length");if(t)return parseInt(t)}function jr(a,e){return new self.Request(a.url,e)}class zr extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const qr={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},_i=oe(oe({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,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:Di,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:wr,bufferController:Or,capLevelController:wt,errorController:Lr,fpsController:Mr,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!1,certLoadPolicy:{default:qr},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},Xr()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:Br});function Xr(){return{cueHandler:Ts,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Qr(a,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(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const t=yt(a),i=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(r=>{const n=`${r==="level"?"playlist":r}LoadPolicy`,o=e[n]===void 0,l=[];s.forEach(d=>{const h=`${r}Loading${d}`,c=e[h];if(c!==void 0&&o){l.push(h);const u=t[n].default;switch(e[n]={default:u},d){case"TimeOut":u.maxLoadTimeMs=c,u.maxTimeToFirstByteMs=c;break;case"MaxRetry":u.errorRetry.maxNumRetry=c,u.timeoutRetry.maxNumRetry=c;break;case"RetryDelay":u.errorRetry.retryDelayMs=c,u.timeoutRetry.retryDelayMs=c;break;case"MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=c,u.timeoutRetry.maxRetryDelayMs=c;break}}}),l.length&&S.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${n}": ${JSON.stringify(e[n])}`)}),oe(oe({},t),e)}function yt(a){return a&&typeof a=="object"?Array.isArray(a)?a.map(yt):Object.keys(a).reduce((e,t)=>(e[t]=yt(a[t]),e),{}):a}function Jr(a){const e=a.loader;e!==Ci&&e!==Di?(S.log("[config]: Custom loader detected, cannot enable progressive streaming"),a.progressive=!1):Vr()&&(a.loader=Ci,a.progressive=!0,a.enableSoftwareAES=!0,S.log("[config]: Progressive streaming enabled, using FetchLoader"))}let Et;class Zr extends Ar{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(x.LEVEL_LOADED,this.onLevelLoaded,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this),e.on(x.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(x.LEVEL_LOADED,this.onLevelLoaded,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this),e.off(x.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const i=this.hls.config.preferManagedMediaSource,s=[],r={},n={};let o=!1,l=!1,d=!1;t.levels.forEach(h=>{var c,u;const f=h.attrs;let{audioCodec:m,videoCodec:g}=h;((c=m)==null?void 0:c.indexOf("mp4a.40.34"))!==-1&&(Et||(Et=/chrome|firefox/i.test(navigator.userAgent)),Et&&(h.audioCodec=m=void 0)),m&&(h.audioCodec=m=Ve(m,i)),((u=g)==null?void 0:u.indexOf("avc1"))===0&&(g=h.videoCodec=qs(g));const{width:p,height:v,unknownCodecs:L}=h;if(o||(o=!!(p&&v)),l||(l=!!g),d||(d=!!m),L!=null&&L.length||m&&!dt(m,"audio",i)||g&&!dt(g,"video",i))return;const{CODECS:y,"FRAME-RATE":b,"HDCP-LEVEL":T,"PATHWAY-ID":I,RESOLUTION:A,"VIDEO-RANGE":D}=f,_=`${`${I||"."}-`}${h.bitrate}-${A}-${b}-${y}-${D}-${T}`;if(r[_])if(r[_].uri!==h.url&&!h.attrs["PATHWAY-ID"]){const C=n[_]+=1;h.attrs["PATHWAY-ID"]=new Array(C+1).join(".");const $=new pt(h);r[_]=$,s.push($)}else r[_].addGroupId("audio",f.AUDIO),r[_].addGroupId("text",f.SUBTITLES);else{const C=new pt(h);r[_]=C,n[_]=1,s.push(C)}}),this.filterAndSortMediaOptions(s,t,o,l,d)}filterAndSortMediaOptions(e,t,i,s,r){let n=[],o=[],l=e;if((i||s)&&r&&(l=l.filter(({videoCodec:m,videoRange:g,width:p,height:v})=>(!!m||!!(p&&v))&&cr(g))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);const m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(x.ERROR,{type:K.MEDIA_ERROR,details:R.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:m,reason:m.message})}});return}if(t.audioTracks){const{preferManagedMediaSource:m}=this.hls.config;n=t.audioTracks.filter(g=>!g.audioCodec||dt(g.audioCodec,"audio",m)),wi(n)}t.subtitles&&(o=t.subtitles,wi(o));const d=l.slice(0);l.sort((m,g)=>{if(m.attrs["HDCP-LEVEL"]!==g.attrs["HDCP-LEVEL"])return(m.attrs["HDCP-LEVEL"]||"")>(g.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&m.height!==g.height)return m.height-g.height;if(m.frameRate!==g.frameRate)return m.frameRate-g.frameRate;if(m.videoRange!==g.videoRange)return Ke.indexOf(m.videoRange)-Ke.indexOf(g.videoRange);if(m.videoCodec!==g.videoCodec){const p=Jt(m.videoCodec),v=Jt(g.videoCodec);if(p!==v)return v-p}if(m.uri===g.uri&&m.codecSet!==g.codecSet){const p=Ge(m.codecSet),v=Ge(g.codecSet);if(p!==v)return v-p}return m.averageBitrate!==g.averageBitrate?m.averageBitrate-g.averageBitrate:0});let h=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let m=0;m<d.length;m++)if(d[m].pathwayId===l[0].pathwayId){h=d[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===h){var c;this._firstLevel=m;const g=h.bitrate,p=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${g}`),((c=this.hls.userConfig)==null?void 0:c.abrEwmaDefaultEstimate)===void 0){const v=Math.min(g,this.hls.config.abrEwmaDefaultEstimateMax);v>p&&p===_i.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=v)}break}const u=r&&!s,f={levels:l,audioTracks:n,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:r,video:s,altAudio:!u&&n.some(m=>!!m.url)};this.hls.trigger(x.MANIFEST_PARSED,f),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const h=new Error("invalid level idx"),c=e<0;if(this.hls.trigger(x.ERROR,{type:K.OTHER_ERROR,details:R.LEVEL_SWITCH_ERROR,level:e,fatal:c,error:h,reason:h.message}),c)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,s=this.currentLevel,r=s?s.attrs["PATHWAY-ID"]:void 0,n=t[e],o=n.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=n,i===e&&n.details&&s&&r===o)return;this.log(`Switching to level ${e} (${n.height?n.height+"p ":""}${n.videoRange?n.videoRange+" ":""}${n.codecSet?n.codecSet+" ":""}@${n.bitrate})${o?" with Pathway "+o:""} from level ${i}${r?" with Pathway "+r:""}`);const l={level:e,attrs:n.attrs,details:n.details,bitrate:n.bitrate,averageBitrate:n.averageBitrate,maxBitrate:n.maxBitrate,realBitrate:n.realBitrate,width:n.width,height:n.height,codecSet:n.codecSet,audioCodec:n.audioCodec,videoCodec:n.videoCodec,audioGroups:n.audioGroups,subtitleGroups:n.subtitleGroups,loaded:n.loaded,loadError:n.loadError,fragmentError:n.fragmentError,name:n.name,id:n.id,uri:n.uri,url:n.url,urlId:0,audioGroupIds:n.audioGroupIds,textGroupIds:n.textGroupIds};this.hls.trigger(x.LEVEL_SWITCHING,l);const d=n.details;if(!d||d.live){const h=this.switchParams(n.uri,s?.details,d);this.loadPlaylist(h)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===j.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===z.MAIN){const i=t.elementaryStreams;if(!Object.keys(i).some(r=>!!i[r]))return;const s=this._levels[t.level];s!=null&&s.loadError&&(this.log(`Resetting level error count of ${s.loadError} on frag buffered`),s.loadError=0)}}onLevelLoaded(e,t){var i;const{level:s,details:r}=t,n=this._levels[s];if(!n){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(r.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(n.fragmentError===0&&(n.loadError=0),this.playlistLoaded(s,t,n.details)):(i=t.deliveryDirectives)!=null&&i.skip&&(r.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){let s=i.uri;if(e)try{s=e.addDirectives(s)}catch(n){this.warn(`Could not construct new URL with HLS Delivery Directives: ${n}`)}const r=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${e?.msn!==void 0?" at sn "+e.msn+" part "+e.part:""} with${r?" Pathway "+r:""} ${s}`),this.clearTimer(),this.hls.trigger(x.LEVEL_LOADING,{url:s,level:t,pathwayId:i.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;const i=this._levels.filter((s,r)=>r!==e?!0:(this.steering&&this.steering.removeLevel(s),s===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,s.details&&s.details.fragments.forEach(n=>n.level=-1)),!1));vi(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(x.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(x.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function wi(a){const e={};a.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}var ne={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class en{constructor(e){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=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(x.BUFFER_APPENDED,this.onBufferAppended,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this),e.on(x.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(x.BUFFER_APPENDED,this.onBufferAppended,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this),e.off(x.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const i=this.activePartLists[t];if(i)for(let s=i.length;s--;){const r=i[s];if(!r)break;const n=r.end;if(r.start<=e&&n!==null&&e<=n)return r}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:i}=this,s=Object.keys(i);for(let r=s.length;r--;){const n=i[s[r]];if(n?.body.type===t&&n.buffered){const o=n.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,i,s){this.timeRanges&&(this.timeRanges[e]=t);const r=s?.fragment.sn||-1;Object.keys(this.fragments).forEach(n=>{const o=this.fragments[n];if(!o||r>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===i&&this.removeFragment(o.body);return}const l=o.range[e];l&&l.time.some(d=>{const h=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return h&&this.removeFragment(o.body),h})})}detectPartialFragments(e){const t=this.timeRanges,{frag:i,part:s}=e;if(!t||i.sn==="initSegment")return;const r=De(i),n=this.fragments[r];if(!n||n.buffered&&i.gap)return;const o=!i.relurl;Object.keys(t).forEach(l=>{const d=i.elementaryStreams[l];if(!d)return;const h=t[l],c=o||d.partial===!0;n.range[l]=this.getBufferedTimes(i,s,c,h)}),n.loaded=null,Object.keys(n.range).length?(n.buffered=!0,(n.body.endList=i.endList||n.body.endList)&&(this.endListFragments[n.body.type]=n),ze(n)||this.removeParts(i.sn-1,i.type)):this.removeFragment(n.body)}removeParts(e,t){const i=this.activePartLists[t];i&&(this.activePartLists[t]=i.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){const i=De(e);let s=this.fragments[i];!s&&t&&(s=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,i,s){const r={time:[],partial:i},n=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||n;for(let h=0;h<s.length;h++){const c=s.start(h)-this.bufferPadding,u=s.end(h)+this.bufferPadding;if(d>=c&&l<=u){r.time.push({startPTS:Math.max(n,s.start(h)),endPTS:Math.min(o,s.end(h))});break}else if(n<u&&o>c){const f=Math.max(n,s.start(h)),m=Math.min(o,s.end(h));m>f&&(r.partial=!0,r.time.push({startPTS:f,endPTS:m}))}else if(o<=c)break}return r}getPartialFragment(e){let t=null,i,s,r,n=0;const{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{const h=l[d];h&&ze(h)&&(s=h.body.start-o,r=h.body.end+o,e>=s&&e<=r&&(i=Math.min(e-s,r-e),n<=i&&(t=h.body,n=i)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||ze(t))}getState(e){const t=De(e),i=this.fragments[t];return i?i.buffered?ze(i)?ne.PARTIAL:ne.OK:ne.APPENDING:ne.NOT_LOADED}isTimeBuffered(e,t,i){let s,r;for(let n=0;n<i.length;n++){if(s=i.start(n)-this.bufferPadding,r=i.end(n)+this.bufferPadding,e>=s&&t<=r)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){const{frag:i,part:s}=t;if(i.sn==="initSegment"||i.bitrateTest)return;const r=s?null:t,n=De(i);this.fragments[n]={body:i,appendedPTS:null,loaded:r,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:i,part:s,timeRanges:r}=t;if(i.sn==="initSegment")return;const n=i.type;if(s){let o=this.activePartLists[n];o||(this.activePartLists[n]=o=[]),o.push(s)}this.timeRanges=r,Object.keys(r).forEach(o=>{const l=r[o];this.detectEvictedFragments(o,l,n,s)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=De(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,s,r){s&&!this.hasGaps||Object.keys(this.fragments).forEach(n=>{const o=this.fragments[n];if(!o)return;const l=o.body;l.type!==i||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||r)&&this.removeFragment(l)})}removeFragment(e){const t=De(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const s=e.sn;this.activePartLists[e.type]=i.filter(r=>r.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function ze(a){var e,t,i;return a.buffered&&(a.body.gap||((e=a.range.video)==null?void 0:e.partial)||((t=a.range.audio)==null?void 0:t.partial)||((i=a.range.audiovideo)==null?void 0:i.partial))}function De(a){return`${a.type}_${a.level}_${a.sn}`}const Pi=Math.pow(2,17);class tn{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const i=e.url;if(!i)return Promise.reject(new xe({type:K.NETWORK_ERROR,details:R.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const s=this.config,r=s.fLoader,n=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(Oi(e));return}else e.gap=!1;const d=this.loader=e.loader=r?new r(s):new n(s),h=Fi(e),c=Ei(s.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Pi};e.stats=d.stats,d.load(h,u,{onSuccess:(f,m,g,p)=>{this.resetLoader(e,d);let v=f.data;g.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(v.slice(0,16)),v=v.slice(16)),o({frag:e,part:null,payload:v,networkDetails:p})},onError:(f,m,g,p)=>{this.resetLoader(e,d),l(new xe({type:K.NETWORK_ERROR,details:R.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:oe({url:i,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:g,stats:p}))},onAbort:(f,m,g)=>{this.resetLoader(e,d),l(new xe({type:K.NETWORK_ERROR,details:R.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:g,stats:f}))},onTimeout:(f,m,g)=>{this.resetLoader(e,d),l(new xe({type:K.NETWORK_ERROR,details:R.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:g,stats:f}))},onProgress:(f,m,g,p)=>{t&&t({frag:e,part:null,payload:g,networkDetails:p})}})})}loadPart(e,t,i){this.abort();const s=this.config,r=s.fLoader,n=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(Oi(e,t));return}const d=this.loader=e.loader=r?new r(s):new n(s),h=Fi(e,t),c=Ei(s.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Pi};t.stats=d.stats,d.load(h,u,{onSuccess:(f,m,g,p)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);const v={frag:e,part:t,payload:f.data,networkDetails:p};i(v),o(v)},onError:(f,m,g,p)=>{this.resetLoader(e,d),l(new xe({type:K.NETWORK_ERROR,details:R.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:oe({url:h.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:g,stats:p}))},onAbort:(f,m,g)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new xe({type:K.NETWORK_ERROR,details:R.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:g,stats:f}))},onTimeout:(f,m,g)=>{this.resetLoader(e,d),l(new xe({type:K.NETWORK_ERROR,details:R.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:g,stats:f}))}})})}updateStatsFromPart(e,t){const i=e.stats,s=t.stats,r=s.total;if(i.loaded+=s.loaded,r){const l=Math.round(e.duration/t.duration),d=Math.min(Math.round(i.loaded/r),l),c=(l-d)*Math.round(i.loaded/d);i.total=i.loaded+c}else i.total=Math.max(i.loaded,i.total);const n=i.loading,o=s.loading;n.start?n.first+=o.first-o.start:(n.start=o.start,n.first=o.first),n.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function Fi(a,e=null){const t=e||a,i={frag:a,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,r=t.byteRangeEndOffset;if(k(s)&&k(r)){var n;let o=s,l=r;if(a.sn==="initSegment"&&((n=a.decryptdata)==null?void 0:n.method)==="AES-128"){const d=r-s;d%16&&(l=r+(16-d%16)),s!==0&&(i.resetIV=!0,o=s-16)}i.rangeStart=o,i.rangeEnd=l}return i}function Oi(a,e){const t=new Error(`GAP ${a.gap?"tag":"attribute"} found`),i={type:K.MEDIA_ERROR,details:R.FRAG_GAP,fatal:!1,frag:a,error:t,networkDetails:null};return e&&(i.part=e),(e||a).stats.aborted=!0,new xe(i)}class xe extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class sn{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const i in this.keyUriToKeyInfo){const s=this.keyUriToKeyInfo[i].loader;if(s){var t;if(e&&e!==((t=s.context)==null?void 0:t.frag.type))return;s.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=R.KEY_LOAD_ERROR,i,s,r){return new xe({type:K.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:r,error:i,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:s}=e;for(let r=0;r<t.length;r++){const n=t[r];if(s<=n.cc&&(i==="initSegment"||n.sn==="initSegment"||i<n.sn)){this.emeController.selectKeySystemFormat(n).then(o=>{n.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,s;t&&e.setKeyFormat(t);const r=e.decryptdata;if(!r){const d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,R.KEY_LOAD_ERROR,d))}const n=r.uri;if(!n)return Promise.reject(this.createKeyLoadError(e,R.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${n}"`)));let o=this.keyUriToKeyInfo[n];if((i=o)!=null&&i.decryptdata.key)return r.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((s=o)!=null&&s.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(d=>(r.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=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 r.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,R.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e,t){const i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const s=this.emeController.loadKey(i);if(s)return(e.keyLoadPromise=s.then(r=>(e.mediaKeySessionContext=r,i))).catch(r=>{throw e.keyLoadPromise=null,r})}return Promise.resolve(i)}loadKeyHTTP(e,t){const i=this.config,s=i.loader,r=new s(i);return t.keyLoader=e.loader=r,e.keyLoadPromise=new Promise((n,o)=>{const l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=i.keyLoadPolicy.default,h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(u,f,m,g)=>{const{frag:p,keyInfo:v,url:L}=m;if(!p.decryptdata||v!==this.keyUriToKeyInfo[L])return o(this.createKeyLoadError(p,R.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),g));v.decryptdata.key=p.decryptdata.key=new Uint8Array(u.data),p.keyLoader=null,v.loader=null,n({frag:p,keyInfo:v})},onError:(u,f,m,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,R.KEY_LOAD_ERROR,new Error(`HTTP Error ${u.code} loading key ${u.text}`),m,oe({url:l.url,data:void 0},u)))},onTimeout:(u,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,R.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(u,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,R.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};r.load(l,h,c)})}resetLoader(e){const{frag:t,keyInfo:i,url:s}=e,r=i.loader;t.keyLoader===r&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[s],r&&r.destroy()}}class rn{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(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class ki{constructor(e,t,i,s=0,r=-1,n=!1){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=qe(),this.buffering={audio:qe(),video:qe(),audiovideo:qe()},this.level=e,this.sn=t,this.id=i,this.size=s,this.part=r,this.partial=n}}function qe(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Xe(a,e){for(let i=0,s=a.length;i<s;i++){var t;if(((t=a[i])==null?void 0:t.cc)===e)return a[i]}return null}function nn(a,e,t){return!!(e&&(t.endCC>t.startCC||a&&a.cc<t.startCC))}function an(a,e){const t=a.fragments,i=e.fragments;if(!i.length||!t.length){S.log("No fragments to align");return}const s=Xe(t,i[0].cc);if(!s||s&&!s.startPTS){S.log("No frag in previous level to align on");return}return s}function Mi(a,e){if(a){const t=a.start+e;a.start=a.startPTS=t,a.endPTS=t+a.duration}}function Ni(a,e){const t=e.fragments;for(let i=0,s=t.length;i<s;i++)Mi(t[i],a);e.fragmentHint&&Mi(e.fragmentHint,a),e.alignedSliding=!0}function on(a,e,t){e&&(ln(a,t,e),!t.alignedSliding&&e&&dn(t,e),!t.alignedSliding&&e&&!t.skippedSegments&&gi(e,t))}function ln(a,e,t){if(nn(a,t,e)){const i=an(t,e);i&&k(i.start)&&(S.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),Ni(i.start,e))}}function dn(a,e){if(!a.hasProgramDateTime||!e.hasProgramDateTime)return;const t=a.fragments,i=e.fragments;if(!t.length||!i.length)return;let s,r;const n=Math.min(e.endCC,a.endCC);e.startCC<n&&a.startCC<n&&(s=Xe(i,n),r=Xe(t,n)),(!s||!r)&&(s=i[Math.floor(i.length/2)],r=Xe(t,s.cc)||t[Math.floor(t.length/2)]);const o=s.programDateTime,l=r.programDateTime;if(!o||!l)return;const d=(l-o)/1e3-(r.start-s.start);Ni(d,a)}class hn{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class cn{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function un(a){const e=a.byteLength,t=e&&new DataView(a.buffer).getUint8(e-1);return t?Ae(a,0,e-t):a}class fn{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_(e){const t=new DataView(e),i=new Uint32Array(4);for(let s=0;s<4;s++)i[s]=t.getUint32(s*4);return i}initTable(){const e=this.sBox,t=this.invSBox,i=this.subMix,s=i[0],r=i[1],n=i[2],o=i[3],l=this.invSubMix,d=l[0],h=l[1],c=l[2],u=l[3],f=new Uint32Array(256);let m=0,g=0,p=0;for(p=0;p<256;p++)p<128?f[p]=p<<1:f[p]=p<<1^283;for(p=0;p<256;p++){let v=g^g<<1^g<<2^g<<3^g<<4;v=v>>>8^v&255^99,e[m]=v,t[v]=m;const L=f[m],y=f[L],b=f[y];let T=f[v]*257^v*16843008;s[m]=T<<24|T>>>8,r[m]=T<<16|T>>>16,n[m]=T<<8|T>>>24,o[m]=T,T=b*16843009^y*65537^L*257^m*16843008,d[v]=T<<24|T>>>8,h[v]=T<<16|T>>>16,c[v]=T<<8|T>>>24,u[v]=T,m?(m=L^f[f[f[b^L]]],g^=f[f[g]]):m=g=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let i=!0,s=0;for(;s<t.length&&i;)i=t[s]===this.key[s],s++;if(i)return;this.key=t;const r=this.keySize=t.length;if(r!==4&&r!==6&&r!==8)throw new Error("Invalid aes key size="+r);const n=this.ksRows=(r+6+1)*4;let o,l;const d=this.keySchedule=new Uint32Array(n),h=this.invKeySchedule=new Uint32Array(n),c=this.sBox,u=this.rcon,f=this.invSubMix,m=f[0],g=f[1],p=f[2],v=f[3];let L,y;for(o=0;o<n;o++){if(o<r){L=d[o]=t[o];continue}y=L,o%r===0?(y=y<<8|y>>>24,y=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[y&255],y^=u[o/r|0]<<24):r>6&&o%r===4&&(y=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[y&255]),d[o]=L=(d[o-r]^y)>>>0}for(l=0;l<n;l++)o=n-l,l&3?y=d[o]:y=d[o-4],l<4||o<=4?h[l]=y:h[l]=m[c[y>>>24]]^g[c[y>>>16&255]]^p[c[y>>>8&255]]^v[c[y&255]],h[l]=h[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){const s=this.keySize+6,r=this.invKeySchedule,n=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],h=o[2],c=o[3],u=this.uint8ArrayToUint32Array_(i);let f=u[0],m=u[1],g=u[2],p=u[3];const v=new Int32Array(e),L=new Int32Array(v.length);let y,b,T,I,A,D,P,_,C,$,M,U,B,V;const W=this.networkToHostOrderSwap;for(;t<v.length;){for(C=W(v[t]),$=W(v[t+1]),M=W(v[t+2]),U=W(v[t+3]),A=C^r[0],D=U^r[1],P=M^r[2],_=$^r[3],B=4,V=1;V<s;V++)y=l[A>>>24]^d[D>>16&255]^h[P>>8&255]^c[_&255]^r[B],b=l[D>>>24]^d[P>>16&255]^h[_>>8&255]^c[A&255]^r[B+1],T=l[P>>>24]^d[_>>16&255]^h[A>>8&255]^c[D&255]^r[B+2],I=l[_>>>24]^d[A>>16&255]^h[D>>8&255]^c[P&255]^r[B+3],A=y,D=b,P=T,_=I,B=B+4;y=n[A>>>24]<<24^n[D>>16&255]<<16^n[P>>8&255]<<8^n[_&255]^r[B],b=n[D>>>24]<<24^n[P>>16&255]<<16^n[_>>8&255]<<8^n[A&255]^r[B+1],T=n[P>>>24]<<24^n[_>>16&255]<<16^n[A>>8&255]<<8^n[D&255]^r[B+2],I=n[_>>>24]<<24^n[A>>16&255]<<16^n[D>>8&255]<<8^n[P&255]^r[B+3],L[t]=W(y^f),L[t+1]=W(I^m),L[t+2]=W(T^g),L[t+3]=W(b^p),f=C,m=$,g=M,p=U,t=t+4}return L.buffer}}const mn=16;class Tt{constructor(e,{removePKCS7Padding:t=!0}={}){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=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch{}this.subtle===null&&(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:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?un(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i){return this.useSoftware?new Promise((s,r)=>{this.softwareDecrypt(new Uint8Array(e),t,i);const n=this.flush();n?s(n.buffer):r(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i)}softwareDecrypt(e,t,i){const{currentIV:s,currentResult:r,remainderData:n}=this;this.logOnce("JS AES decrypt"),n&&(e=de(n,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;s&&(i=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new fn),l.expandKey(t);const d=r;return this.currentResult=l.decrypt(o.buffer,0,i),this.currentIV=Ae(o,-16).buffer,d||null}webCryptoDecrypt(e,t,i){const s=this.subtle;return(this.key!==t||!this.fastAesKey)&&(this.key=t,this.fastAesKey=new cn(s,t)),this.fastAesKey.expandKey().then(r=>s?(this.logOnce("WebCrypto AES decrypt"),new hn(s,new Uint8Array(i)).decrypt(e.buffer,r)):Promise.reject(new Error("web crypto not initialized"))).catch(r=>(S.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${r.name}: ${r.message}`),this.onWebCryptoError(e,t,i)))}onWebCryptoError(e,t,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i);const s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;const i=e.length-e.length%mn;return i!==e.length&&(t=Ae(e,0,i),this.remainderData=Ae(e,i)),t}logOnce(e){this.logEnabled&&(S.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const gn={toString:function(a){let e="";const t=a.length;for(let i=0;i<t;i++)e+=`[${a.start(i).toFixed(3)}-${a.end(i).toFixed(3)}]`;return e}},w={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class pn extends rn{constructor(e,t,i,s,r){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=w.STOPPED,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=s,this.log=S.log.bind(S,`${s}:`),this.warn=S.warn.bind(S,`${s}:`),this.hls=e,this.fragmentLoader=new tn(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Tt(e.config),e.on(x.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=w.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;const i=t.partList;if(i!=null&&i.length){const r=i[i.length-1];return J.isBuffered(this.media,r.start+r.duration/2)}const s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}}onMediaAttached(e,t){const i=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);const s=this.config;this.levels&&s.autoStartLoad&&this.state===w.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){const e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.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:e,fragCurrent:t,media:i,mediaBuffer:s,state:r}=this,n=i?i.currentTime:0,o=J.bufferInfo(s||i,n,e.maxBufferHole);if(this.log(`media seeking to ${k(n)?n.toFixed(3):n}, state: ${r}`),this.state===w.ENDED)this.resetLoadingState();else if(t){const l=e.maxFragLookUpTolerance,d=t.start-l,h=t.start+t.duration+l;if(!o.len||h<o.start||d>o.end){const c=n>h;(n<d||c)&&(c&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(n,1/0,this.playlistType,!0),this.lastCurrentTime=n),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=n),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=w.STOPPED,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(e,t,i){this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){const s=r=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${r.part?" p: "+r.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(r)};this._doFragLoad(e,t,i,s).then(r=>{if(!r)return;const n=this.state;if(this.fragContextChanged(e)){(n===w.FRAG_LOADING||!this.fragCurrent&&n===w.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=w.IDLE);return}"payload"in r&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(x.FRAG_LOADED,r)),this._handleFragmentLoadComplete(r)}).catch(r=>{this.state===w.STOPPED||this.state===w.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:i}=this;if(i.getState(e)===ne.APPENDING){const r=e.type,n=this.getFwdBufferInfo(this.mediaBuffer,r),o=Math.max(e.duration,n?n.len:this.config.maxBufferLength);this.reduceMaxBufferLength(o)&&i.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===ne.PARTIAL&&i.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,i=null){if(!(e-t))return;const s={startOffset:e,endOffset:t,type:i};this.hls.trigger(x.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{if(!i||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:s}=this,{payload:r}=i,n=e.decryptdata;if(r&&r.byteLength>0&&n!=null&&n.key&&n.iv&&n.method==="AES-128"){const o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(r),n.key.buffer,n.iv.buffer).catch(l=>{throw s.trigger(x.ERROR,{type:K.MEDIA_ERROR,details:R.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{const d=self.performance.now();return s.trigger(x.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),i.payload=l,this.completeInitSegmentLoad(i)})}return this.completeInitSegmentLoad(i)}).catch(i=>{this.state===w.STOPPED||this.state===w.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const i=e.frag.stats;this.state=w.IDLE,e.frag.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var i,s,r,n;const o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===z.MAIN?"level":"track"} ${e.level} (frag:[${((i=e.startPTS)!=null?i:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?gn.toString(J.getBuffered(o)):"(detached)"})`),e.sn!=="initSegment"){var l;if(e.type!==z.SUBTITLE){const h=e.elementaryStreams;if(!Object.keys(h).some(c=>!!h[c])){this.state=w.IDLE;return}}const d=(l=this.levels)==null?void 0:l[e.level];d!=null&&d.fragmentError&&(this.log(`Resetting level fragment error count of ${d.fragmentError} on frag buffered`),d.fragmentError=0)}this.state=w.IDLE,o&&(!this.loadedmetadata&&e.type==z.MAIN&&o.buffered.length&&((r=this.fragCurrent)==null?void 0:r.sn)===((n=this.fragPrevious)==null?void 0:n.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:i,part:s,partsLoaded:r}=e,n=!r||r.length===0||r.some(l=>!l),o=new ki(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!n);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,s){var r;const n=t?.details;if(!this.levels||!n)throw new Error(`frag load aborted, missing level${n?"":" detail"}s`);let o=null;if(e.encrypted&&!((r=e.decryptdata)!=null&&r.key)?(this.log(`Loading key for ${e.sn} of [${n.startSN}-${n.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=w.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(h=>{if(!this.fragContextChanged(h.frag))return this.hls.trigger(x.KEY_LOADED,h),this.state===w.KEY_LOADING&&(this.state=w.IDLE),h}),this.hls.trigger(x.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&n.encryptedFragments.length&&this.keyLoader.loadClear(e,n.encryptedFragments),i=Math.max(e.start,i||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){const h=n.partList;if(h&&s){i>e.end&&n.fragmentHint&&(e=n.fragmentHint);const c=this.getNextPart(h,e,i);if(c>-1){const u=h[c];this.log(`Loading part sn: ${e.sn} p: ${u.index} cc: ${e.cc} of playlist [${n.startSN}-${n.endSN}] parts [0-${c}-${h.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=u.start+u.duration,this.state=w.FRAG_LOADING;let f;return o?f=o.then(m=>!m||this.fragContextChanged(m.frag)?null:this.doFragPartsLoad(e,u,t,s)).catch(m=>this.handleFragLoadError(m)):f=this.doFragPartsLoad(e,u,t,s).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(x.FRAG_LOADING,{frag:e,part:u,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(h,i))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${n?"of ["+n.startSN+"-"+n.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),k(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=w.FRAG_LOADING;const l=this.config.progressive;let d;return l&&o?d=o.then(h=>!h||this.fragContextChanged(h?.frag)?null:this.fragmentLoader.load(e,s)).catch(h=>this.handleFragLoadError(h)):d=Promise.all([this.fragmentLoader.load(e,l?s:void 0),o]).then(([h])=>(!l&&h&&s&&s(h),h)).catch(h=>this.handleFragLoadError(h)),this.hls.trigger(x.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,i,s){return new Promise((r,n)=>{var o;const l=[],d=(o=i.details)==null?void 0:o.partList,h=c=>{this.fragmentLoader.loadPart(e,c,s).then(u=>{l[c.index]=u;const f=u.part;this.hls.trigger(x.FRAG_LOADED,u);const m=pi(i,e.sn,c.index+1)||xi(d,e.sn,c.index+1);if(m)h(m);else return r({frag:e,part:f,partsLoaded:l})}).catch(n)};h(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===R.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(x.ERROR,t)}else this.hls.trigger(x.ERROR,{type:K.OTHER_ERROR,details:R.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==w.PARSING){!this.fragCurrent&&this.state!==w.STOPPED&&this.state!==w.ERROR&&(this.state=w.IDLE);return}const{frag:i,part:s,level:r}=t,n=self.performance.now();i.stats.parsing.end=n,s&&(s.stats.parsing.end=n),this.updateLevelTiming(i,s,r,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:i}=this,{level:s,sn:r,part:n}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${r} of level ${s}. The current chunk will not be buffered.`),null;const o=t[s],l=n>-1?pi(o,r,n):null,d=l?l.fragment:vr(o,r,i);return d?(i&&i!==d&&(d.stats=i.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,i,s,r){var n;if(!e||this.state!==w.PARSING)return;const{data1:o,data2:l}=e;let d=o;if(o&&l&&(d=de(o,l)),!((n=d)!=null&&n.length))return;const h={type:e.type,frag:t,part:i,chunkMeta:s,parent:t.type,data:d};if(this.hls.trigger(x.BUFFER_APPENDING,h),e.dropped&&e.independent&&!i){if(r)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!J.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const i=t.currentTime,s=J.bufferInfo(t,i,0),r=e.duration,n=Math.min(this.config.maxFragLookUpTolerance*2,r*.25),o=Math.max(Math.min(e.start-n,s.end-n),i+n);e.start-o>n&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){const i=this.getLoadPosition();return k(i)?this.getFwdBufferInfoAtPos(e,i,t):null}getFwdBufferInfoAtPos(e,t,i){const{config:{maxBufferHole:s}}=this,r=J.bufferInfo(e,t,s);if(r.len===0&&r.nextStart!==void 0){const n=this.fragmentTracker.getBufferedFrag(t,i);if(n&&r.nextStart<n.end)return J.bufferInfo(e,t,Math.max(r.nextStart,s))}return r}getMaxBufferLength(e){const{config:t}=this;let i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e){const t=this.config,i=e||t.maxBufferLength;return t.maxMaxBufferLength>=i?(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,t=z.MAIN){const i=this.fragmentTracker.getAppendedFrag(e,z.MAIN);return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){const i=t.fragments,s=i.length;if(!s)return null;const{config:r}=this,n=i[0].start;let o;if(t.live){const l=r.initialLiveManifestSize;if(s<l)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${l})`),null;(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<n)&&(o=this.getInitialLiveFragment(t,i),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=n&&(o=i[0]);if(!o){const l=r.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){const i=this.fragmentTracker.getState(e);return(i===ne.OK||i===ne.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,s,r){const n=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,n&&e&&!e.gap&&i.nextStart){const l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s);if(l!==null&&i.len+l.len>=r)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,i){let s=-1,r=!1,n=!0;for(let o=0,l=e.length;o<l;o++){const d=e[o];if(n=n&&!d.independent,s>-1&&i<d.start)break;const h=d.loaded;h?s=-1:(r||d.independent||n)&&d.fragment===t&&(s=o),r=h}return s}loadedEndOfParts(e,t){const i=e[e.length-1];return i&&t>i.start&&i.loaded}getInitialLiveFragment(e,t){const i=this.fragPrevious;let s=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),s=Er(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){const r=i.sn+1;if(r>=e.startSN&&r<=e.endSN){const n=t[r-e.startSN];i.cc===n.cc&&(s=n,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=Sr(t,i.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const r=this.hls.liveSyncPosition;r!==null&&(s=this.getFragmentAtPosition(r,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,i){const{config:s}=this;let{fragPrevious:r}=this,{fragments:n,endSN:o}=i;const{fragmentHint:l}=i,d=s.maxFragLookUpTolerance,h=i.partList,c=!!(s.lowLatencyMode&&h!=null&&h.length&&l);c&&l&&!this.bitrateTest&&(n=n.concat(l),o=l.sn);let u;if(e<t){const f=e>t-d?0:d;u=Si(r,n,e,f)}else u=n[n.length-1];if(u){const f=u.sn-i.startSN,m=this.fragmentTracker.getState(u);if((m===ne.OK||m===ne.PARTIAL&&u.gap)&&(r=u),r&&u.sn===r.sn&&(!c||h[0].fragment.sn>u.sn)&&r&&u.level===r.level){const p=n[f+1];u.sn<o&&this.fragmentTracker.getState(p)!==ne.OK?u=p:u=null}}return u}synchronizeToLiveEdge(e){const{config:t,media:i}=this;if(!i)return;const s=this.hls.liveSyncPosition,r=i.currentTime,n=e.fragments[0].start,o=e.edge,l=r>=n-t.maxFragLookUpTolerance&&r<=o;if(s!==null&&i.duration>s&&(r<s||!l)){const d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&i.readyState<4||r<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=s),i.readyState&&(this.warn(`Playback: ${r.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),i.currentTime=s))}}alignPlaylists(e,t,i){const s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;const r=e.fragments[0].start,n=!t,o=e.alignedSliding&&k(r);if(n||!o&&!r){const{fragPrevious:l}=this;on(l,i,e);const d=e.fragments[0].start;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${l?l.sn:"na"} fragments: ${s}`),d}return r}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let i=this.startPosition;if(i<t&&(i=-1),i===-1||this.lastCurrentTime===-1){const s=this.startTimeOffset!==null,r=s?this.startTimeOffset:e.startTimeOffset;r!==null&&k(r)?(i=t+r,r<0&&(i+=e.totalduration),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Start time offset ${r} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):e.live?i=this.hls.liveSyncPosition||t:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}getLoadPosition(){const{media:e}=this;let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==w.FRAG_LOADING_WAITING_RETRY)&&(this.state=w.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const h=this.getCurrentContext(t.chunkMeta);h&&(t.frag=h.frag)}const i=t.frag;if(!i||i.type!==e||!this.levels)return;if(this.fragContextChanged(i)){var s;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}const r=t.details===R.FRAG_GAP;r&&this.fragmentTracker.fragBuffered(i,!0);const n=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=n||{};if(n&&o===ie.RetryRequest&&d){this.resetStartWhenNotLoaded(this.levelLastLoaded);const h=vt(d,l);this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${h}ms`),n.resolved=!0,this.retryDate=self.performance.now()+h,this.state=w.FRAG_LOADING_WAITING_RETRY}else if(d&&n)if(this.resetFragmentErrors(e),l<d.maxNumRetry)!r&&o!==ie.RemoveAlternatePermanently&&(n.resolved=!0);else{S.warn(`${t.details} reached or exceeded max retry (${l})`);return}else n?.action===ie.SendAlternateToPenaltyBox?this.state=w.WAITING_LEVEL:this.state=w.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===w.PARSING||this.state===w.PARSED){const t=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,t),s=i&&i.len>.5;s&&this.reduceMaxBufferLength(i.len);const r=!s;return r&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),r}return!1}resetFragmentErrors(e){e===z.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==w.STOPPED&&(this.state=w.IDLE)}afterBufferFlushed(e,t,i){if(!e)return;const s=J.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,i),this.state===w.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=w.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=e?e.details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,s){var r;const n=i.details;if(!n){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((l,d)=>{const h=e.elementaryStreams[d];if(h){const c=h.endPTS-h.startPTS;if(c<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${c})`),l||!1;const u=s?0:mi(n,e,h.startPTS,h.endPTS,h.startDTS,h.endDTS);return this.hls.trigger(x.LEVEL_PTS_UPDATED,{details:n,level:i,drift:u,type:d,frag:e,start:h.startPTS,end:h.endPTS}),!0}return l},!1)&&((r=this.transmuxer)==null?void 0:r.error)===null){const l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(i.fragmentError===0&&(i.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(x.ERROR,{type:K.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=w.PARSED,this.hls.trigger(x.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function Bi(){return self.SourceBuffer||self.WebKitSourceBuffer}function Ui(){if(!Re())return!1;const e=Bi();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function xn(){if(!Ui())return!1;const a=Re();return typeof a?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>a.isTypeSupported(ht(e,"video")))||["mp4a.40.2","fLaC"].some(e=>a.isTypeSupported(ht(e,"audio"))))}function vn(){var a;const e=Bi();return typeof(e==null||(a=e.prototype)==null?void 0:a.changeType)=="function"}function yn(){return typeof __HLS_WORKER_BUNDLE__=="function"}function En(){const a=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(a);return{worker:new self.Worker(e),objectURL:e}}function Tn(a){const e=new self.URL(a,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function me(a="",e=9e4){return{type:a,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class $i{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(e,t,i,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){this.cachedData&&(e=de(this.cachedData,e),this.cachedData=null);let i=Me(e,0),s=i?i.length:0,r;const n=this._audioTrack,o=this._id3Track,l=i?Ut(i):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&k(l))&&(this.basePTS=Sn(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:he.audioId3,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(e,s)){const h=this.appendFrame(n,e,s);h?(this.frameIndex++,this.lastPTS=h.sample.pts,s+=h.length,r=s):s=d}else Ss(e,s)?(i=Me(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:he.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,r=s):s++;if(s===d&&r!==d){const h=Ae(e,r);this.cachedData?this.cachedData=de(this.cachedData,h):this.cachedData=h}}return{audioTrack:n,videoTrack:me(),id3Track:o,textTrack:me()}}demuxSampleAes(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:me(),id3Track:this._id3Track,textTrack:me()}}destroy(){}}const Sn=(a,e,t)=>{if(k(a))return a*90;const i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};function Ln(a,e,t,i){let s,r,n,o;const l=navigator.userAgent.toLowerCase(),d=i,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((e[t+2]&192)>>>6)+1;const c=(e[t+2]&60)>>>2;if(c>h.length-1){const u=new Error(`invalid ADTS sampling index:${c}`);a.emit(x.ERROR,x.ERROR,{type:K.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:!0,error:u,reason:u.message});return}return n=(e[t+2]&1)<<2,n|=(e[t+3]&192)>>>6,S.log(`manifest codec:${i}, ADTS type:${s}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(s=5,o=new Array(4),r=c-3):(s=2,o=new Array(2),r=c):l.indexOf("android")!==-1?(s=2,o=new Array(2),r=c):(s=5,o=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&c>=6?r=c-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(c>=6&&n===1||/vivaldi/i.test(l))||!i&&n===1)&&(s=2,o=new Array(2)),r=c)),o[0]=s<<3,o[0]|=(c&14)>>1,o[1]|=(c&1)<<7,o[1]|=n<<3,s===5&&(o[1]|=(r&14)>>1,o[2]=(r&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:h[c],channelCount:n,codec:"mp4a.40."+s,manifestCodec:d}}function Gi(a,e){return a[e]===255&&(a[e+1]&246)===240}function Vi(a,e){return a[e+1]&1?7:9}function St(a,e){return(a[e+3]&3)<<11|a[e+4]<<3|(a[e+5]&224)>>>5}function An(a,e){return e+5<a.length}function Qe(a,e){return e+1<a.length&&Gi(a,e)}function Rn(a,e){return An(a,e)&&Gi(a,e)&&St(a,e)<=a.length-e}function bn(a,e){if(Qe(a,e)){const t=Vi(a,e);if(e+t>=a.length)return!1;const i=St(a,e);if(i<=t)return!1;const s=e+i;return s===a.length||Qe(a,s)}return!1}function Hi(a,e,t,i,s){if(!a.samplerate){const r=Ln(e,t,i,s);if(!r)return;a.config=r.config,a.samplerate=r.samplerate,a.channelCount=r.channelCount,a.codec=r.codec,a.manifestCodec=r.manifestCodec,S.log(`parsed codec:${a.codec}, rate:${r.samplerate}, channels:${r.channelCount}`)}}function Ki(a){return 1024*9e4/a}function In(a,e){const t=Vi(a,e);if(e+t<=a.length){const i=St(a,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function Wi(a,e,t,i,s){const r=Ki(a.samplerate),n=i+s*r,o=In(e,t);let l;if(o){const{frameLength:c,headerLength:u}=o,f=u+c,m=Math.max(0,t+f-e.length);m?(l=new Uint8Array(f-u),l.set(e.subarray(t+u,e.length),0)):l=e.subarray(t+u,t+f);const g={unit:l,pts:n};return m||a.samples.push(g),{sample:g,length:f,missing:m}}const d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:n},length:d,missing:-1}}let Je=null;const Dn=[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],Cn=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],_n=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],wn=[0,1,1,4];function Yi(a,e,t,i,s){if(t+24>e.length)return;const r=ji(e,t);if(r&&t+r.frameLength<=e.length){const n=r.samplesPerFrame*9e4/r.sampleRate,o=i+s*n,l={unit:e.subarray(t,t+r.frameLength),pts:o,dts:o};return a.config=[],a.channelCount=r.channelCount,a.samplerate=r.sampleRate,a.samples.push(l),{sample:l,length:r.frameLength,missing:0}}}function ji(a,e){const t=a[e+1]>>3&3,i=a[e+1]>>1&3,s=a[e+2]>>4&15,r=a[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&r!==3){const n=a[e+2]>>1&1,o=a[e+3]>>6,l=t===3?3-i:i===3?3:4,d=Dn[l*14+s-1]*1e3,c=Cn[(t===3?0:t===2?1:2)*3+r],u=o===3?1:2,f=_n[t][i],m=wn[i],g=f*8*m,p=Math.floor(f*d/c+n)*m;if(Je===null){const y=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Je=y?parseInt(y[1]):0}return!!Je&&Je<=87&&i===2&&d>=224e3&&o===0&&(a[e+3]=a[e+3]|128),{sampleRate:c,channelCount:u,frameLength:p,samplesPerFrame:g}}}function Lt(a,e){return a[e]===255&&(a[e+1]&224)===224&&(a[e+1]&6)!==0}function zi(a,e){return e+1<a.length&&Lt(a,e)}function Pn(a,e){return Lt(a,e)&&4<=a.length-e}function qi(a,e){if(e+1<a.length&&Lt(a,e)){const i=ji(a,e);let s=4;i!=null&&i.frameLength&&(s=i.frameLength);const r=e+s;return r===a.length||zi(a,r)}return!1}class Fn extends $i{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Me(e,0);let i=t?.length||0;if(qi(e,i))return!1;for(let s=e.length;i<s;i++)if(bn(e,i))return S.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return Rn(e,t)}appendFrame(e,t,i){Hi(e,this.observer,t,i,e.manifestCodec);const s=Wi(e,t,i,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}}const On=/\/emsg[-/]ID3/i;class kn{constructor(e,t){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=t}resetTimeStamp(){}resetInitSegment(e,t,i,s){const r=this.videoTrack=me("video",1),n=this.audioTrack=me("audio",1),o=this.txtTrack=me("text",1);if(this.id3Track=me("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const l=jt(e);if(l.video){const{id:d,timescale:h,codec:c}=l.video;r.id=d,r.timescale=o.timescale=h,r.codec=c}if(l.audio){const{id:d,timescale:h,codec:c}=l.audio;n.id=d,n.timescale=h,n.codec=c}o.id=Ht.text,r.sampleDuration=0,r.duration=n.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return ws(e)}demux(e,t){this.timeOffset=t;let i=e;const s=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=de(this.remainderData,e));const o=$s(i);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=i;const n=this.extractID3Track(s,t);return r.samples=zt(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const s=this.extractID3Track(t,this.timeOffset);return i.samples=zt(e,t),{videoTrack:t,audioTrack:me(),id3Track:s,textTrack:me()}}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const s=G(e.samples,["emsg"]);s&&s.forEach(r=>{const n=Hs(r);if(On.test(n.schemeIdUri)){const o=k(n.presentationTime)?n.presentationTime/n.timeScale:t+n.presentationTimeDelta/n.timeScale;let l=n.eventDuration===4294967295?Number.POSITIVE_INFINITY:n.eventDuration/n.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);const d=n.payload;i.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:he.emsg,duration:l})}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}const Mn=(a,e)=>{let t=0,i=5;e+=i;const s=new Uint32Array(1),r=new Uint32Array(1),n=new Uint8Array(1);for(;i>0;){n[0]=a[e];const o=Math.min(i,8),l=8-o;r[0]=4278190080>>>24+l<<l,s[0]=(n[0]&r[0])>>l,t=t?t<<o|s[0]:s[0],e+=1,i-=o}return t};class Nn{constructor(){this.VideoSample=null}createVideoSample(e,t,i,s){return{key:e,frame:!1,pts:t,dts:i,units:[],debug:s,length:0}}getLastNalUnit(e){var t;let i=this.VideoSample,s;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){const r=i.units;s=r[r.length-1]}return s}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const i=t.samples,s=i.length;if(s){const r=i[s-1];e.pts=r.pts,e.dts=r.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&S.log(e.pts+"/"+e.dts+":"+e.debug)}}class Xi{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,i=e.byteLength-t,s=new Uint8Array(4),r=Math.min(4,t);if(r===0)throw new Error("no bytes available");s.set(e.subarray(i,i+r)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=r*8,this.bytesAvailable-=r}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const i=this.word>>>32-t;if(e>32&&S.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,i=8,s;for(let r=0;r<e;r++)i!==0&&(s=this.readEG(),i=(t+s+256)%256),t=i===0?t:i}readSPS(){let e=0,t=0,i=0,s=0,r,n,o;const l=this.readUByte.bind(this),d=this.readBits.bind(this),h=this.readUEG.bind(this),c=this.readBoolean.bind(this),u=this.skipBits.bind(this),f=this.skipEG.bind(this),m=this.skipUEG.bind(this),g=this.skipScalingList.bind(this);l();const p=l();if(d(5),u(3),l(),m(),p===100||p===110||p===122||p===244||p===44||p===83||p===86||p===118||p===128){const I=h();if(I===3&&u(1),m(),m(),u(1),c())for(n=I!==3?8:12,o=0;o<n;o++)c()&&(o<6?g(16):g(64))}m();const v=h();if(v===0)h();else if(v===1)for(u(1),f(),f(),r=h(),o=0;o<r;o++)f();m(),u(1);const L=h(),y=h(),b=d(1);b===0&&u(1),u(1),c()&&(e=h(),t=h(),i=h(),s=h());let T=[1,1];if(c()&&c())switch(l()){case 1:T=[1,1];break;case 2:T=[12,11];break;case 3:T=[10,11];break;case 4:T=[16,11];break;case 5:T=[40,33];break;case 6:T=[24,11];break;case 7:T=[20,11];break;case 8:T=[32,11];break;case 9:T=[80,33];break;case 10:T=[18,11];break;case 11:T=[15,11];break;case 12:T=[64,33];break;case 13:T=[160,99];break;case 14:T=[4,3];break;case 15:T=[3,2];break;case 16:T=[2,1];break;case 255:{T=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((L+1)*16-e*2-t*2),height:(2-b)*(y+1)*16-(b?2:4)*(i+s),pixelRatio:T}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Bn extends Nn{parseAVCPES(e,t,i,s,r){const n=this.parseAVCNALu(e,i.data);let o=this.VideoSample,l,d=!1;i.data=null,o&&n.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts,"")),n.forEach(h=>{var c;switch(h.type){case 1:{let g=!1;l=!0;const p=h.data;if(d&&p.length>4){const v=new Xi(p).readSliceType();(v===2||v===4||v===7||v===9)&&(g=!0)}if(g){var u;(u=o)!=null&&u.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts,"")),o.frame=!0,o.key=g;break}case 5:l=!0,(c=o)!=null&&c.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts,"")),o.key=!0,o.frame=!0;break;case 6:{l=!0,qt(h.data,1,i.pts,t.samples);break}case 7:{var f,m;l=!0,d=!0;const g=h.data,v=new Xi(g).readSPS();if(!e.sps||e.width!==v.width||e.height!==v.height||((f=e.pixelRatio)==null?void 0:f[0])!==v.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==v.pixelRatio[1]){e.width=v.width,e.height=v.height,e.pixelRatio=v.pixelRatio,e.sps=[g],e.duration=r;const L=g.subarray(1,4);let y="avc1.";for(let b=0;b<3;b++){let T=L[b].toString(16);T.length<2&&(T="0"+T),y+=T}e.codec=y}break}case 8:l=!0,e.pps=[h.data];break;case 9:l=!0,e.audFound=!0,o&&this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts,"");break;case 12:l=!0;break;default:l=!1,o&&(o.debug+="unknown NAL "+h.type+" ");break}o&&l&&o.units.push(h)}),s&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}parseAVCNALu(e,t){const i=t.byteLength;let s=e.naluState||0;const r=s,n=[];let o=0,l,d,h,c=-1,u=0;for(s===-1&&(c=0,u=t[0]&31,s=0,o=1);o<i;){if(l=t[o++],!s){s=l?0:1;continue}if(s===1){s=l?0:2;continue}if(!l)s=3;else if(l===1){if(d=o-s-1,c>=0){const f={data:t.subarray(c,d),type:u};n.push(f)}else{const f=this.getLastNalUnit(e.samples);f&&(r&&o<=4-r&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-r)),d>0&&(f.data=de(f.data,t.subarray(0,d)),f.state=0))}o<i?(h=t[o]&31,c=o,u=h,s=0):s=-1}else s=0}if(c>=0&&s>=0){const f={data:t.subarray(c,i),type:u,state:s};n.push(f)}if(n.length===0){const f=this.getLastNalUnit(e.samples);f&&(f.data=de(f.data,t))}return e.naluState=s,n}}class Un{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Tt(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,i){const s=e[t].unit;if(s.length<=16)return;const r=s.subarray(16,s.length-s.length%16),n=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(n).then(o=>{const l=new Uint8Array(o);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)})}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t);let s=0;for(let r=32;r<e.length-16;r+=160,s+=16)i.set(e.subarray(r,r+16),s);return i}getAvcDecryptedUnit(e,t){const i=new Uint8Array(t);let s=0;for(let r=32;r<e.length-16;r+=160,s+=16)e.set(i.subarray(s,s+16),r);return e}decryptAvcSample(e,t,i,s,r){const n=Xt(r.data),o=this.getAvcEncryptedData(n);this.decryptBuffer(o.buffer).then(l=>{r.data=this.getAvcDecryptedUnit(n,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,s)})}decryptAvcSamples(e,t,i,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){s();return}const r=e[t].units;for(;!(i>=r.length);i++){const n=r[i];if(!(n.data.length<=48||n.type!==1&&n.type!==5)&&(this.decryptAvcSample(e,t,i,s,n),!this.decrypter.isSync()))return}}}}const te=188;class Te{constructor(e,t,i){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.videoParser=new Bn}static probe(e){const t=Te.syncOffset(e);return t>0&&S.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){const t=e.length;let i=Math.min(te*5,t-te)+1,s=0;for(;s<i;){let r=!1,n=-1,o=0;for(let l=s;l<t;l+=te)if(e[l]===71&&(t-l===te||e[l+te]===71)){if(o++,n===-1&&(n=l,n!==0&&(i=Math.min(n+te*99,e.length-te)+1)),r||(r=At(e,l)===0),r&&o>1&&(n===0&&o>2||l+te>i))return n}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Ht[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=Te.createTrack("video"),this._audioTrack=Te.createTrack("audio",s),this._id3Track=Te.createTrack("id3"),this._txtTrack=Te.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,this._duration=s}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,i=!1,s=!1){i||(this.sampleAes=null);let r;const n=this._videoTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack;let h=n.pid,c=n.pesData,u=o.pid,f=l.pid,m=o.pesData,g=l.pesData,p=null,v=this.pmtParsed,L=this._pmtId,y=e.length;if(this.remainderData&&(e=de(this.remainderData,e),y=e.length,this.remainderData=null),y<te&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:n,id3Track:l,textTrack:d};const b=Math.max(0,Te.syncOffset(e));y-=(y-b)%te,y<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,y,e.buffer.byteLength-y));let T=0;for(let A=b;A<y;A+=te)if(e[A]===71){const D=!!(e[A+1]&64),P=At(e,A),_=(e[A+3]&48)>>4;let C;if(_>1){if(C=A+5+e[A+4],C===A+te)continue}else C=A+4;switch(P){case h:D&&(c&&(r=Ce(c))&&this.videoParser.parseAVCPES(n,d,r,!1,this._duration),c={data:[],size:0}),c&&(c.data.push(e.subarray(C,A+te)),c.size+=A+te-C);break;case u:if(D){if(m&&(r=Ce(m)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,r);break;case"mp3":this.parseMPEGPES(o,r);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(C,A+te)),m.size+=A+te-C);break;case f:D&&(g&&(r=Ce(g))&&this.parseID3PES(l,r),g={data:[],size:0}),g&&(g.data.push(e.subarray(C,A+te)),g.size+=A+te-C);break;case 0:D&&(C+=e[C]+1),L=this._pmtId=$n(e,C);break;case L:{D&&(C+=e[C]+1);const $=Gn(e,C,this.typeSupported,i);h=$.videoPid,h>0&&(n.pid=h,n.segmentCodec=$.segmentVideoCodec),u=$.audioPid,u>0&&(o.pid=u,o.segmentCodec=$.segmentAudioCodec),f=$.id3Pid,f>0&&(l.pid=f),p!==null&&!v&&(S.warn(`MPEG-TS PMT found at ${A} after unknown PID '${p}'. Backtracking to sync byte @${b} to parse all TS packets.`),p=null,A=b-188),v=this.pmtParsed=!0;break}case 17:case 8191:break;default:p=P;break}}else T++;if(T>0){const A=new Error(`Found ${T} TS packet/s that do not start with 0x47`);this.observer.emit(x.ERROR,x.ERROR,{type:K.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:!1,error:A,reason:A.message})}n.pesData=c,o.pesData=m,l.pesData=g;const I={audioTrack:o,videoTrack:n,id3Track:l,textTrack:d};return s&&this.extractRemainingSamples(I),I}flush(){const{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:i,id3Track:s,textTrack:r}=e,n=i.pesData,o=t.pesData,l=s.pesData;let d;if(n&&(d=Ce(n))?(this.videoParser.parseAVCPES(i,r,d,!0,this._duration),i.pesData=null):i.pesData=n,o&&(d=Ce(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break}t.pesData=null}else o!=null&&o.size&&S.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=Ce(l))?(this.parseID3PES(s,d),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,i){const s=this.demux(e,i,!0,!this.config.progressive),r=this.sampleAes=new Un(this.observer,this.config,t);return this.decrypt(s,r)}decrypt(e,t){return new Promise(i=>{const{audioTrack:s,videoTrack:r}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{r.samples?t.decryptAvcSamples(r.samples,0,0,()=>{i(e)}):i(e)}):r.samples&&t.decryptAvcSamples(r.samples,0,0,()=>{i(e)})})}destroy(){this._duration=0}parseAACPES(e,t){let i=0;const s=this.aacOverFlow;let r=t.data;if(s){this.aacOverFlow=null;const c=s.missing,u=s.sample.unit.byteLength;if(c===-1)r=de(s.sample.unit,r);else{const f=u-c;s.sample.unit.set(r.subarray(0,c),f),e.samples.push(s.sample),i=s.missing}}let n,o;for(n=i,o=r.length;n<o-1&&!Qe(r,n);n++);if(n!==i){let c;const u=n<o-1;u?c=`AAC PES did not start with ADTS header,offset:${n}`:c="No ADTS header found in AAC PES";const f=new Error(c);if(S.warn(`parsing error: ${c}`),this.observer.emit(x.ERROR,x.ERROR,{type:K.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:!1,levelRetry:u,error:f,reason:c}),!u)return}Hi(e,this.observer,r,n,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){const c=Ki(e.samplerate);l=s.sample.pts+c}else{S.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,h;for(;n<o;)if(h=Wi(e,r,n,l,d),n+=h.length,h.missing){this.aacOverFlow=h;break}else for(d++;n<o-1&&!Qe(r,n);n++);}parseMPEGPES(e,t){const i=t.data,s=i.length;let r=0,n=0;const o=t.pts;if(o===void 0){S.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;n<s;)if(zi(i,n)){const l=Yi(e,i,n,o,r);if(l)n+=l.length,r++;else break}else n++}parseAC3PES(e,t){}parseID3PES(e,t){if(t.pts===void 0){S.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=ae({},t,{type:this._videoTrack?he.emsg:he.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}}function At(a,e){return((a[e+1]&31)<<8)+a[e+2]}function $n(a,e){return(a[e+10]&31)<<8|a[e+11]}function Gn(a,e,t,i){const s={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},r=(a[e+1]&15)<<8|a[e+2],n=e+3+r-4,o=(a[e+10]&15)<<8|a[e+11];for(e+=12+o;e<n;){const l=At(a,e),d=(a[e+3]&15)<<8|a[e+4];switch(a[e]){case 207:if(!i){Rt("ADTS AAC");break}case 15:s.audioPid===-1&&(s.audioPid=l);break;case 21:s.id3Pid===-1&&(s.id3Pid=l);break;case 219:if(!i){Rt("H.264");break}case 27:s.videoPid===-1&&(s.videoPid=l,s.segmentVideoCodec="avc");break;case 3:case 4:!t.mpeg&&!t.mp3?S.log("MPEG audio found, not supported in this browser"):s.audioPid===-1&&(s.audioPid=l,s.segmentAudioCodec="mp3");break;case 193:if(!i){Rt("AC-3");break}case 129:S.warn("AC-3 in M2TS support not included in build");break;case 6:if(s.audioPid===-1&&d>0){let h=e+5,c=d;for(;c>2;){switch(a[h]){case 106:S.warn("AC-3 in M2TS support not included in build");break}const f=a[h+1]+2;h+=f,c-=f}}break;case 194:case 135:S.warn("Unsupported EC-3 in M2TS found");break;case 36:S.warn("Unsupported HEVC in M2TS found");break}e+=d+5}return s}function Rt(a){S.log(`${a} with AES-128-CBC encryption found in unencrypted stream`)}function Ce(a){let e=0,t,i,s,r,n;const o=a.data;if(!a||a.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=de(o[0],o[1]),o.splice(1,1);if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(i=(t[4]<<8)+t[5],i&&i>a.size-6)return null;const d=t[7];d&192&&(r=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(n=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,r-n>60*9e4&&(S.warn(`${Math.round((r-n)/9e4)}s delta between PTS and DTS, align them`),r=n)):n=r),s=t[8];let h=s+9;if(a.size<=h)return null;a.size-=h;const c=new Uint8Array(a.size);for(let u=0,f=o.length;u<f;u++){t=o[u];let m=t.byteLength;if(h)if(h>m){h-=m;continue}else t=t.subarray(h),m-=h,h=0;c.set(t,e),e+=m}return i&&(i-=s+3),{data:c,pts:r,dts:n,len:i}}return null}class Vn extends $i{resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Me(e,0);let i=t?.length||0;if(t&&e[i]===11&&e[i+1]===119&&Ut(t)!==void 0&&Mn(e,i)<=16)return!1;for(let s=e.length;i<s;i++)if(qi(e,i))return S.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return Pn(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return Yi(e,t,i,this.basePTS,this.frameIndex)}}class Qi{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)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(t===6)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]);break;default:if(t===1)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(t===2)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(t===3)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]);break}}}const Ee=Math.pow(2,32)-1;class E{static init(){E.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in E.types)E.types.hasOwnProperty(e)&&(E.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=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]),i=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]);E.HDLR_TYPES={video:t,audio:i};const s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);E.STTS=E.STSC=E.STCO=r,E.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),E.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),E.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),E.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const n=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);E.FTYP=E.box(E.types.ftyp,n,l,n,o),E.DINF=E.box(E.types.dinf,E.box(E.types.dref,s))}static box(e,...t){let i=8,s=t.length;const r=s;for(;s--;)i+=t[s].byteLength;const n=new Uint8Array(i);for(n[0]=i>>24&255,n[1]=i>>16&255,n[2]=i>>8&255,n[3]=i&255,n.set(e,4),s=0,i=8;s<r;s++)n.set(t[s],i),i+=t[s].byteLength;return n}static hdlr(e){return E.box(E.types.hdlr,E.HDLR_TYPES[e])}static mdat(e){return E.box(E.types.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(Ee+1)),s=Math.floor(t%(Ee+1));return E.box(E.types.mdhd,new Uint8Array([1,0,0,0,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,e&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return E.box(E.types.mdia,E.mdhd(e.timescale,e.duration),E.hdlr(e.type),E.minf(e))}static mfhd(e){return E.box(E.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?E.box(E.types.minf,E.box(E.types.smhd,E.SMHD),E.DINF,E.stbl(e)):E.box(E.types.minf,E.box(E.types.vmhd,E.VMHD),E.DINF,E.stbl(e))}static moof(e,t,i){return E.box(E.types.moof,E.mfhd(e),E.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=E.trak(e[t]);return E.box.apply(null,[E.types.moov,E.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(E.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=E.trex(e[t]);return E.box.apply(null,[E.types.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(Ee+1)),s=Math.floor(t%(Ee+1)),r=new Uint8Array([1,0,0,0,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,e&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,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 E.box(E.types.mvhd,r)}static sdtp(e){const t=e.samples||[],i=new Uint8Array(4+t.length);let s,r;for(s=0;s<t.length;s++)r=t[s].flags,i[s+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return E.box(E.types.sdtp,i)}static stbl(e){return E.box(E.types.stbl,E.stsd(e),E.box(E.types.stts,E.STTS),E.box(E.types.stsc,E.STSC),E.box(E.types.stsz,E.STSZ),E.box(E.types.stco,E.STCO))}static avc1(e){let t=[],i=[],s,r,n;for(s=0;s<e.sps.length;s++)r=e.sps[s],n=r.byteLength,t.push(n>>>8&255),t.push(n&255),t=t.concat(Array.prototype.slice.call(r));for(s=0;s<e.pps.length;s++)r=e.pps[s],n=r.byteLength,i.push(n>>>8&255),i.push(n&255),i=i.concat(Array.prototype.slice.call(r));const o=E.box(E.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),l=e.width,d=e.height,h=e.pixelRatio[0],c=e.pixelRatio[1];return E.box(E.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,l>>8&255,l&255,d>>8&255,d&255,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]),o,E.box(E.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),E.box(E.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,c>>24,c>>16&255,c>>8&255,c&255])))}static esds(e){const t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){const t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return E.box(E.types.mp4a,E.audioStsd(e),E.box(E.types.esds,E.esds(e)))}static mp3(e){return E.box(E.types[".mp3"],E.audioStsd(e))}static ac3(e){return E.box(E.types["ac-3"],E.audioStsd(e),E.box(E.types.dac3,e.config))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?E.box(E.types.stsd,E.STSD,E.mp3(e)):e.segmentCodec==="ac3"?E.box(E.types.stsd,E.STSD,E.ac3(e)):E.box(E.types.stsd,E.STSD,E.mp4a(e)):E.box(E.types.stsd,E.STSD,E.avc1(e))}static tkhd(e){const t=e.id,i=e.duration*e.timescale,s=e.width,r=e.height,n=Math.floor(i/(Ee+1)),o=Math.floor(i%(Ee+1));return E.box(E.types.tkhd,new Uint8Array([1,0,0,7,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,t&255,0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,o>>24,o>>16&255,o>>8&255,o&255,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,s>>8&255,s&255,0,0,r>>8&255,r&255,0,0]))}static traf(e,t){const i=E.sdtp(e),s=e.id,r=Math.floor(t/(Ee+1)),n=Math.floor(t%(Ee+1));return E.box(E.types.traf,E.box(E.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),E.box(E.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,r&255,n>>24,n>>16&255,n>>8&255,n&255])),E.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,E.box(E.types.trak,E.tkhd(e),E.mdia(e))}static trex(e){const t=e.id;return E.box(E.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const i=e.samples||[],s=i.length,r=12+16*s,n=new Uint8Array(r);let o,l,d,h,c,u;for(t+=8+r,n.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)l=i[o],d=l.duration,h=l.size,c=l.flags,u=l.cts,n.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,c.degradPrio&61440,c.degradPrio&15,u>>>24&255,u>>>16&255,u>>>8&255,u&255],12+16*o);return E.box(E.types.trun,n)}static initSegment(e){E.types||E.init();const t=E.moov(e);return de(E.FTYP,t)}}E.types=void 0,E.HDLR_TYPES=void 0,E.STTS=void 0,E.STSC=void 0,E.STCO=void 0,E.STSZ=void 0,E.VMHD=void 0,E.SMHD=void 0,E.STSD=void 0,E.FTYP=void 0,E.DINF=void 0;const Hn=9e4;function Kn(a,e,t=1,i=!1){const s=a*e*t;return i?Math.round(s):s}function Oe(a,e=!1){return Kn(a,1e3,1/Hn,e)}const Wn=10*1e3,Ji=1024,Yn=1152,jn=1536;let _e=null,bt=null;class It{constructor(e,t,i,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.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,_e===null){const n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);_e=n?parseInt(n[1]):0}if(bt===null){const r=navigator.userAgent.match(/Safari\/(\d+)/i);bt=r?parseInt(r[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){S.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){S.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){S.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const i=e.reduce((s,r)=>{const n=r.pts-s;return n<-4294967296?(t=!0,ue(s,r.pts)):n>0?s:r.pts},e[0].pts);return t&&S.debug("PTS rollover detected"),i}remux(e,t,i,s,r,n,o,l){let d,h,c,u,f,m,g=r,p=r;const v=e.pid>-1,L=t.pid>-1,y=t.samples.length,b=e.samples.length>0,T=o&&y>0||y>1;if((!v||b)&&(!L||T)||this.ISGenerated||o){if(this.ISGenerated){var A,D,P,_;const U=this.videoTrackConfig;U&&(t.width!==U.width||t.height!==U.height||((A=t.pixelRatio)==null?void 0:A[0])!==((D=U.pixelRatio)==null?void 0:D[0])||((P=t.pixelRatio)==null?void 0:P[1])!==((_=U.pixelRatio)==null?void 0:_[1]))&&this.resetInitSegment()}else c=this.generateIS(e,t,r,n);const C=this.isVideoContiguous;let $=-1,M;if(T&&($=zn(t.samples),!C&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,$>0){S.warn(`[mp4-remuxer]: Dropped ${$} out of ${y} video samples due to a missing keyframe`);const U=this.getVideoStartPts(t.samples);t.samples=t.samples.slice($),t.dropped+=$,p+=(t.samples[0].pts-U)/t.inputTimeScale,M=p}else $===-1&&(S.warn(`[mp4-remuxer]: No keyframe found out of ${y} video samples`),m=!1);if(this.ISGenerated){if(b&&T){const U=this.getVideoStartPts(t.samples),V=(ue(e.samples[0].pts,U)-U)/t.inputTimeScale;g+=Math.max(0,V),p+=Math.max(0,-V)}if(b){if(e.samplerate||(S.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,r,n)),h=this.remuxAudio(e,g,this.isAudioContiguous,n,L||T||l===z.AUDIO?p:void 0),T){const U=h?h.endPTS-h.startPTS:0;t.inputTimeScale||(S.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,r,n)),d=this.remuxVideo(t,p,C,U)}}else T&&(d=this.remuxVideo(t,p,C,0));d&&(d.firstKeyFrame=$,d.independent=$!==-1,d.firstKeyFramePTS=M)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(f=Zi(i,r,this._initPTS,this._initDTS)),s.samples.length&&(u=es(s,r,this._initPTS))),{audio:h,video:d,initSegment:c,independent:m,text:u,id3:f}}generateIS(e,t,i,s){const r=e.samples,n=t.samples,o=this.typeSupported,l={},d=this._initPTS;let h=!d||s,c="audio/mp4",u,f,m;if(h&&(u=f=1/0),e.config&&r.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(c="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}l.audio={id:"audio",container:c,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):E.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(m=e.inputTimeScale,!d||m!==d.timescale?u=f=r[0].pts-Math.round(m*i):h=!1)}if(t.sps&&t.pps&&n.length){if(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:E.initSegment([t]),metadata:{width:t.width,height:t.height}},h)if(m=t.inputTimeScale,!d||m!==d.timescale){const g=this.getVideoStartPts(n),p=Math.round(m*i);f=Math.min(f,ue(n[0].dts,g)-p),u=Math.min(u,g-p)}else h=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(l).length)return this.ISGenerated=!0,h?(this._initPTS={baseTime:u,timescale:m},this._initDTS={baseTime:f,timescale:m}):u=m=void 0,{tracks:l,initPTS:u,timescale:m}}remuxVideo(e,t,i,s){const r=e.inputTimeScale,n=e.samples,o=[],l=n.length,d=this._initPTS;let h=this.nextAvcDts,c=8,u=this.videoSampleDuration,f,m,g=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,v=!1;if(!i||h===null){const O=t*r,F=n[0].pts-ue(n[0].dts,n[0].pts);_e&&h!==null&&Math.abs(O-F-h)<15e3?i=!0:h=O-F}const L=d.baseTime*r/d.timescale;for(let O=0;O<l;O++){const F=n[O];F.pts=ue(F.pts-L,h),F.dts=ue(F.dts-L,h),F.dts<n[O>0?O-1:O].dts&&(v=!0)}v&&n.sort(function(O,F){const Y=O.dts-F.dts,H=O.pts-F.pts;return Y||H}),f=n[0].dts,m=n[n.length-1].dts;const y=m-f,b=y?Math.round(y/(l-1)):u||e.inputTimeScale/30;if(i){const O=f-h,F=O>b,Y=O<-1;if((F||Y)&&(F?S.warn(`AVC: ${Oe(O,!0)} ms (${O}dts) hole between fragments detected at ${t.toFixed(3)}`):S.warn(`AVC: ${Oe(-O,!0)} ms (${O}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!Y||h>=n[0].pts||_e)){f=h;const H=n[0].pts-O;if(F)n[0].dts=f,n[0].pts=H;else for(let q=0;q<n.length&&!(n[q].dts>H);q++)n[q].dts-=O,n[q].pts-=O;S.log(`Video: Initial PTS/DTS adjusted: ${Oe(H,!0)}/${Oe(f,!0)}, delta: ${Oe(O,!0)} ms`)}}f=Math.max(0,f);let T=0,I=0,A=f;for(let O=0;O<l;O++){const F=n[O],Y=F.units,H=Y.length;let q=0;for(let se=0;se<H;se++)q+=Y[se].data.length;I+=q,T+=H,F.length=q,F.dts<A?(F.dts=A,A+=b/4|0||1):A=F.dts,g=Math.min(F.pts,g),p=Math.max(F.pts,p)}m=n[l-1].dts;const D=I+4*T+8;let P;try{P=new Uint8Array(D)}catch(O){this.observer.emit(x.ERROR,x.ERROR,{type:K.MUX_ERROR,details:R.REMUX_ALLOC_ERROR,fatal:!1,error:O,bytes:D,reason:`fail allocating video mdat ${D}`});return}const _=new DataView(P.buffer);_.setUint32(0,D),P.set(E.types.mdat,4);let C=!1,$=Number.POSITIVE_INFINITY,M=Number.POSITIVE_INFINITY,U=Number.NEGATIVE_INFINITY,B=Number.NEGATIVE_INFINITY;for(let O=0;O<l;O++){const F=n[O],Y=F.units;let H=0;for(let le=0,re=Y.length;le<re;le++){const be=Y[le],we=be.data,tt=be.data.byteLength;_.setUint32(c,tt),c+=4,P.set(we,c),c+=tt,H+=4+tt}let q;if(O<l-1)u=n[O+1].dts-F.dts,q=n[O+1].pts-F.pts;else{const le=this.config,re=O>0?F.dts-n[O-1].dts:b;if(q=O>0?F.pts-n[O-1].pts:b,le.stretchShortVideoTrack&&this.nextAudioPts!==null){const be=Math.floor(le.maxBufferHole*r),we=(s?g+s*r:this.nextAudioPts)-F.pts;we>be?(u=we-re,u<0?u=re:C=!0,S.log(`[mp4-remuxer]: It is approximately ${we/90} ms to the next segment; using duration ${u/90} ms for the last video frame.`)):u=re}else u=re}const se=Math.round(F.pts-F.dts);$=Math.min($,u),U=Math.max(U,u),M=Math.min(M,q),B=Math.max(B,q),o.push(new ts(F.key,u,H,se))}if(o.length){if(_e){if(_e<70){const O=o[0].flags;O.dependsOn=2,O.isNonSync=0}}else if(bt&&B-M<U-$&&b/U<.025&&o[0].cts===0){S.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let O=f;for(let F=0,Y=o.length;F<Y;F++){const H=O+o[F].duration,q=O+o[F].cts;if(F<Y-1){const se=H+o[F+1].cts;o[F].duration=se-q}else o[F].duration=F?o[F-1].duration:b;o[F].cts=0,O=H}}}u=C||!u?b:u,this.nextAvcDts=h=m+u,this.videoSampleDuration=u,this.isVideoContiguous=!0;const X={data1:E.moof(e.sequenceNumber++,f,ae({},e,{samples:o})),data2:P,startPTS:g/r,endPTS:(p+u)/r,startDTS:f/r,endDTS:h/r,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,X}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return Yn;case"ac3":return jn;default:return Ji}}remuxAudio(e,t,i,s,r){const n=e.inputTimeScale,o=e.samplerate?e.samplerate:n,l=n/o,d=this.getSamplesPerFrame(e),h=d*l,c=this._initPTS,u=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=r!==void 0;let g=e.samples,p=u?0:8,v=this.nextAudioPts||-1;const L=t*n,y=c.baseTime*n/c.timescale;if(this.isAudioContiguous=i=i||g.length&&v>0&&(s&&Math.abs(L-v)<9e3||Math.abs(ue(g[0].pts-y,L)-v)<20*h),g.forEach(function(V){V.pts=ue(V.pts-y,L)}),!i||v<0){if(g=g.filter(V=>V.pts>=0),!g.length)return;r===0?v=0:s&&!m?v=Math.max(0,L):v=g[0].pts}if(e.segmentCodec==="aac"){const V=this.config.maxAudioFramesDrift;for(let W=0,X=v;W<g.length;W++){const O=g[W],F=O.pts,Y=F-X,H=Math.abs(1e3*Y/n);if(Y<=-V*h&&m)W===0&&(S.warn(`Audio frame @ ${(F/n).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*Y/n)} ms.`),this.nextAudioPts=v=X=F);else if(Y>=V*h&&H<Wn&&m){let q=Math.round(Y/h);X=F-q*h,X<0&&(q--,X+=h),W===0&&(this.nextAudioPts=v=X),S.warn(`[mp4-remuxer]: Injecting ${q} audio frame @ ${(X/n).toFixed(3)}s due to ${Math.round(1e3*Y/n)} ms gap.`);for(let se=0;se<q;se++){const le=Math.max(X,0);let re=Qi.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);re||(S.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),re=O.unit.subarray()),g.splice(W,0,{unit:re,pts:le}),X+=h,W++}}O.pts=X,X+=h}}let b=null,T=null,I,A=0,D=g.length;for(;D--;)A+=g[D].unit.byteLength;for(let V=0,W=g.length;V<W;V++){const X=g[V],O=X.unit;let F=X.pts;if(T!==null){const H=f[V-1];H.duration=Math.round((F-T)/l)}else if(i&&e.segmentCodec==="aac"&&(F=v),b=F,A>0){A+=p;try{I=new Uint8Array(A)}catch(H){this.observer.emit(x.ERROR,x.ERROR,{type:K.MUX_ERROR,details:R.REMUX_ALLOC_ERROR,fatal:!1,error:H,bytes:A,reason:`fail allocating audio mdat ${A}`});return}u||(new DataView(I.buffer).setUint32(0,A),I.set(E.types.mdat,4))}else return;I.set(O,p);const Y=O.byteLength;p+=Y,f.push(new ts(!0,d,Y,0)),T=F}const P=f.length;if(!P)return;const _=f[f.length-1];this.nextAudioPts=v=T+l*_.duration;const C=u?new Uint8Array(0):E.moof(e.sequenceNumber++,b/l,ae({},e,{samples:f}));e.samples=[];const $=b/n,M=v/n,B={data1:C,data2:I,startPTS:$,endPTS:M,startDTS:$,endDTS:M,type:"audio",hasAudio:!0,hasVideo:!1,nb:P};return this.isAudioContiguous=!0,B}remuxEmptyAudio(e,t,i,s){const r=e.inputTimeScale,n=e.samplerate?e.samplerate:r,o=r/n,l=this.nextAudioPts,d=this._initDTS,h=d.baseTime*9e4/d.timescale,c=(l!==null?l:s.startDTS*r)+h,u=s.endDTS*r+h,f=o*Ji,m=Math.ceil((u-c)/f),g=Qi.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(S.warn("[mp4-remuxer]: remux empty Audio"),!g){S.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const p=[];for(let v=0;v<m;v++){const L=c+v*f;p.push({unit:g,pts:L,dts:L})}return e.samples=p,this.remuxAudio(e,t,i,!1)}}function ue(a,e){let t;if(e===null)return a;for(e<a?t=-8589934592:t=8589934592;Math.abs(a-e)>4294967296;)a+=t;return a}function zn(a){for(let e=0;e<a.length;e++)if(a[e].key)return e;return-1}function Zi(a,e,t,i){const s=a.samples.length;if(!s)return;const r=a.inputTimeScale;for(let o=0;o<s;o++){const l=a.samples[o];l.pts=ue(l.pts-t.baseTime*r/t.timescale,e*r)/r,l.dts=ue(l.dts-i.baseTime*r/i.timescale,e*r)/r}const n=a.samples;return a.samples=[],{samples:n}}function es(a,e,t){const i=a.samples.length;if(!i)return;const s=a.inputTimeScale;for(let n=0;n<i;n++){const o=a.samples[n];o.pts=ue(o.pts-t.baseTime*s/t.timescale,e*s)/s}a.samples.sort((n,o)=>n.pts-o.pts);const r=a.samples;return a.samples=[],{samples:r}}class ts{constructor(e,t,i,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=i,this.cts=s,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}class qn{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(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,i,s){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(Os(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:i}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const s=this.initData=jt(e);s.audio&&(t=is(s.audio,Q.AUDIO)),s.video&&(i=is(s.video,Q.VIDEO));const r={};s.audio&&s.video?r.audiovideo={container:"video/mp4",codec:t+","+i,initSegment:e,id:"main"}:s.audio?r.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?r.video={container:"video/mp4",codec:i,initSegment:e,id:"main"}:S.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=r}remux(e,t,i,s,r,n){var o,l;let{initPTS:d,lastEndTime:h}=this;const c={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};k(h)||(h=this.lastEndTime=r||0);const u=t.samples;if(!(u!=null&&u.length))return c;const f={initPTS:void 0,timescale:1};let m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(u),m=this.initData),!((l=m)!=null&&l.length))return S.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const g=Ns(u,m),p=Ms(m,u),v=p===null?r:p;(Xn(d,v,r,g)||f.timescale!==d.timescale&&n)&&(f.initPTS=v-r,d&&d.timescale===1&&S.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});const L=e?v-d.baseTime/d.timescale:h,y=L+g;Us(m,u,d.baseTime/d.timescale),g>0?this.lastEndTime=y:(S.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const b=!!m.audio,T=!!m.video;let I="";b&&(I+="audio"),T&&(I+="video");const A={data1:u,startPTS:L,startDTS:L,endPTS:y,endDTS:y,type:I,hasAudio:b,hasVideo:T,nb:1,dropped:0};return c.audio=A.type==="audio"?A:void 0,c.video=A.type!=="audio"?A:void 0,c.initSegment=f,c.id3=Zi(i,r,d,d),s.samples.length&&(c.text=es(s,r,d)),c}}function Xn(a,e,t,i){if(a===null)return!0;const s=Math.max(i,1),r=e-a.baseTime/a.timescale;return Math.abs(r-t)>s}function is(a,e){const t=a?.codec;if(t&&t.length>4)return t;if(e===Q.AUDIO){if(t==="ec-3"||t==="ac-3"||t==="alac")return t;if(t==="fLaC"||t==="Opus")return Ve(t,!1);const i="mp4a.40.5";return S.info(`Parsed audio codec "${t}" or audio object type not handled. Using "${i}"`),i}return S.warn(`Unhandled video codec "${t}"`),t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":"avc1.42e01e"}const ss=typeof self<"u"?self:void 0;let ve;try{ve=self.performance.now.bind(self.performance)}catch{S.debug("Unable to use Performance API on this environment"),ve=ss?.Date.now}const Dt=[{demux:kn,remux:qn},{demux:Te,remux:It},{demux:Fn,remux:It},{demux:Vn,remux:It}];class rs{constructor(e,t,i,s,r){this.async=!1,this.observer=void 0,this.typeSupported=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=e,this.typeSupported=t,this.config=i,this.vendor=s,this.id=r}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,s){const r=i.transmuxing;r.executeStart=ve();let n=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);const{contiguous:d,discontinuity:h,trackSwitch:c,accurateTimeOffset:u,timeOffset:f,initSegmentChange:m}=s||o,{audioCodec:g,videoCodec:p,defaultInitPts:v,duration:L,initSegmentData:y}=l,b=Qn(n,t);if(b&&b.method==="AES-128"){const D=this.getDecrypter();if(D.isSync()){let P=D.softwareDecrypt(n,b.key.buffer,b.iv.buffer);if(i.part>-1&&(P=D.flush()),!P)return r.executeEnd=ve(),Ct(i);n=new Uint8Array(P)}else return this.decryptionPromise=D.webCryptoDecrypt(n,b.key.buffer,b.iv.buffer).then(P=>{const _=this.push(P,null,i);return this.decryptionPromise=null,_}),this.decryptionPromise}const T=this.needsProbing(h,c);if(T){const D=this.configureTransmuxer(n);if(D)return S.warn(`[transmuxer] ${D.message}`),this.observer.emit(x.ERROR,x.ERROR,{type:K.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:!1,error:D,reason:D.message}),r.executeEnd=ve(),Ct(i)}(h||c||m||T)&&this.resetInitSegment(y,g,p,L,t),(h||m||T)&&this.resetInitialTimestamp(v),d||this.resetContiguity();const I=this.transmux(n,b,f,u,i),A=this.currentTransmuxState;return A.contiguous=!0,A.discontinuity=!1,A.trackSwitch=!1,r.executeEnd=ve(),I}flush(e){const t=e.transmuxing;t.executeStart=ve();const{decrypter:i,currentTransmuxState:s,decryptionPromise:r}=this;if(r)return r.then(()=>this.flush(e));const n=[],{timeOffset:o}=s;if(i){const c=i.flush();c&&n.push(this.push(c,null,e))}const{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=ve(),[Ct(e)];const h=l.flush(o);return Ze(h)?h.then(c=>(this.flushRemux(n,c,e),n)):(this.flushRemux(n,h,e),n)}flushRemux(e,t,i){const{audioTrack:s,videoTrack:r,id3Track:n,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;S.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const h=this.remuxer.remux(s,r,n,o,d,l,!0,this.id);e.push({remuxResult:h,chunkMeta:i}),i.transmuxing.executeEnd=ve()}resetInitialTimestamp(e){const{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,s,r){const{demuxer:n,remuxer:o}=this;!n||!o||(n.resetInitSegment(e,t,i,s),o.resetInitSegment(e,t,i,r))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,s,r){let n;return t&&t.method==="SAMPLE-AES"?n=this.transmuxSampleAes(e,t,i,s,r):n=this.transmuxUnencrypted(e,i,s,r),n}transmuxUnencrypted(e,t,i,s){const{audioTrack:r,videoTrack:n,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,n,o,l,t,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,i,s,r){return this.demuxer.demuxSampleAes(e,t,i).then(n=>({remuxResult:this.remuxer.remux(n.audioTrack,n.videoTrack,n.id3Track,n.textTrack,i,s,!1,this.id),chunkMeta:r}))}configureTransmuxer(e){const{config:t,observer:i,typeSupported:s,vendor:r}=this;let n;for(let u=0,f=Dt.length;u<f;u++){var o;if((o=Dt[u].demux)!=null&&o.probe(e)){n=Dt[u];break}}if(!n)return new Error("Failed to find demuxer by probing fragment data");const l=this.demuxer,d=this.remuxer,h=n.remux,c=n.demux;(!d||!(d instanceof h))&&(this.remuxer=new h(i,t,s,r)),(!l||!(l instanceof c))&&(this.demuxer=new c(i,t,s),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Tt(this.config)),e}}function Qn(a,e){let t=null;return a.byteLength>0&&e?.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const Ct=a=>({remuxResult:{},chunkMeta:a});function Ze(a){return"then"in a&&a.then instanceof Function}class Jn{constructor(e,t,i,s,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=s,this.defaultInitPts=r||null}}class Zn{constructor(e,t,i,s,r,n){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=s,this.timeOffset=r,this.initSegmentChange=n}}var ns={exports:{}};(function(a){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function s(l,d,h){this.fn=l,this.context=d,this.once=h||!1}function r(l,d,h,c,u){if(typeof h!="function")throw new TypeError("The listener must be a function");var f=new s(h,c||l,u),m=t?t+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function n(l,d){--l._eventsCount===0?l._events=new i:delete l._events[d]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],h,c;if(this._eventsCount===0)return d;for(c in h=this._events)e.call(h,c)&&d.push(t?c.slice(1):c);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(h)):d},o.prototype.listeners=function(d){var h=t?t+d:d,c=this._events[h];if(!c)return[];if(c.fn)return[c.fn];for(var u=0,f=c.length,m=new Array(f);u<f;u++)m[u]=c[u].fn;return m},o.prototype.listenerCount=function(d){var h=t?t+d:d,c=this._events[h];return c?c.fn?1:c.length:0},o.prototype.emit=function(d,h,c,u,f,m){var g=t?t+d:d;if(!this._events[g])return!1;var p=this._events[g],v=arguments.length,L,y;if(p.fn){switch(p.once&&this.removeListener(d,p.fn,void 0,!0),v){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,h),!0;case 3:return p.fn.call(p.context,h,c),!0;case 4:return p.fn.call(p.context,h,c,u),!0;case 5:return p.fn.call(p.context,h,c,u,f),!0;case 6:return p.fn.call(p.context,h,c,u,f,m),!0}for(y=1,L=new Array(v-1);y<v;y++)L[y-1]=arguments[y];p.fn.apply(p.context,L)}else{var b=p.length,T;for(y=0;y<b;y++)switch(p[y].once&&this.removeListener(d,p[y].fn,void 0,!0),v){case 1:p[y].fn.call(p[y].context);break;case 2:p[y].fn.call(p[y].context,h);break;case 3:p[y].fn.call(p[y].context,h,c);break;case 4:p[y].fn.call(p[y].context,h,c,u);break;default:if(!L)for(T=1,L=new Array(v-1);T<v;T++)L[T-1]=arguments[T];p[y].fn.apply(p[y].context,L)}}return!0},o.prototype.on=function(d,h,c){return r(this,d,h,c,!1)},o.prototype.once=function(d,h,c){return r(this,d,h,c,!0)},o.prototype.removeListener=function(d,h,c,u){var f=t?t+d:d;if(!this._events[f])return this;if(!h)return n(this,f),this;var m=this._events[f];if(m.fn)m.fn===h&&(!u||m.once)&&(!c||m.context===c)&&n(this,f);else{for(var g=0,p=[],v=m.length;g<v;g++)(m[g].fn!==h||u&&!m[g].once||c&&m[g].context!==c)&&p.push(m[g]);p.length?this._events[f]=p.length===1?p[0]:p:n(this,f)}return this},o.prototype.removeAllListeners=function(d){var h;return d?(h=t?t+d:d,this._events[h]&&n(this,h)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,a.exports=o})(ns);var ea=ns.exports,as=Pt(ea);class ta{constructor(e,t,i,s){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=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=s;const n=(h,c)=>{c=c||{},c.frag=this.frag,c.id=this.id,h===x.ERROR&&(this.error=c.error),this.hls.trigger(h,c)};this.observer=new as,this.observer.on(x.FRAG_DECRYPTED,n),this.observer.on(x.ERROR,n);const o=Re(r.preferManagedMediaSource)||{isTypeSupported:()=>!1},l={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1},d=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(r.workerPath||yn())){try{r.workerPath?(S.log(`loading Web Worker ${r.workerPath} for "${t}"`),this.workerContext=Tn(r.workerPath)):(S.log(`injecting Web Worker for "${t}"`),this.workerContext=En()),this.onwmsg=u=>this.onWorkerMessage(u);const{worker:c}=this.workerContext;c.addEventListener("message",this.onwmsg),c.onerror=u=>{const f=new Error(`${u.message} (${u.filename}:${u.lineno})`);r.enableWorker=!1,S.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(x.ERROR,{type:K.OTHER_ERROR,details:R.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:f})},c.postMessage({cmd:"init",typeSupported:l,vendor:d,id:t,config:JSON.stringify(r)})}catch(c){S.warn(`Error setting up "${t}" Web Worker, fallback to inline`,c),this.resetWorker(),this.error=null,this.transmuxer=new rs(this.observer,l,r,d,t)}return}this.transmuxer=new rs(this.observer,l,r,d,t)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.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 e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,i,s,r,n,o,l,d,h){var c,u;d.transmuxing.start=self.performance.now();const{transmuxer:f}=this,m=n?n.start:r.start,g=r.decryptdata,p=this.frag,v=!(p&&r.cc===p.cc),L=!(p&&d.level===p.level),y=p?d.sn-p.sn:-1,b=this.part?d.part-this.part.index:-1,T=y===0&&d.id>1&&d.id===p?.stats.chunkCount,I=!L&&(y===1||y===0&&(b===1||T&&b<=0)),A=self.performance.now();(L||y||r.stats.parsing.start===0)&&(r.stats.parsing.start=A),n&&(b||!I)&&(n.stats.parsing.start=A);const D=!(p&&((c=r.initSegment)==null?void 0:c.url)===((u=p.initSegment)==null?void 0:u.url)),P=new Zn(v,I,l,L,m,D);if(!I||v||D){S.log(`[transmuxer-interface, ${r.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
|
9
|
+
discontinuity: ${v}
|
10
|
+
trackSwitch: ${L}
|
11
|
+
contiguous: ${I}
|
12
|
+
accurateTimeOffset: ${l}
|
13
|
+
timeOffset: ${m}
|
14
|
+
initSegmentChange: ${D}`);const _=new Jn(i,s,t,o,h);this.configureTransmuxer(_)}if(this.frag=r,this.part=n,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:g,chunkMeta:d,state:P},e instanceof ArrayBuffer?[e]:[]);else if(f){const _=f.push(e,g,d,P);Ze(_)?(f.async=!0,_.then(C=>{this.handleTransmuxComplete(C)}).catch(C=>{this.transmuxerError(C,d,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(_))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let i=t.flush(e);Ze(i)||t.async?(Ze(i)||(i=Promise.resolve(i)),i.then(r=>{this.handleFlushResult(r,e)}).catch(r=>{this.transmuxerError(r,e,"transmuxer-interface flush error")})):this.handleFlushResult(i,e)}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(x.ERROR,{type:K.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(t)}onWorkerMessage(e){const t=e.data,i=this.hls;switch(t.event){case"init":{var s;const r=(s=this.workerContext)==null?void 0:s.objectURL;r&&self.URL.revokeObjectURL(r);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":S[t.data.logType]&&S[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,i.trigger(t.event,t.data);break}}}configureTransmuxer(e){const{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const ia=250,et=2,sa=.1,ra=.05;class na{constructor(e,t,i,s){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=e,this.media=t,this.fragmentTracker=i,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:i,media:s,stalled:r}=this;if(s===null)return;const{currentTime:n,seeking:o}=s,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,n!==e){if(this.moved=!0,o||(this.nudgeRetry=0),r!==null){if(this.stallReported){const p=self.performance.now()-r;S.warn(`playback not stuck anymore @${n}, after ${Math.round(p)}ms`),this.stallReported=!1}this.stalled=null}return}if(d||l){this.stalled=null;return}if(s.paused&&!o||s.ended||s.playbackRate===0||!J.getBuffered(s).length){this.nudgeRetry=0;return}const h=J.bufferInfo(s,n,0),c=h.nextStart||0;if(o){const p=h.len>et,v=!c||t&&t.start<=n||c-n>et&&!this.fragmentTracker.getPartialFragment(n);if(p||v)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var u;if(!(h.len>0)&&!c)return;const v=Math.max(c,h.start||0)-n,L=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,b=(L==null||(u=L.details)==null?void 0:u.live)?L.details.targetduration*2:et,T=this.fragmentTracker.getPartialFragment(n);if(v>0&&(v<=b||T)){s.paused||this._trySkipBufferHole(T);return}}const f=self.performance.now();if(r===null){this.stalled=f;return}const m=f-r;if(!o&&m>=ia&&(this._reportStall(h),!this.media))return;const g=J.bufferInfo(s,n,i.maxBufferHole);this._tryFixBufferStall(g,m)}_tryFixBufferStall(e,t){const{config:i,fragmentTracker:s,media:r}=this;if(r===null)return;const n=r.currentTime,o=s.getPartialFragment(n);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>i.maxBufferHole||e.nextStart&&e.nextStart-n<i.maxBufferHole)&&t>i.highBufferWatchdogPeriod*1e3&&(S.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:i,stallReported:s}=this;if(!s&&i){this.stallReported=!0;const r=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(e)})`);S.warn(r.message),t.trigger(x.ERROR,{type:K.MEDIA_ERROR,details:R.BUFFER_STALLED_ERROR,fatal:!1,error:r,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:i,media:s}=this;if(s===null)return 0;const r=s.currentTime,n=J.bufferInfo(s,r,0),o=r<n.start?n.start:n.nextStart;if(o){const l=n.len<=t.maxBufferHole,d=n.len>0&&n.len<1&&s.readyState<3,h=o-r;if(h>0&&(l||d)){if(h>t.maxBufferHole){const{fragmentTracker:u}=this;let f=!1;if(r===0){const m=u.getAppendedFrag(0,z.MAIN);m&&o<m.end&&(f=!0)}if(!f){const m=e||u.getAppendedFrag(r,z.MAIN);if(m){let g=!1,p=m.end;for(;p<o;){const v=u.getPartialFragment(p);if(v)p+=v.duration;else{g=!0;break}}if(g)return 0}}}const c=Math.max(o+ra,r+sa);if(S.warn(`skipping hole, adjusting currentTime from ${r} to ${c}`),this.moved=!0,this.stalled=null,s.currentTime=c,e&&!e.gap){const u=new Error(`fragment loaded with buffer holes, seeking from ${r} to ${c}`);i.trigger(x.ERROR,{type:K.MEDIA_ERROR,details:R.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:u,reason:u.message,frag:e})}return c}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:i,nudgeRetry:s}=this;if(i===null)return;const r=i.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){const n=r+(s+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${r} to ${n}`);S.warn(o.message),i.currentTime=n,t.trigger(x.ERROR,{type:K.MEDIA_ERROR,details:R.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{const n=new Error(`Playhead still not moving while enough data buffered @${r} after ${e.nudgeMaxRetry} nudges`);S.error(n.message),t.trigger(x.ERROR,{type:K.MEDIA_ERROR,details:R.BUFFER_STALLED_ERROR,error:n,fatal:!0})}}}const aa=100;class oa extends pn{constructor(e,t,i){super(e,t,i,"[stream-controller]",z.MAIN),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:e}=this;e.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.LEVEL_LOADING,this.onLevelLoading,this),e.on(x.LEVEL_LOADED,this.onLevelLoaded,this),e.on(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(x.ERROR,this.onError,this),e.on(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(x.BUFFER_CREATED,this.onBufferCreated,this),e.on(x.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.LEVEL_LOADED,this.onLevelLoaded,this),e.off(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(x.ERROR,this.onError,this),e.off(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(x.BUFFER_CREATED,this.onBufferCreated,this),e.off(x.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:i}=this;if(this.stopLoad(),this.setInterval(aa),this.level=-1,!this.startFragRequested){let s=i.startLevel;s===-1&&(i.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=i.firstAutoLevel),i.nextLoadLevel=s,this.level=i.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=w.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=w.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case w.WAITING_LEVEL:{const{levels:t,level:i}=this,s=t?.[i],r=s?.details;if(r&&(!r.live||this.levelLastLoaded===s)){if(this.waitForCdnTuneIn(r))break;this.state=w.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=w.IDLE;break}break}case w.FRAG_LOADING_WAITING_RETRY:{var e;const t=self.performance.now(),i=this.retryDate;if(!i||t>=i||(e=this.media)!=null&&e.seeking){const{levels:s,level:r}=this,n=s?.[r];this.resetStartWhenNotLoaded(n||null),this.state=w.IDLE}}break}this.state===w.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:i,media:s}=this;if(t===null||!s&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const r=e.nextLoadLevel;if(!(i!=null&&i[r]))return;const n=i[r],o=this.getMainFwdBufferInfo();if(o===null)return;const l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){const g={};this.altAudio&&(g.type="video"),this.hls.trigger(x.BUFFER_EOS,g),this.state=w.ENDED;return}e.loadLevel!==r&&e.manualLevel===-1&&this.log(`Adapting to level ${r} from level ${this.level}`),this.level=e.nextLoadLevel=r;const d=n.details;if(!d||this.state===w.WAITING_LEVEL||d.live&&this.levelLastLoaded!==n){this.level=r,this.state=w.WAITING_LEVEL;return}const h=o.len,c=this.getMaxBufferLength(n.maxBitrate);if(h>=c)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const u=this.backtrackFragment?this.backtrackFragment.start:o.end;let f=this.getNextFragment(u,d);if(this.couldBacktrack&&!this.fragPrevious&&f&&f.sn!=="initSegment"&&this.fragmentTracker.getState(f)!==ne.OK){var m;const p=((m=this.backtrackFragment)!=null?m:f).sn-d.startSN,v=d.fragments[p-1];v&&f.cc===v.cc&&(f=v,this.fragmentTracker.removeFragment(v))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,u)){if(!f.gap){const p=this.audioOnly&&!this.altAudio?Q.AUDIO:Q.VIDEO,v=(p===Q.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,p,z.MAIN)}f=this.getNextFragmentLoopLoading(f,d,o,z.MAIN,c)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,n,u))}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===ne.NOT_LOADED||s===ne.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,i)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,z.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let i;const s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);const r=this.getLevelDetails();if(r!=null&&r.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<r.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?i=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:i=0}else i=0;const n=this.getBufferedFrag(t.currentTime+i);if(n){const o=this.followingBufferedFrag(n);if(o){this.abortCurrentFrag();const l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,h=Math.max(n.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(h,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case w.KEY_LOADING:case w.FRAG_LOADING:case w.FRAG_LOADING_WAITING_RETRY:case w.PARSING:case w.PARSED:this.state=w.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const i=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new na(this.config,i,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.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 e=this.media,t=e?e.currentTime:null;k(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const i=this.getMainFwdBufferInfo();if(i===null||i.len===0){this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(x.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let i=!1,s=!1;t.levels.forEach(r=>{const n=r.audioCodec;n&&(i=i||n.indexOf("mp4a.40.2")!==-1,s=s||n.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=i&&s&&!vn(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:i}=this;if(!i||this.state!==w.IDLE)return;const s=i[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(s.details))&&(this.state=w.WAITING_LEVEL)}onLevelLoaded(e,t){var i;const{levels:s}=this,r=t.level,n=t.details,o=n.totalduration;if(!s){this.warn(`Levels were reset while loading level ${r}`);return}this.log(`Level ${r} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""}, cc [${n.startCC}, ${n.endCC}] duration:${o}`);const l=s[r],d=this.fragCurrent;d&&(this.state===w.FRAG_LOADING||this.state===w.FRAG_LOADING_WAITING_RETRY)&&d.level!==t.level&&d.loader&&this.abortCurrentFrag();let h=0;if(n.live||(i=l.details)!=null&&i.live){var c;if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;h=this.alignPlaylists(n,l.details,(c=this.levelLastLoaded)==null?void 0:c.details)}if(l.details=n,this.levelLastLoaded=l,this.hls.trigger(x.LEVEL_UPDATED,{details:n,level:r}),this.state===w.WAITING_LEVEL){if(this.waitForCdnTuneIn(n))return;this.state=w.IDLE}this.startFragRequested?n.live&&this.synchronizeToLiveEdge(n):this.setStartPosition(n,h),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:i,part:s,payload:r}=e,{levels:n}=this;if(!n){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const o=n[i.level],l=o.details;if(!l){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const d=o.videoCodec,h=l.PTSKnown||!l.live,c=(t=i.initSegment)==null?void 0:t.data,u=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new ta(this.hls,z.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=s?s.index:-1,g=m!==-1,p=new ki(i.level,i.sn,i.stats.chunkCount,r.byteLength,m,g),v=this.initPTS[i.cc];f.push(r,c,u,d,i,s,l.totalduration,h,p,v)}onAudioTrackSwitching(e,t){const i=this.altAudio;if(!!!t.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 n=this.fragCurrent;n&&(this.log("Switching to main audio track, cancel main fragment load"),n.abortRequests(),this.fragmentTracker.removeFragment(n)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const r=this.hls;i&&(r.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),r.trigger(x.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=t.id,s=!!this.hls.audioTracks[i].url;if(s){const r=this.videoBuffer;r&&this.mediaBuffer!==r&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=r)}this.altAudio=s,this.tick()}onBufferCreated(e,t){const i=t.tracks;let s,r,n=!1;for(const o in i){const l=i[o];if(l.id==="main"){if(r=o,s=l,o==="video"){const d=i[o];d&&(this.videoBuffer=d.buffer)}}else n=!0}n&&s?(this.log(`Alternate track found, use ${r}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:i,part:s}=t;if(i&&i.type!==z.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===w.PARSED&&(this.state=w.IDLE);return}const r=s?s.stats:i.stats;this.fragLastKbps=Math.round(8*r.total/(r.buffering.end-r.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,s)}onError(e,t){var i;if(t.fatal){this.state=w.ERROR;return}switch(t.details){case R.FRAG_GAP:case R.FRAG_PARSING_ERROR:case R.FRAG_DECRYPT_ERROR:case R.FRAG_LOAD_ERROR:case R.FRAG_LOAD_TIMEOUT:case R.KEY_LOAD_ERROR:case R.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(z.MAIN,t);break;case R.LEVEL_LOAD_ERROR:case R.LEVEL_LOAD_TIMEOUT:case R.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===w.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===j.LEVEL&&(this.state=w.IDLE);break;case R.BUFFER_APPEND_ERROR:case R.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===R.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case R.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!J.getBuffered(e).length){const i=this.state!==w.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,i)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=w.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Q.AUDIO||this.audioOnly&&!this.altAudio){const i=(t===Q.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,t,z.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}const s=J.getBuffered(e),n=(s.length?s.start(0):0)-i;n>0&&(n<this.config.maxBufferHole||n<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${n} to match buffer start`),i+=n,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${t}`),e.currentTime=i}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(i=>{const{hls:s}=this;if(!i||this.fragContextChanged(e))return;t.fragmentError=0,this.state=w.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const r=e.stats;r.parsing.start=r.parsing.end=r.buffering.start=r.buffering.end=self.performance.now(),s.trigger(x.FRAG_LOADED,i),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const i="main",{hls:s}=this,{remuxResult:r,chunkMeta:n}=e,o=this.getCurrentContext(n);if(!o){this.resetWhenMissingContext(n);return}const{frag:l,part:d,level:h}=o,{video:c,text:u,id3:f,initSegment:m}=r,{details:g}=h,p=this.altAudio?void 0:r.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=w.PARSING,m){if(m!=null&&m.tracks){const y=l.initSegment||l;this._bufferInitSegment(h,m.tracks,y,n),s.trigger(x.FRAG_PARSING_INIT_SEGMENT,{frag:y,id:i,tracks:m.tracks})}const v=m.initPTS,L=m.timescale;k(v)&&(this.initPTS[l.cc]={baseTime:v,timescale:L},s.trigger(x.INIT_PTS_FOUND,{frag:l,id:i,initPTS:v,timescale:L}))}if(c&&g&&l.sn!=="initSegment"){const v=g.fragments[l.sn-1-g.startSN],L=l.sn===g.startSN,y=!v||l.cc>v.cc;if(r.independent!==!1){const{startPTS:b,endPTS:T,startDTS:I,endDTS:A}=c;if(d)d.elementaryStreams[c.type]={startPTS:b,endPTS:T,startDTS:I,endDTS:A};else if(c.firstKeyFrame&&c.independent&&n.id===1&&!y&&(this.couldBacktrack=!0),c.dropped&&c.independent){const D=this.getMainFwdBufferInfo(),P=(D?D.end:this.getLoadPosition())+this.config.maxBufferHole,_=c.firstKeyFramePTS?c.firstKeyFramePTS:b;if(!L&&P<_-this.config.maxBufferHole&&!y){this.backtrack(l);return}else y&&(l.gap=!0);l.setElementaryStreamInfo(c.type,l.start,T,l.start,A,!0)}else L&&b>et&&(l.gap=!0);l.setElementaryStreamInfo(c.type,b,T,I,A),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(c,l,d,n,L||y)}else if(L||y)l.gap=!0;else{this.backtrack(l);return}}if(p){const{startPTS:v,endPTS:L,startDTS:y,endDTS:b}=p;d&&(d.elementaryStreams[Q.AUDIO]={startPTS:v,endPTS:L,startDTS:y,endDTS:b}),l.setElementaryStreamInfo(Q.AUDIO,v,L,y,b),this.bufferFragmentData(p,l,d,n)}if(g&&f!=null&&(t=f.samples)!=null&&t.length){const v={id:i,frag:l,details:g,samples:f.samples};s.trigger(x.FRAG_PARSING_METADATA,v)}if(g&&u){const v={id:i,frag:l,details:g,samples:u.samples};s.trigger(x.FRAG_PARSING_USERDATA,v)}}_bufferInitSegment(e,t,i,s){if(this.state!==w.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:r,video:n,audiovideo:o}=t;if(r){let l=e.audioCodec;const d=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),r.metadata.channelCount!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")),l&&l.indexOf("mp4a.40.5")!==-1&&d.indexOf("android")!==-1&&r.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),r.levelCodec=l,r.id="main",this.log(`Init audio buffer, container:${r.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${r.codec}]`)}n&&(n.levelCodec=e.videoCodec,n.id="main",this.log(`Init video buffer, container:${n.container}, codecs[level/parsed]=[${e.videoCodec||""}/${n.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(x.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{const h=t[l].initSegment;h!=null&&h.byteLength&&this.hls.trigger(x.BUFFER_APPENDING,{type:l,data:h,frag:i,part:null,chunkMeta:s,parent:i.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,z.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=w.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(J.isBuffered(e,i)?t=this.getAppendedFrag(i):J.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;const s=this.fragPlaying,r=t.level;(!s||t.sn!==s.sn||s.level!==r)&&(this.fragPlaying=t,this.hls.trigger(x.FRAG_CHANGED,{frag:t}),(!s||s.level!==r)&&this.hls.trigger(x.LEVEL_SWITCHED,{level:r}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,i=this.currentFrag;if(i&&k(t)&&k(i.programDateTime)){const s=i.programDateTime+(t-i.start)*1e3;return new Date(s)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class Se{static get version(){return"1.5.8"}static isMSESupported(){return Ui()}static isSupported(){return xn()}static getMediaSource(){return Re()}static get Events(){return x}static get ErrorTypes(){return K}static get ErrorDetails(){return R}static get DefaultConfig(){return Se.defaultConfig?Se.defaultConfig:_i}static set DefaultConfig(e){Se.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new as,this._autoLevelCapping=-1,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,this.triggeringException=void 0,ms(e.debug||!1,"Hls instance");const t=this.config=Qr(Se.DefaultConfig,e);this.userConfig=e,t.progressive&&Jr(t);const{abrController:i,bufferController:s,capLevelController:r,errorController:n,fpsController:o}=t,l=new n(this),d=this.abrController=new i(this),h=this.bufferController=new s(this),c=this.capLevelController=new r(this),u=new o(this),f=new er(this),m=new lr(this),g=t.contentSteeringController,p=g?new g(this):null,v=this.levelController=new Zr(this,p),L=new en(this),y=new sn(this.config),b=this.streamController=new oa(this,L,y);c.setStreamController(b),u.setStreamController(b);const T=[f,v,b];p&&T.splice(1,0,p),this.networkControllers=T;const I=[d,h,c,u,m,L];this.audioTrackController=this.createController(t.audioTrackController,T);const A=t.audioStreamController;A&&T.push(new A(this,L,y)),this.subtitleTrackController=this.createController(t.subtitleTrackController,T);const D=t.subtitleStreamController;D&&T.push(new D(this,L,y)),this.createController(t.timelineController,I),y.emeController=this.emeController=this.createController(t.emeController,I),this.cmcdController=this.createController(t.cmcdController,I),this.latencyController=this.createController(dr,I),this.coreComponents=I,T.push(l);const P=l.onErrorOut;typeof P=="function"&&this.on(x.ERROR,P,l)}createController(e,t){if(e){const i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,s){this._emitter.off(e,t,i,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(S.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=!0;const s=e===x.ERROR;this.trigger(x.ERROR,{type:K.OTHER_ERROR,details:R.INTERNAL_EXCEPTION,fatal:s,event:e,error:i}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){S.log("destroy"),this.trigger(x.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 e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){S.log("attachMedia"),this._media=e,this.trigger(x.MEDIA_ATTACHING,{media:e})}detachMedia(){S.log("detachMedia"),this.trigger(x.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,i=this.url,s=this.url=it.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,S.log(`loadSource:${s}`),t&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(x.MANIFEST_LOADING,{url:e})}startLoad(e=-1){S.log(`startLoad(${e})`),this.started=!0,this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){S.log("stopLoad"),this.started=!1,this.networkControllers.forEach(e=>{e.stopLoad()})}resumeBuffering(){this.started&&this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.startLoad(-1)})}pauseBuffering(){this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.stopLoad()})}swapAudioCodec(){S.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){S.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){S.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){S.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){S.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){S.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){S.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(S.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){hr(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const i=e.length;for(let s=0;s<i;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this;let s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,i)for(let r=s;r--;){const n=e[r].attrs["HDCP-LEVEL"];if(n&&n<=i)return r}return s}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}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}}Se.defaultConfig=void 0,Fe.KeySystemFormats,Fe.KeySystems,Fe.SubtitleStreamController,Fe.TimelineController;export{Se as Hls,Se as default};
|