zwplayer-vue2x 1.0.28 → 1.0.30

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.
@@ -1,2 +1,2 @@
1
- !function t(e){var r,i;r=this,i=function(){"use strict";function r(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function i(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?r(Object(i),!0).forEach((function(e){s(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function a(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,v(i.key),i)}}function n(t,e,r){return e&&a(t.prototype,e),r&&a(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,r){return(e=v(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(){return o=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},o.apply(this,arguments)}function l(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,d(t,e)}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}function d(t,e){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},d(t,e)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function f(t,e,r){return f=h()?Reflect.construct.bind():function(t,e,r){var i=[null];i.push.apply(i,e);var a=new(Function.bind.apply(t,i));return r&&d(a,r.prototype),a},f.apply(null,arguments)}function c(t){var e="function"==typeof Map?new Map:void 0;return c=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,i)}function i(){return f(t,arguments,u(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),d(i,t)},c(t)}function v(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function g(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var m={exports:{}};!function(t,e){var r,i,a,n,s;r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,a=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(t,e,r){if(r=r||{},t=t.trim(),!(e=e.trim())){if(!r.alwaysNormalize)return t;var a=s.parseURL(t);if(!a)throw new Error("Error trying to parse base URL.");return a.path=s.normalizePath(a.path),s.buildURLFromParts(a)}var n=s.parseURL(e);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=s.normalizePath(n.path),s.buildURLFromParts(n)):e;var o=s.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=i.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(u.netLoc=o.netLoc,"/"!==n.path[0]))if(n.path){var d=o.path,h=d.substring(0,d.lastIndexOf("/")+1)+n.path;u.path=s.normalizePath(h)}else u.path=o.path,n.params||(u.params=o.params,n.query||(u.query=o.query));return null===u.path&&(u.path=r.alwaysNormalize?s.normalizePath(n.path):n.path),s.buildURLFromParts(u)},parseURL:function(t){var e=r.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(a,"");t.length!==(t=t.replace(n,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}},t.exports=s}(m);var p=m.exports,y=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},E=function(t){return t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached",t}({}),T=function(t){return t.NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError",t}({}),S=function(t){return t.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",t.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",t.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",t.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_PARSING_ERROR="levelParsingError",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.FRAG_GAP="fragGap",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown",t}({}),L=function(){},R={trace:L,debug:L,log:L,warn:L,info:L,error:L},b=R;function A(t){var e=self.console[t];return e?e.bind(self.console,"["+t+"] >"):L}function k(t,e){if(self.console&&!0===t||"object"==typeof t){!function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];r.forEach((function(e){b[e]=t[e]?t[e].bind(t):A(e)}))}(t,"debug","log","info","warn","error");try{b.log('Debug logs enabled for "'+e+'" in hls.js version '+void 0)}catch(t){b=R}}else b=R}var D=b,_=/^(\d+)x(\d+)$/,x=/(.+?)=(".*?"|.*?)(?:,|$)/g,w=function(){function t(e){for(var r in"string"==typeof e&&(e=t.parseAttrList(e)),e)e.hasOwnProperty(r)&&("X-"===r.substring(0,2)&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(r)),this[r]=e[r])}var e=t.prototype;return e.decimalInteger=function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.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},e.hexadecimalIntegerAsNumber=function(t){var e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.decimalFloatingPoint=function(t){return parseFloat(this[t])},e.optionalFloat=function(t,e){var r=this[t];return r?parseFloat(r):e},e.enumeratedString=function(t){return this[t]},e.bool=function(t){return"YES"===this[t]},e.decimalResolution=function(t){var e=_.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},t.parseAttrList=function(t){var e,r={};for(x.lastIndex=0;null!==(e=x.exec(t));){var i=e[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[e[1].trim()]=i}return r},t}();function I(t){return"SCTE35-OUT"===t||"SCTE35-IN"===t}var C=function(){function t(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){var r=e.attr;for(var i in r)if(Object.prototype.hasOwnProperty.call(t,i)&&t[i]!==r[i]){D.warn('DATERANGE tag attribute: "'+i+'" does not match for tags with ID: "'+t.ID+'"'),this._badValueForSameId=i;break}t=o(new w({}),r,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){var a=new Date(this.attr["END-DATE"]);y(a.getTime())&&(this._endDate=a)}}return n(t,[{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 t=this.duration;return null!==t?new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var t=this.attr.decimalFloatingPoint("DURATION");if(y(t))return t}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&&y(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),t}(),P=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}},F="audio",O="video",M="audiovideo",N=function(){function t(t){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[F]=null,e[O]=null,e[M]=null,e),this.baseurl=t}return t.prototype.setByteRange=function(t,e){var r=t.split("@",2),i=[];1===r.length?i[0]=e?e.byteRangeEndOffset:0:i[0]=parseInt(r[1]),i[1]=parseInt(r[0])+i[0],this._byteRange=i},n(t,[{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=p.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}]),t}(),B=function(t){function e(e,r){var i;return(i=t.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 P,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.gap=void 0,i.type=e,i}l(e,t);var r=e.prototype;return r.setKeyFormat=function(t){if(this.levelkeys){var e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}},r.abortRequests=function(){var t,e;null==(t=this.loader)||t.abort(),null==(e=this.keyLoader)||e.abort()},r.setElementaryStreamInfo=function(t,e,r,i,a,n){void 0===n&&(n=!1);var s=this.elementaryStreams,o=s[t];o?(o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,a)):s[t]={startPTS:e,endPTS:r,startDTS:i,endDTS:a,partial:n}},r.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[F]=null,t[O]=null,t[M]=null},n(e,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{var e=Object.keys(this.levelkeys);if(1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!y(this.programDateTime))return null;var t=y(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;if(null!=(t=this._decryptdata)&&t.encrypted)return!0;if(this.levelkeys){var e=Object.keys(this.levelkeys),r=e.length;if(r>1||1===r&&this.levelkeys[e[0]].encrypted)return!0}return!1}}]),e}(N),U=function(t){function e(e,r,i,a,n){var s;(s=t.call(this,i)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.stats=new P,s.duration=e.decimalFloatingPoint("DURATION"),s.gap=e.bool("GAP"),s.independent=e.bool("INDEPENDENT"),s.relurl=e.enumeratedString("URI"),s.fragment=r,s.index=a;var o=e.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,n),n&&(s.fragOffset=n.fragOffset+n.duration),s}return l(e,t),n(e,[{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)}}]),e}(N),G=function(){function t(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}return t.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!r||!!e,this.advanced=this.endSN>t.endSN||e>0||0===e&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay},n(t,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&y(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return null!=(t=this.fragments)&&t.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 t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),t}(),H=g(void 0);function K(t,e,r){return Uint8Array.prototype.slice?t.slice(e,r):new Uint8Array(Array.prototype.slice.call(t,e,r))}var V,W=function(t,e){return e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},Y=function(t,e){return e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},j=function(t,e){for(var r=e,i=0;W(t,e);)i+=10,i+=q(t,e+6),Y(t,e+10)&&(i+=10),e+=i;if(i>0)return t.subarray(r,r+i)},q=function(t,e){var r=0;return r=(127&t[e])<<21,r|=(127&t[e+1])<<14,r|=(127&t[e+2])<<7,r|=127&t[e+3]},z=function(t,e){return W(t,e)&&q(t,e+6)+10<=t.length-e},X=function(t){return t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info},Q=function(t){var e=String.fromCharCode(t[0],t[1],t[2],t[3]),r=q(t,4);return{type:e,size:r,data:t.subarray(10,10+r)}},$=function(t){for(var e=0,r=[];W(t,e);){for(var i=q(t,e+6),a=(e+=10)+i;e+8<a;){var n=Q(t.subarray(e)),s=Z(n);s&&r.push(s),e+=n.size+10}Y(t,e)&&(e+=10)}return r},Z=function(t){return"PRIV"===t.type?J(t):"W"===t.type[0]?et(t):tt(t)},J=function(t){if(!(t.size<2)){var e=it(t.data,!0),r=new Uint8Array(t.data.subarray(e.length+1));return{key:t.type,info:e,data:r.buffer}}},tt=function(t){if(!(t.size<2)){if("TXXX"===t.type){var e=1,r=it(t.data.subarray(e),!0);e+=r.length+1;var i=it(t.data.subarray(e));return{key:t.type,info:r,data:i}}var a=it(t.data.subarray(1));return{key:t.type,data:a}}},et=function(t){if("WXXX"===t.type){if(t.size<2)return;var e=1,r=it(t.data.subarray(e),!0);e+=r.length+1;var i=it(t.data.subarray(e));return{key:t.type,info:r,data:i}}var a=it(t.data);return{key:t.type,data:a}},rt=function(t){if(8===t.data.byteLength){var e=new Uint8Array(t.data),r=1&e[3],i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},it=function(t,e){void 0===e&&(e=!1);var r=at();if(r){var i=r.decode(t);if(e){var a=i.indexOf("\0");return-1!==a?i.substring(0,a):i}return i.replace(/\0/g,"")}for(var n,s,o,l=t.length,u="",d=0;d<l;){if(0===(n=t[d++])&&e)return u;if(0!==n&&3!==n)switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(n);break;case 12:case 13:s=t[d++],u+=String.fromCharCode((31&n)<<6|63&s);break;case 14:s=t[d++],o=t[d++],u+=String.fromCharCode((15&n)<<12|(63&s)<<6|(63&o)<<0)}}return u};function at(){return V||void 0===self.TextDecoder||(V=new self.TextDecoder("utf-8")),V}var nt=function(t){for(var e="",r=0;r<t.length;r++){var i=t[r].toString(16);i.length<2&&(i="0"+i),e+=i}return e},st=Math.pow(2,32)-1,ot=[].push,lt={video:1,audio:2,id3:3,text:4};function ut(t){return String.fromCharCode.apply(null,t)}function dt(t,e){var r=t[e]<<8|t[e+1];return r<0?65536+r:r}function ht(t,e){var r=ft(t,e);return r<0?4294967296+r:r}function ft(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function ct(t,e,r){t[e]=r>>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r}function vt(t,e){var r=[];if(!e.length)return r;for(var i=t.byteLength,a=0;a<i;){var n=ht(t,a),s=n>1?a+n:i;if(ut(t.subarray(a+4,a+8))===e[0])if(1===e.length)r.push(t.subarray(a+8,s));else{var o=vt(t.subarray(a+8,s),e.slice(1));o.length&&ot.apply(r,o)}a=s}return r}function gt(t){var e=[],r=t[0],i=8,a=ht(t,i);i+=4,i+=0===r?8:16,i+=2;var n=t.length+0,s=dt(t,i);i+=2;for(var o=0;o<s;o++){var l=i,u=ht(t,l);l+=4;var d=2147483647&u;if(1==(2147483648&u)>>>31)return D.warn("SIDX has hierarchical references (not supported)"),null;var h=ht(t,l);l+=4,e.push({referenceSize:d,subsegmentDuration:h,info:{duration:h/a,start:n,end:n+d-1}}),n+=d,i=l+=4}return{earliestPresentationTime:0,timescale:a,version:r,referencesCount:s,references:e}}function mt(t){for(var e=[],r=vt(t,["moov","trak"]),i=0;i<r.length;i++){var a=r[i],n=vt(a,["tkhd"])[0];if(n){var s=n[0],o=0===s?12:20,l=ht(n,o),u=vt(a,["mdia","mdhd"])[0];if(u){var d=ht(u,o=0===(s=u[0])?12:20),h=vt(a,["mdia","hdlr"])[0];if(h){var f=ut(h.subarray(8,12)),c={soun:F,vide:O}[f];if(c){var v=vt(a,["mdia","minf","stbl","stsd"])[0],g=void 0;v&&(g=ut(v.subarray(12,16))),e[l]={timescale:d,type:c},e[c]={timescale:d,id:l,codec:g}}}}}}return vt(t,["moov","mvex","trex"]).forEach((function(t){var r=ht(t,4),i=e[r];i&&(i.default={duration:ht(t,12),flags:ht(t,20)})})),e}function pt(t,e){if(!t||!e)return t;var r=e.keyId;return r&&e.isCommonEncryption&&vt(t,["moov","trak"]).forEach((function(t){var e=vt(t,["mdia","minf","stbl","stsd"])[0].subarray(8),i=vt(e,["enca"]),a=i.length>0;a||(i=vt(e,["encv"])),i.forEach((function(t){vt(a?t.subarray(28):t.subarray(78),["sinf"]).forEach((function(t){var e=function(t){var e=vt(t,["schm"])[0];if(e){var r=ut(e.subarray(4,8));if("cbcs"===r||"cenc"===r)return vt(t,["schi","tenc"])[0]}return D.error("[eme] missing 'schm' box"),null}(t);if(e){var i=e.subarray(8,24);i.some((function(t){return 0!==t}))||(D.log("[eme] Patching keyId in 'enc"+(a?"a":"v")+">sinf>>tenc' box: "+nt(i)+" -> "+nt(r)),e.set(r,8))}}))}))})),t}function yt(t){var e=ht(t,0),r=8;1&e&&(r+=4),4&e&&(r+=4);for(var i=0,a=ht(t,4),n=0;n<a;n++)256&e&&(i+=ht(t,r),r+=4),512&e&&(r+=4),1024&e&&(r+=4),2048&e&&(r+=4);return i}function Et(t,e){var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}function Tt(t,e){var r=[],i=e.samples,a=e.timescale,n=e.id,s=!1;return vt(i,["moof"]).map((function(o){var l=o.byteOffset-8;vt(o,["traf"]).map((function(o){var u=vt(o,["tfdt"]).map((function(t){var e=t[0],r=ht(t,4);return 1===e&&(r*=Math.pow(2,32),r+=ht(t,8)),r/a}))[0];return void 0!==u&&(t=u),vt(o,["tfhd"]).map((function(u){var d=ht(u,4),h=16777215&ht(u,0),f=0,c=0!=(16&h),v=0,g=0!=(32&h),m=8;d===n&&(0!=(1&h)&&(m+=8),0!=(2&h)&&(m+=4),0!=(8&h)&&(f=ht(u,m),m+=4),c&&(v=ht(u,m),m+=4),g&&(m+=4),"video"===e.type&&(s=function(t){if(!t)return!1;var e=t.indexOf("."),r=e<0?t:t.substring(0,e);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(e.codec)),vt(o,["trun"]).map((function(n){var o=n[0],u=16777215&ht(n,0),d=0!=(1&u),h=0,c=0!=(4&u),g=0!=(256&u),m=0,p=0!=(512&u),y=0,E=0!=(1024&u),T=0!=(2048&u),S=0,L=ht(n,4),R=8;d&&(h=ht(n,R),R+=4),c&&(R+=4);for(var b=h+l,A=0;A<L;A++){if(g?(m=ht(n,R),R+=4):m=f,p?(y=ht(n,R),R+=4):y=v,E&&(R+=4),T&&(S=0===o?ht(n,R):ft(n,R),R+=4),e.type===O)for(var k=0;k<y;){var D=ht(i,b);St(s,i[b+=4])&&Lt(i.subarray(b,b+D),s?2:1,t+S/a,r),b+=D,k+=D+4}t+=m/a}})))}))}))})),r}function St(t,e){if(t){var r=e>>1&63;return 39===r||40===r}return 6==(31&e)}function Lt(t,e,r,i){var a=Rt(t),n=0;n+=e;for(var s=0,o=0,l=!1,u=0;n<a.length;){s=0;do{if(n>=a.length)break;s+=u=a[n++]}while(255===u);o=0;do{if(n>=a.length)break;o+=u=a[n++]}while(255===u);var d=a.length-n;if(!l&&4===s&&n<a.length){if(l=!0,181===a[n++]){var h=dt(a,n);if(n+=2,49===h){var f=ht(a,n);if(n+=4,1195456820===f){var c=a[n++];if(3===c){var v=a[n++],g=64&v,m=g?2+3*(31&v):0,p=new Uint8Array(m);if(g){p[0]=v;for(var y=1;y<m;y++)p[y]=a[n++]}i.push({type:c,payloadType:s,pts:r,bytes:p})}}}}}else if(5===s&&o<d){if(l=!0,o>16){for(var E=[],T=0;T<16;T++){var S=a[n++].toString(16);E.push(1==S.length?"0"+S:S),3!==T&&5!==T&&7!==T&&9!==T||E.push("-")}for(var L=o-16,R=new Uint8Array(L),b=0;b<L;b++)R[b]=a[n++];i.push({payloadType:s,pts:r,uuid:E.join(""),userData:it(R),userDataBytes:R})}}else if(o<d)n+=o;else if(o>d)break}}function Rt(t){for(var e=t.byteLength,r=[],i=1;i<e-2;)0===t[i]&&0===t[i+1]&&3===t[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return t;var a=e-r.length,n=new Uint8Array(a),s=0;for(i=0;i<a;s++,i++)s===r[0]&&(s++,r.shift()),n[i]=t[s];return n}var bt=function(){function t(t,e,r,i,a){void 0===i&&(i=[1]),void 0===a&&(a=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=a,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&"AES-128"!==t}t.clearKeyUriToKeyIdMap=function(){};var e=t.prototype;return e.isSupported=function(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method}return!1},e.getDecryptData=function(e){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof e&&("AES-128"!==this.method||this.iv||D.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var r=function(t){for(var e=new Uint8Array(16),r=12;r<16;r++)e[r]=t>>8*(15-r)&255;return e}(e);return new t(this.method,this.uri,"identity",this.keyFormatVersions,r)}return this},t}(),At={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function kt(t,e){return MediaSource.isTypeSupported((e||"video")+'/mp4;codecs="'+t+'"')}var Dt=/#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,_t=/#EXT-X-MEDIA:(.*)/g,xt=/^#EXT(?:INF|-X-TARGETDURATION):/m,wt=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),It=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),Ct=function(){function t(){}return t.findGroup=function(t,e){for(var r=0;r<t.length;r++){var i=t[r];if(i.id===e)return i}},t.convertAVC1ToAVCOTI=function(t){var e=t.split(".");if(e.length>2){var r=e.shift()+".";return r+=parseInt(e.shift()).toString(16),r+=("000"+parseInt(e.shift()).toString(16)).slice(-4)}return t},t.resolve=function(t,e){return p.buildAbsoluteURL(e,t,{alwaysNormalize:!0})},t.isMediaPlaylist=function(t){return xt.test(t)},t.parseMasterPlaylist=function(e,r){var i,a={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:!1},n=[];for(Dt.lastIndex=0;null!=(i=Dt.exec(e));)if(i[1]){var s,o=new w(i[1]),l=i[2],u={attrs:o,bitrate:o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),name:o.NAME,url:t.resolve(l,r)},d=o.decimalResolution("RESOLUTION");d&&(u.width=d.width,u.height=d.height),Ot((o.CODECS||"").split(/[ ,]+/).filter((function(t){return t})),u),u.videoCodec&&-1!==u.videoCodec.indexOf("avc1")&&(u.videoCodec=t.convertAVC1ToAVCOTI(u.videoCodec)),null!=(s=u.unknownCodecs)&&s.length||n.push(u),a.levels.push(u)}else if(i[3]){var h=i[3],f=i[4];switch(h){case"SESSION-DATA":var c=new w(f),v=c["DATA-ID"];v&&(null===a.sessionData&&(a.sessionData={}),a.sessionData[v]=c);break;case"SESSION-KEY":var g=Pt(f,r);g.encrypted&&g.isSupported()?(null===a.sessionKeys&&(a.sessionKeys=[]),a.sessionKeys.push(g)):D.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+f+'"');break;case"DEFINE":break;case"CONTENT-STEERING":var m=new w(f);a.contentSteering={uri:t.resolve(m["SERVER-URI"],r),pathwayId:m["PATHWAY-ID"]||"."};break;case"START":a.startTimeOffset=Ft(f)}}var p=n.length>0&&n.length<a.levels.length;return a.levels=p?n:a.levels,0===a.levels.length&&(a.playlistParsingError=new Error("no levels found in manifest")),a},t.parseMasterPlaylistMedia=function(e,r,i){var a,n={},s=i.levels,o={AUDIO:s.map((function(t){return{id:t.attrs.AUDIO,audioCodec:t.audioCodec}})),SUBTITLES:s.map((function(t){return{id:t.attrs.SUBTITLES,textCodec:t.textCodec}})),"CLOSED-CAPTIONS":[]},l=0;for(_t.lastIndex=0;null!==(a=_t.exec(e));){var u=new w(a[1]),d=u.TYPE;if(d){var h=o[d],f=n[d]||[];n[d]=f;var c={attrs:u,bitrate:0,id:l++,groupId:u["GROUP-ID"]||"",instreamId:u["INSTREAM-ID"],name:u.NAME||u.LANGUAGE||"",type:d,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:u.LANGUAGE,url:u.URI?t.resolve(u.URI,r):""};if(null!=h&&h.length){var v=t.findGroup(h,c.groupId)||h[0];Mt(c,v,"audioCodec"),Mt(c,v,"textCodec")}f.push(c)}}return n},t.parseLevelPlaylist=function(t,e,r,i,a,n){var s,l,u,d=new G(e),h=d.fragments,f=null,c=0,v=0,g=0,m=0,p=null,E=new B(i,e),T=-1,S=!1;for(wt.lastIndex=0,d.m3u8=t,d.hasVariableRefs=!1;null!==(s=wt.exec(t));){S&&(S=!1,(E=new B(i,e)).start=g,E.sn=c,E.cc=m,E.level=r,f&&(E.initSegment=f,E.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null));var L=s[1];if(L){E.duration=parseFloat(L);var R=(" "+s[2]).slice(1);E.title=R||null,E.tagList.push(R?["INF",L,R]:["INF",L])}else if(s[3]){if(y(E.duration)){E.start=g,u&&Ut(E,u,d),E.sn=c,E.level=r,E.cc=m,E.urlId=a,h.push(E);var b=(" "+s[3]).slice(1);E.relurl=b,Nt(E,p),p=E,g+=E.duration,c++,v=0,S=!0}}else if(s[4]){var A=(" "+s[4]).slice(1);p?E.setByteRange(A,p):E.setByteRange(A)}else if(s[5])E.rawProgramDateTime=(" "+s[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),-1===T&&(T=h.length);else{if(!(s=s[0].match(It))){D.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<s.length&&void 0===s[l];l++);var k=(" "+s[l]).slice(1),_=(" "+s[l+1]).slice(1),x=s[l+2]?(" "+s[l+2]).slice(1):"";switch(k){case"PLAYLIST-TYPE":d.type=_.toUpperCase();break;case"MEDIA-SEQUENCE":c=d.startSN=parseInt(_);break;case"SKIP":var I=new w(_),P=I.decimalInteger("SKIPPED-SEGMENTS");if(y(P)){d.skippedSegments=P;for(var F=P;F--;)h.unshift(null);c+=P}var O=I.enumeratedString("RECENTLY-REMOVED-DATERANGES");O&&(d.recentlyRemovedDateranges=O.split("\t"));break;case"TARGETDURATION":d.targetduration=Math.max(parseInt(_),1);break;case"VERSION":d.version=parseInt(_);break;case"EXTM3U":case"DEFINE":break;case"ENDLIST":d.live=!1;break;case"#":(_||x)&&E.tagList.push(x?[_,x]:[_]);break;case"DISCONTINUITY":m++,E.tagList.push(["DIS"]);break;case"GAP":E.gap=!0,E.tagList.push([k]);break;case"BITRATE":E.tagList.push([k,_]);break;case"DATERANGE":var M=new w(_),N=new C(M,d.dateRanges[M.ID]);N.isValid||d.skippedSegments?d.dateRanges[N.id]=N:D.warn('Ignoring invalid DATERANGE tag: "'+_+'"'),E.tagList.push(["EXT-X-DATERANGE",_]);break;case"DISCONTINUITY-SEQUENCE":m=parseInt(_);break;case"KEY":var H=Pt(_,e);if(H.isSupported()){if("NONE"===H.method){u=void 0;break}u||(u={}),u[H.keyFormat]&&(u=o({},u)),u[H.keyFormat]=H}else D.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+_+'"');break;case"START":d.startTimeOffset=Ft(_);break;case"MAP":var K=new w(_);if(E.duration){var V=new B(i,e);Bt(V,K,r,u),f=V,E.initSegment=f,f.rawProgramDateTime&&!E.rawProgramDateTime&&(E.rawProgramDateTime=f.rawProgramDateTime)}else Bt(E,K,r,u),f=E,S=!0;break;case"SERVER-CONTROL":var W=new w(_);d.canBlockReload=W.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=W.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&W.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=W.optionalFloat("PART-HOLD-BACK",0),d.holdBack=W.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Y=new w(_);d.partTarget=Y.decimalFloatingPoint("PART-TARGET");break;case"PART":var j=d.partList;j||(j=d.partList=[]);var q=v>0?j[j.length-1]:void 0,z=v++,X=new w(_),Q=new U(X,E,e,z,q);j.push(Q),E.duration+=Q.duration;break;case"PRELOAD-HINT":var $=new w(_);d.preloadHint=$;break;case"RENDITION-REPORT":var Z=new w(_);d.renditionReports=d.renditionReports||[],d.renditionReports.push(Z);break;default:D.warn("line parsed but not handled: "+s)}}}p&&!p.relurl?(h.pop(),g-=p.duration,d.partList&&(d.fragmentHint=p)):d.partList&&(Nt(E,p),E.cc=m,d.fragmentHint=E,u&&Ut(E,u,d));var J=h.length,tt=h[0],et=h[J-1];if((g+=d.skippedSegments*d.targetduration)>0&&J&&et){d.averagetargetduration=g/J;var rt=et.sn;d.endSN="initSegment"!==rt?rt:0,d.live||(et.endList=!0),tt&&(d.startCC=tt.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(g+=d.fragmentHint.duration),d.totalduration=g,d.endCC=m,T>0&&function(t,e){for(var r=t[e],i=e;i--;){var a=t[i];if(!a)return;a.programDateTime=r.programDateTime-1e3*a.duration,r=a}}(h,T),d},t}();function Pt(t,e,r){var i,a,n=new w(t),s=null!=(i=n.METHOD)?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),u=n.KEYFORMATVERSIONS,d=null!=(a=n.KEYFORMAT)?a:"identity";o&&n.IV&&!l&&D.error("Invalid IV: "+n.IV);var h=o?Ct.resolve(o,e):"",f=(u||"1").split("/").map(Number).filter(Number.isFinite);return new bt(s,h,d,f,l)}function Ft(t){var e=new w(t).decimalFloatingPoint("TIME-OFFSET");return y(e)?e:null}function Ot(t,e){["video","audio","text"].forEach((function(r){var i=t.filter((function(t){return function(t,e){var r=At[e];return!!r&&!0===r[t.slice(0,4)]}(t,r)}));if(i.length){var a=i.filter((function(t){return 0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)}));e[r+"Codec"]=a.length>0?a[0]:i[0],t=t.filter((function(t){return-1===i.indexOf(t)}))}})),e.unknownCodecs=t}function Mt(t,e,r){var i=e[r];i&&(t[r]=i)}function Nt(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),y(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function Bt(t,e,r,i){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=r,t.sn="initSegment",i&&(t.levelkeys=i),t.initSegment=null}function Ut(t,e,r){t.levelkeys=e;var i=r.encryptedFragments;i.length&&i[i.length-1].levelkeys===e||!Object.keys(e).some((function(t){return e[t].isCommonEncryption}))||i.push(t)}var Gt="manifest",Ht="level",Kt="audioTrack",Vt="subtitleTrack",Wt="main",Yt="audio",jt="subtitle";function qt(t){switch(t.type){case Kt:return Yt;case Vt:return jt;default:return Wt}}function zt(t,e){var r=t.url;return void 0!==r&&0!==r.indexOf("data:")||(r=e.url),r}var Xt=function(){function t(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}var e=t.prototype;return e.startLoad=function(t){},e.stopLoad=function(){this.destroyInternalLoaders()},e.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)},e.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)},e.createInternalLoader=function(t){var e=this.hls.config,r=e.pLoader,i=e.loader,a=new(r||i)(e);return this.loaders[t.type]=a,a},e.getInternalLoader=function(t){return this.loaders[t.type]},e.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},e.destroyInternalLoaders=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}},e.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},e.onManifestLoading=function(t,e){var r=e.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Gt,url:r,deliveryDirectives:null})},e.onLevelLoading=function(t,e){var r=e.id,i=e.level,a=e.url,n=e.deliveryDirectives;this.load({id:r,level:i,responseType:"text",type:Ht,url:a,deliveryDirectives:n})},e.onAudioTrackLoading=function(t,e){var r=e.id,i=e.groupId,a=e.url,n=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:Kt,url:a,deliveryDirectives:n})},e.onSubtitleTrackLoading=function(t,e){var r=e.id,i=e.groupId,a=e.url,n=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:Vt,url:a,deliveryDirectives:n})},e.load=function(t){var e,r,i,a=this,n=this.hls.config,s=this.getInternalLoader(t);if(s){var l=s.context;if(l&&l.url===t.url)return void D.trace("[playlist-loader]: playlist request ongoing");D.log("[playlist-loader]: aborting previous loader for type: "+t.type),s.abort()}if(r=t.type===Gt?n.manifestLoadPolicy.default:o({},n.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(t),null!=(e=t.deliveryDirectives)&&e.part&&(t.type===Ht&&null!==t.level?i=this.hls.levels[t.level].details:t.type===Kt&&null!==t.id?i=this.hls.audioTracks[t.id].details:t.type===Vt&&null!==t.id&&(i=this.hls.subtitleTracks[t.id].details),i)){var u=i.partTarget,d=i.targetduration;if(u&&d){var h=1e3*Math.max(3*u,.8*d);r=o({},r,{maxTimeToFirstByteMs:Math.min(h,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,r.maxTimeToFirstByteMs)})}}var f=r.errorRetry||r.timeoutRetry||{},c={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:f.maxNumRetry||0,retryDelay:f.retryDelayMs||0,maxRetryDelay:f.maxRetryDelayMs||0},v={onSuccess:function(t,e,r,i){var n=a.getInternalLoader(r);a.resetInternalLoader(r.type);var s=t.data;0===s.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),Ct.isMediaPlaylist(s)?a.handleTrackOrLevelPlaylist(t,e,r,i||null,n):a.handleMasterPlaylist(t,e,r,i)):a.handleManifestParsingError(t,r,new Error("no EXTM3U delimiter"),i||null,e)},onError:function(t,e,r,i){a.handleNetworkError(e,r,!1,t,i)},onTimeout:function(t,e,r){a.handleNetworkError(e,r,!0,void 0,t)}};s.load(t,c,v)},e.handleMasterPlaylist=function(t,e,r,i){var a=this.hls,n=t.data,s=zt(t,r),o=Ct.parseMasterPlaylist(n,s);if(o.playlistParsingError)this.handleManifestParsingError(t,r,o.playlistParsingError,i,e);else{var l=o.contentSteering,u=o.levels,d=o.sessionData,h=o.sessionKeys,f=o.startTimeOffset,c=o.variableList;this.variableList=c;var v=Ct.parseMasterPlaylistMedia(n,s,o),g=v.AUDIO,m=void 0===g?[]:g,p=v.SUBTITLES,y=v["CLOSED-CAPTIONS"];m.length&&(m.some((function(t){return!t.url}))||!u[0].audioCodec||u[0].attrs.AUDIO||(D.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new w({}),bitrate:0,url:""}))),a.trigger(E.MANIFEST_LOADED,{levels:u,audioTracks:m,subtitles:p,captions:y,contentSteering:l,url:s,stats:e,networkDetails:i,sessionData:d,sessionKeys:h,startTimeOffset:f,variableList:c})}},e.handleTrackOrLevelPlaylist=function(t,e,r,i,a){var n=this.hls,s=r.id,o=r.level,l=r.type,u=zt(t,r),d=y(s)?s:0,h=y(o)?o:d,f=qt(r),c=Ct.parseLevelPlaylist(t.data,u,h,f,d,this.variableList);if(l===Gt){var v={attrs:new w({}),bitrate:0,details:c,name:"",url:u};n.trigger(E.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:u,stats:e,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),r.levelDetails=c,this.handlePlaylistLoaded(c,t,e,r,i,a)},e.handleManifestParsingError=function(t,e,r,i,a){this.hls.trigger(E.ERROR,{type:T.NETWORK_ERROR,details:S.MANIFEST_PARSING_ERROR,fatal:e.type===Gt,url:t.url,err:r,error:r,reason:r.message,response:t,context:e,networkDetails:i,stats:a})},e.handleNetworkError=function(t,e,r,a,n){void 0===r&&(r=!1);var s="A network "+(r?"timeout":"error"+(a?" (status "+a.code+")":""))+" occurred while loading "+t.type;t.type===Ht?s+=": "+t.level+" id: "+t.id:t.type!==Kt&&t.type!==Vt||(s+=" id: "+t.id+' group-id: "'+t.groupId+'"');var o=new Error(s);D.warn("[playlist-loader]: "+s);var l=S.UNKNOWN,u=!1,d=this.getInternalLoader(t);switch(t.type){case Gt:l=r?S.MANIFEST_LOAD_TIMEOUT:S.MANIFEST_LOAD_ERROR,u=!0;break;case Ht:l=r?S.LEVEL_LOAD_TIMEOUT:S.LEVEL_LOAD_ERROR,u=!1;break;case Kt:l=r?S.AUDIO_TRACK_LOAD_TIMEOUT:S.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case Vt:l=r?S.SUBTITLE_TRACK_LOAD_TIMEOUT:S.SUBTITLE_LOAD_ERROR,u=!1}d&&this.resetInternalLoader(t.type);var h={type:T.NETWORK_ERROR,details:l,fatal:u,url:t.url,loader:d,context:t,error:o,networkDetails:e,stats:n};if(a){var f=(null==e?void 0:e.url)||t.url;h.response=i({url:f,data:void 0},a)}this.hls.trigger(E.ERROR,h)},e.handlePlaylistLoaded=function(t,e,r,i,a,n){var s=this.hls,o=i.type,l=i.level,u=i.id,d=i.groupId,h=i.deliveryDirectives,f=zt(e,i),c=qt(i),v="number"==typeof i.level&&c===Wt?l:void 0;if(t.fragments.length){t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));var g=t.playlistParsingError;if(g)s.trigger(E.ERROR,{type:T.NETWORK_ERROR,details:S.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:e,context:i,level:v,parent:c,networkDetails:a,stats:r});else switch(t.live&&n&&(n.getCacheAge&&(t.ageHeader=n.getCacheAge()||0),n.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),o){case Gt:case Ht:s.trigger(E.LEVEL_LOADED,{details:t,level:v||0,id:u||0,stats:r,networkDetails:a,deliveryDirectives:h});break;case Kt:s.trigger(E.AUDIO_TRACK_LOADED,{details:t,id:u||0,groupId:d||"",stats:r,networkDetails:a,deliveryDirectives:h});break;case Vt:s.trigger(E.SUBTITLE_TRACK_LOADED,{details:t,id:u||0,groupId:d||"",stats:r,networkDetails:a,deliveryDirectives:h})}}else{var m=new Error("No Segments found in Playlist");s.trigger(E.ERROR,{type:T.NETWORK_ERROR,details:S.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:m,reason:m.message,response:e,context:i,level:v,parent:c,networkDetails:a,stats:r})}},t}();function Qt(t,e){var r;try{r=new Event("addtrack")}catch(t){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)}function $t(t,e,r,i){var a=t.mode;if("disabled"===a&&(t.mode="hidden"),t.cues&&t.cues.length>0)for(var n=function(t,e,r){var i=[],a=function(t,e){if(e<t[0].startTime)return 0;var r=t.length-1;if(e>t[r].endTime)return-1;for(var i=0,a=r;i<=a;){var n=Math.floor((a+i)/2);if(e<t[n].startTime)a=n-1;else{if(!(e>t[n].startTime&&i<r))return n;i=n+1}}return t[i].startTime-e<e-t[a].startTime?i:a}(t,e);if(a>-1)for(var n=a,s=t.length;n<s;n++){var o=t[n];if(o.startTime>=e&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}(t.cues,e,r),s=0;s<n.length;s++)i&&!i(n[s])||t.removeCue(n[s]);"disabled"===a&&(t.mode=a)}var Zt="org.id3",Jt="com.apple.quicktime.HLS",te="https://aomedia.org/emsg/ID3";function ee(){if("undefined"!=typeof self)return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var re=function(){var t=ee();try{new t(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function ie(t,e){return t.getTime()/1e3-e}var ae=function(){function t(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}var e=t.prototype;return e.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},e._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)},e._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)},e.onMediaAttached=function(t,e){this.media=e.media},e.onMediaDetaching=function(){this.id3Track&&(function(t){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(var r=t.cues.length;r--;)t.removeCue(t.cues[r]);"disabled"===e&&(t.mode=e)}(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},e.onManifestLoading=function(){this.dateRangeCuesAppended={}},e.createTrack=function(t){var e=this.getID3Track(t.textTracks);return e.mode="hidden",e},e.getID3Track=function(t){if(this.media){for(var e=0;e<t.length;e++){var r=t[e];if("metadata"===r.kind&&"id3"===r.label)return Qt(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},e.onFragParsingMetadata=function(t,e){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,a=r.enableID3MetadataCues;if(i||a){var n=e.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var s=ee(),o=0;o<n.length;o++){var l=n[o].type;if((l!==te||i)&&a){var u=$(n[o].data);if(u){var d=n[o].pts,h=d+n[o].duration;h>re&&(h=re),h-d<=0&&(h=d+.25);for(var f=0;f<u.length;f++){var c=u[f];if(!X(c)){this.updateId3CueEnds(d);var v=new s(d,h,"");v.value=c,l&&(v.type=l),this.id3Track.addCue(v)}}}}}}}},e.updateId3CueEnds=function(t){var e,r=null==(e=this.id3Track)?void 0:e.cues;if(r)for(var i=r.length;i--;){var a=r[i];a.startTime<t&&a.endTime===re&&(a.endTime=t)}},e.onBufferFlushing=function(t,e){var r=e.startOffset,i=e.endOffset,a=e.type,n=this.id3Track,s=this.hls;if(s){var o=s.config,l=o.enableEmsgMetadataCues,u=o.enableID3MetadataCues;n&&(l||u)&&$t(n,r,i,"audio"===a?function(t){return t.type===Zt&&u}:"video"===a?function(t){return t.type===te&&l}:function(t){return t.type===Zt&&u||t.type===te&&l})}},e.onLevelUpdated=function(t,e){var r=this,i=e.details;if(this.media&&i.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var a=this.dateRangeCuesAppended,n=this.id3Track,s=i.dateRanges,o=Object.keys(s);if(n)for(var l=Object.keys(a).filter((function(t){return!o.includes(t)})),u=function(){var t=l[d];Object.keys(a[t].cues).forEach((function(e){n.removeCue(a[t].cues[e])})),delete a[t]},d=l.length;d--;)u();var h=i.fragments[i.fragments.length-1];if(0!==o.length&&y(null==h?void 0:h.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var f=h.programDateTime/1e3-h.start,c=ee(),v=function(){var t=o[g],e=s[t],i=a[t],n=(null==i?void 0:i.cues)||{},l=(null==i?void 0:i.durationKnown)||!1,u=ie(e.startDate,f),d=re,h=e.endDate;if(h)d=ie(h,f),l=!0;else if(e.endOnNext&&!l){var v=o.reduce((function(t,r){var i=s[r];return i.class===e.class&&i.id!==r&&i.startDate>e.startDate&&t.push(i),t}),[]).sort((function(t,e){return t.startDate.getTime()-e.startDate.getTime()}))[0];v&&(d=ie(v.startDate,f),l=!0)}for(var m,p,y=Object.keys(e.attr),E=0;E<y.length;E++){var T=y[E];if("ID"!==(p=T)&&"CLASS"!==p&&"START-DATE"!==p&&"DURATION"!==p&&"END-DATE"!==p&&"END-ON-NEXT"!==p){var S=n[T];if(S)l&&!i.durationKnown&&(S.endTime=d);else{var L=e.attr[T];S=new c(u,d,""),I(T)&&(m=L,L=Uint8Array.from(m.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),S.value={key:T,data:L},S.type=Jt,S.id=t,r.id3Track.addCue(S),n[T]=S}}}a[t]={cues:n,dateRange:e,durationKnown:l}},g=0;g<o.length;g++)v()}}},t}(),ne=function(){function t(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 e=t.prototype;return e.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},e.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)},e.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)},e.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},e.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},e.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},e.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)},e.onError=function(t,e){var r;e.details===S.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(r=this.levelDetails)&&r.live&&D.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},e.timeupdate=function(){var t=this.media,e=this.levelDetails;if(t&&e){this.currentTime=t.currentTime;var r=this.computeLatency();if(null!==r){this._latency=r;var i=this.config,a=i.lowLatencyMode,n=i.maxLiveSyncPlaybackRate;if(a&&1!==n){var s=this.targetLatency;if(null!==s){var o=r-s,l=o<Math.min(this.maxLatency,s+e.targetduration);if(e.live&&l&&o>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,n)),d=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;t.playbackRate=Math.min(u,Math.max(1,d))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}}}}},e.estimateLiveEdge=function(){var t=this.levelDetails;return null===t?null:t.edge+t.age},e.computeLatency=function(){var t=this.estimateLiveEdge();return null===t?null:t-this.currentTime},n(t,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config,e=this.levelDetails;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(null===t)return null;var e=t.holdBack,r=t.partHoldBack,i=t.targetduration,a=this.config,n=a.liveSyncDuration,s=a.liveSyncDurationCount,o=a.lowLatencyMode,l=this.hls.userConfig,u=o&&r||e;(l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==n?n:s*i);var d=i;return u+Math.min(1*this.stallCount,d)}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),e=this.targetLatency,r=this.levelDetails;if(null===t||null===e||null===r)return null;var i=r.edge,a=t-e-this.edgeStalled,n=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(n,a),s)}},{key:"drift",get:function(){var t=this.levelDetails;return null===t?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;if(null===t)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}}]),t}(),se=["NONE","TYPE-0","TYPE-1",null],oe="",le="YES",ue="v2",de=function(){function t(t,e,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=r}return t.prototype.addDirectives=function(t){var e=new self.URL(t);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href},t}(),he=function(){function t(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter((function(t){return t})).join(",").replace(/\.[^.,]+/g,"")}return t.prototype.addFallback=function(t){this.url.push(t.url),this._attrs.push(t.attrs)},n(t,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"attrs",get:function(){return this._attrs[this._urlId]}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(t){var e=t%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}},{key:"audioGroupId",get:function(){var t;return null==(t=this.audioGroupIds)?void 0:t[this.urlId]}},{key:"textGroupId",get:function(){var t;return null==(t=this.textGroupIds)?void 0:t[this.urlId]}}]),t}();function fe(t,e){var r=e.startPTS;if(y(r)){var i,a=0;e.sn>t.sn?(a=r-t.start,i=t):(a=t.start-r,i=e),i.duration!==a&&(i.duration=a)}else e.sn>t.sn?t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration:e.start=Math.max(t.start-e.duration,0)}function ce(t,e,r,i,a,n){i-r<=0&&(D.warn("Fragment should have a positive duration",e),i=r+e.duration,n=a+e.duration);var s=r,o=i,l=e.startPTS,u=e.endPTS;if(y(l)){var d=Math.abs(l-r);y(e.deltaPTS)?e.deltaPTS=Math.max(d,e.deltaPTS):e.deltaPTS=d,s=Math.max(r,l),r=Math.min(r,l),a=Math.min(a,e.startDTS),o=Math.min(i,u),i=Math.max(i,u),n=Math.max(n,e.endDTS)}var h=r-e.start;0!==e.start&&(e.start=r),e.duration=i-e.start,e.startPTS=r,e.maxStartPTS=s,e.startDTS=a,e.endPTS=i,e.minEndPTS=o,e.endDTS=n;var f,c=e.sn;if(!t||c<t.startSN||c>t.endSN)return 0;var v=c-t.startSN,g=t.fragments;for(g[v]=e,f=v;f>0;f--)fe(g[f],g[f-1]);for(f=v;f<g.length-1;f++)fe(g[f],g[f+1]);return t.fragmentHint&&fe(g[g.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,h}function ve(t,e){for(var r=null,i=t.fragments,a=i.length-1;a>=0;a--){var n=i[a].initSegment;if(n){r=n;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var s,l,u,d,h,f=0;if(function(t,e,r){for(var i=e.skippedSegments,a=Math.max(t.startSN,e.startSN)-e.startSN,n=(t.fragmentHint?1:0)+(i?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,s=e.startSN-t.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=a;u<=n;u++){var d=l[s+u],h=o[u];i&&!h&&u<i&&(h=e.fragments[u]=d),d&&h&&r(d,h)}}(t,e,(function(t,i){t.relurl&&(f=t.cc-i.cc),y(t.startPTS)&&y(t.endPTS)&&(i.start=i.startPTS=t.startPTS,i.startDTS=t.startDTS,i.maxStartPTS=t.maxStartPTS,i.endPTS=t.endPTS,i.endDTS=t.endDTS,i.minEndPTS=t.minEndPTS,i.duration=t.endPTS-t.startPTS,i.duration&&(s=i),e.PTSKnown=e.alignedSliding=!0),i.elementaryStreams=t.elementaryStreams,i.loader=t.loader,i.stats=t.stats,i.urlId=t.urlId,t.initSegment&&(i.initSegment=t.initSegment,r=t.initSegment)})),r&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach((function(t){var e;t.initSegment&&t.initSegment.relurl!==(null==(e=r)?void 0:e.relurl)||(t.initSegment=r)})),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some((function(t){return!t})),e.deltaUpdateFailed){D.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var c=e.skippedSegments;c--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=(l=t.dateRanges,u=e.dateRanges,d=e.recentlyRemovedDateranges,h=o({},l),d&&d.forEach((function(t){delete h[t]})),Object.keys(u).forEach((function(t){var e=new C(u[t].attr,h[t]);e.isValid?h[t]=e:D.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(u[t].attr)+'"')})),h));var v=e.fragments;if(f){D.warn("discontinuity sliding from playlist, take drift into account");for(var g=0;g<v.length;g++)v[g].cc+=f}e.skippedSegments&&(e.startCC=e.fragments[0].cc),function(t,e,r){if(t&&e)for(var i=0,a=0,n=t.length;a<=n;a++){var s=t[a],o=e[a+i];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):i--}}(t.partList,e.partList,(function(t,e){e.elementaryStreams=t.elementaryStreams,e.stats=t.stats})),s?ce(e,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):ge(t,e),v.length&&(e.totalduration=e.edge-v[0].start),e.driftStartTime=t.driftStartTime,e.driftStart=t.driftStart;var m=e.advancedDateTime;if(e.advanced&&m){var p=e.edge;e.driftStart||(e.driftStartTime=m,e.driftStart=p),e.driftEndTime=m,e.driftEnd=p}else e.driftEndTime=t.driftEndTime,e.driftEnd=t.driftEnd,e.advancedDateTime=t.advancedDateTime}function ge(t,e){var r=e.startSN+e.skippedSegments-t.startSN,i=t.fragments;r<0||r>=i.length||function(t,e){if(e){for(var r=t.fragments,i=t.skippedSegments;i<r.length;i++)r[i].start+=e;t.fragmentHint&&(t.fragmentHint.start+=e)}}(e,i[r].start)}function me(t,e,r){var i;return null!=t&&t.details?pe(null==(i=t.details)?void 0:i.partList,e,r):null}function pe(t,e,r){if(t)for(var i=t.length;i--;){var a=t[i];if(a.index===r&&a.fragment.sn===e)return a}return null}function ye(t){switch(t.details){case S.FRAG_LOAD_TIMEOUT:case S.KEY_LOAD_TIMEOUT:case S.LEVEL_LOAD_TIMEOUT:case S.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Ee(t,e){var r=ye(e);return t.default[(r?"timeout":"error")+"Retry"]}function Te(t,e){var r="linear"===t.backoff?1:Math.pow(2,e);return Math.min(r*t.retryDelayMs,t.maxRetryDelayMs)}function Se(t){return i(i({},t),{errorRetry:null,timeoutRetry:null})}function Le(t,e,r,i){return!!t&&e<t.maxNumRetry&&(function(t){return 0===t&&!1===navigator.onLine||!!t&&(t<400||t>499)}(i)||!!r)}var Re=function(t,e){for(var r=0,i=t.length-1,a=null,n=null;r<=i;){var s=e(n=t[a=(r+i)/2|0]);if(s>0)r=a+1;else{if(!(s<0))return n;i=a-1}}return null};function be(t,e,r,i){void 0===r&&(r=0),void 0===i&&(i=0);var a=null;if(t?a=e[t.sn-e[0].sn+1]||null:0===r&&0===e[0].start&&(a=e[0]),a&&0===Ae(r,i,a))return a;var n=Re(e,Ae.bind(null,r,i));return!n||n===t&&a?a:n}function Ae(t,e,r){if(void 0===t&&(t=0),void 0===e&&(e=0),r.start<=t&&r.start+r.duration>t)return 0;var i=Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=t?1:r.start-i>t&&r.start?-1:0}function ke(t,e,r){var i=1e3*Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>t}var De,_e=3e5,xe=0,we=2,Ie=5,Ce=0,Pe=1,Fe=2,Oe=function(){function t(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=D.log.bind(D,"[info]:"),this.warn=D.warn.bind(D,"[warning]:"),this.error=D.error.bind(D,"[error]:"),this.registerListeners()}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(E.ERROR,this.onError,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this)},e.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))},e.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},e.startLoad=function(t){this.playlistError=0},e.stopLoad=function(){},e.getVariantLevelIndex=function(t){return(null==t?void 0:t.type)===Wt?t.level:this.hls.loadLevel},e.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},e.onError=function(t,e){var r;if(!e.fatal){var i=this.hls,a=e.context;switch(e.details){case S.FRAG_LOAD_ERROR:case S.FRAG_LOAD_TIMEOUT:case S.KEY_LOAD_ERROR:case S.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case S.FRAG_GAP:case S.FRAG_PARSING_ERROR:case S.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=we);case S.LEVEL_EMPTY_ERROR:case S.LEVEL_PARSING_ERROR:var n,s,o=e.parent===Wt?e.level:i.loadLevel;return void(e.details===S.LEVEL_EMPTY_ERROR&&null!=(n=e.context)&&null!=(s=n.levelDetails)&&s.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,o)));case S.LEVEL_LOAD_ERROR:case S.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,a.level)));case S.AUDIO_TRACK_LOAD_ERROR:case S.AUDIO_TRACK_LOAD_TIMEOUT:case S.SUBTITLE_LOAD_ERROR:case S.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var l=i.levels[i.loadLevel];if(l&&(a.type===Kt&&a.groupId===l.audioGroupId||a.type===Vt&&a.groupId===l.textGroupId))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,i.loadLevel),e.errorAction.action=we,void(e.errorAction.flags=Pe)}return;case S.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var u=i.levels[i.loadLevel],d=null==u?void 0:u.attrs["HDCP-LEVEL"];return void(d&&(e.errorAction={action:we,flags:Fe,hdcpLevel:d}));case S.BUFFER_ADD_CODEC_ERROR:case S.REMUX_ALLOC_ERROR:return void(e.errorAction=this.getLevelSwitchAction(e,null!=(r=e.level)?r:i.loadLevel));case S.INTERNAL_EXCEPTION:case S.BUFFER_APPENDING_ERROR:case S.BUFFER_APPEND_ERROR:case S.BUFFER_FULL_ERROR:case S.LEVEL_SWITCH_ERROR:case S.BUFFER_STALLED_ERROR:case S.BUFFER_SEEK_OVER_HOLE:case S.BUFFER_NUDGE_ON_STALL:return void(e.errorAction={action:xe,flags:Ce})}if(e.type===T.KEY_SYSTEM_ERROR){var h=this.getVariantLevelIndex(e.frag);return e.levelRetry=!1,void(e.errorAction=this.getLevelSwitchAction(e,h))}}},e.getPlaylistRetryOrSwitchAction=function(t,e){var r,i,a=Ee(this.hls.config.playlistLoadPolicy,t),n=this.playlistError++,s=null==(r=t.response)?void 0:r.code;return Le(a,n,ye(t),s)?{action:Ie,flags:Ce,retryConfig:a,retryCount:n}:null!=(i=t.context)&&i.deliveryDirectives?{action:xe,flags:Ce,retryConfig:a||{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},retryCount:n}:this.getLevelSwitchAction(t,e)},e.getFragRetryOrSwitchAction=function(t){var e=this.hls,r=this.getVariantLevelIndex(t.frag),i=e.levels[r],a=e.config,n=a.fragLoadPolicy,s=a.keyLoadPolicy,o=Ee(t.details.startsWith("key")?s:n,t),l=e.levels.reduce((function(t,e){return t+e.fragmentError}),0);if(i){var u;t.details!==S.FRAG_GAP&&i.fragmentError++;var d=null==(u=t.response)?void 0:u.code;if(Le(o,l,ye(t),d))return{action:Ie,flags:Ce,retryConfig:o,retryCount:l}}var h=this.getLevelSwitchAction(t,r);return o&&(h.retryConfig=o,h.retryCount=l),h},e.getLevelSwitchAction=function(t,e){var r=this.hls;null==e&&(e=r.loadLevel);var i=this.hls.levels[e];if(i&&(i.loadError++,r.autoLevelEnabled)){for(var a,n,s=-1,o=r.levels,l=null==(a=t.frag)?void 0:a.type,u=null!=(n=t.context)?n:{},d=u.type,h=u.groupId,f=o.length;f--;){var c=(f+r.loadLevel)%o.length;if(c!==r.loadLevel&&0===o[c].loadError){var v=o[c];if(t.details===S.FRAG_GAP&&t.frag){var g=o[c].details;if(g){var m=be(t.frag,g.fragments,t.frag.start);if(null!=m&&m.gap)continue}}else{if(d===Kt&&h===v.audioGroupId||d===Vt&&h===v.textGroupId)continue;if(l===Yt&&i.audioGroupId===v.audioGroupId||l===jt&&i.textGroupId===v.textGroupId)continue}s=c;break}}if(s>-1&&r.loadLevel!==s)return t.levelRetry=!0,{action:we,flags:Ce,nextAutoLevel:s}}return{action:we,flags:Pe}},e.onErrorOut=function(t,e){var r;switch(null==(r=e.errorAction)?void 0:r.action){case xe:break;case we:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===S.FRAG_GAP||(e.fatal=!0)}e.fatal&&this.hls.stopLoad()},e.sendAlternateToPenaltyBox=function(t){var e=this.hls,r=t.errorAction;if(r){var i=r.flags,a=r.hdcpLevel,n=r.nextAutoLevel;switch(i){case Ce:this.switchLevel(t,n);break;case Pe:r.resolved||(r.resolved=this.redundantFailover(t));break;case Fe:a&&(e.maxHdcpLevel=se[se.indexOf(a)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+e.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(t,n)}},e.switchLevel=function(t,e){void 0!==e&&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)},e.redundantFailover=function(t){var e=this,r=this.hls,i=this.penalizedRenditions,a=t.parent===Wt?t.level:r.loadLevel,n=r.levels[a],s=n.url.length,o=t.frag?t.frag.urlId:n.urlId;n.urlId!==o||t.frag&&!n.details||this.penalizeRendition(n,t);for(var l=function(){var l=(o+u)%s,d=i[l];if(!d||function(t,e,r){if(performance.now()-t.lastErrorPerfMs>_e)return!0;var i=t.details;if(e.details===S.FRAG_GAP&&i&&e.frag){var a=e.frag.start,n=be(null,i.fragments,a);if(n&&!n.gap)return!0}if(r&&t.errors.length<r.errors.length){var s=t.errors[t.errors.length-1];if(i&&s.frag&&e.frag&&Math.abs(s.frag.start-e.frag.start)>3*i.targetduration)return!0}return!1}(d,t,i[o]))return e.warn("Switching to Redundant Stream "+(l+1)+"/"+s+': "'+n.url[l]+'" after '+t.details),e.playlistError=0,r.levels.forEach((function(t){t.urlId=l})),r.nextLoadLevel=a,{v:!0}},u=1;u<s;u++){var d=l();if("object"==typeof d)return d.v}return!1},e.penalizeRendition=function(t,e){var r=this.penalizedRenditions,i=r[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};i.lastErrorPerfMs=performance.now(),i.errors.push(e),i.details=t.details,r[t.urlId]=i},t}(),Me=function(){function t(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=D.log.bind(D,e+":"),this.warn=D.warn.bind(D,e+":"),this.hls=t}var e=t.prototype;return e.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},e.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},e.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},e.stopLoad=function(){this.canLoad=!1,this.clearTimer()},e.switchParams=function(t,e){var r=null==e?void 0:e.renditionReports;if(r){for(var i=-1,a=0;a<r.length;a++){var n=r[a],s=void 0;try{s=new self.URL(n.URI,e.url).href}catch(t){D.warn("Could not construct new URL for Rendition Report: "+t),s=n.URI||""}if(s===t){i=a;break}s===t.substring(0,s.length)&&(i=a)}if(-1!==i){var o=r[i],l=parseInt(o["LAST-MSN"])||(null==e?void 0:e.lastPartSn),u=parseInt(o["LAST-PART"])||(null==e?void 0:e.lastPartIndex);if(this.hls.config.lowLatencyMode){var d=Math.min(e.age-e.partTarget,e.targetduration);u>=0&&d>e.partTarget&&(u+=1)}return new de(l,u>=0?u:void 0,oe)}}},e.loadPlaylist=function(t){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},e.shouldLoadPlaylist=function(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)},e.shouldReloadPlaylist=function(t){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(t)},e.playlistLoaded=function(t,e,r){var i=this,a=e.details,n=e.stats,s=self.performance.now(),o=n.loading.first?Math.max(0,s-n.loading.first):0;if(a.advancedDateTime=Date.now()-o,a.live||null!=r&&r.live){if(a.reloaded(r),r&&this.log("live playlist "+t+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED")),r&&a.fragments.length>0&&ve(r,a),!this.canLoad||!a.live)return;var l,u=void 0,d=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var h=this.hls.config.lowLatencyMode,f=a.lastPartSn,c=a.endSN,v=a.lastPartIndex,g=f===c;-1!==v?(u=g?c+1:f,d=g?h?0:v:v+1):u=c+1;var m=a.age,p=m+a.ageHeader,y=Math.min(p-a.partTarget,1.5*a.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+a.age),y=0;else{var E=Math.floor(y/a.targetduration);u+=E,void 0!==d&&(d+=Math.round(y%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+m.toFixed(2)+"s goal: "+y+" skip sn "+E+" to part "+d)}a.tuneInGoal=y}if(l=this.getDeliveryDirectives(a,e.deliveryDirectives,u,d),h||!g)return void this.loadPlaylist(l)}else a.canBlockReload&&(l=this.getDeliveryDirectives(a,e.deliveryDirectives,u,d));var T=this.hls.mainForwardBufferInfo,S=T?T.end-T.len:0,L=function(t,e){void 0===e&&(e=1/0);var r=1e3*t.targetduration;if(t.updated){var i=t.fragments;if(i.length&&4*r>e){var a=1e3*i[i.length-1].duration;a<r&&(r=a)}}else r/=2;return Math.round(r)}(a,1e3*(a.edge-S));a.updated&&s>this.requestScheduled+L&&(this.requestScheduled=n.loading.start),void 0!==u&&a.canBlockReload?this.requestScheduled=n.loading.first+L-(1e3*a.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+L<s?this.requestScheduled=s:this.requestScheduled-s<=0&&(this.requestScheduled+=L);var R=this.requestScheduled-s;R=Math.max(0,R),this.log("reload live playlist "+t+" in "+Math.round(R)+" ms"),this.timer=self.setTimeout((function(){return i.loadPlaylist(l)}),R)}else this.clearTimer()},e.getDeliveryDirectives=function(t,e,r,i){var a=function(t,e){var r=t.canSkipUntil,i=t.canSkipDateRanges,a=t.endSN;return r&&(void 0!==e?e-a:0)<r?i?ue:le:oe}(t,r);return null!=e&&e.skip&&t.deltaUpdateFailed&&(r=e.msn,i=e.part,a=oe),new de(r,i,a)},e.checkRetry=function(t){var e=this,r=t.details,i=ye(t),a=t.errorAction,n=a||{},s=n.action,o=n.retryCount,l=void 0===o?0:o,u=n.retryConfig,d=s===Ie&&!!a&&!!u;if(d){var h;if(this.requestScheduled=-1,i&&null!=(h=t.context)&&h.deliveryDirectives)this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var f=Te(u,l);this.timer=self.setTimeout((function(){return e.loadPlaylist()}),f),this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+r+'" in '+f+"ms")}t.levelRetry=!0,a.resolved=!0}return d},t}(),Ne=function(t){function e(e,r){var i;return(i=t.call(this,e,"[level-controller]")||this)._levels=[],i._firstLevel=-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}l(e,t);var r=e.prototype;return r._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.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(E.FRAG_LOADED,this.onFragLoaded,this),t.on(E.ERROR,this.onError,this)},r._unregisterListeners=function(){var t=this.hls;t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(E.FRAG_LOADED,this.onFragLoaded,this),t.off(E.ERROR,this.onError,this)},r.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),t.prototype.destroy.call(this)},r.startLoad=function(){this._levels.forEach((function(t){t.loadError=0,t.fragmentError=0})),t.prototype.startLoad.call(this)},r.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]},r.onManifestLoading=function(t,e){this.resetLevels()},r.onManifestLoaded=function(t,e){var r,i=[],a={};e.levels.forEach((function(t){var e,n=t.attrs;-1!==(null==(e=t.audioCodec)?void 0:e.indexOf("mp4a.40.34"))&&(De||(De=/chrome|firefox/i.test(navigator.userAgent)),De&&(t.audioCodec=void 0));var s=n.AUDIO,o=n.CODECS,l=n["FRAME-RATE"];n["PATHWAY-ID"];var u=n.RESOLUTION,d=n.SUBTITLES,h=t.bitrate+"-"+u+"-"+l+"-"+o;(r=a[h])?r.addFallback(t):(r=new he(t),a[h]=r,i.push(r)),Be(r,"audio",s),Be(r,"text",d)})),this.filterAndSortMediaOptions(i,e)},r.filterAndSortMediaOptions=function(t,e){var r=this,i=[],a=[],n=!1,s=!1,o=!1,l=t.filter((function(t){var e=t.audioCodec,r=t.videoCodec,i=t.width,a=t.height,l=t.unknownCodecs;return n||(n=!(!i||!a)),s||(s=!!r),o||(o=!!e),!(null!=l&&l.length)&&(!e||kt(e,"audio"))&&(!r||kt(r,"video"))}));if((n||s)&&o&&(l=l.filter((function(t){var e=t.videoCodec,r=t.width,i=t.height;return!!e||!(!r||!i)}))),0!==l.length){e.audioTracks&&Ue(i=e.audioTracks.filter((function(t){return!t.audioCodec||kt(t.audioCodec,"audio")}))),e.subtitles&&Ue(a=e.subtitles);var u=l.slice(0);l.sort((function(t,e){return t.attrs["HDCP-LEVEL"]!==e.attrs["HDCP-LEVEL"]?(t.attrs["HDCP-LEVEL"]||"")>(e.attrs["HDCP-LEVEL"]||"")?1:-1:t.bitrate!==e.bitrate?t.bitrate-e.bitrate:t.attrs["FRAME-RATE"]!==e.attrs["FRAME-RATE"]?t.attrs.decimalFloatingPoint("FRAME-RATE")-e.attrs.decimalFloatingPoint("FRAME-RATE"):t.attrs.SCORE!==e.attrs.SCORE?t.attrs.decimalFloatingPoint("SCORE")-e.attrs.decimalFloatingPoint("SCORE"):n&&t.height!==e.height?t.height-e.height:0}));var d=u[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==u.length)for(var h=0;h<u.length;h++)if(u[h].pathwayId===l[0].pathwayId){d=u[h];break}this._levels=l;for(var f=0;f<l.length;f++)if(l[f]===d){this._firstLevel=f,this.log("manifest loaded, "+l.length+" level(s) found, first bitrate: "+d.bitrate);break}var c=o&&!s,v={levels:l,audioTracks:i,subtitleTracks:a,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:o,video:s,altAudio:!c&&i.some((function(t){return!!t.url}))};this.hls.trigger(E.MANIFEST_PARSED,v),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then((function(){if(r.hls){var t=new Error("no level with compatible codecs found in manifest");r.hls.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:t,reason:t.message})}}))},r.onError=function(t,e){!e.fatal&&e.context&&e.context.type===Ht&&e.context.level===this.level&&this.checkRetry(e)},r.onFragLoaded=function(t,e){var r=e.frag;if(void 0!==r&&r.type===Wt){var i=this._levels[r.level];void 0!==i&&(i.loadError=0)}},r.onLevelLoaded=function(t,e){var r,i,a=e.level,n=e.details,s=this._levels[a];if(!s)return this.warn("Invalid level index "+a),void(null!=(i=e.deliveryDirectives)&&i.skip&&(n.deltaUpdateFailed=!0));a===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0),this.playlistLoaded(a,e,s.details)):null!=(r=e.deliveryDirectives)&&r.skip&&(n.deltaUpdateFailed=!0)},r.onAudioTrackSwitched=function(t,e){var r=this.currentLevel;if(r){var i=this.hls.audioTracks[e.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==i){for(var a=-1,n=0;n<r.audioGroupIds.length;n++)if(r.audioGroupIds[n]===i){a=n;break}-1!==a&&a!==r.urlId&&(r.urlId=a,this.canLoad&&this.startLoad())}}},r.loadPlaylist=function(e){t.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var a=i.urlId,n=i.uri;if(e)try{n=e.addDirectives(n)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}var s=i.attrs["PATHWAY-ID"];this.log("Loading level index "+r+(void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:"")+" with"+(s?" Pathway "+s:"")+" URI "+(a+1)+"/"+i.url.length+" "+n),this.clearTimer(),this.hls.trigger(E.LEVEL_LOADING,{url:n,level:r,id:a,deliveryDirectives:e||null})}},r.removeLevel=function(t,e){var r=this,i=function(t,r){return r!==e},a=this._levels.filter((function(a,n){return n!==t||(a.url.length>1&&void 0!==e?(a.url=a.url.filter(i),a.audioGroupIds&&(a.audioGroupIds=a.audioGroupIds.filter(i)),a.textGroupIds&&(a.textGroupIds=a.textGroupIds.filter(i)),a.urlId=0,!0):(r.steering&&r.steering.removeLevel(a),!1))}));this.hls.trigger(E.LEVELS_UPDATED,{levels:a})},r.onLevelsUpdated=function(t,e){var r=e.levels;r.forEach((function(t,e){var r=t.details;null!=r&&r.fragments&&r.fragments.forEach((function(t){t.level=e}))})),this._levels=r},n(e,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var e=this._levels;if(0!==e.length){if(t<0||t>=e.length){var r=new Error("invalid level idx"),i=t<0;if(this.hls.trigger(E.ERROR,{type:T.OTHER_ERROR,details:S.LEVEL_SWITCH_ERROR,level:t,fatal:i,error:r,reason:r.message}),i)return;t=Math.min(t,e.length-1)}var a=this.currentLevelIndex,n=this.currentLevel,s=n?n.attrs["PATHWAY-ID"]:void 0,l=e[t],u=l.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=l,a!==t||!l.details||!n||s!==u){this.log("Switching to level "+t+(u?" with Pathway "+u:"")+" from level "+a+(s?" with Pathway "+s:""));var d=o({},l,{level:t,maxBitrate:l.maxBitrate,attrs:l.attrs,uri:l.uri,urlId:l.urlId});delete d._attrs,delete d._urlId,this.hls.trigger(E.LEVEL_SWITCHING,d);var h=l.details;if(!h||h.live){var f=this.switchParams(l.uri,null==n?void 0:n.details);this.loadPlaylist(f)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}}]),e}(Me);function Be(t,e,r){r&&("audio"===e?(t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds[t.url.length-1]=r):"text"===e&&(t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds[t.url.length-1]=r))}function Ue(t){var e={};t.forEach((function(t){var r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++}))}var Ge="NOT_LOADED",He="APPENDING",Ke="PARTIAL",Ve="OK",We=function(){function t(t){this.mainFragEntity=null,this.activeParts=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 e=t.prototype;return e._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)},e._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)},e.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.mainFragEntity=this.activeParts=null},e.getAppendedFrag=function(t,e){if(e===Wt){var r=this.mainFragEntity,i=this.activeParts;if(r)if(r&&i)for(var a=i.length;a--;){var n=i[a],s=n?n.end:r.appendedPTS;if(n.start<=t&&null!==s&&t<=s)return a>9&&(this.activeParts=i.slice(a-9)),n}else if(r.body.start<=t&&null!==r.appendedPTS&&t<=r.appendedPTS)return r.body}return this.getBufferedFrag(t,e)},e.getBufferedFrag=function(t,e){for(var r=this.fragments,i=Object.keys(r),a=i.length;a--;){var n=r[i[a]];if((null==n?void 0:n.body.type)===e&&n.buffered){var s=n.body;if(s.start<=t&&t<=s.end)return s}}return null},e.detectEvictedFragments=function(t,e,r){var i=this;this.timeRanges&&(this.timeRanges[t]=e),Object.keys(this.fragments).forEach((function(a){var n=i.fragments[a];if(n)if(n.buffered||n.loaded){var s=n.range[t];s&&s.time.some((function(t){var r=!i.isTimeBuffered(t.startPTS,t.endPTS,e);return r&&i.removeFragment(n.body),r}))}else n.body.type===r&&i.removeFragment(n.body)}))},e.detectPartialFragments=function(t){var e=this,r=this.timeRanges,i=t.frag,a=t.part;if(r&&"initSegment"!==i.sn){var n=je(i),s=this.fragments[n];s&&(Object.keys(r).forEach((function(t){var n=i.elementaryStreams[t];if(n){var o=r[t],l=null!==a||!0===n.partial;s.range[t]=e.getBufferedTimes(i,a,l,o)}})),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,s.body.endList&&(this.endListFragments[s.body.type]=s)):this.removeFragment(s.body))}},e.fragBuffered=function(t,e){var r=je(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)},e.getBufferedTimes=function(t,e,r,i){for(var a={time:[],partial:r},n=e?e.start:t.start,s=e?e.end:t.end,o=t.minEndPTS||s,l=t.maxStartPTS||n,u=0;u<i.length;u++){var d=i.start(u)-this.bufferPadding,h=i.end(u)+this.bufferPadding;if(l>=d&&o<=h){a.time.push({startPTS:Math.max(n,i.start(u)),endPTS:Math.min(s,i.end(u))});break}if(n<h&&s>d)a.partial=!0,a.time.push({startPTS:Math.max(n,i.start(u)),endPTS:Math.min(s,i.end(u))});else if(s<=d)break}return a},e.getPartialFragment=function(t){var e,r,i,a=null,n=0,s=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach((function(l){var u=o[l];u&&Ye(u)&&(r=u.body.start-s,i=u.body.end+s,t>=r&&t<=i&&(e=Math.min(t-r,i-t),n<=e&&(a=u.body,n=e)))})),a},e.isEndListAppended=function(t){var e=this.endListFragments[t];return void 0!==e&&(e.buffered||Ye(e))},e.getState=function(t){var e=je(t),r=this.fragments[e];return r?r.buffered?Ye(r)?Ke:Ve:He:Ge},e.isTimeBuffered=function(t,e,r){for(var i,a,n=0;n<r.length;n++){if(i=r.start(n)-this.bufferPadding,a=r.end(n)+this.bufferPadding,t>=i&&e<=a)return!0;if(e<=i)return!1}return!1},e.onFragLoaded=function(t,e){var r=e.frag,i=e.part;if("initSegment"!==r.sn&&!r.bitrateTest&&!i){var a=je(r);this.fragments[a]={body:r,appendedPTS:null,loaded:e,buffered:!1,range:Object.create(null)}}},e.onBufferAppended=function(t,e){var r=this,i=e.frag,a=e.part,n=e.timeRanges,s=this.mainFragEntity;if(i.type===Wt){var o=s?s.body:null;if(o!==i){s&&o&&o.sn!==i.sn&&(s.buffered=!0,this.fragments[je(o)]=s);var l=je(i);s=this.mainFragEntity=this.fragments[l]||{body:i,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)}}if(a){var u=this.activeParts;u||(this.activeParts=u=[]),u.push(a)}else this.activeParts=null}this.timeRanges=n,Object.keys(n).forEach((function(t){var e=n[t];if(r.detectEvictedFragments(t,e),!a&&s){var o=i.elementaryStreams[t];if(!o)return;for(var l=0;l<e.length;l++){var u=e.end(l);u<=o.endPTS&&u>o.startPTS?s.appendedPTS=Math.max(u,s.appendedPTS||0):s.appendedPTS=o.endPTS}}}))},e.onFragBuffered=function(t,e){this.detectPartialFragments(e)},e.hasFragment=function(t){var e=je(t);return!!this.fragments[e]},e.removeFragmentsInRange=function(t,e,r,i,a){var n=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach((function(s){var o=n.fragments[s];if(o){var l=o.body;l.type!==r||i&&!l.gap||l.start<e&&l.end>t&&(o.buffered||a)&&n.removeFragment(l)}}))},e.removeFragment=function(t){var e=je(t);t.stats.loaded=0,t.clearElementaryStreamInfo(),this.mainFragEntity===this.fragments[e]&&(this.mainFragEntity=null),delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]},e.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.mainFragEntity=null,this.activeParts=null,this.hasGaps=!1},t}();function Ye(t){var e,r;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(r=t.range.audio)?void 0:r.partial))}function je(t){return t.type+"_"+t.level+"_"+t.urlId+"_"+t.sn}var qe=Math.pow(2,17),ze=function(){function t(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var e=t.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(t,e){var r=this,a=t.url;if(!a)return Promise.reject(new $e({type:T.NETWORK_ERROR,details:S.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a "+(a?"part list":"url")),networkDetails:null}));this.abort();var n=this.config,s=n.fLoader,o=n.loader;return new Promise((function(l,u){if(r.loader&&r.loader.destroy(),t.gap)u(Qe(t));else{var d=r.loader=t.loader=s?new s(n):new o(n),h=Xe(t),f=Se(n.fragLoadPolicy.default),c={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===t.sn?1/0:qe};t.stats=d.stats,d.load(h,c,{onSuccess:function(e,i,a,n){r.resetLoader(t,d);var s=e.data;a.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),l({frag:t,part:null,payload:s,networkDetails:n})},onError:function(e,n,s,o){r.resetLoader(t,d),u(new $e({type:T.NETWORK_ERROR,details:S.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:i({url:a,data:void 0},e),error:new Error("HTTP Error "+e.code+" "+e.text),networkDetails:s,stats:o}))},onAbort:function(e,i,a){r.resetLoader(t,d),u(new $e({type:T.NETWORK_ERROR,details:S.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:a,stats:e}))},onTimeout:function(e,i,a){r.resetLoader(t,d),u(new $e({type:T.NETWORK_ERROR,details:S.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error("Timeout after "+c.timeout+"ms"),networkDetails:a,stats:e}))},onProgress:function(r,i,a,n){e&&e({frag:t,part:null,payload:a,networkDetails:n})}})}}))},e.loadPart=function(t,e,r){var a=this;this.abort();var n=this.config,s=n.fLoader,o=n.loader;return new Promise((function(l,u){if(a.loader&&a.loader.destroy(),t.gap||e.gap)u(Qe(t,e));else{var d=a.loader=t.loader=s?new s(n):new o(n),h=Xe(t,e),f=Se(n.fragLoadPolicy.default),c={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:qe};e.stats=d.stats,d.load(h,c,{onSuccess:function(i,n,s,o){a.resetLoader(t,d),a.updateStatsFromPart(t,e);var u={frag:t,part:e,payload:i.data,networkDetails:o};r(u),l(u)},onError:function(r,n,s,o){a.resetLoader(t,d),u(new $e({type:T.NETWORK_ERROR,details:S.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:i({url:h.url,data:void 0},r),error:new Error("HTTP Error "+r.code+" "+r.text),networkDetails:s,stats:o}))},onAbort:function(r,i,n){t.stats.aborted=e.stats.aborted,a.resetLoader(t,d),u(new $e({type:T.NETWORK_ERROR,details:S.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:n,stats:r}))},onTimeout:function(r,i,n){a.resetLoader(t,d),u(new $e({type:T.NETWORK_ERROR,details:S.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error("Timeout after "+c.timeout+"ms"),networkDetails:n,stats:r}))}})}}))},e.updateStatsFromPart=function(t,e){var r=t.stats,i=e.stats,a=i.total;if(r.loaded+=i.loaded,a){var n=Math.round(t.duration/e.duration),s=Math.min(Math.round(r.loaded/a),n),o=(n-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,u=i.loading;l.start?l.first+=u.first-u.start:(l.start=u.start,l.first=u.first),l.end=u.end},e.resetLoader=function(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()},t}();function Xe(t,e){void 0===e&&(e=null);var r=e||t,i={frag:t,part:e,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},a=r.byteRangeStartOffset,n=r.byteRangeEndOffset;if(y(a)&&y(n)){var s,o=a,l=n;if("initSegment"===t.sn&&"AES-128"===(null==(s=t.decryptdata)?void 0:s.method)){var u=n-a;u%16&&(l=n+(16-u%16)),0!==a&&(i.resetIV=!0,o=a-16)}i.rangeStart=o,i.rangeEnd=l}return i}function Qe(t,e){var r=new Error("GAP "+(t.gap?"tag":"attribute")+" found"),i={type:T.MEDIA_ERROR,details:S.FRAG_GAP,fatal:!1,frag:t,error:r,networkDetails:null};return e&&(i.part=e),(e||t).stats.aborted=!0,new $e(i)}var $e=function(t){function e(e){var r;return(r=t.call(this,e.error.message)||this).data=void 0,r.data=e,r}return l(e,t),e}(c(Error)),Ze=function(){function t(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}var e=t.prototype;return e.abort=function(){for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t].loader;e&&e.abort()}},e.detach=function(){for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}},e.destroy=function(){for(var t in this.detach(),this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}},e.createKeyLoadError=function(t,e,r,i,a){return void 0===e&&(e=S.KEY_LOAD_ERROR),new $e({type:T.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:a,error:r,networkDetails:i})},e.loadClear=function(t,e){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=t.sn,a=t.cc,n=function(){var t=e[s];if(a<=t.cc&&("initSegment"===i||"initSegment"===t.sn||i<t.sn))return r.emeController.selectKeySystemFormat(t).then((function(e){t.setKeyFormat(e)})),"break"},s=0;s<e.length&&"break"!==n();s++);},e.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)},e.loadInternal=function(t,e){var r,i;e&&t.setKeyFormat(e);var a=t.decryptdata;if(!a){var n=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,S.KEY_LOAD_ERROR,n))}var s=a.uri;if(!s)return Promise.reject(this.createKeyLoadError(t,S.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+s+'"')));var o,l=this.keyUriToKeyInfo[s];if(null!=(r=l)&&r.decryptdata.key)return a.key=l.decryptdata.key,Promise.resolve({frag:t,keyInfo:l});if(null!=(i=l)&&i.keyLoadPromise)switch(null==(o=l.mediaKeySessionContext)?void 0:o.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return l.keyLoadPromise.then((function(e){return a.key=e.keyInfo.decryptdata.key,{frag:t,keyInfo:l}}))}switch(l=this.keyUriToKeyInfo[s]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===a.keyFormat?this.loadKeyHTTP(l,t):this.loadKeyEME(l,t);case"AES-128":return this.loadKeyHTTP(l,t);default:return Promise.reject(this.createKeyLoadError(t,S.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+a.method+'"')))}},e.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(e){return t.mediaKeySessionContext=e,r}))).catch((function(e){throw t.keyLoadPromise=null,e}))}return Promise.resolve(r)},e.loadKeyHTTP=function(t,e){var r=this,a=this.config,n=new(0,a.loader)(a);return e.keyLoader=t.loader=n,t.keyLoadPromise=new Promise((function(s,o){var l={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},u=a.keyLoadPolicy.default,d={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:function(t,e,i,a){var n=i.frag,l=i.keyInfo,u=i.url;if(!n.decryptdata||l!==r.keyUriToKeyInfo[u])return o(r.createKeyLoadError(n,S.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),a));l.decryptdata.key=n.decryptdata.key=new Uint8Array(t.data),n.keyLoader=null,l.loader=null,s({frag:n,keyInfo:l})},onError:function(t,a,n,s){r.resetLoader(a),o(r.createKeyLoadError(e,S.KEY_LOAD_ERROR,new Error("HTTP Error "+t.code+" loading key "+t.text),n,i({url:l.url,data:void 0},t)))},onTimeout:function(t,i,a){r.resetLoader(i),o(r.createKeyLoadError(e,S.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),a))},onAbort:function(t,i,a){r.resetLoader(i),o(r.createKeyLoadError(e,S.INTERNAL_ABORTED,new Error("key loading aborted"),a))}};n.load(l,d,h)}))},e.resetLoader=function(t){var e=t.frag,r=t.keyInfo,i=t.url,a=r.loader;e.keyLoader===a&&(e.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],a&&a.destroy()},t}(),Je=function(){function t(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var e=t.prototype;return e.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},e.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},e.onHandlerDestroyed=function(){},e.hasInterval=function(){return!!this._tickInterval},e.hasNextTick=function(){return!!this._tickTimer},e.setInterval=function(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)},e.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},e.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},e.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},e.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},e.doTick=function(){},t}(),tr={length:0,start:function(){return 0},end:function(){return 0}},er=function(){function t(){}return t.isBuffered=function(e,r){try{if(e)for(var i=t.getBuffered(e),a=0;a<i.length;a++)if(r>=i.start(a)&&r<=i.end(a))return!0}catch(t){}return!1},t.bufferInfo=function(e,r,i){try{if(e){var a,n=t.getBuffered(e),s=[];for(a=0;a<n.length;a++)s.push({start:n.start(a),end:n.end(a)});return this.bufferedInfo(s,r,i)}}catch(t){}return{len:0,start:r,end:r,nextStart:void 0}},t.bufferedInfo=function(t,e,r){e=Math.max(0,e),t.sort((function(t,e){var r=t.start-e.start;return r||e.end-t.end}));var i=[];if(r)for(var a=0;a<t.length;a++){var n=i.length;if(n){var s=i[n-1].end;t[a].start-s<r?t[a].end>s&&(i[n-1].end=t[a].end):i.push(t[a])}else i.push(t[a])}else i=t;for(var o,l=0,u=e,d=e,h=0;h<i.length;h++){var f=i[h].start,c=i[h].end;if(e+r>=f&&e<c)u=f,l=(d=c)-e;else if(e+r<f){o=f;break}}return{len:l,start:u||0,end:d||0,nextStart:o}},t.getBuffered=function(t){try{return t.buffered}catch(t){return D.log("failed to get media.buffered",t),tr}},t}(),rr=function(t,e,r,i,a,n){void 0===i&&(i=0),void 0===a&&(a=-1),void 0===n&&(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={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=e,this.id=r,this.size=i,this.part=a,this.partial=n};function ir(t,e){if(t){var r=t.start+e;t.start=t.startPTS=r,t.endPTS=r+t.duration}}function ar(t,e){for(var r=e.fragments,i=0,a=r.length;i<a;i++)ir(r[i],t);e.fragmentHint&&ir(e.fragmentHint,t),e.alignedSliding=!0}function nr(t,e,r){e&&(function(t,e,r){if(function(t,e,r){return!(!e.details||!(r.endCC>r.startCC||t&&t.cc<r.startCC))}(t,r,e)){var i=function(t,e,r){var i=t.fragments,a=e.fragments;if(a.length&&i.length){var n=function(t,e){for(var r=null,i=0,a=t.length;i<a;i++){var n=t[i];if(n&&n.cc===e){r=n;break}}return r}(i,a[0].cc);if(n&&(!n||n.startPTS))return n;D.log("No frag in previous level to align on")}else D.log("No fragments to align")}(r.details,e);i&&y(i.start)&&(D.log("Adjusting PTS using last level due to CC increase within current level "+e.url),ar(i.start,e))}}(t,r,e),!r.alignedSliding&&e.details&&function(t,e){if(e.fragments.length&&t.hasProgramDateTime&&e.hasProgramDateTime){var r=e.fragments[0].programDateTime,i=t.fragments[0].programDateTime,a=(i-r)/1e3+e.fragments[0].start;a&&y(a)&&(D.log("Adjusting PTS using programDateTime delta "+(i-r)+"ms, sliding:"+a.toFixed(3)+" "+t.url+" "),ar(a,t))}}(r,e.details),r.alignedSliding||!e.details||r.skippedSegments||ge(e.details,r))}var sr=function(){function t(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}return t.prototype.decrypt=function(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)},t}(),or=function(){function t(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}return t.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},t}(),lr=function(){function t(){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 e=t.prototype;return e.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},e.initTable=function(){var t=this.sBox,e=this.invSBox,r=this.subMix,i=r[0],a=r[1],n=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],d=o[2],h=o[3],f=new Uint32Array(256),c=0,v=0,g=0;for(g=0;g<256;g++)f[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var m=v^v<<1^v<<2^v<<3^v<<4;m=m>>>8^255&m^99,t[c]=m,e[m]=c;var p=f[c],y=f[p],E=f[y],T=257*f[m]^16843008*m;i[c]=T<<24|T>>>8,a[c]=T<<16|T>>>16,n[c]=T<<8|T>>>24,s[c]=T,T=16843009*E^65537*y^257*p^16843008*c,l[m]=T<<24|T>>>8,u[m]=T<<16|T>>>16,d[m]=T<<8|T>>>24,h[m]=T,c?(c=p^f[f[f[E^p]]],v^=f[f[v]]):c=v=1}},e.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 a=this.keySize=e.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var n,s,o,l,u=this.ksRows=4*(a+6+1),d=this.keySchedule=new Uint32Array(u),h=this.invKeySchedule=new Uint32Array(u),f=this.sBox,c=this.rcon,v=this.invSubMix,g=v[0],m=v[1],p=v[2],y=v[3];for(n=0;n<u;n++)n<a?o=d[n]=e[n]:(l=o,n%a==0?(l=f[(l=l<<8|l>>>24)>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l],l^=c[n/a|0]<<24):a>6&&n%a==4&&(l=f[l>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l]),d[n]=o=(d[n-a]^l)>>>0);for(s=0;s<u;s++)n=u-s,l=3&s?d[n]:d[n-4],h[s]=s<4||n<=4?l:g[f[l>>>24]]^m[f[l>>>16&255]]^p[f[l>>>8&255]]^y[f[255&l]],h[s]=h[s]>>>0}},e.networkToHostOrderSwap=function(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24},e.decrypt=function(t,e,r){for(var i,a,n,s,o,l,u,d,h,f,c,v,g,m,p=this.keySize+6,y=this.invKeySchedule,E=this.invSBox,T=this.invSubMix,S=T[0],L=T[1],R=T[2],b=T[3],A=this.uint8ArrayToUint32Array_(r),k=A[0],D=A[1],_=A[2],x=A[3],w=new Int32Array(t),I=new Int32Array(w.length),C=this.networkToHostOrderSwap;e<w.length;){for(h=C(w[e]),f=C(w[e+1]),c=C(w[e+2]),v=C(w[e+3]),o=h^y[0],l=v^y[1],u=c^y[2],d=f^y[3],g=4,m=1;m<p;m++)i=S[o>>>24]^L[l>>16&255]^R[u>>8&255]^b[255&d]^y[g],a=S[l>>>24]^L[u>>16&255]^R[d>>8&255]^b[255&o]^y[g+1],n=S[u>>>24]^L[d>>16&255]^R[o>>8&255]^b[255&l]^y[g+2],s=S[d>>>24]^L[o>>16&255]^R[l>>8&255]^b[255&u]^y[g+3],o=i,l=a,u=n,d=s,g+=4;i=E[o>>>24]<<24^E[l>>16&255]<<16^E[u>>8&255]<<8^E[255&d]^y[g],a=E[l>>>24]<<24^E[u>>16&255]<<16^E[d>>8&255]<<8^E[255&o]^y[g+1],n=E[u>>>24]<<24^E[d>>16&255]<<16^E[o>>8&255]<<8^E[255&l]^y[g+2],s=E[d>>>24]<<24^E[o>>16&255]<<16^E[l>>8&255]<<8^E[255&u]^y[g+3],I[e]=C(i^k),I[e+1]=C(s^D),I[e+2]=C(n^_),I[e+3]=C(a^x),k=h,D=f,_=c,x=v,e+=4}return I.buffer},t}(),ur=function(){function t(t,e){var r=(void 0===e?{}:e).removePKCS7Padding,i=void 0===r||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 a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(t){}null===this.subtle&&(this.useSoftware=!0)}var e=t.prototype;return e.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},e.isSync=function(){return this.useSoftware},e.flush=function(){var t=this.currentResult,e=this.remainderData;if(!t||e)return this.reset(),null;var r,i,a,n=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?(i=(r=n).byteLength,(a=i&&new DataView(r.buffer).getUint8(i-1))?K(r,0,i-a):r):n},e.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},e.decrypt=function(t,e,r){var i=this;return this.useSoftware?new Promise((function(a,n){i.softwareDecrypt(new Uint8Array(t),e,r);var s=i.flush();s?a(s.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(t),e,r)},e.softwareDecrypt=function(t,e,r){var i=this.currentIV,a=this.currentResult,n=this.remainderData;this.logOnce("JS AES decrypt"),n&&(t=Et(n,t),this.remainderData=null);var s=this.getValidChunk(t);if(!s.length)return null;i&&(r=i);var o=this.softwareDecrypter;o||(o=this.softwareDecrypter=new lr),o.expandKey(e);var l=a;return this.currentResult=o.decrypt(s.buffer,0,r),this.currentIV=K(s,-16).buffer,l||null},e.webCryptoDecrypt=function(t,e,r){var i=this,a=this.subtle;return this.key===e&&this.fastAesKey||(this.key=e,this.fastAesKey=new or(a,e)),this.fastAesKey.expandKey().then((function(e){return a?(i.logOnce("WebCrypto AES decrypt"),new sr(a,new Uint8Array(r)).decrypt(t.buffer,e)):Promise.reject(new Error("web crypto not initialized"))})).catch((function(a){return D.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+a.name+": "+a.message),i.onWebCryptoError(t,e,r)}))},e.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")},e.getValidChunk=function(t){var e=t,r=t.length-t.length%16;return r!==t.length&&(e=K(t,0,r),this.remainderData=K(t,r)),e},e.logOnce=function(t){this.logEnabled&&(D.log("[decrypter]: "+t),this.logEnabled=!1)},t}(),dr=function(t){for(var e="",r=t.length,i=0;i<r;i++)e+="["+t.start(i).toFixed(3)+"-"+t.end(i).toFixed(3)+"]";return e},hr="STOPPED",fr="IDLE",cr="KEY_LOADING",vr="FRAG_LOADING",gr="FRAG_LOADING_WAITING_RETRY",mr="PARSING",pr="PARSED",yr="ENDED",Er="ERROR",Tr="WAITING_LEVEL",Sr=function(t){function e(e,r,i,a,n){var s;return(s=t.call(this)||this).hls=void 0,s.fragPrevious=null,s.fragCurrent=null,s.fragmentTracker=void 0,s.transmuxer=null,s._state=hr,s.playlistType=void 0,s.media=null,s.mediaBuffer=null,s.config=void 0,s.bitrateTest=!1,s.lastCurrentTime=0,s.nextLoadPosition=0,s.startPosition=0,s.startTimeOffset=null,s.loadedmetadata=!1,s.retryDate=0,s.levels=null,s.fragmentLoader=void 0,s.keyLoader=void 0,s.levelLastLoaded=null,s.startFragRequested=!1,s.decrypter=void 0,s.initPTS=[],s.onvseeking=null,s.onvended=null,s.logPrefix="",s.log=void 0,s.warn=void 0,s.playlistType=n,s.logPrefix=a,s.log=D.log.bind(D,a+":"),s.warn=D.warn.bind(D,a+":"),s.hls=e,s.fragmentLoader=new ze(e.config),s.keyLoader=i,s.fragmentTracker=r,s.config=e.config,s.decrypter=new ur(e.config),e.on(E.MANIFEST_LOADED,s.onManifestLoaded,function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(s)),s}l(e,t);var r=e.prototype;return r.doTick=function(){this.onTickEnd()},r.onTickEnd=function(){},r.startLoad=function(t){},r.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();var t=this.fragCurrent;null!=t&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=hr},r._streamEnded=function(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;var r=e.partList;if(null!=r&&r.length){var i=r[r.length-1];return er.isBuffered(this.media,i.start+i.duration/2)}var a=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(a)},r.getLevelDetails=function(){var t;if(this.levels&&null!==this.levelLastLoaded)return null==(t=this.levels[this.levelLastLoaded])?void 0:t.details},r.onMediaAttached=function(t,e){var r=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);var i=this.config;this.levels&&i.autoStartLoad&&this.state===hr&&this.startLoad(i.startPosition)},r.onMediaDetaching=function(){var t=this.media;null!=t&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},r.onMediaSeeking=function(){var t=this.config,e=this.fragCurrent,r=this.media,i=this.mediaBuffer,a=this.state,n=r?r.currentTime:0,s=er.bufferInfo(i||r,n,t.maxBufferHole);if(this.log("media seeking to "+(y(n)?n.toFixed(3):n)+", state: "+a),this.state===yr)this.resetLoadingState();else if(e){var o=t.maxFragLookUpTolerance,l=e.start-o,u=e.start+e.duration+o;if(!s.len||u<s.start||l>s.end){var d=n>u;(n<l||d)&&(d&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.abortRequests()),this.resetLoadingState())}}r&&(this.fragmentTracker.removeFragmentsInRange(n,1/0,this.playlistType,!0),this.lastCurrentTime=n),this.loadedmetadata||s.len||(this.nextLoadPosition=this.startPosition=n),this.tickImmediate()},r.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},r.onManifestLoaded=function(t,e){this.startTimeOffset=e.startTimeOffset,this.initPTS=[]},r.onHandlerDestroying=function(){this.stopLoad(),t.prototype.onHandlerDestroying.call(this)},r.onHandlerDestroyed=function(){this.state=hr,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,t.prototype.onHandlerDestroyed.call(this)},r.loadFragment=function(t,e,r){this._loadFragForPlayback(t,e,r)},r._loadFragForPlayback=function(t,e,r){var i=this;this._doFragLoad(t,e,r,(function(e){if(i.fragContextChanged(t))return i.warn("Fragment "+t.sn+(e.part?" p: "+e.part.index:"")+" of level "+t.level+" was dropped during download."),void i.fragmentTracker.removeFragment(t);t.stats.chunkCount++,i._handleFragmentLoadProgress(e)})).then((function(e){if(e){var r=i.state;i.fragContextChanged(t)?(r===vr||!i.fragCurrent&&r===mr)&&(i.fragmentTracker.removeFragment(t),i.state=fr):("payload"in e&&(i.log("Loaded fragment "+t.sn+" of level "+t.level),i.hls.trigger(E.FRAG_LOADED,e)),i._handleFragmentLoadComplete(e))}})).catch((function(e){i.state!==hr&&i.state!==Er&&(i.warn(e),i.resetFragmentLoading(t))}))},r.clearTrackerIfNeeded=function(t){var e;if(this.fragmentTracker.getState(t)===He){var r=t.type,i=this.getFwdBufferInfo(this.mediaBuffer,r),a=Math.max(t.duration,i?i.len:this.config.maxBufferLength);this.reduceMaxBufferLength(a)&&this.fragmentTracker.removeFragment(t)}else 0===(null==(e=this.mediaBuffer)?void 0:e.buffered.length)&&this.fragmentTracker.removeAllFragments()},r.flushMainBuffer=function(t,e,r){if(void 0===r&&(r=null),t-e){var i={startOffset:t,endOffset:e,type:r};this.hls.trigger(E.BUFFER_FLUSHING,i)}},r._loadInitSegment=function(t,e){var r=this;this._doFragLoad(t,e).then((function(e){if(!e||r.fragContextChanged(t)||!r.levels)throw new Error("init load aborted");return e})).then((function(e){var i=r.hls,a=e.payload,n=t.decryptdata;if(a&&a.byteLength>0&&n&&n.key&&n.iv&&"AES-128"===n.method){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(a),n.key.buffer,n.iv.buffer).catch((function(e){throw i.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e})).then((function(r){var a=self.performance.now();return i.trigger(E.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:s,tdecrypt:a}}),e.payload=r,e}))}return e})).then((function(i){var a=r.fragCurrent,n=r.hls;if(!r.levels)throw new Error("init load aborted, missing levels");var s=t.stats;r.state=fr,e.fragmentError=0,t.data=new Uint8Array(i.payload),s.parsing.start=s.buffering.start=self.performance.now(),s.parsing.end=s.buffering.end=self.performance.now(),i.frag===a&&n.trigger(E.FRAG_BUFFERED,{stats:s,frag:a,part:null,id:t.type}),r.tick()})).catch((function(e){r.state!==hr&&r.state!==Er&&(r.warn(e),r.resetFragmentLoading(t))}))},r.fragContextChanged=function(t){var e=this.fragCurrent;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId},r.fragBufferedComplete=function(t,e){var r,i,a,n,s=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(e?" part: "+e.index:"")+" of "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level+" (frag:["+(null!=(r=t.startPTS)?r:NaN).toFixed(3)+"-"+(null!=(i=t.endPTS)?i:NaN).toFixed(3)+"] > buffer:"+(s?dr(er.getBuffered(s)):"(detached)")+")"),this.state=fr,s&&(!this.loadedmetadata&&t.type==Wt&&s.buffered.length&&(null==(a=this.fragCurrent)?void 0:a.sn)===(null==(n=this.fragPrevious)?void 0:n.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},r.seekToStartPos=function(){},r._handleFragmentLoadComplete=function(t){var e=this.transmuxer;if(e){var r=t.frag,i=t.part,a=t.partsLoaded,n=!a||0===a.length||a.some((function(t){return!t})),s=new rr(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!n);e.flush(s)}},r._handleFragmentLoadProgress=function(t){},r._doFragLoad=function(t,e,r,i){var a,n=this;void 0===r&&(r=null);var s=null==e?void 0:e.details;if(!this.levels||!s)throw new Error("frag load aborted, missing level"+(s?"":" detail")+"s");var o=null;if(!t.encrypted||null!=(a=t.decryptdata)&&a.key?!t.encrypted&&s.encryptedFragments.length&&this.keyLoader.loadClear(t,s.encryptedFragments):(this.log("Loading key for "+t.sn+" of ["+s.startSN+"-"+s.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level),this.state=cr,this.fragCurrent=t,o=this.keyLoader.load(t).then((function(t){if(!n.fragContextChanged(t.frag))return n.hls.trigger(E.KEY_LOADED,t),n.state===cr&&(n.state=fr),t})),this.hls.trigger(E.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),r=Math.max(t.start,r||0),this.config.lowLatencyMode){var l=s.partList;if(l&&i){r>t.end&&s.fragmentHint&&(t=s.fragmentHint);var u=this.getNextPart(l,t,r);if(u>-1){var d,h=l[u];return this.log("Loading part sn: "+t.sn+" p: "+h.index+" cc: "+t.cc+" of playlist ["+s.startSN+"-"+s.endSN+"] parts [0-"+u+"-"+(l.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=h.start+h.duration,this.state=vr,d=o?o.then((function(r){return!r||n.fragContextChanged(r.frag)?null:n.doFragPartsLoad(t,h,e,i)})).catch((function(t){return n.handleFragLoadError(t)})):this.doFragPartsLoad(t,h,e,i).catch((function(t){return n.handleFragLoadError(t)})),this.hls.trigger(E.FRAG_LOADING,{frag:t,part:h,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):d}if(!t.url||this.loadedEndOfParts(l,r))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(s?"of ["+s.startSN+"-"+s.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),y(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=vr;var f,c=this.config.progressive;return f=c&&o?o.then((function(e){return!e||n.fragContextChanged(null==e?void 0:e.frag)?null:n.fragmentLoader.load(t,i)})).catch((function(t){return n.handleFragLoadError(t)})):Promise.all([this.fragmentLoader.load(t,c?i:void 0),o]).then((function(t){var e=t[0];return!c&&e&&i&&i(e),e})).catch((function(t){return n.handleFragLoadError(t)})),this.hls.trigger(E.FRAG_LOADING,{frag:t,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):f},r.doFragPartsLoad=function(t,e,r,i){var a=this;return new Promise((function(n,s){var o,l=[],u=null==(o=r.details)?void 0:o.partList;!function e(o){a.fragmentLoader.loadPart(t,o,i).then((function(i){l[o.index]=i;var s=i.part;a.hls.trigger(E.FRAG_LOADED,i);var d=me(r,t.sn,o.index+1)||pe(u,t.sn,o.index+1);if(!d)return n({frag:t,part:s,partsLoaded:l});e(d)})).catch(s)}(e)}))},r.handleFragLoadError=function(t){if("data"in t){var e=t.data;t.data&&e.details===S.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(E.ERROR,e)}else this.hls.trigger(E.ERROR,{type:T.OTHER_ERROR,details:S.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},r._handleTransmuxerFlush=function(t){var e=this.getCurrentContext(t);if(e&&this.state===mr){var r=e.frag,i=e.part,a=e.level,n=self.performance.now();r.stats.parsing.end=n,i&&(i.stats.parsing.end=n),this.updateLevelTiming(r,i,a,t.partial)}else this.fragCurrent||this.state===hr||this.state===Er||(this.state=fr)},r.getCurrentContext=function(t){var e=this.levels,r=this.fragCurrent,i=t.level,a=t.sn,n=t.part;if(null==e||!e[i])return this.warn("Levels object was unset while buffering fragment "+a+" of level "+i+". The current chunk will not be buffered."),null;var s=e[i],o=n>-1?me(s,a,n):null,l=o?o.fragment:function(t,e,r){if(null==t||!t.details)return null;var i=t.details,a=i.fragments[e-i.startSN];return a||((a=i.fragmentHint)&&a.sn===e?a:e<i.startSN&&r&&r.sn===e?r:null)}(s,a,r);return l?(r&&r!==l&&(l.stats=r.stats),{frag:l,part:o,level:s}):null},r.bufferFragmentData=function(t,e,r,i){var a;if(t&&this.state===mr){var n=t.data1,s=t.data2,o=n;if(n&&s&&(o=Et(n,s)),null!=(a=o)&&a.length){var l={type:t.type,frag:e,part:r,chunkMeta:i,parent:e.type,data:o};this.hls.trigger(E.BUFFER_APPENDING,l),t.dropped&&t.independent&&!r&&this.flushBufferGap(e)}}},r.flushBufferGap=function(t){var e=this.media;if(e)if(er.isBuffered(e,e.currentTime)){var r=e.currentTime,i=er.bufferInfo(e,r,0),a=t.duration,n=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),s=Math.max(Math.min(t.start-n,i.end-n),r+n);t.start-s>n&&this.flushMainBuffer(s,t.start)}else this.flushMainBuffer(0,t.start)},r.getFwdBufferInfo=function(t,e){var r=this.getLoadPosition();return y(r)?this.getFwdBufferInfoAtPos(t,r,e):null},r.getFwdBufferInfoAtPos=function(t,e,r){var i=this.config.maxBufferHole,a=er.bufferInfo(t,e,i);if(0===a.len&&void 0!==a.nextStart){var n=this.fragmentTracker.getBufferedFrag(e,r);if(n&&a.nextStart<n.end)return er.bufferInfo(t,e,Math.max(a.nextStart,i))}return a},r.getMaxBufferLength=function(t){var e,r=this.config;return e=t?Math.max(8*r.maxBufferSize/t,r.maxBufferLength):r.maxBufferLength,Math.min(e,r.maxMaxBufferLength)},r.reduceMaxBufferLength=function(t){var e=this.config,r=t||e.maxBufferLength;return e.maxMaxBufferLength>=r&&(e.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+e.maxMaxBufferLength+"s"),!0)},r.getNextFragment=function(t,e){var r=e.fragments,i=r.length;if(!i)return null;var a,n=this.config,s=r[0].start;if(e.live){var o=n.initialLiveManifestSize;if(i<o)return this.warn("Not enough fragments to start playback (have: "+i+", need: "+o+")"),null;e.PTSKnown||this.startFragRequested||-1!==this.startPosition||(a=this.getInitialLiveFragment(e,r),this.startPosition=a?this.hls.liveSyncPosition||a.start:t)}else t<=s&&(a=r[0]);if(!a){var l=n.lowLatencyMode?e.partEnd:e.fragmentEnd;a=this.getFragmentAtPosition(t,l,e)}return this.mapToInitFragWhenRequired(a)},r.isLoopLoading=function(t,e){var r=this.fragmentTracker.getState(t);return(r===Ve||r===Ke&&!!t.gap)&&this.nextLoadPosition>e},r.getNextFragmentLoopLoading=function(t,e,r,i,a){var n=t.gap,s=this.getNextFragment(this.nextLoadPosition,e);if(null===s)return s;if(t=s,n&&t&&!t.gap&&r.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i);if(null!==o&&r.len+o.len>=a)return this.log('buffer full after gaps in "'+i+'" playlist starting at sn: '+t.sn),null}return t},r.mapToInitFragWhenRequired=function(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment},r.getNextPart=function(t,e,r){for(var i=-1,a=!1,n=!0,s=0,o=t.length;s<o;s++){var l=t[s];if(n=n&&!l.independent,i>-1&&r<l.start)break;var u=l.loaded;u?i=-1:(a||l.independent||n)&&l.fragment===e&&(i=s),a=u}return i},r.loadedEndOfParts=function(t,e){var r=t[t.length-1];return r&&e>r.start&&r.loaded},r.getInitialLiveFragment=function(t,e){var r=this.fragPrevious,i=null;if(r){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=function(t,e,r){if(null===e||!Array.isArray(t)||!t.length||!y(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;i<t.length;++i){var a=t[i];if(ke(e,r,a))return a}return null}(e,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var a=r.sn+1;if(a>=t.startSN&&a<=t.endSN){var n=e[a-t.startSN];r.cc===n.cc&&(i=n,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=function(t,e){return Re(t,(function(t){return t.cc<e?1:t.cc>e?-1:0}))}(e,r.cc),i&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn))}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?t.fragmentEnd:t.edge,t))}return i},r.getFragmentAtPosition=function(t,e,r){var i,a=this.config,n=this.fragPrevious,s=r.fragments,o=r.endSN,l=r.fragmentHint,u=a.maxFragLookUpTolerance,d=!!(a.lowLatencyMode&&r.partList&&l);if(d&&l&&!this.bitrateTest&&(s=s.concat(l),o=l.sn),i=t<e?be(n,s,t,t>e-u?0:u):s[s.length-1]){var h=i.sn-r.startSN,f=this.fragmentTracker.getState(i);if((f===Ve||f===Ke&&i.gap)&&(n=i),n&&i.sn===n.sn&&!d&&n&&i.level===n.level){var c=s[h+1];i=i.sn<o&&this.fragmentTracker.getState(c)!==Ve?c:null}}return i},r.synchronizeToLiveEdge=function(t){var e=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,a=r.currentTime,n=t.fragments[0].start,s=t.edge,o=a>=n-e.maxFragLookUpTolerance&&a<=s;if(null!==i&&r.duration>i&&(a<i||!o)){var l=void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!o&&r.readyState<4||a<s-l)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState&&(this.warn("Playback: "+a.toFixed(3)+" is located too far from the end of live sliding playlist: "+s+", reset currentTime to : "+i.toFixed(3)),r.currentTime=i))}}},r.alignPlaylists=function(t,e){var r=this.levels,i=this.levelLastLoaded,a=this.fragPrevious,n=null!==i?r[i]:null,s=t.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;var o=t.fragments[0].start,l=!e,u=t.alignedSliding&&y(o);if(l||!u&&!o){nr(a,n,t);var d=t.fragments[0].start;return this.log("Live playlist sliding: "+d.toFixed(2)+" start-sn: "+(e?e.startSN:"na")+"->"+t.startSN+" prev-sn: "+(a?a.sn:"na")+" fragments: "+s),d}return o},r.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},r.setStartPosition=function(t,e){var r=this.startPosition;if(r<e&&(r=-1),-1===r||-1===this.lastCurrentTime){var i=null!==this.startTimeOffset,a=i?this.startTimeOffset:t.startTimeOffset;null!==a&&y(a)?(r=e+a,a<0&&(r+=t.totalduration),r=Math.min(Math.max(e,r),e+t.totalduration),this.log("Start time offset "+a+" found in "+(i?"multivariant":"media")+" playlist, adjust startPosition to "+r),this.startPosition=r):t.live?r=this.hls.liveSyncPosition||e:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},r.getLoadPosition=function(){var t=this.media,e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e},r.handleFragLoadAborted=function(t,e){this.transmuxer&&"initSegment"!==t.sn&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(e?" part"+e.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},r.resetFragmentLoading=function(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===gr)||(this.state=fr)},r.onFragmentOrKeyLoadError=function(t,e){if(e.chunkMeta&&!e.frag){var r=this.getCurrentContext(e.chunkMeta);r&&(e.frag=r.frag)}var i=e.frag;if(i&&i.type===t&&this.levels)if(this.fragContextChanged(i)){var a;this.warn("Frag load error must match current frag to retry "+i.url+" > "+(null==(a=this.fragCurrent)?void 0:a.url))}else{var n=e.details===S.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,!0);var s=e.errorAction,o=s||{},l=o.action,u=o.retryCount,d=void 0===u?0:u,h=o.retryConfig;if(s&&l===Ie&&h){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var f=Te(h,d);this.warn("Fragment "+i.sn+" of "+t+" "+i.level+" errored with "+e.details+", retrying loading "+(d+1)+"/"+h.maxNumRetry+" in "+f+"ms"),s.resolved=!0,this.retryDate=self.performance.now()+f,this.state=gr}else h&&s?(this.resetFragmentErrors(t),d<h.maxNumRetry?n||(s.resolved=!0):D.warn(e.details+" reached or exceeded max retry ("+d+")")):this.state=Er;this.tickImmediate()}},r.reduceLengthAndFlushBuffer=function(t){if(this.state===mr||this.state===pr){var e=t.parent,r=this.getFwdBufferInfo(this.mediaBuffer,e),i=r&&r.len>.5;i&&this.reduceMaxBufferLength(r.len);var a=!i;return a&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+e+" buffer"),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),a}return!1},r.resetFragmentErrors=function(t){t===Yt&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==hr&&(this.state=fr)},r.afterBufferFlushed=function(t,e,r){if(t){var i=er.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,i,r),this.state===yr&&this.resetLoadingState()}},r.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=fr},r.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var e=this.levels?this.levels[t].details:null;null!=e&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},r.resetWhenMissingContext=function(t){this.warn("The loading context changed while buffering fragment "+t.sn+" of level "+t.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(t.level),this.resetLoadingState()},r.removeUnbufferedFrags=function(t){void 0===t&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},r.updateLevelTiming=function(t,e,r,i){var a,n=this,s=r.details;if(s){if(Object.keys(t.elementaryStreams).reduce((function(e,a){var o=t.elementaryStreams[a];if(o){var l=o.endPTS-o.startPTS;if(l<=0)return n.warn("Could not parse fragment "+t.sn+" "+a+" duration reliably ("+l+")"),e||!1;var u=i?0:ce(s,t,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return n.hls.trigger(E.LEVEL_PTS_UPDATED,{details:s,level:r,drift:u,type:a,frag:t,start:o.startPTS,end:o.endPTS}),!0}return e}),!1))r.fragmentError=0;else if(null===(null==(a=this.transmuxer)?void 0:a.error)){var o=new Error("Found no media in fragment "+t.sn+" of level "+r.id+" resetting transmuxer to fallback to playlist timing");if(this.warn(o.message),this.hls.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_PARSING_ERROR,fatal:!1,error:o,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+r.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=pr,this.hls.trigger(E.FRAG_PARSED,{frag:t,part:e})}else this.warn("level.details undefined")},r.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},r.recoverWorkerError=function(t){"demuxerWorker"===t.event&&(this.resetTransmuxer(),this.resetLoadingState())},n(e,[{key:"state",get:function(){return this._state},set:function(t){var e=this._state;e!==t&&(this._state=t,this.log(e+"->"+t))}}]),e}(Je);function Lr(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}function Rr(){return self.SourceBuffer||self.WebKitSourceBuffer}function br(t,e){return void 0===t&&(t=""),void 0===e&&(e=9e4),{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var Ar=function(){function t(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var e=t.prototype;return e.resetInitSegment=function(t,e,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},e.resetTimeStamp=function(t){this.initPTS=t,this.resetContiguity()},e.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},e.canParse=function(t,e){return!1},e.appendFrame=function(t,e,r){},e.demux=function(t,e){this.cachedData&&(t=Et(this.cachedData,t),this.cachedData=null);var r,i=j(t,0),a=i?i.length:0,n=this._audioTrack,s=this._id3Track,o=i?function(t){for(var e=$(t),r=0;r<e.length;r++){var i=e[r];if(X(i))return rt(i)}}(i):void 0,l=t.length;for((null===this.basePTS||0===this.frameIndex&&y(o))&&(this.basePTS=kr(o,e,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Zt,duration:Number.POSITIVE_INFINITY});a<l;){if(this.canParse(t,a)){var u=this.appendFrame(n,t,a);u?(this.frameIndex++,this.lastPTS=u.sample.pts,r=a+=u.length):a=l}else z(t,a)?(i=j(t,a),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Zt,duration:Number.POSITIVE_INFINITY}),r=a+=i.length):a++;if(a===l&&r!==l){var d=K(t,r);this.cachedData?this.cachedData=Et(this.cachedData,d):this.cachedData=d}}return{audioTrack:n,videoTrack:br(),id3Track:s,textTrack:br()}},e.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},e.flush=function(t){var e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:br(),id3Track:this._id3Track,textTrack:br()}},e.destroy=function(){},t}(),kr=function(t,e,r){return y(t)?90*t:9e4*e+(r?9e4*r.baseTime/r.timescale:0)};function Dr(t,e){return 255===t[e]&&240==(246&t[e+1])}function _r(t,e){return 1&t[e+1]?7:9}function xr(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function wr(t,e){return e+1<t.length&&Dr(t,e)}function Ir(t,e){if(wr(t,e)){var r=_r(t,e);if(e+r>=t.length)return!1;var i=xr(t,e);if(i<=r)return!1;var a=e+i;return a===t.length||wr(t,a)}return!1}function Cr(t,e,r,i,a){if(!t.samplerate){var n=function(t,e,r,i){var a,n,s,o,l=navigator.userAgent.toLowerCase(),u=i,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];a=1+((192&e[r+2])>>>6);var h=(60&e[r+2])>>>2;if(!(h>d.length-1))return s=(1&e[r+2])<<2,s|=(192&e[r+3])>>>6,D.log("manifest codec:"+i+", ADTS type:"+a+", samplingIndex:"+h),/firefox/i.test(l)?h>=6?(a=5,o=new Array(4),n=h-3):(a=2,o=new Array(2),n=h):-1!==l.indexOf("android")?(a=2,o=new Array(2),n=h):(a=5,o=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&h>=6?n=h-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(h>=6&&1===s||/vivaldi/i.test(l))||!i&&1===s)&&(a=2,o=new Array(2)),n=h)),o[0]=a<<3,o[0]|=(14&h)>>1,o[1]|=(1&h)<<7,o[1]|=s<<3,5===a&&(o[1]|=(14&n)>>1,o[2]=(1&n)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:d[h],channelCount:s,codec:"mp4a.40."+a,manifestCodec:u};t.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+h})}(e,r,i,a);if(!n)return;t.config=n.config,t.samplerate=n.samplerate,t.channelCount=n.channelCount,t.codec=n.codec,t.manifestCodec=n.manifestCodec,D.log("parsed codec:"+t.codec+", rate:"+n.samplerate+", channels:"+n.channelCount)}}function Pr(t){return 9216e4/t}function Fr(t,e,r,i,a){var n,s=i+a*Pr(t.samplerate),o=function(t,e){var r=_r(t,e);if(e+r<=t.length){var i=xr(t,e)-r;if(i>0)return{headerLength:r,frameLength:i}}}(e,r);if(o){var l=o.frameLength,u=o.headerLength,d=u+l,h=Math.max(0,r+d-e.length);h?(n=new Uint8Array(d-u)).set(e.subarray(r+u,e.length),0):n=e.subarray(r+u,r+d);var f={unit:n,pts:s};return h||t.samples.push(f),{sample:f,length:d,missing:h}}var c=e.length-r;return(n=new Uint8Array(c)).set(e.subarray(r,e.length),0),{sample:{unit:n,pts:s},length:c,missing:-1}}var Or=function(t){function e(e,r){var i;return(i=t.call(this)||this).observer=void 0,i.config=void 0,i.observer=e,i.config=r,i}l(e,t);var r=e.prototype;return r.resetInitSegment=function(e,r,i,a){t.prototype.resetInitSegment.call(this,e,r,i,a),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},e.probe=function(t){if(!t)return!1;for(var e=(j(t,0)||[]).length,r=t.length;e<r;e++)if(Ir(t,e))return D.log("ADTS sync word found !"),!0;return!1},r.canParse=function(t,e){return function(t,e){return function(t,e){return e+5<t.length}(t,e)&&Dr(t,e)&&xr(t,e)<=t.length-e}(t,e)},r.appendFrame=function(t,e,r){Cr(t,this.observer,e,r,t.manifestCodec);var i=Fr(t,e,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i},e}(Ar),Mr=/\/emsg[-/]ID3/i,Nr=function(){function t(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 e=t.prototype;return e.resetTimeStamp=function(){},e.resetInitSegment=function(t,e,r,i){var a=this.videoTrack=br("video",1),n=this.audioTrack=br("audio",1),s=this.txtTrack=br("text",1);if(this.id3Track=br("id3",1),this.timeOffset=0,null!=t&&t.byteLength){var o=mt(t);if(o.video){var l=o.video,u=l.id,d=l.timescale,h=l.codec;a.id=u,a.timescale=s.timescale=d,a.codec=h}if(o.audio){var f=o.audio,c=f.id,v=f.timescale,g=f.codec;n.id=c,n.timescale=v,n.codec=g}s.id=lt.text,a.sampleDuration=0,a.duration=n.duration=i}},e.resetContiguity=function(){},t.probe=function(t){return vt(t=t.length>16384?t.subarray(0,16384):t,["moof"]).length>0},e.demux=function(t,e){this.timeOffset=e;var r=t,i=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Et(this.remainderData,t));var n=function(t){var e={valid:null,remainder:null},r=vt(t,["moof"]);if(!r)return e;if(r.length<2)return e.remainder=t,e;var i=r[r.length-1];return e.valid=K(t,0,i.byteOffset-8),e.remainder=K(t,i.byteOffset-8),e}(r);this.remainderData=n.remainder,i.samples=n.valid||new Uint8Array}else i.samples=r;var s=this.extractID3Track(i,e);return a.samples=Tt(e,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},e.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=Tt(t,e),{videoTrack:e,audioTrack:br(),id3Track:i,textTrack:br()}},e.extractID3Track=function(t,e){var r=this.id3Track;if(t.samples.length){var i=vt(t.samples,["emsg"]);i&&i.forEach((function(t){var i=function(t){var e=t[0],r="",i="",a=0,n=0,s=0,o=0,l=0,u=0;if(0===e){for(;"\0"!==ut(t.subarray(u,u+1));)r+=ut(t.subarray(u,u+1)),u+=1;for(r+=ut(t.subarray(u,u+1)),u+=1;"\0"!==ut(t.subarray(u,u+1));)i+=ut(t.subarray(u,u+1)),u+=1;i+=ut(t.subarray(u,u+1)),u+=1,a=ht(t,12),n=ht(t,16),o=ht(t,20),l=ht(t,24),u=28}else if(1===e){a=ht(t,u+=4);var d=ht(t,u+=4),h=ht(t,u+=4);for(u+=4,s=Math.pow(2,32)*d+h,Number.isSafeInteger(s)||(s=Number.MAX_SAFE_INTEGER,D.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ht(t,u),l=ht(t,u+=4),u+=4;"\0"!==ut(t.subarray(u,u+1));)r+=ut(t.subarray(u,u+1)),u+=1;for(r+=ut(t.subarray(u,u+1)),u+=1;"\0"!==ut(t.subarray(u,u+1));)i+=ut(t.subarray(u,u+1)),u+=1;i+=ut(t.subarray(u,u+1)),u+=1}return{schemeIdUri:r,value:i,timeScale:a,presentationTime:s,presentationTimeDelta:n,eventDuration:o,id:l,payload:t.subarray(u,t.byteLength)}}(t);if(Mr.test(i.schemeIdUri)){var a=y(i.presentationTime)?i.presentationTime/i.timeScale:e+i.presentationTimeDelta/i.timeScale,n=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;n<=.001&&(n=Number.POSITIVE_INFINITY);var s=i.payload;r.samples.push({data:s,len:s.byteLength,dts:a,pts:a,type:te,duration:n})}}))}return r},e.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},e.destroy=function(){},t}(),Br=null,Ur=[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],Gr=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Hr=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Kr=[0,1,1,4];function Vr(t,e,r,i,a){if(!(r+24>e.length)){var n=Wr(e,r);if(n&&r+n.frameLength<=e.length){var s=i+a*(9e4*n.samplesPerFrame/n.sampleRate),o={unit:e.subarray(r,r+n.frameLength),pts:s,dts:s};return t.config=[],t.channelCount=n.channelCount,t.samplerate=n.sampleRate,t.samples.push(o),{sample:o,length:n.frameLength,missing:0}}}}function Wr(t,e){var r=t[e+1]>>3&3,i=t[e+1]>>1&3,a=t[e+2]>>4&15,n=t[e+2]>>2&3;if(1!==r&&0!==a&&15!==a&&3!==n){var s=t[e+2]>>1&1,o=t[e+3]>>6,l=1e3*Ur[14*(3===r?3-i:3===i?3:4)+a-1],u=Gr[3*(3===r?0:2===r?1:2)+n],d=3===o?1:2,h=Hr[r][i],f=Kr[i],c=8*h*f,v=Math.floor(h*l/u+s)*f;if(null===Br){var g=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Br=g?parseInt(g[1]):0}return!!Br&&Br<=87&&2===i&&l>=224e3&&0===o&&(t[e+3]=128|t[e+3]),{sampleRate:u,channelCount:d,frameLength:v,samplesPerFrame:c}}}function Yr(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function jr(t,e){return e+1<t.length&&Yr(t,e)}function qr(t,e){if(e+1<t.length&&Yr(t,e)){var r=Wr(t,e),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var a=e+i;return a===t.length||jr(t,a)}return!1}var zr=function(){function t(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 e=t.prototype;return e.loadWord=function(){var t=this.data,e=this.bytesAvailable,r=t.byteLength-e,i=new Uint8Array(4),a=Math.min(4,e);if(0===a)throw new Error("no bytes available");i.set(t.subarray(r,r+a)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a},e.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)},e.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;if(t>32&&D.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},e.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if(0!=(this.word&2147483648>>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},e.skipUEG=function(){this.skipBits(1+this.skipLZ())},e.skipEG=function(){this.skipBits(1+this.skipLZ())},e.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},e.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},e.readBoolean=function(){return 1===this.readBits(1)},e.readUByte=function(){return this.readBits(8)},e.readUShort=function(){return this.readBits(16)},e.readUInt=function(){return this.readBits(32)},e.skipScalingList=function(t){for(var e=8,r=8,i=0;i<t;i++)0!==r&&(r=(e+this.readEG()+256)%256),e=0===r?e:r},e.readSPS=function(){var t,e,r,i=0,a=0,n=0,s=0,o=this.readUByte.bind(this),l=this.readBits.bind(this),u=this.readUEG.bind(this),d=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),c=this.skipUEG.bind(this),v=this.skipScalingList.bind(this);o();var g=o();if(l(5),h(3),o(),c(),100===g||110===g||122===g||244===g||44===g||83===g||86===g||118===g||128===g){var m=u();if(3===m&&h(1),c(),c(),h(1),d())for(e=3!==m?8:12,r=0;r<e;r++)d()&&v(r<6?16:64)}c();var p=u();if(0===p)u();else if(1===p)for(h(1),f(),f(),t=u(),r=0;r<t;r++)f();c(),h(1);var y=u(),E=u(),T=l(1);0===T&&h(1),h(1),d()&&(i=u(),a=u(),n=u(),s=u());var S=[1,1];if(d()&&d())switch(o()){case 1:S=[1,1];break;case 2:S=[12,11];break;case 3:S=[10,11];break;case 4:S=[16,11];break;case 5:S=[40,33];break;case 6:S=[24,11];break;case 7:S=[20,11];break;case 8:S=[32,11];break;case 9:S=[80,33];break;case 10:S=[18,11];break;case 11:S=[15,11];break;case 12:S=[64,33];break;case 13:S=[160,99];break;case 14:S=[4,3];break;case 15:S=[3,2];break;case 16:S=[2,1];break;case 255:S=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(y+1)-2*i-2*a),height:(2-T)*(E+1)*16-(T?2:4)*(n+s),pixelRatio:S}},e.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},t}(),Xr=function(){function t(t,e,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new ur(e,{removePKCS7Padding:!1})}var e=t.prototype;return e.decryptBuffer=function(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)},e.decryptAacSample=function(t,e,r){var i=this,a=t[e].unit;if(!(a.length<=16)){var n=a.subarray(16,a.length-a.length%16),s=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(s).then((function(n){var s=new Uint8Array(n);a.set(s,16),i.decrypter.isSync()||i.decryptAacSamples(t,e+1,r)}))}},e.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}},e.getAvcEncryptedData=function(t){for(var e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e),i=0,a=32;a<t.length-16;a+=160,i+=16)r.set(t.subarray(a,a+16),i);return r},e.getAvcDecryptedUnit=function(t,e){for(var r=new Uint8Array(e),i=0,a=32;a<t.length-16;a+=160,i+=16)t.set(r.subarray(i,i+16),a);return t},e.decryptAvcSample=function(t,e,r,i,a){var n=this,s=Rt(a.data),o=this.getAvcEncryptedData(s);this.decryptBuffer(o.buffer).then((function(o){a.data=n.getAvcDecryptedUnit(s,o),n.decrypter.isSync()||n.decryptAvcSamples(t,e,r+1,i)}))},e.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 a=t[e].units;!(r>=a.length);r++){var n=a[r];if(!(n.data.length<=48||1!==n.type&&5!==n.type||(this.decryptAvcSample(t,e,r,i,n),this.decrypter.isSync())))return}}},t}(),Qr=188,$r=function(){function t(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._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=r}t.probe=function(e){var r=t.syncOffset(e);return r>0&&D.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},t.syncOffset=function(t){for(var e=t.length,r=Math.min(940,t.length-Qr)+1,i=0;i<r;){for(var a=!1,n=i;n<e&&71===t[n];n+=Qr)if(a||0!==Jr(t,n)||(a=!0),a&&n+Qr>r)return i;i++}return-1},t.createTrack=function(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:lt[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}};var e=t.prototype;return e.resetInitSegment=function(e,r,i,a){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=t.createTrack("video"),this._audioTrack=t.createTrack("audio",a),this._id3Track=t.createTrack("id3"),this._txtTrack=t.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i,this._duration=a},e.resetTimeStamp=function(){},e.resetContiguity=function(){var t=this._audioTrack,e=this._avcTrack,r=this._id3Track;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},e.demux=function(e,r,i,a){var n;void 0===i&&(i=!1),void 0===a&&(a=!1),i||(this.sampleAes=null);var s=this._avcTrack,o=this._audioTrack,l=this._id3Track,u=this._txtTrack,d=s.pid,h=s.pesData,f=o.pid,c=l.pid,v=o.pesData,g=l.pesData,m=null,p=this.pmtParsed,y=this._pmtId,L=e.length;if(this.remainderData&&(L=(e=Et(this.remainderData,e)).length,this.remainderData=null),L<Qr&&!a)return this.remainderData=e,{audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};var R=Math.max(0,t.syncOffset(e));(L-=(L-R)%Qr)<e.byteLength&&!a&&(this.remainderData=new Uint8Array(e.buffer,L,e.buffer.byteLength-L));for(var b=0,A=R;A<L;A+=Qr)if(71===e[A]){var k=!!(64&e[A+1]),_=Jr(e,A),x=void 0;if((48&e[A+3])>>4>1){if((x=A+5+e[A+4])===A+Qr)continue}else x=A+4;switch(_){case d:k&&(h&&(n=ri(h))&&this.parseAVCPES(s,u,n,!1),h={data:[],size:0}),h&&(h.data.push(e.subarray(x,A+Qr)),h.size+=A+Qr-x);break;case f:if(k){if(v&&(n=ri(v)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n)}v={data:[],size:0}}v&&(v.data.push(e.subarray(x,A+Qr)),v.size+=A+Qr-x);break;case c:k&&(g&&(n=ri(g))&&this.parseID3PES(l,n),g={data:[],size:0}),g&&(g.data.push(e.subarray(x,A+Qr)),g.size+=A+Qr-x);break;case 0:k&&(x+=e[x]+1),y=this._pmtId=ti(e,x);break;case y:k&&(x+=e[x]+1);var w=ei(e,x,this.typeSupported,i);(d=w.avc)>0&&(s.pid=d),(f=w.audio)>0&&(o.pid=f,o.segmentCodec=w.segmentCodec),(c=w.id3)>0&&(l.pid=c),null===m||p||(D.warn("MPEG-TS PMT found at "+A+" after unknown PID '"+m+"'. Backtracking to sync byte @"+R+" to parse all TS packets."),m=null,A=R-188),p=this.pmtParsed=!0;break;case 17:case 8191:break;default:m=_}}else b++;if(b>0){var I=new Error("Found "+b+" TS packet/s that do not start with 0x47");this.observer.emit(E.ERROR,E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_PARSING_ERROR,fatal:!1,error:I,reason:I.message})}s.pesData=h,o.pesData=v,l.pesData=g;var C={audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};return a&&this.extractRemainingSamples(C),C},e.flush=function(){var t,e=this.remainderData;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},e.extractRemainingSamples=function(t){var e,r=t.audioTrack,i=t.videoTrack,a=t.id3Track,n=t.textTrack,s=i.pesData,o=r.pesData,l=a.pesData;if(s&&(e=ri(s))?(this.parseAVCPES(i,n,e,!0),i.pesData=null):i.pesData=s,o&&(e=ri(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,e);break;case"mp3":this.parseMPEGPES(r,e)}r.pesData=null}else null!=o&&o.size&&D.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(e=ri(l))?(this.parseID3PES(a,e),a.pesData=null):a.pesData=l},e.demuxSampleAes=function(t,e,r){var i=this.demux(t,r,!0,!this.config.progressive),a=this.sampleAes=new Xr(this.observer,this.config,e);return this.decrypt(i,a)},e.decrypt=function(t,e){return new Promise((function(r){var i=t.audioTrack,a=t.videoTrack;i.samples&&"aac"===i.segmentCodec?e.decryptAacSamples(i.samples,0,(function(){a.samples?e.decryptAvcSamples(a.samples,0,0,(function(){r(t)})):r(t)})):a.samples&&e.decryptAvcSamples(a.samples,0,0,(function(){r(t)}))}))},e.destroy=function(){this._duration=0},e.parseAVCPES=function(t,e,r,i){var a,n=this,s=this.parseAVCNALu(t,r.data),o=this.avcSample,l=!1;r.data=null,o&&s.length&&!t.audFound&&(ii(o,t),o=this.avcSample=Zr(!1,r.pts,r.dts,"")),s.forEach((function(i){switch(i.type){case 1:a=!0,o||(o=n.avcSample=Zr(!0,r.pts,r.dts,"")),o.frame=!0;var s=i.data;if(l&&s.length>4){var u=new zr(s).readSliceType();2!==u&&4!==u&&7!==u&&9!==u||(o.key=!0)}break;case 5:a=!0,o||(o=n.avcSample=Zr(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:a=!0,Lt(i.data,1,r.pts,e.samples);break;case 7:if(a=!0,l=!0,!t.sps){var d=i.data,h=new zr(d).readSPS();t.width=h.width,t.height=h.height,t.pixelRatio=h.pixelRatio,t.sps=[d],t.duration=n._duration;for(var f=d.subarray(1,4),c="avc1.",v=0;v<3;v++){var g=f[v].toString(16);g.length<2&&(g="0"+g),c+=g}t.codec=c}break;case 8:a=!0,t.pps||(t.pps=[i.data]);break;case 9:a=!1,t.audFound=!0,o&&ii(o,t),o=n.avcSample=Zr(!1,r.pts,r.dts,"");break;case 12:a=!0;break;default:a=!1,o&&(o.debug+="unknown NAL "+i.type+" ")}o&&a&&o.units.push(i)})),i&&o&&(ii(o,t),this.avcSample=null)},e.getLastNalUnit=function(t){var e,r,i=this.avcSample;if(i&&0!==i.units.length||(i=t[t.length-1]),null!=(e=i)&&e.units){var a=i.units;r=a[a.length-1]}return r},e.parseAVCNALu=function(t,e){var r,i,a=e.byteLength,n=t.naluState||0,s=n,o=[],l=0,u=-1,d=0;for(-1===n&&(u=0,d=31&e[0],n=0,l=1);l<a;)if(r=e[l++],n)if(1!==n)if(r)if(1===r){if(u>=0){var h={data:e.subarray(u,l-n-1),type:d};o.push(h)}else{var f=this.getLastNalUnit(t.samples);if(f&&(s&&l<=4-s&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-s)),(i=l-n-1)>0)){var c=new Uint8Array(f.data.byteLength+i);c.set(f.data,0),c.set(e.subarray(0,i),f.data.byteLength),f.data=c,f.state=0}}l<a?(u=l,d=31&e[l],n=0):n=-1}else n=0;else n=3;else n=r?0:2;else n=r?0:1;if(u>=0&&n>=0){var v={data:e.subarray(u,a),type:d,state:n};o.push(v)}if(0===o.length){var g=this.getLastNalUnit(t.samples);if(g){var m=new Uint8Array(g.data.byteLength+e.byteLength);m.set(g.data,0),m.set(e,g.data.byteLength),g.data=m}}return t.naluState=n,o},e.parseAACPES=function(t,e){var r,i,a,n=0,s=this.aacOverFlow,o=e.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;if(-1===l){var d=new Uint8Array(u+o.byteLength);d.set(s.sample.unit,0),d.set(o,u),o=d}else{var h=u-l;s.sample.unit.set(o.subarray(0,l),h),t.samples.push(s.sample),n=s.missing}}for(r=n,i=o.length;r<i-1&&!wr(o,r);r++);if(r!==n){var f,c=r<i-1;f=c?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES";var v=new Error(f);if(D.warn("parsing error: "+f),this.observer.emit(E.ERROR,E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_PARSING_ERROR,fatal:!1,levelRetry:c,error:v,reason:f}),!c)return}if(Cr(t,this.observer,o,r,this.audioCodec),void 0!==e.pts)a=e.pts;else{if(!s)return void D.warn("[tsdemuxer]: AAC PES unknown PTS");var g=Pr(t.samplerate);a=s.sample.pts+g}for(var m,p=0;r<i;){if(r+=(m=Fr(t,o,r,a,p)).length,m.missing){this.aacOverFlow=m;break}for(p++;r<i-1&&!wr(o,r);r++);}},e.parseMPEGPES=function(t,e){var r=e.data,i=r.length,a=0,n=0,s=e.pts;if(void 0!==s)for(;n<i;)if(jr(r,n)){var o=Vr(t,r,n,s,a);if(!o)break;n+=o.length,a++}else n++;else D.warn("[tsdemuxer]: MPEG PES unknown PTS")},e.parseID3PES=function(t,e){if(void 0!==e.pts){var r=o({},e,{type:this._avcTrack?te:Zt,duration:Number.POSITIVE_INFINITY});t.samples.push(r)}else D.warn("[tsdemuxer]: ID3 PES unknown PTS")},t}();function Zr(t,e,r,i){return{key:t,frame:!1,pts:e,dts:r,units:[],debug:i,length:0}}function Jr(t,e){return((31&t[e+1])<<8)+t[e+2]}function ti(t,e){return(31&t[e+10])<<8|t[e+11]}function ei(t,e,r,i){var a={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},n=e+3+((15&t[e+1])<<8|t[e+2])-4;for(e+=12+((15&t[e+10])<<8|t[e+11]);e<n;){var s=Jr(t,e);switch(t[e]){case 207:if(!i){D.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===a.audio&&(a.audio=s);break;case 21:-1===a.id3&&(a.id3=s);break;case 219:if(!i){D.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===a.avc&&(a.avc=s);break;case 3:case 4:!0!==r.mpeg&&!0!==r.mp3?D.log("MPEG audio found, not supported in this browser"):-1===a.audio&&(a.audio=s,a.segmentCodec="mp3");break;case 36:D.warn("Unsupported HEVC stream type found")}e+=5+((15&t[e+3])<<8|t[e+4])}return a}function ri(t){var e,r,i,a,n,s=0,o=t.data;if(!t||0===t.size)return null;for(;o[0].length<19&&o.length>1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(1===((e=o[0])[0]<<16)+(e[1]<<8)+e[2]){if((r=(e[4]<<8)+e[5])&&r>t.size-6)return null;var u=e[7];192&u&&(a=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&u?a-(n=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2)>54e5&&(D.warn(Math.round((a-n)/9e4)+"s delta between PTS and DTS, align them"),a=n):n=a);var d=(i=e[8])+9;if(t.size<=d)return null;t.size-=d;for(var h=new Uint8Array(t.size),f=0,c=o.length;f<c;f++){var v=(e=o[f]).byteLength;if(d){if(d>v){d-=v;continue}e=e.subarray(d),v-=d,d=0}h.set(e,s),s+=v}return r&&(r-=i+3),{data:h,pts:a,dts:n,len:r}}return null}function ii(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){var r=e.samples,i=r.length;if(!i)return void e.dropped++;var a=r[i-1];t.pts=a.pts,t.dts=a.dts}e.samples.push(t)}t.debug.length&&D.log(t.pts+"/"+t.dts+":"+t.debug)}var ai=function(t){function e(){return t.apply(this,arguments)||this}l(e,t);var r=e.prototype;return r.resetInitSegment=function(e,r,i,a){t.prototype.resetInitSegment.call(this,e,r,i,a),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},e.probe=function(t){if(!t)return!1;for(var e=(j(t,0)||[]).length,r=t.length;e<r;e++)if(qr(t,e))return D.log("MPEG Audio sync word found !"),!0;return!1},r.canParse=function(t,e){return function(t,e){return Yr(t,e)&&4<=t.length-e}(t,e)},r.appendFrame=function(t,e,r){if(null!==this.basePTS)return Vr(t,e,r,this.basePTS,this.frameIndex)},e}(Ar),ni=function(){function t(){}return t.getSilentFrame=function(t,e){if("mp4a.40.2"===t){if(1===e)return new Uint8Array([0,200,0,128,35,128]);if(2===e)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===e)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},t}(),si=Math.pow(2,32)-1,oi=function(){function t(){}return t.init=function(){var e;for(e in t.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},t.types)t.types.hasOwnProperty(e)&&(t.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var r=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]);t.HDLR_TYPES={video:r,audio:i};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);t.STTS=t.STSC=t.STCO=n,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);t.FTYP=t.box(t.types.ftyp,s,l,s,o),t.DINF=t.box(t.types.dinf,t.box(t.types.dref,a))},t.box=function(t){for(var e=8,r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];for(var n=i.length,s=n;n--;)e+=i[n].byteLength;var o=new Uint8Array(e);for(o[0]=e>>24&255,o[1]=e>>16&255,o[2]=e>>8&255,o[3]=255&e,o.set(t,4),n=0,e=8;n<s;n++)o.set(i[n],e),e+=i[n].byteLength;return o},t.hdlr=function(e){return t.box(t.types.hdlr,t.HDLR_TYPES[e])},t.mdat=function(e){return t.box(t.types.mdat,e)},t.mdhd=function(e,r){r*=e;var i=Math.floor(r/(si+1)),a=Math.floor(r%(si+1));return t.box(t.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,255&e,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},t.mdia=function(e){return t.box(t.types.mdia,t.mdhd(e.timescale,e.duration),t.hdlr(e.type),t.minf(e))},t.mfhd=function(e){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},t.minf=function(e){return"audio"===e.type?t.box(t.types.minf,t.box(t.types.smhd,t.SMHD),t.DINF,t.stbl(e)):t.box(t.types.minf,t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(e))},t.moof=function(e,r,i){return t.box(t.types.moof,t.mfhd(e),t.traf(i,r))},t.moov=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trak(e[r]);return t.box.apply(null,[t.types.moov,t.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(t.mvex(e)))},t.mvex=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trex(e[r]);return t.box.apply(null,[t.types.mvex].concat(i))},t.mvhd=function(e,r){r*=e;var i=Math.floor(r/(si+1)),a=Math.floor(r%(si+1)),n=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,255&e,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,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 t.box(t.types.mvhd,n)},t.sdtp=function(e){var r,i,a=e.samples||[],n=new Uint8Array(4+a.length);for(r=0;r<a.length;r++)i=a[r].flags,n[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return t.box(t.types.sdtp,n)},t.stbl=function(e){return t.box(t.types.stbl,t.stsd(e),t.box(t.types.stts,t.STTS),t.box(t.types.stsc,t.STSC),t.box(t.types.stsz,t.STSZ),t.box(t.types.stco,t.STCO))},t.avc1=function(e){var r,i,a,n=[],s=[];for(r=0;r<e.sps.length;r++)a=(i=e.sps[r]).byteLength,n.push(a>>>8&255),n.push(255&a),n=n.concat(Array.prototype.slice.call(i));for(r=0;r<e.pps.length;r++)a=(i=e.pps[r]).byteLength,s.push(a>>>8&255),s.push(255&a),s=s.concat(Array.prototype.slice.call(i));var o=t.box(t.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|e.sps.length].concat(n).concat([e.pps.length]).concat(s))),l=e.width,u=e.height,d=e.pixelRatio[0],h=e.pixelRatio[1];return t.box(t.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,u>>8&255,255&u,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,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))},t.esds=function(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))},t.mp4a=function(e){var r=e.samplerate;return t.box(t.types.mp4a,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,r>>8&255,255&r,0,0]),t.box(t.types.esds,t.esds(e)))},t.mp3=function(e){var r=e.samplerate;return t.box(t.types[".mp3"],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,r>>8&255,255&r,0,0]))},t.stsd=function(e){return"audio"===e.type?"mp3"===e.segmentCodec&&"mp3"===e.codec?t.box(t.types.stsd,t.STSD,t.mp3(e)):t.box(t.types.stsd,t.STSD,t.mp4a(e)):t.box(t.types.stsd,t.STSD,t.avc1(e))},t.tkhd=function(e){var r=e.id,i=e.duration*e.timescale,a=e.width,n=e.height,s=Math.floor(i/(si+1)),o=Math.floor(i%(si+1));return t.box(t.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,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,a>>8&255,255&a,0,0,n>>8&255,255&n,0,0]))},t.traf=function(e,r){var i=t.sdtp(e),a=e.id,n=Math.floor(r/(si+1)),s=Math.floor(r%(si+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s])),t.trun(e,i.length+16+20+8+16+8+8),i)},t.trak=function(e){return e.duration=e.duration||4294967295,t.box(t.types.trak,t.tkhd(e),t.mdia(e))},t.trex=function(e){var r=e.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},t.trun=function(e,r){var i,a,n,s,o,l,u=e.samples||[],d=u.length,h=12+16*d,f=new Uint8Array(h);for(r+=8+h,f.set(["video"===e.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<d;i++)n=(a=u[i]).duration,s=a.size,o=a.flags,l=a.cts,f.set([n>>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,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*i);return t.box(t.types.trun,f)},t.initSegment=function(e){t.types||t.init();var r=t.moov(e),i=new Uint8Array(t.FTYP.byteLength+r.byteLength);return i.set(t.FTYP),i.set(r,t.FTYP.byteLength),i},t}();function li(t,e){return void 0===e&&(e=!1),function(t,e,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var a=t*e*r;return i?Math.round(a):a}(t,1e3,1/9e4,e)}oi.types=void 0,oi.HDLR_TYPES=void 0,oi.STTS=void 0,oi.STSC=void 0,oi.STCO=void 0,oi.STSZ=void 0,oi.VMHD=void 0,oi.SMHD=void 0,oi.STSD=void 0,oi.FTYP=void 0,oi.DINF=void 0;var ui=null,di=null,hi=function(){function t(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.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,null===ui){var a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ui=a?parseInt(a[1]):0}if(null===di){var n=navigator.userAgent.match(/Safari\/(\d+)/i);di=n?parseInt(n[1]):0}}var e=t.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){D.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},e.resetNextTimestamp=function(){D.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},e.resetInitSegment=function(){D.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},e.getVideoStartPts=function(t){var e=!1,r=t.reduce((function(t,r){var i=r.pts-t;return i<-4294967296?(e=!0,fi(t,r.pts)):i>0?t:r.pts}),t[0].pts);return e&&D.debug("PTS rollover detected"),r},e.remux=function(t,e,r,i,a,n,s,o){var l,u,d,h,f,c,v=a,g=a,m=t.pid>-1,p=e.pid>-1,y=e.samples.length,E=t.samples.length>0,T=s&&y>0||y>1;if((!m||E)&&(!p||T)||this.ISGenerated||s){this.ISGenerated||(d=this.generateIS(t,e,a,n));var S,L=this.isVideoContiguous,R=-1;if(T&&(R=function(t){for(var e=0;e<t.length;e++)if(t[e].key)return e;return-1}(e.samples),!L&&this.config.forceKeyFrameOnDiscontinuity))if(c=!0,R>0){D.warn("[mp4-remuxer]: Dropped "+R+" out of "+y+" video samples due to a missing keyframe");var b=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(R),e.dropped+=R,S=g+=(e.samples[0].pts-b)/e.inputTimeScale}else-1===R&&(D.warn("[mp4-remuxer]: No keyframe found out of "+y+" video samples"),c=!1);if(this.ISGenerated){if(E&&T){var A=this.getVideoStartPts(e.samples),k=(fi(t.samples[0].pts,A)-A)/e.inputTimeScale;v+=Math.max(0,k),g+=Math.max(0,-k)}if(E){if(t.samplerate||(D.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(t,e,a,n)),u=this.remuxAudio(t,v,this.isAudioContiguous,n,p||T||o===Yt?g:void 0),T){var _=u?u.endPTS-u.startPTS:0;e.inputTimeScale||(D.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(t,e,a,n)),l=this.remuxVideo(e,g,L,_)}}else T&&(l=this.remuxVideo(e,g,L,0));l&&(l.firstKeyFrame=R,l.independent=-1!==R,l.firstKeyFramePTS=S)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=ci(r,a,this._initPTS,this._initDTS)),i.samples.length&&(h=vi(i,a,this._initPTS))),{audio:u,video:l,initSegment:d,independent:c,text:h,id3:f}},e.generateIS=function(t,e,r,i){var a,n,s,o=t.samples,l=e.samples,u=this.typeSupported,d={},h=this._initPTS,f=!h||i,c="audio/mp4";if(f&&(a=n=1/0),t.config&&o.length&&(t.timescale=t.samplerate,"mp3"===t.segmentCodec&&(u.mpeg?(c="audio/mpeg",t.codec=""):u.mp3&&(t.codec="mp3")),d.audio={id:"audio",container:c,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&u.mpeg?new Uint8Array(0):oi.initSegment([t]),metadata:{channelCount:t.channelCount}},f&&(s=t.inputTimeScale,h&&s===h.timescale?f=!1:a=n=o[0].pts-Math.round(s*r))),e.sps&&e.pps&&l.length&&(e.timescale=e.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:oi.initSegment([e]),metadata:{width:e.width,height:e.height}},f))if(s=e.inputTimeScale,h&&s===h.timescale)f=!1;else{var v=this.getVideoStartPts(l),g=Math.round(s*r);n=Math.min(n,fi(l[0].dts,v)-g),a=Math.min(a,v-g)}if(Object.keys(d).length)return this.ISGenerated=!0,f?(this._initPTS={baseTime:a,timescale:s},this._initDTS={baseTime:n,timescale:s}):a=s=void 0,{tracks:d,initPTS:a,timescale:s}},e.remuxVideo=function(t,e,r,i){var a,n,s=t.inputTimeScale,l=t.samples,u=[],d=l.length,h=this._initPTS,f=this.nextAvcDts,c=8,v=this.videoSampleDuration,g=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,p=!1;r&&null!==f||(f=e*s-(l[0].pts-fi(l[0].dts,l[0].pts)));for(var y=h.baseTime*s/h.timescale,L=0;L<d;L++){var R=l[L];R.pts=fi(R.pts-y,f),R.dts=fi(R.dts-y,f),R.dts<l[L>0?L-1:L].dts&&(p=!0)}p&&l.sort((function(t,e){var r=t.dts-e.dts,i=t.pts-e.pts;return r||i})),a=l[0].dts;var b=(n=l[l.length-1].dts)-a,A=b?Math.round(b/(d-1)):v||t.inputTimeScale/30;if(r){var k=a-f,_=k>A,x=k<-1;if((_||x)&&(_?D.warn("AVC: "+li(k,!0)+" ms ("+k+"dts) hole between fragments detected, filling it"):D.warn("AVC: "+li(-k,!0)+" ms ("+k+"dts) overlapping between fragments detected"),!x||f>l[0].pts)){a=f;var w=l[0].pts-k;l[0].dts=a,l[0].pts=w,D.log("Video: First PTS/DTS adjusted: "+li(w,!0)+"/"+li(a,!0)+", delta: "+li(k,!0)+" ms")}}a=Math.max(0,a);for(var I=0,C=0,P=0;P<d;P++){for(var F=l[P],O=F.units,M=O.length,N=0,B=0;B<M;B++)N+=O[B].data.length;C+=N,I+=M,F.length=N,F.dts=Math.max(F.dts,a),g=Math.min(F.pts,g),m=Math.max(F.pts,m)}n=l[d-1].dts;var U,G=C+4*I+8;try{U=new Uint8Array(G)}catch(t){return void this.observer.emit(E.ERROR,E.ERROR,{type:T.MUX_ERROR,details:S.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:G,reason:"fail allocating video mdat "+G})}var H=new DataView(U.buffer);H.setUint32(0,G),U.set(oi.types.mdat,4);for(var K=!1,V=Number.POSITIVE_INFINITY,W=Number.POSITIVE_INFINITY,Y=Number.NEGATIVE_INFINITY,j=Number.NEGATIVE_INFINITY,q=0;q<d;q++){for(var z=l[q],X=z.units,Q=0,$=0,Z=X.length;$<Z;$++){var J=X[$],tt=J.data,et=J.data.byteLength;H.setUint32(c,et),c+=4,U.set(tt,c),c+=et,Q+=4+et}var rt=void 0;if(q<d-1)v=l[q+1].dts-z.dts,rt=l[q+1].pts-z.pts;else{var it=this.config,at=q>0?z.dts-l[q-1].dts:A;if(rt=q>0?z.pts-l[q-1].pts:A,it.stretchShortVideoTrack&&null!==this.nextAudioPts){var nt=Math.floor(it.maxBufferHole*s),st=(i?g+i*s:this.nextAudioPts)-z.pts;st>nt?((v=st-at)<0?v=at:K=!0,D.log("[mp4-remuxer]: It is approximately "+st/90+" ms to the next segment; using duration "+v/90+" ms for the last video frame.")):v=at}else v=at}var ot=Math.round(z.pts-z.dts);V=Math.min(V,v),Y=Math.max(Y,v),W=Math.min(W,rt),j=Math.max(j,rt),u.push(new mi(z.key,v,Q,ot))}if(u.length)if(ui){if(ui<70){var lt=u[0].flags;lt.dependsOn=2,lt.isNonSync=0}}else if(di&&j-W<Y-V&&A/Y<.025&&0===u[0].cts){D.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ut=a,dt=0,ht=u.length;dt<ht;dt++){var ft=ut+u[dt].duration,ct=ut+u[dt].cts;if(dt<ht-1){var vt=ft+u[dt+1].cts;u[dt].duration=vt-ct}else u[dt].duration=dt?u[dt-1].duration:A;u[dt].cts=0,ut=ft}}v=K||!v?A:v,this.nextAvcDts=f=n+v,this.videoSampleDuration=v,this.isVideoContiguous=!0;var gt={data1:oi.moof(t.sequenceNumber++,a,o({},t,{samples:u})),data2:U,startPTS:g/s,endPTS:(m+v)/s,startDTS:a/s,endDTS:f/s,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:t.dropped};return t.samples=[],t.dropped=0,gt},e.remuxAudio=function(t,e,r,i,a){var n=t.inputTimeScale,s=n/(t.samplerate?t.samplerate:n),l="aac"===t.segmentCodec?1024:1152,u=l*s,d=this._initPTS,h="mp3"===t.segmentCodec&&this.typeSupported.mpeg,f=[],c=void 0!==a,v=t.samples,g=h?0:8,m=this.nextAudioPts||-1,p=e*n,y=d.baseTime*n/d.timescale;if(this.isAudioContiguous=r=r||v.length&&m>0&&(i&&Math.abs(p-m)<9e3||Math.abs(fi(v[0].pts-y,p)-m)<20*u),v.forEach((function(t){t.pts=fi(t.pts-y,p)})),!r||m<0){if(v=v.filter((function(t){return t.pts>=0})),!v.length)return;m=0===a?0:i&&!c?Math.max(0,p):v[0].pts}if("aac"===t.segmentCodec)for(var L=this.config.maxAudioFramesDrift,R=0,b=m;R<v.length;R++){var A=v[R],k=A.pts,_=k-b,x=Math.abs(1e3*_/n);if(_<=-L*u&&c)0===R&&(D.warn("Audio frame @ "+(k/n).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*_/n)+" ms."),this.nextAudioPts=m=b=k);else if(_>=L*u&&x<1e4&&c){var w=Math.round(_/u);(b=k-w*u)<0&&(w--,b+=u),0===R&&(this.nextAudioPts=m=b),D.warn("[mp4-remuxer]: Injecting "+w+" audio frame @ "+(b/n).toFixed(3)+"s due to "+Math.round(1e3*_/n)+" ms gap.");for(var I=0;I<w;I++){var C=Math.max(b,0),P=ni.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);P||(D.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),P=A.unit.subarray()),v.splice(R,0,{unit:P,pts:C}),b+=u,R++}}A.pts=b,b+=u}for(var F,O=null,M=null,N=0,B=v.length;B--;)N+=v[B].unit.byteLength;for(var U=0,G=v.length;U<G;U++){var H=v[U],K=H.unit,V=H.pts;if(null!==M)f[U-1].duration=Math.round((V-M)/s);else{if(r&&"aac"===t.segmentCodec&&(V=m),O=V,!(N>0))return;N+=g;try{F=new Uint8Array(N)}catch(t){return void this.observer.emit(E.ERROR,E.ERROR,{type:T.MUX_ERROR,details:S.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:N,reason:"fail allocating audio mdat "+N})}h||(new DataView(F.buffer).setUint32(0,N),F.set(oi.types.mdat,4))}F.set(K,g);var W=K.byteLength;g+=W,f.push(new mi(!0,l,W,0)),M=V}var Y=f.length;if(Y){var j=f[f.length-1];this.nextAudioPts=m=M+s*j.duration;var q=h?new Uint8Array(0):oi.moof(t.sequenceNumber++,O/s,o({},t,{samples:f}));t.samples=[];var z=O/n,X=m/n,Q={data1:q,data2:F,startPTS:z,endPTS:X,startDTS:z,endDTS:X,type:"audio",hasAudio:!0,hasVideo:!1,nb:Y};return this.isAudioContiguous=!0,Q}},e.remuxEmptyAudio=function(t,e,r,i){var a=t.inputTimeScale,n=a/(t.samplerate?t.samplerate:a),s=this.nextAudioPts,o=this._initDTS,l=9e4*o.baseTime/o.timescale,u=(null!==s?s:i.startDTS*a)+l,d=i.endDTS*a+l,h=1024*n,f=Math.ceil((d-u)/h),c=ni.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(D.warn("[mp4-remuxer]: remux empty Audio"),c){for(var v=[],g=0;g<f;g++){var m=u+g*h;v.push({unit:c,pts:m,dts:m})}return t.samples=v,this.remuxAudio(t,e,r,!1)}D.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},t}();function fi(t,e){var r;if(null===e)return t;for(r=e<t?-8589934592:8589934592;Math.abs(t-e)>4294967296;)t+=r;return t}function ci(t,e,r,i){var a=t.samples.length;if(a){for(var n=t.inputTimeScale,s=0;s<a;s++){var o=t.samples[s];o.pts=fi(o.pts-9e4*r.baseTime/r.timescale,e*n)/n,o.dts=fi(o.dts-9e4*i.baseTime/i.timescale,e*n)/n}var l=t.samples;return t.samples=[],{samples:l}}}function vi(t,e,r){var i=t.samples.length;if(i){for(var a=t.inputTimeScale,n=0;n<i;n++){var s=t.samples[n];s.pts=fi(s.pts-9e4*r.baseTime/r.timescale,e*a)/a}t.samples.sort((function(t,e){return t.pts-e.pts}));var o=t.samples;return t.samples=[],{samples:o}}}var gi,mi=function(t,e,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=r,this.cts=i,this.flags=new pi(t)},pi=function(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1},yi=function(){function t(){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 e=t.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){this.initPTS=t,this.lastEndTime=null},e.resetNextTimestamp=function(){this.lastEndTime=null},e.resetInitSegment=function(t,e,r,i){this.audioCodec=e,this.videoCodec=r,this.generateInitSegment(pt(t,i)),this.emitInitSegment=!0},e.generateInitSegment=function(t){var e=this.audioCodec,r=this.videoCodec;if(null==t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=mt(t);e||(e=Ei(i.audio,F)),r||(r=Ei(i.video,O));var a={};i.audio&&i.video?a.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:i.audio?a.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:i.video?a.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:D.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},e.remux=function(t,e,r,i,a,n){var s,o,l=this.initPTS,u=this.lastEndTime,d={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};y(u)||(u=this.lastEndTime=a||0);var h=e.samples;if(null==h||!h.length)return d;var f={initPTS:void 0,timescale:1},c=this.initData;if(null!=(s=c)&&s.length||(this.generateInitSegment(h),c=this.initData),null==(o=c)||!o.length)return D.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);var v=function(t,e){return vt(e,["moof","traf"]).reduce((function(e,r){var i=vt(r,["tfdt"])[0],a=i[0],n=vt(r,["tfhd"]).reduce((function(e,r){var n=ht(r,4),s=t[n];if(s){var o=ht(i,4);if(1===a){if(o===st)return D.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),e;o*=st+1,o+=ht(i,8)}var l=o/(s.timescale||9e4);if(isFinite(l)&&(null===e||l<e))return l}return e}),null);return null!==n&&isFinite(n)&&(null===e||n<e)?n:e}),null)}(c,h),g=null===v?a:v;(function(t,e,r){if(null===t)return!0;var i=e-t.baseTime/t.timescale;return i<0&&Math.abs(i-r)>1}(l,g,a)||f.timescale!==l.timescale&&n)&&(f.initPTS=g-a,this.initPTS=l={baseTime:f.initPTS,timescale:1});var m=function(t,e){for(var r=0,i=0,a=0,n=vt(t,["moof","traf"]),s=0;s<n.length;s++){var o=n[s],l=vt(o,["tfhd"])[0],u=e[ht(l,4)];if(u){var d=u.default,h=ht(l,0)|(null==d?void 0:d.flags),f=null==d?void 0:d.duration;8&h&&(f=ht(l,2&h?12:8));for(var c=u.timescale||9e4,v=vt(o,["trun"]),g=0;g<v.length;g++)!(r=yt(v[g]))&&f&&(r=f*ht(v[g],4)),u.type===O?i+=r/c:u.type===F&&(a+=r/c)}}if(0===i&&0===a){for(var m=0,p=vt(t,["sidx"]),y=0;y<p.length;y++){var E=gt(p[y]);null!=E&&E.references&&(m+=E.references.reduce((function(t,e){return t+e.info.duration||0}),0))}return m}return i||a}(h,c),p=t?g-l.baseTime/l.timescale:u,E=p+m;!function(t,e,r){vt(e,["moof","traf"]).forEach((function(e){vt(e,["tfhd"]).forEach((function(i){var a=ht(i,4),n=t[a];if(n){var s=n.timescale||9e4;vt(e,["tfdt"]).forEach((function(t){var e=t[0],i=ht(t,4);if(0===e)i-=r*s,ct(t,4,i=Math.max(i,0));else{i*=Math.pow(2,32),i+=ht(t,8),i-=r*s,i=Math.max(i,0);var a=Math.floor(i/(st+1)),n=Math.floor(i%(st+1));ct(t,4,a),ct(t,8,n)}}))}}))}))}(c,h,l.baseTime/l.timescale),m>0?this.lastEndTime=E:(D.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var T=!!c.audio,S=!!c.video,L="";T&&(L+="audio"),S&&(L+="video");var R={data1:h,startPTS:p,startDTS:p,endPTS:E,endDTS:E,type:L,hasAudio:T,hasVideo:S,nb:1,dropped:0};return d.audio="audio"===R.type?R:void 0,d.video="audio"!==R.type?R:void 0,d.initSegment=f,d.id3=ci(r,a,l,l),i.samples.length&&(d.text=vi(i,a,l)),d},t}();function Ei(t,e){var r=null==t?void 0:t.codec;return r&&r.length>4?r:"hvc1"===r||"hev1"===r?"hvc1.1.c.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||e===O?"avc1.42e01e":"mp4a.40.5"}try{gi=self.performance.now.bind(self.performance)}catch(t){D.debug("Unable to use Performance API on this environment"),gi="undefined"!=typeof self&&self.Date.now}var Ti=[{demux:Nr,remux:yi},{demux:$r,remux:hi},{demux:Or,remux:hi},{demux:ai,remux:hi}],Si=function(){function t(t,e,r,i,a){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=a}var e=t.prototype;return e.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},e.push=function(t,e,r,i){var a=this,n=r.transmuxing;n.executeStart=gi();var s=new Uint8Array(t),o=this.currentTransmuxState,l=this.transmuxConfig;i&&(this.currentTransmuxState=i);var u=i||o,d=u.contiguous,h=u.discontinuity,f=u.trackSwitch,c=u.accurateTimeOffset,v=u.timeOffset,g=u.initSegmentChange,m=l.audioCodec,p=l.videoCodec,y=l.defaultInitPts,L=l.duration,R=l.initSegmentData,b=function(t,e){var r=null;return t.byteLength>0&&null!=e&&null!=e.key&&null!==e.iv&&null!=e.method&&(r=e),r}(s,e);if(b&&"AES-128"===b.method){var A=this.getDecrypter();if(!A.isSync())return this.decryptionPromise=A.webCryptoDecrypt(s,b.key.buffer,b.iv.buffer).then((function(t){var e=a.push(t,null,r);return a.decryptionPromise=null,e})),this.decryptionPromise;var k=A.softwareDecrypt(s,b.key.buffer,b.iv.buffer);if(r.part>-1&&(k=A.flush()),!k)return n.executeEnd=gi(),Li(r);s=new Uint8Array(k)}var _=this.needsProbing(h,f);if(_){var x=this.configureTransmuxer(s);if(x)return D.warn("[transmuxer] "+x.message),this.observer.emit(E.ERROR,E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_PARSING_ERROR,fatal:!1,error:x,reason:x.message}),n.executeEnd=gi(),Li(r)}(h||f||g||_)&&this.resetInitSegment(R,m,p,L,e),(h||g||_)&&this.resetInitialTimestamp(y),d||this.resetContiguity();var w=this.transmux(s,b,v,c,r),I=this.currentTransmuxState;return I.contiguous=!0,I.discontinuity=!1,I.trackSwitch=!1,n.executeEnd=gi(),w},e.flush=function(t){var e=this,r=t.transmuxing;r.executeStart=gi();var i=this.decrypter,a=this.currentTransmuxState,n=this.decryptionPromise;if(n)return n.then((function(){return e.flush(t)}));var s=[],o=a.timeOffset;if(i){var l=i.flush();l&&s.push(this.push(l,null,t))}var u=this.demuxer,d=this.remuxer;if(!u||!d)return r.executeEnd=gi(),[Li(t)];var h=u.flush(o);return Ri(h)?h.then((function(r){return e.flushRemux(s,r,t),s})):(this.flushRemux(s,h,t),s)},e.flushRemux=function(t,e,r){var i=e.audioTrack,a=e.videoTrack,n=e.id3Track,s=e.textTrack,o=this.currentTransmuxState,l=o.accurateTimeOffset,u=o.timeOffset;D.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var d=this.remuxer.remux(i,a,n,s,u,l,!0,this.id);t.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=gi()},e.resetInitialTimestamp=function(t){var e=this.demuxer,r=this.remuxer;e&&r&&(e.resetTimeStamp(t),r.resetTimeStamp(t))},e.resetContiguity=function(){var t=this.demuxer,e=this.remuxer;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())},e.resetInitSegment=function(t,e,r,i,a){var n=this.demuxer,s=this.remuxer;n&&s&&(n.resetInitSegment(t,e,r,i),s.resetInitSegment(t,e,r,a))},e.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},e.transmux=function(t,e,r,i,a){return e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,r,i,a):this.transmuxUnencrypted(t,r,i,a)},e.transmuxUnencrypted=function(t,e,r,i){var a=this.demuxer.demux(t,e,!1,!this.config.progressive),n=a.audioTrack,s=a.videoTrack,o=a.id3Track,l=a.textTrack;return{remuxResult:this.remuxer.remux(n,s,o,l,e,r,!1,this.id),chunkMeta:i}},e.transmuxSampleAes=function(t,e,r,i,a){var n=this;return this.demuxer.demuxSampleAes(t,e,r).then((function(t){return{remuxResult:n.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,r,i,!1,n.id),chunkMeta:a}}))},e.configureTransmuxer=function(t){for(var e,r=this.config,i=this.observer,a=this.typeSupported,n=this.vendor,s=0,o=Ti.length;s<o;s++)if(Ti[s].demux.probe(t)){e=Ti[s];break}if(!e)return new Error("Failed to find demuxer by probing fragment data");var l=this.demuxer,u=this.remuxer,d=e.remux,h=e.demux;u&&u instanceof d||(this.remuxer=new d(i,r,a,n)),l&&l instanceof h||(this.demuxer=new h(i,r,a),this.probe=h.probe)},e.needsProbing=function(t,e){return!this.demuxer||!this.remuxer||t||e},e.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new ur(this.config)),t},t}(),Li=function(t){return{remuxResult:{},chunkMeta:t}};function Ri(t){return"then"in t&&t.then instanceof Function}var bi=function(t,e,r,i,a){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=r,this.duration=i,this.defaultInitPts=a||null},Ai=function(t,e,r,i,a,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=t,this.contiguous=e,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=a,this.initSegmentChange=n},ki={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,r="~";function i(){}function a(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function n(t,e,i,n,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new a(i,n||t,s),l=r?r+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],o]:t._events[l].push(o):(t._events[l]=o,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var t,i,a=[];if(0===this._eventsCount)return a;for(i in t=this._events)e.call(t,i)&&a.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(t)):a},o.prototype.listeners=function(t){var e=r?r+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var a=0,n=i.length,s=new Array(n);a<n;a++)s[a]=i[a].fn;return s},o.prototype.listenerCount=function(t){var e=r?r+t:t,i=this._events[e];return i?i.fn?1:i.length:0},o.prototype.emit=function(t,e,i,a,n,s){var o=r?r+t:t;if(!this._events[o])return!1;var l,u,d=this._events[o],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(t,d.fn,void 0,!0),h){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,e),!0;case 3:return d.fn.call(d.context,e,i),!0;case 4:return d.fn.call(d.context,e,i,a),!0;case 5:return d.fn.call(d.context,e,i,a,n),!0;case 6:return d.fn.call(d.context,e,i,a,n,s),!0}for(u=1,l=new Array(h-1);u<h;u++)l[u-1]=arguments[u];d.fn.apply(d.context,l)}else{var f,c=d.length;for(u=0;u<c;u++)switch(d[u].once&&this.removeListener(t,d[u].fn,void 0,!0),h){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,e);break;case 3:d[u].fn.call(d[u].context,e,i);break;case 4:d[u].fn.call(d[u].context,e,i,a);break;default:if(!l)for(f=1,l=new Array(h-1);f<h;f++)l[f-1]=arguments[f];d[u].fn.apply(d[u].context,l)}}return!0},o.prototype.on=function(t,e,r){return n(this,t,e,r,!1)},o.prototype.once=function(t,e,r){return n(this,t,e,r,!0)},o.prototype.removeListener=function(t,e,i,a){var n=r?r+t:t;if(!this._events[n])return this;if(!e)return s(this,n),this;var o=this._events[n];if(o.fn)o.fn!==e||a&&!o.once||i&&o.context!==i||s(this,n);else{for(var l=0,u=[],d=o.length;l<d;l++)(o[l].fn!==e||a&&!o[l].once||i&&o[l].context!==i)&&u.push(o[l]);u.length?this._events[n]=1===u.length?u[0]:u:s(this,n)}return this},o.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&s(this,e)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,t.exports=o}(ki);var Di=g(ki.exports);function _i(t,e){if(!((r=e.remuxResult).audio||r.video||r.text||r.id3||r.initSegment))return!1;var r,i=[],a=e.remuxResult,n=a.audio,s=a.video;return n&&xi(i,n),s&&xi(i,s),t.postMessage({event:"transmuxComplete",data:e},i),!0}function xi(t,e){e.data1&&t.push(e.data1.buffer),e.data2&&t.push(e.data2.buffer)}function wi(t,e,r){e.reduce((function(e,r){return _i(t,r)||e}),!1)||t.postMessage({event:"transmuxComplete",data:e[0]}),t.postMessage({event:"flush",data:r})}void 0!==e&&e&&function(t){var e=new Di,r=function(e,r){t.postMessage({event:e,data:r})};e.on(E.FRAG_DECRYPTED,r),e.on(E.ERROR,r);var i=function(){var t=function(t){var e=function(e){r("workerLog",{logType:t,message:e})};D[t]=e};for(var e in D)t(e)};t.addEventListener("message",(function(a){var n=a.data;switch(n.cmd){case"init":var s=JSON.parse(n.config);t.transmuxer=new Si(e,n.typeSupported,s,n.vendor,n.id),k(s.debug,n.id),i(),r("init",null);break;case"configure":t.transmuxer.configure(n.config);break;case"demux":var o=t.transmuxer.push(n.data,n.decryptdata,n.chunkMeta,n.state);Ri(o)?(t.transmuxer.async=!0,o.then((function(e){_i(t,e)})).catch((function(t){r(E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:t,err:t,reason:"transmuxer-worker push error"})}))):(t.transmuxer.async=!1,_i(t,o));break;case"flush":var l=n.chunkMeta,u=t.transmuxer.flush(l);Ri(u)||t.transmuxer.async?(Ri(u)||(u=Promise.resolve(u)),u.then((function(e){wi(t,e,l)})).catch((function(t){r(E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:t,err:t,reason:"transmuxer-worker flush error"})}))):wi(t,u,l)}}))}(self);var Ii=Lr()||{isTypeSupported:function(){return!1}},Ci=function(){function e(e,r,i,a){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 s=e.config;this.hls=e,this.id=r,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=i,this.onFlush=a;var o=function(t,e){(e=e||{}).frag=n.frag,e.id=n.id,t===E.ERROR&&(n.error=e.error),n.hls.trigger(t,e)};this.observer=new Di,this.observer.on(E.FRAG_DECRYPTED,o),this.observer.on(E.ERROR,o);var l,u,d,h,f={mp4:Ii.isTypeSupported("video/mp4"),mpeg:Ii.isTypeSupported("audio/mpeg"),mp3:Ii.isTypeSupported('audio/mp4; codecs="mp3"')},c=navigator.vendor;if(!this.useWorker||"undefined"==typeof Worker||(s.workerPath,0))this.transmuxer=new Si(this.observer,f,s,c,r);else try{s.workerPath?(D.log("loading Web Worker "+s.workerPath+' for "'+r+'"'),this.workerContext=(d=s.workerPath,h=new self.URL(d,self.location.href).href,{worker:new self.Worker(h),scriptURL:h})):(D.log('injecting Web Worker for "'+r+'"'),this.workerContext=(l=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+t.toString()+")(true);"],{type:"text/javascript"}),u=self.URL.createObjectURL(l),{worker:new self.Worker(u),objectURL:u})),this.onwmsg=function(t){return n.onWorkerMessage(t)};var v=this.workerContext.worker;v.addEventListener("message",this.onwmsg),v.onerror=function(t){var e=new Error(t.message+" ("+t.filename+":"+t.lineno+")");s.enableWorker=!1,D.warn('Error in "'+r+'" Web Worker, fallback to inline'),n.hls.trigger(E.ERROR,{type:T.OTHER_ERROR,details:S.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:e})},v.postMessage({cmd:"init",typeSupported:f,vendor:c,id:r,config:JSON.stringify(s)})}catch(t){D.warn('Error setting up "'+r+'" Web Worker, fallback to inline',t),this.resetWorker(),this.error=null,this.transmuxer=new Si(this.observer,f,s,c,r)}}var r=e.prototype;return r.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}},r.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},r.push=function(t,e,r,i,a,n,s,o,l,u){var d,h,f=this;l.transmuxing.start=self.performance.now();var c=this.transmuxer,v=n?n.start:a.start,g=a.decryptdata,m=this.frag,p=!(m&&a.cc===m.cc),y=!(m&&l.level===m.level),E=m?l.sn-m.sn:-1,T=this.part?l.part-this.part.index:-1,S=0===E&&l.id>1&&l.id===(null==m?void 0:m.stats.chunkCount),L=!y&&(1===E||0===E&&(1===T||S&&T<=0)),R=self.performance.now();(y||E||0===a.stats.parsing.start)&&(a.stats.parsing.start=R),!n||!T&&L||(n.stats.parsing.start=R);var b=!(m&&(null==(d=a.initSegment)?void 0:d.url)===(null==(h=m.initSegment)?void 0:h.url)),A=new Ai(p,L,o,y,v,b);if(!L||p||b){D.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+l.sn+" p: "+l.part+" level: "+l.level+" id: "+l.id+"\n discontinuity: "+p+"\n trackSwitch: "+y+"\n contiguous: "+L+"\n accurateTimeOffset: "+o+"\n timeOffset: "+v+"\n initSegmentChange: "+b);var k=new bi(r,i,e,s,u);this.configureTransmuxer(k)}if(this.frag=a,this.part=n,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:g,chunkMeta:l,state:A},t instanceof ArrayBuffer?[t]:[]);else if(c){var _=c.push(t,g,l,A);Ri(_)?(c.async=!0,_.then((function(t){f.handleTransmuxComplete(t)})).catch((function(t){f.transmuxerError(t,l,"transmuxer-interface push error")}))):(c.async=!1,this.handleTransmuxComplete(_))}},r.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);Ri(i)||r.async?(Ri(i)||(i=Promise.resolve(i)),i.then((function(r){e.handleFlushResult(r,t)})).catch((function(r){e.transmuxerError(r,t,"transmuxer-interface flush error")}))):this.handleFlushResult(i,t)}},r.transmuxerError=function(t,e,r){this.hls&&(this.error=t,this.hls.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:r}))},r.handleFlushResult=function(t,e){var r=this;t.forEach((function(t){r.handleTransmuxComplete(t)})),this.onFlush(e)},r.onWorkerMessage=function(t){var e=t.data,r=this.hls;switch(e.event){case"init":var i,a=null==(i=this.workerContext)?void 0:i.objectURL;a&&self.URL.revokeObjectURL(a);break;case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;case"workerLog":D[e.data.logType]&&D[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)}},r.configureTransmuxer=function(t){var e=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)},r.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},e}(),Pi=function(){function t(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 e=t.prototype;return e.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},e.poll=function(t,e){var r=this.config,i=this.media,a=this.stalled;if(null!==i){var n=i.currentTime,s=i.seeking,o=this.seeking&&!s,l=!this.seeking&&s;if(this.seeking=s,n===t){if(l||o)this.stalled=null;else if(!(i.paused&&!s||i.ended||0===i.playbackRate)&&er.getBuffered(i).length){var u=er.bufferInfo(i,n,0),d=u.len>0,h=u.nextStart||0;if(d||h){if(s){var f=u.len>2,c=!h||e&&e.start<=n||h-n>2&&!this.fragmentTracker.getPartialFragment(n);if(f||c)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var v,g=Math.max(h,u.start||0)-n,m=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,p=(null==m||null==(v=m.details)?void 0:v.live)?2*m.details.targetduration:2,y=this.fragmentTracker.getPartialFragment(n);if(g>0&&(g<=p||y))return void this._trySkipBufferHole(y)}var E=self.performance.now();if(null!==a){var T=E-a;if(s||!(T>=250)||(this._reportStall(u),this.media)){var S=er.bufferInfo(i,n,r.maxBufferHole);this._tryFixBufferStall(S,T)}}else this.stalled=E}}}else if(this.moved=!0,null!==a){if(this.stallReported){var L=self.performance.now()-a;D.warn("playback not stuck anymore @"+n+", after "+Math.round(L)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},e._tryFixBufferStall=function(t,e){var r=this.config,i=this.fragmentTracker,a=this.media;if(null!==a){var n=a.currentTime,s=i.getPartialFragment(n);if(s&&(this._trySkipBufferHole(s)||!this.media))return;(t.len>r.maxBufferHole||t.nextStart&&t.nextStart-n<r.maxBufferHole)&&e>1e3*r.highBufferWatchdogPeriod&&(D.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},e._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)+")");D.warn(i.message),e.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:t.len})}},e._trySkipBufferHole=function(t){var e=this.config,r=this.hls,i=this.media;if(null===i)return 0;var a=i.currentTime,n=er.bufferInfo(i,a,0),s=a<n.start?n.start:n.nextStart;if(s){var o=n.len<=e.maxBufferHole,l=n.len>0&&n.len<1&&i.readyState<3,u=s-a;if(u>0&&(o||l)){if(u>e.maxBufferHole){var d=this.fragmentTracker,h=!1;if(0===a){var f=d.getAppendedFrag(0,Wt);f&&s<f.end&&(h=!0)}if(!h){var c=t||d.getAppendedFrag(a,Wt);if(c){for(var v=!1,g=c.end;g<s;){var m=d.getPartialFragment(g);if(!m){v=!0;break}g+=m.duration}if(v)return 0}}}var p=Math.max(s+.05,a+.1);if(D.warn("skipping hole, adjusting currentTime from "+a+" to "+p),this.moved=!0,this.stalled=null,i.currentTime=p,t&&!t.gap){var y=new Error("fragment loaded with buffer holes, seeking from "+a+" to "+p);r.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:y,reason:y.message,frag:t})}return p}}return 0},e._tryNudgeBuffer=function(){var t=this.config,e=this.hls,r=this.media,i=this.nudgeRetry;if(null!==r){var a=r.currentTime;if(this.nudgeRetry++,i<t.nudgeMaxRetry){var n=a+(i+1)*t.nudgeOffset,s=new Error("Nudging 'currentTime' from "+a+" to "+n);D.warn(s.message),r.currentTime=n,e.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.BUFFER_NUDGE_ON_STALL,error:s,fatal:!1})}else{var o=new Error("Playhead still not moving while enough data buffered @"+a+" after "+t.nudgeMaxRetry+" nudges");D.error(o.message),e.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.BUFFER_STALLED_ERROR,error:o,fatal:!0})}}},t}(),Fi=function(t){function e(e,r,i){var a;return(a=t.call(this,e,r,i,"[stream-controller]",Wt)||this).audioCodecSwap=!1,a.gapController=null,a.level=-1,a._forceStartLoad=!1,a.altAudio=!1,a.audioOnly=!1,a.fragPlaying=null,a.onvplaying=null,a.onvseeked=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a._registerListeners(),a}l(e,t);var r=e.prototype;return r._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.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.LEVEL_LOADING,this.onLevelLoading,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(E.ERROR,this.onError,this),t.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(E.BUFFER_CREATED,this.onBufferCreated,this),t.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this)},r._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.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(E.ERROR,this.onError,this),t.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(E.BUFFER_CREATED,this.onBufferCreated,this),t.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(E.FRAG_BUFFERED,this.onFragBuffered,this)},r.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},r.startLoad=function(t){if(this.levels){var e=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var i=r.startLevel;-1===i&&(r.config.testBandwidth&&this.levels.length>1?(i=0,this.bitrateTest=!0):i=r.nextAutoLevel),this.level=r.nextLoadLevel=i,this.loadedmetadata=!1}e>0&&-1===t&&(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e),this.state=fr,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=hr},r.stopLoad=function(){this._forceStartLoad=!1,t.prototype.stopLoad.call(this)},r.doTick=function(){switch(this.state){case Tr:var t,e=this.levels,r=this.level,i=null==e||null==(t=e[r])?void 0:t.details;if(i&&(!i.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(i))break;this.state=fr;break}break;case gr:var a,n=self.performance.now(),s=this.retryDate;(!s||n>=s||null!=(a=this.media)&&a.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=fr)}this.state===fr&&this.doTickIdle(),this.onTickEnd()},r.onTickEnd=function(){t.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},r.doTickIdle=function(){var t=this.hls,e=this.levelLastLoaded,r=this.levels,i=this.media,a=t.config,n=t.nextLoadLevel;if(null!==e&&(i||!this.startFragRequested&&a.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&null!=r&&r[n]){var s=r[n],o=this.getMainFwdBufferInfo();if(null!==o){var l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){var u={};return this.altAudio&&(u.type="video"),this.hls.trigger(E.BUFFER_EOS,u),void(this.state=yr)}t.loadLevel!==n&&-1===t.manualLevel&&this.log("Adapting to level "+n+" from level "+this.level),this.level=t.nextLoadLevel=n;var d=s.details;if(!d||this.state===Tr||d.live&&this.levelLastLoaded!==n)return this.level=n,void(this.state=Tr);var h=o.len,f=this.getMaxBufferLength(s.maxBitrate);if(!(h>=f)){this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);var c=this.backtrackFragment?this.backtrackFragment.start:o.end,v=this.getNextFragment(c,d);if(this.couldBacktrack&&!this.fragPrevious&&v&&"initSegment"!==v.sn&&this.fragmentTracker.getState(v)!==Ve){var g,m=(null!=(g=this.backtrackFragment)?g:v).sn-d.startSN,p=d.fragments[m-1];p&&v.cc===p.cc&&(v=p,this.fragmentTracker.removeFragment(p))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(v&&this.isLoopLoading(v,c)){if(!v.gap){var y=this.audioOnly&&!this.altAudio?F:O,T=(y===O?this.videoBuffer:this.mediaBuffer)||this.media;T&&this.afterBufferFlushed(T,y,Wt)}v=this.getNextFragmentLoopLoading(v,d,o,Wt,f)}v&&(!v.initSegment||v.initSegment.data||this.bitrateTest||(v=v.initSegment),this.loadFragment(v,s,c))}}}},r.loadFragment=function(e,r,i){var a=this.fragmentTracker.getState(e);this.fragCurrent=e,a===Ge?"initSegment"===e.sn?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,t.prototype.loadFragment.call(this,e,r,i)):this.clearTrackerIfNeeded(e)},r.getAppendedFrag=function(t){var e=this.fragmentTracker.getAppendedFrag(t,Wt);return e&&"fragment"in e?e.fragment:e},r.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,Wt)},r.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},r.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},r.nextLevelSwitch=function(){var t=this.levels,e=this.media;if(null!=e&&e.readyState){var r,i=this.getAppendedFrag(e.currentTime);if(i&&i.start>1&&this.flushMainBuffer(0,i.start-1),!e.paused&&t){var a=t[this.hls.nextLoadLevel],n=this.fragLastKbps;r=n&&this.fragCurrent?this.fragCurrent.duration*a.maxBitrate/(1e3*n)+1:0}else r=0;var s=this.getBufferedFrag(e.currentTime+r);if(s){var o=this.followingBufferedFrag(s);if(o){this.abortCurrentFrag();var l=o.maxStartPTS?o.maxStartPTS:o.start,u=o.duration,d=Math.max(s.end,l+Math.min(Math.max(u-this.config.maxFragLookUpTolerance,.5*u),.75*u));this.flushMainBuffer(d,Number.POSITIVE_INFINITY)}}}},r.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case cr:case vr:case gr:case mr:case pr:this.state=fr}this.nextLoadPosition=this.getLoadPosition()},r.flushMainBuffer=function(e,r){t.prototype.flushMainBuffer.call(this,e,r,this.altAudio?"video":null)},r.onMediaAttached=function(e,r){t.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 Pi(this.config,i,this.fragmentTracker,this.hls)},r.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),t.prototype.onMediaDetaching.call(this)},r.onMediaPlaying=function(){this.tick()},r.onMediaSeeked=function(){var t=this.media,e=t?t.currentTime:null;y(e)&&this.log("Media seeked to "+e.toFixed(3));var r=this.getMainFwdBufferInfo();null!==r&&0!==r.len?this.tick():this.warn('Main forward buffer length on "seeked" event '+(r?r.len:"empty")+")")},r.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=0,this.fragPlaying=null,this.backtrackFragment=null},r.onManifestParsed=function(t,e){var r,i,a,n=!1,s=!1;e.levels.forEach((function(t){(r=t.audioCodec)&&(-1!==r.indexOf("mp4a.40.2")&&(n=!0),-1!==r.indexOf("mp4a.40.5")&&(s=!0))})),this.audioCodecSwitch=n&&s&&!("function"==typeof(null==(a=Rr())||null==(i=a.prototype)?void 0:i.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1},r.onLevelLoading=function(t,e){var r=this.levels;if(r&&this.state===fr){var i=r[e.level];(!i.details||i.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(i.details))&&(this.state=Tr)}},r.onLevelLoaded=function(t,e){var r,i=this.levels,a=e.level,n=e.details,s=n.totalduration;if(i){this.log("Level "+a+" loaded ["+n.startSN+","+n.endSN+"], cc ["+n.startCC+", "+n.endCC+"] duration:"+s);var o=i[a],l=this.fragCurrent;!l||this.state!==vr&&this.state!==gr||l.level===e.level&&l.urlId===o.urlId||!l.loader||this.abortCurrentFrag();var u=0;if(n.live||null!=(r=o.details)&&r.live){if(n.fragments[0]||(n.deltaUpdateFailed=!0),n.deltaUpdateFailed)return;u=this.alignPlaylists(n,o.details)}if(o.details=n,this.levelLastLoaded=a,this.hls.trigger(E.LEVEL_UPDATED,{details:n,level:a}),this.state===Tr){if(this.waitForCdnTuneIn(n))return;this.state=fr}this.startFragRequested?n.live&&this.synchronizeToLiveEdge(n):this.setStartPosition(n,u),this.tick()}else this.warn("Levels were reset while loading level "+a)},r._handleFragmentLoadProgress=function(t){var e,r=t.frag,i=t.part,a=t.payload,n=this.levels;if(n){var s=n[r.level],o=s.details;if(!o)return this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset"),void this.fragmentTracker.removeFragment(r);var l=s.videoCodec,u=o.PTSKnown||!o.live,d=null==(e=r.initSegment)?void 0:e.data,h=this._getAudioCodec(s),f=this.transmuxer=this.transmuxer||new Ci(this.hls,Wt,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),c=i?i.index:-1,v=-1!==c,g=new rr(r.level,r.sn,r.stats.chunkCount,a.byteLength,c,v),m=this.initPTS[r.cc];f.push(a,d,h,l,r,i,o.totalduration,u,g,m)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},r.onAudioTrackSwitching=function(t,e){var r=this.altAudio;if(!e.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i&&(this.log("Switching to main audio track, cancel main fragment load"),i.abortRequests(),this.fragmentTracker.removeFragment(i)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var a=this.hls;r&&(a.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),a.trigger(E.AUDIO_TRACK_SWITCHED,e)}},r.onAudioTrackSwitched=function(t,e){var r=e.id,i=!!this.hls.audioTracks[r].url;if(i){var a=this.videoBuffer;a&&this.mediaBuffer!==a&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=a)}this.altAudio=i,this.tick()},r.onBufferCreated=function(t,e){var r,i,a=e.tracks,n=!1;for(var s in a){var o=a[s];if("main"===o.id){if(i=s,r=o,"video"===s){var l=a[s];l&&(this.videoBuffer=l.buffer)}}else n=!0}n&&r?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},r.onFragBuffered=function(t,e){var r=e.frag,i=e.part;if(!r||r.type===Wt){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===pr&&(this.state=fr));var a=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}},r.onError=function(t,e){var r;if(e.fatal)this.state=Er;else switch(e.details){case S.FRAG_GAP:case S.FRAG_PARSING_ERROR:case S.FRAG_DECRYPT_ERROR:case S.FRAG_LOAD_ERROR:case S.FRAG_LOAD_TIMEOUT:case S.KEY_LOAD_ERROR:case S.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Wt,e);break;case S.LEVEL_LOAD_ERROR:case S.LEVEL_LOAD_TIMEOUT:case S.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==Tr||(null==(r=e.context)?void 0:r.type)!==Ht||(this.state=fr);break;case S.BUFFER_FULL_ERROR:if(!e.parent||"main"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case S.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}},r.checkBuffer=function(){var t=this.media,e=this.gapController;if(t&&e&&t.readyState){if(this.loadedmetadata||!er.getBuffered(t).length){var r=this.state!==fr?this.fragCurrent:null;e.poll(this.lastCurrentTime,r)}this.lastCurrentTime=t.currentTime}},r.onFragLoadEmergencyAborted=function(){this.state=fr,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},r.onBufferFlushed=function(t,e){var r=e.type;if(r!==F||this.audioOnly&&!this.altAudio){var i=(r===O?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,Wt)}},r.onLevelsUpdated=function(t,e){this.levels=e.levels},r.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},r.seekToStartPos=function(){var t=this.media;if(t){var e=t.currentTime,r=this.startPosition;if(r>=0&&e<r){if(t.seeking)return void this.log("could not seek to "+r+", already seeking at "+e);var i=er.getBuffered(t),a=(i.length?i.start(0):0)-r;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+a+" to match buffer start"),r+=a,this.startPosition=r),this.log("seek to target start position "+r+" from current time "+e),t.currentTime=r}}},r._getAudioCodec=function(t){var e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e=-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),e},r._loadBitrateTestFrag=function(t,e){var r=this;t.bitrateTest=!0,this._doFragLoad(t,e).then((function(i){var a=r.hls;if(i&&!r.fragContextChanged(t)){e.fragmentError=0,r.state=fr,r.startFragRequested=!1,r.bitrateTest=!1;var n=t.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),a.trigger(E.FRAG_LOADED,i),t.bitrateTest=!1}}))},r._handleTransmuxComplete=function(t){var e,r="main",i=this.hls,a=t.remuxResult,n=t.chunkMeta,s=this.getCurrentContext(n);if(s){var o=s.frag,l=s.part,u=s.level,d=a.video,h=a.text,f=a.id3,c=a.initSegment,v=u.details,g=this.altAudio?void 0:a.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=mr,c){c.tracks&&(this._bufferInitSegment(u,c.tracks,o,n),i.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:o,id:r,tracks:c.tracks}));var m=c.initPTS,p=c.timescale;y(m)&&(this.initPTS[o.cc]={baseTime:m,timescale:p},i.trigger(E.INIT_PTS_FOUND,{frag:o,id:r,initPTS:m,timescale:p}))}if(d&&!1!==a.independent){if(v){var T=d.startPTS,S=d.endPTS,L=d.startDTS,R=d.endDTS;if(l)l.elementaryStreams[d.type]={startPTS:T,endPTS:S,startDTS:L,endDTS:R};else if(d.firstKeyFrame&&d.independent&&1===n.id&&(this.couldBacktrack=!0),d.dropped&&d.independent){var b=this.getMainFwdBufferInfo();if((b?b.end:this.getLoadPosition())+this.config.maxBufferHole<(d.firstKeyFramePTS?d.firstKeyFramePTS:T)-this.config.maxBufferHole)return void this.backtrack(o);o.setElementaryStreamInfo(d.type,o.start,S,o.start,R,!0)}o.setElementaryStreamInfo(d.type,T,S,L,R),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(d,o,l,n)}}else if(!1===a.independent)return void this.backtrack(o);if(g){var A=g.startPTS,k=g.endPTS,D=g.startDTS,_=g.endDTS;l&&(l.elementaryStreams[F]={startPTS:A,endPTS:k,startDTS:D,endDTS:_}),o.setElementaryStreamInfo(F,A,k,D,_),this.bufferFragmentData(g,o,l,n)}if(v&&null!=f&&null!=(e=f.samples)&&e.length){var x={id:r,frag:o,details:v,samples:f.samples};i.trigger(E.FRAG_PARSING_METADATA,x)}if(v&&h){var w={id:r,frag:o,details:v,samples:h.samples};i.trigger(E.FRAG_PARSING_USERDATA,w)}}}else this.resetWhenMissingContext(n)},r._bufferInitSegment=function(t,e,r,i){var a=this;if(this.state===mr){this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;var n=e.audio,s=e.video,o=e.audiovideo;if(n){var l=t.audioCodec,u=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l=-1!==l.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==n.metadata.channelCount&&-1===u.indexOf("firefox")&&(l="mp4a.40.5")),-1!==u.indexOf("android")&&"audio/mpeg"!==n.container&&(l="mp4a.40.2",this.log("Android: force audio codec to "+l)),t.audioCodec&&t.audioCodec!==l&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+l+'"'),n.levelCodec=l,n.id="main",this.log("Init audio buffer, container:"+n.container+", codecs[selected/level/parsed]=["+(l||"")+"/"+(t.audioCodec||"")+"/"+n.codec+"]")}s&&(s.levelCodec=t.videoCodec,s.id="main",this.log("Init video buffer, container:"+s.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+s.codec+"]")),o&&this.log("Init audiovideo buffer, container:"+o.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+o.codec+"]"),this.hls.trigger(E.BUFFER_CODECS,e),Object.keys(e).forEach((function(t){var n=e[t].initSegment;null!=n&&n.byteLength&&a.hls.trigger(E.BUFFER_APPENDING,{type:t,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})})),this.tick()}},r.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Wt)},r.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=fr},r.checkFragmentChanged=function(){var t=this.media,e=null;if(t&&t.readyState>1&&!1===t.seeking){var r=t.currentTime;if(er.isBuffered(t,r)?e=this.getAppendedFrag(r):er.isBuffered(t,r+.1)&&(e=this.getAppendedFrag(r+.1)),e){this.backtrackFragment=null;var i=this.fragPlaying,a=e.level;i&&e.sn===i.sn&&i.level===a&&e.urlId===i.urlId||(this.fragPlaying=e,this.hls.trigger(E.FRAG_CHANGED,{frag:e}),i&&i.level===a||this.hls.trigger(E.LEVEL_SWITCHED,{level:a}))}}},n(e,[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var e=t.currentTime,r=this.currentFrag;if(r&&y(e)&&y(r.programDateTime)){var i=r.programDateTime+1e3*(e-r.start);return new Date(i)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),e}(Sr),Oi=function(){function t(t,e,r){void 0===e&&(e=0),void 0===r&&(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 e=t.prototype;return e.sample=function(t,e){var r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t},e.getTotalWeight=function(){return this.totalWeight_},e.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},t}(),Mi=function(){function t(t,e,r,i){void 0===i&&(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 Oi(t),this.fast_=new Oi(e),this.defaultTTFB_=i,this.ttfb_=new Oi(t)}var e=t.prototype;return e.update=function(t,e){var r=this.slow_,i=this.fast_,a=this.ttfb_;r.halfLife!==t&&(this.slow_=new Oi(t,r.getEstimate(),r.getTotalWeight())),i.halfLife!==e&&(this.fast_=new Oi(e,i.getEstimate(),i.getTotalWeight())),a.halfLife!==t&&(this.ttfb_=new Oi(t,a.getEstimate(),a.getTotalWeight()))},e.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)},e.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))},e.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},e.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},e.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},e.destroy=function(){},t}(),Ni=function(){function t(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;var e=t.config;this.bwEstimator=new Mi(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;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)},e.unregisterListeners=function(){var t=this.hls;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)},e.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},e.onFragLoading=function(t,e){var r,i=e.frag;this.ignoreFragment(i)||(this.fragCurrent=i,this.partCurrent=null!=(r=e.part)?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))},e.onLevelSwitching=function(t,e){this.clearTimer()},e.getTimeToLoadFrag=function(t,e,r,i){return t+r/e+(i?this.lastLevelLoadSec:0)},e.onLevelLoaded=function(t,e){var r=this.hls.config,i=e.stats,a=i.total,n=i.bwEstimate;y(a)&&y(n)&&(this.lastLevelLoadSec=8*a/n),e.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},e._abandonRulesCheck=function(){var t=this.fragCurrent,e=this.partCurrent,r=this.hls,i=r.autoLevelEnabled,a=r.media;if(t&&a){var n=performance.now(),s=e?e.stats:t.stats,o=e?e.duration:t.duration,l=n-s.loading.start;if(s.aborted||s.loaded&&s.loaded===s.total||0===t.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(i&&!a.paused&&a.playbackRate&&a.readyState){var u=r.mainForwardBufferInfo;if(null!==u){var d=this.bwEstimator.getEstimateTTFB(),h=Math.abs(a.playbackRate);if(!(l<=Math.max(d,o/(2*h)*1e3))){var f=u.len/h;if(!(f>=2*o/h)){var c=s.loading.first?s.loading.first-s.loading.start:-1,v=s.loaded&&c>-1,g=this.bwEstimator.getEstimate(),m=r.levels,p=r.minAutoLevel,T=m[t.level],S=s.total||Math.max(s.loaded,Math.round(o*T.maxBitrate/8)),L=l-c;L<1&&v&&(L=Math.min(l,8*s.loaded/g));var R=v?1e3*s.loaded/L:0,b=R?(S-s.loaded)/R:8*S/g+d/1e3;if(!(b<=f)){var A,k=R?8*R:g,_=Number.POSITIVE_INFINITY;for(A=t.level-1;A>p;A--){var x=m[A].maxBitrate;if((_=this.getTimeToLoadFrag(d/1e3,k,o*x,!m[A].details))<f)break}_>=b||_>10*o||(r.nextLoadLevel=A,v?this.bwEstimator.sample(l-Math.min(d,c),s.loaded):this.bwEstimator.sampleTTFB(l),this.clearTimer(),D.warn("[abr] Fragment "+t.sn+(e?" part "+e.index:"")+" of level "+t.level+" is loading too slowly;\n Time to underbuffer: "+f.toFixed(3)+" s\n Estimated load time for current fragment: "+b.toFixed(3)+" s\n Estimated load time for down switch fragment: "+_.toFixed(3)+" s\n TTFB estimate: "+c+"\n Current BW estimate: "+(y(g)?(g/1024).toFixed(3):"Unknown")+" Kb/s\n New BW estimate: "+(this.bwEstimator.getEstimate()/1024).toFixed(3)+" Kb/s\n Aborting and switching to level "+A),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),r.trigger(E.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:s}))}}}}}}},e.onFragLoaded=function(t,e){var r=e.frag,i=e.part,a=i?i.stats:r.stats;if(r.type===Wt&&this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var n=i?i.duration:r.duration,s=this.hls.levels[r.level],o=(s.loaded?s.loaded.bytes:0)+a.loaded,l=(s.loaded?s.loaded.duration:0)+n;s.loaded={bytes:o,duration:l},s.realBitrate=Math.round(8*o/l)}if(r.bitrateTest){var u={stats:a,frag:r,part:i,id:r.type};this.onFragBuffered(E.FRAG_BUFFERED,u),r.bitrateTest=!1}}},e.onFragBuffered=function(t,e){var r=e.frag,i=e.part,a=null!=i&&i.stats.loaded?i.stats:r.stats;if(!a.aborted&&!this.ignoreFragment(r)){var n=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,a.loaded),a.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}},e.ignoreFragment=function(t){return t.type!==Wt||"initSegment"===t.sn},e.clearTimer=function(){self.clearInterval(this.timer)},e.getNextABRAutoLevel=function(){var t=this.fragCurrent,e=this.partCurrent,r=this.hls,i=r.maxAutoLevel,a=r.config,n=r.minAutoLevel,s=r.media,o=e?e.duration:t?t.duration:0,l=s&&0!==s.playbackRate?Math.abs(s.playbackRate):1,u=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,d=r.mainForwardBufferInfo,h=(d?d.len:0)/l,f=this.findBestLevel(u,n,i,h,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(f>=0)return f;D.trace("[abr] "+(h?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var c=o?Math.min(o,a.maxStarvationDelay):a.maxStarvationDelay,v=a.abrBandWidthFactor,g=a.abrBandWidthUpFactor;if(!h){var m=this.bitrateTestDelay;m&&(c=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-m,D.trace("[abr] bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*c)+" ms"),v=g=1)}return f=this.findBestLevel(u,n,i,h+c,v,g),Math.max(f,0)},e.findBestLevel=function(t,e,r,i,a,n){for(var s,o=this.fragCurrent,l=this.partCurrent,u=this.lastLoadedFragLevel,d=this.hls.levels,h=d[u],f=!(null==h||null==(s=h.details)||!s.live),c=null==h?void 0:h.codecSet,v=l?l.duration:o?o.duration:0,g=this.bwEstimator.getEstimateTTFB()/1e3,m=e,p=-1,E=r;E>=e;E--){var T=d[E];if(!T||c&&T.codecSet!==c)T&&(m=Math.min(E,m),p=Math.max(E,p));else{-1!==p&&D.trace("[abr] Skipped level(s) "+m+"-"+p+' with CODECS:"'+d[p].attrs.CODECS+'"; not compatible with "'+h.attrs.CODECS+'"');var S=T.details,L=(l?null==S?void 0:S.partTarget:null==S?void 0:S.averagetargetduration)||v,R=void 0;R=E<=u?a*t:n*t;var b=d[E].maxBitrate,A=this.getTimeToLoadFrag(g,R,b*L,void 0===S);if(D.trace("[abr] level:"+E+" adjustedbw-bitrate:"+Math.round(R-b)+" avgDuration:"+L.toFixed(1)+" maxFetchDuration:"+i.toFixed(1)+" fetchDuration:"+A.toFixed(1)),R>b&&(0===A||!y(A)||f&&!this.bitrateTestDelay||A<i))return E}}return-1},n(t,[{key:"nextAutoLevel",get:function(){var t=this._nextAutoLevel,e=this.bwEstimator;if(-1!==t&&!e.canEstimate())return t;var r=this.getNextABRAutoLevel();if(-1!==t){var i=this.hls.levels;if(i.length>Math.max(t,r)&&i[t].loadError<=i[r].loadError)return t}return-1!==t&&(r=Math.min(t,r)),r},set:function(t){this._nextAutoLevel=t}}]),t}(),Bi=function(){function t(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}var e=t.prototype;return e.append=function(t,e){var r=this.queues[e];r.push(t),1===r.length&&this.buffers[e]&&this.executeNext(e)},e.insertAbort=function(t,e){this.queues[e].unshift(t),this.executeNext(e)},e.appendBlocker=function(t){var e,r=new Promise((function(t){e=t})),i={execute:e,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,t),r},e.executeNext=function(t){var e=this.buffers,r=this.queues,i=e[t],a=r[t];if(a.length){var n=a[0];try{n.execute()}catch(e){D.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),n.onError(e),null!=i&&i.updating||(a.shift(),this.executeNext(t))}}},e.shiftAndExecuteNext=function(t){this.queues[t].shift(),this.executeNext(t)},e.current=function(t){return this.queues[t][0]},t}(),Ui=Lr(),Gi=/([ha]vc.)(?:\.[^.,]+)+/,Hi=function(){function t(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.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var t=e.media,r=e.mediaSource;D.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",e._onMediaEmptied),e.updateMediaElementDuration(),e.hls.trigger(E.MEDIA_ATTACHED,{media:t})),r&&r.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){D.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){D.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=function(){var t=e.media,r=e._objectUrl;t&&t.src!==r&&D.error("Media element src was set while attaching MediaSource ("+r+" > "+t.src+")")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var e=t.prototype;return e.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},e.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},e.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_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)},e.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_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)},e._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new Bi(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},e.onManifestParsed=function(t,e){var r=2;e.audio&&!e.video||e.altAudio,r=1,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.details=null,D.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},e.onMediaAttaching=function(t,e){var r=this.media=e.media;if(r&&Ui){var i=this.mediaSource=new Ui;i.addEventListener("sourceopen",this._onMediaSourceOpen),i.addEventListener("sourceended",this._onMediaSourceEnded),i.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(i),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}},e.onMediaDetaching=function(){var t=this.media,e=this.mediaSource,r=this._objectUrl;if(e){if(D.log("[buffer-controller]: media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){D.warn("[buffer-controller]: onMediaDetaching: "+t.message+" while calling endOfStream")}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),t.src===r?(t.removeAttribute("src"),t.load()):D.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(E.MEDIA_DETACHED,void 0)},e.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach((function(e){var r=t.sourceBuffer[e];try{r&&(t.removeBufferListeners(e),t.mediaSource&&t.mediaSource.removeSourceBuffer(r),t.sourceBuffer[e]=void 0)}catch(t){D.warn("[buffer-controller]: Failed to reset the "+e+" buffer",t)}})),this._initSourceBuffer()},e.onBufferCodecs=function(t,e){var r=this,i=this.getSourceBufferTypes().length;Object.keys(e).forEach((function(t){if(i){var a=r.tracks[t];if(a&&"function"==typeof a.buffer.changeType){var n=e[t],s=n.id,o=n.codec,l=n.levelCodec,u=n.container,d=n.metadata,h=(a.levelCodec||a.codec).replace(Gi,"$1"),f=(l||o).replace(Gi,"$1");if(h!==f){var c=u+";codecs="+(l||o);r.appendChangeType(t,c),D.log("[buffer-controller]: switching codec "+h+" to "+f),r.tracks[t]={buffer:a.buffer,codec:o,container:u,levelCodec:l,metadata:d,id:s}}}}else r.pendingTracks[t]=e[t]})),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},e.appendChangeType=function(t,e){var r=this,i=this.operationQueue,a={execute:function(){var a=r.sourceBuffer[t];a&&(D.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+e),a.changeType(e)),i.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(e){D.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",e)}};i.append(a,t)},e.onBufferAppending=function(t,e){var r=this,i=this.hls,a=this.operationQueue,n=this.tracks,s=e.data,o=e.type,l=e.frag,u=e.part,d=e.chunkMeta,h=d.buffering[o],f=self.performance.now();h.start=f;var c=l.stats.buffering,v=u?u.stats.buffering:null;0===c.start&&(c.start=f),v&&0===v.start&&(v.start=f);var g=n.audio,m=!1;"audio"===o&&"audio/mpeg"===(null==g?void 0:g.container)&&(m=!this.lastMpegAudioChunk||1===d.id||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);var p=l.start,y={execute:function(){if(h.executeStart=self.performance.now(),m){var t=r.sourceBuffer[o];if(t){var e=p-t.timestampOffset;Math.abs(e)>=.1&&(D.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+p+" (delta: "+e+") sn: "+l.sn+")"),t.timestampOffset=p)}}r.appendExecutor(s,o)},onStart:function(){},onComplete:function(){var t=self.performance.now();h.executeEnd=h.end=t,0===c.first&&(c.first=t),v&&0===v.first&&(v.first=t);var e=r.sourceBuffer,i={};for(var a in e)i[a]=er.getBuffered(e[a]);r.appendError=0,r.hls.trigger(E.BUFFER_APPENDED,{type:o,frag:l,part:u,chunkMeta:d,parent:l.type,timeRanges:i})},onError:function(t){D.error("[buffer-controller]: Error encountered while trying to append to the "+o+" SourceBuffer",t);var e={type:T.MEDIA_ERROR,parent:l.type,details:S.BUFFER_APPEND_ERROR,frag:l,part:u,chunkMeta:d,error:t,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=S.BUFFER_FULL_ERROR:(r.appendError++,e.details=S.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(D.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),e.fatal=!0)),i.trigger(E.ERROR,e)}};a.append(y,o)},e.onBufferFlushing=function(t,e){var r=this,i=this.operationQueue,a=function(t){return{execute:r.removeExecutor.bind(r,t,e.startOffset,e.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(E.BUFFER_FLUSHED,{type:t})},onError:function(e){D.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",e)}}};e.type?i.append(a(e.type),e.type):this.getSourceBufferTypes().forEach((function(t){i.append(a(t),t)}))},e.onFragParsed=function(t,e){var r=this,i=e.frag,a=e.part,n=[],s=a?a.elementaryStreams:i.elementaryStreams;s[M]?n.push("audiovideo"):(s[F]&&n.push("audio"),s[O]&&n.push("video")),0===n.length&&D.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers((function(){var t=self.performance.now();i.stats.buffering.end=t,a&&(a.stats.buffering.end=t);var e=a?a.stats:i.stats;r.hls.trigger(E.FRAG_BUFFERED,{frag:i,part:a,stats:e,id:i.type})}),n)},e.onFragChanged=function(t,e){this.flushBackBuffer()},e.onBufferEos=function(t,e){var r=this;this.getSourceBufferTypes().reduce((function(t,i){var a=r.sourceBuffer[i];return!a||e.type&&e.type!==i||(a.ending=!0,a.ended||(a.ended=!0,D.log("[buffer-controller]: "+i+" sourceBuffer now EOS"))),t&&!(a&&!a.ended)}),!0)&&(D.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){r.getSourceBufferTypes().forEach((function(t){var e=r.sourceBuffer[t];e&&(e.ending=!1)}));var t=r.mediaSource;t&&"open"===t.readyState?(D.log("[buffer-controller]: Calling mediaSource.endOfStream()"),t.endOfStream()):t&&D.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+t.readyState)})))},e.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())},e.flushBackBuffer=function(){var t=this.hls,e=this.details,r=this.media,i=this.sourceBuffer;if(r&&null!==e){var a=this.getSourceBufferTypes();if(a.length){var n=e.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if(y(n)&&!(n<0)){var s=r.currentTime,o=e.levelTargetDuration,l=Math.max(n,o),u=Math.floor(s/o)*o-l;a.forEach((function(r){var a=i[r];if(a){var n=er.getBuffered(a);if(n.length>0&&u>n.start(0)){if(t.trigger(E.BACK_BUFFER_REACHED,{bufferEnd:u}),e.live)t.trigger(E.LIVE_BACK_BUFFER_REACHED,{bufferEnd:u});else if(a.ended&&n.end(n.length-1)-s<2*o)return void D.info("[buffer-controller]: Cannot flush "+r+" back buffer while SourceBuffer is in ended state");t.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:u,type:r})}}}))}}}},e.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var t=this.details,e=this.hls,r=this.media,i=this.mediaSource,a=t.fragments[0].start+t.totalduration,n=r.duration,s=y(i.duration)?i.duration:0;t.live&&e.config.liveDurationInfinity?(D.log("[buffer-controller]: Media Source duration is set to Infinity"),i.duration=1/0,this.updateSeekableRange(t)):(a>s&&a>n||!y(n))&&(D.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),i.duration=a)}},e.updateSeekableRange=function(t){var e=this.mediaSource,r=t.fragments;if(r.length&&t.live&&null!=e&&e.setLiveSeekableRange){var i=Math.max(0,r[0].start),a=Math.max(i,i+t.totalduration);e.setLiveSeekableRange(i,a)}},e.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,e=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&!t||2===i){this.createSourceBuffers(r),this.pendingTracks={};var a=this.getSourceBufferTypes();if(a.length)this.hls.trigger(E.BUFFER_CREATED,{tracks:this.tracks}),a.forEach((function(t){e.executeNext(t)}));else{var n=new Error("could not create source buffer for media codec(s)");this.hls.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:n,reason:n.message})}}},e.createSourceBuffers=function(t){var e=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(var i in t)if(!e[i]){var a=t[i];if(!a)throw Error("source buffer exists for track "+i+", however track does not");var n=a.levelCodec||a.codec,s=a.container+";codecs="+n;D.log("[buffer-controller]: creating sourceBuffer("+s+")");try{var o=e[i]=r.addSourceBuffer(s),l=i;this.addBufferListener(l,"updatestart",this._onSBUpdateStart),this.addBufferListener(l,"updateend",this._onSBUpdateEnd),this.addBufferListener(l,"error",this._onSBUpdateError),this.tracks[i]={buffer:o,codec:n,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(t){D.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:s})}}},e._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},e._onSBUpdateEnd=function(t){var e=this.operationQueue;e.current(t).onComplete(),e.shiftAndExecuteNext(t)},e._onSBUpdateError=function(t,e){var r=new Error(t+" SourceBuffer error");D.error("[buffer-controller]: "+r,e),this.hls.trigger(E.ERROR,{type:T.MEDIA_ERROR,details:S.BUFFER_APPENDING_ERROR,error:r,fatal:!1});var i=this.operationQueue.current(t);i&&i.onError(e)},e.removeExecutor=function(t,e,r){var i=this.media,a=this.mediaSource,n=this.operationQueue,s=this.sourceBuffer[t];if(!i||!a||!s)return D.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void n.shiftAndExecuteNext(t);var o=y(i.duration)?i.duration:1/0,l=y(a.duration)?a.duration:1/0,u=Math.max(0,e),d=Math.min(r,o,l);d>u&&!s.ending?(s.ended=!1,D.log("[buffer-controller]: Removing ["+u+","+d+"] from the "+t+" SourceBuffer"),s.remove(u,d)):n.shiftAndExecuteNext(t)},e.appendExecutor=function(t,e){var r=this.operationQueue,i=this.sourceBuffer[e];if(!i)return D.warn("[buffer-controller]: Attempting to append to the "+e+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(e);i.ended=!1,i.appendBuffer(t)},e.blockBuffers=function(t,e){var r=this;if(void 0===e&&(e=this.getSourceBufferTypes()),!e.length)return D.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(t);var i=this.operationQueue,a=e.map((function(t){return i.appendBlocker(t)}));Promise.all(a).then((function(){t(),e.forEach((function(t){var e=r.sourceBuffer[t];null!=e&&e.updating||i.shiftAndExecuteNext(t)}))}))},e.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},e.addBufferListener=function(t,e,r){var i=this.sourceBuffer[t];if(i){var a=r.bind(this,t);this.listeners[t].push({event:e,listener:a}),i.addEventListener(e,a)}},e.removeBufferListeners=function(t){var e=this.sourceBuffer[t];e&&this.listeners[t].forEach((function(t){e.removeEventListener(t.event,t.listener)}))},t}(),Ki=function(){function t(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 e=t.prototype;return e.setStreamController=function(t){this.streamController=t},e.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},e.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.BUFFER_CODECS,this.onBufferCodecs,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this)},e.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.BUFFER_CODECS,this.onBufferCodecs,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this)},e.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})},e.onMediaAttaching=function(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null},e.onManifestParsed=function(t,e){var r=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,r.config.capLevelToPlayerSize&&e.video&&this.startCapping()},e.onBufferCodecs=function(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()},e.onMediaDetaching=function(){this.stopCapping()},e.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var t=this.hls.levels;if(t.length){var e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},e.getMaxLevel=function(e){var r=this,i=this.hls.levels;if(!i.length)return-1;var a=i.filter((function(t,i){return r.isLevelAllowed(t)&&i<=e}));return this.clientRect=null,t.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)},e.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},e.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},e.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},e.isLevelAllowed=function(t){return!this.restrictedLevels.some((function(e){return t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height}))},t.getMaxLevelByMediaSize=function(t,e,r){if(null==t||!t.length)return-1;for(var i,a,n=t.length-1,s=0;s<t.length;s+=1){var o=t[s];if((o.width>=e||o.height>=r)&&(i=o,!(a=t[s+1])||i.width!==a.width||i.height!==a.height)){n=s;break}}return n},n(t,[{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(t){}return t}}]),t}(),Vi=function(){function t(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 e=t.prototype;return e.setStreamController=function(t){this.streamController=t},e.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},e.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&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},e.checkFPS=function(t,e,r){var i=performance.now();if(e){if(this.lastTime){var a=i-this.lastTime,n=r-this.lastDroppedFrames,s=e-this.lastDecodedFrames,o=1e3*n/a,l=this.hls;if(l.trigger(E.FPS_DROP,{currentDropped:n,currentDecoded:s,totalDroppedFrames:r}),o>0&&n>l.config.fpsDroppedMonitoringThreshold*s){var u=l.currentLevel;D.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=u)&&(u-=1,l.trigger(E.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},e.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)},t}(),Wi=/^age:\s*[\d.]+\s*$/im,Yi=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new P,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},e.abort=function(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.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()},e.loadInternal=function(){var t=this,e=this.config,r=this.context;if(e){var i=this.loader=new self.XMLHttpRequest,a=this.stats;a.loading.first=0,a.loaded=0;var n=this.xhrSetup;n?Promise.resolve().then((function(){if(!t.stats.aborted)return n(i,r.url)})).catch((function(t){return i.open("GET",r.url,!0),n(i,r.url)})).then((function(){t.stats.aborted||t.openAndSendXhr(i,r,e)})).catch((function(e){t.callbacks.onError({code:i.status,text:e.message},r,i,a)})):this.openAndSendXhr(i,r,e)}},e.openAndSendXhr=function(t,e,r){t.readyState||t.open("GET",e.url,!0);var i=this.context.headers,a=r.loadPolicy,n=a.maxTimeToFirstByteMs,s=a.maxLoadTimeMs;if(i)for(var o in i)t.setRequestHeader(o,i[o]);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=n&&y(n)?n:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),t.send()},e.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(t&&e){var i=e.readyState,a=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;var n=e.status,s="text"!==e.responseType;if(n>=200&&n<300&&(s&&e.response||null!==e.responseText)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var o=s?e.response:e.responseText,l="arraybuffer"===e.responseType?o.byteLength:o.length;if(r.loaded=r.total=l,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,t,o,e),!this.callbacks)return;var d={url:e.responseURL,data:o,code:n};this.callbacks.onSuccess(d,r,t,e)}else{var h=a.loadPolicy.errorRetry;Le(h,r.retry,!1,n)?this.retry(h):(D.error(n+" while loading "+t.url),this.callbacks.onError({code:n,text:e.statusText},t,e,r))}}}},e.loadtimeout=function(){var t,e=null==(t=this.config)?void 0:t.loadPolicy.timeoutRetry;if(Le(e,this.stats.retry,!0))this.retry(e);else{D.warn("timeout while loading "+this.context.url);var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}},e.retry=function(t){var e=this.context,r=this.stats;this.retryDelay=Te(t,r.retry),r.retry++,D.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)},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&Wi.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},e.getResponseHeader=function(t){return this.loader&&new RegExp("^"+t+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null},t}(),ji=function(){function t(){this.chunks=[],this.dataLength=0}var e=t.prototype;return e.push=function(t){this.chunks.push(t),this.dataLength+=t.length},e.flush=function(){var t,e=this.chunks,r=this.dataLength;return e.length?(t=1===e.length?e[0]:function(t,e){for(var r=new Uint8Array(e),i=0,a=0;a<t.length;a++){var n=t[a];r.set(n,i),i+=n.length}return r}(e,r),this.reset(),t):new Uint8Array(0)},e.reset=function(){this.chunks.length=0,this.dataLength=0},t}(),qi=/(\d+)-(\d+)\/(\d+)/,zi=function(){function t(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||Xi,this.controller=new self.AbortController,this.stats=new P}var e=t.prototype;return e.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},e.abortInternal=function(){var t=this.response;null!=t&&t.ok||(this.stats.aborted=!0,this.controller.abort())},e.abort=function(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},e.load=function(t,e,r){var i=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var n=function(t,e){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(o({},t.headers))};return t.rangeEnd&&r.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),r}(t,this.controller.signal),s=r.onProgress,l="arraybuffer"===t.responseType,u=l?"byteLength":"length",d=e.loadPolicy,h=d.maxTimeToFirstByteMs,f=d.maxLoadTimeMs;this.context=t,this.config=e,this.callbacks=r,this.request=this.fetchSetup(t,n),self.clearTimeout(this.requestTimeout),e.timeout=h&&y(h)?h:f,this.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(a,t,i.response)}),e.timeout),self.fetch(this.request).then((function(n){i.response=i.loader=n;var o=Math.max(self.performance.now(),a.loading.start);if(self.clearTimeout(i.requestTimeout),e.timeout=f,i.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(a,t,i.response)}),f-(o-a.loading.start)),!n.ok){var u=n.status,d=n.statusText;throw new Qi(d||"fetch, bad network response",u,n)}return a.loading.first=o,a.total=function(t){var e=t.get("Content-Range");if(e){var r=function(t){var e=qi.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}(e);if(y(r))return r}var i=t.get("Content-Length");if(i)return parseInt(i)}(n.headers)||a.total,s&&y(e.highWaterMark)?i.loadProgressively(n,a,t,e.highWaterMark,s):l?n.arrayBuffer():"json"===t.responseType?n.json():n.text()})).then((function(n){var o=i.response;self.clearTimeout(i.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var l=n[u];l&&(a.loaded=a.total=l);var d={url:o.url,data:n,code:o.status};s&&!y(e.highWaterMark)&&s(a,t,n,o),r.onSuccess(d,a,t,o)})).catch((function(e){if(self.clearTimeout(i.requestTimeout),!a.aborted){var n=e&&e.code||0,s=e?e.message:null;r.onError({code:n,text:s},t,e?e.details:null,a)}}))},e.getCacheAge=function(){var t=null;if(this.response){var e=this.response.headers.get("age");t=e?parseFloat(e):null}return t},e.getResponseHeader=function(t){return this.response?this.response.headers.get(t):null},e.loadProgressively=function(t,e,r,i,a){void 0===i&&(i=0);var n=new ji,s=t.body.getReader();return function o(){return s.read().then((function(s){if(s.done)return n.dataLength&&a(e,r,n.flush(),t),Promise.resolve(new ArrayBuffer(0));var l=s.value,u=l.length;return e.loaded+=u,u<i||n.dataLength?(n.push(l),n.dataLength>=i&&a(e,r,n.flush(),t)):a(e,r,l,t),o()})).catch((function(){return Promise.reject()}))}()},t}();function Xi(t,e){return new self.Request(t.url,e)}var Qi=function(t){function e(e,r,i){var a;return(a=t.call(this,e)||this).code=void 0,a.details=void 0,a.code=r,a.details=i,a}return l(e,t),e}(c(Error)),$i={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},Zi=i(i({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Yi,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Ni,bufferController:Hi,capLevelController:Ki,errorController:Oe,fpsController:Vi,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:$i},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:$i},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:H,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:void 0});function Ji(t){return t&&"object"==typeof t?Array.isArray(t)?t.map(Ji):Object.keys(t).reduce((function(e,r){return e[r]=Ji(t[r]),e}),{}):t}function ta(t){var e=t.loader;e!==zi&&e!==Yi?(D.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}()&&(t.loader=zi,t.progressive=!0,t.enableSoftwareAES=!0,D.log("[config]: Progressive streaming enabled, using FetchLoader"))}var ea=function(){function t(e){void 0===e&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Di,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,k(e.debug||!1,"Hls instance");var r=this.config=function(t,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var r=Ji(t),a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((function(t){var i=("level"===t?"playlist":t)+"LoadPolicy",n=void 0===e[i],s=[];a.forEach((function(a){var o=t+"Loading"+a,l=e[o];if(void 0!==l&&n){s.push(o);var u=r[i].default;switch(e[i]={default:u},a){case"TimeOut":u.maxLoadTimeMs=l,u.maxTimeToFirstByteMs=l;break;case"MaxRetry":u.errorRetry.maxNumRetry=l,u.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":u.errorRetry.retryDelayMs=l,u.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=l,u.timeoutRetry.maxRetryDelayMs=l}}})),s.length&&D.warn('hls.js config: "'+s.join('", "')+'" setting(s) are deprecated, use "'+i+'": '+JSON.stringify(e[i]))})),i(i({},r),e)}(t.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,r.progressive&&ta(r);var a=r.abrController,n=r.bufferController,s=r.capLevelController,o=r.errorController,l=r.fpsController,u=new o(this),d=this.abrController=new a(this),h=this.bufferController=new n(this),f=this.capLevelController=new s(this),c=new l(this),v=new Xt(this),g=new ae(this),m=r.contentSteeringController,p=m?new m(this):null,y=this.levelController=new Ne(this,p),T=new We(this),S=new Ze(this.config),L=this.streamController=new Fi(this,T,S);f.setStreamController(L),c.setStreamController(L);var R=[v,y,L];p&&R.splice(1,0,p),this.networkControllers=R;var b=[d,h,f,c,g,T];this.audioTrackController=this.createController(r.audioTrackController,R);var A=r.audioStreamController;A&&R.push(new A(this,T,S)),this.subtitleTrackController=this.createController(r.subtitleTrackController,R);var _=r.subtitleStreamController;_&&R.push(new _(this,T,S)),this.createController(r.timelineController,b),S.emeController=this.emeController=this.createController(r.emeController,b),this.cmcdController=this.createController(r.cmcdController,b),this.latencyController=this.createController(ne,b),this.coreComponents=b,R.push(u);var x=u.onErrorOut;"function"==typeof x&&this.on(E.ERROR,x,u)}t.isSupported=function(){return function(){var t=Lr();if(!t)return!1;var e=Rr(),r=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove;return!!r&&!!i}()};var e=t.prototype;return e.createController=function(t,e){if(t){var r=new t(this);return e&&e.push(r),r}return null},e.on=function(t,e,r){void 0===r&&(r=this),this._emitter.on(t,e,r)},e.once=function(t,e,r){void 0===r&&(r=this),this._emitter.once(t,e,r)},e.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},e.off=function(t,e,r,i){void 0===r&&(r=this),this._emitter.off(t,e,r,i)},e.listeners=function(t){return this._emitter.listeners(t)},e.emit=function(t,e,r){return this._emitter.emit(t,e,r)},e.trigger=function(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){D.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.trigger(E.ERROR,{type:T.OTHER_ERROR,details:S.INTERNAL_EXCEPTION,fatal:!1,event:t,error:e})}return!1},e.listenerCount=function(t){return this._emitter.listenerCount(t)},e.destroy=function(){D.log("destroy"),this.trigger(E.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(t){return t.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(t){return t.destroy()})),this.coreComponents.length=0;var t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null},e.attachMedia=function(t){D.log("attachMedia"),this._media=t,this.trigger(E.MEDIA_ATTACHING,{media:t})},e.detachMedia=function(){D.log("detachMedia"),this.trigger(E.MEDIA_DETACHING,void 0),this._media=null},e.loadSource=function(t){this.stopLoad();var e=this.media,r=this.url,i=this.url=p.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});D.log("loadSource:"+i),e&&r&&r!==i&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(e)),this.trigger(E.MANIFEST_LOADING,{url:t})},e.startLoad=function(t){void 0===t&&(t=-1),D.log("startLoad("+t+")"),this.networkControllers.forEach((function(e){e.startLoad(t)}))},e.stopLoad=function(){D.log("stopLoad"),this.networkControllers.forEach((function(t){t.stopLoad()}))},e.swapAudioCodec=function(){D.log("swapAudioCodec"),this.streamController.swapAudioCodec()},e.recoverMediaError=function(){D.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},e.removeLevel=function(t,e){void 0===e&&(e=0),this.levelController.removeLevel(t,e)},n(t,[{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){D.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){D.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){D.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){D.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){D.log("set startLevel:"+t),-1!==t&&(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&&(D.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"ttfbEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(t){se.indexOf(t)>-1&&(this._maxHdcpLevel=t)}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{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=-1===r&&e&&e.length?e.length-1:r,i)for(var a=t;a--;){var n=e[a].attrs["HDCP-LEVEL"];if(n&&n<=i)return a}return t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{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:"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(){}},{key:"Events",get:function(){return E}},{key:"ErrorTypes",get:function(){return T}},{key:"ErrorDetails",get:function(){return S}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:Zi},set:function(e){t.defaultConfig=e}}]),t}();return ea.defaultConfig=void 0,ea},"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(r="undefined"!=typeof globalThis?globalThis:r||self).Hls=i()}(!1);
1
+ !function e(t){var r,i;r=this,i=function(){"use strict";function r(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,f(i.key),i)}}function i(e,t,i){return t&&r(e.prototype,t),i&&r(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t,r){return(t=f(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},n.apply(null,arguments)}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function o(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,h(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function c(e){var t="function"==typeof Map?new Map:void 0;return c=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(l())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,t);var a=new(e.bind.apply(e,i));return r&&h(a,r.prototype),a}(e,arguments,s(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,e)},c(e)}function v(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var g,m,p={exports:{}},y=(g||(g=1,function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function a(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function n(e,t,i,n,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new a(i,n||e,s),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function s(e,t){0===--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,a=[];if(0===this._eventsCount)return a;for(i in e=this._events)t.call(e,i)&&a.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var a=0,n=i.length,s=new Array(n);a<n;a++)s[a]=i[a].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,a,n,s){var o=r?r+e:e;if(!this._events[o])return!1;var l,u,d=this._events[o],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),h){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,a),!0;case 5:return d.fn.call(d.context,t,i,a,n),!0;case 6:return d.fn.call(d.context,t,i,a,n,s),!0}for(u=1,l=new Array(h-1);u<h;u++)l[u-1]=arguments[u];d.fn.apply(d.context,l)}else{var f,c=d.length;for(u=0;u<c;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),h){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,i);break;case 4:d[u].fn.call(d[u].context,t,i,a);break;default:if(!l)for(f=1,l=new Array(h-1);f<h;f++)l[f-1]=arguments[f];d[u].fn.apply(d[u].context,l)}}return!0},o.prototype.on=function(e,t,r){return n(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return n(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,a){var n=r?r+e:e;if(!this._events[n])return this;if(!t)return s(this,n),this;var o=this._events[n];if(o.fn)o.fn!==t||a&&!o.once||i&&o.context!==i||s(this,n);else{for(var l=0,u=[],d=o.length;l<d;l++)(o[l].fn!==t||a&&!o[l].once||i&&o[l].context!==i)&&u.push(o[l]);u.length?this._events[n]=1===u.length?u[0]:u:s(this,n)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(p)),p.exports),E=v(y),T={exports:{}},S=(m||(m=1,function(e){var t,r,i,a,n;t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,n={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var a=n.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");return a.path=n.normalizePath(a.path),n.buildURLFromParts(a)}var s=n.parseURL(t);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return i.alwaysNormalize?(s.path=n.normalizePath(s.path),n.buildURLFromParts(s)):t;var o=n.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=r.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(u.netLoc=o.netLoc,"/"!==s.path[0]))if(s.path){var d=o.path,h=d.substring(0,d.lastIndexOf("/")+1)+s.path;u.path=n.normalizePath(h)}else u.path=o.path,s.params||(u.params=o.params,s.query||(u.query=o.query));return null===u.path&&(u.path=i.alwaysNormalize?n.normalizePath(s.path):s.path),n.buildURLFromParts(u)},parseURL:function(e){var r=t.exec(e);return r?{scheme:r[1]||"",netLoc:r[2]||"",path:r[3]||"",params:r[4]||"",query:r[5]||"",fragment:r[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(i,"");e.length!==(e=e.replace(a,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=n}(T)),T.exports),L=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},R=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=A},A=Number.MAX_SAFE_INTEGER||9007199254740991,b=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),k=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),D=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.STALL_RESOLVED="hlsStallResolved",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({}),_="manifest",I="level",C="audioTrack",x="subtitleTrack",w="main",P="audio",O="subtitle",M=function(){function e(e,t,r){void 0===t&&(t=0),void 0===r&&(r=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_=r}var t=e.prototype;return t.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},e}(),F=function(){function e(e,t,r,i){void 0===i&&(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 M(e),this.fast_=new M(t),this.defaultTTFB_=i,this.ttfb_=new M(e)}var t=e.prototype;return t.update=function(e,t){var r=this.slow_,i=this.fast_,a=this.ttfb_;r.halfLife!==e&&(this.slow_=new M(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new M(t,i.getEstimate(),i.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new M(e,a.getEstimate(),a.getTotalWeight()))},t.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},t.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},t.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},t.destroy=function(){},i(e,[{key:"defaultEstimate",get:function(){return this.defaultEstimate_}}])}(),N=function(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var r="["+e+"]:";this.trace=B,this.debug=t.debug.bind(null,r),this.log=t.log.bind(null,r),this.warn=t.warn.bind(null,r),this.info=t.info.bind(null,r),this.error=t.error.bind(null,r)},B=function(){},U={trace:B,debug:B,log:B,warn:B,info:B,error:B};function G(){return n({},U)}function V(e,t,r){return t[e]?t[e].bind(t):function(e,t){var r=self.console[e];return r?r.bind(self.console,(t?"["+t+"] ":"")+"["+e+"] >"):B}(e,r)}var H=G();function K(e,t,r){var i=G();if("object"==typeof console&&!0===e||"object"==typeof e){var a=["debug","log","info","warn","error"];a.forEach(function(t){i[t]=V(t,e,r)});try{i.log('Debug logs enabled for "'+t+'" in hls.js version '+void 0)}catch(e){return G()}a.forEach(function(t){H[t]=V(t,e)})}else n(H,i);return i}var Y,j,W=H,q=j?Y:(j=1,Y=void 0),X=v(q);function z(e){if(void 0===e&&(e=!0),"undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function Q(e,t){if(void 0===t&&(t=!1),"undefined"!=typeof TextDecoder){var r=new TextDecoder("utf-8").decode(e);if(t){var i=r.indexOf("\0");return-1!==i?r.substring(0,i):r}return r.replace(/\0/g,"")}for(var a,n,s,o=e.length,l="",u=0;u<o;){if(0===(a=e[u++])&&t)return l;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(a);break;case 12:case 13:n=e[u++],l+=String.fromCharCode((31&a)<<6|63&n);break;case 14:n=e[u++],s=e[u++],l+=String.fromCharCode((15&a)<<12|(63&n)<<6|63&s)}}return l}function $(e){for(var t="",r=0;r<e.length;r++){var i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t}function Z(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var J=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}},ee="audio",te="video",re="audiovideo",ie=function(){function e(e){var t,r,i;this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof e&&(e={url:e}),this.base=e,(i=oe(t=this,r="stats"))&&(i.enumerable=!0,Object.defineProperty(t,r,i))}var t=e.prototype;return t.setByteRange=function(e,t){var r,i=e.split("@",2);r=1===i.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(i[1]),this._byteRange=[r,parseInt(i[0])+r]},t.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[ee]=null,e[te]=null,e[re]=null},i(e,[{key:"baseurl",get:function(){return this.base.url}},{key:"byteRange",get:function(){return null===this._byteRange?[]:this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"elementaryStreams",get:function(){var e;return null===this._streams&&(this._streams=((e={})[ee]=null,e[te]=null,e[re]=null,e)),this._streams},set:function(e){this._streams=e}},{key:"hasStats",get:function(){return null!==this._stats}},{key:"hasStreams",get:function(){return null!==this._streams}},{key:"stats",get:function(){return null===this._stats&&(this._stats=new J),this._stats},set:function(e){this._stats=e}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=S.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}])}();function ae(e){return"initSegment"!==e.sn}var ne=function(e){function t(t,r){var i;return(i=e.call(this,r)||this)._decryptdata=null,i._programDateTime=null,i._ref=null,i._bitrate=void 0,i.rawProgramDateTime=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.playlistOffset=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,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=t,i}o(t,e);var r=t.prototype;return r.addStart=function(e){this.setStart(this.start+e)},r.setStart=function(e){this.start=e,this._ref&&(this._ref.start=e)},r.setDuration=function(e){this.duration=e,this._ref&&(this._ref.duration=e)},r.setKeyFormat=function(e){if(this.levelkeys){var t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}},r.abortRequests=function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()},r.setElementaryStreamInfo=function(e,t,r,i,a,n){void 0===n&&(n=!1);var s=this.elementaryStreams,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,a)):s[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:a,partial:n}},i(t,[{key:"byteLength",get:function(){if(this.hasStats){var e=this.stats.total;if(e)return e}if(this.byteRange.length){var t=this.byteRange[0],r=this.byteRange[1];if(L(t)&&L(r))return r-t}return null}},{key:"bitrate",get:function(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null},set:function(e){this._bitrate=e}},{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 t=Object.keys(this.levelkeys);if(1===t.length){var r=this._decryptdata=this.levelkeys[t[0]]||null;if(r)return r.getDecryptData(this.sn)}}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;var e=L(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t,r=Object.keys(this.levelkeys),i=r.length;if(i>1||1===i&&null!=(t=this.levelkeys[r[0]])&&t.encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(e){L(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return ae(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}}])}(ie),se=function(e){function t(t,r,i,a,n){var s;(s=e.call(this,i)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.duration=t.decimalFloatingPoint("DURATION"),s.gap=t.bool("GAP"),s.independent=t.bool("INDEPENDENT"),s.relurl=t.enumeratedString("URI"),s.fragment=r,s.index=a;var o=t.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,n),n&&(s.fragOffset=n.fragOffset+n.duration),s}return o(t,e),i(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}])}(ie);function oe(e,t){var r=Object.getPrototypeOf(e);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i||oe(r,t)}}var le=Math.pow(2,32)-1,ue=[].push,de={video:1,audio:2,id3:3,text:4};function he(e){return String.fromCharCode.apply(null,e)}function fe(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function ce(e,t){var r=ge(e,t);return r<0?4294967296+r:r}function ve(e,t){var r=ce(e,t);return r*=Math.pow(2,32),r+=ce(e,t+4)}function ge(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function me(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,a=0;a<i;){var n=ce(e,a),s=n>1?a+n:i;if(he(e.subarray(a+4,a+8))===t[0])if(1===t.length)r.push(e.subarray(a+8,s));else{var o=me(e.subarray(a+8,s),t.slice(1));o.length&&ue.apply(r,o)}a=s}return r}function pe(e){var t=[],r=e[0],i=8,a=ce(e,i);i+=4;var n=0,s=0;0===r?(n=ce(e,i),s=ce(e,i+4),i+=8):(n=ve(e,i),s=ve(e,i+8),i+=16),i+=2;var o=e.length+s,l=fe(e,i);i+=2;for(var u=0;u<l;u++){var d=i,h=ce(e,d);d+=4;var f=2147483647&h;if(1==(2147483648&h)>>>31)return W.warn("SIDX has hierarchical references (not supported)"),null;var c=ce(e,d);d+=4,t.push({referenceSize:f,subsegmentDuration:c,info:{duration:c/a,start:o,end:o+f-1}}),o+=f,i=d+=4}return{earliestPresentationTime:n,timescale:a,version:r,referencesCount:l,references:t}}function ye(e){for(var t=[],r=me(e,["moov","trak"]),i=0;i<r.length;i++){var a=r[i],n=me(a,["tkhd"])[0];if(n){var s=n[0],o=ce(n,0===s?12:20),l=me(a,["mdia","mdhd"])[0];if(l){var u=ce(l,0===(s=l[0])?12:20),h=me(a,["mdia","hdlr"])[0];if(h){var f=he(h.subarray(8,12)),c={soun:ee,vide:te}[f],v=Ee(me(a,["mdia","minf","stbl","stsd"])[0]);c?(t[o]={timescale:u,type:c,stsd:v},t[c]=d({timescale:u,id:o},v)):t[o]={timescale:u,type:f,stsd:v}}}}}return me(e,["moov","mvex","trex"]).forEach(function(e){var r=ce(e,4),i=t[r];i&&(i.default={duration:ce(e,12),flags:ce(e,20)})}),t}function Ee(e){var t,r=e.subarray(8),i=r.subarray(86),a=he(r.subarray(4,8)),n=a,s="enca"===a||"encv"===a;if(s){var o=me(r,[a])[0];me(o.subarray("enca"===a?28:78),["sinf"]).forEach(function(e){var t=me(e,["schm"])[0];if(t){var r=he(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var i=me(e,["frma"])[0];i&&(n=he(i))}}})}var l=n;switch(n){case"avc1":case"avc2":case"avc3":case"avc4":var u=me(i,["avcC"])[0];u&&u.length>3&&(n+="."+Le(u[1])+Le(u[2])+Le(u[3]),t=Te("avc1"===l?"dva1":"dvav",i));break;case"mp4a":var d=me(r,[a])[0],h=me(d.subarray(28),["esds"])[0];if(h&&h.length>7){var f=4;if(3!==h[f++])break;f=Se(h,f),f+=2;var c=h[f++];if(128&c&&(f+=2),64&c&&(f+=h[f++]),4!==h[f++])break;f=Se(h,f);var v=h[f++];if(64!==v)break;if(n+="."+Le(v),f+=12,5!==h[f++])break;f=Se(h,f);var g=h[f++],m=(248&g)>>3;31===m&&(m+=1+((7&g)<<3)+((224&h[f])>>5)),n+="."+m}break;case"hvc1":case"hev1":var p=me(i,["hvcC"])[0];if(p&&p.length>12){var y=p[1],E=["","A","B","C"][y>>6],T=31&y,S=ce(p,2),L=(32&y)>>5?"H":"L",R=p[12],A=p.subarray(6,12);n+="."+E+T,n+="."+function(e){for(var t=0,r=0;r<32;r++)t|=(e>>r&1)<<31-r;return t>>>0}(S).toString(16).toUpperCase(),n+="."+L+R;for(var b="",k=A.length;k--;){var D=A[k];(D||b)&&(b="."+D.toString(16).toUpperCase()+b)}n+=b}t=Te("hev1"==l?"dvhe":"dvh1",i);break;case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":n=Te(n,i)||n;break;case"vp09":var _=me(i,["vpcC"])[0];if(_&&_.length>6){var I=_[4],C=_[5],x=_[6]>>4&15;n+="."+Re(I)+"."+Re(C)+"."+Re(x)}break;case"av01":var w=me(i,["av1C"])[0];if(w&&w.length>2){var P=w[1]>>>5,O=31&w[1],M=w[2]>>>7?"H":"M",F=(64&w[2])>>6,N=(32&w[2])>>5,B=2===P&&F?N?12:10:F?10:8,U=(16&w[2])>>4,G=(8&w[2])>>3,V=(4&w[2])>>2,H=3&w[2];n+="."+P+"."+Re(O)+M+"."+Re(B)+"."+U+"."+G+V+H+"."+Re(1)+"."+Re(1)+"."+Re(1)+".0",t=Te("dav1",i)}}return{codec:n,encrypted:s,supplemental:t}}function Te(e,t){var r=me(t,["dvvC"]),i=r.length?r[0]:me(t,["dvcC"])[0];if(i){var a=i[2]>>1&127,n=i[2]<<5&32|i[3]>>3&31;return e+"."+Re(a)+"."+Re(n)}}function Se(e,t){for(var r=t+5;128&e[t++]&&t<r;);return t}function Le(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function Re(e){return(e<10?"0":"")+e}function Ae(e,t){if(e&&t){var r=t.keyId;r&&t.isCommonEncryption&&me(e,["moov","trak"]).forEach(function(e){var t=me(e,["mdia","minf","stbl","stsd"])[0].subarray(8),i=me(t,["enca"]),a=i.length>0;a||(i=me(t,["encv"])),i.forEach(function(e){me(a?e.subarray(28):e.subarray(78),["sinf"]).forEach(function(e){var t=function(e){var t=me(e,["schm"])[0];if(t){var r=he(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return me(e,["schi","tenc"])[0]}return null}(e);if(t){var i=t.subarray(8,24);i.some(function(e){return 0!==e})||(W.log("[eme] Patching keyId in 'enc"+(a?"a":"v")+">sinf>>tenc' box: "+$(i)+" -> "+$(r)),t.set(r,8))}})})})}}function be(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function ke(e,t){var r=[],i=t.samples,a=t.timescale,n=t.id,s=!1;return me(i,["moof"]).map(function(o){var l=o.byteOffset-8;me(o,["traf"]).map(function(o){var u=me(o,["tfdt"]).map(function(e){var t=e[0],r=ce(e,4);return 1===t&&(r*=Math.pow(2,32),r+=ce(e,8)),r/a})[0];return void 0!==u&&(e=u),me(o,["tfhd"]).map(function(u){var d=ce(u,4),h=16777215&ce(u,0),f=0,c=!!(16&h),v=0,g=!!(32&h),m=8;d===n&&(!!(1&h)&&(m+=8),!!(2&h)&&(m+=4),!!(8&h)&&(f=ce(u,m),m+=4),c&&(v=ce(u,m),m+=4),g&&(m+=4),"video"===t.type&&(s=De(t.codec)),me(o,["trun"]).map(function(n){var o=n[0],u=16777215&ce(n,0),d=!!(1&u),h=0,c=!!(4&u),g=!!(256&u),m=0,p=!!(512&u),y=0,E=!!(1024&u),T=!!(2048&u),S=0,L=ce(n,4),R=8;d&&(h=ce(n,R),R+=4),c&&(R+=4);for(var A=h+l,b=0;b<L;b++){if(g?(m=ce(n,R),R+=4):m=f,p?(y=ce(n,R),R+=4):y=v,E&&(R+=4),T&&(S=0===o?ce(n,R):ge(n,R),R+=4),t.type===te)for(var k=0;k<y;){var D=ce(i,A);_e(s,i[A+=4])&&Ie(i.subarray(A,A+D),s?2:1,e+S/a,r),A+=D,k+=D+4}e+=m/a}}))})})}),r}function De(e){if(!e)return!1;var t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function _e(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6==(31&t)}function Ie(e,t,r,i){var a=Ce(e),n=0;n+=t;for(var s=0,o=0,l=0;n<a.length;){s=0;do{if(n>=a.length)break;s+=l=a[n++]}while(255===l);o=0;do{if(n>=a.length)break;o+=l=a[n++]}while(255===l);var u=a.length-n,d=n;if(o<u)n+=o;else if(o>u){W.error("Malformed SEI payload. "+o+" is too small, only "+u+" bytes left to parse.");break}if(4===s){if(181===a[d++]){var h=fe(a,d);if(d+=2,49===h){var f=ce(a,d);if(d+=4,1195456820===f){var c=a[d++];if(3===c){var v=a[d++],g=64&v,m=g?2+3*(31&v):0,p=new Uint8Array(m);if(g){p[0]=v;for(var y=1;y<m;y++)p[y]=a[d++]}i.push({type:c,payloadType:s,pts:r,bytes:p})}}}}}else if(5===s&&o>16){for(var E=[],T=0;T<16;T++){var S=a[d++].toString(16);E.push(1==S.length?"0"+S:S),3!==T&&5!==T&&7!==T&&9!==T||E.push("-")}for(var L=o-16,R=new Uint8Array(L),A=0;A<L;A++)R[A]=a[d++];i.push({payloadType:s,pts:r,uuid:E.join(""),userData:Q(R),userDataBytes:R})}}}function Ce(e){for(var t=e.byteLength,r=[],i=1;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;var a=t-r.length,n=new Uint8Array(a),s=0;for(i=0;i<a;s++,i++)s===r[0]&&(s++,r.shift()),n[i]=e[s];return n}var xe=function(){return/\(Windows.+Firefox\//i.test(navigator.userAgent)},we={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,dav1:.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 Pe(e,t){var r=we[t];return!!r&&!!r[e.slice(0,4)]}function Oe(e,t,r){return void 0===r&&(r=!0),!e.split(",").some(function(e){return!Me(e,t,r)})}function Me(e,t,r){var i;void 0===r&&(r=!0);var a=z(r);return null!=(i=null==a?void 0:a.isTypeSupported(Fe(e,t)))&&i}function Fe(e,t){return t+"/mp4;codecs="+e}function Ne(e){if(e){var t=e.substring(0,4);return we.video[t]}return 2}function Be(e){var t=xe();return e.split(",").reduce(function(e,r){var i=t&&De(r)?9:we.video[r];return i?(2*i+e)/(e?3:2):(we.audio[r]+e)/(e?2:1)},0)}var Ue={},Ge=/flac|opus|mp4a\.40\.34/i;function Ve(e,t){return void 0===t&&(t=!0),e.replace(Ge,function(e){return function(e,t){if(void 0===t&&(t=!0),Ue[e])return Ue[e];for(var r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e],i=0;i<r.length;i++){var a;if(Me(r[i],"audio",t))return Ue[e]=r[i],r[i];if("mp3"===r[i]&&null!=(a=z(t))&&a.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t)})}function He(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(Ke(e,"audio")||Ke(e,"video")))return e;if(t){var r=t.split(",");if(r.length>1){if(e)for(var i=r.length;i--;)if(r[i].substring(0,4)===e.substring(0,4))return r[i];return r[0]}}return t||e}function Ke(e,t){return Pe(e,t)&&Me(e,t)}function Ye(e){if(e.startsWith("av01.")){for(var t=e.split("."),r=["0","111","01","01","01","0"],i=t.length;i>4&&i<10;i++)t[i]=r[i-4];return t.join(".")}return e}function je(e){var t=z(e)||{isTypeSupported:function(){return!1}};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1}}function We(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var qe=["NONE","TYPE-0","TYPE-1",null],Xe=["SDR","PQ","HLG"],ze="",Qe="YES",$e="v2";function Ze(e){var t=e.canSkipUntil,r=e.canSkipDateRanges,i=e.age;return t&&i<t/2?r?$e:Qe:ze}var Je=function(){function e(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}return e.prototype.addDirectives=function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},e}(),et=function(){function e(e){if(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.supplemental=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(function(e){return!!e}).map(function(e){return e.substring(0,4)}).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;var r=null==(t=e.supplemental)?void 0:t.videoCodec;r&&r!==e.videoCodec&&(this.codecSet+=","+r.substring(0,4))}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}var t=e.prototype;return t.hasAudioGroup=function(e){return tt(this._audioGroups,e)},t.hasSubtitleGroup=function(e){return tt(this._subtitleGroups,e)},t.addGroupId=function(e,t){if(t)if("audio"===e){var r=this._audioGroups;r||(r=this._audioGroups=[]),-1===r.indexOf(t)&&r.push(t)}else if("text"===e){var i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),-1===i.indexOf(t)&&i.push(t)}},t.addFallback=function(){},i(e,[{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(e){}},{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 e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}}])}();function tt(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function rt(e,t){var r=!1,i=[];if(e&&(r="SDR"!==e,i=[e]),t){var a="SDR"!==(i=t.allowedVideoRanges||Xe.slice(0)).join("")&&!t.videoCodec;(r=void 0!==t.preferHDR?t.preferHDR:a&&function(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}())||(i=["SDR"])}return{preferHDR:r,allowedVideoRanges:i}}var it=function(e,t){return JSON.stringify(e,function(e){var t=new WeakSet;return function(r,i){if(e&&(i=e(r,i)),"object"==typeof i&&null!==i){if(t.has(i))return;t.add(i)}return i}}(t))};function at(e,t){W.log('[abr] start candidates with "'+e+'" ignored because '+t)}function nt(e){return e.reduce(function(e,t){var r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);var i=t.channels||"2";return r.channels[i]=(r.channels[i]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function st(e,t){var r;return!!e&&e!==(null==(r=t.loadLevelObj)?void 0:r.uri)}var ot=function(e){function t(t){var r;return(r=e.call(this,"abr",t.logger)||this).hls=void 0,r.lastLevelLoadSec=0,r.lastLoadedFragLevel=-1,r.firstSelection=-1,r._nextAutoLevel=-1,r.nextAutoLevelKey="",r.audioTracksByGroup=null,r.codecTiers=null,r.timer=-1,r.fragCurrent=null,r.partCurrent=null,r.bitrateTestDelay=0,r.rebufferNotice=-1,r.supportedCache={},r.bwEstimator=void 0,r._abandonRulesCheck=function(e){var t,i=r,a=i.fragCurrent,n=i.partCurrent,s=i.hls,o=s.autoLevelEnabled,l=s.media;if(a&&l){var u=performance.now(),d=n?n.stats:a.stats,h=n?n.duration:a.duration,f=u-d.loading.start,c=s.minAutoLevel,v=a.level,g=r._nextAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||v<=c)return r.clearTimer(),void(r._nextAutoLevel=-1);if(o){var m=g>-1&&g!==v,p=!!e||m;if(p||!l.paused&&l.playbackRate&&l.readyState){var y=s.mainForwardBufferInfo;if(p||null!==y){var E=r.bwEstimator.getEstimateTTFB(),T=Math.abs(l.playbackRate);if(!(f<=Math.max(E,h/(2*T)*1e3))){var S=y?y.len/T:0,R=d.loading.first?d.loading.first-d.loading.start:-1,A=d.loaded&&R>-1,b=r.getBwEstimate(),k=s.levels,_=k[v],I=Math.max(d.loaded,Math.round(h*(a.bitrate||_.averageBitrate)/8)),C=A?f-R:f;C<1&&A&&(C=Math.min(f,8*d.loaded/b));var x=A?1e3*d.loaded/C:0,w=E/1e3,P=x?(I-d.loaded)/x:8*I/b+w;if(!(P<=S)){var O,M=x?8*x:b,F=!0===(null==(t=(null==e?void 0:e.details)||r.hls.latestLevelDetails)?void 0:t.live),N=r.hls.config.abrBandWidthUpFactor,B=Number.POSITIVE_INFINITY;for(O=v-1;O>c;O--){var U=k[O].maxBitrate,G=!k[O].details||F;if((B=r.getTimeToLoadFrag(w,M,h*U,G))<Math.min(S,h+w))break}if(!(B>=P||B>10*h)){A?r.bwEstimator.sample(f-Math.min(E,R),d.loaded):r.bwEstimator.sampleTTFB(f);var V=k[O].maxBitrate;r.getBwEstimate()*N>V&&r.resetEstimator(V);var H=r.findBestLevel(V,c,O,0,S,1,1);H>-1&&(O=H),r.warn("Fragment "+a.sn+(n?" part "+n.index:"")+" of level "+v+" is loading too slowly;\n Fragment duration: "+a.duration.toFixed(3)+"\n Time to underbuffer: "+S.toFixed(3)+" s\n Estimated load time for current fragment: "+P.toFixed(3)+" s\n Estimated load time for down switch fragment: "+B.toFixed(3)+" s\n TTFB estimate: "+(0|R)+" ms\n Current BW estimate: "+(L(b)?0|b:"Unknown")+" bps\n New BW estimate: "+(0|r.getBwEstimate())+" bps\n Switching to level "+O+" @ "+(0|V)+" bps"),s.nextLoadLevel=s.nextAutoLevel=O,r.clearTimer();var K=function(){if(r.clearTimer(),r.fragCurrent===a&&r.hls.loadLevel===O&&O>0){var e=r.getStarvationDelay();if(r.warn("Aborting inflight request "+(O>0?"and switching down":"")+"\n Fragment duration: "+a.duration.toFixed(3)+" s\n Time to underbuffer: "+e.toFixed(3)+" s"),a.abortRequests(),r.fragCurrent=r.partCurrent=null,O>c){var t=r.findBestLevel(r.hls.levels[c].bitrate,c,O,0,e,1,1);-1===t&&(t=c),r.hls.nextLoadLevel=r.hls.nextAutoLevel=t,r.resetEstimator(r.hls.levels[t].bitrate)}}};m||P>2*B?K():r.timer=self.setInterval(K,1e3*B),s.trigger(D.FRAG_LOAD_EMERGENCY_ABORTED,{frag:a,part:n,stats:d})}}}}}}}},r.hls=t,r.bwEstimator=r.initEstimator(),r.registerListeners(),r}o(t,e);var r=t.prototype;return r.resetEstimator=function(e){e&&(this.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},r.initEstimator=function(){var e=this.hls.config;return new F(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},r.registerListeners=function(){var e=this.hls;e.on(D.MANIFEST_LOADING,this.onManifestLoading,this),e.on(D.FRAG_LOADING,this.onFragLoading,this),e.on(D.FRAG_LOADED,this.onFragLoaded,this),e.on(D.FRAG_BUFFERED,this.onFragBuffered,this),e.on(D.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(D.LEVEL_LOADED,this.onLevelLoaded,this),e.on(D.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(D.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(D.ERROR,this.onError,this)},r.unregisterListeners=function(){var e=this.hls;e&&(e.off(D.MANIFEST_LOADING,this.onManifestLoading,this),e.off(D.FRAG_LOADING,this.onFragLoading,this),e.off(D.FRAG_LOADED,this.onFragLoaded,this),e.off(D.FRAG_BUFFERED,this.onFragBuffered,this),e.off(D.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(D.LEVEL_LOADED,this.onLevelLoaded,this),e.off(D.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(D.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(D.ERROR,this.onError,this))},r.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null},r.onManifestLoading=function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},r.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},r.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},r.onFragLoading=function(e,t){var r,i=t.frag;this.ignoreFragment(i)||(i.bitrateTest||(this.fragCurrent=i,this.partCurrent=null!=(r=t.part)?r:null),this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100))},r.onLevelSwitching=function(e,t){this.clearTimer()},r.onError=function(e,t){if(!t.fatal)switch(t.details){case k.BUFFER_ADD_CODEC_ERROR:case k.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case k.FRAG_LOAD_TIMEOUT:var r=t.frag,i=this.fragCurrent,a=this.partCurrent;if(r&&i&&r.sn===i.sn&&r.level===i.level){var n=performance.now(),s=a?a.stats:r.stats,o=n-s.loading.start,l=s.loading.first?s.loading.first-s.loading.start:-1;if(s.loaded&&l>-1){var u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(o-Math.min(u,l),s.loaded)}else this.bwEstimator.sampleTTFB(o)}}},r.getTimeToLoadFrag=function(e,t,r,i){return e+r/t+(i?e+this.lastLevelLoadSec:0)},r.onLevelLoaded=function(e,t){var r=this.hls.config,i=t.stats.loading,a=i.end-i.first;L(a)&&(this.lastLevelLoadSec=a/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)},r.onFragLoaded=function(e,t){var r=t.frag,i=t.part,a=i?i.stats:r.stats;if(r.type===w&&this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var n=i?i.duration:r.duration,s=this.hls.levels[r.level],o=(s.loaded?s.loaded.bytes:0)+a.loaded,l=(s.loaded?s.loaded.duration:0)+n;s.loaded={bytes:o,duration:l},s.realBitrate=Math.round(8*o/l)}if(r.bitrateTest){var u={stats:a,frag:r,part:i,id:r.type};this.onFragBuffered(D.FRAG_BUFFERED,u),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}},r.onFragBuffered=function(e,t){var r=t.frag,i=t.part,a=null!=i&&i.stats.loaded?i.stats:r.stats;if(!a.aborted&&!this.ignoreFragment(r)){var n=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,a.loaded),a.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}},r.ignoreFragment=function(e){return e.type!==w||"initSegment"===e.sn},r.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},r.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},r.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls;if(r.levels.length<=1)return r.loadLevel;var i=r.maxAutoLevel,a=r.config,n=r.minAutoLevel,s=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay(),u=a.abrBandWidthFactor,d=a.abrBandWidthUpFactor;if(l){var h=this.findBestLevel(o,n,i,l,0,u,d);if(h>=0)return this.rebufferNotice=-1,h}var f=s?Math.min(s,a.maxStarvationDelay):a.maxStarvationDelay;if(!l){var c=this.bitrateTestDelay;c&&(f=(s?Math.min(s,a.maxLoadingDelay):a.maxLoadingDelay)-c,this.info("bitrate test took "+Math.round(1e3*c)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*f)+" ms"),u=d=1)}var v=this.findBestLevel(o,n,i,l,f,u,d);if(this.rebufferNotice!==v&&(this.rebufferNotice=v,this.info((l?"rebuffering expected":"buffer is empty")+", optimal quality level "+v)),v>-1)return v;var g=r.levels[n],m=r.loadLevelObj;return m&&(null==g?void 0:g.bitrate)<m.bitrate?n:r.loadLevel},r.getStarvationDelay=function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/r},r.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},r.findBestLevel=function(e,t,r,i,a,n,s){var o,l=this,u=i+a,d=this.lastLoadedFragLevel,h=-1===d?this.hls.firstLevel:d,f=this.fragCurrent,c=this.partCurrent,v=this.hls,g=v.levels,m=v.allAudioTracks,p=v.loadLevel,y=v.config;if(1===g.length)return 0;var E,T=g[h],S=!(null==(o=this.hls.latestLevelDetails)||!o.live),R=-1===p||-1===d,A="SDR",b=(null==T?void 0:T.frameRate)||0,k=y.audioPreference,D=y.videoPreference,_=(this.audioTracksByGroup||(this.audioTracksByGroup=nt(m)),-1);if(R){if(-1!==this.firstSelection)return this.firstSelection;var I=this.codecTiers||(this.codecTiers=function(e,t,r,i){return e.slice(r,i+1).reduce(function(e,t,r){if(!t.codecSet)return e;var i=t.audioGroups,a=e[t.codecSet];a||(e[t.codecSet]=a={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:r,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!i,fragmentError:0}),a.minBitrate=Math.min(a.minBitrate,t.bitrate);var n=Math.min(t.height,t.width);return a.minHeight=Math.min(a.minHeight,n),a.minFramerate=Math.min(a.minFramerate,t.frameRate),a.minIndex=Math.min(a.minIndex,r),a.maxScore=Math.max(a.maxScore,t.score),a.fragmentError+=t.fragmentError,a.videoRanges[t.videoRange]=(a.videoRanges[t.videoRange]||0)+1,e},{})}(g,0,t,r)),C=function(e,t,r,i,a){for(var n=Object.keys(e),s=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,l=null==a?void 0:a.videoCodec,u=s&&2===parseInt(s),d=!1,h=!1,f=1/0,c=1/0,v=1/0,g=1/0,m=0,p=[],y=rt(t,a),E=y.preferHDR,T=y.allowedVideoRanges,S=function(){var t=e[n[R]];d||(d=t.channels[2]>0),f=Math.min(f,t.minHeight),c=Math.min(c,t.minFramerate),v=Math.min(v,t.minBitrate),T.filter(function(e){return t.videoRanges[e]>0}).length>0&&(h=!0)},R=n.length;R--;)S();f=L(f)?f:0,c=L(c)?c:0;var A=Math.max(1080,f),b=Math.max(30,c);v=L(v)?v:r,r=Math.max(v,r),h||(t=void 0);var k=n.length>1;return{codecSet:n.reduce(function(t,i){var a=e[i];if(i===t)return t;if(p=h?T.filter(function(e){return a.videoRanges[e]>0}):[],k){if(a.minBitrate>r)return at(i,"min bitrate of "+a.minBitrate+" > current estimate of "+r),t;if(!a.hasDefaultAudio)return at(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!=0)return at(i,'audio codec preference "'+o+'" not found'),t;if(s&&!u){if(!a.channels[s])return at(i,"no renditions with "+s+" channel sound found (channels options: "+Object.keys(a.channels)+")"),t}else if((!o||u)&&d&&0===a.channels[2])return at(i,"no renditions with stereo sound found"),t;if(a.minHeight>A)return at(i,"min resolution of "+a.minHeight+" > maximum of "+A),t;if(a.minFramerate>b)return at(i,"min framerate of "+a.minFramerate+" > maximum of "+b),t;if(!p.some(function(e){return a.videoRanges[e]>0}))return at(i,"no variants with VIDEO-RANGE of "+it(p)+" found"),t;if(l&&i.indexOf(l.substring(0,4))%5!=0)return at(i,'video codec preference "'+l+'" not found'),t;if(a.maxScore<m)return at(i,"max score of "+a.maxScore+" < selected max of "+m),t}return t&&(Be(i)>=Be(t)||a.fragmentError>e[t].fragmentError)?t:(g=a.minIndex,m=a.maxScore,i)},void 0),videoRanges:p,preferHDR:E,minFramerate:c,minBitrate:v,minIndex:g}}(I,A,e,k,D),x=C.codecSet,w=C.videoRanges,P=C.minFramerate,O=C.minBitrate,M=C.minIndex,F=C.preferHDR;_=M,E=x,A=F?w[w.length-1]:w[0],b=P,e=Math.max(e,O),this.log("picked start tier "+it(C))}else E=null==T?void 0:T.codecSet,A=null==T?void 0:T.videoRange;for(var N,B=c?c.duration:f?f.duration:0,U=this.bwEstimator.getEstimateTTFB()/1e3,G=[],V=function(){var t,o=g[H],f=H>h;if(!o)return 0;if((E&&o.codecSet!==E||A&&o.videoRange!==A||f&&b>o.frameRate||!f&&b>0&&b<o.frameRate||null!=(t=o.supportedResult)&&null!=(t=t.decodingInfoResults)&&t.some(function(e){return!1===e.smooth}))&&(!R||H!==_))return G.push(H),0;var v,m=o.details,y=(c?null==m?void 0:m.partTarget:null==m?void 0:m.averagetargetduration)||B;v=f?s*e:n*e;var T=B&&i>=2*B&&0===a?o.averageBitrate:o.maxBitrate,k=l.getTimeToLoadFrag(U,v,T*y,void 0===m);if(v>=T&&(H===d||0===o.loadError&&0===o.fragmentError)&&(k<=U||!L(k)||S&&!l.bitrateTestDelay||k<u)){var D=l.forcedAutoLevel;return H===p||-1!==D&&D===p||(G.length&&l.trace("Skipped level(s) "+G.join(",")+" of "+r+' max with CODECS and VIDEO-RANGE:"'+g[G[0]].codecs+'" '+g[G[0]].videoRange+'; not compatible with "'+E+'" '+A),l.info("switch candidate:"+h+"->"+H+" adjustedbw("+Math.round(v)+")-bitrate="+Math.round(v-T)+" ttfb:"+U.toFixed(1)+" avgDuration:"+y.toFixed(1)+" maxFetchDuration:"+u.toFixed(1)+" fetchDuration:"+k.toFixed(1)+" firstSelection:"+R+" codecSet:"+o.codecSet+" videoRange:"+o.videoRange+" hls.loadLevel:"+p)),R&&(l.firstSelection=H),{v:H}}},H=r;H>=t;H--)if(0!==(N=V())&&N)return N.v;return-1},r.deriveNextAutoLevel=function(e){var t=this.hls,r=t.maxAutoLevel,i=t.minAutoLevel;return Math.min(Math.max(e,i),r)},i(t,[{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.minAutoLevel,i=this.getBwEstimate(),a=this.hls.config.maxStarvationDelay,n=this.findBestLevel(i,r,t,0,a,1,1);if(n>-1)return n;var s=this.hls.firstLevel,o=Math.min(Math.max(s,r),t);return this.warn("Could not find best starting auto level. Defaulting to first in playlist "+s+" clamped to "+o),o}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var a=this.hls.levels;if(a.length>Math.max(e,i)&&a[e].loadError<=a[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i},set:function(e){var t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}}])}(N),lt=function(){function e(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}var t=e.prototype;return t.destroy=function(){this.tracks=this.queues=null},t.append=function(e,t,r){if(null!==this.queues&&null!==this.tracks){var i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)}},t.appendBlocker=function(e){var t=this;return new Promise(function(r){var i={label:"async-blocker",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.append(i,e)})},t.prependBlocker=function(e){var t=this;return new Promise(function(r){if(t.queues){var i={label:"async-blocker-prepend",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.queues[e].unshift(i)}})},t.removeBlockers=function(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(function(e){var t,r=null==(t=e[0])?void 0:t.label;"async-blocker"!==r&&"async-blocker-prepend"!==r||(e[0].execute(),e.splice(0,1))})},t.unblockAudio=function(e){null!==this.queues&&this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")},t.executeNext=function(e){if(null!==this.queues&&null!==this.tracks){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(t){var i;if(r.onError(t),null===this.queues||null===this.tracks)return;var a=null==(i=this.tracks[e])?void 0:i.buffer;null!=a&&a.updating||this.shiftAndExecuteNext(e)}}}},t.shiftAndExecuteNext=function(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))},t.current=function(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null},t.toString=function(){var e=this.queues,t=this.tracks;return null===e||null===t?"<destroyed>":"\n"+this.list("video")+"\n"+this.list("audio")+"\n"+this.list("audiovideo")+"}"},t.list=function(e){var t,r;return null!=(t=this.queues)&&t[e]||null!=(r=this.tracks)&&r[e]?e+": ("+this.listSbInfo(e)+") "+this.listOps(e):""},t.listSbInfo=function(e){var t,r=null==(t=this.tracks)?void 0:t[e],i=null==r?void 0:r.buffer;return i?"SourceBuffer"+(i.updating?" updating":"")+(r.ended?" ended":"")+(r.ending?" ending":""):"none"},t.listOps=function(e){var t;return(null==(t=this.queues)?void 0:t[e].map(function(e){return e.label}).join(", "))||""},e}(),ut=function(e,t){for(var r=0,i=e.length-1,a=null,n=null;r<=i;){var s=t(n=e[a=(r+i)/2|0]);if(s>0)r=a+1;else{if(!(s<0))return n;i=a-1}}return null};function dt(e,t,r,i,a){void 0===r&&(r=0),void 0===i&&(i=0),void 0===a&&(a=.005);var n=null;if(e){n=t[1+e.sn-t[0].sn]||null;var s=e.endDTS-r;s>0&&s<15e-7&&(r+=15e-7),n&&e.level!==n.level&&n.end<=e.end&&(n=t[2+e.sn-t[0].sn]||null)}else 0===r&&0===t[0].start&&(n=t[0]);if(n&&((!e||e.level===n.level)&&0===ht(r,i,n)||function(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var i=t.tagList.reduce(function(e,t){return"INF"===t[0]&&(e+=parseFloat(t[1])),e},r);return e.start<=i}return!1}(n,e,Math.min(a,i))))return n;var o=ut(t,ht.bind(null,r,i));return!o||o===e&&n?n:o}function ht(e,t,r){if(void 0===e&&(e=0),void 0===t&&(t=0),r.start<=e&&r.start+r.duration>e)return 0;var i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function ft(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function ct(e){switch(e.details){case k.FRAG_LOAD_TIMEOUT:case k.KEY_LOAD_TIMEOUT:case k.LEVEL_LOAD_TIMEOUT:case k.MANIFEST_LOAD_TIMEOUT:case k.AUDIO_TRACK_LOAD_TIMEOUT:case k.SUBTITLE_TRACK_LOAD_TIMEOUT:case k.ASSET_LIST_LOAD_TIMEOUT:return!0}return!1}function vt(e){return e.details.startsWith("key")}function gt(e){return vt(e)&&!!e.frag&&!e.frag.decryptdata}function mt(e,t){var r=ct(t);return e.default[(r?"timeout":"error")+"Retry"]}function pt(e,t){var r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function yt(e){return d(d({},e),{errorRetry:null,timeoutRetry:null})}function Et(e,t,r,i){if(!e)return!1;var a=null==i?void 0:i.code,n=t<e.maxNumRetry&&(function(e){return Tt(e)||!!e&&(e<400||e>499)}(a)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,n):n}function Tt(e){return 0===e&&!1===navigator.onLine}var St=0,Lt=2,Rt=3,At=5,bt=0,kt=1,Dt=2,_t=4,It=function(e){function t(t){var r;return(r=e.call(this,"error-controller",t.logger)||this).hls=void 0,r.playlistError=0,r.hls=t,r.registerListeners(),r}o(t,e);var r=t.prototype;return r.registerListeners=function(){var e=this.hls;e.on(D.ERROR,this.onError,this),e.on(D.MANIFEST_LOADING,this.onManifestLoading,this),e.on(D.LEVEL_UPDATED,this.onLevelUpdated,this)},r.unregisterListeners=function(){var e=this.hls;e&&(e.off(D.ERROR,this.onError,this),e.off(D.ERROR,this.onErrorOut,this),e.off(D.MANIFEST_LOADING,this.onManifestLoading,this),e.off(D.LEVEL_UPDATED,this.onLevelUpdated,this))},r.destroy=function(){this.unregisterListeners(),this.hls=null},r.startLoad=function(e){},r.stopLoad=function(){this.playlistError=0},r.getVariantLevelIndex=function(e){return(null==e?void 0:e.type)===w?e.level:this.getVariantIndex()},r.getVariantIndex=function(){var e,t=this.hls,r=t.currentLevel;return null!=(e=t.loadLevelObj)&&e.details||-1===r?t.loadLevel:r},r.variantHasKey=function(e,t){if(e){var r;if(null!=(r=e.details)&&r.hasKey(t))return!0;var i=e.audioGroups;if(i)return this.hls.allAudioTracks.filter(function(e){return i.indexOf(e.groupId)>=0}).some(function(e){var r;return null==(r=e.details)?void 0:r.hasKey(t)})}return!1},r.onManifestLoading=function(){this.playlistError=0},r.onLevelUpdated=function(){this.playlistError=0},r.onError=function(e,t){var r;if(!t.fatal){var i=this.hls,a=t.context;switch(t.details){case k.FRAG_LOAD_ERROR:case k.FRAG_LOAD_TIMEOUT:case k.KEY_LOAD_ERROR:case k.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case k.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=Ct());case k.FRAG_GAP:case k.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=Lt);case k.LEVEL_EMPTY_ERROR:case k.LEVEL_PARSING_ERROR:var n,s=t.parent===w?t.level:i.loadLevel;return void(t.details===k.LEVEL_EMPTY_ERROR&&null!=(n=t.context)&&null!=(n=n.levelDetails)&&n.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,s)));case k.LEVEL_LOAD_ERROR:case k.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case k.AUDIO_TRACK_LOAD_ERROR:case k.AUDIO_TRACK_LOAD_TIMEOUT:case k.SUBTITLE_LOAD_ERROR:case k.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var o=i.loadLevelObj;if(o&&(a.type===C&&o.hasAudioGroup(a.groupId)||a.type===x&&o.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=Lt,void(t.errorAction.flags=kt)}return;case k.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:Lt,flags:Dt});case k.KEY_SYSTEM_SESSION_UPDATE_FAILED:case k.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case k.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:Lt,flags:_t});case k.BUFFER_ADD_CODEC_ERROR:case k.REMUX_ALLOC_ERROR:case k.BUFFER_APPEND_ERROR:var l;return void(t.errorAction||(t.errorAction=this.getLevelSwitchAction(t,null!=(l=t.level)?l:i.loadLevel)));case k.INTERNAL_EXCEPTION:case k.BUFFER_APPENDING_ERROR:case k.BUFFER_FULL_ERROR:case k.LEVEL_SWITCH_ERROR:case k.BUFFER_STALLED_ERROR:case k.BUFFER_SEEK_OVER_HOLE:case k.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=Ct())}t.type===b.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=Ct())}},r.getPlaylistRetryOrSwitchAction=function(e,t){var r=mt(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(Et(r,i,ct(e),e.response))return{action:At,flags:bt,retryConfig:r,retryCount:i};var a=this.getLevelSwitchAction(e,t);return r&&(a.retryConfig=r,a.retryCount=i),a},r.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],a=t.config,n=a.fragLoadPolicy,s=a.keyLoadPolicy,o=mt(vt(e)?s:n,e),l=t.levels.reduce(function(e,t){return e+t.fragmentError},0);if(i&&(e.details!==k.FRAG_GAP&&i.fragmentError++,!gt(e)&&Et(o,l,ct(e),e.response)))return{action:At,flags:bt,retryConfig:o,retryCount:l};var u=this.getLevelSwitchAction(e,r);return o&&(u.retryConfig=o,u.retryCount=l),u},r.getLevelSwitchAction=function(e,t){var r=this.hls;null==t&&(t=r.loadLevel);var i=this.hls.levels[t];if(i){var a,n,s=e.details;i.loadError++,s===k.BUFFER_APPEND_ERROR&&i.fragmentError++;var o=-1,l=r.levels,u=r.loadLevel,d=r.minAutoLevel,h=r.maxAutoLevel;r.autoLevelEnabled||r.config.preserveManualLevelOnError||(r.loadLevel=-1);for(var f,c=null==(a=e.frag)?void 0:a.type,v=(c===P&&s===k.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(s===k.BUFFER_ADD_CODEC_ERROR||s===k.BUFFER_APPEND_ERROR))&&l.some(function(e){var t=e.audioCodec;return i.audioCodec!==t}),g="video"===e.sourceBufferName&&(s===k.BUFFER_ADD_CODEC_ERROR||s===k.BUFFER_APPEND_ERROR)&&l.some(function(e){var t=e.codecSet,r=e.audioCodec;return i.codecSet!==t&&i.audioCodec===r}),m=null!=(n=e.context)?n:{},p=m.type,y=m.groupId,E=function(){var t=(T+u)%l.length;if(t!==u&&t>=d&&t<=h&&0===l[t].loadError){var r,a,n=l[t];if(s===k.FRAG_GAP&&c===w&&e.frag){var f=l[t].details;if(f){var m=dt(e.frag,f.fragments,e.frag.start);if(null!=m&&m.gap)return 0}}else{if(p===C&&n.hasAudioGroup(y)||p===x&&n.hasSubtitleGroup(y))return 0;if(c===P&&null!=(r=i.audioGroups)&&r.some(function(e){return n.hasAudioGroup(e)})||c===O&&null!=(a=i.subtitleGroups)&&a.some(function(e){return n.hasSubtitleGroup(e)})||v&&i.audioCodec===n.audioCodec||g&&i.codecSet===n.codecSet||!v&&i.codecSet!==n.codecSet)return 0}return o=t,1}},T=l.length;T--&&(0===(f=E())||1!==f););if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:Lt,flags:bt,nextAutoLevel:o}}return{action:Lt,flags:kt}},r.onErrorOut=function(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case St:break;case Lt:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===k.FRAG_GAP?/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()):t.fatal=!0}t.fatal&&this.hls.stopLoad()},r.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var i=r.flags,a=r.nextAutoLevel;switch(i){case bt:this.switchLevel(e,a);break;case Dt:var n=this.getVariantLevelIndex(e.frag),s=t.levels[n],o=null==s?void 0:s.attrs["HDCP-LEVEL"];if(r.hdcpLevel=o,"NONE"===o)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(o){t.maxHdcpLevel=qe[qe.indexOf(o)-1],r.resolved=!0,this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower');break}case _t:var l=e.decryptdata;if(l){for(var u=this.hls.levels,d=u.length,h=d;h--;){var f,c;this.variantHasKey(u[h],l)&&(this.log("Banned key found in level "+h+" ("+u[h].bitrate+'bps) or audio group "'+(null==(f=u[h].audioGroups)?void 0:f.join(","))+'" ('+(null==(c=e.frag)?void 0:c.type)+" fragment) "+$(l.keyId||[])),u[h].fragmentError++,u[h].loadError++,this.log("Removing level "+h+" with key error ("+e.error+")"),this.hls.removeLevel(h))}var v=e.frag;if(this.hls.levels.length<d)r.resolved=!0;else if(v&&v.type!==w){var g=v.decryptdata;g&&!l.matches(g)&&(r.resolved=!0)}}}r.resolved||this.switchLevel(e,a)}},r.switchLevel=function(e,t){if(void 0!==t&&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,e.details===k.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName))for(var r=We(e.mimeType),i=this.hls.levels,a=i.length;a--;)i[a][e.sourceBufferName+"Codec"]===r&&(this.log("Removing level "+a+" for "+e.details+' ("'+r+'" not supported)'),this.hls.removeLevel(a))},t}(N);function Ct(e){var t={action:St,flags:bt};return e&&(t.resolved=!0),t}var xt={length:0,start:function(){return 0},end:function(){return 0}},wt=function(){function e(){}return e.isBuffered=function(t,r){if(t)for(var i=e.getBuffered(t),a=i.length;a--;)if(r>=i.start(a)&&r<=i.end(a))return!0;return!1},e.bufferedRanges=function(t){if(t){var r=e.getBuffered(t);return e.timeRangesToArray(r)}return[]},e.timeRangesToArray=function(e){for(var t=[],r=0;r<e.length;r++)t.push({start:e.start(r),end:e.end(r)});return t},e.bufferInfo=function(t,r,i){if(t){var a=e.bufferedRanges(t);if(a.length)return e.bufferedInfo(a,r,i)}return{len:0,start:r,end:r,bufferedIndex:-1}},e.bufferedInfo=function(e,t,r){t=Math.max(0,t),e.length>1&&e.sort(function(e,t){return e.start-t.start||t.end-e.end});var i=-1,a=[];if(r)for(var n=0;n<e.length;n++){t>=e[n].start&&t<=e[n].end&&(i=n);var s=a.length;if(s){var o=a[s-1].end;e[n].start-o<r?e[n].end>o&&(a[s-1].end=e[n].end):a.push(e[n])}else a.push(e[n])}else a=e;for(var l,u=0,d=t,h=t,f=0;f<a.length;f++){var c=a[f].start,v=a[f].end;if(-1===i&&t>=c&&t<=v&&(i=f),t+r>=c&&t<v)d=c,u=(h=v)-t;else if(t+r<c){l=c;break}}return{len:u,start:d||0,end:h||0,nextStart:l,buffered:e,bufferedIndex:i}},e.getBuffered=function(e){try{return e.buffered||xt}catch(e){return W.log("failed to get media.buffered",e),xt}},e}(),Pt=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Ot="HlsJsTrackRemovedError",Mt=function(e){function t(t){var r;return(r=e.call(this,t)||this).name=Ot,r}return o(t,e),t}(c(Error)),Ft=function(e){function t(t,r){var i,a;return(i=e.call(this,"buffer-controller",t.logger)||this).hls=void 0,i.fragmentTracker=void 0,i.details=null,i._objectUrl=null,i.operationQueue=null,i.bufferCodecEventsTotal=0,i.media=null,i.mediaSource=null,i.lastMpegAudioChunk=null,i.blockedAudioAppend=null,i.lastVideoAppendEnd=0,i.appendSource=void 0,i.transferData=void 0,i.overrides=void 0,i.appendErrors={audio:0,video:0,audiovideo:0},i.tracks={},i.sourceBuffers=[[null,null],[null,null]],i._onEndStreaming=function(e){var t;i.hls&&"open"===(null==(t=i.mediaSource)?void 0:t.readyState)&&i.hls.pauseBuffering()},i._onStartStreaming=function(e){i.hls&&i.hls.resumeBuffering()},i._onMediaSourceOpen=function(e){var t=i,r=t.media,a=t.mediaSource;e&&i.log("Media source opened"),r&&a&&(a.removeEventListener("sourceopen",i._onMediaSourceOpen),r.removeEventListener("emptied",i._onMediaEmptied),i.updateDuration(),i.hls.trigger(D.MEDIA_ATTACHED,{media:r,mediaSource:a}),null!==i.mediaSource&&i.checkPendingTracks())},i._onMediaSourceClose=function(){i.log("Media source closed")},i._onMediaSourceEnded=function(){i.log("Media source ended")},i._onMediaEmptied=function(){var e=i,t=e.mediaSrc,r=e._objectUrl;t!==r&&i.error("Media element src was set while attaching MediaSource ("+r+" > "+t+")")},i.hls=t,i.fragmentTracker=r,i.appendSource=(a=z(t.config.preferManagedMediaSource),"undefined"!=typeof self&&a===self.ManagedMediaSource),i.initTracks(),i.registerListeners(),i}o(t,e);var r=t.prototype;return r.hasSourceTypes=function(){return Object.keys(this.tracks).length>0},r.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null},r.registerListeners=function(){var e=this.hls;e.on(D.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(D.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(D.MANIFEST_LOADING,this.onManifestLoading,this),e.on(D.MANIFEST_PARSED,this.onManifestParsed,this),e.on(D.BUFFER_RESET,this.onBufferReset,this),e.on(D.BUFFER_APPENDING,this.onBufferAppending,this),e.on(D.BUFFER_CODECS,this.onBufferCodecs,this),e.on(D.BUFFER_EOS,this.onBufferEos,this),e.on(D.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(D.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(D.FRAG_PARSED,this.onFragParsed,this),e.on(D.FRAG_CHANGED,this.onFragChanged,this),e.on(D.ERROR,this.onError,this)},r.unregisterListeners=function(){var e=this.hls;e.off(D.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(D.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(D.MANIFEST_LOADING,this.onManifestLoading,this),e.off(D.MANIFEST_PARSED,this.onManifestParsed,this),e.off(D.BUFFER_RESET,this.onBufferReset,this),e.off(D.BUFFER_APPENDING,this.onBufferAppending,this),e.off(D.BUFFER_CODECS,this.onBufferCodecs,this),e.off(D.BUFFER_EOS,this.onBufferEos,this),e.off(D.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(D.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(D.FRAG_PARSED,this.onFragParsed,this),e.off(D.FRAG_CHANGED,this.onFragChanged,this),e.off(D.ERROR,this.onError,this)},r.transferMedia=function(){var e=this,t=this.media,r=this.mediaSource;if(!t)return null;var i={};if(this.operationQueue){var a=this.isUpdating();a||this.operationQueue.removeBlockers();var s=this.isQueued();(a||s)&&this.warn("Transfering MediaSource with"+(s?" operations in queue":"")+(a?" updating SourceBuffer(s)":"")+" "+this.operationQueue),this.operationQueue.destroy()}var o=this.transferData;return!this.sourceBufferCount&&o&&o.mediaSource===r?n(i,o.tracks):this.sourceBuffers.forEach(function(t){var r=t[0];r&&(i[r]=n({},e.tracks[r]),e.removeBuffer(r)),t[0]=t[1]=null}),{media:t,mediaSource:r,tracks:i}},r.initTracks=function(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0},r.onManifestLoading=function(){this.bufferCodecEventsTotal=0,this.details=null},r.onManifestParsed=function(e,t){var r,i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsTotal=i,this.log(i+" bufferCodec event(s) expected."),null!=(r=this.transferData)&&r.mediaSource&&this.sourceBufferCount&&i&&this.bufferCreated()},r.onMediaAttaching=function(e,t){var r=this.media=t.media;this.transferData=this.overrides=void 0;var i=z(this.appendSource);if(i){var a=!!t.mediaSource;(a||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var n=this.mediaSource=t.mediaSource||new i;if(this.assignMediaSource(n),a)this._objectUrl=r.src,this.attachTransferred();else{var s=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{r.removeAttribute("src");var o=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||o&&n instanceof o,Nt(r),function(e,t){var r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(r,s),r.load()}catch(e){r.src=s}else r.src=s}r.addEventListener("emptied",this._onMediaEmptied)}},r.assignMediaSource=function(e){var t,r;this.log(((null==(t=this.transferData)?void 0:t.mediaSource)===e?"transferred":"created")+" media source: "+(null==(r=e.constructor)?void 0:r.name)),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))},r.attachTransferred=function(){var e=this,t=this.media,r=this.transferData;if(r&&t){var i=this.tracks,a=r.tracks,n=a?Object.keys(a):null,s=n?n.length:0,o=function(){Promise.resolve().then(function(){e.media&&e.mediaSourceOpenOrEnded&&e._onMediaSourceOpen()})};if(a&&n&&s){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log("attachTransferred: (bufferCodecEventsTotal "+this.bufferCodecEventsTotal+")\nrequired tracks: "+it(i,function(e,t){return"initSegment"===e?void 0:t})+";\ntransfer tracks: "+it(a,function(e,t){return"initSegment"===e?void 0:t})+"}"),!function(e,t){var r=Object.keys(e),i=Object.keys(t),a=r.length,n=i.length;return!a||!n||a===n&&!r.some(function(e){return-1===i.indexOf(e)})}(a,i)){r.mediaSource=null,r.tracks=void 0;var l=t.currentTime,u=this.details,d=Math.max(l,(null==u?void 0:u.fragments[0].start)||0);return d-l>1?void this.log("attachTransferred: waiting for playback to reach new tracks start time "+l+" -> "+d):(this.warn('attachTransferred: resetting MediaSource for incompatible tracks ("'+Object.keys(a)+'"->"'+Object.keys(i)+'") start time: '+d+" currentTime: "+l),this.onMediaDetaching(D.MEDIA_DETACHING,{}),this.onMediaAttaching(D.MEDIA_ATTACHING,r),void(t.currentTime=d))}this.transferData=void 0,n.forEach(function(t){var r=t,i=a[r];if(i){var n=i.buffer;if(n){var s=e.fragmentTracker,o=i.id;if(s.hasFragments(o)||s.hasParts(o)){var l=wt.getBuffered(n);s.detectEvictedFragments(r,l,o,null,!0)}var u=Bt(r),d=[r,n];e.sourceBuffers[u]=d,n.updating&&e.operationQueue&&e.operationQueue.prependBlocker(r),e.trackSourceBuffer(r,i)}}}),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}},r.onMediaDetaching=function(e,t){var r=this,i=!!t.transferMedia;this.transferData=this.overrides=void 0;var a=this.media,n=this.mediaSource,s=this._objectUrl;if(n){if(this.log("media source "+(i?"transferring":"detaching")),i)this.sourceBuffers.forEach(function(e){var t=e[0];t&&r.removeBuffer(t)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var o="open"===n.readyState;try{for(var l=n.sourceBuffers,u=l.length;u--;)o&&l[u].abort(),n.removeSourceBuffer(l[u]);o&&n.endOfStream()}catch(e){this.warn("onMediaDetaching: "+e.message+" while calling endOfStream")}}this.sourceBufferCount&&this.onBufferReset()}n.removeEventListener("sourceopen",this._onMediaSourceOpen),n.removeEventListener("sourceended",this._onMediaSourceEnded),n.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(n.removeEventListener("startstreaming",this._onStartStreaming),n.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}a&&(a.removeEventListener("emptied",this._onMediaEmptied),i||(s&&self.URL.revokeObjectURL(s),this.mediaSrc===s?(a.removeAttribute("src"),this.appendSource&&Nt(a),a.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null)},r.onBufferReset=function(){var e=this;this.sourceBuffers.forEach(function(t){var r=t[0];r&&e.resetBuffer(r)}),this.initTracks()},r.resetBuffer=function(e){var t,r=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),r)try{var i;null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(r)}catch(t){this.warn("onBufferReset "+e,t)}delete this.tracks[e]},r.removeBuffer=function(e){this.removeBufferListeners(e),this.sourceBuffers[Bt(e)]=[null,null];var t=this.tracks[e];t&&(t.buffer=void 0)},r.resetQueue=function(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new lt(this.tracks)},r.onBufferCodecs=function(e,t){var r,i=this,a=this.tracks,n=Object.keys(t);this.log('BUFFER_CODECS: "'+n+'" (current SB count '+this.sourceBufferCount+")");var s="audiovideo"in t&&(a.audio||a.video)||a.audiovideo&&("audio"in t||"video"in t),o=!s&&this.sourceBufferCount&&this.media&&n.some(function(e){return!a[e]});s||o?this.warn('Unsupported transition between "'+Object.keys(a)+'" and "'+n+'" SourceBuffers'):(n.forEach(function(e){var r,n,s=t[e],o=s.id,l=s.codec,u=s.levelCodec,d=s.container,h=s.metadata,f=s.supplemental,c=a[e],v=null==(r=i.transferData)||null==(r=r.tracks)?void 0:r[e],g=null!=v&&v.buffer?v:c,m=(null==g?void 0:g.pendingCodec)||(null==g?void 0:g.codec),p=null==g?void 0:g.levelCodec;c||(c=a[e]={buffer:void 0,listeners:[],codec:l,supplemental:f,container:d,levelCodec:u,metadata:h,id:o});var y=He(m,p),E=null==y?void 0:y.replace(Pt,"$1"),T=He(l,u),S=null==(n=T)?void 0:n.replace(Pt,"$1");T&&y&&E!==S&&("audio"===e.slice(0,5)&&(T=Ve(T,i.appendSource)),i.log("switching codec "+m+" to "+T),T!==(c.pendingCodec||c.codec)&&(c.pendingCodec=T),c.container=d,i.appendChangeType(e,d,T))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&"main"===(null==(r=t.audio)?void 0:r.id)&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))},r.appendChangeType=function(e,t,r){var i=this,a=t+";codecs="+r,n={label:"change-type="+a,execute:function(){var n=i.tracks[e];if(n){var s=n.buffer;null!=s&&s.changeType&&(i.log("changing "+e+" sourceBuffer type to "+a),s.changeType(a),n.codec=r,n.container=t)}i.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){i.warn("Failed to change "+e+" SourceBuffer type",t)}};this.append(n,e,this.isPending(this.tracks[e]))},r.blockAudio=function(e){var t,r=this,i=e.start,a=i+.05*e.duration;if(!0!==(null==(t=this.fragmentTracker.getAppendedFrag(i,w))?void 0:t.gap)){var n={label:"block-audio",execute:function(){var e,t=r.tracks.video;(r.lastVideoAppendEnd>a||null!=t&&t.buffer&&wt.isBuffered(t.buffer,a)||!0===(null==(e=r.fragmentTracker.getAppendedFrag(a,w))?void 0:e.gap))&&(r.blockedAudioAppend=null,r.shiftAndExecuteNext("audio"))},onStart:function(){},onComplete:function(){},onError:function(e){r.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:n,frag:e},this.append(n,"audio",!0)}},r.unblockAudio=function(){var e=this.blockedAudioAppend,t=this.operationQueue;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))},r.onBufferAppending=function(e,t){var r=this,i=this.tracks,a=t.data,n=t.type,s=t.parent,o=t.frag,l=t.part,u=t.chunkMeta,d=t.offset,h=u.buffering[n],f=o.sn,c=o.cc,v=self.performance.now();h.start=v;var g=o.stats.buffering,m=l?l.stats.buffering:null;0===g.start&&(g.start=v),m&&0===m.start&&(m.start=v);var p=i.audio,y=!1;"audio"===n&&"audio/mpeg"===(null==p?void 0:p.container)&&(y=!this.lastMpegAudioChunk||1===u.id||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);var E=i.video,T=null==E?void 0:E.buffer;if(T&&"initSegment"!==f){var S=l||o,R=this.blockedAudioAppend;if("audio"!==n||"main"===s||this.blockedAudioAppend||E.ending||E.ended){if("video"===n){var A=S.end;if(R){var _=R.frag.start;(A>_||A<this.lastVideoAppendEnd||wt.isBuffered(T,_))&&this.unblockAudio()}this.lastVideoAppendEnd=A}}else{var I=S.start+.05*S.duration,C=T.buffered,x=this.currentOp("video");C.length||x?!x&&!wt.isBuffered(T,I)&&this.lastVideoAppendEnd<I&&this.blockAudio(S):this.blockAudio(S)}}var P=(l||o).start,O={label:"append-"+n,execute:function(){var e;h.executeStart=self.performance.now();var t=null==(e=r.tracks[n])?void 0:e.buffer;t&&(y?r.updateTimestampOffset(t,P,.1,n,f,c):void 0!==d&&L(d)&&r.updateTimestampOffset(t,d,1e-6,n,f,c)),r.appendExecutor(a,n)},onStart:function(){},onComplete:function(){var e=self.performance.now();h.executeEnd=h.end=e,0===g.first&&(g.first=e),m&&0===m.first&&(m.first=e);var t={};r.sourceBuffers.forEach(function(e){var r=e[0],i=e[1];r&&(t[r]=wt.getBuffered(i))}),r.appendErrors[n]=0,"audio"===n||"video"===n?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(D.BUFFER_APPENDED,{type:n,frag:o,part:l,chunkMeta:u,parent:o.type,timeRanges:t})},onError:function(e){var t,i={type:b.MEDIA_ERROR,parent:o.type,details:k.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:o,part:l,chunkMeta:u,error:e,err:e,fatal:!1},a=null==(t=r.media)?void 0:t.error;if(e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e)i.details=k.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&r.mediaSourceOpenOrEnded&&!a)i.errorAction=Ct(!0);else if(e.name===Ot&&0===r.sourceBufferCount)i.errorAction=Ct(!0);else{var s=++r.appendErrors[n];r.warn("Failed "+s+"/"+r.hls.config.appendErrorMaxRetry+' times to append segment in "'+n+'" sourceBuffer ('+(a||"no media error")+")"),(s>=r.hls.config.appendErrorMaxRetry||a)&&(i.fatal=!0)}r.hls.trigger(D.ERROR,i)}};this.log('queuing "'+n+'" append sn: '+f+(l?" p: "+l.index:"")+" of "+(o.type===w?"level":"track")+" "+o.level+" cc: "+c),this.append(O,n,this.isPending(this.tracks[n]))},r.getFlushOp=function(e,t,r){var i=this;return this.log('queuing "'+e+'" remove '+t+"-"+r),{label:"remove",execute:function(){i.removeExecutor(e,t,r)},onStart:function(){},onComplete:function(){i.hls.trigger(D.BUFFER_FLUSHED,{type:e})},onError:function(a){i.warn("Failed to remove "+t+"-"+r+' from "'+e+'" SourceBuffer',a)}}},r.onBufferFlushing=function(e,t){var r=this,i=t.type,a=t.startOffset,n=t.endOffset;i?this.append(this.getFlushOp(i,a,n),i):this.sourceBuffers.forEach(function(e){var t=e[0];t&&r.append(r.getFlushOp(t,a,n),t)})},r.onFragParsed=function(e,t){var r=this,i=t.frag,a=t.part,n=[],s=a?a.elementaryStreams:i.elementaryStreams;s[re]?n.push("audiovideo"):(s[ee]&&n.push("audio"),s[te]&&n.push("video")),0===n.length&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers(function(){var e=self.performance.now();i.stats.buffering.end=e,a&&(a.stats.buffering.end=e);var t=a?a.stats:i.stats;r.hls.trigger(D.FRAG_BUFFERED,{frag:i,part:a,stats:t,id:i.type})},n).catch(function(e){r.warn("Fragment buffered callback "+e),r.stepOperationQueue(r.sourceBufferTypes)})},r.onFragChanged=function(e,t){this.trimBuffers()},r.onBufferEos=function(e,t){var r,i=this;this.sourceBuffers.forEach(function(e){var r=e[0];if(r){var a=i.tracks[r];t.type&&t.type!==r||(a.ending=!0,a.ended||(a.ended=!0,i.log(r+" buffer reached EOS")))}});var a=!1!==(null==(r=this.overrides)?void 0:r.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some(function(e){var t,r=e[0];return r&&!(null!=(t=i.tracks[r])&&t.ended)})?a?(this.log("Queueing EOS"),this.blockUntilOpen(function(){i.tracksEnded();var e=i.mediaSource;e&&"open"===e.readyState?(i.log("Calling mediaSource.endOfStream()"),e.endOfStream(),i.hls.trigger(D.BUFFERED_TO_END,void 0)):e&&i.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState)})):(this.tracksEnded(),this.hls.trigger(D.BUFFERED_TO_END,void 0)):"video"===t.type&&this.unblockAudio()},r.tracksEnded=function(){var e=this;this.sourceBuffers.forEach(function(t){var r=t[0];if(null!==r){var i=e.tracks[r];i&&(i.ending=!1)}})},r.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.updateDuration())},r.updateDuration=function(){var e=this;this.blockUntilOpen(function(){var t=e.getDurationAndRange();t&&e.updateMediaSource(t)})},r.onError=function(e,t){if(t.details===k.BUFFER_APPEND_ERROR&&t.frag){var r,i=null==(r=t.errorAction)?void 0:r.nextAutoLevel;L(i)&&i!==t.frag.level&&this.resetAppendErrors()}},r.resetAppendErrors=function(){this.appendErrors={audio:0,video:0,audiovideo:0}},r.trimBuffers=function(){var e=this.hls,t=this.details,r=this.media;if(r&&null!==t&&this.sourceBufferCount){var i=e.config,a=r.currentTime,n=t.levelTargetDuration,s=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(L(s)&&s>=0){var o=Math.max(s,n),l=Math.floor(a/n)*n-o;this.flushBackBuffer(a,n,l)}var u=i.frontBufferFlushThreshold;if(L(u)&&u>0){var d=Math.max(i.maxBufferLength,u),h=Math.max(d,n),f=Math.floor(a/n)*n+h;this.flushFrontBuffer(a,n,f)}}},r.flushBackBuffer=function(e,t,r){var i=this;this.sourceBuffers.forEach(function(e){var t=e[0],a=e[1];if(a){var n=wt.getBuffered(a);if(n.length>0&&r>n.start(0)){var s;i.hls.trigger(D.BACK_BUFFER_REACHED,{bufferEnd:r});var o=i.tracks[t];if(null!=(s=i.details)&&s.live)i.hls.trigger(D.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(null!=o&&o.ended)return void i.log("Cannot flush "+t+" back buffer while SourceBuffer is in ended state");i.hls.trigger(D.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:t})}}})},r.flushFrontBuffer=function(e,t,r){var i=this;this.sourceBuffers.forEach(function(t){var a=t[0],n=t[1];if(n){var s=wt.getBuffered(n),o=s.length;if(o<2)return;var l=s.start(o-1),u=s.end(o-1);if(r>l||e>=l&&e<=u)return;i.hls.trigger(D.BUFFER_FLUSHING,{startOffset:l,endOffset:1/0,type:a})}})},r.getDurationAndRange=function(){var e,t=this.details,r=this.mediaSource;if(!t||!this.media||"open"!==(null==r?void 0:r.readyState))return null;var i=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&r.setLiveSeekableRange){var a=Math.max(0,t.fragmentStart);return{duration:1/0,start:a,end:Math.max(a,i)}}return{duration:1/0}}var n=null==(e=this.overrides)?void 0:e.duration;if(n)return L(n)?{duration:n}:null;var s=this.media.duration;return i>(L(r.duration)?r.duration:0)&&i>s||!L(s)?{duration:i}:null},r.updateMediaSource=function(e){var t=e.duration,r=e.start,i=e.end,a=this.mediaSource;this.media&&a&&"open"===a.readyState&&(a.duration!==t&&(L(t)&&this.log("Updating MediaSource duration to "+t.toFixed(3)),a.duration=t),void 0!==r&&void 0!==i&&(this.log("MediaSource duration is set to "+a.duration+". Setting seekable range to "+r+"-"+i+"."),a.setLiveSeekableRange(r,i)))},r.checkPendingTracks=function(){var e=this.bufferCodecEventsTotal,t=this.pendingTrackCount,r=this.tracks;if(this.log("checkPendingTracks (pending: "+t+" codec events expected: "+e+") "+it(r)),this.tracksReady){var i,a=null==(i=this.transferData)?void 0:i.tracks;a&&Object.keys(a).length?this.attachTransferred():this.createSourceBuffers()}},r.bufferCreated=function(){var e=this;if(this.sourceBufferCount){var t={};this.sourceBuffers.forEach(function(r){var i=r[0],a=r[1];if(i){var n=e.tracks[i];t[i]={buffer:a,container:n.container,codec:n.codec,supplemental:n.supplemental,levelCodec:n.levelCodec,id:n.id,metadata:n.metadata}}}),this.hls.trigger(D.BUFFER_CREATED,{tracks:t}),this.log("SourceBuffers created. Running queue: "+this.operationQueue),this.sourceBuffers.forEach(function(t){var r=t[0];e.executeNext(r)})}else{var r=new Error("could not create source buffer for media codec(s)");this.hls.trigger(D.ERROR,{type:b.MEDIA_ERROR,details:k.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:r,reason:r.message})}},r.createSourceBuffers=function(){var e=this.tracks,t=this.sourceBuffers,r=this.mediaSource;if(!r)throw new Error("createSourceBuffers called when mediaSource was null");for(var i in e){var a=i,n=e[a];if(this.isPending(n)){var s=this.getTrackCodec(n,a),o=n.container+";codecs="+s;n.codec=s,this.log("creating sourceBuffer("+o+")"+(this.currentOp(a)?" Queued":"")+" "+it(n));try{var l=r.addSourceBuffer(o),u=Bt(a),d=[a,l];t[u]=d,n.buffer=l}catch(e){var h;return this.error("error while trying to add sourceBuffer: "+e.message),this.shiftAndExecuteNext(a),null==(h=this.operationQueue)||h.removeBlockers(),delete this.tracks[a],void this.hls.trigger(D.ERROR,{type:b.MEDIA_ERROR,details:k.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:a,mimeType:o,parent:n.id})}this.trackSourceBuffer(a,n)}}this.bufferCreated()},r.getTrackCodec=function(e,t){var r=e.supplemental,i=e.codec;r&&("video"===t||"audiovideo"===t)&&Oe(r,"video")&&(i=function(e,t){var r=[];if(e)for(var i=e.split(","),a=0;a<i.length;a++)Pe(i[a],"video")||r.push(i[a]);return t&&r.push(t),r.join(",")}(i,r));var a=He(i,e.levelCodec);return a?"audio"===t.slice(0,5)?Ve(a,this.appendSource):a:""},r.trackSourceBuffer=function(e,t){var r=this,i=t.buffer;if(i){var a=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:a,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",function(e,t){var i=t.removedRanges;null!=i&&i.length&&r.hls.trigger(D.BUFFER_FLUSHED,{type:e})})}},r.onSBUpdateStart=function(e){var t=this.currentOp(e);t&&t.onStart()},r.onSBUpdateEnd=function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var r=this.currentOp(e);r&&(r.onComplete(),this.shiftAndExecuteNext(e))}else this.resetBuffer(e)},r.onSBUpdateError=function(e,t){var r,i=new Error(e+" SourceBuffer error. MediaSource readyState: "+(null==(r=this.mediaSource)?void 0:r.readyState));this.error(""+i,t),this.hls.trigger(D.ERROR,{type:b.MEDIA_ERROR,details:k.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});var a=this.currentOp(e);a&&a.onError(i)},r.updateTimestampOffset=function(e,t,r,i,a,n){var s=t-e.timestampOffset;Math.abs(s)>=r&&(this.log("Updating "+i+" SourceBuffer timestampOffset to "+t+" (sn: "+a+" cc: "+n+")"),e.timestampOffset=t)},r.removeExecutor=function(e,t,r){var i=this.media,a=this.mediaSource,n=this.tracks[e],s=null==n?void 0:n.buffer;if(!i||!a||!s)return this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void this.shiftAndExecuteNext(e);var o=L(i.duration)?i.duration:1/0,l=L(a.duration)?a.duration:1/0,u=Math.max(0,t),d=Math.min(r,o,l);d>u&&(!n.ending||n.ended)?(n.ended=!1,this.log("Removing ["+u+","+d+"] from the "+e+" SourceBuffer"),s.remove(u,d)):this.shiftAndExecuteNext(e)},r.appendExecutor=function(e,t){var r=this.tracks[t],i=null==r?void 0:r.buffer;if(!i)throw new Mt("Attempting to append to the "+t+" SourceBuffer, but it does not exist");r.ending=!1,r.ended=!1,i.appendBuffer(e)},r.blockUntilOpen=function(e){var t=this;if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(function(e){t.warn("SourceBuffer blocked callback "+e),t.stepOperationQueue(t.sourceBufferTypes)});else try{e()}catch(e){this.warn("Callback run without blocking "+this.operationQueue+" "+e)}},r.isUpdating=function(){return this.sourceBuffers.some(function(e){var t=e[0],r=e[1];return t&&r.updating})},r.isQueued=function(){var e=this;return this.sourceBuffers.some(function(t){var r=t[0];return r&&!!e.currentOp(r)})},r.isPending=function(e){return!!e&&!e.buffer},r.blockBuffers=function(e,t){var r=this;if(void 0===t&&(t=this.sourceBufferTypes),!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);var i=this.operationQueue,a=t.map(function(e){return r.appendBlocker(e)});return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(a).then(function(t){i===r.operationQueue&&(e(),r.stepOperationQueue(r.sourceBufferTypes))})},r.stepOperationQueue=function(e){var t=this;e.forEach(function(e){var r,i=null==(r=t.tracks[e])?void 0:r.buffer;i&&!i.updating&&t.shiftAndExecuteNext(e)})},r.append=function(e,t,r){this.operationQueue&&this.operationQueue.append(e,t,r)},r.appendBlocker=function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)},r.currentOp=function(e){return this.operationQueue?this.operationQueue.current(e):null},r.executeNext=function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)},r.shiftAndExecuteNext=function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)},r.addBufferListener=function(e,t,r){var i=this.tracks[e];if(i){var a=i.buffer;if(a){var n=r.bind(this,e);i.listeners.push({event:t,listener:n}),a.addEventListener(t,n)}}},r.removeBufferListeners=function(e){var t=this.tracks[e];if(t){var r=t.buffer;r&&(t.listeners.forEach(function(e){r.removeEventListener(e.event,e.listener)}),t.listeners.length=0)}},i(t,[{key:"mediaSourceOpenOrEnded",get:function(){var e,t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}},{key:"sourceBufferTracks",get:function(){var e=this;return Object.keys(this.tracks).reduce(function(t,r){var i=e.tracks[r];return t[r]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},t},{})}},{key:"bufferedToEnd",get:function(){var e=this;return this.sourceBufferCount>0&&!this.sourceBuffers.some(function(t){var r=t[0];if(r){var i=e.tracks[r];if(i)return!i.ended||i.ending}return!1})}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"mediaSrc",get:function(){var e,t,r=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==r?void 0:r.src}},{key:"pendingTrackCount",get:function(){var e=this;return Object.keys(this.tracks).reduce(function(t,r){return t+(e.isPending(e.tracks[r])?1:0)},0)}},{key:"sourceBufferCount",get:function(){return this.sourceBuffers.reduce(function(e,t){return e+(t[0]?1:0)},0)}},{key:"sourceBufferTypes",get:function(){return this.sourceBuffers.map(function(e){return e[0]}).filter(function(e){return!!e})}}])}(N);function Nt(e){var t=e.querySelectorAll("source");[].slice.call(t).forEach(function(t){e.removeChild(t)})}function Bt(e){return"audio"===e?1:0}var Ut=function(){function e(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()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},t.registerListeners=function(){var e=this.hls;e.on(D.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(D.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(D.MANIFEST_PARSED,this.onManifestParsed,this),e.on(D.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(D.BUFFER_CODECS,this.onBufferCodecs,this),e.on(D.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListener=function(){var e=this.hls;e.off(D.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(D.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(D.MANIFEST_PARSED,this.onManifestParsed,this),e.off(D.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(D.BUFFER_CODECS,this.onBufferCodecs,this),e.off(D.MEDIA_DETACHING,this.onMediaDetaching,this)},t.onFpsDropLevelCapping=function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},t.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},t.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onLevelsUpdated=function(e,t){this.timer&&L(this.autoLevelCapping)&&this.detectPlayerSize()},t.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onMediaDetaching=function(){this.stopCapping(),this.media=null},t.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&t.logger.log("Setting autoLevelCapping to "+r+": "+e[r].height+"p@"+e[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),t.autoLevelCapping=r,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},t.getMaxLevel=function(t){var r=this,i=this.hls.levels;if(!i.length)return-1;var a=i.filter(function(e,i){return r.isLevelAllowed(e)&&i<=t});return this.clientRect=null,e.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)},t.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},t.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},t.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},t.isLevelAllowed=function(e){return!this.restrictedLevels.some(function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height})},e.getMaxLevelByMediaSize=function(e,t,r){if(null==e||!e.length)return-1;for(var i=function(e,t){return!t||e.width!==t.width||e.height!==t.height},a=e.length-1,n=Math.max(t,r),s=0;s<e.length;s+=1){var o=e[s];if((o.width>=n||o.height>=n)&&i(o,e[s+1])){a=s;break}}return a},i(e,[{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 e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}}])}(),Gt=/^(\d+)x(\d+)$/,Vt=/(.+?)=(".*?"|.*?)(?:,|$)/g,Ht=function(){function e(t,r){"string"==typeof t&&(t=e.parseAttrList(t,r)),n(this,t)}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},t.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},t.enumeratedString=function(e){return this[e]},t.enumeratedStringList=function(e,t){var r=this[e];return(r?r.split(/[ ,]+/):[]).reduce(function(e,t){return e[t.toLowerCase()]=!0,e},t)},t.bool=function(e){return"YES"===this[e]},t.decimalResolution=function(e){var t=Gt.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e,t){var r,i={};for(Vt.lastIndex=0;null!==(r=Vt.exec(e));){var a=r[1].trim(),n=r[2],s=0===n.indexOf('"')&&n.lastIndexOf('"')===n.length-1,o=!1;if(s)n=n.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":o=!0}if(t&&(s||o));else if(!o&&!s)switch(a){case"CLOSED-CAPTIONS":if("NONE"===n)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":W.warn(e+": attribute "+a+" is missing quotes")}i[a]=n}return i},i(e,[{key:"clientAttrs",get:function(){return Object.keys(this).filter(function(e){return"X-"===e.substring(0,2)})}}])}();function Kt(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function Yt(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var jt=function(){return i(function(e,t,r){var i;if(void 0===r&&(r=0),this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==t?void 0:t.tagAnchor)||null,this.tagOrder=null!=(i=null==t?void 0:t.tagOrder)?i:r,t){var a=t.attr;for(var s in a)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==a[s]){W.warn('DATERANGE tag attribute: "'+s+'" does not match for tags with ID: "'+e.ID+'"'),this._badValueForSameId=s;break}e=n(new Ht({}),a,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){var o=(null==t?void 0:t.endDate)||new Date(this.attr["END-DATE"]);L(o.getTime())&&(this._endDate=o)}},[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}},{key:"startTime",get:function(){var e=this.tagAnchor;return null===e||null===e.programDateTime?(W.warn('Expected tagAnchor Fragment with PDT set for DateRange "'+this.id+'": '+e),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var e=this._endDate||this._dateAtEnd;if(e)return e;var t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(L(e))return e}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:"isInterstitial",get:function(){return"com.apple.hls.interstitial"===this.class}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&L(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}])}(),Wt=function(){function e(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.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!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.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}var t=e.prototype;return t.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1},t.hasKey=function(e){return this.encryptedFragments.some(function(t){var r=t.decryptdata;return r||(t.setKeyFormat(e.keyFormat),r=t.decryptdata),!!r&&e.matches(r)})},i(e,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&L(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){return this.fragments.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var e=this.partList;if(e){var t=this.lastPartIndex;if(-1!==t){for(var r=e.length;r--;)if(e[r].index>t)return e[r].index;return t}}return 0}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age&&this.misses<3){var e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}])}();function qt(e,t){return e.length===t.length&&!e.some(function(e,r){return e!==t[r]})}function Xt(e,t){return!e&&!t||!(!e||!t)&&qt(e,t)}var zt=0,Qt=1;function $t(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function Zt(e){switch(e){case"AES-128":case"AES-256":return zt;case"AES-256-CTR":return Qt;default:throw new Error("invalid full segment method "+e)}}var Jt={},er=function(){function e(e,t,r,i,a,n){void 0===i&&(i=[1]),void 0===a&&(a=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=r,this.keyFormatVersions=i,this.iv=a,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&!$t(e),null!=n&&n.startsWith("0x")&&(this.keyId=new Uint8Array(Z(n)))}e.clearKeyUriToKeyIdMap=function(){Jt={}},e.setKeyIdForUri=function(e,t){Jt[e]=t};var t=e.prototype;return t.matches=function(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&qt(e.keyFormatVersions,this.keyFormatVersions)&&Xt(e.iv,this.iv)&&Xt(e.keyId,this.keyId)},t.isSupported=function(){if(this.method){if($t(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method}return!1},t.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if($t(this.method)){var r=this.iv;return r||("number"!=typeof t&&(W.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0),r=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}(t)),new e(this.method,this.uri,"identity",this.keyFormatVersions,r)}return this},e}(),tr=/#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,rr=/#EXT-X-MEDIA:(.*)/g,ir=/^#EXT(?:INF|-X-TARGETDURATION):/m,ar=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),nr=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|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("|")),sr=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}},e.resolve=function(e,t){return S.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.isMediaPlaylist=function(e){return ir.test(e)},e.parseMasterPlaylist=function(t,r){var i,a={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:!1},n=[];if(tr.lastIndex=0,!t.startsWith("#EXTM3U"))return a.playlistParsingError=new Error("no EXTM3U delimiter"),a;for(;null!=(i=tr.exec(t));)if(i[1]){var s,o=new Ht(i[1],a),l=i[2],u={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:e.resolve(l,r)},d=o.decimalResolution("RESOLUTION");d&&(u.width=d.width,u.height=d.height),hr(o.CODECS,u);var h=o["SUPPLEMENTAL-CODECS"];h&&(u.supplemental={},hr(h,u.supplemental)),null!=(s=u.unknownCodecs)&&s.length||n.push(u),a.levels.push(u)}else if(i[3]){var f=i[3],c=i[4];switch(f){case"SESSION-DATA":var v=new Ht(c,a),g=v["DATA-ID"];g&&(null===a.sessionData&&(a.sessionData={}),a.sessionData[g]=v);break;case"SESSION-KEY":var m=ur(c,r,a);m.encrypted&&m.isSupported()?(null===a.sessionKeys&&(a.sessionKeys=[]),a.sessionKeys.push(m)):W.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+c+'"');break;case"DEFINE":break;case"CONTENT-STEERING":var p=new Ht(c,a);a.contentSteering={uri:e.resolve(p["SERVER-URI"],r),pathwayId:p["PATHWAY-ID"]||"."};break;case"START":a.startTimeOffset=dr(c)}}var y=n.length>0&&n.length<a.levels.length;return a.levels=y?n:a.levels,0===a.levels.length&&(a.playlistParsingError=new Error("no levels found in manifest")),a},e.parseMasterPlaylistMedia=function(t,r,i){var a,n={},s=i.levels,o={AUDIO:s.map(function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}}),SUBTITLES:s.map(function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}}),"CLOSED-CAPTIONS":[]},l=0;for(rr.lastIndex=0;null!==(a=rr.exec(t));){var u=new Ht(a[1],i),d=u.TYPE;if(d){var h=o[d],f=n[d]||[];n[d]=f;var c=u.LANGUAGE,v=u["ASSOC-LANGUAGE"],g=u.CHANNELS,m=u.CHARACTERISTICS,p=u["INSTREAM-ID"],y={attrs:u,bitrate:0,id:l++,groupId:u["GROUP-ID"]||"",name:u.NAME||c||"",type:d,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:c,url:u.URI?e.resolve(u.URI,r):""};if(v&&(y.assocLang=v),g&&(y.channels=g),m&&(y.characteristics=m),p&&(y.instreamId=p),null!=h&&h.length){var E=e.findGroup(h,y.groupId)||h[0];fr(y,E,"audioCodec"),fr(y,E,"textCodec")}f.push(y)}}return n},e.parseLevelPlaylist=function(e,t,r,i,a,s){var o,l,u,d,h,f={url:t},c=new Wt(t),v=c.fragments,g=[],m=null,p=0,y=0,E=0,T=0,S=0,R=null,A=new ne(i,f),b=-1,k=!1,D=null;if(ar.lastIndex=0,c.m3u8=e,c.hasVariableRefs=!1,"#EXTM3U"!==(null==(o=ar.exec(e))?void 0:o[0]))return c.playlistParsingError=new Error("Missing format identifier #EXTM3U"),c;for(;null!==(l=ar.exec(e));){k&&(k=!1,(A=new ne(i,f)).playlistOffset=E,A.setStart(E),A.sn=p,A.cc=T,S&&(A.bitrate=S),A.level=r,m&&(A.initSegment=m,m.rawProgramDateTime&&(A.rawProgramDateTime=m.rawProgramDateTime,m.rawProgramDateTime=null),D&&(A.setByteRange(D),D=null)));var _=l[1];if(_){A.duration=parseFloat(_);var I=(" "+l[2]).slice(1);A.title=I||null,A.tagList.push(I?["INF",_,I]:["INF",_])}else if(l[3]){if(L(A.duration)){A.playlistOffset=E,A.setStart(E),d&&gr(A,d,c),A.sn=p,A.level=r,A.cc=T,v.push(A);var C=(" "+l[3]).slice(1);A.relurl=C,cr(A,R,g),R=A,E+=A.duration,p++,y=0,k=!0}}else{if(!(l=l[0].match(nr))){W.warn("No matches on slow regex match for level playlist!");continue}for(u=1;u<l.length&&void 0===l[u];u++);var x=(" "+l[u]).slice(1),w=(" "+l[u+1]).slice(1),P=l[u+2]?(" "+l[u+2]).slice(1):null;switch(x){case"BYTERANGE":R?A.setByteRange(w,R):A.setByteRange(w);break;case"PROGRAM-DATE-TIME":A.rawProgramDateTime=w,A.tagList.push(["PROGRAM-DATE-TIME",w]),-1===b&&(b=v.length);break;case"PLAYLIST-TYPE":c.type&&mr(c,x,l),c.type=w.toUpperCase();break;case"MEDIA-SEQUENCE":0!==c.startSN?mr(c,x,l):v.length>0&&pr(c,x,l),p=c.startSN=parseInt(w);break;case"SKIP":c.skippedSegments&&mr(c,x,l);var O=new Ht(w,c),M=O.decimalInteger("SKIPPED-SEGMENTS");if(L(M)){c.skippedSegments+=M;for(var F=M;F--;)v.push(null);p+=M}var N=O.enumeratedString("RECENTLY-REMOVED-DATERANGES");N&&(c.recentlyRemovedDateranges=(c.recentlyRemovedDateranges||[]).concat(N.split("\t")));break;case"TARGETDURATION":0!==c.targetduration&&mr(c,x,l),c.targetduration=Math.max(parseInt(w),1);break;case"VERSION":null!==c.version&&mr(c,x,l),c.version=parseInt(w);break;case"INDEPENDENT-SEGMENTS":case"DEFINE":break;case"ENDLIST":c.live||mr(c,x,l),c.live=!1;break;case"#":(w||P)&&A.tagList.push(P?[w,P]:[w]);break;case"DISCONTINUITY":T++,A.tagList.push(["DIS"]);break;case"GAP":A.gap=!0,A.tagList.push([x]);break;case"BITRATE":A.tagList.push([x,w]),S=1e3*parseInt(w),L(S)?A.bitrate=S:S=0;break;case"DATERANGE":var B=new Ht(w,c),U=new jt(B,c.dateRanges[B.ID],c.dateRangeTagCount);c.dateRangeTagCount++,U.isValid||c.skippedSegments?c.dateRanges[U.id]=U:W.warn('Ignoring invalid DATERANGE tag: "'+w+'"'),A.tagList.push(["EXT-X-DATERANGE",w]);break;case"DISCONTINUITY-SEQUENCE":0!==c.startCC?mr(c,x,l):v.length>0&&pr(c,x,l),c.startCC=T=parseInt(w);break;case"KEY":var G=ur(w,t,c);if(G.isSupported()){if("NONE"===G.method){d=void 0;break}d||(d={});var V=d[G.keyFormat];null!=V&&V.matches(G)||(V&&(d=n({},d)),d[G.keyFormat]=G)}else W.warn('[Keys] Ignoring unsupported EXT-X-KEY tag: "'+w+'" (light build)');break;case"START":c.startTimeOffset=dr(w);break;case"MAP":var H=new Ht(w,c);if(A.duration){var K=new ne(i,f);vr(K,H,r,d),m=K,A.initSegment=m,m.rawProgramDateTime&&!A.rawProgramDateTime&&(A.rawProgramDateTime=m.rawProgramDateTime)}else{var Y=A.byteRangeEndOffset;if(Y){var j=A.byteRangeStartOffset;D=Y-j+"@"+j}else D=null;vr(A,H,r,d),m=A,k=!0}m.cc=T;break;case"SERVER-CONTROL":h&&mr(c,x,l),h=new Ht(w),c.canBlockReload=h.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=h.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&h.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=h.optionalFloat("PART-HOLD-BACK",0),c.holdBack=h.optionalFloat("HOLD-BACK",0);break;case"PART-INF":c.partTarget&&mr(c,x,l);var q=new Ht(w);c.partTarget=q.decimalFloatingPoint("PART-TARGET");break;case"PART":var X=c.partList;X||(X=c.partList=[]);var z=y>0?X[X.length-1]:void 0,Q=y++,$=new Ht(w,c),Z=new se($,A,f,Q,z);X.push(Z),A.duration+=Z.duration;break;case"PRELOAD-HINT":var J=new Ht(w,c);c.preloadHint=J;break;case"RENDITION-REPORT":var ee=new Ht(w,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(ee);break;default:W.warn("line parsed but not handled: "+l)}}}R&&!R.relurl?(v.pop(),E-=R.duration,c.partList&&(c.fragmentHint=R)):c.partList&&(cr(A,R,g),A.cc=T,c.fragmentHint=A,d&&gr(A,d,c)),c.targetduration||(c.playlistParsingError=new Error("Missing Target Duration"));var te=v.length,re=v[0],ie=v[te-1];if((E+=c.skippedSegments*c.targetduration)>0&&te&&ie){c.averagetargetduration=E/te;var ae=ie.sn;c.endSN="initSegment"!==ae?ae:0,c.live||(ie.endList=!0),b>0&&(function(e,t){for(var r=e[t],i=t;i--;){var a=e[i];if(!a)return;a.programDateTime=r.programDateTime-1e3*a.duration,r=a}}(v,b),re&&g.unshift(re))}return c.fragmentHint&&(E+=c.fragmentHint.duration),c.totalduration=E,g.length&&c.dateRangeTagCount&&re&&or(g,c),c.endCC=T,c},e}();function or(e,t){var r=e.length;if(!r){if(!t.hasProgramDateTime)return;var i=t.fragments[t.fragments.length-1];e.push(i),r++}for(var a=e[r-1],n=t.live?1/0:t.totalduration,s=Object.keys(t.dateRanges),o=s.length;o--;){var l=t.dateRanges[s[o]],u=l.startDate.getTime();l.tagAnchor=a.ref;for(var d=r;d--;){var h;if((null==(h=e[d])?void 0:h.sn)<t.startSN)break;var f=lr(t,u,e,d,n);if(-1!==f){l.tagAnchor=t.fragments[f].ref;break}}}}function lr(e,t,r,i,a){var n=r[i];if(n){var s,o=n.programDateTime;if((t>=o||0===i)&&t<=o+1e3*(((null==(s=r[i+1])?void 0:s.start)||a)-n.start)){var l=r[i].sn-e.startSN;if(l<0)return-1;var u=e.fragments;if(u.length>r.length)for(var d=(r[i+1]||u[u.length-1]).sn-e.startSN;d>l;d--){var h=u[d].programDateTime;if(t>=h&&t<h+1e3*u[d].duration)return d}return l}}return-1}function ur(e,t,r){var i,a,n=new Ht(e,r),s=null!=(i=n.METHOD)?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),u=n.KEYFORMATVERSIONS,d=null!=(a=n.KEYFORMAT)?a:"identity";o&&n.IV&&!l&&W.error("Invalid IV: "+n.IV);var h=o?sr.resolve(o,t):"",f=(u||"1").split("/").map(Number).filter(Number.isFinite);return new er(s,h,d,f,l,n.KEYID)}function dr(e){var t=new Ht(e).decimalFloatingPoint("TIME-OFFSET");return L(t)?t:null}function hr(e,t){var r=(e||"").split(/[ ,]+/).filter(function(e){return e});["video","audio","text"].forEach(function(e){var i=r.filter(function(t){return Pe(t,e)});i.length&&(t[e+"Codec"]=i.map(function(e){return e.split("/")[0]}).join(","),r=r.filter(function(e){return-1===i.indexOf(e)}))}),t.unknownCodecs=r}function fr(e,t,r){var i=t[r];i&&(e[r]=i)}function cr(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function vr(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function gr(e,t,r){e.levelkeys=t;var i=r.encryptedFragments;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some(function(e){return t[e].isCommonEncryption})||i.push(e)}function mr(e,t,r){e.playlistParsingError=new Error("#EXT-X-"+t+" must not appear more than once ("+r[0]+")")}function pr(e,t,r){e.playlistParsingError=new Error("#EXT-X-"+t+" must appear before the first Media Segment ("+r[0]+")")}function yr(e,t){var r=t.startPTS;if(L(r)){var i,a=0;t.sn>e.sn?(a=r-e.start,i=e):(a=e.start-r,i=t),i.duration!==a&&i.setDuration(a)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration):t.setStart(Math.max(e.start-t.duration,0))}function Er(e,t,r,i,a,n,s){i-r<=0&&(s.warn("Fragment should have a positive duration",t),i=r+t.duration,n=a+t.duration);var o=r,l=i,u=t.startPTS,d=t.endPTS;if(L(u)){var h=Math.abs(u-r);e&&h>e.totalduration?s.warn("media timestamps and playlist times differ by "+h+"s for level "+t.level+" "+e.url):L(t.deltaPTS)?t.deltaPTS=Math.max(h,t.deltaPTS):t.deltaPTS=h,o=Math.max(r,u),r=Math.min(r,u),a=void 0!==t.startDTS?Math.min(a,t.startDTS):a,l=Math.min(i,d),i=Math.max(i,d),n=void 0!==t.endDTS?Math.max(n,t.endDTS):n}var f=r-t.start;0!==t.start&&t.setStart(r),t.setDuration(i-t.start),t.startPTS=r,t.maxStartPTS=o,t.startDTS=a,t.endPTS=i,t.minEndPTS=l,t.endDTS=n;var c,v=t.sn;if(!e||v<e.startSN||v>e.endSN)return 0;var g=v-e.startSN,m=e.fragments;for(m[g]=t,c=g;c>0;c--)yr(m[c],m[c-1]);for(c=g;c<m.length-1;c++)yr(m[c],m[c+1]);return e.fragmentHint&&yr(m[m.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,f}function Tr(e,t,r){if(e!==t){for(var i,a=null,s=e.fragments,o=s.length-1;o>=0;o--){var l=s[o].initSegment;if(l){a=l;break}}e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,r){for(var i=t.skippedSegments,a=Math.max(e.startSN,t.startSN)-t.startSN,n=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,s=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,u=a;u<=n;u++){var d=l[s+u],h=o[u];if(i&&!h&&d&&(h=t.fragments[u]=d),d&&h){r(d,h,u,o);var f=d.relurl,c=h.relurl;if(f&&_r(f,c))return void(t.playlistParsingError=Sr("media sequence mismatch "+h.sn+":",e,t,0,h));if(d.cc!==h.cc)return void(t.playlistParsingError=Sr("discontinuity sequence mismatch ("+d.cc+"!="+h.cc+")",e,t,0,h))}}}(e,t,function(e,r,n,s){if((!t.startCC||t.skippedSegments)&&r.cc!==e.cc){for(var o=e.cc-r.cc,l=n;l<s.length;l++)s[l].cc+=o;t.endCC=s[s.length-1].cc}L(e.startPTS)&&L(e.endPTS)&&(r.setStart(r.startPTS=e.startPTS),r.startDTS=e.startDTS,r.maxStartPTS=e.maxStartPTS,r.endPTS=e.endPTS,r.endDTS=e.endDTS,r.minEndPTS=e.minEndPTS,r.setDuration(e.endPTS-e.startPTS),r.duration&&(i=r),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(r.elementaryStreams=e.elementaryStreams),r.loader=e.loader,e.hasStats&&(r.stats=e.stats),e.initSegment&&(r.initSegment=e.initSegment,a=e.initSegment)});var u=t.fragments,d=t.fragmentHint?u.concat(t.fragmentHint):u;if(a&&d.forEach(function(e){var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=a)?void 0:t.relurl)||(e.initSegment=a)}),t.skippedSegments){if(t.deltaUpdateFailed=u.some(function(e){return!e}),t.deltaUpdateFailed){r.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var h=t.skippedSegments;h--;)u.shift();t.startSN=u[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=function(e,t,r){var i=t.dateRanges,a=t.recentlyRemovedDateranges,s=n({},e);a&&a.forEach(function(e){delete s[e]});var o=Object.keys(s).length;return o?(Object.keys(i).forEach(function(e){var t=s[e],a=new jt(i[e].attr,t);a.isValid?(s[e]=a,t||(a.tagOrder+=o)):r.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+it(i[e].attr)+'"')}),s):i}(e.dateRanges,t,r));var f=e.fragments.filter(function(e){return e.rawProgramDateTime});if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(var c=1;c<d.length;c++)null===d[c].programDateTime&&cr(d[c],d[c-1],f);or(f,t)}t.endCC=u[u.length-1].cc}if(!t.startCC){var v,g=Ar(e,t.startSN-1);t.startCC=null!=(v=null==g?void 0:g.cc)?v:u[0].cc}!function(e,t,r){if(e&&t)for(var i=0,a=0,n=e.length;a<=n;a++){var s=e[a],o=t[a+i];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):i--}}(e.partList,t.partList,function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),i?Er(t,i,i.startPTS,i.endPTS,i.startDTS,i.endDTS,r):Lr(e,t),u.length&&(t.totalduration=t.edge-u[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var m=t.advancedDateTime;if(t.advanced&&m){var p=t.edge;t.driftStart||(t.driftStartTime=m,t.driftStart=p),t.driftEndTime=m,t.driftEnd=p}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}}function Sr(e,t,r,i,a){return new Error(e+" "+a.url+"\nPlaylist starting @"+t.startSN+"\n"+t.m3u8+"\n\nPlaylist starting @"+r.startSN+"\n"+r.m3u8)}function Lr(e,t,r){void 0===r&&(r=!0);var i=t.startSN+t.skippedSegments-e.startSN,a=e.fragments,n=i>=0,s=0;if(n&&i<a.length)s=a[i].start;else if(n&&t.startSN===e.endSN+1)s=e.fragmentEnd;else if(n&&r)s=e.fragmentStart+i*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;s=e.fragmentStart}!function(e,t){if(t){for(var r=e.fragments,i=e.skippedSegments;i<r.length;i++)r[i].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}(t,s)}function Rr(e,t){void 0===t&&(t=1/0);var r=1e3*e.targetduration;if(e.updated){var i=e.fragments;if(i.length&&4*r>t){var a=1e3*i[i.length-1].duration;a<r&&(r=a)}}else r/=2;return Math.round(r)}function Ar(e,t,r){if(!e)return null;var i=e.fragments[t-e.startSN];return i||((i=e.fragmentHint)&&i.sn===t?i:t<e.startSN&&r&&r.sn===t?r:null)}function br(e,t,r){return e?kr(e.partList,t,r):null}function kr(e,t,r){if(e)for(var i=e.length;i--;){var a=e[i];if(a.index===r&&a.fragment.sn===t)return a}return null}function Dr(e){e.forEach(function(e,t){var r;null==(r=e.details)||r.fragments.forEach(function(e){e.level=t,e.initSegment&&(e.initSegment.level=t)})})}function _r(e,t){return!(e===t||!t)&&Ir(e)!==Ir(t)}function Ir(e){return e.replace(/\?[^?]*$/,"")}var Cr=function(e){function t(t){var r;return(r=e.call(this,"content-steering",t.logger)||this).hls=void 0,r.loader=null,r.uri=null,r.pathwayId=".",r._pathwayPriority=null,r.timeToLoad=300,r.reloadTimer=-1,r.updated=0,r.started=!1,r.enabled=!0,r.levels=null,r.audioTracks=null,r.subtitleTracks=null,r.penalizedPathways={},r.hls=t,r.registerListeners(),r}o(t,e);var r=t.prototype;return r.registerListeners=function(){var e=this.hls;e.on(D.MANIFEST_LOADING,this.onManifestLoading,this),e.on(D.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(D.MANIFEST_PARSED,this.onManifestParsed,this),e.on(D.ERROR,this.onError,this)},r.unregisterListeners=function(){var e=this.hls;e&&(e.off(D.MANIFEST_LOADING,this.onManifestLoading,this),e.off(D.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(D.MANIFEST_PARSED,this.onManifestParsed,this),e.off(D.ERROR,this.onError,this))},r.pathways=function(){return(this.levels||[]).reduce(function(e,t){return-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e},[])},r.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}},r.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},r.clearTimeout=function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},r.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},r.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter(function(t){return t!==e}))},r.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},r.onManifestLoaded=function(e,t){var r=t.contentSteering;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},r.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},r.onError=function(e,t){var r=t.errorAction;if((null==r?void 0:r.action)===Lt&&r.flags===kt){var i=this.levels,a=this._pathwayPriority,n=this.pathwayId;if(t.context){var s=t.context,o=s.groupId,l=s.pathwayId,u=s.type;o&&i?n=this.getPathwayForGroupId(o,u,n):l&&(n=l)}n in this.penalizedPathways||(this.penalizedPathways[n]=performance.now()),!a&&i&&(a=this.pathways()),a&&a.length>1&&(this.updatePathwayPriority(a),r.resolved=this.pathwayId!==n),t.details!==k.BUFFER_APPEND_ERROR||t.fatal?r.resolved||this.warn("Could not resolve "+t.details+' ("'+t.error.message+'") with content-steering for Pathway: '+n+" levels: "+(i?i.length:i)+" priorities: "+it(a)+" penalized: "+it(this.penalizedPathways)):r.resolved=!0}},r.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t},r.getLevelsForPathway=function(e){return null===this.levels?[]:this.levels.filter(function(t){return e===t.pathwayId})},r.updatePathwayPriority=function(e){var t;this._pathwayPriority=e;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(function(e){i-r[e]>3e5&&delete r[e]});for(var a=0;a<e.length;a++){var n=e[a];if(!(n in r)){if(n===this.pathwayId)return;var s=this.hls.nextLoadLevel,o=this.hls.levels[s];if((t=this.getLevelsForPathway(n)).length>0){this.log('Setting Pathway to "'+n+'"'),this.pathwayId=n,Dr(t),this.hls.trigger(D.LEVELS_UPDATED,{levels:t});var l=this.hls.levels[s];o&&l&&this.levels&&(l.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==o.bitrate&&this.log("Unstable Pathways change from bitrate "+o.bitrate+" to "+l.bitrate),this.hls.nextLoadLevel=s);break}}}},r.getPathwayForGroupId=function(e,t,r){for(var i=this.getLevelsForPathway(r).concat(this.levels||[]),a=0;a<i.length;a++)if(t===C&&i[a].hasAudioGroup(e)||t===x&&i[a].hasSubtitleGroup(e))return i[a].pathwayId;return r},r.clonePathways=function(e){var t=this,r=this.levels;if(r){var i={},a={};e.forEach(function(e){var n=e.ID,s=e["BASE-ID"],o=e["URI-REPLACEMENT"];if(!r.some(function(e){return e.pathwayId===n})){var l=t.getLevelsForPathway(s).map(function(e){var t=new Ht(e.attrs);t["PATHWAY-ID"]=n;var r=t.AUDIO&&t.AUDIO+"_clone_"+n,s=t.SUBTITLES&&t.SUBTITLES+"_clone_"+n;r&&(i[t.AUDIO]=r,t.AUDIO=r),s&&(a[t.SUBTITLES]=s,t.SUBTITLES=s);var l=wr(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o),u=new et({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:l,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var d=1;d<e.audioGroups.length;d++)u.addGroupId("audio",e.audioGroups[d]+"_clone_"+n);if(e.subtitleGroups)for(var h=1;h<e.subtitleGroups.length;h++)u.addGroupId("text",e.subtitleGroups[h]+"_clone_"+n);return u});r.push.apply(r,l),xr(t.audioTracks,i,o,n),xr(t.subtitleTracks,a,o,n)}})}},r.loadSteeringManifest=function(e){var t,r=this,i=this.hls.config,a=i.loader;this.loader&&this.loader.destroy(),this.loader=new a(i);try{t=new self.URL(e)}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if("data:"!==t.protocol){var n=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+n)}var s={responseType:"json",url:t.href},o=i.steeringManifestLoadPolicy.default,l=o.errorRetry||o.timeoutRetry||{},u={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},d={onSuccess:function(e,i,a,n){r.log('Loaded steering manifest: "'+t+'"');var s=e.data;if(1===(null==s?void 0:s.VERSION)){r.updated=performance.now(),r.timeToLoad=s.TTL;var o=s["RELOAD-URI"],l=s["PATHWAY-CLONES"],u=s["PATHWAY-PRIORITY"];if(o)try{r.uri=new self.URL(o,t).href}catch(e){return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+o)}r.scheduleRefresh(r.uri||a.url),l&&r.clonePathways(l);var d={steeringManifest:s,url:t.toString()};r.hls.trigger(D.STEERING_MANIFEST_LOADED,d),u&&r.updatePathwayPriority(u)}else r.log("Steering VERSION "+s.VERSION+" not supported!")},onError:function(e,t,i,a){if(r.log("Error loading steering manifest: "+e.code+" "+e.text+" ("+t.url+")"),r.stopLoad(),410===e.code)return r.enabled=!1,void r.log("Steering manifest "+t.url+" no longer available");var n=1e3*r.timeToLoad;if(429!==e.code)r.scheduleRefresh(r.uri||t.url,n);else{var s=r.loader;if("function"==typeof(null==s?void 0:s.getResponseHeader)){var o=s.getResponseHeader("Retry-After");o&&(n=1e3*parseFloat(o))}r.log("Steering manifest "+t.url+" rate limited")}},onTimeout:function(e,t,i){r.log("Timeout loading steering manifest ("+t.url+")"),r.scheduleRefresh(r.uri||t.url)}};this.log("Requesting steering manifest: "+t),this.loader.load(s,u,d)},r.scheduleRefresh=function(e,t){var r=this;void 0===t&&(t=1e3*this.timeToLoad),this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var t,i=null==(t=r.hls)?void 0:t.media;!i||i.ended?r.scheduleRefresh(e,1e3*r.timeToLoad):r.loadSteeringManifest(e)},t)},i(t,[{key:"pathwayPriority",get:function(){return this._pathwayPriority},set:function(e){this.updatePathwayPriority(e)}}])}(N);function xr(e,t,r,i){e&&Object.keys(t).forEach(function(a){var s=e.filter(function(e){return e.groupId===a}).map(function(e){var s=n({},e);return s.details=void 0,s.attrs=new Ht(s.attrs),s.url=s.attrs.URI=wr(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),s.groupId=s.attrs["GROUP-ID"]=t[a],s.attrs["PATHWAY-ID"]=i,s});e.push.apply(e,s)})}function wr(e,t,r,i){var a,n=i.HOST,s=i.PARAMS,o=i[r];t&&(a=null==o?void 0:o[t])&&(e=a);var l=new self.URL(e);return n&&!a&&(l.host=n),s&&Object.keys(s).sort().forEach(function(e){e&&l.searchParams.set(e,s[e])}),l.href}var Pr=function(){function e(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()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.registerListeners=function(){this.hls.on(D.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(D.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListeners=function(){this.hls.off(D.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(D.MEDIA_DETACHING,this.onMediaDetaching,this)},t.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},t.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i,i&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},t.onMediaDetaching=function(){this.media=null},t.checkFPS=function(e,t,r){var i=performance.now();if(t){if(this.lastTime){var a=i-this.lastTime,n=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,o=1e3*n/a,l=this.hls;if(l.trigger(D.FPS_DROP,{currentDropped:n,currentDecoded:s,totalDroppedFrames:r}),o>0&&n>l.config.fpsDroppedMonitoringThreshold*s){var u=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=u)&&(u-=1,l.trigger(D.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},t.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},e}(),Or=function(){function e(){this.chunks=[],this.dataLength=0}var t=e.prototype;return t.push=function(e){this.chunks.push(e),this.dataLength+=e.length},t.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var r=new Uint8Array(t),i=0,a=0;a<e.length;a++){var n=e[a];r.set(n,i),i+=n.length}return r}(t,r),this.reset(),e):new Uint8Array(0)},t.reset=function(){this.chunks.length=0,this.dataLength=0},e}();function Mr(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function Fr(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function Nr(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]}function Br(e,t){for(var r=t,i=0;Fr(e,t);)i+=10,i+=Nr(e,t+6),Mr(e,t+10)&&(i+=10),t+=i;if(i>0)return e.subarray(r,r+i)}function Ur(e,t){return 255===e[t]&&240==(246&e[t+1])}function Gr(e,t){return 1&e[t+1]?7:9}function Vr(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Hr(e,t){return t+1<e.length&&Ur(e,t)}function Kr(e,t){if(Hr(e,t)){var r=Gr(e,t);if(t+r>=e.length)return!1;var i=Vr(e,t);if(i<=r)return!1;var a=t+i;return a===e.length||Hr(e,a)}return!1}function Yr(e,t,r,i,a){if(!e.samplerate){var s=function(e,t,r,i){var a=t[r+2],n=a>>2&15;if(!(n>12)){var s=1+(a>>6&3),o=t[r+3]>>6&3|(1&a)<<2,l="mp4a.40."+s,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][n],d=n;5!==s&&29!==s||(d-=3);var h=[s<<3|(14&d)>>1,(1&d)<<7|o<<3];return W.log("manifest codec:"+i+", parsed codec:"+l+", channels:"+o+", rate:"+u+" (ADTS object type:"+s+" sampling index:"+n+")"),{config:h,samplerate:u,channelCount:o,codec:l,parsedCodec:l,manifestCodec:i}}var f=new Error("invalid ADTS sampling index:"+n);e.emit(D.ERROR,D.ERROR,{type:b.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,fatal:!0,error:f,reason:f.message})}(t,r,i,a);if(!s)return;n(e,s)}}function jr(e){return 9216e4/e}function Wr(e,t,r,i,a){var n,s=i+a*jr(e.samplerate),o=function(e,t){var r=Gr(e,t);if(t+r<=e.length){var i=Vr(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);if(o){var l=o.frameLength,u=o.headerLength,d=u+l,h=Math.max(0,r+d-t.length);h?(n=new Uint8Array(d-u)).set(t.subarray(r+u,t.length),0):n=t.subarray(r+u,r+d);var f={unit:n,pts:s};return h||e.samples.push(f),{sample:f,length:d,missing:h}}var c=t.length-r;return(n=new Uint8Array(c)).set(t.subarray(r,t.length),0),{sample:{unit:n,pts:s},length:c,missing:-1}}function qr(e,t){return Fr(e,t)&&Nr(e,t+6)+10<=e.length-t}function Xr(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=1/0),function(e,t,r,i){var a=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e),n=1;"BYTES_PER_ELEMENT"in i&&(n=i.BYTES_PER_ELEMENT);var s,o=(s=e)&&s.buffer instanceof ArrayBuffer&&void 0!==s.byteLength&&void 0!==s.byteOffset?e.byteOffset:0,l=(o+e.byteLength)/n,u=(o+t)/n,d=Math.floor(Math.max(0,Math.min(u,l))),h=Math.floor(Math.min(d+Math.max(r,0),l));return new i(a,d,h-d)}(e,t,r,Uint8Array)}function zr(e){var t={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var r=e.data.subarray(1).indexOf(0);if(-1!==r){var i=Q(Xr(e.data,1,r)),a=e.data[2+r],n=e.data.subarray(3+r).indexOf(0);if(-1!==n){var s,o=Q(Xr(e.data,3+r,n));return s="--\x3e"===i?Q(Xr(e.data,4+r+n)):function(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}(e.data.subarray(4+r+n)),t.mimeType=i,t.pictureType=a,t.description=o,t.data=s,t}}}else console.log("Ignore frame with unrecognized character encoding")}function Qr(e){return"PRIV"===e.type?function(e){if(!(e.size<2)){var t=Q(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=Q(e.data.subarray(t),!0);t+=r.length+1;var i=Q(e.data.subarray(t));return{key:e.type,info:r,data:i}}var a=Q(e.data);return{key:e.type,info:"",data:a}}(e):"APIC"===e.type?zr(e):function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=Q(e.data.subarray(t),!0);t+=r.length+1;var i=Q(e.data.subarray(t));return{key:e.type,info:r,data:i}}var a=Q(e.data.subarray(1));return{key:e.type,info:"",data:a}}}(e)}function $r(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=Nr(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}function Zr(e){for(var t=0,r=[];Fr(e,t);){var i=Nr(e,t+6);e[t+5]>>6&1&&(t+=10);for(var a=(t+=10)+i;t+10<a;){var n=$r(e.subarray(t)),s=Qr(n);s&&r.push(s),t+=n.size+10}Mr(e,t)&&(t+=10)}return r}function Jr(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function ei(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}}function ti(e){for(var t=Zr(e),r=0;r<t.length;r++){var i=t[r];if(Jr(i))return ei(i)}}var ri=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function ii(e,t){return void 0===e&&(e=""),void 0===t&&(t=9e4),{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var ai=function(){function e(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},t.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},t.canParse=function(e,t){return!1},t.appendFrame=function(e,t,r){},t.demux=function(e,t){this.cachedData&&(e=be(this.cachedData,e),this.cachedData=null);var r,i=Br(e,0),a=i?i.length:0,n=this._audioTrack,s=this._id3Track,o=i?ti(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&L(o))&&(this.basePTS=ni(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ri.audioId3,duration:Number.POSITIVE_INFINITY});a<l;){if(this.canParse(e,a)){var u=this.appendFrame(n,e,a);u?(this.frameIndex++,this.lastPTS=u.sample.pts,r=a+=u.length):a=l}else qr(e,a)?(i=Br(e,a),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ri.audioId3,duration:Number.POSITIVE_INFINITY}),r=a+=i.length):a++;if(a===l&&r!==l){var d=e.slice(r);this.cachedData?this.cachedData=be(this.cachedData,d):this.cachedData=d}}return{audioTrack:n,videoTrack:ii(),id3Track:s,textTrack:ii()}},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},t.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:ii(),id3Track:this._id3Track,textTrack:ii()}},t.destroy=function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0},e}(),ni=function(e,t,r){return L(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0)},si=null,oi=[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],li=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],ui=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],di=[0,1,1,4];function hi(e,t,r,i,a){if(!(r+24>t.length)){var n=fi(t,r);if(n&&r+n.frameLength<=t.length){var s=i+a*(9e4*n.samplesPerFrame/n.sampleRate),o={unit:t.subarray(r,r+n.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(o),{sample:o,length:n.frameLength,missing:0}}}}function fi(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,a=e[t+2]>>4&15,n=e[t+2]>>2&3;if(1!==r&&0!==a&&15!==a&&3!==n){var s=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*oi[14*(3===r?3-i:3===i?3:4)+a-1],u=li[3*(3===r?0:2===r?1:2)+n],d=3===o?1:2,h=ui[r][i],f=di[i],c=8*h*f,v=Math.floor(h*l/u+s)*f;if(null===si){var g=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);si=g?parseInt(g[1]):0}return!!si&&si<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:u,channelCount:d,frameLength:v,samplesPerFrame:c}}}function ci(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function vi(e,t){return t+1<e.length&&ci(e,t)}function gi(e,t){if(t+1<e.length&&ci(e,t)){var r=fi(e,t),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var a=t+i;return a===e.length||vi(e,a)}return!1}var mi=function(e){function t(t,r){var i;return(i=e.call(this)||this).observer=void 0,i.config=void 0,i.observer=t,i.config=r,i}o(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,i,a){e.prototype.resetInitSegment.call(this,t,r,i,a),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},t.probe=function(e,t){if(!e)return!1;var r=Br(e,0),i=(null==r?void 0:r.length)||0;if(gi(e,i))return!1;for(var a=e.length;i<a;i++)if(Kr(e,i))return t.log("ADTS sync word found !"),!0;return!1},r.canParse=function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&Ur(e,t)&&Vr(e,t)<=e.length-t}(e,t)},r.appendFrame=function(e,t,r){Yr(e,this.observer,t,r,e.manifestCodec);var i=Wr(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i},t}(ai),pi=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,i,a){e.prototype.resetInitSegment.call(this,t,r,i,a),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;var t=Br(e,0),r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==ti(t)&&function(e,t){var r=0,i=5;t+=i;for(var a=new Uint32Array(1),n=new Uint32Array(1),s=new Uint8Array(1);i>0;){s[0]=e[t];var o=Math.min(i,8),l=8-o;n[0]=4278190080>>>24+l<<l,a[0]=(s[0]&n[0])>>l,r=r?r<<o|a[0]:a[0],t+=1,i-=o}return r}(e,r)<=16)return!1;for(var i=e.length;r<i;r++)if(gi(e,r))return W.log("MPEG Audio sync word found !"),!0;return!1},r.canParse=function(e,t){return function(e,t){return ci(e,t)&&4<=e.length-t}(e,t)},r.appendFrame=function(e,t,r){if(null!==this.basePTS)return hi(e,t,r,this.basePTS,this.frameIndex)},t}(ai),yi=function(){function e(e,t,r){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=r}return e.prototype.decrypt=function(e,t){switch(this.aesMode){case zt:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Qt:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error("[AESCrypto] invalid aes mode "+this.aesMode)}},e}(),Ei=function(){function e(){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 t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},t.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],a=r[1],n=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],d=o[2],h=o[3],f=new Uint32Array(256),c=0,v=0,g=0;for(g=0;g<256;g++)f[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var m=v^v<<1^v<<2^v<<3^v<<4;m=m>>>8^255&m^99,e[c]=m,t[m]=c;var p=f[c],y=f[p],E=f[y],T=257*f[m]^16843008*m;i[c]=T<<24|T>>>8,a[c]=T<<16|T>>>16,n[c]=T<<8|T>>>24,s[c]=T,T=16843009*E^65537*y^257*p^16843008*c,l[m]=T<<24|T>>>8,u[m]=T<<16|T>>>16,d[m]=T<<8|T>>>24,h[m]=T,c?(c=p^f[f[f[E^p]]],v^=f[f[v]]):c=v=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var a=this.keySize=t.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var n,s,o,l,u=this.ksRows=4*(a+6+1),d=this.keySchedule=new Uint32Array(u),h=this.invKeySchedule=new Uint32Array(u),f=this.sBox,c=this.rcon,v=this.invSubMix,g=v[0],m=v[1],p=v[2],y=v[3];for(n=0;n<u;n++)n<a?o=d[n]=t[n]:(l=o,n%a===0?(l=f[(l=l<<8|l>>>24)>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l],l^=c[n/a|0]<<24):a>6&&n%a===4&&(l=f[l>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l]),d[n]=o=(d[n-a]^l)>>>0);for(s=0;s<u;s++)n=u-s,l=3&s?d[n]:d[n-4],h[s]=s<4||n<=4?l:g[f[l>>>24]]^m[f[l>>>16&255]]^p[f[l>>>8&255]]^y[f[255&l]],h[s]=h[s]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,r){for(var i,a,n,s,o,l,u,d,h,f,c,v,g,m,p=this.keySize+6,y=this.invKeySchedule,E=this.invSBox,T=this.invSubMix,S=T[0],L=T[1],R=T[2],A=T[3],b=this.uint8ArrayToUint32Array_(r),k=b[0],D=b[1],_=b[2],I=b[3],C=new Int32Array(e),x=new Int32Array(C.length),w=this.networkToHostOrderSwap;t<C.length;){for(h=w(C[t]),f=w(C[t+1]),c=w(C[t+2]),v=w(C[t+3]),o=h^y[0],l=v^y[1],u=c^y[2],d=f^y[3],g=4,m=1;m<p;m++)i=S[o>>>24]^L[l>>16&255]^R[u>>8&255]^A[255&d]^y[g],a=S[l>>>24]^L[u>>16&255]^R[d>>8&255]^A[255&o]^y[g+1],n=S[u>>>24]^L[d>>16&255]^R[o>>8&255]^A[255&l]^y[g+2],s=S[d>>>24]^L[o>>16&255]^R[l>>8&255]^A[255&u]^y[g+3],o=i,l=a,u=n,d=s,g+=4;i=E[o>>>24]<<24^E[l>>16&255]<<16^E[u>>8&255]<<8^E[255&d]^y[g],a=E[l>>>24]<<24^E[u>>16&255]<<16^E[d>>8&255]<<8^E[255&o]^y[g+1],n=E[u>>>24]<<24^E[d>>16&255]<<16^E[o>>8&255]<<8^E[255&l]^y[g+2],s=E[d>>>24]<<24^E[o>>16&255]<<16^E[l>>8&255]<<8^E[255&u]^y[g+3],x[t]=w(i^k),x[t+1]=w(s^D),x[t+2]=w(n^_),x[t+3]=w(a^I),k=h,D=f,_=c,I=v,t+=4}return x.buffer},e}(),Ti=function(){function e(e,t,r){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=r}return e.prototype.expandKey=function(){var e=function(e){switch(e){case zt:return"AES-CBC";case Qt:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode "+e)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])},e}(),Si=function(){function e(e,t){var r=(void 0===t?{}:t).removePKCS7Padding,i=void 0===r||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.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}var t=e.prototype;return t.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},t.isSync=function(){return this.useSoftware},t.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r,i,a,n=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(r=n).byteLength,(a=i&&new DataView(r.buffer).getUint8(i-1))?r.slice(0,i-a):r):n},t.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},t.decrypt=function(e,t,r,i){var a=this;return this.useSoftware?new Promise(function(n,s){var o=ArrayBuffer.isView(e)?e:new Uint8Array(e);a.softwareDecrypt(o,t,r,i);var l=a.flush();l?n(l.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r,i)},t.softwareDecrypt=function(e,t,r,i){var a=this.currentIV,n=this.currentResult,s=this.remainderData;if(i!==zt||16!==t.byteLength)return W.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),s&&(e=be(s,e),this.remainderData=null);var o=this.getValidChunk(e);if(!o.length)return null;a&&(r=a);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Ei),l.expandKey(t);var u=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=o.slice(-16).buffer,u||null},t.webCryptoDecrypt=function(e,t,r,i){var a=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r,i));this.key=t,this.fastAesKey=new Ti(this.subtle,t,i)}return this.fastAesKey.expandKey().then(function(t){return a.subtle?(a.logOnce("WebCrypto AES decrypt"),new yi(a.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(n){return W.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+n.name+": "+n.message),a.onWebCryptoError(e,t,r,i)})},t.onWebCryptoError=function(e,t,r,i){var a=this.enableSoftwareAES;if(a){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,i);var n=this.flush();if(n)return n.buffer}throw new Error("WebCrypto"+(a?" and softwareDecrypt":"")+": failed to decrypt data")},t.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=e.slice(0,r),this.remainderData=e.slice(r)),t},t.logOnce=function(e){this.logEnabled&&(W.log("[decrypter]: "+e),this.logEnabled=!1)},e}(),Li=/\/emsg[-/]ID3/i,Ri=function(){function e(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}var t=e.prototype;return t.resetTimeStamp=function(){},t.resetInitSegment=function(e,t,r,i){var a=this.videoTrack=ii("video",1),n=this.audioTrack=ii("audio",1),s=this.txtTrack=ii("text",1);if(this.id3Track=ii("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=ye(e);if(o.video){var l=o.video,u=l.id,d=l.timescale,h=l.codec,f=l.supplemental;a.id=u,a.timescale=s.timescale=d,a.codec=h,a.supplemental=f}if(o.audio){var c=o.audio,v=c.id,g=c.timescale,m=c.codec;n.id=v,n.timescale=g,n.codec=m}s.id=de.text,a.sampleDuration=0,a.duration=n.duration=i}},t.resetContiguity=function(){this.remainderData=null},e.probe=function(e){return function(e){for(var t=e.byteLength,r=0;r<t;){var i=ce(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}(e)},t.demux=function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=be(this.remainderData,e));var n=function(e){var t={valid:null,remainder:null},r=me(e,["moof"]);if(r.length<2)return t.remainder=e,t;var i=r[r.length-1];return t.valid=e.slice(0,i.byteOffset-8),t.remainder=e.slice(i.byteOffset-8),t}(r);this.remainderData=n.remainder,i.samples=n.valid||new Uint8Array}else i.samples=r;var s=this.extractID3Track(i,t);return a.samples=ke(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},t.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(t,this.timeOffset);return r.samples=ke(e,t),{videoTrack:t,audioTrack:ii(),id3Track:i,textTrack:ii()}},t.extractID3Track=function(e,t){var r=this,i=this.id3Track;if(e.samples.length){var a=me(e.samples,["emsg"]);a&&a.forEach(function(e){var a=function(e){var t=e[0],r="",i="",a=0,n=0,s=0,o=0,l=0,u=0;if(0===t){for(;"\0"!==he(e.subarray(u,u+1));)r+=he(e.subarray(u,u+1)),u+=1;for(r+=he(e.subarray(u,u+1)),u+=1;"\0"!==he(e.subarray(u,u+1));)i+=he(e.subarray(u,u+1)),u+=1;i+=he(e.subarray(u,u+1)),u+=1,a=ce(e,12),n=ce(e,16),o=ce(e,20),l=ce(e,24),u=28}else if(1===t){a=ce(e,u+=4);var d=ce(e,u+=4),h=ce(e,u+=4);for(u+=4,s=Math.pow(2,32)*d+h,R(s)||(s=Number.MAX_SAFE_INTEGER,W.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ce(e,u),l=ce(e,u+=4),u+=4;"\0"!==he(e.subarray(u,u+1));)r+=he(e.subarray(u,u+1)),u+=1;for(r+=he(e.subarray(u,u+1)),u+=1;"\0"!==he(e.subarray(u,u+1));)i+=he(e.subarray(u,u+1)),u+=1;i+=he(e.subarray(u,u+1)),u+=1}return{schemeIdUri:r,value:i,timeScale:a,presentationTime:s,presentationTimeDelta:n,eventDuration:o,id:l,payload:e.subarray(u,e.byteLength)}}(e);if(Li.test(a.schemeIdUri)){var n=Ai(a,t),s=4294967295===a.eventDuration?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;s<=.001&&(s=Number.POSITIVE_INFINITY);var o=a.payload;i.samples.push({data:o,len:o.byteLength,dts:n,pts:n,type:ri.emsg,duration:s})}else if(r.config.enableEmsgKLVMetadata&&a.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var l=Ai(a,t);i.samples.push({data:a.payload,len:a.payload.byteLength,dts:l,pts:l,type:ri.misbklv,duration:Number.POSITIVE_INFINITY})}})}return i},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0},e}();function Ai(e,t){return L(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var bi=function(){function e(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Si(t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,zt)},t.decryptAacSample=function(e,t,r){var i=this,a=e[t].unit;if(!(a.length<=16)){var n=a.subarray(16,a.length-a.length%16),s=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(s).then(function(n){var s=new Uint8Array(n);a.set(s,16),i.decrypter.isSync()||i.decryptAacSamples(e,t+1,r)}).catch(r)}},t.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)r.set(e.subarray(a,a+16),i);return r},t.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)e.set(r.subarray(i,i+16),a);return e},t.decryptAvcSample=function(e,t,r,i,a){var n=this,s=Ce(a.data),o=this.getAvcEncryptedData(s);this.decryptBuffer(o.buffer).then(function(o){a.data=n.getAvcDecryptedUnit(s,o),n.decrypter.isSync()||n.decryptAvcSamples(e,t,r+1,i)}).catch(i)},t.decryptAvcSamples=function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var a=e[t].units;!(r>=a.length);r++){var n=a[r];if(!(n.data.length<=48||1!==n.type&&5!==n.type||(this.decryptAvcSample(e,t,r,i,n),this.decrypter.isSync())))return}}},e}(),ki=function(){function e(){this.VideoSample=null}var t=e.prototype;return t.createVideoSample=function(e,t,r){return{key:e,frame:!1,pts:t,dts:r,units:[],length:0}},t.getLastNalUnit=function(e){var t,r,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){var a=i.units;r=a[a.length-1]}return r},t.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,i=r.length;if(!i)return void t.dropped++;var a=r[i-1];e.pts=a.pts,e.dts=a.dts}t.samples.push(e)}},t.parseNALu=function(e,t,r){var i,a,n=t.byteLength,s=e.naluState||0,o=s,l=[],u=0,d=-1,h=0;for(-1===s&&(d=0,h=this.getNALuType(t,0),s=0,u=1);u<n;)if(i=t[u++],s)if(1!==s)if(i)if(1===i){if(a=u-s-1,d>=0){var f={data:t.subarray(d,a),type:h};l.push(f)}else{var c=this.getLastNalUnit(e.samples);c&&(o&&u<=4-o&&c.state&&(c.data=c.data.subarray(0,c.data.byteLength-o)),a>0&&(c.data=be(c.data,t.subarray(0,a)),c.state=0))}u<n?(d=u,h=this.getNALuType(t,u),s=0):s=-1}else s=0;else s=3;else s=i?0:2;else s=i?0:1;if(d>=0&&s>=0){var v={data:t.subarray(d,n),type:h,state:s};l.push(v)}if(0===l.length){var g=this.getLastNalUnit(e.samples);g&&(g.data=be(g.data,t))}return e.naluState=s,l},e}(),Di=function(){function e(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}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");i.set(e.subarray(r,r+a)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a},t.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&W.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){var 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()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},e}(),_i=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.parsePES=function(e,t,r,i){var a,n=this,s=this.parseNALu(e,r.data,i),o=this.VideoSample,l=!1;r.data=null,o&&s.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),s.forEach(function(i){var s,u;switch(i.type){case 1:var d=!1;a=!0;var h,f=i.data;if(l&&f.length>4){var c=n.readSliceType(f);2!==c&&4!==c&&7!==c&&9!==c||(d=!0)}d&&null!=(h=o)&&h.frame&&!o.key&&(n.pushAccessUnit(o,e),o=n.VideoSample=null),o||(o=n.VideoSample=n.createVideoSample(!0,r.pts,r.dts)),o.frame=!0,o.key=d;break;case 5:a=!0,null!=(s=o)&&s.frame&&!o.key&&(n.pushAccessUnit(o,e),o=n.VideoSample=null),o||(o=n.VideoSample=n.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 6:a=!0,Ie(i.data,1,r.pts,t.samples);break;case 7:var v,g;a=!0,l=!0;var m=i.data,p=n.readSPS(m);if(!e.sps||e.width!==p.width||e.height!==p.height||(null==(v=e.pixelRatio)?void 0:v[0])!==p.pixelRatio[0]||(null==(g=e.pixelRatio)?void 0:g[1])!==p.pixelRatio[1]){e.width=p.width,e.height=p.height,e.pixelRatio=p.pixelRatio,e.sps=[m];for(var y=m.subarray(1,4),E="avc1.",T=0;T<3;T++){var S=y[T].toString(16);S.length<2&&(S="0"+S),E+=S}e.codec=E}break;case 8:a=!0,e.pps=[i.data];break;case 9:a=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(n.pushAccessUnit(o,e),o=null),o||(o=n.VideoSample=n.createVideoSample(!1,r.pts,r.dts));break;case 12:a=!0;break;default:a=!1}o&&a&&o.units.push(i)}),i&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)},r.getNALuType=function(e,t){return 31&e[t]},r.readSliceType=function(e){var t=new Di(e);return t.readUByte(),t.readUEG(),t.readUEG()},r.skipScalingList=function(e,t){for(var r=8,i=8,a=0;a<e;a++)0!==i&&(i=(r+t.readEG()+256)%256),r=0===i?r:i},r.readSPS=function(e){var t,r,i,a=new Di(e),n=0,s=0,o=0,l=0,u=a.readUByte.bind(a),d=a.readBits.bind(a),h=a.readUEG.bind(a),f=a.readBoolean.bind(a),c=a.skipBits.bind(a),v=a.skipEG.bind(a),g=a.skipUEG.bind(a),m=this.skipScalingList.bind(this);u();var p=u();if(d(5),c(3),u(),g(),100===p||110===p||122===p||244===p||44===p||83===p||86===p||118===p||128===p){var y=h();if(3===y&&c(1),g(),g(),c(1),f())for(r=3!==y?8:12,i=0;i<r;i++)f()&&m(i<6?16:64,a)}g();var E=h();if(0===E)h();else if(1===E)for(c(1),v(),v(),t=h(),i=0;i<t;i++)v();g(),c(1);var T=h(),S=h(),L=d(1);0===L&&c(1),c(1),f()&&(n=h(),s=h(),o=h(),l=h());var R=[1,1];if(f()&&f())switch(u()){case 1:R=[1,1];break;case 2:R=[12,11];break;case 3:R=[10,11];break;case 4:R=[16,11];break;case 5:R=[40,33];break;case 6:R=[24,11];break;case 7:R=[20,11];break;case 8:R=[32,11];break;case 9:R=[80,33];break;case 10:R=[18,11];break;case 11:R=[15,11];break;case 12:R=[64,33];break;case 13:R=[160,99];break;case 14:R=[4,3];break;case 15:R=[3,2];break;case 16:R=[2,1];break;case 255:R=[u()<<8|u(),u()<<8|u()]}return{width:Math.ceil(16*(T+1)-2*n-2*s),height:(2-L)*(S+1)*16-(L?2:4)*(o+l),pixelRatio:R}},t}(ki),Ii=188,Ci=function(){function e(e,t,r,i){this.logger=void 0,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._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=r,this.logger=i,this.videoParser=null}e.probe=function(t,r){var i=e.syncOffset(t);return i>0&&r.warn("MPEG2-TS detected but first sync word found @ offset "+i),-1!==i},e.syncOffset=function(e){for(var t=e.length,r=Math.min(940,t-Ii)+1,i=0;i<r;){for(var a=!1,n=-1,s=0,o=i;o<t;o+=Ii){if(71!==e[o]||t-o!==Ii&&71!==e[o+Ii]){if(s)return-1;break}if(s++,-1===n&&0!==(n=o)&&(r=Math.min(n+18612,e.length-Ii)+1),a||(a=0===xi(e,o)),a&&s>1&&(0===n&&s>2||o+Ii>r))return n}i++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:de[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}};var t=e.prototype;return t.resetInitSegment=function(t,r,i,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=a,this._audioTrack=e.createTrack("audio",a),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},t.demux=function(t,r,i,a){var n;void 0===i&&(i=!1),void 0===a&&(a=!1),i||(this.sampleAes=null);var s=this._videoTrack,o=this._audioTrack,l=this._id3Track,u=this._txtTrack,d=s.pid,h=s.pesData,f=o.pid,c=l.pid,v=o.pesData,g=l.pesData,m=null,p=this.pmtParsed,y=this._pmtId,E=t.length;if(this.remainderData&&(E=(t=be(this.remainderData,t)).length,this.remainderData=null),E<Ii&&!a)return this.remainderData=t,{audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};var T=Math.max(0,e.syncOffset(t));(E-=(E-T)%Ii)<t.byteLength&&!a&&(this.remainderData=new Uint8Array(t.buffer,E,t.buffer.byteLength-E));for(var S=0,L=T;L<E;L+=Ii)if(71===t[L]){var R=!!(64&t[L+1]),A=xi(t,L),b=void 0;if((48&t[L+3])>>4>1){if((b=L+5+t[L+4])===L+Ii)continue}else b=L+4;switch(A){case d:R&&(h&&(n=Fi(h,this.logger))&&(this.readyVideoParser(s.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(s,u,n,!1)),h={data:[],size:0}),h&&(h.data.push(t.subarray(b,L+Ii)),h.size+=L+Ii-b);break;case f:if(R){if(v&&(n=Fi(v,this.logger)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n)}v={data:[],size:0}}v&&(v.data.push(t.subarray(b,L+Ii)),v.size+=L+Ii-b);break;case c:R&&(g&&(n=Fi(g,this.logger))&&this.parseID3PES(l,n),g={data:[],size:0}),g&&(g.data.push(t.subarray(b,L+Ii)),g.size+=L+Ii-b);break;case 0:R&&(b+=t[b]+1),y=this._pmtId=wi(t,b);break;case y:R&&(b+=t[b]+1);var k=Pi(t,b,this.typeSupported,i,this.observer,this.logger);(d=k.videoPid)>0&&(s.pid=d,s.segmentCodec=k.segmentVideoCodec),(f=k.audioPid)>0&&(o.pid=f,o.segmentCodec=k.segmentAudioCodec),(c=k.id3Pid)>0&&(l.pid=c),null===m||p||(this.logger.warn("MPEG-TS PMT found at "+L+" after unknown PID '"+m+"'. Backtracking to sync byte @"+T+" to parse all TS packets."),m=null,L=T-188),p=this.pmtParsed=!0;break;case 17:case 8191:break;default:m=A}}else S++;S>0&&Oi(this.observer,new Error("Found "+S+" TS packet/s that do not start with 0x47"),void 0,this.logger),s.pesData=h,o.pesData=v,l.pesData=g;var D={audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};return a&&this.extractRemainingSamples(D),D},t.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},t.extractRemainingSamples=function(e){var t,r=e.audioTrack,i=e.videoTrack,a=e.id3Track,n=e.textTrack,s=i.pesData,o=r.pesData,l=a.pesData;if(s&&(t=Fi(s,this.logger))?(this.readyVideoParser(i.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(i,n,t,!0),i.pesData=null)):i.pesData=s,o&&(t=Fi(o,this.logger))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t)}r.pesData=null}else null!=o&&o.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(t=Fi(l,this.logger))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=l},t.demuxSampleAes=function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),a=this.sampleAes=new bi(this.observer,this.config,t);return this.decrypt(i,a)},t.readyVideoParser=function(e){null===this.videoParser&&"avc"===e&&(this.videoParser=new _i)},t.decrypt=function(e,t){return new Promise(function(r){var i=e.audioTrack,a=e.videoTrack;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,function(){a.samples?t.decryptAvcSamples(a.samples,0,0,function(){r(e)}):r(e)}):a.samples&&t.decryptAvcSamples(a.samples,0,0,function(){r(e)})})},t.destroy=function(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0},t.parseAACPES=function(e,t){var r,i,a,n=0,s=this.aacOverFlow,o=t.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;if(-1===l)o=be(s.sample.unit,o);else{var d=u-l;s.sample.unit.set(o.subarray(0,l),d),e.samples.push(s.sample),n=s.missing}}for(r=n,i=o.length;r<i-1&&!Hr(o,r);r++);if(r!==n){var h,f=r<i-1;if(h=f?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES",Oi(this.observer,new Error(h),f,this.logger),!f)return}if(Yr(e,this.observer,o,r,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!s)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var c=jr(e.samplerate);a=s.sample.pts+c}for(var v,g=0;r<i;){if(r+=(v=Wr(e,o,r,a,g)).length,v.missing){this.aacOverFlow=v;break}for(g++;r<i-1&&!Hr(o,r);r++);}},t.parseMPEGPES=function(e,t){var r=t.data,i=r.length,a=0,n=0,s=t.pts;if(void 0!==s)for(;n<i;)if(vi(r,n)){var o=hi(e,r,n,s,a);if(!o)break;n+=o.length,a++}else n++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},t.parseAC3PES=function(e,t){},t.parseID3PES=function(e,t){if(void 0!==t.pts){var r=n({},t,{type:this._videoTrack?ri.emsg:ri.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},e}();function xi(e,t){return((31&e[t+1])<<8)+e[t+2]}function wi(e,t){return(31&e[t+10])<<8|e[t+11]}function Pi(e,t,r,i,a,n){var s={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<o;){var l=xi(e,t),u=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){Mi("ADTS AAC",n);break}case 15:-1===s.audioPid&&(s.audioPid=l);break;case 21:-1===s.id3Pid&&(s.id3Pid=l);break;case 219:if(!i){Mi("H.264",n);break}case 27:-1===s.videoPid&&(s.videoPid=l);break;case 3:case 4:r.mpeg||r.mp3?-1===s.audioPid&&(s.audioPid=l,s.segmentAudioCodec="mp3"):n.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){Mi("AC-3",n);break}case 129:n.warn("AC-3 in M2TS support not included in build");break;case 6:if(-1===s.audioPid&&u>0)for(var d=t+5,h=u;h>2;){106===e[d]&&n.warn("AC-3 in M2TS support not included in build");var f=e[d+1]+2;d+=f,h-=f}break;case 194:case 135:return Oi(a,new Error("Unsupported EC-3 in M2TS found"),void 0,n),s;case 36:return Oi(a,new Error("Unsupported HEVC in M2TS found"),void 0,n),s}t+=u+5}return s}function Oi(e,t,r,i){i.warn("parsing error: "+t.message),e.emit(D.ERROR,D.ERROR,{type:b.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function Mi(e,t){t.log(e+" with AES-128-CBC encryption found in unencrypted stream")}function Fi(e,t){var r,i,a,n,s,o=0,l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=be(l[0],l[1]),l.splice(1,1);if(1===((r=l[0])[0]<<16)+(r[1]<<8)+r[2]){if((i=(r[4]<<8)+r[5])&&i>e.size-6)return null;var u=r[7];192&u&&(n=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&u?n-(s=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2)>54e5&&(t.warn(Math.round((n-s)/9e4)+"s delta between PTS and DTS, align them"),n=s):s=n);var d=(a=r[8])+9;if(e.size<=d)return null;e.size-=d;for(var h=new Uint8Array(e.size),f=0,c=l.length;f<c;f++){var v=(r=l[f]).byteLength;if(d){if(d>v){d-=v;continue}r=r.subarray(d),v-=d,d=0}h.set(r,o),o+=v}return i&&(i-=a+3),{data:h,pts:n,dts:s,len:i}}return null}var Ni=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)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])}},e}(),Bi=Math.pow(2,32)-1,Ui=function(){function e(){}return e.init=function(){var t;for(t in e.types={avc1:[],avcC:[],hvc1:[],hvcC:[],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:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=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:r,audio:i};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=n,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]);var s=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,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,a))},e.box=function(e){for(var t=8,r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];for(var n=i.length,s=n;n--;)t+=i[n].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),n=0,t=8;n<s;n++)o.set(i[n],t),t+=i[n].byteLength;return o},e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])},e.mdat=function(t){return e.box(e.types.mdat,t)},e.mdhd=function(t,r){r*=t;var i=Math.floor(r/(Bi+1)),a=Math.floor(r%(Bi+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,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale||0,t.duration||0),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))},e.moov=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale||0,t[0].duration||0)].concat(i).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(i))},e.mvhd=function(t,r){r*=t;var i=Math.floor(r/(Bi+1)),a=Math.floor(r%(Bi+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,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,n)},e.sdtp=function(t){var r,i,a=t.samples||[],n=new Uint8Array(4+a.length);for(r=0;r<a.length;r++)i=a[r].flags,n[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return e.box(e.types.sdtp,n)},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),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))},e.avc1=function(t){var r,i,a,n=[],s=[];for(r=0;r<t.sps.length;r++)a=(i=t.sps[r]).byteLength,n.push(a>>>8&255),n.push(255&a),n=n.concat(Array.prototype.slice.call(i));for(r=0;r<t.pps.length;r++)a=(i=t.pps[r]).byteLength,s.push(a>>>8&255),s.push(255&a),s=s.concat(Array.prototype.slice.call(i));var o=e.box(e.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(s))),l=t.width,u=t.height,d=t.pixelRatio[0],h=t.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,255&l,u>>8&255,255&u,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([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))},e.esds=function(e){var t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2].concat(t,[6,1,2]))},e.audioStsd=function(e){var t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,255&t,0,0])},e.mp4a=function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){return e.box(e.types[".mp3"],e.audioStsd(t))},e.ac3=function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))},e.stsd=function(t){var r=t.segmentCodec;if("audio"===t.type){if("aac"===r)return e.box(e.types.stsd,e.STSD,e.mp4a(t));if("mp3"===r&&"mp3"===t.codec)return e.box(e.types.stsd,e.STSD,e.mp3(t))}else{if(!t.pps||!t.sps)throw new Error("video track missing pps or sps");if("avc"===r)return e.box(e.types.stsd,e.STSD,e.avc1(t))}throw new Error("unsupported "+t.type+" segment codec ("+r+"/"+t.codec+")")},e.tkhd=function(t){var r=t.id,i=(t.duration||0)*(t.timescale||0),a=t.width||0,n=t.height||0,s=Math.floor(i/(Bi+1)),o=Math.floor(i%(Bi+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,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,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,a>>8&255,255&a,0,0,n>>8&255,255&n,0,0]))},e.traf=function(t,r){var i=e.sdtp(t),a=t.id,n=Math.floor(r/(Bi+1)),s=Math.floor(r%(Bi+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,i.length+16+20+8+16+8+8),i)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,r){var i,a,n,s,o,l,u=t.samples||[],d=u.length,h=12+16*d,f=new Uint8Array(h);for(r+=8+h,f.set(["video"===t.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<d;i++)n=(a=u[i]).duration,s=a.size,o=a.flags,l=a.cts,f.set([n>>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,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*i);return e.box(e.types.trun,f)},e.initSegment=function(t){e.types||e.init();var r=e.moov(t);return be(e.FTYP,r)},e.hvc1=function(e){return new Uint8Array},e}();function Gi(e,t){return function(e,t,r){var i=e*t*r;return Math.round(i)}(e,1e3,1/9e4)}Ui.types=void 0,Ui.HDLR_TYPES=void 0,Ui.STTS=void 0,Ui.STSC=void 0,Ui.STCO=void 0,Ui.STSZ=void 0,Ui.VMHD=void 0,Ui.SMHD=void 0,Ui.STSD=void 0,Ui.FTYP=void 0,Ui.DINF=void 0;var Vi=null,Hi=null;function Ki(e,t,r,i){return{duration:t,size:r,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}var Yi=function(e){function t(t,r,i,a){var n;if((n=e.call(this,"mp4-remuxer",a)||this).observer=void 0,n.config=void 0,n.typeSupported=void 0,n.ISGenerated=!1,n._initPTS=null,n._initDTS=null,n.nextVideoTs=null,n.nextAudioTs=null,n.videoSampleDuration=null,n.isAudioContiguous=!1,n.isVideoContiguous=!1,n.videoTrackConfig=void 0,n.observer=t,n.config=r,n.typeSupported=i,n.ISGenerated=!1,null===Vi){var s=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Vi=s?parseInt(s[1]):0}if(null===Hi){var o=navigator.userAgent.match(/Safari\/(\d+)/i);Hi=o?parseInt(o[1]):0}return n}o(t,e);var r=t.prototype;return r.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},r.resetTimeStamp=function(e){this.log("initPTS & initDTS reset"),this._initPTS=this._initDTS=e},r.resetNextTimestamp=function(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},r.resetInitSegment=function(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},r.getVideoStartPts=function(e){var t=!1,r=e[0].pts,i=e.reduce(function(e,i){var a=i.pts,n=a-e;return n<-4294967296&&(t=!0,n=(a=ji(a,r))-e),n>0?e:a},r);return t&&this.debug("PTS rollover detected"),i},r.remux=function(e,t,r,i,a,n,s,o){var l,u,d,h,f,c,v=a,g=a,m=e.pid>-1,p=t.pid>-1,y=t.samples.length,E=e.samples.length>0,T=s&&y>0||y>1;if((!m||E)&&(!p||T)||this.ISGenerated||s){if(this.ISGenerated){var S,L,R,A,b=this.videoTrackConfig;(b&&(t.width!==b.width||t.height!==b.height||(null==(S=t.pixelRatio)?void 0:S[0])!==(null==(L=b.pixelRatio)?void 0:L[0])||(null==(R=t.pixelRatio)?void 0:R[1])!==(null==(A=b.pixelRatio)?void 0:A[1]))||!b&&T||null===this.nextAudioTs&&E)&&this.resetInitSegment()}this.ISGenerated||(d=this.generateIS(e,t,a,n));var k,D=this.isVideoContiguous,_=-1;if(T&&(_=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!D&&this.config.forceKeyFrameOnDiscontinuity))if(c=!0,_>0){this.warn("Dropped "+_+" out of "+y+" video samples due to a missing keyframe");var I=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(_),t.dropped+=_,k=g+=(t.samples[0].pts-I)/t.inputTimeScale}else-1===_&&(this.warn("No keyframe found out of "+y+" video samples"),c=!1);if(this.ISGenerated){if(E&&T){var C=this.getVideoStartPts(t.samples),x=(ji(e.samples[0].pts,C)-C)/t.inputTimeScale;v+=Math.max(0,x),g+=Math.max(0,-x)}if(E){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),d=this.generateIS(e,t,a,n)),u=this.remuxAudio(e,v,this.isAudioContiguous,n,p||T||o===P?g:void 0),T){var w=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),d=this.generateIS(e,t,a,n)),l=this.remuxVideo(t,g,D,w)}}else T&&(l=this.remuxVideo(t,g,D,0));l&&(l.firstKeyFrame=_,l.independent=-1!==_,l.firstKeyFramePTS=k)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=Wi(r,a,this._initPTS,this._initDTS)),i.samples.length&&(h=qi(i,a,this._initPTS))),{audio:u,video:l,initSegment:d,independent:c,text:h,id3:f}},r.generateIS=function(e,t,r,i){var a,n,s,o=e.samples,l=t.samples,u=this.typeSupported,d={},h=this._initPTS,f=!h||i,c="audio/mp4",v=-1;if(f&&(a=n=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":u.mpeg?(c="audio/mpeg",e.codec=""):u.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}d.audio={id:"audio",container:c,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&u.mpeg?new Uint8Array(0):Ui.initSegment([e]),metadata:{channelCount:e.channelCount}},f&&(v=e.id,s=e.inputTimeScale,h&&s===h.timescale?f=!1:a=n=o[0].pts-Math.round(s*r))}if(t.sps&&t.pps&&l.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Ui.initSegment([t]),metadata:{width:t.width,height:t.height}},f)if(v=t.id,s=t.inputTimeScale,h&&s===h.timescale)f=!1;else{var g=this.getVideoStartPts(l),m=Math.round(s*r);n=Math.min(n,ji(l[0].dts,g)-m),a=Math.min(a,g-m)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,f?(h&&this.warn("Timestamps at playlist time: "+(i?"":"~")+r+" "+a/s+" != initPTS: "+h.baseTime/h.timescale+" ("+h.baseTime+"/"+h.timescale+") trackId: "+h.trackId),this.log("Found initPTS at playlist time: "+r+" offset: "+a/s+" ("+a+"/"+s+") trackId: "+v),this._initPTS={baseTime:a,timescale:s,trackId:v},this._initDTS={baseTime:n,timescale:s,trackId:v}):a=s=void 0,{tracks:d,initPTS:a,timescale:s,trackId:v}},r.remuxVideo=function(e,t,r,i){var a,s,o=e.inputTimeScale,l=e.samples,u=[],d=l.length,h=this._initPTS,f=h.baseTime*o/h.timescale,c=this.nextVideoTs,v=8,g=this.videoSampleDuration,m=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,y=!1;if(!r||null===c){var E=f+t*o,T=l[0].pts-ji(l[0].dts,l[0].pts);Vi&&null!==c&&Math.abs(E-T-(c+f))<15e3?r=!0:c=E-T-f}for(var S=c+f,L=0;L<d;L++){var R=l[L];R.pts=ji(R.pts,S),R.dts=ji(R.dts,S),R.dts<l[L>0?L-1:L].dts&&(y=!0)}y&&l.sort(function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i}),a=l[0].dts;var A=(s=l[l.length-1].dts)-a,_=A?Math.round(A/(d-1)):g||e.inputTimeScale/30;if(r){var I=a-S,C=I>_,x=I<-1;if((C||x)&&(C?this.warn((e.segmentCodec||"").toUpperCase()+": "+Gi(I)+" ms ("+I+"dts) hole between fragments detected at "+t.toFixed(3)):this.warn((e.segmentCodec||"").toUpperCase()+": "+Gi(-I)+" ms ("+I+"dts) overlapping between fragments detected at "+t.toFixed(3)),!x||S>=l[0].pts||Vi)){a=S;var w=l[0].pts-I;if(C)l[0].dts=a,l[0].pts=w;else for(var P=!0,O=0;O<l.length&&!(l[O].dts>w&&P);O++){var M=l[O].pts;if(l[O].dts-=I,l[O].pts-=I,O<l.length-1){var F=l[O+1].pts;P=F<=l[O].pts==F<=M}}this.log("Video: Initial PTS/DTS adjusted: "+Gi(w)+"/"+Gi(a)+", delta: "+Gi(I)+" ms")}}for(var N=0,B=0,U=a=Math.max(0,a),G=0;G<d;G++){for(var V=l[G],H=V.units,K=H.length,Y=0,j=0;j<K;j++)Y+=H[j].data.length;B+=Y,N+=K,V.length=Y,V.dts<U?(V.dts=U,U+=_/4|0||1):U=V.dts,m=Math.min(V.pts,m),p=Math.max(V.pts,p)}s=l[d-1].dts;var W,q=B+4*N+8;try{W=new Uint8Array(q)}catch(e){return void this.observer.emit(D.ERROR,D.ERROR,{type:b.MUX_ERROR,details:k.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:q,reason:"fail allocating video mdat "+q})}var X=new DataView(W.buffer);X.setUint32(0,q),W.set(Ui.types.mdat,4);for(var z=!1,Q=Number.POSITIVE_INFINITY,$=Number.POSITIVE_INFINITY,Z=Number.NEGATIVE_INFINITY,J=Number.NEGATIVE_INFINITY,ee=0;ee<d;ee++){for(var te=l[ee],re=te.units,ie=0,ae=0,ne=re.length;ae<ne;ae++){var se=re[ae],oe=se.data,le=se.data.byteLength;X.setUint32(v,le),v+=4,W.set(oe,v),v+=le,ie+=4+le}var ue=void 0;if(ee<d-1)g=l[ee+1].dts-te.dts,ue=l[ee+1].pts-te.pts;else{var de=this.config,he=ee>0?te.dts-l[ee-1].dts:_;if(ue=ee>0?te.pts-l[ee-1].pts:_,de.stretchShortVideoTrack&&null!==this.nextAudioTs){var fe=Math.floor(de.maxBufferHole*o),ce=(i?m+i*o:this.nextAudioTs+f)-te.pts;ce>fe?((g=ce-he)<0?g=he:z=!0,this.log("It is approximately "+ce/90+" ms to the next segment; using duration "+g/90+" ms for the last video frame.")):g=he}else g=he}var ve=Math.round(te.pts-te.dts);Q=Math.min(Q,g),Z=Math.max(Z,g),$=Math.min($,ue),J=Math.max(J,ue),u.push(Ki(te.key,g,ie,ve))}if(u.length)if(Vi){if(Vi<70){var ge=u[0].flags;ge.dependsOn=2,ge.isNonSync=0}}else if(Hi&&J-$<Z-Q&&_/Z<.025&&0===u[0].cts){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var me=a,pe=0,ye=u.length;pe<ye;pe++){var Ee=me+u[pe].duration,Te=me+u[pe].cts;if(pe<ye-1){var Se=Ee+u[pe+1].cts;u[pe].duration=Se-Te}else u[pe].duration=pe?u[pe-1].duration:_;u[pe].cts=0,me=Ee}}var Le=s+(g=z||!g?_:g);this.nextVideoTs=c=Le-f,this.videoSampleDuration=g,this.isVideoContiguous=!0;var Re={data1:Ui.moof(e.sequenceNumber++,a,n(e,{samples:u})),data2:W,startPTS:(m-f)/o,endPTS:(p+g-f)/o,startDTS:(a-f)/o,endDTS:c/o,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Re},r.getSamplesPerFrame=function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}},r.remuxAudio=function(e,t,r,i,a){var s=e.inputTimeScale,o=s/(e.samplerate?e.samplerate:s),l=this.getSamplesPerFrame(e),u=l*o,d=this._initPTS,h="mp3"===e.segmentCodec&&this.typeSupported.mpeg,f=[],c=void 0!==a,v=e.samples,g=h?0:8,m=this.nextAudioTs||-1,p=d.baseTime*s/d.timescale,y=p+t*s;if(this.isAudioContiguous=r=r||v.length&&m>0&&(i&&Math.abs(y-(m+p))<9e3||Math.abs(ji(v[0].pts,y)-(m+p))<20*u),v.forEach(function(e){e.pts=ji(e.pts,y)}),!r||m<0){if(v=v.filter(function(e){return e.pts>=0}),!v.length)return;m=0===a?0:i&&!c?Math.max(0,y-p):v[0].pts-p}if("aac"===e.segmentCodec)for(var E=this.config.maxAudioFramesDrift,T=0,S=m+p;T<v.length;T++){var L=v[T],R=L.pts,A=R-S,_=Math.abs(1e3*A/s);if(A<=-E*u&&c)0===T&&(this.warn("Audio frame @ "+(R/s).toFixed(3)+"s overlaps marker by "+Math.round(1e3*A/s)+" ms."),this.nextAudioTs=m=R-p,S=R);else if(A>=E*u&&_<1e4&&c){var I=Math.round(A/u);for(S=R-I*u;S<0&&I&&u;)I--,S+=u;0===T&&(this.nextAudioTs=m=S-p),this.warn("Injecting "+I+" audio frames @ "+((S-p)/s).toFixed(3)+"s due to "+Math.round(1e3*A/s)+" ms gap.");for(var C=0;C<I;C++){var x=Ni.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);x||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),x=L.unit.subarray()),v.splice(T,0,{unit:x,pts:S}),S+=u,T++}}L.pts=S,S+=u}for(var w,P=null,O=null,M=0,F=v.length;F--;)M+=v[F].unit.byteLength;for(var N=0,B=v.length;N<B;N++){var U=v[N],G=U.unit,V=U.pts;if(null!==O)f[N-1].duration=Math.round((V-O)/o);else{if(r&&"aac"===e.segmentCodec&&(V=m+p),P=V,!(M>0))return;M+=g;try{w=new Uint8Array(M)}catch(e){return void this.observer.emit(D.ERROR,D.ERROR,{type:b.MUX_ERROR,details:k.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:M,reason:"fail allocating audio mdat "+M})}h||(new DataView(w.buffer).setUint32(0,M),w.set(Ui.types.mdat,4))}w.set(G,g);var H=G.byteLength;g+=H,f.push(Ki(!0,l,H,0)),O=V}var K=f.length;if(K){var Y=f[f.length-1];m=O-p,this.nextAudioTs=m+o*Y.duration;var j=h?new Uint8Array(0):Ui.moof(e.sequenceNumber++,P/o,n({},e,{samples:f}));e.samples=[];var W=(P-p)/s,q=m/s,X={data1:j,data2:w,startPTS:W,endPTS:q,startDTS:W,endDTS:q,type:"audio",hasAudio:!0,hasVideo:!1,nb:K};return this.isAudioContiguous=!0,X}},t}(N);function ji(e,t){var r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}function Wi(e,t,r,i){var a=e.samples.length;if(a){for(var n=e.inputTimeScale,s=0;s<a;s++){var o=e.samples[s];o.pts=ji(o.pts-r.baseTime*n/r.timescale,t*n)/n,o.dts=ji(o.dts-i.baseTime*n/i.timescale,t*n)/n}var l=e.samples;return e.samples=[],{samples:l}}}function qi(e,t,r){var i=e.samples.length;if(i){for(var a=e.inputTimeScale,n=0;n<i;n++){var s=e.samples[n];s.pts=ji(s.pts-r.baseTime*a/r.timescale,t*a)/a}e.samples.sort(function(e,t){return e.pts-t.pts});var o=e.samples;return e.samples=[],{samples:o}}}var Xi,zi=function(e){function t(t,r,i,a){var n;return(n=e.call(this,"passthrough-remuxer",a)||this).emitInitSegment=!1,n.audioCodec=void 0,n.videoCodec=void 0,n.initData=void 0,n.initPTS=null,n.initTracks=void 0,n.lastEndTime=null,n.isVideoContiguous=!1,n}o(t,e);var r=t.prototype;return r.destroy=function(){},r.resetTimeStamp=function(e){this.lastEndTime=null;var t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)},r.resetNextTimestamp=function(){this.isVideoContiguous=!1,this.lastEndTime=null},r.resetInitSegment=function(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(e,i),this.emitInitSegment=!0},r.generateInitSegment=function(e,t){var r=this.audioCodec,i=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var a=this.initData=ye(e),n=a.audio,s=a.video;if(t)Ae(e,t);else{var o=n||s;null!=o&&o.encrypted&&this.warn('Init segment with encrypted track with has no key ("'+o.codec+'")!')}n&&(r=$i(n,ee,this)),s&&(i=$i(s,te,this));var l={};n&&s?l.audiovideo={container:"video/mp4",codec:r+","+i,supplemental:s.supplemental,encrypted:s.encrypted,initSegment:e,id:"main"}:n?l.audio={container:"audio/mp4",codec:r,encrypted:n.encrypted,initSegment:e,id:"audio"}:s?l.video={container:"video/mp4",codec:i,supplemental:s.supplemental,encrypted:s.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=l},r.remux=function(e,t,r,i,a,n){var s,o,l=this.initPTS,u=this.lastEndTime,d={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};L(u)||(u=this.lastEndTime=a||0);var h=t.samples;if(!h.length)return d;var f={initPTS:void 0,timescale:void 0,trackId:void 0},c=this.initData;if(null!=(s=c)&&s.length||(this.generateInitSegment(h),c=this.initData),null==(o=c)||!o.length)return this.warn("Failed to generate initSegment."),d;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);var v=function(e,t,r){for(var i={},a=me(e,["moof","traf"]),n=0;n<a.length;n++){var s=a[n],o=me(s,["tfhd"])[0],l=ce(o,4),u=t[l];if(u){i[l]||(i[l]={start:NaN,duration:0,sampleCount:0,timescale:u.timescale,type:u.type});var d=i[l],h=me(s,["tfdt"])[0];if(h){var f=h[0],c=ce(h,4);1===f&&(c===le?r.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(c*=le+1,c+=ce(h,8))),L(c)&&(!L(d.start)||c<d.start)&&(d.start=c)}var v=u.default,g=ce(o,0)|(null==v?void 0:v.flags),m=(null==v?void 0:v.duration)||0;8&g&&(m=ce(o,2&g?12:8));for(var p=me(s,["trun"]),y=d.start||0,E=0,T=m,S=0;S<p.length;S++){var R=p[S],A=ce(R,4),b=d.sampleCount;d.sampleCount+=A;var k=1&R[3],D=4&R[3],_=1&R[2],I=2&R[2],C=4&R[2],x=8&R[2],w=8,P=A;for(k&&(w+=4),D&&A&&(1&R[w+1]||void 0!==d.keyFrameIndex||(d.keyFrameIndex=b),w+=4,_?(T=ce(R,w),w+=4):T=m,I&&(w+=4),x&&(w+=4),y+=T,E+=T,P--);P--;)_?(T=ce(R,w),w+=4):T=m,I&&(w+=4),C&&(1&R[w+1]||void 0===d.keyFrameIndex&&(d.keyFrameIndex=d.sampleCount-(P+1),d.keyFrameStart=y),w+=4),x&&(w+=4),y+=T,E+=T;!E&&m&&(E+=m*A)}d.duration+=E}}if(!Object.keys(i).some(function(e){return i[e].duration})){for(var O=1/0,M=0,F=me(e,["sidx"]),N=0;N<F.length;N++){var B=pe(F[N]);if(null!=B&&B.references){O=Math.min(O,B.earliestPresentationTime/B.timescale);var U=B.references.reduce(function(e,t){return e+t.info.duration||0},0);M=Math.max(M,U+B.earliestPresentationTime/B.timescale)}}M&&L(M)&&Object.keys(i).forEach(function(e){i[e].duration||(i[e].duration=M*i[e].timescale-i[e].start)})}return i}(h,c,this),g=c.audio?v[c.audio.id]:null,m=c.video?v[c.video.id]:null,p=Qi(m,1/0),y=Qi(g,1/0),E=Qi(m,0,!0),T=Qi(g,0,!0),S=a,R=0,A=g&&(!m||!l&&y<p||l&&l.trackId===c.audio.id),b=A?g:m;if(b){var k=b.timescale,D=b.start-a*k,_=A?c.audio.id:c.video.id;S=b.start/k,R=A?T-y:E-p,!n&&l||!function(e,t,r,i){if(null===e)return!0;var a=Math.max(i,1),n=t-e.baseTime/e.timescale;return Math.abs(n-r)>a}(l,S,a,R)&&k===l.timescale||(l&&this.warn("Timestamps at playlist time: "+(n?"":"~")+a+" "+D/k+" != initPTS: "+l.baseTime/l.timescale+" ("+l.baseTime+"/"+l.timescale+") trackId: "+l.trackId),this.log("Found initPTS at playlist time: "+a+" offset: "+(S-a)+" ("+D+"/"+k+") trackId: "+_),l=null,f.initPTS=D,f.timescale=k,f.trackId=_)}else this.warn("No audio or video samples found for initPTS at playlist time: "+a);l?(f.initPTS=l.baseTime,f.timescale=l.timescale,f.trackId=l.trackId):(f.timescale&&void 0!==f.trackId&&void 0!==f.initPTS||(this.warn("Could not set initPTS"),f.initPTS=S,f.timescale=1,f.trackId=-1),this.initPTS=l={baseTime:f.initPTS,timescale:f.timescale,trackId:f.trackId});var I=S-l.baseTime/l.timescale,C=I+R;R>0?this.lastEndTime=C:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var x=!!c.audio,w=!!c.video,P="";x&&(P+="audio"),w&&(P+="video");var O={data1:h,startPTS:I,startDTS:I,endPTS:C,endDTS:C,type:P,hasAudio:x,hasVideo:w,nb:1,dropped:0,encrypted:!!c.audio&&c.audio.encrypted||!!c.video&&c.video.encrypted};d.audio=x&&!w?O:void 0,d.video=w?O:void 0;var M=null==m?void 0:m.sampleCount;if(M){var F=m.keyFrameIndex,N=-1!==F;O.nb=M,O.dropped=0===F||this.isVideoContiguous?0:N?F:M,O.independent=N,O.firstKeyFrame=F,N&&m.keyFrameStart&&(O.firstKeyFramePTS=(m.keyFrameStart-l.baseTime)/l.timescale),this.isVideoContiguous||(d.independent=N),this.isVideoContiguous||(this.isVideoContiguous=N),O.dropped&&this.warn("fmp4 does not start with IDR: firstIDR "+F+"/"+M+" dropped: "+O.dropped+" start: "+(O.firstKeyFramePTS||"NA"))}return d.initSegment=f,d.id3=Wi(r,a,l,l),i.samples.length&&(d.text=qi(i,a,l)),d},t}(N);function Qi(e,t,r){return void 0===r&&(r=!1),void 0!==(null==e?void 0:e.start)?(e.start+(r?e.duration:0))/e.timescale:t}function $i(e,t,r){var i=e.codec;return i&&i.length>4?i:t===ee?"ec-3"===i||"ac-3"===i||"alac"===i?i:"fLaC"===i||"Opus"===i?Ve(i,!1):(r.warn('Unhandled audio codec "'+i+'" in mp4 MAP'),i||"mp4a"):(r.warn('Unhandled video codec "'+i+'" in mp4 MAP'),i||"avc1")}try{Xi=self.performance.now.bind(self.performance)}catch(e){Xi=Date.now}var Zi=[{demux:Ri,remux:zi},{demux:Ci,remux:Yi},{demux:mi,remux:Yi},{demux:pi,remux:Yi}],Ji=function(){function e(e,t,r,i,a,n){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=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=r,this.id=a,this.logger=n}var t=e.prototype;return t.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},t.push=function(e,t,r,i){var a=this,n=r.transmuxing;n.executeStart=Xi();var s=new Uint8Array(e),o=this.currentTransmuxState,l=this.transmuxConfig;i&&(this.currentTransmuxState=i);var u=i||o,d=u.contiguous,h=u.discontinuity,f=u.trackSwitch,c=u.accurateTimeOffset,v=u.timeOffset,g=u.initSegmentChange,m=l.audioCodec,p=l.videoCodec,y=l.defaultInitPts,E=l.duration,T=l.initSegmentData,S=function(e,t){var r=null;return e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t),r}(s,t);if(S&&$t(S.method)){var L=this.getDecrypter(),R=Zt(S.method);if(!L.isSync())return this.asyncResult=!0,this.decryptionPromise=L.webCryptoDecrypt(s,S.key.buffer,S.iv.buffer,R).then(function(e){var t=a.push(e,null,r);return a.decryptionPromise=null,t}),this.decryptionPromise;var A=L.softwareDecrypt(s,S.key.buffer,S.iv.buffer,R);if(r.part>-1){var _=L.flush();A=_?_.buffer:_}if(!A)return n.executeEnd=Xi(),ea(r);s=new Uint8Array(A)}var I=this.needsProbing(h,f);if(I){var C=this.configureTransmuxer(s);if(C)return this.logger.warn("[transmuxer] "+C.message),this.observer.emit(D.ERROR,D.ERROR,{type:b.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,fatal:!1,error:C,reason:C.message}),n.executeEnd=Xi(),ea(r)}(h||f||g||I)&&this.resetInitSegment(T,m,p,E,t),(h||g||I)&&this.resetInitialTimestamp(y),d||this.resetContiguity();var x=this.transmux(s,S,v,c,r);this.asyncResult=ta(x);var w=this.currentTransmuxState;return w.contiguous=!0,w.discontinuity=!1,w.trackSwitch=!1,n.executeEnd=Xi(),x},t.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=Xi();var i=this.decrypter,a=this.currentTransmuxState,n=this.decryptionPromise;if(n)return this.asyncResult=!0,n.then(function(){return t.flush(e)});var s=[],o=a.timeOffset;if(i){var l=i.flush();l&&s.push(this.push(l.buffer,null,e))}var u=this.demuxer,d=this.remuxer;if(!u||!d){r.executeEnd=Xi();var h=[ea(e)];return this.asyncResult?Promise.resolve(h):h}var f=u.flush(o);return ta(f)?(this.asyncResult=!0,f.then(function(r){return t.flushRemux(s,r,e),s})):(this.flushRemux(s,f,e),this.asyncResult?Promise.resolve(s):s)},t.flushRemux=function(e,t,r){var i=t.audioTrack,a=t.videoTrack,n=t.id3Track,s=t.textTrack,o=this.currentTransmuxState,l=o.accurateTimeOffset,u=o.timeOffset;this.logger.log("[transmuxer.ts]: Flushed "+this.id+" sn: "+r.sn+(r.part>-1?" part: "+r.part:"")+" of "+(this.id===w?"level":"track")+" "+r.level);var d=this.remuxer.remux(i,a,n,s,u,l,!0,this.id);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=Xi()},t.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},t.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},t.resetInitSegment=function(e,t,r,i,a){var n=this.demuxer,s=this.remuxer;n&&s&&(n.resetInitSegment(e,t,r,i),s.resetInitSegment(e,t,r,a))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(e,t,r,i,a){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,a):this.transmuxUnencrypted(e,r,i,a)},t.transmuxUnencrypted=function(e,t,r,i){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),n=a.audioTrack,s=a.videoTrack,o=a.id3Track,l=a.textTrack;return{remuxResult:this.remuxer.remux(n,s,o,l,t,r,!1,this.id),chunkMeta:i}},t.transmuxSampleAes=function(e,t,r,i,a){var n=this;return this.demuxer.demuxSampleAes(e,t,r).then(function(e){return{remuxResult:n.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,n.id),chunkMeta:a}})},t.configureTransmuxer=function(e){for(var t,r=this.config,i=this.observer,a=this.typeSupported,n=0,s=Zi.length;n<s;n++){var o;if(null!=(o=Zi[n].demux)&&o.probe(e,this.logger)){t=Zi[n];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var l=this.demuxer,u=this.remuxer,d=t.remux,h=t.demux;u&&u instanceof d||(this.remuxer=new d(i,r,a,this.logger)),l&&l instanceof h||(this.demuxer=new h(i,r,a,this.logger),this.probe=h.probe)},t.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},t.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new Si(this.config)),e},e}(),ea=function(e){return{remuxResult:{},chunkMeta:e}};function ta(e){return"then"in e&&e.then instanceof Function}var ra=function(e,t,r,i,a){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=r,this.duration=i,this.defaultInitPts=a||null},ia=function(e,t,r,i,a,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=r,this.trackSwitch=i,this.timeOffset=a,this.initSegmentChange=n},aa=/(\d+)-(\d+)\/(\d+)/,na=function(){function e(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||sa,this.controller=new self.AbortController,this.stats=new J}var t=e.prototype;return t.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},t.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(e,t,r){var i=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var s=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(n({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}(e,this.controller.signal),o="arraybuffer"===e.responseType,l=o?"byteLength":"length",u=t.loadPolicy,d=u.maxTimeToFirstByteMs,h=u.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),t.timeout=d&&L(d)?d:h,this.requestTimeout=self.setTimeout(function(){i.callbacks&&(i.abortInternal(),i.callbacks.onTimeout(a,e,i.response))},t.timeout),(ta(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(function(r){var n;i.response=i.loader=r;var s=Math.max(self.performance.now(),a.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=h,i.requestTimeout=self.setTimeout(function(){i.callbacks&&(i.abortInternal(),i.callbacks.onTimeout(a,e,i.response))},h-(s-a.loading.start)),!r.ok){var l=r.status,u=r.statusText;throw new oa(u||"fetch, bad network response",l,r)}a.loading.first=s,a.total=function(e){var t=e.get("Content-Range");if(t){var r=function(e){var t=aa.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(L(r))return r}var i=e.get("Content-Length");if(i)return parseInt(i)}(r.headers)||a.total;var d=null==(n=i.callbacks)?void 0:n.onProgress;return d&&L(t.highWaterMark)?i.loadProgressively(r,a,e,t.highWaterMark,d):o?r.arrayBuffer():"json"===e.responseType?r.json():r.text()}).then(function(r){var n,s,o=i.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(i.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var u=r[l];u&&(a.loaded=a.total=u);var d={url:o.url,data:r,code:o.status},h=null==(n=i.callbacks)?void 0:n.onProgress;h&&!L(t.highWaterMark)&&h(a,e,r,o),null==(s=i.callbacks)||s.onSuccess(d,a,e,o)}).catch(function(t){var r;if(self.clearTimeout(i.requestTimeout),!a.aborted){var n=t&&t.code||0,s=t?t.message:null;null==(r=i.callbacks)||r.onError({code:n,text:s},e,t?t.details:null,a)}})},t.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},t.loadProgressively=function(e,t,r,i,a){void 0===i&&(i=0);var n=new Or,s=e.body.getReader(),o=function(){return s.read().then(function(s){if(s.done)return n.dataLength&&a(t,r,n.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));var l=s.value,u=l.length;return t.loaded+=u,u<i||n.dataLength?(n.push(l),n.dataLength>=i&&a(t,r,n.flush().buffer,e)):a(t,r,l.buffer,e),o()}).catch(function(){return Promise.reject()})};return o()},e}();function sa(e,t){return new self.Request(e.url,t)}var oa=function(e){function t(t,r,i){var a;return(a=e.call(this,t)||this).code=void 0,a.details=void 0,a.code=r,a.details=i,a}return o(t,e),t}(c(Error)),la=/^age:\s*[\d.]+\s*$/im,ua=function(){function e(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 J,this.retryDelay=0}var t=e.prototype;return t.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},t.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},t.load=function(e,t,r){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=r,this.loadInternal()},t.loadInternal=function(){var e=this,t=this.config,r=this.context;if(t&&r){var i=this.loader=new self.XMLHttpRequest,a=this.stats;a.loading.first=0,a.loaded=0,a.aborted=!1;var n=this.xhrSetup;n?Promise.resolve().then(function(){if(e.loader===i&&!e.stats.aborted)return n(i,r.url)}).catch(function(t){if(e.loader===i&&!e.stats.aborted)return i.open("GET",r.url,!0),n(i,r.url)}).then(function(){e.loader!==i||e.stats.aborted||e.openAndSendXhr(i,r,t)}).catch(function(t){var n;null==(n=e.callbacks)||n.onError({code:i.status,text:t.message},r,i,a)}):this.openAndSendXhr(i,r,t)}},t.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var i=t.headers,a=r.loadPolicy,n=a.maxTimeToFirstByteMs,s=a.maxLoadTimeMs;if(i)for(var o in i)e.setRequestHeader(o,i[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),r.timeout=n&&L(n)?n:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},t.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,a=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var n=t.status,s="text"===t.responseType?t.responseText:null;if(n>=200&&n<300){var o=null!=s?s:t.response;if(null!=o){var l,u;r.loading.end=Math.max(self.performance.now(),r.loading.first);var d="arraybuffer"===t.responseType?o.byteLength:o.length;r.loaded=r.total=d,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first);var h=null==(l=this.callbacks)?void 0:l.onProgress;h&&h(r,e,o,t);var f={url:t.responseURL,data:o,code:n};return void(null==(u=this.callbacks)||u.onSuccess(f,r,e,t))}}var c,v=a.loadPolicy.errorRetry;Et(v,r.retry,!1,{url:e.url,data:void 0,code:n})?this.retry(v):(W.error(n+" while loading "+e.url),null==(c=this.callbacks)||c.onError({code:n,text:t.statusText},e,t,r))}}},t.loadtimeout=function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(Et(e,this.stats.retry,!0))this.retry(e);else{var t;W.warn("timeout while loading "+(null==(t=this.context)?void 0:t.url));var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}},t.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=pt(e,r.retry),r.retry++,W.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+(null==t?void 0:t.url)+", retrying "+r.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)},t.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},t.getCacheAge=function(){var e=null;if(this.loader&&la.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},e}(),da={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},ha=d(d({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,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,ignorePlaylistParsingErrors:!1,loader:ua,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:ot,bufferController:Ft,capLevelController:Ut,errorController:It,fpsController:Pr,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,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!1,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!1,preserveManualLevelOnError:!1,certLoadPolicy:{default:da},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}}},interstitialAssetListLoadPolicy:{default:da},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:X,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:Cr,interstitialsController:void 0});function fa(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(fa):Object.keys(e).reduce(function(t,r){return t[r]=fa(e[r]),t},{}):e}function ca(e,t){var r=e.loader;r!==na&&r!==ua?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=na,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}var va="NOT_LOADED",ga="APPENDING",ma="PARTIAL",pa="OK",ya=function(){function e(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()}var t=e.prototype;return t._registerListeners=function(){var e=this.hls;e&&(e.on(D.MANIFEST_LOADING,this.onManifestLoading,this),e.on(D.BUFFER_APPENDED,this.onBufferAppended,this),e.on(D.FRAG_BUFFERED,this.onFragBuffered,this),e.on(D.FRAG_LOADED,this.onFragLoaded,this))},t._unregisterListeners=function(){var e=this.hls;e&&(e.off(D.MANIFEST_LOADING,this.onManifestLoading,this),e.off(D.BUFFER_APPENDED,this.onBufferAppended,this),e.off(D.FRAG_BUFFERED,this.onFragBuffered,this),e.off(D.FRAG_LOADED,this.onFragLoaded,this))},t.destroy=function(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},t.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var i=r.length;i--;){var a=r[i];if(!a)break;if(a.start<=e&&e<=a.end&&a.loaded)return a}return this.getBufferedFrag(e,t)},t.getBufferedFrag=function(e,t){return this.getFragAtPos(e,t,!0)},t.getFragAtPos=function(e,t,r){for(var i=this.fragments,a=Object.keys(i),n=a.length;n--;){var s=i[a[n]];if((null==s?void 0:s.body.type)===t&&(!r||s.buffered)){var o=s.body;if(o.start<=e&&e<=o.end)return o}}return null},t.detectEvictedFragments=function(e,t,r,i,a){var n=this;this.timeRanges&&(this.timeRanges[e]=t);var s=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach(function(i){var o=n.fragments[i];if(o&&!(s>=o.body.sn))if(o.buffered||o.loaded&&!a){var l=o.range[e];l&&(0!==l.time.length?l.time.some(function(e){var r=!n.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&n.removeFragment(o.body),r}):n.removeFragment(o.body))}else o.body.type===r&&n.removeFragment(o.body)})},t.detectPartialFragments=function(e){var t=this,r=this.timeRanges;if(r&&"initSegment"!==e.frag.sn){var i=e.frag,a=Ta(i),n=this.fragments[a];if(!(!n||n.buffered&&i.gap)){var s=!i.relurl;Object.keys(r).forEach(function(a){var o=i.elementaryStreams[a];if(o){var l=r[a],u=s||!0===o.partial;n.range[a]=t.getBufferedTimes(i,e.part,u,l)}}),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),Ea(n)||this.removeParts(i.sn-1,i.type)):this.removeFragment(n.body)}}},t.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=Sa(r,function(t){return t.fragment.sn>=e}))},t.fragBuffered=function(e,t){var r=Ta(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)},t.getBufferedTimes=function(e,t,r,i){for(var a={time:[],partial:r},n=e.start,s=e.end,o=e.minEndPTS||s,l=e.maxStartPTS||n,u=0;u<i.length;u++){var d=i.start(u)-this.bufferPadding,h=i.end(u)+this.bufferPadding;if(l>=d&&o<=h){a.time.push({startPTS:Math.max(n,i.start(u)),endPTS:Math.min(s,i.end(u))});break}if(n<h&&s>d){var f=Math.max(n,i.start(u)),c=Math.min(s,i.end(u));c>f&&(a.partial=!0,a.time.push({startPTS:f,endPTS:c}))}else if(s<=d)break}return a},t.getPartialFragment=function(e){var t,r,i,a=null,n=0,s=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach(function(l){var u=o[l];u&&Ea(u)&&(r=u.body.start-s,i=u.body.end+s,e>=r&&e<=i&&(t=Math.min(e-r,i-e),n<=t&&(a=u.body,n=t)))}),a},t.isEndListAppended=function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||Ea(t))},t.getState=function(e){var t=Ta(e),r=this.fragments[t];return r?r.buffered?Ea(r)?ma:pa:ga:va},t.isTimeBuffered=function(e,t,r){for(var i,a,n=0;n<r.length;n++){if(i=r.start(n)-this.bufferPadding,a=r.end(n)+this.bufferPadding,e>=i&&t<=a)return!0;if(t<=i)return!1}return!1},t.onManifestLoading=function(){this.removeAllFragments()},t.onFragLoaded=function(e,t){if("initSegment"!==t.frag.sn&&!t.frag.bitrateTest){var r=t.frag,i=t.part?null:t,a=Ta(r);this.fragments[a]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}},t.onBufferAppended=function(e,t){var r=t.frag,i=t.part,a=t.timeRanges,n=t.type;if("initSegment"!==r.sn){var s=r.type;if(i){var o=this.activePartLists[s];o||(this.activePartLists[s]=o=[]),o.push(i)}this.timeRanges=a;var l=a[n];this.detectEvictedFragments(n,l,s,i)}},t.onFragBuffered=function(e,t){this.detectPartialFragments(t)},t.hasFragment=function(e){var t=Ta(e);return!!this.fragments[t]},t.hasFragments=function(e){var t=this.fragments,r=Object.keys(t);if(!e)return r.length>0;for(var i=r.length;i--;){var a=t[r[i]];if((null==a?void 0:a.body.type)===e)return!0}return!1},t.hasParts=function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)},t.removeFragmentsInRange=function(e,t,r,i,a){var n=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach(function(s){var o=n.fragments[s];if(o){var l=o.body;l.type!==r||i&&!l.gap||l.start<t&&l.end>e&&(o.buffered||a)&&n.removeFragment(l)}})},t.removeFragment=function(e){var t=Ta(e);e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=Sa(r,function(e){return e.fragment.sn!==i})}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},t.removeAllFragments=function(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var t=null==(e=this.hls)||null==(e=e.latestLevelDetails)?void 0:e.partList;t&&t.forEach(function(e){return e.clearElementaryStreamInfo()})},e}();function Ea(e){var t,r,i;return e.buffered&&!!(e.body.gap||null!=(t=e.range.video)&&t.partial||null!=(r=e.range.audio)&&r.partial||null!=(i=e.range.audiovideo)&&i.partial)}function Ta(e){return e.type+"_"+e.level+"_"+e.sn}function Sa(e,t){return e.filter(function(e){var r=t(e);return r||e.clearElementaryStreamInfo(),r})}var La=Math.pow(2,17),Ra=function(){function e(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var t=e.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,t){var r=this,i=e.url;if(!i)return Promise.reject(new ka({type:b.NETWORK_ERROR,details:k.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();var a=this.config,n=a.fLoader,s=a.loader;return new Promise(function(o,l){if(r.loader&&r.loader.destroy(),e.gap){if(e.tagList.some(function(e){return"GAP"===e[0]}))return void l(ba(e));e.gap=!1}var u=r.loader=n?new n(a):new s(a),h=Aa(e);e.loader=u;var f=yt(a.fragLoadPolicy.default),c={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:La};e.stats=u.stats;var v={onSuccess:function(t,i,a,n){r.resetLoader(e,u);var s=t.data;a.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),o({frag:e,part:null,payload:s,networkDetails:n})},onError:function(t,a,n,s){r.resetLoader(e,u),l(new ka({type:b.NETWORK_ERROR,details:k.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:d({url:i,data:void 0},t),error:new Error("HTTP Error "+t.code+" "+t.text),networkDetails:n,stats:s}))},onAbort:function(t,i,a){r.resetLoader(e,u),l(new ka({type:b.NETWORK_ERROR,details:k.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:a,stats:t}))},onTimeout:function(t,i,a){r.resetLoader(e,u),l(new ka({type:b.NETWORK_ERROR,details:k.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+c.timeout+"ms"),networkDetails:a,stats:t}))}};t&&(v.onProgress=function(r,i,a,n){return t({frag:e,part:null,payload:a,networkDetails:n})}),u.load(h,c,v)})},t.loadPart=function(e,t,r){var i=this;this.abort();var a=this.config,n=a.fLoader,s=a.loader;return new Promise(function(o,l){if(i.loader&&i.loader.destroy(),e.gap||t.gap)l(ba(e,t));else{var u=i.loader=n?new n(a):new s(a),h=Aa(e,t);e.loader=u;var f=yt(a.fragLoadPolicy.default),c={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:La};t.stats=u.stats,u.load(h,c,{onSuccess:function(a,n,s,l){i.resetLoader(e,u),i.updateStatsFromPart(e,t);var d={frag:e,part:t,payload:a.data,networkDetails:l};r(d),o(d)},onError:function(r,a,n,s){i.resetLoader(e,u),l(new ka({type:b.NETWORK_ERROR,details:k.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:d({url:h.url,data:void 0},r),error:new Error("HTTP Error "+r.code+" "+r.text),networkDetails:n,stats:s}))},onAbort:function(r,a,n){e.stats.aborted=t.stats.aborted,i.resetLoader(e,u),l(new ka({type:b.NETWORK_ERROR,details:k.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:n,stats:r}))},onTimeout:function(r,a,n){i.resetLoader(e,u),l(new ka({type:b.NETWORK_ERROR,details:k.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+c.timeout+"ms"),networkDetails:n,stats:r}))}})}})},t.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,a=i.total;if(r.loaded+=i.loaded,a){var n=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/a),n),o=(n-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,u=i.loading;l.start?l.first+=u.first-u.start:(l.start=u.start,l.first=u.first),l.end=u.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},e}();function Aa(e,t){void 0===t&&(t=null);var r,i=t||e,a={frag:e,part:t,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},n=i.byteRangeStartOffset,s=i.byteRangeEndOffset;if(L(n)&&L(s)){var o,l=n,u=s;if("initSegment"===e.sn&&("AES-128"===(r=null==(o=e.decryptdata)?void 0:o.method)||"AES-256"===r)){var d=s-n;d%16&&(u=s+(16-d%16)),0!==n&&(a.resetIV=!0,l=n-16)}a.rangeStart=l,a.rangeEnd=u}return a}function ba(e,t){var r=new Error("GAP "+(e.gap?"tag":"attribute")+" found"),i={type:b.MEDIA_ERROR,details:k.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new ka(i)}var ka=function(e){function t(t){var r;return(r=e.call(this,t.error.message)||this).data=void 0,r.data=t,r}return o(t,e),t}(c(Error)),Da=function(e){function t(t,r){var i;return(i=e.call(this,t,r)||this)._boundTick=void 0,i._tickTimer=null,i._tickInterval=null,i._tickCallCount=0,i._boundTick=i.tick.bind(i),i}o(t,e);var r=t.prototype;return r.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},r.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},r.onHandlerDestroyed=function(){},r.hasInterval=function(){return!!this._tickInterval},r.hasNextTick=function(){return!!this._tickTimer},r.setInterval=function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},r.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},r.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},r.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},r.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},r.doTick=function(){},t}(N),_a=function(e,t,r,i,a,n){void 0===i&&(i=0),void 0===a&&(a=-1),void 0===n&&(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={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=e,this.sn=t,this.id=r,this.size=i,this.part=a,this.partial=n};function Ia(e,t){for(var r=0,i=e.length;r<i;r++){var a;if((null==(a=e[r])?void 0:a.cc)===t)return e[r]}return null}function Ca(e,t){var r=e.start+t;e.startPTS=r,e.setStart(r),e.endPTS=r+e.duration}function xa(e,t){for(var r=t.fragments,i=0,a=r.length;i<a;i++)Ca(r[i],e);t.fragmentHint&&Ca(t.fragmentHint,e),t.alignedSliding=!0}function wa(e,t){e&&(function(e,t){if(function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e)){var r=Math.min(t.endCC,e.endCC),i=Ia(t.fragments,r),a=Ia(e.fragments,r);i&&a&&(W.log("Aligning playlist at start of dicontinuity sequence "+r),xa(i.start-a.start,e))}}(t,e),t.alignedSliding||function(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var r,i,a=e.fragments,n=t.fragments;if(a.length&&n.length){var s=Math.min(t.endCC,e.endCC);t.startCC<s&&e.startCC<s&&(r=Ia(n,s),i=Ia(a,s)),r&&i||(i=Ia(a,(r=n[Math.floor(n.length/2)]).cc)||a[Math.floor(a.length/2)]);var o=r.programDateTime,l=i.programDateTime;o&&l&&xa((l-o)/1e3-(i.start-r.start),e)}}}(t,e),t.alignedSliding||t.skippedSegments||Lr(e,t,!1))}function Pa(e,t,r){Oa(e,t,r),e.addEventListener(t,r)}function Oa(e,t,r){e.removeEventListener(t,r)}var Ma=function(e){for(var t="",r=e.length,i=0;i<r;i++)t+="["+e.start(i).toFixed(3)+"-"+e.end(i).toFixed(3)+"]";return t},Fa="STOPPED",Na="IDLE",Ba="KEY_LOADING",Ua="FRAG_LOADING",Ga="FRAG_LOADING_WAITING_RETRY",Va="PARSING",Ha="PARSED",Ka="ENDED",Ya="ERROR",ja="WAITING_LEVEL",Wa=function(e){function t(t,r,i,a,n){var s;return(s=e.call(this,a,t.logger)||this).hls=void 0,s.fragPrevious=null,s.fragCurrent=null,s.fragmentTracker=void 0,s.transmuxer=null,s._state=Fa,s.playlistType=void 0,s.media=null,s.mediaBuffer=null,s.config=void 0,s.bitrateTest=!1,s.lastCurrentTime=0,s.nextLoadPosition=0,s.startPosition=0,s.startTimeOffset=null,s.retryDate=0,s.levels=null,s.fragmentLoader=void 0,s.keyLoader=void 0,s.levelLastLoaded=null,s.startFragRequested=!1,s.decrypter=void 0,s.initPTS=[],s.buffering=!0,s.loadingParts=!1,s.loopSn=void 0,s.onMediaSeeking=function(){var e=s,t=e.config,r=e.fragCurrent,i=e.media,a=e.mediaBuffer,n=e.state,o=i?i.currentTime:0,l=wt.bufferInfo(a||i,o,t.maxBufferHole),u=!l.len;if(s.log("Media seeking to "+(L(o)?o.toFixed(3):o)+", state: "+n+", "+(u?"out of":"in")+" buffer"),s.state===Ka)s.resetLoadingState();else if(r){var d=t.maxFragLookUpTolerance,h=r.start-d,f=r.start+r.duration+d;if(u||f<l.start||h>l.end){var c=o>f;(o<h||c)&&(c&&r.loader&&(s.log("Cancelling fragment load for seek (sn: "+r.sn+")"),r.abortRequests(),s.resetLoadingState()),s.fragPrevious=null)}}if(i&&(s.fragmentTracker.removeFragmentsInRange(o,1/0,s.playlistType,!0),o>s.lastCurrentTime&&(s.lastCurrentTime=o),!s.loadingParts)){var v=Math.max(l.end,o),g=s.shouldLoadParts(s.getLevelDetails(),v);g&&(s.log("LL-Part loading ON after seeking to "+o.toFixed(2)+" with buffer @"+v.toFixed(2)),s.loadingParts=g)}s.hls.hasEnoughToStart||(s.log("Setting "+(u?"startPosition":"nextLoadPosition")+" to "+o+" for seek without enough to start"),s.nextLoadPosition=o,u&&(s.startPosition=o)),u&&s.state===Na&&s.tickImmediate()},s.onMediaEnded=function(){s.log("setting startPosition to 0 because media ended"),s.startPosition=s.lastCurrentTime=0},s.playlistType=n,s.hls=t,s.fragmentLoader=new Ra(t.config),s.keyLoader=i,s.fragmentTracker=r,s.config=t.config,s.decrypter=new Si(t.config),s}o(t,e);var r=t.prototype;return r.registerListeners=function(){var e=this.hls;e.on(D.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(D.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(D.MANIFEST_LOADING,this.onManifestLoading,this),e.on(D.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(D.ERROR,this.onError,this)},r.unregisterListeners=function(){var e=this.hls;e.off(D.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(D.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(D.MANIFEST_LOADING,this.onManifestLoading,this),e.off(D.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(D.ERROR,this.onError,this)},r.doTick=function(){this.onTickEnd()},r.onTickEnd=function(){},r.startLoad=function(e){},r.stopLoad=function(){if(this.state!==Fa){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Fa}},r.pauseBuffering=function(){this.buffering=!1},r.resumeBuffering=function(){this.buffering=!0},r._streamEnded=function(e,t){if(t.live||!this.media)return!1;var r=e.end||0,i=this.config.timelineOffset||0;if(r<=i)return!1;var a=e.buffered;this.config.maxBufferHole&&a&&a.length>1&&(e=wt.bufferedInfo(a,e.start,0));var n=e.nextStart;if(n&&n>i&&n<t.edge)return!1;if(this.media.currentTime<e.start)return!1;var s=t.partList;if(null!=s&&s.length){var o=s[s.length-1];return wt.isBuffered(this.media,o.start+o.duration/2)}var l=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(l)},r.getLevelDetails=function(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details},r.onMediaAttached=function(e,t){var r=this.media=this.mediaBuffer=t.media;Pa(r,"seeking",this.onMediaSeeking),Pa(r,"ended",this.onMediaEnded);var i=this.config;this.levels&&i.autoStartLoad&&this.state===Fa&&this.startLoad(i.startPosition)},r.onMediaDetaching=function(e,t){var r=!!t.transferMedia,i=this.media;if(null!==i){if(i.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),Oa(i,"seeking",this.onMediaSeeking),Oa(i,"ended",this.onMediaEnded),this.keyLoader&&!r&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,r)return this.resetLoadingState(),void this.resetTransmuxer();this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}},r.onManifestLoading=function(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1},r.onError=function(e,t){},r.onManifestLoaded=function(e,t){this.startTimeOffset=t.startTimeOffset},r.onHandlerDestroying=function(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),e.prototype.onHandlerDestroying.call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null},r.onHandlerDestroyed=function(){this.state=Fa,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,e.prototype.onHandlerDestroyed.call(this)},r.loadFragment=function(e,t,r){this.startFragRequested=!0,this._loadFragForPlayback(e,t,r)},r._loadFragForPlayback=function(e,t,r){var i=this;this._doFragLoad(e,t,r,function(e){var t=e.frag;if(i.fragContextChanged(t))return i.warn(t.type+" sn: "+t.sn+(e.part?" part: "+e.part.index:"")+" of "+i.fragInfo(t,!1,e.part)+") was dropped during download."),void i.fragmentTracker.removeFragment(t);t.stats.chunkCount++,i._handleFragmentLoadProgress(e)}).then(function(e){if(e){var t=i.state,r=e.frag;i.fragContextChanged(r)?(t===Ua||!i.fragCurrent&&t===Va)&&(i.fragmentTracker.removeFragment(r),i.state=Na):("payload"in e&&(i.log("Loaded "+r.type+" sn: "+r.sn+" of "+i.playlistLabel()+" "+r.level),i.hls.trigger(D.FRAG_LOADED,e)),i._handleFragmentLoadComplete(e))}}).catch(function(t){i.state!==Fa&&i.state!==Ya&&(i.warn("Frag error: "+((null==t?void 0:t.message)||t)),i.resetFragmentLoading(e))})},r.clearTrackerIfNeeded=function(e){var t,r=this.fragmentTracker;if(r.getState(e)===ga){var i=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,i),n=Math.max(e.duration,a?a.len:this.config.maxBufferLength),s=this.backtrackFragment;(1===(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(n,e.duration))&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===ma&&r.removeFragment(e))},r.checkLiveUpdate=function(e){if(e.updated&&!e.live){var 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)},r.waitForLive=function(e){var t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)},r.flushMainBuffer=function(e,t,r){if(void 0===r&&(r=null),e-t){var i={startOffset:e,endOffset:t,type:r};this.hls.trigger(D.BUFFER_FLUSHING,i)}},r._loadInitSegment=function(e,t){var r=this;this._doFragLoad(e,t).then(function(e){var t=null==e?void 0:e.frag;if(!t||r.fragContextChanged(t)||!r.levels)throw new Error("init load aborted");return e}).then(function(e){var t=r.hls,i=e.frag,a=e.payload,n=i.decryptdata;if(a&&a.byteLength>0&&null!=n&&n.key&&n.iv&&$t(n.method)){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(a),n.key.buffer,n.iv.buffer,Zt(n.method)).catch(function(e){throw t.trigger(D.ERROR,{type:b.MEDIA_ERROR,details:k.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e}).then(function(a){var n=self.performance.now();return t.trigger(D.FRAG_DECRYPTED,{frag:i,payload:a,stats:{tstart:s,tdecrypt:n}}),e.payload=a,r.completeInitSegmentLoad(e)})}return r.completeInitSegmentLoad(e)}).catch(function(t){r.state!==Fa&&r.state!==Ya&&(r.warn(t),r.resetFragmentLoading(e))})},r.completeInitSegmentLoad=function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var t=e.frag.stats;this.state!==Fa&&(this.state=Na),e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()},r.unhandledEncryptionError=function(e,t){var r,i,a=e.tracks;if(a&&!t.encrypted&&(null!=(r=a.audio)&&r.encrypted||null!=(i=a.video)&&i.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){var n=this.media,s=new Error("EME not supported (light build)");return this.warn(s.message),!(!n||n.mediaKeys)&&(this.hls.trigger(D.ERROR,{type:b.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_NO_KEYS,fatal:!0,error:s,frag:t}),this.resetTransmuxer(),!0)}return!1},r.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level},r.fragBufferedComplete=function(e,t){var r=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+this.fragInfo(e,!1,t)+" > buffer:"+(r?Ma(wt.getBuffered(r)):"(detached)")+")"),ae(e)){var i;if(e.type!==O){var a=e.elementaryStreams;if(!Object.keys(a).some(function(e){return!!a[e]}))return void(this.state=Na)}var n=null==(i=this.levels)?void 0:i[e.level];null!=n&&n.fragmentError&&(this.log("Resetting level fragment error count of "+n.fragmentError+" on frag buffered"),n.fragmentError=0)}this.state=Na},r._handleFragmentLoadComplete=function(e){var t=this.transmuxer;if(t){var r=e.frag,i=e.part,a=e.partsLoaded,n=!a||0===a.length||a.some(function(e){return!e}),s=new _a(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!n);t.flush(s)}},r._handleFragmentLoadProgress=function(e){},r._doFragLoad=function(e,t,r,i){var a,n=this;void 0===r&&(r=null),this.fragCurrent=e;var s=t.details;if(!this.levels||!s)throw new Error("frag load aborted, missing level"+(s?"":" detail")+"s");var o=null;if(!e.encrypted||null!=(a=e.decryptdata)&&a.key)e.encrypted||(o=this.keyLoader.loadClear(e,s.encryptedFragments,this.startFragRequested))&&this.log("[eme] blocking frag load until media-keys acquired");else if(this.log("Loading key for "+e.sn+" of ["+s.startSN+"-"+s.endSN+"], "+this.playlistLabel()+" "+e.level),this.state=Ba,this.fragCurrent=e,o=this.keyLoader.load(e).then(function(e){if(!n.fragContextChanged(e.frag))return n.hls.trigger(D.KEY_LOADED,e),n.state===Ba&&(n.state=Na),e}),this.hls.trigger(D.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);var l,u=this.fragPrevious;if(ae(e)&&(!u||e.sn!==u.sn)){var d=this.shouldLoadParts(t.details,e.end);d!==this.loadingParts&&(this.log("LL-Part loading "+(d?"ON":"OFF")+" loading sn "+(null==u?void 0:u.sn)+"->"+e.sn),this.loadingParts=d)}if(r=Math.max(e.start,r||0),this.loadingParts&&ae(e)){var h=s.partList;if(h&&i){r>s.fragmentEnd&&s.fragmentHint&&(e=s.fragmentHint);var f=this.getNextPart(h,e,r);if(f>-1){var c,v=h[f];return e=this.fragCurrent=v.fragment,this.log("Loading "+e.type+" sn: "+e.sn+" part: "+v.index+" ("+f+"/"+(h.length-1)+") of "+this.fragInfo(e,!1,v)+") cc: "+e.cc+" ["+s.startSN+"-"+s.endSN+"], target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=v.start+v.duration,this.state=Ua,c=o?o.then(function(r){return!r||n.fragContextChanged(r.frag)?null:n.doFragPartsLoad(e,v,t,i)}).catch(function(e){return n.handleFragLoadError(e)}):this.doFragPartsLoad(e,v,t,i).catch(function(e){return n.handleFragLoadError(e)}),this.hls.trigger(D.FRAG_LOADING,{frag:e,part:v,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!e.url||this.loadedEndOfParts(h,r))return Promise.resolve(null)}}if(ae(e)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @"+r.toFixed(2)+" Check buffer at sn: "+e.sn+" loaded parts: "+(null==(l=s.partList)?void 0:l.filter(function(e){return e.loaded}).map(function(e){return"["+e.start+"-"+e.end+"]"}))),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log("Loading "+e.type+" sn: "+e.sn+" of "+this.fragInfo(e,!1)+") cc: "+e.cc+" ["+s.startSN+"-"+s.endSN+"], target: "+parseFloat(r.toFixed(3))),L(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Ua;var g,m=this.config.progressive;return g=m&&o?o.then(function(t){return!t||n.fragContextChanged(t.frag)?null:n.fragmentLoader.load(e,i)}).catch(function(e){return n.handleFragLoadError(e)}):Promise.all([this.fragmentLoader.load(e,m?i:void 0),o]).then(function(e){var t=e[0];return!m&&i&&i(t),t}).catch(function(e){return n.handleFragLoadError(e)}),this.hls.trigger(D.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):g},r.doFragPartsLoad=function(e,t,r,i){var a=this;return new Promise(function(n,s){var o,l=[],u=null==(o=r.details)?void 0:o.partList,d=function(t){a.fragmentLoader.loadPart(e,t,i).then(function(i){l[t.index]=i;var s=i.part;a.hls.trigger(D.FRAG_LOADED,i);var o=br(r.details,e.sn,t.index+1)||kr(u,e.sn,t.index+1);if(!o)return n({frag:e,part:s,partsLoaded:l});d(o)}).catch(s)};d(t)})},r.handleFragLoadError=function(e){if("data"in e){var t=e.data;t.frag&&t.details===k.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===b.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(D.ERROR,t)}else this.hls.trigger(D.ERROR,{type:b.OTHER_ERROR,details:k.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null},r._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(t&&this.state===Va){var r=t.frag,i=t.part,a=t.level,n=self.performance.now();r.stats.parsing.end=n,i&&(i.stats.parsing.end=n);var s=this.getLevelDetails(),o=s&&r.sn>s.endSN||this.shouldLoadParts(s,r.end);o!==this.loadingParts&&(this.log("LL-Part loading "+(o?"ON":"OFF")+" after parsing segment ending @"+r.end.toFixed(2)),this.loadingParts=o),this.updateLevelTiming(r,i,a,e.partial)}else this.fragCurrent||this.state===Fa||this.state===Ya||(this.state=Na)},r.shouldLoadParts=function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var r,i,a=e.partList[0];if(a.fragment.type===O)return!1;if(t>=a.end+((null==(r=e.fragmentHint)?void 0:r.duration)||0)&&(this.hls.hasEnoughToStart?(null==(i=this.media)?void 0:i.currentTime)||this.lastCurrentTime:this.getLoadPosition())>a.start-a.fragment.duration)return!0}}return!1},r.getCurrentContext=function(e){var t=this.levels,r=this.fragCurrent,i=e.level,a=e.sn,n=e.part;if(null==t||!t[i])return this.warn("Levels object was unset while buffering fragment "+a+" of "+this.playlistLabel()+" "+i+". The current chunk will not be buffered."),null;var s=t[i],o=s.details,l=n>-1?br(o,a,n):null,u=l?l.fragment:Ar(o,a,r);return u?(r&&r!==u&&(u.stats=r.stats),{frag:u,part:l,level:s}):null},r.bufferFragmentData=function(e,t,r,i,a){if(this.state===Va){var n=e.data1,s=e.data2,o=n;if(s&&(o=be(n,s)),o.length){var l=this.initPTS[t.cc],u=l?-l.baseTime/l.timescale:void 0,d={type:e.type,frag:t,part:r,chunkMeta:i,offset:u,parent:t.type,data:o};if(this.hls.trigger(D.BUFFER_APPENDING,d),e.dropped&&e.independent&&!r){if(a)return;this.flushBufferGap(t)}}}},r.flushBufferGap=function(e){var t=this.media;if(t)if(wt.isBuffered(t,t.currentTime)){var r=t.currentTime,i=wt.bufferInfo(t,r,0),a=e.duration,n=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),s=Math.max(Math.min(e.start-n,i.end-n),r+n);e.start-s>n&&this.flushMainBuffer(s,e.start)}else this.flushMainBuffer(0,e.start)},r.getFwdBufferInfo=function(e,t){var r,i=this.getLoadPosition();if(!L(i))return null;var a=this.lastCurrentTime>i||null!=(r=this.media)&&r.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,i,t,a)},r.getFwdBufferInfoAtPos=function(e,t,r,i){var a=wt.bufferInfo(e,t,i);if(0===a.len&&void 0!==a.nextStart){var n=this.fragmentTracker.getBufferedFrag(t,r);if(n&&(a.nextStart<=n.end||n.gap)){var s=Math.max(Math.min(a.nextStart,n.end)-t,i);return wt.bufferInfo(e,t,s)}}return a},r.getMaxBufferLength=function(e){var t,r=this.config;return t=e?Math.max(8*r.maxBufferSize/e,r.maxBufferLength):r.maxBufferLength,Math.min(t,r.maxMaxBufferLength)},r.reduceMaxBufferLength=function(e,t){var r=this.config,i=Math.max(Math.min(e-t,r.maxBufferLength),t),a=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return a>=i&&(r.maxMaxBufferLength=a,this.warn("Reduce max buffer length to "+a+"s"),!0)},r.getAppendedFrag=function(e,t){void 0===t&&(t=w);var r=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return r&&"fragment"in r?r.fragment:r},r.getNextFragment=function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var a=this.config,n=r[0].start,s=a.lowLatencyMode&&!!t.partList,o=null;if(t.live){var l=a.initialLiveManifestSize;if(i<l)return this.warn("Not enough fragments to start playback (have: "+i+", need: "+l+")"),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<n){var u;s&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),o=this.getInitialLiveFragment(t);var d=this.hls.startPosition,h=this.hls.liveSyncPosition,f=o?(-1!==d&&d>=n?d:h)||o.start:e;this.log("Setting startPosition to "+f+" to match start frag at live edge. mainStart: "+d+" liveSyncPosition: "+h+" frag.start: "+(null==(u=o)?void 0:u.start)),this.startPosition=this.nextLoadPosition=f}}else e<=n&&(o=r[0]);if(!o){var c=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,c,t)}var v=this.filterReplacedPrimary(o,t);if(!v&&o){var g=o.sn-t.startSN;v=this.filterReplacedPrimary(r[g+1]||null,t)}return this.mapToInitFragWhenRequired(v)},r.isLoopLoading=function(e,t){var r=this.fragmentTracker.getState(e);return(r===pa||r===ma&&!!e.gap)&&this.nextLoadPosition>t},r.getNextFragmentLoopLoading=function(e,t,r,i,a){var n=null;if(e.gap&&(n=this.getNextFragment(this.nextLoadPosition,t))&&!n.gap&&r.nextStart){var s=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i,0);if(null!==s&&r.len+s.len>=a){var o=n.sn;return this.loopSn!==o&&(this.log('buffer full after gaps in "'+i+'" playlist starting at sn: '+o),this.loopSn=o),null}}return this.loopSn=void 0,n},r.filterReplacedPrimary=function(e,t){return e?(this.config,e):e},r.mapToInitFragWhenRequired=function(e){return null==e||!e.initSegment||e.initSegment.data||this.bitrateTest?e:e.initSegment},r.getNextPart=function(e,t,r){for(var i=-1,a=!1,n=!0,s=0,o=e.length;s<o;s++){var l=e[s];if(n=n&&!l.independent,i>-1&&r<l.start)break;var u=l.loaded;u?i=-1:(a||(l.independent||n)&&l.fragment===t)&&(l.fragment!==t&&this.warn("Need buffer at "+r+" but next unloaded part starts at "+l.start),i=s),a=u}return i},r.loadedEndOfParts=function(e,t){for(var r,i=e.length;i--;){if(!(r=e[i]).loaded)return!1;if(t>r.start)return!0}return!1},r.getInitialLiveFragment=function(e){var t=e.fragments,r=this.fragPrevious,i=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=function(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!L(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;for(var i=0;i<e.length;++i){var a=e[i];if(ft(t,r,a))return a}return null}(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var a=r.sn+1;if(a>=e.startSN&&a<=e.endSN){var n=t[a-e.startSN];r.cc===n.cc&&(i=n,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=function(e,t,r){if(e&&e.startCC<=t&&e.endCC>=t){var i,a=e.fragments,n=e.fragmentHint;return n&&(a=a.concat(n)),ut(a,function(e){return e.cc<t?1:e.cc>t?-1:(i=e,e.end<=r?1:e.start>r?-1:0)}),i||null}return null}(e,r.cc,r.end),i&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn))}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i},r.getFragmentAtPosition=function(e,t,r){var i,a,n=this.config,s=this.fragPrevious,o=r.fragments,l=r.endSN,u=r.fragmentHint,d=n.maxFragLookUpTolerance,h=r.partList,f=!!(this.loadingParts&&null!=h&&h.length&&u);if(f&&!this.bitrateTest&&h[h.length-1].fragment.sn===u.sn&&(o=o.concat(u),l=u.sn),i=e<t?dt(s,o,e,e<this.lastCurrentTime||e>t-d||null!=(a=this.media)&&a.paused||!this.startFragRequested?0:d):o[o.length-1]){var c=i.sn-r.startSN,v=this.fragmentTracker.getState(i);if((v===pa||v===ma&&i.gap)&&(s=i),s&&i.sn===s.sn&&(!f||h[0].fragment.sn>i.sn||!r.live)&&i.level===s.level){var g=o[c+1];i=i.sn<l&&this.fragmentTracker.getState(g)!==pa?g:null}}return i},r.alignPlaylists=function(e,t,r){var i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;var a=e.fragmentStart,n=!t,s=e.alignedSliding&&L(a);if(n||!s&&!a){wa(r,e);var o=e.fragmentStart;return this.log("Live playlist sliding: "+o.toFixed(2)+" start-sn: "+(t?t.startSN:"na")+"->"+e.startSN+" fragments: "+i),o}return a},r.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},r.setStartPosition=function(e,t){var r=this.startPosition;r<t&&(r=-1);var i=this.timelineOffset;if(-1===r){var a=null!==this.startTimeOffset,n=a?this.startTimeOffset:e.startTimeOffset;null!==n&&L(n)?(r=t+n,n<0&&(r+=e.edge),r=Math.min(Math.max(t,r),t+e.totalduration),this.log("Setting startPosition to "+r+" for start time offset "+n+" found in "+(a?"multivariant":"media")+" playlist"),this.startPosition=r):e.live?(r=this.hls.liveSyncPosition||t,this.log("Setting startPosition to -1 to start at live edge "+r),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=r=0),this.lastCurrentTime=r+i}this.nextLoadPosition=r+i},r.getLoadPosition=function(){var e,t=this.media,r=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?r=t.currentTime:this.nextLoadPosition>=0&&(r=this.nextLoadPosition),r},r.handleFragLoadAborted=function(e,t){this.transmuxer&&e.type===this.playlistType&&ae(e)&&e.stats.aborted&&(this.log("Fragment "+e.sn+(t?" part "+t.index:"")+" of "+this.playlistLabel()+" "+e.level+" was aborted"),this.resetFragmentLoading(e))},r.resetFragmentLoading=function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===Ga)||(this.state=Na)},r.onFragmentOrKeyLoadError=function(e,t){var r;if(t.chunkMeta&&!t.frag){var i=this.getCurrentContext(t.chunkMeta);i&&(t.frag=i.frag)}var a=t.frag;if(a&&a.type===e&&this.levels)if(this.fragContextChanged(a)){var n;this.warn("Frag load error must match current frag to retry "+a.url+" > "+(null==(n=this.fragCurrent)?void 0:n.url))}else{var s=t.details===k.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(a,!0);var o=t.errorAction;if(o){var l=o.action,u=o.flags,d=o.retryCount,h=void 0===d?0:d,f=o.retryConfig,c=!!f,v=c&&l===At,g=c&&!o.resolved&&u===kt,m=null==(r=this.hls.latestLevelDetails)?void 0:r.live;if(!v&&g&&ae(a)&&!a.endList&&m&&!gt(t))this.resetFragmentErrors(e),this.treatAsGap(a),o.resolved=!0;else if((v||g)&&h<f.maxNumRetry){var p,y=Tt(null==(p=t.response)?void 0:p.code),E=pt(f,h);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+E,this.state=Ga,o.resolved=!0,y)return this.log("Waiting for connection (offline)"),this.retryDate=1/0,void(t.reason="offline");this.warn("Fragment "+a.sn+" of "+e+" "+a.level+" errored with "+t.details+", retrying loading "+(h+1)+"/"+f.maxNumRetry+" in "+E+"ms")}else if(f){if(this.resetFragmentErrors(e),!(h<f.maxNumRetry))return void this.warn(t.details+" reached or exceeded max retry ("+h+")");s||l===Rt||(o.resolved=!0)}else this.state=l===Lt?ja:Ya;this.tickImmediate()}else this.state=Ya}},r.checkRetryDate=function(){var e=self.performance.now(),t=this.retryDate,r=t===1/0;(!t||e>=t||r&&!Tt(0))&&(r&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=Na)},r.reduceLengthAndFlushBuffer=function(e){if(this.state===Va||this.state===Ha){var t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),a=i&&i.len>.5;a&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);var n=!a;return n&&this.warn("Buffer full error while media.currentTime ("+this.getLoadPosition()+") is not buffered, flush "+r+" buffer"),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),n}return!1},r.resetFragmentErrors=function(e){e===P&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==Fa&&(this.state=Na)},r.afterBufferFlushed=function(e,t,r){if(e){var i=wt.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===Ka&&this.resetLoadingState()}},r.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==Fa&&(this.state=Na)},r.resetStartWhenNotLoaded=function(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var e=this.levelLastLoaded,t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},r.resetWhenMissingContext=function(e){this.log("Loading context changed while buffering sn "+e.sn+" of "+this.playlistLabel()+" "+(-1===e.level?"<removed>":e.level)+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()},r.removeUnbufferedFrags=function(e){void 0===e&&(e=0),this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)},r.updateLevelTiming=function(e,t,r,i){var a=this,n=r.details;if(n){var s;if(!Object.keys(e.elementaryStreams).reduce(function(t,s){var o=e.elementaryStreams[s];if(o){var l=o.endPTS-o.startPTS;if(l<=0)return a.warn("Could not parse fragment "+e.sn+" "+s+" duration reliably ("+l+")"),t||!1;var u=i?0:Er(n,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS,a);return a.hls.trigger(D.LEVEL_PTS_UPDATED,{details:n,level:r,drift:u,type:s,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t},!1)&&(0===r.fragmentError&&this.treatAsGap(e,r),null===(null==(s=this.transmuxer)?void 0:s.error))){var o=new Error("Found no media in fragment "+e.sn+" of "+this.playlistLabel()+" "+e.level+" resetting transmuxer to fallback to playlist timing");if(this.warn(o.message),this.hls.trigger(D.ERROR,{type:b.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,fatal:!1,error:o,frag:e,reason:"Found no media in msn "+e.sn+" of "+this.playlistLabel()+' "'+r.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=Ha,this.log("Parsed "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+this.fragInfo(e,!1,t)+")"),this.hls.trigger(D.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")},r.playlistLabel=function(){return this.playlistType===w?"level":"track"},r.fragInfo=function(e,t,r){var i,a;return void 0===t&&(t=!0),this.playlistLabel()+" "+e.level+" ("+(r?"part":"frag")+":["+(null!=(i=t&&!r?e.startPTS:(r||e).start)?i:NaN).toFixed(3)+"-"+(null!=(a=t&&!r?e.endPTS:(r||e).end)?a:NaN).toFixed(3)+"]"+(r&&"main"===e.type?"INDEPENDENT="+(r.independent?"YES":"NO"):"")},r.treatAsGap=function(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)},r.resetTransmuxer=function(){var e;null==(e=this.transmuxer)||e.reset()},r.recoverWorkerError=function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())},i(t,[{key:"startPositionValue",get:function(){var e=this.nextLoadPosition,t=this.startPosition;return-1===t&&e?e:t}},{key:"bufferingEnabled",get:function(){return this.buffering}},{key:"inFlightFrag",get:function(){return{frag:this.fragCurrent,state:this.state}}},{key:"timelineOffset",get:function(){var e,t=this.config.timelineOffset;return t?(null==(e=this.getLevelDetails())?void 0:e.appliedTimelineOffset)||t:0}},{key:"primaryPrefetch",get:function(){return this.config,!1}},{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}])}(Da),qa=function(e){function t(t,r){var i;return(i=e.call(this,"gap-controller",t.logger)||this).hls=void 0,i.fragmentTracker=void 0,i.media=null,i.mediaSource=void 0,i.nudgeRetry=0,i.stallReported=!1,i.stalled=null,i.moved=!1,i.seeking=!1,i.buffered={},i.lastCurrentTime=0,i.ended=0,i.waiting=0,i.onMediaPlaying=function(){i.ended=0,i.waiting=0},i.onMediaWaiting=function(){var e;null!=(e=i.media)&&e.seeking||(i.waiting=self.performance.now(),i.tick())},i.onMediaEnded=function(){var e;i.hls&&(i.ended=(null==(e=i.media)?void 0:e.currentTime)||1,i.hls.trigger(D.MEDIA_ENDED,{stalled:!1}))},i.hls=t,i.fragmentTracker=r,i.registerListeners(),i}o(t,e);var r=t.prototype;return r.registerListeners=function(){var e=this.hls;e&&(e.on(D.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(D.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(D.BUFFER_APPENDED,this.onBufferAppended,this))},r.unregisterListeners=function(){var e=this.hls;e&&(e.off(D.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(D.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(D.BUFFER_APPENDED,this.onBufferAppended,this))},r.destroy=function(){e.prototype.destroy.call(this),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0},r.onMediaAttached=function(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;var r=this.media=t.media;Pa(r,"playing",this.onMediaPlaying),Pa(r,"waiting",this.onMediaWaiting),Pa(r,"ended",this.onMediaEnded)},r.onMediaDetaching=function(e,t){this.clearInterval();var r=this.media;r&&(Oa(r,"playing",this.onMediaPlaying),Oa(r,"waiting",this.onMediaWaiting),Oa(r,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0},r.onBufferAppended=function(e,t){this.buffered=t.timeRanges},r.tick=function(){var e;if(null!=(e=this.media)&&e.readyState&&this.hasBuffered){var t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}},r.poll=function(e,t){var r,i,a=null==(r=this.hls)?void 0:r.config;if(a){var n=this.media;if(n){var s=n.seeking,o=this.seeking&&!s,l=!this.seeking&&s,u=n.paused&&!s||n.ended||0===n.playbackRate;if(this.seeking=s,e!==t)return t&&(this.ended=0),this.moved=!0,s||(this.nudgeRetry=0,a.nudgeOnVideoHole&&!u&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(l||o)o&&this.stallResolved(e);else{if(u)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&n.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(D.MEDIA_ENDED,{stalled:!1})));if(wt.getBuffered(n).length){var d=wt.bufferInfo(n,e,0),h=d.nextStart||0,f=this.fragmentTracker;if(s&&f&&this.hls){var c=Xa(this.hls.inFlightFragments,e),v=d.len>2,g=!h||c||h-e>2&&!f.getPartialFragment(e);if(v||g)return;this.moved=!1}var m=null==(i=this.hls)?void 0:i.latestLevelDetails;if(!this.moved&&null!==this.stalled&&f){if(!(d.len>0||h))return;var p=Math.max(h,d.start||0)-e,y=null!=m&&m.live?2*m.targetduration:2,E=Qa(e,f);if(p>0&&(p<=y||E))return void(n.paused||this._trySkipBufferHole(E))}var T=a.detectStallWithCurrentTimeMs,S=self.performance.now(),L=this.waiting,R=this.stalled;if(null===R){if(!(L>0&&S-L<T))return void(this.stalled=S);R=this.stalled=L}var A=S-R;if(!s&&(A>=T||L)&&this.hls){var b;if("ended"===(null==(b=this.mediaSource)?void 0:b.readyState)&&(null==m||!m.live)&&Math.abs(e-((null==m?void 0:m.edge)||0))<1){if(this.ended)return;return this.ended=e||1,void this.hls.trigger(D.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media||!this.hls)return}var k=wt.bufferInfo(n,e,a.maxBufferHole);this._tryFixBufferStall(k,A,e)}else this.nudgeRetry=0}}}},r.stallResolved=function(e){var t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){var r=self.performance.now()-t;this.log("playback not stuck anymore @"+e+", after "+Math.round(r)+"ms"),this.stallReported=!1,this.waiting=0,this.hls.trigger(D.STALL_RESOLVED,{})}},r.nudgeOnVideoHole=function(e,t){var r,i=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(r=this.buffered.audio)&&r.length&&i&&i.length>1&&e>i.end(0)){var a=wt.bufferedInfo(wt.timeRangesToArray(this.buffered.audio),e,0);if(a.len>1&&t>=a.start){var n=wt.timeRangesToArray(i),s=wt.bufferedInfo(n,t,0).bufferedIndex;if(s>-1&&s<n.length-1){var o=wt.bufferedInfo(n,e,0).bufferedIndex,l=n[s].end,u=n[s+1].start;if((-1===o||o>s)&&u-l<1&&e-l<2){var d=new Error("nudging playhead to flush pipeline after video hole. currentTime: "+e+" hole: "+l+" -> "+u+" buffered index: "+o);this.warn(d.message),this.media.currentTime+=1e-6;var h=Qa(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);var f=wt.bufferInfo(this.media,e,0);this.hls.trigger(D.ERROR,{type:b.MEDIA_ERROR,details:k.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:d,reason:d.message,frag:h,buffer:f.len,bufferInfo:f})}}}}},r._tryFixBufferStall=function(e,t,r){var i,a,n=this.fragmentTracker,s=this.media,o=null==(i=this.hls)?void 0:i.config;if(s&&n&&o){var l=null==(a=this.hls)?void 0:a.latestLevelDetails,u=Qa(r,n);if((u||null!=l&&l.live&&r<l.fragmentStart)&&(this._trySkipBufferHole(u)||!this.media))return;var d=e.buffered,h=this.adjacentTraversal(e,r);(d&&d.length>1&&e.len>o.maxBufferHole||e.nextStart&&(e.nextStart-r<o.maxBufferHole||h))&&(t>1e3*o.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}},r.adjacentTraversal=function(e,t){var r=this.fragmentTracker,i=e.nextStart;if(r&&i){var a=r.getFragAtPos(t,w),n=r.getFragAtPos(i,w);if(a&&n)return n.sn-a.sn<2}return!1},r._reportStall=function(e){var t=this.hls,r=this.media,i=this.stallReported,a=this.stalled;if(!i&&null!==a&&r&&t){this.stallReported=!0;var n=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+it(e)+")");this.warn(n.message),t.trigger(D.ERROR,{type:b.MEDIA_ERROR,details:k.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len,bufferInfo:e,stalled:{start:a}})}},r._trySkipBufferHole=function(e){var t,r=this.fragmentTracker,i=this.media,a=null==(t=this.hls)?void 0:t.config;if(!i||!r||!a)return 0;var n=i.currentTime,s=wt.bufferInfo(i,n,0),o=n<s.start?s.start:s.nextStart;if(o&&this.hls){var l=s.len<=a.maxBufferHole,u=s.len>0&&s.len<1&&i.readyState<3,d=o-n;if(d>0&&(l||u)){if(d>a.maxBufferHole){var h=!1;if(0===n){var f=r.getAppendedFrag(0,w);f&&o<f.end&&(h=!0)}if(!h&&e){var c;if(null==(c=this.hls.loadLevelObj)||!c.details)return 0;if(Xa(this.hls.inFlightFragments,o))return 0;for(var v=!1,g=e.end;g<o;){var m=Qa(g,r);if(!m){v=!0;break}g+=m.duration}if(v)return 0}}var p=Math.max(o+.05,n+.1);if(this.warn("skipping hole, adjusting currentTime from "+n+" to "+p),this.moved=!0,i.currentTime=p,null==e||!e.gap){var y=new Error("fragment loaded with buffer holes, seeking from "+n+" to "+p),E={type:b.MEDIA_ERROR,details:k.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:y,reason:y.message,buffer:s.len,bufferInfo:s};e&&("fragment"in e?E.part=e:E.frag=e),this.hls.trigger(D.ERROR,E)}return p}}return 0},r._tryNudgeBuffer=function(e){var t=this.hls,r=this.media,i=this.nudgeRetry,a=null==t?void 0:t.config;if(!r||!a)return 0;var n=r.currentTime;if(this.nudgeRetry++,i<a.nudgeMaxRetry){var s=n+(i+1)*a.nudgeOffset,o=new Error("Nudging 'currentTime' from "+n+" to "+s);this.warn(o.message),r.currentTime=s,t.trigger(D.ERROR,{type:b.MEDIA_ERROR,details:k.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1,buffer:e.len,bufferInfo:e})}else{var l=new Error("Playhead still not moving while enough data buffered @"+n+" after "+a.nudgeMaxRetry+" nudges");this.error(l.message),t.trigger(D.ERROR,{type:b.MEDIA_ERROR,details:k.BUFFER_STALLED_ERROR,error:l,fatal:!0,buffer:e.len,bufferInfo:e})}},i(t,[{key:"hasBuffered",get:function(){return Object.keys(this.buffered).length>0}}])}(Da);function Xa(e,t){var r=za(e.main);if(r&&r.start<=t)return r;var i=za(e.audio);return i&&i.start<=t?i:null}function za(e){if(!e)return null;switch(e.state){case Na:case Fa:case Ka:case Ya:return null}return e.frag}function Qa(e,t){return t.getAppendedFrag(e,w)||t.getPartialFragment(e)}function $a(e,t,r,i){var a=e.mode;if("disabled"===a&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var n=function(e,t,r){var i=[],a=function(e,t){if(t<=e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;for(var i,a=0,n=r;a<=n;)if(t<e[i=Math.floor((n+a)/2)].startTime)n=i-1;else{if(!(t>e[i].startTime&&a<r))return i;a=i+1}return e[a].startTime-t<t-e[n].startTime?a:n}(e,t);if(a>-1)for(var n=a,s=e.length;n<s;n++){var o=e[n];if(o.startTime>=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}(e.cues,t,r),s=0;s<n.length;s++)i&&!i(n[s])||e.removeCue(n[s]);"disabled"===a&&(e.mode=a)}function Za(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function Ja(e,t,r,i,a){var n=new e(t,r,"");try{n.value=i,a&&(n.type=a)}catch(s){n=new e(t,r,it(a?d({type:a},i):i))}return n}var en=function(){var e=Za();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}(),tn=function(){function e(e){var t=this;this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=function(){t.hls&&t.hls.trigger(D.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}var t=e.prototype;return t.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null},t._registerListeners=function(){var e=this.hls;e&&(e.on(D.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(D.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(D.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(D.MANIFEST_LOADING,this.onManifestLoading,this),e.on(D.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(D.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(D.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(D.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))},t._unregisterListeners=function(){var e=this.hls;e&&(e.off(D.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(D.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(D.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(D.MANIFEST_LOADING,this.onManifestLoading,this),e.off(D.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(D.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(D.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(D.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))},t.onMediaAttaching=function(e,t){this.media=t.media},t.onMediaAttached=function(){var e,t=null==(e=this.hls)?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)},t.onMediaDetaching=function(e,t){this.media=null,t.transferMedia||(this.id3Track&&(this.id3Track.remove(),this.id3Track=null),this.dateRangeCuesAppended={})},t.onManifestLoading=function(){this.dateRangeCuesAppended={}},t.createTrack=function(e){return r="metadata",i="id3",a="hidden",(n=(t=e).ownerDocument.createElement("track")).kind=r,n.label=i,n.src="data:,WEBVTT",n.track.mode=a,t.appendChild(n),n;var t,r,i,a,n},t.onFragParsingMetadata=function(e,t){if(this.media&&this.hls){var r=this.hls.config,i=r.enableEmsgMetadataCues,a=r.enableID3MetadataCues;if(i||a){var n=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var s=Za();if(s)for(var o=0;o<n.length;o++){var l=n[o].type;if((l!==ri.emsg||i)&&a){var u=Zr(n[o].data),d=n[o].pts,h=d+n[o].duration;h>en&&(h=en),h-d<=0&&(h=d+.25);for(var f=0;f<u.length;f++){var c=u[f];if(!Jr(c)){this.updateId3CueEnds(d,l);var v=Ja(s,d,h,c,l);v&&this.id3Track.track.addCue(v)}}}}}}},t.updateId3CueEnds=function(e,t){var r,i=null==(r=this.id3Track)?void 0:r.track.cues;if(i)for(var a=i.length;a--;){var n=i[a];n.type===t&&n.startTime<e&&n.endTime===en&&(n.endTime=e)}},t.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,a=t.type,n=this.id3Track,s=this.hls;if(s){var o,l=s.config,u=l.enableEmsgMetadataCues,d=l.enableID3MetadataCues;n&&(u||d)&&(o="audio"===a?function(e){return e.type===ri.audioId3&&d}:"video"===a?function(e){return e.type===ri.emsg&&u}:function(e){return e.type===ri.audioId3&&d||e.type===ri.emsg&&u},$a(n.track,r,i,o))}},t.onLevelUpdated=function(e,t){var r=t.details;this.updateDateRangeCues(r,!0)},t.onLevelPtsUpdated=function(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)},t.updateDateRangeCues=function(e,t){var r=this;if(this.hls&&this.media){var i=this.hls.config;i.assetPlayerId,i.timelineOffset;var a=i.enableDateRangeMetadataCues;if(i.interstitialsController,a){var n=Za();if(e.hasProgramDateTime){var s,o=this.id3Track,l=e.dateRanges,u=Object.keys(l),d=this.dateRangeCuesAppended;if(o&&t)if(null!=(s=o.track.cues)&&s.length)for(var h=Object.keys(d).filter(function(e){return!u.includes(e)}),f=function(){var e,t=h[c],i=null==(e=d[t])?void 0:e.cues;delete d[t],i&&Object.keys(i).forEach(function(e){var t=i[e];if(t){t.removeEventListener("enter",r.onEventCueEnter);try{o.track.removeCue(t)}catch(e){}}})},c=h.length;c--;)f();else d=this.dateRangeCuesAppended={};var v=e.fragments[e.fragments.length-1];if(0!==u.length&&L(null==v?void 0:v.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var g=function(){var e=u[m],t=l[e],i=t.startTime,a=d[e],s=(null==a?void 0:a.cues)||{},o=(null==a?void 0:a.durationKnown)||!1,h=en,f=t.duration;if(t.endDate&&null!==f)h=i+f,o=!0;else if(t.endOnNext&&!o){var c=u.reduce(function(e,r){if(r!==t.id){var i=l[r];if(i.class===t.class&&i.startDate>t.startDate&&(!e||t.startDate<e.startDate))return i}return e},null);c&&(h=c.startTime,o=!0)}for(var v=Object.keys(t.attr),g=0;g<v.length;g++){var p=v[g];if(Kt(p)){var y=s[p];if(y)!o||null!=a&&a.durationKnown?Math.abs(y.startTime-i)>.01&&(y.startTime=i,y.endTime=h):y.endTime=h;else if(n){var E=t.attr[p];Yt(p)&&(E=Z(E));var T=Ja(n,i,h,{key:p,data:E},ri.dateRange);T&&(T.id=e,r.id3Track.track.addCue(T),s[p]=T)}}}d[e]={cues:s,dateRange:t,durationKnown:o}},m=0;m<u.length;m++)g()}}}}},e}(),rn=function(){function e(e){var t=this;this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=function(){var e=t.media,r=t.levelDetails;if(e&&r){t.currentTime=e.currentTime;var i=t.computeLatency();if(null!==i){t._latency=i;var a=t.config,n=a.lowLatencyMode,s=a.maxLiveSyncPlaybackRate;if(n&&1!==s&&r.live){var o=t.targetLatency;if(null!==o){var l=i-o;if(l<Math.min(t.maxLatency,o+r.targetduration)&&l>.05&&t.forwardBufferLength>1){var u=Math.min(2,Math.max(1,s)),d=Math.round(2/(1+Math.exp(-.75*l-t.edgeStalled))*20)/20,h=Math.min(u,Math.max(1,d));t.changeMediaPlaybackRate(e,h)}else 1!==e.playbackRate&&0!==e.playbackRate&&t.changeMediaPlaybackRate(e,1)}}}}},this.hls=e,this.config=e.config,this.registerListeners()}var t=e.prototype;return t.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null},t.registerListeners=function(){var e=this.hls;e&&(e.on(D.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(D.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(D.MANIFEST_LOADING,this.onManifestLoading,this),e.on(D.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(D.ERROR,this.onError,this))},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(D.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(D.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(D.MANIFEST_LOADING,this.onManifestLoading,this),e.off(D.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(D.ERROR,this.onError,this))},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)},t.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)},t.onManifestLoading=function(){this._latency=null,this.stallCount=0},t.onLevelUpdated=function(e,t){var r=t.details;r.advanced&&this.onTimeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)},t.onError=function(e,t){var r;t.details===k.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(r=this.levelDetails)&&r.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))},t.changeMediaPlaybackRate=function(e,t){var r,i;e.playbackRate!==t&&(null==(r=this.hls)||r.logger.debug("[latency-controller]: latency="+this.latency.toFixed(3)+", targetLatency="+(null==(i=this.targetLatency)?void 0:i.toFixed(3))+", forwardBufferLength="+this.forwardBufferLength.toFixed(3)+": adjusting playback rate from "+e.playbackRate+" to "+t),e.playbackRate=t)},t.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},t.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},i(e,[{key:"levelDetails",get:function(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}},{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config;if(void 0!==e.liveMaxLatencyDuration)return e.liveMaxLatencyDuration;var t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e||null===this.hls)return null;var t=e.holdBack,r=e.partHoldBack,i=e.targetduration,a=this.config,n=a.liveSyncDuration,s=a.liveSyncDurationCount,o=a.lowLatencyMode,l=this.hls.userConfig,u=o&&r||t;(this._targetLatencyUpdated||l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==n?n:s*i);var d=i;return u+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,d)},set:function(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;var r=this.levelDetails;if(null===r)return null;var i=r.edge,a=e-t-this.edgeStalled,n=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(n,a),s)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}])}(),an=function(e){function t(t,r){var i;return(i=e.call(this,r,t.logger)||this).hls=void 0,i.canLoad=!1,i.timer=-1,i.hls=t,i}o(t,e);var r=t.prototype;return r.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},r.clearTimer=function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)},r.startLoad=function(){this.canLoad=!0,this.loadPlaylist()},r.stopLoad=function(){this.canLoad=!1,this.clearTimer()},r.switchParams=function(e,t,r){var i=null==t?void 0:t.renditionReports;if(i){for(var a=-1,n=0;n<i.length;n++){var s=i[n],o=void 0;try{o=new self.URL(s.URI,t.url).href}catch(e){this.warn("Could not construct new URL for Rendition Report: "+e),o=s.URI||""}if(o===e){a=n;break}o===e.substring(0,o.length)&&(a=n)}if(-1!==a){var l=i[a],u=parseInt(l["LAST-MSN"])||t.lastPartSn,d=parseInt(l["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){var h=Math.min(t.age-t.partTarget,t.targetduration);d>=0&&h>t.partTarget&&(d+=1)}var f=r&&Ze(r);return new Je(u,d>=0?d:void 0,f)}}},r.loadPlaylist=function(e){this.clearTimer()},r.loadingPlaylist=function(e,t){this.clearTimer()},r.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},r.getUrlWithDirectives=function(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}return e},r.playlistLoaded=function(e,t,r){var i=t.details,a=t.stats,n=self.performance.now(),s=a.loading.first?Math.max(0,n-a.loading.first):0;i.advancedDateTime=Date.now()-s;var o=this.hls.config.timelineOffset;if(o!==i.appliedTimelineOffset){var l=Math.max(o||0,0);i.appliedTimelineOffset=l,i.fragments.forEach(function(e){e.setStart(e.playlistOffset+l)})}if(i.live||null!=r&&r.live){var u="levelInfo"in t?t.levelInfo:t.track;if(i.reloaded(r),r&&i.fragments.length>0){Tr(r,i,this);var d=i.playlistParsingError;if(d){this.warn(d);var h=this.hls;if(!h.config.ignorePlaylistParsingErrors){var f,c=t.networkDetails;return void h.trigger(D.ERROR,{type:b.NETWORK_ERROR,details:k.LEVEL_PARSING_ERROR,fatal:!1,url:i.url,error:d,reason:d.message,level:t.level||void 0,parent:null==(f=i.fragments[0])?void 0:f.type,networkDetails:c,stats:a})}i.playlistParsingError=null}}-1===i.requestScheduled&&(i.requestScheduled=a.loading.start);var v,g=this.hls.mainForwardBufferInfo,m=g?g.end-g.len:0,p=Rr(i,1e3*(i.edge-m));if(i.requestScheduled+p<n?i.requestScheduled=n:i.requestScheduled+=p,this.log("live playlist "+e+" "+(i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED")),!this.canLoad||!i.live)return;var y=void 0,E=void 0;if(i.canBlockReload&&i.endSN&&i.advanced){var T=this.hls.config.lowLatencyMode,S=i.lastPartSn,L=i.endSN,R=i.lastPartIndex,A=S===L;-1!==R?A?(y=L+1,E=T?0:R):(y=S,E=T?R+1:i.maxPartIndex):y=L+1;var _=i.age,I=_+i.ageHeader,C=Math.min(I-i.partTarget,1.5*i.targetduration);if(C>0){if(I>3*i.targetduration)this.log("Playlist last advanced "+_.toFixed(2)+"s ago. Omitting segment and part directives."),y=void 0,E=void 0;else if(null!=r&&r.tuneInGoal&&I-i.partTarget>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+C+" with playlist age: "+i.age),C=0;else{var x=Math.floor(C/i.targetduration);y+=x,void 0!==E&&(E+=Math.round(C%i.targetduration/i.partTarget)),this.log("CDN Tune-in age: "+i.ageHeader+"s last advanced "+_.toFixed(2)+"s goal: "+C+" skip sn "+x+" to part "+E)}i.tuneInGoal=C}if(v=this.getDeliveryDirectives(i,t.deliveryDirectives,y,E),T||!A)return i.requestScheduled=n,void this.loadingPlaylist(u,v)}else(i.canBlockReload||i.canSkipUntil)&&(v=this.getDeliveryDirectives(i,t.deliveryDirectives,y,E));v&&void 0!==y&&i.canBlockReload&&(i.requestScheduled=a.loading.first+Math.max(p-2*s,p/2)),this.scheduleLoading(u,v,i)}else this.clearTimer()},r.scheduleLoading=function(e,t,r){var i=this,a=r||e.details;if(a){var n=self.performance.now(),s=a.requestScheduled;if(n>=s)this.loadingPlaylist(e,t);else{var o=s-n;this.log("reload live playlist "+(e.name||e.bitrate+"bps")+" in "+Math.round(o)+" ms"),this.clearTimer(),this.timer=self.setTimeout(function(){return i.loadingPlaylist(e,t)},o)}}else this.loadingPlaylist(e,t)},r.getDeliveryDirectives=function(e,t,r,i){var a=Ze(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,a=ze),new Je(r,i,a)},r.checkRetry=function(e){var t=this,r=e.details,i=ct(e),a=e.errorAction,n=a||{},s=n.action,o=n.retryCount,l=void 0===o?0:o,u=n.retryConfig,d=!!a&&!!u&&(s===At||!a.resolved&&s===Lt);if(d){var h;if(l>=u.maxNumRetry)return!1;if(i&&null!=(h=e.context)&&h.deliveryDirectives)this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var f=pt(u,l);this.clearTimer(),this.timer=self.setTimeout(function(){return t.loadPlaylist()},f),this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+r+'" in '+f+"ms")}e.levelRetry=!0,a.resolved=!0}return d},t}(N),nn=function(e){function t(t,r){var i;return(i=e.call(this,t,"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}o(t,e);var r=t.prototype;return r._registerListeners=function(){var e=this.hls;e.on(D.MANIFEST_LOADING,this.onManifestLoading,this),e.on(D.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(D.LEVEL_LOADED,this.onLevelLoaded,this),e.on(D.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(D.FRAG_BUFFERED,this.onFragBuffered,this),e.on(D.ERROR,this.onError,this)},r._unregisterListeners=function(){var e=this.hls;e.off(D.MANIFEST_LOADING,this.onManifestLoading,this),e.off(D.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(D.LEVEL_LOADED,this.onLevelLoaded,this),e.off(D.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(D.FRAG_BUFFERED,this.onFragBuffered,this),e.off(D.ERROR,this.onError,this)},r.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),e.prototype.destroy.call(this)},r.stopLoad=function(){this._levels.forEach(function(e){e.loadError=0,e.fragmentError=0}),e.prototype.stopLoad.call(this)},r.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},r.onManifestLoading=function(e,t){this.resetLevels()},r.onManifestLoaded=function(e,t){var r=this,i=this.hls.config.preferManagedMediaSource,a=[],n={},s={},o=!1,l=!1,u=!1;t.levels.forEach(function(e){var t=e.attrs,d=e.audioCodec,h=e.videoCodec;d&&(e.audioCodec=d=Ve(d,i)||void 0),h&&(h=e.videoCodec=function(e){for(var t=e.split(","),r=0;r<t.length;r++){var i=t[r].split(".");i.length>2&&"avc1"===i[0]&&(t[r]="avc1."+parseInt(i[1]).toString(16)+("000"+parseInt(i[2]).toString(16)).slice(-4))}return t.join(",")}(h));var f=e.width,c=e.height,v=e.unknownCodecs,g=(null==v?void 0:v.length)||0;if(o||(o=!(!f||!c)),l||(l=!!h),u||(u=!!d),g||d&&!r.isAudioSupported(d)||h&&!r.isVideoSupported(h))r.log('Some or all CODECS not supported "'+t.CODECS+'"');else{var m=t.CODECS,p=t["FRAME-RATE"],y=t["HDCP-LEVEL"],E=t["PATHWAY-ID"],T=t.RESOLUTION,S=t["VIDEO-RANGE"],L=(E||".")+"-"+e.bitrate+"-"+T+"-"+p+"-"+m+"-"+S+"-"+y;if(n[L])if(n[L].uri===e.url||e.attrs["PATHWAY-ID"])n[L].addGroupId("audio",t.AUDIO),n[L].addGroupId("text",t.SUBTITLES);else{var R=s[L]+=1;e.attrs["PATHWAY-ID"]=new Array(R+1).join(".");var A=r.createLevel(e);n[L]=A,a.push(A)}else{var b=r.createLevel(e);n[L]=b,s[L]=1,a.push(b)}}}),this.filterAndSortMediaOptions(a,t,o,l,u)},r.createLevel=function(e){var t=new et(e),r=e.supplemental;if(null!=r&&r.videoCodec&&!this.isVideoSupported(r.videoCodec)){var i=new Error('SUPPLEMENTAL-CODECS not supported "'+r.videoCodec+'"');this.log(i.message),t.supportedResult=q.getUnsupportedResult(i,[])}return t},r.isAudioSupported=function(e){return Oe(e,"audio",this.hls.config.preferManagedMediaSource)},r.isVideoSupported=function(e){return Oe(e,"video",this.hls.config.preferManagedMediaSource)},r.filterAndSortMediaOptions=function(e,t,r,i,a){var n,s=this,o=[],l=[],u=e,d=(null==(n=t.stats)?void 0:n.parsing)||{};if((r||i)&&a&&(u=u.filter(function(e){var t,r=e.videoCodec,i=e.videoRange,a=e.width,n=e.height;return(!!r||!(!a||!n))&&!!(t=i)&&Xe.indexOf(t)>-1})),0===u.length)return Promise.resolve().then(function(){if(s.hls){var e="no level with compatible codecs found in manifest",r=e;t.levels.length&&(r="one or more CODECS in variant not supported: "+it(t.levels.map(function(e){return e.attrs.CODECS}).filter(function(e,t,r){return r.indexOf(e)===t})),s.warn(r),e+=" ("+r+")");var i=new Error(e);s.hls.trigger(D.ERROR,{type:b.MEDIA_ERROR,details:k.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:i,reason:r})}}),void(d.end=performance.now());t.audioTracks&&sn(o=t.audioTracks.filter(function(e){return!e.audioCodec||s.isAudioSupported(e.audioCodec)})),t.subtitles&&sn(l=t.subtitles);var h=u.slice(0);u.sort(function(e,t){if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return Xe.indexOf(e.videoRange)-Xe.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){var i=Ne(e.videoCodec),a=Ne(t.videoCodec);if(i!==a)return a-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var n=Be(e.codecSet),s=Be(t.codecSet);if(n!==s)return s-n}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});var f=h[0];if(this.steering&&(u=this.steering.filterParsedLevels(u)).length!==h.length)for(var c=0;c<h.length;c++)if(h[c].pathwayId===u[0].pathwayId){f=h[c];break}this._levels=u;for(var v=0;v<u.length;v++)if(u[v]===f){var g;this._firstLevel=v;var m=f.bitrate,p=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+m),void 0===(null==(g=this.hls.userConfig)?void 0:g.abrEwmaDefaultEstimate)){var y=Math.min(m,this.hls.config.abrEwmaDefaultEstimateMax);y>p&&p===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=y)}break}var E=a&&!i,T=this.hls.config,S=!(!T.audioStreamController||!T.audioTrackController),L={levels:u,audioTracks:o,subtitleTracks:l,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:a,video:i,altAudio:S&&!E&&o.some(function(e){return!!e.url})};d.end=performance.now(),this.hls.trigger(D.MANIFEST_PARSED,L)},r.onError=function(e,t){!t.fatal&&t.context&&t.context.type===I&&t.context.level===this.level&&this.checkRetry(t)},r.onFragBuffered=function(e,t){var r=t.frag;if(void 0!==r&&r.type===w){var i=r.elementaryStreams;if(!Object.keys(i).some(function(e){return!!i[e]}))return;var a=this._levels[r.level];null!=a&&a.loadError&&(this.log("Resetting level error count of "+a.loadError+" on frag buffered"),a.loadError=0)}},r.onLevelLoaded=function(e,t){var r,i,a=t.level,n=t.details,s=t.levelInfo;if(!s)return this.warn("Invalid level index "+a),void(null!=(i=t.deliveryDirectives)&&i.skip&&(n.deltaUpdateFailed=!0));if(s===this.currentLevel||t.withoutMultiVariant){0===s.fragmentError&&(s.loadError=0);var o=s.details;o===t.details&&o.advanced&&(o=void 0),this.playlistLoaded(a,t,o)}else null!=(r=t.deliveryDirectives)&&r.skip&&(n.deltaUpdateFailed=!0)},r.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,t)},r.loadingPlaylist=function(t,r){e.prototype.loadingPlaylist.call(this,t,r);var i=this.getUrlWithDirectives(t.uri,r),a=this.currentLevelIndex,n=t.attrs["PATHWAY-ID"],s=t.details,o=null==s?void 0:s.age;this.log("Loading level index "+a+(void 0!==(null==r?void 0:r.msn)?" at sn "+r.msn+" part "+r.part:"")+(n?" Pathway "+n:"")+(o&&s.live?" age "+o.toFixed(1)+(s.type&&" "+s.type||""):"")+" "+i),this.hls.trigger(D.LEVEL_LOADING,{url:i,level:a,levelInfo:t,pathwayId:t.attrs["PATHWAY-ID"],id:0,deliveryDirectives:r||null})},r.removeLevel=function(e){var t,r=this;if(1!==this._levels.length){var i=this._levels.filter(function(t,i){return i!==e||(r.steering&&r.steering.removeLevel(t),t===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,t.details&&t.details.fragments.forEach(function(e){return e.level=-1})),!1)});Dr(i),this._levels=i,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);var a=i.length-1;this._firstLevel=Math.min(this._firstLevel,a),this._startLevel&&(this._startLevel=Math.min(this._startLevel,a)),this.hls.trigger(D.LEVELS_UPDATED,{levels:i})}},r.onLevelsUpdated=function(e,t){var r=t.levels;this._levels=r},r.checkMaxAutoUpdated=function(){var e=this.hls,t=e.autoLevelCapping,r=e.maxAutoLevel,i=e.maxHdcpLevel;this._maxAutoLevel!==r&&(this._maxAutoLevel=r,this.hls.trigger(D.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))},i(t,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"loadLevelObj",get:function(){return this.currentLevel}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var r=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(D.ERROR,{type:b.OTHER_ERROR,details:k.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}var a=this.currentLevelIndex,n=this.currentLevel,s=n?n.attrs["PATHWAY-ID"]:void 0,o=t[e],l=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=o,a!==e||!n||s!==l){this.log("Switching to level "+e+" ("+(o.height?o.height+"p ":"")+(o.videoRange?o.videoRange+" ":"")+(o.codecSet?o.codecSet+" ":"")+"@"+o.bitrate+")"+(l?" with Pathway "+l:"")+" from level "+a+(s?" with Pathway "+s:""));var u={level:e,attrs:o.attrs,details:o.details,bitrate:o.bitrate,averageBitrate:o.averageBitrate,maxBitrate:o.maxBitrate,realBitrate:o.realBitrate,width:o.width,height:o.height,codecSet:o.codecSet,audioCodec:o.audioCodec,videoCodec:o.videoCodec,audioGroups:o.audioGroups,subtitleGroups:o.subtitleGroups,loaded:o.loaded,loadError:o.loadError,fragmentError:o.fragmentError,name:o.name,id:o.id,uri:o.uri,url:o.url,urlId:0,audioGroupIds:o.audioGroupIds,textGroupIds:o.textGroupIds};this.hls.trigger(D.LEVEL_SWITCHING,u);var d=o.details;if(!d||d.live){var h=this.switchParams(o.uri,null==n?void 0:n.details,d);this.loadPlaylist(h)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathways",get:function(){return this.steering?this.steering.pathways():[]}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var t=this.steering.pathways(),r=e.filter(function(e){return-1!==t.indexOf(e)});if(e.length<1)return void this.warn("pathwayPriority "+e+" should contain at least one pathway from list: "+t);this.steering.pathwayPriority=r}}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}])}(an);function sn(e){var t={};e.forEach(function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++})}var on=[];function ln(e,t,r){if(!((i=t.remuxResult).audio||i.video||i.text||i.id3||i.initSegment))return!1;var i,a=[],n=t.remuxResult,s=n.audio,o=n.video;return s&&un(a,s),o&&un(a,o),e.postMessage({event:"transmuxComplete",data:t,instanceNo:r},a),!0}function un(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function dn(e,t,r,i){t.reduce(function(t,r){return ln(e,r,i)||t},!1)||e.postMessage({event:"transmuxComplete",data:t[0],instanceNo:i}),e.postMessage({event:"flush",data:r,instanceNo:i})}function hn(e,t,r){self.postMessage({event:e,data:t,instanceNo:r})}void 0!==t&&t&&self.addEventListener("message",function(e){var t=e.data,r=t.instanceNo;if(void 0!==r){var i=on[r];if("reset"===t.cmd&&(delete on[t.resetNo],i&&i.destroy(),t.cmd="init"),"init"===t.cmd){var a=JSON.parse(t.config),n=new E;n.on(D.FRAG_DECRYPTED,hn),n.on(D.ERROR,hn);var s=K(a.debug,t.id);return function(e,t){var r=function(r){e[r]=function(){var e=Array.prototype.join.call(arguments," ");hn("workerLog",{logType:r,message:e},t)}};for(var i in e)r(i)}(s,r),on[r]=new Ji(n,t.typeSupported,a,"",t.id,s),void hn("init",null,r)}if(i)switch(t.cmd){case"configure":i.configure(t.config);break;case"demux":var o=i.push(t.data,t.decryptdata,t.chunkMeta,t.state);ta(o)?o.then(function(e){ln(self,e,r)}).catch(function(e){hn(D.ERROR,{instanceNo:r,type:b.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,chunkMeta:t.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker push error"},r)}):ln(self,o,r);break;case"flush":var l=t.chunkMeta,u=i.flush(l);ta(u)?u.then(function(e){dn(self,e,l,r)}).catch(function(e){hn(D.ERROR,{type:b.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,chunkMeta:t.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker flush error"},r)}):dn(self,u,l,r)}}});var fn=void 0,cn={},vn=0,gn=function(){function t(t,r,i,a){var n=this;this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=vn++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=function(e){var t=e.data,r=n.hls;if(r&&null!=t&&t.event&&t.instanceNo===n.instanceNo)switch(t.event){case"init":var i,a=null==(i=n.workerContext)?void 0:i.objectURL;a&&self.URL.revokeObjectURL(a);break;case"transmuxComplete":n.handleTransmuxComplete(t.data);break;case"flush":n.onFlush(t.data);break;case"workerLog":r.logger[t.data.logType]&&r.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=n.frag,t.data.part=n.part,t.data.id=n.id,r.trigger(t.event,t.data)}},this.onWorkerError=function(e){if(n.hls){var t=new Error(e.message+" ("+e.filename+":"+e.lineno+")");n.hls.config.enableWorker=!1,n.hls.logger.warn('Error in "'+n.id+'" Web Worker, fallback to inline'),n.hls.trigger(D.ERROR,{type:b.OTHER_ERROR,details:k.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})}};var s=t.config;this.hls=t,this.id=r,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=i,this.onFlush=a;var o=function(e,t){(t=t||{}).frag=n.frag||void 0,e===D.ERROR&&(t.parent=n.id,t.part=n.part,n.error=t.error),n.hls.trigger(e,t)};this.observer=new E,this.observer.on(D.FRAG_DECRYPTED,o),this.observer.on(D.ERROR,o);var l=je(s.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){var u=this.hls.logger;s.workerPath;try{s.workerPath?(u.log("loading Web Worker "+s.workerPath+' for "'+r+'"'),this.workerContext=function(e){var t=cn[e];if(t)return t.clientCount++,t;var r=new self.URL(e,self.location.href).href,i={worker:new self.Worker(r),scriptURL:r,clientCount:1};return cn[e]=i,i}(s.workerPath)):(u.log('injecting Web Worker for "'+r+'"'),this.workerContext=function(){var t=cn[void 0];if(t)return t.clientCount++,t;var r=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+e.toString()+")(true);"],{type:"text/javascript"}),i=self.URL.createObjectURL(r),a={worker:new self.Worker(i),objectURL:i,clientCount:1};return cn[void 0]=a,a}());var d=this.workerContext.worker;d.addEventListener("message",this.onWorkerMessage),d.addEventListener("error",this.onWorkerError),d.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:l,id:r,config:it(s)})}catch(e){u.warn('Error setting up "'+r+'" Web Worker, fallback to inline',e),this.terminateWorker(),this.error=null,this.transmuxer=new Ji(this.observer,l,s,"",r,t.logger)}}else this.transmuxer=new Ji(this.observer,l,s,"",r,t.logger)}var r=t.prototype;return r.reset=function(){if(this.frag=null,this.part=null,this.workerContext){var e=this.instanceNo;this.instanceNo=vn++;var t=this.hls.config,r=je(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:it(t)})}},r.terminateWorker=function(){if(this.workerContext){var e=this.workerContext.worker;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),function(e){var t=cn[e||fn];if(t&&1===t.clientCount--){var r=t.worker,i=t.objectURL;delete cn[e||fn],i&&self.URL.revokeObjectURL(i),r.terminate()}}(this.hls.config.workerPath)}},r.destroy=function(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null},r.push=function(e,t,r,i,a,n,s,o,l,u){var d,h,f=this;l.transmuxing.start=self.performance.now();var c=this.instanceNo,v=this.transmuxer,g=n?n.start:a.start,m=a.decryptdata,p=this.frag,y=!(p&&a.cc===p.cc),E=!(p&&l.level===p.level),T=p?l.sn-p.sn:-1,S=this.part?l.part-this.part.index:-1,L=0===T&&l.id>1&&l.id===(null==p?void 0:p.stats.chunkCount),R=!E&&(1===T||0===T&&(1===S||L&&S<=0)),A=self.performance.now();(E||T||0===a.stats.parsing.start)&&(a.stats.parsing.start=A),!n||!S&&R||(n.stats.parsing.start=A);var b=!(p&&(null==(d=a.initSegment)?void 0:d.url)===(null==(h=p.initSegment)?void 0:h.url)),k=new ia(y,R,o,E,g,b);if(!R||y||b){this.hls.logger.log("[transmuxer-interface]: Starting new transmux session for "+a.type+" sn: "+l.sn+(l.part>-1?" part: "+l.part:"")+" "+(this.id===w?"level":"track")+": "+l.level+" id: "+l.id+"\n discontinuity: "+y+"\n trackSwitch: "+E+"\n contiguous: "+R+"\n accurateTimeOffset: "+o+"\n timeOffset: "+g+"\n initSegmentChange: "+b);var D=new ra(r,i,t,s,u);this.configureTransmuxer(D)}if(this.frag=a,this.part=n,this.workerContext)this.workerContext.worker.postMessage({instanceNo:c,cmd:"demux",data:e,decryptdata:m,chunkMeta:l,state:k},e instanceof ArrayBuffer?[e]:[]);else if(v){var _=v.push(e,m,l,k);ta(_)?_.then(function(e){f.handleTransmuxComplete(e)}).catch(function(e){f.transmuxerError(e,l,"transmuxer-interface push error")}):this.handleTransmuxComplete(_)}},r.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.instanceNo,i=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:r,cmd:"flush",chunkMeta:e});else if(i){var a=i.flush(e);ta(a)?a.then(function(r){t.handleFlushResult(r,e)}).catch(function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")}):this.handleFlushResult(a,e)}},r.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(D.ERROR,{type:b.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:r}))},r.handleFlushResult=function(e,t){var r=this;e.forEach(function(e){r.handleTransmuxComplete(e)}),this.onFlush(t)},r.configureTransmuxer=function(e){var t=this.instanceNo,r=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):r&&r.configure(e)},r.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},t}();function mn(){return self.SourceBuffer||self.WebKitSourceBuffer}function pn(){if(!z())return!1;var e=mn();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}var yn=function(e){function t(t,r,i){var a;return(a=e.call(this,t,r,i,"stream-controller",w)||this).audioCodecSwap=!1,a.level=-1,a._forceStartLoad=!1,a._hasEnoughToStart=!1,a.altAudio=0,a.audioOnly=!1,a.fragPlaying=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a.onMediaPlaying=function(){a.tick()},a.onMediaSeeked=function(){var e=a.media,t=e?e.currentTime:null;if(null!==t&&L(t)&&(a.log("Media seeked to "+t.toFixed(3)),a.getBufferedFrag(t))){var r=a.getFwdBufferInfoAtPos(e,t,w,0);null!==r&&0!==r.len?a.tick():a.warn("Main forward buffer length at "+t+' on "seeked" event '+(r?r.len:"empty")+")")}},a.registerListeners(),a}o(t,e);var r=t.prototype;return r.registerListeners=function(){e.prototype.registerListeners.call(this);var t=this.hls;t.on(D.MANIFEST_PARSED,this.onManifestParsed,this),t.on(D.LEVEL_LOADING,this.onLevelLoading,this),t.on(D.LEVEL_LOADED,this.onLevelLoaded,this),t.on(D.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(D.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(D.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(D.BUFFER_CREATED,this.onBufferCreated,this),t.on(D.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(D.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(D.FRAG_BUFFERED,this.onFragBuffered,this)},r.unregisterListeners=function(){e.prototype.unregisterListeners.call(this);var t=this.hls;t.off(D.MANIFEST_PARSED,this.onManifestParsed,this),t.off(D.LEVEL_LOADED,this.onLevelLoaded,this),t.off(D.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(D.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(D.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(D.BUFFER_CREATED,this.onBufferCreated,this),t.off(D.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(D.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(D.FRAG_BUFFERED,this.onFragBuffered,this)},r.onHandlerDestroying=function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),e.prototype.onHandlerDestroying.call(this)},r.startLoad=function(e,t){if(this.levels){var r=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var a=i.startLevel;-1===a&&(i.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=i.firstAutoLevel),i.nextLoadLevel=a,this.level=i.loadLevel,this._hasEnoughToStart=!!t}r>0&&-1===e&&!t&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),e=r),this.state=Na,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=Fa},r.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},r.doTick=function(){switch(this.state){case ja:var e=this.levels,t=this.level,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r&&!this.waitForLive(r))){if(this.waitForCdnTuneIn(i))break;this.state=Na;break}if(this.hls.nextLoadLevel!==this.level){this.state=Na;break}break;case Ga:this.checkRetryDate()}this.state===Na&&this.doTickIdle(),this.onTickEnd()},r.onTickEnd=function(){var t;e.prototype.onTickEnd.call(this),null!=(t=this.media)&&t.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()},r.doTickIdle=function(){var e=this.hls,t=this.levelLastLoaded,r=this.levels,i=this.media;if(null!==t&&(i||this.primaryPrefetch||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var a=this.buffering?e.nextLoadLevel:e.loadLevel;if(null!=r&&r[a]){var n=r[a],s=this.getMainFwdBufferInfo();if(null!==s){var o=this.getLevelDetails();if(o&&this._streamEnded(s,o)){var l={};return 2===this.altAudio&&(l.type="video"),this.hls.trigger(D.BUFFER_EOS,l),void(this.state=Ka)}if(this.buffering){e.loadLevel!==a&&-1===e.manualLevel&&this.log("Adapting to level "+a+" from level "+this.level),this.level=e.nextLoadLevel=a;var u=n.details;if(!u||this.state===ja||this.waitForLive(n))return this.level=a,this.state=ja,void(this.startFragRequested=!1);var d=s.len,h=this.getMaxBufferLength(n.maxBitrate);if(!(d>=h)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var f=this.backtrackFragment?this.backtrackFragment.start:s.end,c=this.getNextFragment(f,u);if(this.couldBacktrack&&!this.fragPrevious&&c&&ae(c)&&this.fragmentTracker.getState(c)!==pa){var v,g=(null!=(v=this.backtrackFragment)?v:c).sn-u.startSN,m=u.fragments[g-1];m&&c.cc===m.cc&&(c=m,this.fragmentTracker.removeFragment(m))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(c&&this.isLoopLoading(c,f)){if(!c.gap){var p=this.audioOnly&&!this.altAudio?ee:te,y=(p===te?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,p,w)}c=this.getNextFragmentLoopLoading(c,u,s,w,h)}c&&(!c.initSegment||c.initSegment.data||this.bitrateTest||(c=c.initSegment),this.loadFragment(c,n,f))}}}}}},r.loadFragment=function(t,r,i){var a=this.fragmentTracker.getState(t);a===va||a===ma?ae(t)?this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,r)):e.prototype.loadFragment.call(this,t,r,i):this._loadInitSegment(t,r):this.clearTrackerIfNeeded(t)},r.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,w)},r.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},r.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},r.nextLevelSwitch=function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var r,i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);var a=this.getLevelDetails();if(null!=a&&a.live){var n=this.getMainFwdBufferInfo();if(!n||n.len<2*a.targetduration)return}if(!t.paused&&e){var s=e[this.hls.nextLoadLevel],o=this.fragLastKbps;r=o&&this.fragCurrent?this.fragCurrent.duration*s.maxBitrate/(1e3*o)+1:0}else r=0;var l=this.getBufferedFrag(t.currentTime+r);if(l){var u=this.followingBufferedFrag(l);if(u){this.abortCurrentFrag();var d=u.maxStartPTS?u.maxStartPTS:u.start,h=u.duration,f=Math.max(l.end,d+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*(this.couldBacktrack?.5:.125)),h*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(f,Number.POSITIVE_INFINITY)}}}},r.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case Ba:case Ua:case Ga:case Va:case Ha:this.state=Na}this.nextLoadPosition=this.getLoadPosition()},r.flushMainBuffer=function(t,r){e.prototype.flushMainBuffer.call(this,t,r,2===this.altAudio?"video":null)},r.onMediaAttached=function(t,r){e.prototype.onMediaAttached.call(this,t,r);var i=r.media;Pa(i,"playing",this.onMediaPlaying),Pa(i,"seeked",this.onMediaSeeked)},r.onMediaDetaching=function(t,r){var i=this.media;i&&(Oa(i,"playing",this.onMediaPlaying),Oa(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,e.prototype.onMediaDetaching.call(this,t,r),r.transferMedia||(this._hasEnoughToStart=!1)},r.onManifestLoading=function(){e.prototype.onManifestLoading.call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(D.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1},r.onManifestParsed=function(e,t){for(var r,i,a=!1,n=!1,s=0;s<t.levels.length;s++){var o=t.levels[s].audioCodec;o&&(a=a||-1!==o.indexOf("mp4a.40.2"),n=n||-1!==o.indexOf("mp4a.40.5"))}this.audioCodecSwitch=a&&n&&!("function"==typeof(null==(i=mn())||null==(r=i.prototype)?void 0:r.changeType)),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},r.onLevelLoading=function(e,t){if(this.levels&&this.state===Na){var r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=ja)}},r.onLevelLoaded=function(e,t){var r,i=this.levels,a=this.startFragRequested,n=t.level,s=t.details,o=s.totalduration;if(i){this.log("Level "+n+" loaded ["+s.startSN+","+s.endSN+"]"+(s.lastPartSn?"[part-"+s.lastPartSn+"-"+s.lastPartIndex+"]":"")+", cc ["+s.startCC+", "+s.endCC+"] duration:"+o);var l=t.levelInfo,u=this.fragCurrent;!u||this.state!==Ua&&this.state!==Ga||u.level!==t.level&&u.loader&&this.abortCurrentFrag();var d=0;if(s.live||null!=(r=l.details)&&r.live){var h;if(this.checkLiveUpdate(s),s.deltaUpdateFailed)return;d=this.alignPlaylists(s,l.details,null==(h=this.levelLastLoaded)?void 0:h.details)}if(l.details=s,this.levelLastLoaded=l,a||this.setStartPosition(s,d),this.hls.trigger(D.LEVEL_UPDATED,{details:s,level:n}),this.state===ja){if(this.waitForCdnTuneIn(s))return;this.state=Na}a&&s.live&&this.synchronizeToLiveEdge(s),this.tick()}else this.warn("Levels were reset while loading level "+n)},r.synchronizeToLiveEdge=function(e){var t=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,a=this.getLoadPosition(),n=e.fragmentStart,s=e.edge,o=a>=n-t.maxFragLookUpTolerance&&a<=s;if(null!==i&&r.duration>i&&(a<i||!o)){var l=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!o&&r.readyState<4||a<s-l)&&(this._hasEnoughToStart||(this.nextLoadPosition=i),r.readyState))if(this.warn("Playback: "+a.toFixed(3)+" is located too far from the end of live sliding playlist: "+s+", reset currentTime to : "+i.toFixed(3)),"buffered"===this.config.liveSyncMode){var u,d=wt.bufferInfo(r,i,0);if(null==(u=d.buffered)||!u.length)return void(r.currentTime=i);if(d.start<=a)return void(r.currentTime=i);var h=wt.bufferedInfo(d.buffered,a,0).nextStart;h&&(r.currentTime=h)}else r.currentTime=i}}},r._handleFragmentLoadProgress=function(e){var t,r=e.frag,i=e.part,a=e.payload,n=this.levels;if(n){var s=n[r.level];if(s){var o=s.details;if(!o)return this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset"),void this.fragmentTracker.removeFragment(r);var l=s.videoCodec,u=o.PTSKnown||!o.live,d=null==(t=r.initSegment)?void 0:t.data,h=this._getAudioCodec(s),f=this.transmuxer=this.transmuxer||new gn(this.hls,w,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),c=i?i.index:-1,v=-1!==c,g=new _a(r.level,r.sn,r.stats.chunkCount,a.byteLength,c,v),m=this.initPTS[r.cc];f.push(a,d,h,l,r,i,o.totalduration,u,g,m)}else this.warn("Level "+r.level+" not found on progress")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},r.onAudioTrackSwitching=function(e,t){var r=this,i=this.hls,a=2===this.altAudio;if(st(t.url,i))this.altAudio=1;else{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();if(a)return this.fragmentTracker.removeAllFragments(),i.once(D.BUFFER_FLUSHED,function(){r.hls&&r.hls.trigger(D.AUDIO_TRACK_SWITCHED,t)}),void i.trigger(D.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});i.trigger(D.AUDIO_TRACK_SWITCHED,t)}},r.onAudioTrackSwitched=function(e,t){var r=st(t.url,this.hls);if(r){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r?2:0,this.tick()},r.onBufferCreated=function(e,t){var r,i,a=t.tracks,n=!1;for(var s in a){var o=a[s];if("main"===o.id){if(i=s,r=o,"video"===s){var l=a[s];l&&(this.videoBuffer=l.buffer)}}else n=!0}n&&r?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},r.onFragBuffered=function(e,t){var r=t.frag,i=t.part,a=r.type===w;if(a){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===Ha&&(this.state=Na));var n=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),ae(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}var s=this.media;s&&(!this._hasEnoughToStart&&wt.getBuffered(s).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),a&&this.tick())},r.onError=function(e,t){var r;if(t.fatal)this.state=Ya;else switch(t.details){case k.FRAG_GAP:case k.FRAG_PARSING_ERROR:case k.FRAG_DECRYPT_ERROR:case k.FRAG_LOAD_ERROR:case k.FRAG_LOAD_TIMEOUT:case k.KEY_LOAD_ERROR:case k.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(w,t);break;case k.LEVEL_LOAD_ERROR:case k.LEVEL_LOAD_TIMEOUT:case k.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==ja||(null==(r=t.context)?void 0:r.type)!==I||(this.state=Na);break;case k.BUFFER_ADD_CODEC_ERROR:case k.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case k.BUFFER_FULL_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case k.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}},r.onFragLoadEmergencyAborted=function(){this.state=Na,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()},r.onBufferFlushed=function(e,t){var r=t.type;if(r!==ee||!this.altAudio){var i=(r===te?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,r,w),this.tick())}},r.onLevelsUpdated=function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels},r.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},r.seekToStartPos=function(){var e=this.media;if(e){var t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void this.log("could not seek to "+r+", already seeking at "+t);var i=this.timelineOffset;i&&r&&(r+=i);var a=this.getLevelDetails(),n=wt.getBuffered(e),s=n.length?n.start(0):0,o=s-r,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||o>0&&(o<l||this.loadingParts&&o<2*((null==a?void 0:a.partTarget)||0)))&&(this.log("adjusting start position by "+o+" to match buffer start"),r+=o,this.startPosition=r),t<r&&(this.log("seek to target start position "+r+" from current time "+t+" buffer start "+s),e.currentTime=r)}}},r._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t},r._loadBitrateTestFrag=function(e,t){var r=this;e.bitrateTest=!0,this._doFragLoad(e,t).then(function(e){var i=r.hls,a=null==e?void 0:e.frag;if(a&&!r.fragContextChanged(a)){t.fragmentError=0,r.state=Na,r.startFragRequested=!1,r.bitrateTest=!1;var n=a.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),i.trigger(D.FRAG_LOADED,e),a.bitrateTest=!1}}).catch(function(t){r.state!==Fa&&r.state!==Ya&&(r.warn(t),r.resetFragmentLoading(e))})},r._handleTransmuxComplete=function(e){var t=this.playlistType,r=this.hls,i=e.remuxResult,a=e.chunkMeta,n=this.getCurrentContext(a);if(n){var s=n.frag,o=n.part,l=n.level,u=i.video,d=i.text,h=i.id3,f=i.initSegment,c=l.details,v=this.altAudio?void 0:i.audio;if(this.fragContextChanged(s))this.fragmentTracker.removeFragment(s);else{if(this.state=Va,f){var g=f.tracks;if(g){var m=s.initSegment||s;if(this.unhandledEncryptionError(f,s))return;this._bufferInitSegment(l,g,m,a),r.trigger(D.FRAG_PARSING_INIT_SEGMENT,{frag:m,id:t,tracks:g})}var p=f.initPTS,y=f.timescale,E=this.initPTS[s.cc];if(L(p)&&(!E||E.baseTime!==p||E.timescale!==y)){var T=f.trackId;this.initPTS[s.cc]={baseTime:p,timescale:y,trackId:T},r.trigger(D.INIT_PTS_FOUND,{frag:s,id:t,initPTS:p,timescale:y,trackId:T})}}if(u&&c){v&&"audiovideo"===u.type&&this.logMuxedErr(s);var S=c.fragments[s.sn-1-c.startSN],R=s.sn===c.startSN,A=!S||s.cc>S.cc;if(!1!==i.independent){var b=u.startPTS,k=u.endPTS,_=u.startDTS,I=u.endDTS;if(o)o.elementaryStreams[u.type]={startPTS:b,endPTS:k,startDTS:_,endDTS:I};else if(u.firstKeyFrame&&u.independent&&1===a.id&&!A&&(this.couldBacktrack=!0),u.dropped&&u.independent){var C=this.getMainFwdBufferInfo(),x=(C?C.end:this.getLoadPosition())+this.config.maxBufferHole,w=u.firstKeyFramePTS?u.firstKeyFramePTS:b;if(!R&&x<w-this.config.maxBufferHole&&!A)return void this.backtrack(s);A&&(s.gap=!0),s.setElementaryStreamInfo(u.type,s.start,k,s.start,I,!0)}else R&&b-(c.appliedTimelineOffset||0)>2&&(s.gap=!0);s.setElementaryStreamInfo(u.type,b,k,_,I),this.backtrackFragment&&(this.backtrackFragment=s),this.bufferFragmentData(u,s,o,a,R||A)}else{if(!R&&!A)return void this.backtrack(s);s.gap=!0}}if(v){var P=v.startPTS,O=v.endPTS,M=v.startDTS,F=v.endDTS;o&&(o.elementaryStreams[ee]={startPTS:P,endPTS:O,startDTS:M,endDTS:F}),s.setElementaryStreamInfo(ee,P,O,M,F),this.bufferFragmentData(v,s,o,a)}if(c&&null!=h&&h.samples.length){var N={id:t,frag:s,details:c,samples:h.samples};r.trigger(D.FRAG_PARSING_METADATA,N)}if(c&&d){var B={id:t,frag:s,details:c,samples:d.samples};r.trigger(D.FRAG_PARSING_USERDATA,B)}}}else this.resetWhenMissingContext(a)},r.logMuxedErr=function(e){this.warn((ae(e)?"Media":"Init")+" segment with muxed audiovideo where only video expected: "+e.url)},r._bufferInitSegment=function(e,t,r,i){var a=this;if(this.state===Va){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(r));var n=t.audio,s=t.video,o=t.audiovideo;if(n){var l=e.audioCodec,u=He(n.codec,l);"mp4a"===u&&(u="mp4a.40.5");var d=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var h=n.metadata;h&&"channelCount"in h&&1!==(h.channelCount||1)&&-1===d.indexOf("firefox")&&(u="mp4a.40.5")}u&&-1!==u.indexOf("mp4a.40.5")&&-1!==d.indexOf("android")&&"audio/mpeg"!==n.container&&(u="mp4a.40.2",this.log("Android: force audio codec to "+u)),l&&l!==u&&this.log('Swapping manifest audio codec "'+l+'" for "'+u+'"'),n.levelCodec=u,n.id=w,this.log("Init audio buffer, container:"+n.container+", codecs[selected/level/parsed]=["+(u||"")+"/"+(l||"")+"/"+n.codec+"]"),delete t.audiovideo}if(s){s.levelCodec=e.videoCodec,s.id=w;var f=s.codec;if(4===(null==f?void 0:f.length))switch(f){case"hvc1":case"hev1":s.codec="hvc1.1.6.L120.90";break;case"av01":s.codec="av01.0.04M.08";break;case"avc1":s.codec="avc1.42e01e"}this.log("Init video buffer, container:"+s.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+f+"]"+(s.codec!==f?" parsed-corrected="+s.codec:"")+(s.supplemental?" supplemental="+s.supplemental:"")),delete t.audiovideo}o&&(this.log("Init audiovideo buffer, container:"+o.container+", codecs[level/parsed]=["+e.codecs+"/"+o.codec+"]"),delete t.video,delete t.audio);var c=Object.keys(t);if(c.length){if(this.hls.trigger(D.BUFFER_CODECS,t),!this.hls)return;c.forEach(function(e){var n=t[e].initSegment;null!=n&&n.byteLength&&a.hls.trigger(D.BUFFER_APPENDING,{type:e,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})})}this.tickImmediate()}},r.getMainFwdBufferInfo=function(){var e=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,w)},r.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=Na},r.checkFragmentChanged=function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(wt.isBuffered(e,r)?t=this.getAppendedFrag(r):wt.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;var i=this.fragPlaying,a=t.level;i&&t.sn===i.sn&&i.level===a||(this.fragPlaying=t,this.hls.trigger(D.FRAG_CHANGED,{frag:t}),i&&i.level===a||this.hls.trigger(D.LEVEL_SWITCHED,{level:a}))}}},i(t,[{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"maxBufferLength",get:function(){var e=this.levels,t=this.level,r=null==e?void 0:e[t];return r?this.getMaxBufferLength(r.maxBitrate):this.config.maxBufferLength}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e;if(this.fragPlaying)return this.fragPlaying;var t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return L(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(L(t)){var r=this.getLevelDetails(),i=this.currentFrag||(r?dt(null,r.fragments,t):null);if(i){var a=i.programDateTime;if(null!==a){var n=a+1e3*(t-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}}])}(Wa),En=function(e){function t(t,r){var i;return(i=e.call(this,"key-loader",r)||this).config=void 0,i.keyIdToKeyInfo={},i.emeController=null,i.config=t,i}o(t,e);var r=t.prototype;return r.abort=function(e){for(var t in this.keyIdToKeyInfo){var r=this.keyIdToKeyInfo[t].loader;if(r){var i;if(e&&e!==(null==(i=r.context)?void 0:i.frag.type))return;r.abort()}}},r.detach=function(){for(var e in this.keyIdToKeyInfo){var t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}},r.destroy=function(){for(var e in this.detach(),this.keyIdToKeyInfo){var t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}},r.createKeyLoadError=function(e,t,r,i,a){return void 0===t&&(t=k.KEY_LOAD_ERROR),new ka({type:b.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:r,networkDetails:i||null})},r.loadClear=function(e,t,r){return null},r.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(function(r){return t.loadInternal(e,r)}):this.loadInternal(e)},r.loadInternal=function(e,t){var r,i,a=e.decryptdata;if(!a){var n=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: "+(this.emeController&&this.config.emeEnabled)+")");return Promise.reject(this.createKeyLoadError(e,k.KEY_LOAD_ERROR,n))}var s=a.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,k.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+s+'"')));var o=Tn(a),l=this.keyIdToKeyInfo[o];if(null!=(r=l)&&r.decryptdata.key)return a.key=l.decryptdata.key,Promise.resolve({frag:e,keyInfo:l});if(this.emeController&&null!=(i=l)&&i.keyLoadPromise)switch(this.emeController.getKeyStatus(l.decryptdata)){case"usable":case"usable-in-future":return l.keyLoadPromise.then(function(t){var r=t.keyInfo;return a.key=r.decryptdata.key,{frag:e,keyInfo:r}})}switch(this.log((this.keyIdToKeyInfo[o]?"Rel":"L")+"oading"+(a.keyId?" keyId: "+$(a.keyId):"")+" URI: "+a.uri+" from "+e.type+" "+e.level),l=this.keyIdToKeyInfo[o]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===a.keyFormat?this.loadKeyHTTP(l,e):this.loadKeyEME(l,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(l,e);default:return Promise.reject(this.createKeyLoadError(e,k.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+a.method+'"')))}},r.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);return(e.keyLoadPromise=i.then(function(t){return e.mediaKeySessionContext=t,r})).catch(function(r){throw e.keyLoadPromise=null,"data"in r&&(r.data.frag=t),r})}return Promise.resolve(r)},r.loadKeyHTTP=function(e,t){var r=this,i=this.config,a=new(0,i.loader)(i);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise(function(n,s){var o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=i.keyLoadPolicy.default,u={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:function(e,t,i,a){var o=i.frag,l=i.keyInfo,u=Tn(l.decryptdata);if(!o.decryptdata||l!==r.keyIdToKeyInfo[u])return s(r.createKeyLoadError(o,k.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),a));l.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=null,l.loader=null,n({frag:o,keyInfo:l})},onError:function(e,i,a,n){r.resetLoader(i),s(r.createKeyLoadError(t,k.KEY_LOAD_ERROR,new Error("HTTP Error "+e.code+" loading key "+e.text),a,d({url:o.url,data:void 0},e)))},onTimeout:function(e,i,a){r.resetLoader(i),s(r.createKeyLoadError(t,k.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),a))},onAbort:function(e,i,a){r.resetLoader(i),s(r.createKeyLoadError(t,k.INTERNAL_ABORTED,new Error("key loading aborted"),a))}};a.load(o,u,h)})},r.resetLoader=function(e){var t=e.frag,r=e.keyInfo,i=e.url,a=r.loader;t.keyLoader===a&&(t.keyLoader=null,r.loader=null);var n=Tn(r.decryptdata)||i;delete this.keyIdToKeyInfo[n],a&&a.destroy()},t}(N);function Tn(e){return e.uri}function Sn(e){switch(e.type){case C:return P;case x:return O;default:return w}}function Ln(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}var Rn=function(){function e(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}var t=e.prototype;return t.startLoad=function(e){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){var e=this.hls;e.on(D.MANIFEST_LOADING,this.onManifestLoading,this),e.on(D.LEVEL_LOADING,this.onLevelLoading,this),e.on(D.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(D.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(D.LEVELS_UPDATED,this.onLevelsUpdated,this)},t.unregisterListeners=function(){var e=this.hls;e.off(D.MANIFEST_LOADING,this.onManifestLoading,this),e.off(D.LEVEL_LOADING,this.onLevelLoading,this),e.off(D.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(D.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(D.LEVELS_UPDATED,this.onLevelsUpdated,this)},t.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,a=new(r||i)(t);return this.loaders[e.type]=a,a},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:_,url:r,deliveryDirectives:null,levelOrTrack:null})},t.onLevelLoading=function(e,t){var r=t.id,i=t.level,a=t.pathwayId,n=t.url,s=t.deliveryDirectives,o=t.levelInfo;this.load({id:r,level:i,pathwayId:a,responseType:"text",type:I,url:n,deliveryDirectives:s,levelOrTrack:o})},t.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,n=t.deliveryDirectives,s=t.track;this.load({id:r,groupId:i,level:null,responseType:"text",type:C,url:a,deliveryDirectives:n,levelOrTrack:s})},t.onSubtitleTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,n=t.deliveryDirectives,s=t.track;this.load({id:r,groupId:i,level:null,responseType:"text",type:x,url:a,deliveryDirectives:n,levelOrTrack:s})},t.onLevelsUpdated=function(e,t){var r=this.loaders[I];if(r){var i=r.context;i&&!t.levels.some(function(e){return e===i.levelOrTrack})&&(r.abort(),delete this.loaders[I])}},t.load=function(e){var t,r,i,a=this,s=this.hls.config,o=this.getInternalLoader(e);if(o){var l=this.hls.logger,u=o.context;if(u&&u.levelOrTrack===e.levelOrTrack&&(u.url===e.url||u.deliveryDirectives&&!e.deliveryDirectives))return void(u.url===e.url?l.log("[playlist-loader]: ignore "+e.url+" ongoing request"):l.log("[playlist-loader]: ignore "+e.url+" in favor of "+u.url));l.log("[playlist-loader]: aborting previous loader for type: "+e.type),o.abort()}if(r=e.type===_?s.manifestLoadPolicy.default:n({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),o=this.createInternalLoader(e),L(null==(t=e.deliveryDirectives)?void 0:t.part)&&(e.type===I&&null!==e.level?i=this.hls.levels[e.level].details:e.type===C&&null!==e.id?i=this.hls.audioTracks[e.id].details:e.type===x&&null!==e.id&&(i=this.hls.subtitleTracks[e.id].details),i)){var d=i.partTarget,h=i.targetduration;if(d&&h){var f=1e3*Math.max(3*d,.8*h);r=n({},r,{maxTimeToFirstByteMs:Math.min(f,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(f,r.maxTimeToFirstByteMs)})}}var c=r.errorRetry||r.timeoutRetry||{},v={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},g={onSuccess:function(e,t,r,i){var n=a.getInternalLoader(r);a.resetInternalLoader(r.type);var s=e.data;t.parsing.start=performance.now(),sr.isMediaPlaylist(s)||r.type!==_?a.handleTrackOrLevelPlaylist(e,t,r,i||null,n):a.handleMasterPlaylist(e,t,r,i)},onError:function(e,t,r,i){a.handleNetworkError(t,r,!1,e,i)},onTimeout:function(e,t,r){a.handleNetworkError(t,r,!0,void 0,e)}};o.load(e,v,g)},t.checkAutostartLoad=function(){if(this.hls){var e=this.hls,t=e.config,r=t.autoStartLoad,i=t.startPosition,a=e.forceStartLoad;(r||a)&&(this.hls.logger.log((r?"auto":"force")+" startLoad with configured startPosition "+i),this.hls.startLoad(i))}},t.handleMasterPlaylist=function(e,t,r,i){var a=this,n=this.hls,s=e.data,o=Ln(e,r),l=sr.parseMasterPlaylist(s,o);if(l.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,r,l.playlistParsingError,i,t);var u=l.contentSteering,d=l.levels,h=l.sessionData,f=l.sessionKeys,c=l.startTimeOffset,v=l.variableList;this.variableList=v,d.forEach(function(e){var t=e.unknownCodecs;if(t)for(var r=a.hls.config.preferManagedMediaSource,i=e.audioCodec,n=e.videoCodec,s=t.length;s--;){var o=t[s];Oe(o,"audio",r)?(e.audioCodec=i=i?i+","+o:o,we.audio[i.substring(0,4)]=2,t.splice(s,1)):Oe(o,"video",r)&&(e.videoCodec=n=n?n+","+o:o,we.video[n.substring(0,4)]=2,t.splice(s,1))}});var g=sr.parseMasterPlaylistMedia(s,o,l),m=g.AUDIO,p=void 0===m?[]:m,y=g.SUBTITLES,E=g["CLOSED-CAPTIONS"];p.length&&(p.some(function(e){return!e.url})||!d[0].audioCodec||d[0].attrs.AUDIO||(this.hls.logger.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 Ht({}),bitrate:0,url:""}))),n.trigger(D.MANIFEST_LOADED,{levels:d,audioTracks:p,subtitles:y,captions:E,contentSteering:u,url:o,stats:t,networkDetails:i,sessionData:h,sessionKeys:f,startTimeOffset:c,variableList:v})},t.handleTrackOrLevelPlaylist=function(e,t,r,i,a){var n=this.hls,s=r.id,o=r.level,l=r.type,u=Ln(e,r),d=L(o)?o:L(s)?s:0,h=Sn(r),f=sr.parseLevelPlaylist(e.data,u,d,h,0,this.variableList);if(l===_){var c={attrs:new Ht({}),bitrate:0,details:f,name:"",url:u};f.requestScheduled=t.loading.start+Rr(f,0),n.trigger(D.MANIFEST_LOADED,{levels:[c],audioTracks:[],url:u,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=f,this.handlePlaylistLoaded(f,e,t,r,i,a)},t.handleManifestParsingError=function(e,t,r,i,a){this.hls.trigger(D.ERROR,{type:b.NETWORK_ERROR,details:k.MANIFEST_PARSING_ERROR,fatal:t.type===_,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:a})},t.handleNetworkError=function(e,t,r,i,a){void 0===r&&(r=!1);var n="A network "+(r?"timeout":"error"+(i?" (status "+i.code+")":""))+" occurred while loading "+e.type;e.type===I?n+=": "+e.level+" id: "+e.id:e.type!==C&&e.type!==x||(n+=" id: "+e.id+' group-id: "'+e.groupId+'"');var s=new Error(n);this.hls.logger.warn("[playlist-loader]: "+n);var o=k.UNKNOWN,l=!1,u=this.getInternalLoader(e);switch(e.type){case _:o=r?k.MANIFEST_LOAD_TIMEOUT:k.MANIFEST_LOAD_ERROR,l=!0;break;case I:o=r?k.LEVEL_LOAD_TIMEOUT:k.LEVEL_LOAD_ERROR,l=!1;break;case C:o=r?k.AUDIO_TRACK_LOAD_TIMEOUT:k.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case x:o=r?k.SUBTITLE_TRACK_LOAD_TIMEOUT:k.SUBTITLE_LOAD_ERROR,l=!1}u&&this.resetInternalLoader(e.type);var h={type:b.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:u,context:e,error:s,networkDetails:t,stats:a};if(i){var f=e.url;t&&"url"in t&&(f=t.url),h.response=d({url:f,data:void 0},i)}this.hls.trigger(D.ERROR,h)},t.handlePlaylistLoaded=function(e,t,r,i,a,n){var s=this.hls,o=i.type,l=i.level,u=i.levelOrTrack,d=i.id,h=i.groupId,f=i.deliveryDirectives,c=Ln(t,i),v=Sn(i),g="number"==typeof i.level&&v===w?l:void 0,m=e.playlistParsingError;if(m){if(this.hls.logger.warn(m+" "+e.url),!s.config.ignorePlaylistParsingErrors)return void s.trigger(D.ERROR,{type:b.NETWORK_ERROR,details:k.LEVEL_PARSING_ERROR,fatal:!1,url:c,error:m,reason:m.message,response:t,context:i,level:g,parent:v,networkDetails:a,stats:r});e.playlistParsingError=null}if(e.fragments.length)switch(e.live&&n&&(n.getCacheAge&&(e.ageHeader=n.getCacheAge()||0),n.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case _:case I:if(g)if(u){if(u!==s.levels[g]){var p=s.levels.indexOf(u);p>-1&&(g=p)}}else g=0;s.trigger(D.LEVEL_LOADED,{details:e,levelInfo:u||s.levels[0],level:g||0,id:d||0,stats:r,networkDetails:a,deliveryDirectives:f,withoutMultiVariant:o===_});break;case C:s.trigger(D.AUDIO_TRACK_LOADED,{details:e,track:u,id:d||0,groupId:h||"",stats:r,networkDetails:a,deliveryDirectives:f});break;case x:s.trigger(D.SUBTITLE_TRACK_LOADED,{details:e,track:u,id:d||0,groupId:h||"",stats:r,networkDetails:a,deliveryDirectives:f})}else{var y=e.playlistParsingError=new Error("No Segments found in Playlist");s.trigger(D.ERROR,{type:b.NETWORK_ERROR,details:k.LEVEL_EMPTY_ERROR,fatal:!1,url:c,error:y,reason:y.message,response:t,context:i,level:g,parent:v,networkDetails:a,stats:r})}},e}(),An={supported:!1,smooth:!1,powerEfficient:!1},bn={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function kn(e,t,r,i){void 0===i&&(i={});var a=e.videoCodec;if(!a&&!e.audioCodec||!r)return Promise.resolve(bn);for(var n=[],s=function(e){var t,r=null==(t=e.videoCodec)?void 0:t.split(","),i=_n(e),a=e.width||640,n=e.height||480,s=e.frameRate||30,o=e.videoRange.toLowerCase();return r?r.map(function(e){var t={contentType:Fe(Ye(e),"video"),width:a,height:n,bitrate:i,framerate:s};return"sdr"!==o&&(t.transferFunction=o),t}):[]}(e),o=s.length,l=function(e,t,r){var i,a=null==(i=e.audioCodec)?void 0:i.split(","),n=_n(e);return a&&e.audioGroups?e.audioGroups.reduce(function(e,i){var s,o=i?null==(s=t.groups[i])?void 0:s.tracks:null;return o?o.reduce(function(e,t){if(t.groupId===i){var s=parseFloat(t.channels||"");a.forEach(function(t){var i={contentType:Fe(t,"audio"),bitrate:r?Dn(t,n):n};s&&(i.channels=""+s),e.push(i)})}return e},e):e},[]):[]}(e,t,o>0),u=l.length,d=o||1*u||1;d--;){var h={type:"media-source"};if(o&&(h.video=s[d%o]),u){h.audio=l[d%u];var f=h.audio.bitrate;h.video&&f&&(h.video.bitrate-=f)}n.push(h)}if(a){var c=navigator.userAgent;if(a.split(",").some(function(e){return De(e)})&&xe())return Promise.resolve(function(e,t){return{supported:!1,configurations:t,decodingInfoResults:[An],error:e}}(new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: ("+c+")"),n))}return Promise.all(n.map(function(e){var t,a,n,s,o=(a="",n=(t=e).audio,(s=t.video)&&(a+=We(s.contentType)+"_r"+s.height+"x"+s.width+"f"+Math.ceil(s.framerate)+(s.transferFunction||"sd")+"_"+Math.ceil(s.bitrate/1e5)),n&&(a+=(s?"_":"")+We(n.contentType)+"_c"+n.channels),a);return i[o]||(i[o]=r.decodingInfo(e))})).then(function(e){return{supported:!e.some(function(e){return!e.supported}),configurations:n,decodingInfoResults:e}}).catch(function(e){return{supported:!1,configurations:n,decodingInfoResults:[],error:e}})}function Dn(e,t){if(t<=1)return 1;var r=128e3;return"ec-3"===e?r=768e3:"ac-3"===e&&(r=64e4),Math.min(t/2,r)}function _n(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}var In=function(){function e(t){void 0===t&&(t={}),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new E,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var r=this.logger=K(t.debug||!1,"Hls instance",t.assetPlayerId),i=this.config=function(e,t,r){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var i=fa(e),a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(e){var n=("level"===e?"playlist":e)+"LoadPolicy",s=void 0===t[n],o=[];a.forEach(function(r){var a=e+"Loading"+r,l=t[a];if(void 0!==l&&s){o.push(a);var u=i[n].default;switch(t[n]={default:u},r){case"TimeOut":u.maxLoadTimeMs=l,u.maxTimeToFirstByteMs=l;break;case"MaxRetry":u.errorRetry.maxNumRetry=l,u.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":u.errorRetry.retryDelayMs=l,u.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=l,u.timeoutRetry.maxRetryDelayMs=l}}}),o.length&&r.warn('hls.js config: "'+o.join('", "')+'" setting(s) are deprecated, use "'+n+'": '+it(t[n]))}),d(d({},i),t)}(e.DefaultConfig,t,r);this.userConfig=t,i.progressive&&ca(i,r);var a=i.abrController,n=i.bufferController,s=i.capLevelController,o=i.errorController,l=i.fpsController,u=new o(this),h=this.abrController=new a(this),f=new ya(this),c=i.interstitialsController,v=c?this.interstitialsController=new c(this,e):null,g=this.bufferController=new n(this,f),m=this.capLevelController=new s(this),p=new l(this),y=new Rn(this),T=i.contentSteeringController,S=T?new T(this):null,L=this.levelController=new nn(this,S),R=new tn(this),A=new En(this.config,this.logger),b=this.streamController=new yn(this,f,A),k=this.gapController=new qa(this,f);m.setStreamController(b),p.setStreamController(b);var _=[y,L,b];v&&_.splice(1,0,v),S&&_.splice(1,0,S),this.networkControllers=_;var I=[h,g,k,m,p,R,f];this.audioTrackController=this.createController(i.audioTrackController,_);var C=i.audioStreamController;C&&_.push(this.audioStreamController=new C(this,f,A)),this.subtitleTrackController=this.createController(i.subtitleTrackController,_);var x=i.subtitleStreamController;x&&_.push(this.subtititleStreamController=new x(this,f,A)),this.createController(i.timelineController,I),A.emeController=this.emeController=this.createController(i.emeController,I),this.cmcdController=this.createController(i.cmcdController,I),this.latencyController=this.createController(rn,I),this.coreComponents=I,_.push(u);var w=u.onErrorOut;"function"==typeof w&&this.on(D.ERROR,w,u),this.on(D.MANIFEST_LOADED,y.onManifestLoaded,y)}e.isMSESupported=function(){return pn()},e.isSupported=function(){return function(){if(!pn())return!1;var e=z();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(t){return e.isTypeSupported(Fe(t,"video"))})||["mp4a.40.2","fLaC"].some(function(t){return e.isTypeSupported(Fe(t,"audio"))}))}()},e.getMediaSource=function(){return z()};var t=e.prototype;return t.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},t.on=function(e,t,r){void 0===r&&(r=this),this._emitter.on(e,t,r)},t.once=function(e,t,r){void 0===r&&(r=this),this._emitter.once(e,t,r)},t.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},t.off=function(e,t,r,i){void 0===r&&(r=this),this._emitter.off(e,t,r,i)},t.listeners=function(e){return this._emitter.listeners(e)},t.emit=function(e,t,r){return this._emitter.emit(e,t,r)},t.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;var r=e===D.ERROR;this.trigger(D.ERROR,{type:b.OTHER_ERROR,details:k.INTERNAL_EXCEPTION,fatal:r,event:e,error:t}),this.triggeringException=!1}}return!1},t.listenerCount=function(e){return this._emitter.listenerCount(e)},t.destroy=function(){this.logger.log("destroy"),this.trigger(D.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 e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},t.attachMedia=function(e){if(!e||"media"in e&&!e.media){var t=new Error("attachMedia failed: invalid argument ("+e+")");this.trigger(D.ERROR,{type:b.OTHER_ERROR,details:k.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}else{this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());var r="media"in e,i=r?e.media:e,a=r?e:{media:i};this._media=i,this.trigger(D.MEDIA_ATTACHING,a)}},t.detachMedia=function(){this.logger.log("detachMedia");var e={};this.trigger(D.MEDIA_DETACHING,e),this._media=null,this.trigger(D.MEDIA_DETACHED,e)},t.transferMedia=function(){this._media=null;var e=this.bufferController.transferMedia(),t={transferMedia:e};return this.trigger(D.MEDIA_DETACHING,t),this.trigger(D.MEDIA_DETACHED,t),e},t.loadSource=function(e){this.stopLoad();var t=this.media,r=this._url,i=this._url=S.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:"+i),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(D.MANIFEST_LOADING,{url:e})},t.startLoad=function(e,t){void 0===e&&(e=-1),this.logger.log("startLoad("+e+(t?", <skip seek to start>":"")+")"),this.started=!0,this.resumeBuffering();for(var r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(e,t),this.started&&this.networkControllers);r++);},t.stopLoad=function(){this.logger.log("stopLoad"),this.started=!1;for(var e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);},t.resumeBuffering=function(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(function(e){e.resumeBuffering&&e.resumeBuffering()}))},t.pauseBuffering=function(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(function(e){e.pauseBuffering&&e.pauseBuffering()}))},t.swapAudioCodec=function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.recoverMediaError=function(){this.logger.log("recoverMediaError");var e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))},t.removeLevel=function(e){this.levelController.removeLevel(e)},t.setAudioOption=function(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null},t.setSubtitleOption=function(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null},t.getMediaDecodingInfo=function(e,t){return void 0===t&&(t=this.allAudioTracks),kn(e,nt(t),navigator.mediaCapabilities)},i(e,[{key:"url",get:function(){return this._url}},{key:"hasEnoughToStart",get:function(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function(){return this.streamController.startPositionValue}},{key:"loadingEnabled",get:function(){return this.started}},{key:"bufferingEnabled",get:function(){return this.streamController.bufferingEnabled}},{key:"inFlightFragments",get:function(){var e,t=((e={})[w]=this.streamController.inFlightFrag,e);return this.audioStreamController&&(t[P]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(t[O]=this.subtititleStreamController.inFlightFrag),t}},{key:"sessionId",get:function(){var e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(i){try{var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){var r=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)})}}}()),e}},{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"latestLevelDetails",get:function(){return this.streamController.getLevelDetails()||null}},{key:"loadLevelObj",get:function(){return this.levelController.loadLevelObj}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){this.logger.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){this.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){this.logger.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){this.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){this.logger.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(this.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"abrEwmaDefaultEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(e){return qe.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=-1===r&&null!=t&&t.length?t.length-1:r,i)for(var a=e;a--;){var n=t[a].attrs["HDCP-LEVEL"];if(n&&n<=i)return a}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{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},set:function(e){this.latencyController.targetLatency=e}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathways",get:function(){return this.levelController.pathways}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(e){this.levelController.pathwayPriority=e}},{key:"bufferedToEnd",get:function(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}}],[{key:"version",get:function(){return fn}},{key:"Events",get:function(){return D}},{key:"MetadataSchema",get:function(){return ri}},{key:"ErrorTypes",get:function(){return b}},{key:"ErrorDetails",get:function(){return k}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:ha},set:function(t){e.defaultConfig=t}}])}();return In.defaultConfig=void 0,In},"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(r="undefined"!=typeof globalThis?globalThis:r||self).Hls=i()}(!1);
2
2
  //# sourceMappingURL=hls.light.min.js.map