lemon-mse 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/_hls.d.ts +3105 -0
- package/dist/es/flv.d.ts +410 -0
- package/dist/es/flv.js +1 -0
- package/dist/es/hls.d.ts +3 -0
- package/dist/es/hls.js +1 -0
- package/dist/es/index.d.ts +4 -0
- package/dist/es/index.js +1 -0
- package/dist/flv.js +1 -0
- package/dist/hls.js +1 -0
- package/dist/index.js +1 -0
- package/package.json +14 -9
- package/build.config.ts +0 -22
- package/dist/hls.d.mts +0 -7
- package/dist/hls.d.ts +0 -7
- package/dist/hls.mjs +0 -14
- package/dist/xg-flv-hls.d.mts +0 -9
- package/dist/xg-flv-hls.d.ts +0 -9
- package/dist/xg-flv-hls.mjs +0 -8
- package/dist/xg-flv.d.mts +0 -1
- package/dist/xg-flv.d.ts +0 -1
- package/dist/xg-flv.mjs +0 -6
- package/dist/xg-hls.d.mts +0 -1
- package/dist/xg-hls.d.ts +0 -1
- package/dist/xg-hls.mjs +0 -8
- package/src/hls.ts +0 -8
- package/src/xg-flv-hls.ts +0 -4
- package/src/xg-flv.ts +0 -2
- package/src/xg-hls.ts +0 -1
- package/tsconfig.json +0 -28
package/dist/hls.mjs
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
function so(Fe){return Fe&&Fe.__esModule&&Object.prototype.hasOwnProperty.call(Fe,"default")?Fe.default:Fe}var Gi={exports:{}};(function(Fe,lo){(function er(tr){(function(yt,ge){Fe.exports=ge()})(this,function(){function yt(a,n){var i=Object.keys(a);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(a);n&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(a,t).enumerable})),i.push.apply(i,e)}return i}function ge(a){for(var n=1;n<arguments.length;n++){var i=arguments[n]!=null?arguments[n]:{};n%2?yt(Object(i),!0).forEach(function(e){Ki(a,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(i)):yt(Object(i)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(i,e))})}return a}function Vi(a,n){if(typeof a!="object"||!a)return a;var i=a[Symbol.toPrimitive];if(i!==void 0){var e=i.call(a,n||"default");if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(a)}function rr(a){var n=Vi(a,"string");return typeof n=="symbol"?n:String(n)}function ir(a,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,rr(e.key),e)}}function he(a,n,i){return n&&ir(a.prototype,n),i&&ir(a,i),Object.defineProperty(a,"prototype",{writable:!1}),a}function Ki(a,n,i){return n=rr(n),n in a?Object.defineProperty(a,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):a[n]=i,a}function ye(){return ye=Object.assign?Object.assign.bind():function(a){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(a[e]=i[e])}return a},ye.apply(this,arguments)}function Re(a,n){a.prototype=Object.create(n.prototype),a.prototype.constructor=a,We(a,n)}function Et(a){return Et=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},Et(a)}function We(a,n){return We=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},We(a,n)}function Wi(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Xe(a,n,i){return Wi()?Xe=Reflect.construct.bind():Xe=function(t,r,s){var o=[null];o.push.apply(o,r);var l=Function.bind.apply(t,o),u=new l;return s&&We(u,s.prototype),u},Xe.apply(null,arguments)}function Yi(a){try{return Function.toString.call(a).indexOf("[native code]")!==-1}catch{return typeof a=="function"}}function ze(a){var n=typeof Map=="function"?new Map:void 0;return ze=function(e){if(e===null||!Yi(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(typeof n<"u"){if(n.has(e))return n.get(e);n.set(e,t)}function t(){return Xe(e,arguments,Et(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),We(t,e)},ze(a)}function qi(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function nr(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var ar={exports:{}};(function(a,n){(function(i){var e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,t=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,s=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,u,d){if(d=d||{},l=l.trim(),u=u.trim(),!u){if(!d.alwaysNormalize)return l;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");return f.path=o.normalizePath(f.path),o.buildURLFromParts(f)}var h=o.parseURL(u);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return d.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):u;var c=o.parseURL(l);if(!c)throw new Error("Error trying to parse base URL.");if(!c.netLoc&&c.path&&c.path[0]!=="/"){var v=t.exec(c.path);c.netLoc=v[1],c.path=v[2]}c.netLoc&&!c.path&&(c.path="/");var m={scheme:c.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(m.netLoc=c.netLoc,h.path[0]!=="/"))if(!h.path)m.path=c.path,h.params||(m.params=c.params,h.query||(m.query=c.query));else{var g=c.path,p=g.substring(0,g.lastIndexOf("/")+1)+h.path;m.path=o.normalizePath(p)}return m.path===null&&(m.path=d.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(m)},parseURL:function(l){var u=e.exec(l);return u?{scheme:u[1]||"",netLoc:u[2]||"",path:u[3]||"",params:u[4]||"",query:u[5]||"",fragment:u[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(r,"");l.length!==(l=l.replace(s,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};a.exports=o})()})(ar);var xt=ar.exports,O=Number.isFinite||function(a){return typeof a=="number"&&isFinite(a)},ji=Number.isSafeInteger||function(a){return typeof a=="number"&&Math.abs(a)<=Xi},Xi=Number.MAX_SAFE_INTEGER||9007199254740991,x=function(a){return a.MEDIA_ATTACHING="hlsMediaAttaching",a.MEDIA_ATTACHED="hlsMediaAttached",a.MEDIA_DETACHING="hlsMediaDetaching",a.MEDIA_DETACHED="hlsMediaDetached",a.BUFFER_RESET="hlsBufferReset",a.BUFFER_CODECS="hlsBufferCodecs",a.BUFFER_CREATED="hlsBufferCreated",a.BUFFER_APPENDING="hlsBufferAppending",a.BUFFER_APPENDED="hlsBufferAppended",a.BUFFER_EOS="hlsBufferEos",a.BUFFER_FLUSHING="hlsBufferFlushing",a.BUFFER_FLUSHED="hlsBufferFlushed",a.MANIFEST_LOADING="hlsManifestLoading",a.MANIFEST_LOADED="hlsManifestLoaded",a.MANIFEST_PARSED="hlsManifestParsed",a.LEVEL_SWITCHING="hlsLevelSwitching",a.LEVEL_SWITCHED="hlsLevelSwitched",a.LEVEL_LOADING="hlsLevelLoading",a.LEVEL_LOADED="hlsLevelLoaded",a.LEVEL_UPDATED="hlsLevelUpdated",a.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",a.LEVELS_UPDATED="hlsLevelsUpdated",a.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",a.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",a.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",a.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",a.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",a.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",a.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",a.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",a.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",a.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",a.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",a.CUES_PARSED="hlsCuesParsed",a.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",a.INIT_PTS_FOUND="hlsInitPtsFound",a.FRAG_LOADING="hlsFragLoading",a.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",a.FRAG_LOADED="hlsFragLoaded",a.FRAG_DECRYPTED="hlsFragDecrypted",a.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",a.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",a.FRAG_PARSING_METADATA="hlsFragParsingMetadata",a.FRAG_PARSED="hlsFragParsed",a.FRAG_BUFFERED="hlsFragBuffered",a.FRAG_CHANGED="hlsFragChanged",a.FPS_DROP="hlsFpsDrop",a.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",a.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",a.ERROR="hlsError",a.DESTROYING="hlsDestroying",a.KEY_LOADING="hlsKeyLoading",a.KEY_LOADED="hlsKeyLoaded",a.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",a.BACK_BUFFER_REACHED="hlsBackBufferReached",a.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",a}({}),V=function(a){return a.NETWORK_ERROR="networkError",a.MEDIA_ERROR="mediaError",a.KEY_SYSTEM_ERROR="keySystemError",a.MUX_ERROR="muxError",a.OTHER_ERROR="otherError",a}({}),_=function(a){return a.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",a.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",a.KEY_SYSTEM_NO_SESSION="keySystemNoSession",a.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",a.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",a.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",a.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",a.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",a.MANIFEST_LOAD_ERROR="manifestLoadError",a.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",a.MANIFEST_PARSING_ERROR="manifestParsingError",a.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",a.LEVEL_EMPTY_ERROR="levelEmptyError",a.LEVEL_LOAD_ERROR="levelLoadError",a.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",a.LEVEL_PARSING_ERROR="levelParsingError",a.LEVEL_SWITCH_ERROR="levelSwitchError",a.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",a.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",a.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",a.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",a.FRAG_LOAD_ERROR="fragLoadError",a.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",a.FRAG_DECRYPT_ERROR="fragDecryptError",a.FRAG_PARSING_ERROR="fragParsingError",a.FRAG_GAP="fragGap",a.REMUX_ALLOC_ERROR="remuxAllocError",a.KEY_LOAD_ERROR="keyLoadError",a.KEY_LOAD_TIMEOUT="keyLoadTimeOut",a.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",a.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",a.BUFFER_APPEND_ERROR="bufferAppendError",a.BUFFER_APPENDING_ERROR="bufferAppendingError",a.BUFFER_STALLED_ERROR="bufferStalledError",a.BUFFER_FULL_ERROR="bufferFullError",a.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",a.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",a.INTERNAL_EXCEPTION="internalException",a.INTERNAL_ABORTED="aborted",a.UNKNOWN="unknown",a}({}),Oe=function(){},Tt={trace:Oe,debug:Oe,log:Oe,warn:Oe,info:Oe,error:Oe},Ye=Tt;function zi(a){var n=self.console[a];return n?n.bind(self.console,"["+a+"] >"):Oe}function $i(a){for(var n=arguments.length,i=new Array(n>1?n-1:0),e=1;e<n;e++)i[e-1]=arguments[e];i.forEach(function(t){Ye[t]=a[t]?a[t].bind(a):zi(t)})}function sr(a,n){if(typeof console=="object"&&a===!0||typeof a=="object"){$i(a,"debug","log","info","warn","error");try{Ye.log('Debug logs enabled for "'+n+'" in hls.js version 1.5.8')}catch{Ye=Tt}}else Ye=Tt}var A=Ye,Qi=/^(\d+)x(\d+)$/,or=/(.+?)=(".*?"|.*?)(?:,|$)/g,ne=function(){function a(i){typeof i=="string"&&(i=a.parseAttrList(i)),ye(this,i)}var n=a.prototype;return n.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},n.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;for(var r=new Uint8Array(t.length/2),s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null},n.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},n.decimalFloatingPoint=function(e){return parseFloat(this[e])},n.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},n.enumeratedString=function(e){return this[e]},n.bool=function(e){return this[e]==="YES"},n.decimalResolution=function(e){var t=Qi.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},a.parseAttrList=function(e){var t,r={},s='"';for(or.lastIndex=0;(t=or.exec(e))!==null;){var o=t[2];o.indexOf(s)===0&&o.lastIndexOf(s)===o.length-1&&(o=o.slice(1,-1));var l=t[1].trim();r[l]=o}return r},he(a,[{key:"clientAttrs",get:function(){return Object.keys(this).filter(function(e){return e.substring(0,2)==="X-"})}}]),a}();function Zi(a){return a!=="ID"&&a!=="CLASS"&&a!=="START-DATE"&&a!=="DURATION"&&a!=="END-DATE"&&a!=="END-ON-NEXT"}function Ji(a){return a==="SCTE35-OUT"||a==="SCTE35-IN"}var lr=function(){function a(n,i){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,i){var e=i.attr;for(var t in e)if(Object.prototype.hasOwnProperty.call(n,t)&&n[t]!==e[t]){A.warn('DATERANGE tag attribute: "'+t+'" does not match for tags with ID: "'+n.ID+'"'),this._badValueForSameId=t;break}n=ye(new ne({}),e,n)}if(this.attr=n,this._startDate=new Date(n["START-DATE"]),"END-DATE"in this.attr){var r=new Date(this.attr["END-DATE"]);O(r.getTime())&&(this._endDate=r)}}return he(a,[{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 i=this.duration;return i!==null?new Date(this._startDate.getTime()+i*1e3):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var i=this.attr.decimalFloatingPoint("DURATION");if(O(i))return i}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&&O(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),a}(),$e=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}},$={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},ur=function(){function a(i){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(e={},e[$.AUDIO]=null,e[$.VIDEO]=null,e[$.AUDIOVIDEO]=null,e),this.baseurl=i}var n=a.prototype;return n.setByteRange=function(e,t){var r=e.split("@",2),s;r.length===1?s=t?.byteRangeEndOffset||0:s=parseInt(r[1]),this._byteRange=[s,parseInt(r[0])+s]},he(a,[{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=xt.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),a}(),St=function(a){Re(n,a);function n(e,t){var r;return r=a.call(this,t)||this,r._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkeys=void 0,r.type=void 0,r.loader=null,r.keyLoader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new $e,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.endList=void 0,r.gap=void 0,r.urlId=0,r.type=e,r}var i=n.prototype;return i.setKeyFormat=function(t){if(this.levelkeys){var r=this.levelkeys[t];r&&!this._decryptdata&&(this._decryptdata=r.getDecryptData(this.sn))}},i.abortRequests=function(){var t,r;(t=this.loader)==null||t.abort(),(r=this.keyLoader)==null||r.abort()},i.setElementaryStreamInfo=function(t,r,s,o,l,u){u===void 0&&(u=!1);var d=this.elementaryStreams,f=d[t];if(!f){d[t]={startPTS:r,endPTS:s,startDTS:o,endDTS:l,partial:u};return}f.startPTS=Math.min(f.startPTS,r),f.endPTS=Math.max(f.endPTS,s),f.startDTS=Math.min(f.startDTS,o),f.endDTS=Math.max(f.endDTS,l)},i.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[$.AUDIO]=null,t[$.VIDEO]=null,t[$.AUDIOVIDEO]=null},he(n,[{key:"decryptdata",get:function(){var t=this.levelkeys;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var r=this.levelkeys.identity;if(r)this._decryptdata=r.getDecryptData(this.sn);else{var s=Object.keys(this.levelkeys);if(s.length===1)return this._decryptdata=this.levelkeys[s[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!O(this.programDateTime))return null;var t=O(this.duration)?this.duration:0;return this.programDateTime+t*1e3}},{key:"encrypted",get:function(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){var r=Object.keys(this.levelkeys),s=r.length;if(s>1||s===1&&this.levelkeys[r[0]].encrypted)return!0}return!1}}]),n}(ur),en=function(a){Re(n,a);function n(i,e,t,r,s){var o;o=a.call(this,t)||this,o.fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.stats=new $e,o.duration=i.decimalFloatingPoint("DURATION"),o.gap=i.bool("GAP"),o.independent=i.bool("INDEPENDENT"),o.relurl=i.enumeratedString("URI"),o.fragment=e,o.index=r;var l=i.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,s),s&&(o.fragOffset=s.fragOffset+s.duration),o}return he(n,[{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)}}]),n}(ur),tn=10,rn=function(){function a(i){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=i}var n=a.prototype;return n.reloaded=function(e){if(!e){this.advanced=!0,this.updated=!0;return}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||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},he(a,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?O(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||tn}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;if(e>0){var t=this.driftEnd-this.driftStart;return t*1e3/e}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return(e=this.fragments)!=null&&e.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 e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),a}(),nn=void 0,an=nr(nn);function Me(a,n,i){return Uint8Array.prototype.slice?a.slice(n,i):new Uint8Array(Array.prototype.slice.call(a,n,i))}var Lt=function(n,i){return i+10<=n.length&&n[i]===73&&n[i+1]===68&&n[i+2]===51&&n[i+3]<255&&n[i+4]<255&&n[i+6]<128&&n[i+7]<128&&n[i+8]<128&&n[i+9]<128},fr=function(n,i){return i+10<=n.length&&n[i]===51&&n[i+1]===68&&n[i+2]===73&&n[i+3]<255&&n[i+4]<255&&n[i+6]<128&&n[i+7]<128&&n[i+8]<128&&n[i+9]<128},Qe=function(n,i){for(var e=i,t=0;Lt(n,i);){t+=10;var r=Ze(n,i+6);t+=r,fr(n,i+10)&&(t+=10),i+=t}if(t>0)return n.subarray(e,e+t)},Ze=function(n,i){var e=0;return e=(n[i]&127)<<21,e|=(n[i+1]&127)<<14,e|=(n[i+2]&127)<<7,e|=n[i+3]&127,e},sn=function(n,i){return Lt(n,i)&&Ze(n,i+6)+10<=n.length-i},dr=function(n){for(var i=cr(n),e=0;e<i.length;e++){var t=i[e];if(hr(t))return hn(t)}},hr=function(n){return n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp"},on=function(n){var i=String.fromCharCode(n[0],n[1],n[2],n[3]),e=Ze(n,4),t=10;return{type:i,size:e,data:n.subarray(t,t+e)}},cr=function(n){for(var i=0,e=[];Lt(n,i);){var t=Ze(n,i+6);i+=10;for(var r=i+t;i+8<r;){var s=on(n.subarray(i)),o=ln(s);o&&e.push(o),i+=s.size+10}fr(n,i)&&(i+=10)}return e},ln=function(n){return n.type==="PRIV"?un(n):n.type[0]==="W"?dn(n):fn(n)},un=function(n){if(!(n.size<2)){var i=we(n.data,!0),e=new Uint8Array(n.data.subarray(i.length+1));return{key:n.type,info:i,data:e.buffer}}},fn=function(n){if(!(n.size<2)){if(n.type==="TXXX"){var i=1,e=we(n.data.subarray(i),!0);i+=e.length+1;var t=we(n.data.subarray(i));return{key:n.type,info:e,data:t}}var r=we(n.data.subarray(1));return{key:n.type,data:r}}},dn=function(n){if(n.type==="WXXX"){if(n.size<2)return;var i=1,e=we(n.data.subarray(i),!0);i+=e.length+1;var t=we(n.data.subarray(i));return{key:n.type,info:e,data:t}}var r=we(n.data);return{key:n.type,data:r}},hn=function(n){if(n.data.byteLength===8){var i=new Uint8Array(n.data),e=i[3]&1,t=(i[4]<<23)+(i[5]<<15)+(i[6]<<7)+i[7];return t/=45,e&&(t+=4772185884e-2),Math.round(t)}},we=function(n,i){i===void 0&&(i=!1);var e=cn();if(e){var t=e.decode(n);if(i){var r=t.indexOf("\0");return r!==-1?t.substring(0,r):t}return t.replace(/\0/g,"")}for(var s=n.length,o,l,u,d="",f=0;f<s;){if(o=n[f++],o===0&&i)return d;if(o===0||o===3)continue;switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(o);break;case 12:case 13:l=n[f++],d+=String.fromCharCode((o&31)<<6|l&63);break;case 14:l=n[f++],u=n[f++],d+=String.fromCharCode((o&15)<<12|(l&63)<<6|(u&63)<<0);break}}return d},At;function cn(){if(!navigator.userAgent.includes("PlayStation 4"))return!At&&typeof self.TextDecoder<"u"&&(At=new self.TextDecoder("utf-8")),At}var vr={hexDump:function(n){for(var i="",e=0;e<n.length;e++){var t=n[e].toString(16);t.length<2&&(t="0"+t),i+=t}return i}},Je=Math.pow(2,32)-1,vn=[].push,gr={video:1,audio:2,id3:3,text:4};function se(a){return String.fromCharCode.apply(null,a)}function mr(a,n){var i=a[n]<<8|a[n+1];return i<0?65536+i:i}function N(a,n){var i=yr(a,n);return i<0?4294967296+i:i}function pr(a,n){var i=N(a,n);return i*=Math.pow(2,32),i+=N(a,n+4),i}function yr(a,n){return a[n]<<24|a[n+1]<<16|a[n+2]<<8|a[n+3]}function Rt(a,n,i){a[n]=i>>24,a[n+1]=i>>16&255,a[n+2]=i>>8&255,a[n+3]=i&255}function gn(a){for(var n=a.byteLength,i=0;i<n;){var e=N(a,i);if(e>8&&a[i+4]===109&&a[i+5]===111&&a[i+6]===111&&a[i+7]===102)return!0;i=e>1?i+e:n}return!1}function G(a,n){var i=[];if(!n.length)return i;for(var e=a.byteLength,t=0;t<e;){var r=N(a,t),s=se(a.subarray(t+4,t+8)),o=r>1?t+r:e;if(s===n[0])if(n.length===1)i.push(a.subarray(t+8,o));else{var l=G(a.subarray(t+8,o),n.slice(1));l.length&&vn.apply(i,l)}t=o}return i}function mn(a){var n=[],i=a[0],e=8,t=N(a,e);e+=4;var r=0,s=0;i===0?(r=N(a,e),s=N(a,e+4),e+=8):(r=pr(a,e),s=pr(a,e+8),e+=16),e+=2;var o=a.length+s,l=mr(a,e);e+=2;for(var u=0;u<l;u++){var d=e,f=N(a,d);d+=4;var h=f&2147483647,c=(f&2147483648)>>>31;if(c===1)return A.warn("SIDX has hierarchical references (not supported)"),null;var v=N(a,d);d+=4,n.push({referenceSize:h,subsegmentDuration:v,info:{duration:v/t,start:o,end:o+h-1}}),o+=h,d+=4,e=d}return{earliestPresentationTime:r,timescale:t,version:i,referencesCount:l,references:n}}function Er(a){for(var n=[],i=G(a,["moov","trak"]),e=0;e<i.length;e++){var t=i[e],r=G(t,["tkhd"])[0];if(r){var s=r[0],o=N(r,s===0?12:20),l=G(t,["mdia","mdhd"])[0];if(l){s=l[0];var u=N(l,s===0?12:20),d=G(t,["mdia","hdlr"])[0];if(d){var f=se(d.subarray(8,12)),h={soun:$.AUDIO,vide:$.VIDEO}[f];if(h){var c=G(t,["mdia","minf","stbl","stsd"])[0],v=pn(c);n[o]={timescale:u,type:h},n[h]=ge({timescale:u,id:o},v)}}}}}var m=G(a,["moov","mvex","trex"]);return m.forEach(function(g){var p=N(g,4),y=n[p];y&&(y.default={duration:N(g,12),flags:N(g,20)})}),n}function pn(a){var n=a.subarray(8),i=n.subarray(86),e=se(n.subarray(4,8)),t=e,r=e==="enca"||e==="encv";if(r){var s=G(n,[e])[0],o=s.subarray(e==="enca"?28:78),l=G(o,["sinf"]);l.forEach(function(pe){var de=G(pe,["schm"])[0];if(de){var le=se(de.subarray(4,8));if(le==="cbcs"||le==="cenc"){var Ue=G(pe,["frma"])[0];Ue&&(t=se(Ue))}}})}switch(t){case"avc1":case"avc2":case"avc3":case"avc4":{var u=G(i,["avcC"])[0];t+="."+et(u[1])+et(u[2])+et(u[3]);break}case"mp4a":{var d=G(n,[e])[0],f=G(d.subarray(28),["esds"])[0];if(f&&f.length>12){var h=4;if(f[h++]!==3)break;h=bt(f,h),h+=2;var c=f[h++];if(c&128&&(h+=2),c&64&&(h+=f[h++]),f[h++]!==4)break;h=bt(f,h);var v=f[h++];if(v===64)t+="."+et(v);else break;if(h+=12,f[h++]!==5)break;h=bt(f,h);var m=f[h++],g=(m&248)>>3;g===31&&(g+=1+((m&7)<<3)+((f[h]&224)>>5)),t+="."+g}break}case"hvc1":case"hev1":{var p=G(i,["hvcC"])[0],y=p[1],E=["","A","B","C"][y>>6],S=y&31,L=N(p,2),D=(y&32)>>5?"H":"L",R=p[12],T=p.subarray(6,12);t+="."+E+S,t+="."+L.toString(16).toUpperCase(),t+="."+D+R;for(var b="",I=T.length;I--;){var P=T[I];if(P||b){var C=P.toString(16).toUpperCase();b="."+C+b}}t+=b;break}case"dvh1":case"dvhe":{var w=G(i,["dvcC"])[0],M=w[2]>>1&127,F=w[2]<<5&32|w[3]>>3&31;t+="."+be(M)+"."+be(F);break}case"vp09":{var H=G(i,["vpcC"])[0],U=H[4],W=H[5],K=H[6]>>4&15;t+="."+be(U)+"."+be(W)+"."+be(K);break}case"av01":{var B=G(i,["av1C"])[0],Q=B[1]>>>5,q=B[1]&31,J=B[2]>>>7?"H":"M",ee=(B[2]&64)>>6,re=(B[2]&32)>>5,Z=Q===2&&ee?re?12:10:ee?10:8,X=(B[2]&16)>>4,Pe=(B[2]&8)>>3,Ee=(B[2]&4)>>2,te=B[2]&3,ce=1,ve=1,ie=1,z=0;t+="."+Q+"."+be(q)+J+"."+be(Z)+"."+X+"."+Pe+Ee+te+"."+be(ce)+"."+be(ve)+"."+be(ie)+"."+z;break}}return{codec:t,encrypted:r}}function bt(a,n){for(var i=n+5;a[n++]&128&&n<i;);return n}function et(a){return("0"+a.toString(16).toUpperCase()).slice(-2)}function be(a){return(a<10?"0":"")+a}function yn(a,n){if(!a||!n)return a;var i=n.keyId;if(i&&n.isCommonEncryption){var e=G(a,["moov","trak"]);e.forEach(function(t){var r=G(t,["mdia","minf","stbl","stsd"])[0],s=r.subarray(8),o=G(s,["enca"]),l=o.length>0;l||(o=G(s,["encv"])),o.forEach(function(u){var d=l?u.subarray(28):u.subarray(78),f=G(d,["sinf"]);f.forEach(function(h){var c=En(h);if(c){var v=c.subarray(8,24);v.some(function(m){return m!==0})||(A.log("[eme] Patching keyId in 'enc"+(l?"a":"v")+">sinf>>tenc' box: "+vr.hexDump(v)+" -> "+vr.hexDump(i)),c.set(i,8))}})})})}return a}function En(a){var n=G(a,["schm"])[0];if(n){var i=se(n.subarray(4,8));if(i==="cbcs"||i==="cenc")return G(a,["schi","tenc"])[0]}return A.error("[eme] missing 'schm' box"),null}function xn(a,n){return G(n,["moof","traf"]).reduce(function(i,e){var t=G(e,["tfdt"])[0],r=t[0],s=G(e,["tfhd"]).reduce(function(o,l){var u=N(l,4),d=a[u];if(d){var f=N(t,4);if(r===1){if(f===Je)return A.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;f*=Je+1,f+=N(t,8)}var h=d.timescale||9e4,c=f/h;if(O(c)&&(o===null||c<o))return c}return o},null);return s!==null&&O(s)&&(i===null||s<i)?s:i},null)}function Tn(a,n){for(var i=0,e=0,t=0,r=G(a,["moof","traf"]),s=0;s<r.length;s++){var o=r[s],l=G(o,["tfhd"])[0],u=N(l,4),d=n[u];if(d){var f=d.default,h=N(l,0)|f?.flags,c=f?.duration;h&8&&(h&2?c=N(l,12):c=N(l,8));for(var v=d.timescale||9e4,m=G(o,["trun"]),g=0;g<m.length;g++){if(i=Sn(m[g]),!i&&c){var p=N(m[g],4);i=c*p}d.type===$.VIDEO?e+=i/v:d.type===$.AUDIO&&(t+=i/v)}}}if(e===0&&t===0){for(var y=1/0,E=0,S=0,L=G(a,["sidx"]),D=0;D<L.length;D++){var R=mn(L[D]);if(R!=null&&R.references){y=Math.min(y,R.earliestPresentationTime/R.timescale);var T=R.references.reduce(function(b,I){return b+I.info.duration||0},0);E=Math.max(E,T+R.earliestPresentationTime/R.timescale),S=E-y}}if(S&&O(S))return S}return e||t}function Sn(a){var n=N(a,0),i=8;n&1&&(i+=4),n&4&&(i+=4);for(var e=0,t=N(a,4),r=0;r<t;r++){if(n&256){var s=N(a,i);e+=s,i+=4}n&512&&(i+=4),n&1024&&(i+=4),n&2048&&(i+=4)}return e}function Ln(a,n,i){G(n,["moof","traf"]).forEach(function(e){G(e,["tfhd"]).forEach(function(t){var r=N(t,4),s=a[r];if(s){var o=s.timescale||9e4;G(e,["tfdt"]).forEach(function(l){var u=l[0],d=i*o;if(d){var f=N(l,4);if(u===0)f-=d,f=Math.max(f,0),Rt(l,4,f);else{f*=Math.pow(2,32),f+=N(l,8),f-=d,f=Math.max(f,0);var h=Math.floor(f/(Je+1)),c=Math.floor(f%(Je+1));Rt(l,4,h),Rt(l,8,c)}}})}})})}function An(a){var n={valid:null,remainder:null},i=G(a,["moof"]);if(i.length<2)return n.remainder=a,n;var e=i[i.length-1];return n.valid=Me(a,0,e.byteOffset-8),n.remainder=Me(a,e.byteOffset-8),n}function xe(a,n){var i=new Uint8Array(a.length+n.length);return i.set(a),i.set(n,a.length),i}function xr(a,n){var i=[],e=n.samples,t=n.timescale,r=n.id,s=!1,o=G(e,["moof"]);return o.map(function(l){var u=l.byteOffset-8,d=G(l,["traf"]);d.map(function(f){var h=G(f,["tfdt"]).map(function(c){var v=c[0],m=N(c,4);return v===1&&(m*=Math.pow(2,32),m+=N(c,8)),m/t})[0];return h!==void 0&&(a=h),G(f,["tfhd"]).map(function(c){var v=N(c,4),m=N(c,0)&16777215,g=(m&1)!==0,p=(m&2)!==0,y=(m&8)!==0,E=0,S=(m&16)!==0,L=0,D=(m&32)!==0,R=8;v===r&&(g&&(R+=8),p&&(R+=4),y&&(E=N(c,R),R+=4),S&&(L=N(c,R),R+=4),D&&(R+=4),n.type==="video"&&(s=Rn(n.codec)),G(f,["trun"]).map(function(T){var b=T[0],I=N(T,0)&16777215,P=(I&1)!==0,C=0,w=(I&4)!==0,M=(I&256)!==0,F=0,H=(I&512)!==0,U=0,W=(I&1024)!==0,K=(I&2048)!==0,B=0,Q=N(T,4),q=8;P&&(C=N(T,q),q+=4),w&&(q+=4);for(var J=C+u,ee=0;ee<Q;ee++){if(M?(F=N(T,q),q+=4):F=E,H?(U=N(T,q),q+=4):U=L,W&&(q+=4),K&&(b===0?B=N(T,q):B=yr(T,q),q+=4),n.type===$.VIDEO)for(var re=0;re<U;){var Z=N(e,J);if(J+=4,bn(s,e[J])){var X=e.subarray(J,J+Z);Tr(X,s?2:1,a+B/t,i)}J+=Z,re+=Z+4}a+=F/t}}))})})}),i}function Rn(a){if(!a)return!1;var n=a.indexOf("."),i=n<0?a:a.substring(0,n);return i==="hvc1"||i==="hev1"||i==="dvh1"||i==="dvhe"}function bn(a,n){if(a){var i=n>>1&63;return i===39||i===40}else{var e=n&31;return e===6}}function Tr(a,n,i,e){var t=Sr(a),r=0;r+=n;for(var s=0,o=0,l=0;r<t.length;){s=0;do{if(r>=t.length)break;l=t[r++],s+=l}while(l===255);o=0;do{if(r>=t.length)break;l=t[r++],o+=l}while(l===255);var u=t.length-r,d=r;if(o<u)r+=o;else if(o>u){A.error("Malformed SEI payload. "+o+" is too small, only "+u+" bytes left to parse.");break}if(s===4){var f=t[d++];if(f===181){var h=mr(t,d);if(d+=2,h===49){var c=N(t,d);if(d+=4,c===1195456820){var v=t[d++];if(v===3){var m=t[d++],g=31&m,p=64&m,y=p?2+g*3:0,E=new Uint8Array(y);if(p){E[0]=m;for(var S=1;S<y;S++)E[S]=t[d++]}e.push({type:v,payloadType:s,pts:i,bytes:E})}}}}}else if(s===5&&o>16){for(var L=[],D=0;D<16;D++){var R=t[d++].toString(16);L.push(R.length==1?"0"+R:R),(D===3||D===5||D===7||D===9)&&L.push("-")}for(var T=o-16,b=new Uint8Array(T),I=0;I<T;I++)b[I]=t[d++];e.push({payloadType:s,pts:i,uuid:L.join(""),userData:we(b),userDataBytes:b})}}}function Sr(a){for(var n=a.byteLength,i=[],e=1;e<n-2;)a[e]===0&&a[e+1]===0&&a[e+2]===3?(i.push(e+2),e+=2):e++;if(i.length===0)return a;var t=n-i.length,r=new Uint8Array(t),s=0;for(e=0;e<t;s++,e++)s===i[0]&&(s++,i.shift()),r[e]=a[s];return r}function In(a){var n=a[0],i="",e="",t=0,r=0,s=0,o=0,l=0,u=0;if(n===0){for(;se(a.subarray(u,u+1))!=="\0";)i+=se(a.subarray(u,u+1)),u+=1;for(i+=se(a.subarray(u,u+1)),u+=1;se(a.subarray(u,u+1))!=="\0";)e+=se(a.subarray(u,u+1)),u+=1;e+=se(a.subarray(u,u+1)),u+=1,t=N(a,12),r=N(a,16),o=N(a,20),l=N(a,24),u=28}else if(n===1){u+=4,t=N(a,u),u+=4;var d=N(a,u);u+=4;var f=N(a,u);for(u+=4,s=Math.pow(2,32)*d+f,ji(s)||(s=Number.MAX_SAFE_INTEGER,A.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=N(a,u),u+=4,l=N(a,u),u+=4;se(a.subarray(u,u+1))!=="\0";)i+=se(a.subarray(u,u+1)),u+=1;for(i+=se(a.subarray(u,u+1)),u+=1;se(a.subarray(u,u+1))!=="\0";)e+=se(a.subarray(u,u+1)),u+=1;e+=se(a.subarray(u,u+1)),u+=1}var h=a.subarray(u,a.byteLength);return{schemeIdUri:i,value:e,timeScale:t,presentationTime:s,presentationTimeDelta:r,eventDuration:o,id:l,payload:h}}var _n=function(){a.clearKeyUriToKeyIdMap=function(){};function a(i,e,t,r,s){r===void 0&&(r=[1]),s===void 0&&(s=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=i,this.uri=e,this.keyFormat=t,this.keyFormatVersions=r,this.iv=s,this.encrypted=i?i!=="NONE":!1,this.isCommonEncryption=this.encrypted&&i!=="AES-128"}var n=a.prototype;return n.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES"}return!1},n.getDecryptData=function(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&A.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=Dn(e),r=new a(this.method,this.uri,"identity",this.keyFormatVersions,t);return r}return this},a}();function Dn(a){for(var n=new Uint8Array(16),i=12;i<16;i++)n[i]=a>>8*(15-i)&255;return n}function Ne(a){if(a===void 0&&(a=!0),!(typeof self>"u")){var n=(a||!self.MediaSource)&&self.ManagedMediaSource;return n||self.MediaSource||self.WebKitMediaSource}}function Cn(a){return typeof self<"u"&&a===self.ManagedMediaSource}var tt={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Pn(a,n){var i=tt[n];return!!i&&!!i[a.slice(0,4)]}function It(a,n,i){return i===void 0&&(i=!0),!a.split(",").some(function(e){return!Lr(e,n,i)})}function Lr(a,n,i){var e;i===void 0&&(i=!0);var t=Ne(i);return(e=t?.isTypeSupported(_t(a,n)))!=null?e:!1}function _t(a,n){return n+'/mp4;codecs="'+a+'"'}function Ar(a){if(a){var n=a.substring(0,4);return tt.video[n]}return 2}function rt(a){return a.split(",").reduce(function(n,i){var e=tt.video[i];return e?(e*2+n)/(n?3:2):(tt.audio[i]+n)/(n?2:1)},0)}var Dt={};function wn(a,n){if(n===void 0&&(n=!0),Dt[a])return Dt[a];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[a],e=0;e<i.length;e++)if(Lr(i[e],"audio",n))return Dt[a]=i[e],i[e];return a}var kn=/flac|opus/i;function it(a,n){return n===void 0&&(n=!0),a.replace(kn,function(i){return wn(i.toLowerCase(),n)})}function Rr(a,n){return a&&a!=="mp4a"?a:n&&n.split(",")[0]}function Fn(a){var n=a.split(".");if(n.length>2){var i=n.shift()+".";return i+=parseInt(n.shift()).toString(16),i+=("000"+parseInt(n.shift()).toString(16)).slice(-4),i}return a}var br=/#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,Ir=/#EXT-X-MEDIA:(.*)/g,On=/^#EXT(?:INF|-X-TARGETDURATION):/m,_r=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Mn=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),qe=function(){function a(){}return a.findGroup=function(i,e){for(var t=0;t<i.length;t++){var r=i[t];if(r.id===e)return r}},a.resolve=function(i,e){return xt.buildAbsoluteURL(e,i,{alwaysNormalize:!0})},a.isMediaPlaylist=function(i){return On.test(i)},a.parseMasterPlaylist=function(i,e){var t=!1,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:t},s=[];br.lastIndex=0;for(var o;(o=br.exec(i))!=null;)if(o[1]){var l,u=new ne(o[1]),d=o[2],f={attrs:u,bitrate:u.decimalInteger("BANDWIDTH")||u.decimalInteger("AVERAGE-BANDWIDTH"),name:u.NAME,url:a.resolve(d,e)},h=u.decimalResolution("RESOLUTION");h&&(f.width=h.width,f.height=h.height),Nn(u.CODECS,f),(l=f.unknownCodecs)!=null&&l.length||s.push(f),r.levels.push(f)}else if(o[3]){var c=o[3],v=o[4];switch(c){case"SESSION-DATA":{var m=new ne(v),g=m["DATA-ID"];g&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[g]=m);break}case"SESSION-KEY":{var p=Dr(v,e);p.encrypted&&p.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(p)):A.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+v+'"');break}case"DEFINE":break;case"CONTENT-STEERING":{var y=new ne(v);r.contentSteering={uri:a.resolve(y["SERVER-URI"],e),pathwayId:y["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=Cr(v);break}}}var E=s.length>0&&s.length<r.levels.length;return r.levels=E?s:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},a.parseMasterPlaylistMedia=function(i,e,t){var r,s={},o=t.levels,l={AUDIO:o.map(function(L){return{id:L.attrs.AUDIO,audioCodec:L.audioCodec}}),SUBTITLES:o.map(function(L){return{id:L.attrs.SUBTITLES,textCodec:L.textCodec}}),"CLOSED-CAPTIONS":[]},u=0;for(Ir.lastIndex=0;(r=Ir.exec(i))!==null;){var d=new ne(r[1]),f=d.TYPE;if(f){var h=l[f],c=s[f]||[];s[f]=c;var v=d.LANGUAGE,m=d["ASSOC-LANGUAGE"],g=d.CHANNELS,p=d.CHARACTERISTICS,y=d["INSTREAM-ID"],E={attrs:d,bitrate:0,id:u++,groupId:d["GROUP-ID"]||"",name:d.NAME||v||"",type:f,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:v,url:d.URI?a.resolve(d.URI,e):""};if(m&&(E.assocLang=m),g&&(E.channels=g),p&&(E.characteristics=p),y&&(E.instreamId=y),h!=null&&h.length){var S=a.findGroup(h,E.groupId)||h[0];Pr(E,S,"audioCodec"),Pr(E,S,"textCodec")}c.push(E)}}return s},a.parseLevelPlaylist=function(i,e,t,r,s,o){var l=new rn(e),u=l.fragments,d=null,f=0,h=0,c=0,v=0,m=null,g=new St(r,e),p,y,E,S=-1,L=!1,D=null;for(_r.lastIndex=0,l.m3u8=i,l.hasVariableRefs=!1;(p=_r.exec(i))!==null;){L&&(L=!1,g=new St(r,e),g.start=c,g.sn=f,g.cc=v,g.level=t,d&&(g.initSegment=d,g.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null,D&&(g.setByteRange(D),D=null)));var R=p[1];if(R){g.duration=parseFloat(R);var T=(" "+p[2]).slice(1);g.title=T||null,g.tagList.push(T?["INF",R,T]:["INF",R])}else if(p[3]){if(O(g.duration)){g.start=c,E&&Fr(g,E,l),g.sn=f,g.level=t,g.cc=v,u.push(g);var b=(" "+p[3]).slice(1);g.relurl=b,wr(g,m),m=g,c+=g.duration,f++,h=0,L=!0}}else if(p[4]){var I=(" "+p[4]).slice(1);m?g.setByteRange(I,m):g.setByteRange(I)}else if(p[5])g.rawProgramDateTime=(" "+p[5]).slice(1),g.tagList.push(["PROGRAM-DATE-TIME",g.rawProgramDateTime]),S===-1&&(S=u.length);else{if(p=p[0].match(Mn),!p){A.warn("No matches on slow regex match for level playlist!");continue}for(y=1;y<p.length&&!(typeof p[y]<"u");y++);var P=(" "+p[y]).slice(1),C=(" "+p[y+1]).slice(1),w=p[y+2]?(" "+p[y+2]).slice(1):"";switch(P){case"PLAYLIST-TYPE":l.type=C.toUpperCase();break;case"MEDIA-SEQUENCE":f=l.startSN=parseInt(C);break;case"SKIP":{var M=new ne(C),F=M.decimalInteger("SKIPPED-SEGMENTS");if(O(F)){l.skippedSegments=F;for(var H=F;H--;)u.unshift(null);f+=F}var U=M.enumeratedString("RECENTLY-REMOVED-DATERANGES");U&&(l.recentlyRemovedDateranges=U.split(" "));break}case"TARGETDURATION":l.targetduration=Math.max(parseInt(C),1);break;case"VERSION":l.version=parseInt(C);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":l.live=!1;break;case"#":(C||w)&&g.tagList.push(w?[C,w]:[C]);break;case"DISCONTINUITY":v++,g.tagList.push(["DIS"]);break;case"GAP":g.gap=!0,g.tagList.push([P]);break;case"BITRATE":g.tagList.push([P,C]);break;case"DATERANGE":{var W=new ne(C),K=new lr(W,l.dateRanges[W.ID]);K.isValid||l.skippedSegments?l.dateRanges[K.id]=K:A.warn('Ignoring invalid DATERANGE tag: "'+C+'"'),g.tagList.push(["EXT-X-DATERANGE",C]);break}case"DEFINE":break;case"DISCONTINUITY-SEQUENCE":v=parseInt(C);break;case"KEY":{var B=Dr(C,e);if(B.isSupported()){if(B.method==="NONE"){E=void 0;break}E||(E={}),E[B.keyFormat]&&(E=ye({},E)),E[B.keyFormat]=B}else A.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+C+'"');break}case"START":l.startTimeOffset=Cr(C);break;case"MAP":{var Q=new ne(C);if(g.duration){var q=new St(r,e);kr(q,Q,t,E),d=q,g.initSegment=d,d.rawProgramDateTime&&!g.rawProgramDateTime&&(g.rawProgramDateTime=d.rawProgramDateTime)}else{var J=g.byteRangeEndOffset;if(J){var ee=g.byteRangeStartOffset;D=J-ee+"@"+ee}else D=null;kr(g,Q,t,E),d=g,L=!0}break}case"SERVER-CONTROL":{var re=new ne(C);l.canBlockReload=re.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=re.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&re.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=re.optionalFloat("PART-HOLD-BACK",0),l.holdBack=re.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Z=new ne(C);l.partTarget=Z.decimalFloatingPoint("PART-TARGET");break}case"PART":{var X=l.partList;X||(X=l.partList=[]);var Pe=h>0?X[X.length-1]:void 0,Ee=h++,te=new ne(C),ce=new en(te,g,e,Ee,Pe);X.push(ce),g.duration+=ce.duration;break}case"PRELOAD-HINT":{var ve=new ne(C);l.preloadHint=ve;break}case"RENDITION-REPORT":{var ie=new ne(C);l.renditionReports=l.renditionReports||[],l.renditionReports.push(ie);break}default:A.warn("line parsed but not handled: "+p);break}}}m&&!m.relurl?(u.pop(),c-=m.duration,l.partList&&(l.fragmentHint=m)):l.partList&&(wr(g,m),g.cc=v,l.fragmentHint=g,E&&Fr(g,E,l));var z=u.length,pe=u[0],de=u[z-1];if(c+=l.skippedSegments*l.targetduration,c>0&&z&&de){l.averagetargetduration=c/z;var le=de.sn;l.endSN=le!=="initSegment"?le:0,l.live||(de.endList=!0),pe&&(l.startCC=pe.cc)}else l.endSN=0,l.startCC=0;return l.fragmentHint&&(c+=l.fragmentHint.duration),l.totalduration=c,l.endCC=v,S>0&&Bn(u,S),l},a}();function Dr(a,n,i){var e,t,r=new ne(a),s=(e=r.METHOD)!=null?e:"",o=r.URI,l=r.hexadecimalInteger("IV"),u=r.KEYFORMATVERSIONS,d=(t=r.KEYFORMAT)!=null?t:"identity";o&&r.IV&&!l&&A.error("Invalid IV: "+r.IV);var f=o?qe.resolve(o,n):"",h=(u||"1").split("/").map(Number).filter(Number.isFinite);return new _n(s,f,d,h,l)}function Cr(a){var n=new ne(a),i=n.decimalFloatingPoint("TIME-OFFSET");return O(i)?i:null}function Nn(a,n){var i=(a||"").split(/[ ,]+/).filter(function(e){return e});["video","audio","text"].forEach(function(e){var t=i.filter(function(r){return Pn(r,e)});t.length&&(n[e+"Codec"]=t.join(","),i=i.filter(function(r){return t.indexOf(r)===-1}))}),n.unknownCodecs=i}function Pr(a,n,i){var e=n[i];e&&(a[i]=e)}function Bn(a,n){for(var i=a[n],e=n;e--;){var t=a[e];if(!t)return;t.programDateTime=i.programDateTime-t.duration*1e3,i=t}}function wr(a,n){a.rawProgramDateTime?a.programDateTime=Date.parse(a.rawProgramDateTime):n!=null&&n.programDateTime&&(a.programDateTime=n.endProgramDateTime),O(a.programDateTime)||(a.programDateTime=null,a.rawProgramDateTime=null)}function kr(a,n,i,e){a.relurl=n.URI,n.BYTERANGE&&a.setByteRange(n.BYTERANGE),a.level=i,a.sn="initSegment",e&&(a.levelkeys=e),a.initSegment=null}function Fr(a,n,i){a.levelkeys=n;var e=i.encryptedFragments;(!e.length||e[e.length-1].levelkeys!==n)&&Object.keys(n).some(function(t){return n[t].isCommonEncryption})&&e.push(a)}var Y={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},j={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Or(a){var n=a.type;switch(n){case Y.AUDIO_TRACK:return j.AUDIO;case Y.SUBTITLE_TRACK:return j.SUBTITLE;default:return j.MAIN}}function Ct(a,n){var i=a.url;return(i===void 0||i.indexOf("data:")===0)&&(i=n.url),i}var Un=function(){function a(i){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=i,this.registerListeners()}var n=a.prototype;return n.startLoad=function(e){},n.stopLoad=function(){this.destroyInternalLoaders()},n.registerListeners=function(){var e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.LEVEL_LOADING,this.onLevelLoading,this),e.on(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.unregisterListeners=function(){var e=this.hls;e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.LEVEL_LOADING,this.onLevelLoading,this),e.off(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,s=t.loader,o=r||s,l=new o(t);return this.loaders[e.type]=l,l},n.getInternalLoader=function(e){return this.loaders[e.type]},n.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},n.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},n.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},n.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Y.MANIFEST,url:r,deliveryDirectives:null})},n.onLevelLoading=function(e,t){var r=t.id,s=t.level,o=t.pathwayId,l=t.url,u=t.deliveryDirectives;this.load({id:r,level:s,pathwayId:o,responseType:"text",type:Y.LEVEL,url:l,deliveryDirectives:u})},n.onAudioTrackLoading=function(e,t){var r=t.id,s=t.groupId,o=t.url,l=t.deliveryDirectives;this.load({id:r,groupId:s,level:null,responseType:"text",type:Y.AUDIO_TRACK,url:o,deliveryDirectives:l})},n.onSubtitleTrackLoading=function(e,t){var r=t.id,s=t.groupId,o=t.url,l=t.deliveryDirectives;this.load({id:r,groupId:s,level:null,responseType:"text",type:Y.SUBTITLE_TRACK,url:o,deliveryDirectives:l})},n.load=function(e){var t,r=this,s=this.hls.config,o=this.getInternalLoader(e);if(o){var l=o.context;if(l&&l.url===e.url&&l.level===e.level){A.trace("[playlist-loader]: playlist request ongoing");return}A.log("[playlist-loader]: aborting previous loader for type: "+e.type),o.abort()}var u;if(e.type===Y.MANIFEST?u=s.manifestLoadPolicy.default:u=ye({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),o=this.createInternalLoader(e),O((t=e.deliveryDirectives)==null?void 0:t.part)){var d;if(e.type===Y.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Y.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Y.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){var f=d.partTarget,h=d.targetduration;if(f&&h){var c=Math.max(f*3,h*.8)*1e3;u=ye({},u,{maxTimeToFirstByteMs:Math.min(c,u.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(c,u.maxTimeToFirstByteMs)})}}}var v=u.errorRetry||u.timeoutRetry||{},m={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:v.maxNumRetry||0,retryDelay:v.retryDelayMs||0,maxRetryDelay:v.maxRetryDelayMs||0},g={onSuccess:function(y,E,S,L){var D=r.getInternalLoader(S);r.resetInternalLoader(S.type);var R=y.data;if(R.indexOf("#EXTM3U")!==0){r.handleManifestParsingError(y,S,new Error("no EXTM3U delimiter"),L||null,E);return}E.parsing.start=performance.now(),qe.isMediaPlaylist(R)?r.handleTrackOrLevelPlaylist(y,E,S,L||null,D):r.handleMasterPlaylist(y,E,S,L)},onError:function(y,E,S,L){r.handleNetworkError(E,S,!1,y,L)},onTimeout:function(y,E,S){r.handleNetworkError(E,S,!0,void 0,y)}};o.load(e,m,g)},n.handleMasterPlaylist=function(e,t,r,s){var o=this.hls,l=e.data,u=Ct(e,r),d=qe.parseMasterPlaylist(l,u);if(d.playlistParsingError){this.handleManifestParsingError(e,r,d.playlistParsingError,s,t);return}var f=d.contentSteering,h=d.levels,c=d.sessionData,v=d.sessionKeys,m=d.startTimeOffset,g=d.variableList;this.variableList=g;var p=qe.parseMasterPlaylistMedia(l,u,d),y=p.AUDIO,E=y===void 0?[]:y,S=p.SUBTITLES,L=p["CLOSED-CAPTIONS"];if(E.length){var D=E.some(function(R){return!R.url});!D&&h[0].audioCodec&&!h[0].attrs.AUDIO&&(A.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),E.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new ne({}),bitrate:0,url:""}))}o.trigger(x.MANIFEST_LOADED,{levels:h,audioTracks:E,subtitles:S,captions:L,contentSteering:f,url:u,stats:t,networkDetails:s,sessionData:c,sessionKeys:v,startTimeOffset:m,variableList:g})},n.handleTrackOrLevelPlaylist=function(e,t,r,s,o){var l=this.hls,u=r.id,d=r.level,f=r.type,h=Ct(e,r),c=0,v=O(d)?d:O(u)?u:0,m=Or(r),g=qe.parseLevelPlaylist(e.data,h,v,m,c,this.variableList);if(f===Y.MANIFEST){var p={attrs:new ne({}),bitrate:0,details:g,name:"",url:h};l.trigger(x.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:h,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=g,this.handlePlaylistLoaded(g,e,t,r,s,o)},n.handleManifestParsingError=function(e,t,r,s,o){this.hls.trigger(x.ERROR,{type:V.NETWORK_ERROR,details:_.MANIFEST_PARSING_ERROR,fatal:t.type===Y.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:o})},n.handleNetworkError=function(e,t,r,s,o){r===void 0&&(r=!1);var l="A network "+(r?"timeout":"error"+(s?" (status "+s.code+")":""))+" occurred while loading "+e.type;e.type===Y.LEVEL?l+=": "+e.level+" id: "+e.id:(e.type===Y.AUDIO_TRACK||e.type===Y.SUBTITLE_TRACK)&&(l+=" id: "+e.id+' group-id: "'+e.groupId+'"');var u=new Error(l);A.warn("[playlist-loader]: "+l);var d=_.UNKNOWN,f=!1,h=this.getInternalLoader(e);switch(e.type){case Y.MANIFEST:d=r?_.MANIFEST_LOAD_TIMEOUT:_.MANIFEST_LOAD_ERROR,f=!0;break;case Y.LEVEL:d=r?_.LEVEL_LOAD_TIMEOUT:_.LEVEL_LOAD_ERROR,f=!1;break;case Y.AUDIO_TRACK:d=r?_.AUDIO_TRACK_LOAD_TIMEOUT:_.AUDIO_TRACK_LOAD_ERROR,f=!1;break;case Y.SUBTITLE_TRACK:d=r?_.SUBTITLE_TRACK_LOAD_TIMEOUT:_.SUBTITLE_LOAD_ERROR,f=!1;break}h&&this.resetInternalLoader(e.type);var c={type:V.NETWORK_ERROR,details:d,fatal:f,url:e.url,loader:h,context:e,error:u,networkDetails:t,stats:o};if(s){var v=t?.url||e.url;c.response=ge({url:v,data:void 0},s)}this.hls.trigger(x.ERROR,c)},n.handlePlaylistLoaded=function(e,t,r,s,o,l){var u=this.hls,d=s.type,f=s.level,h=s.id,c=s.groupId,v=s.deliveryDirectives,m=Ct(t,s),g=Or(s),p=typeof s.level=="number"&&g===j.MAIN?f:void 0;if(!e.fragments.length){var y=new Error("No Segments found in Playlist");u.trigger(x.ERROR,{type:V.NETWORK_ERROR,details:_.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:y,reason:y.message,response:t,context:s,level:p,parent:g,networkDetails:o,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var E=e.playlistParsingError;if(E){u.trigger(x.ERROR,{type:V.NETWORK_ERROR,details:_.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:E,reason:E.message,response:t,context:s,level:p,parent:g,networkDetails:o,stats:r});return}switch(e.live&&l&&(l.getCacheAge&&(e.ageHeader=l.getCacheAge()||0),(!l.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),d){case Y.MANIFEST:case Y.LEVEL:u.trigger(x.LEVEL_LOADED,{details:e,level:p||0,id:h||0,stats:r,networkDetails:o,deliveryDirectives:v});break;case Y.AUDIO_TRACK:u.trigger(x.AUDIO_TRACK_LOADED,{details:e,id:h||0,groupId:c||"",stats:r,networkDetails:o,deliveryDirectives:v});break;case Y.SUBTITLE_TRACK:u.trigger(x.SUBTITLE_TRACK_LOADED,{details:e,id:h||0,groupId:c||"",stats:r,networkDetails:o,deliveryDirectives:v});break}},a}();function Gn(a,n){var i;try{i=new Event("addtrack")}catch{i=document.createEvent("Event"),i.initEvent("addtrack",!1,!1)}i.track=a,n.dispatchEvent(i)}function Hn(a){var n=a.mode;if(n==="disabled"&&(a.mode="hidden"),a.cues)for(var i=a.cues.length;i--;)a.removeCue(a.cues[i]);n==="disabled"&&(a.mode=n)}function Vn(a,n,i,e){var t=a.mode;if(t==="disabled"&&(a.mode="hidden"),a.cues&&a.cues.length>0)for(var r=Wn(a.cues,n,i),s=0;s<r.length;s++)(!e||e(r[s]))&&a.removeCue(r[s]);t==="disabled"&&(a.mode=t)}function Kn(a,n){if(n<a[0].startTime)return 0;var i=a.length-1;if(n>a[i].endTime)return-1;for(var e=0,t=i;e<=t;){var r=Math.floor((t+e)/2);if(n<a[r].startTime)t=r-1;else if(n>a[r].startTime&&e<i)e=r+1;else return r}return a[e].startTime-n<n-a[t].startTime?e:t}function Wn(a,n,i){var e=[],t=Kn(a,n);if(t>-1)for(var r=t,s=a.length;r<s;r++){var o=a[r];if(o.startTime>=n&&o.endTime<=i)e.push(o);else if(o.startTime>i)return e}return e}var Te={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},Yn=.25;function Pt(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Mr(a,n,i,e,t){var r=new a(n,i,"");try{r.value=e,t&&(r.type=t)}catch{r=new a(n,i,JSON.stringify(t?ge({type:t},e):e))}return r}var nt=function(){var a=Pt();try{a&&new a(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function wt(a,n){return a.getTime()/1e3-n}function qn(a){return Uint8Array.from(a.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var jn=function(){function a(i){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=i,this._registerListeners()}var n=a.prototype;return n.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},n._registerListeners=function(){var e=this.hls;e.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this)},n._unregisterListeners=function(){var e=this.hls;e.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this)},n.onMediaAttached=function(e,t){this.media=t.media},n.onMediaDetaching=function(){this.id3Track&&(Hn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},n.onManifestLoading=function(){this.dateRangeCuesAppended={}},n.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},n.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if(r.kind==="metadata"&&r.label==="id3")return Gn(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},n.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,s=r.enableEmsgMetadataCues,o=r.enableID3MetadataCues;if(!(!s&&!o)){var l=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var u=Pt();if(u)for(var d=0;d<l.length;d++){var f=l[d].type;if(!(f===Te.emsg&&!s||!o)){var h=cr(l[d].data);if(h){var c=l[d].pts,v=c+l[d].duration;v>nt&&(v=nt);var m=v-c;m<=0&&(v=c+Yn);for(var g=0;g<h.length;g++){var p=h[g];if(!hr(p)){this.updateId3CueEnds(c,f);var y=Mr(u,c,v,p,f);y&&this.id3Track.addCue(y)}}}}}}}},n.updateId3CueEnds=function(e,t){var r,s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(var o=s.length;o--;){var l=s[o];l.type===t&&l.startTime<e&&l.endTime===nt&&(l.endTime=e)}},n.onBufferFlushing=function(e,t){var r=t.startOffset,s=t.endOffset,o=t.type,l=this.id3Track,u=this.hls;if(u){var d=u.config,f=d.enableEmsgMetadataCues,h=d.enableID3MetadataCues;if(l&&(f||h)){var c;o==="audio"?c=function(m){return m.type===Te.audioId3&&h}:o==="video"?c=function(m){return m.type===Te.emsg&&f}:c=function(m){return m.type===Te.audioId3&&h||m.type===Te.emsg&&f},Vn(l,r,s,c)}}},n.onLevelUpdated=function(e,t){var r=this,s=t.details;if(!(!this.media||!s.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var o=this.dateRangeCuesAppended,l=this.id3Track,u=s.dateRanges,d=Object.keys(u);if(l)for(var f=Object.keys(o).filter(function(E){return!d.includes(E)}),h=function(){var S=f[c];Object.keys(o[S].cues).forEach(function(L){l.removeCue(o[S].cues[L])}),delete o[S]},c=f.length;c--;)h();var v=s.fragments[s.fragments.length-1];if(!(d.length===0||!O(v?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var m=v.programDateTime/1e3-v.start,g=Pt(),p=function(){var S=d[y],L=u[S],D=wt(L.startDate,m),R=o[S],T=R?.cues||{},b=R?.durationKnown||!1,I=nt,P=L.endDate;if(P)I=wt(P,m),b=!0;else if(L.endOnNext&&!b){var C=d.reduce(function(K,B){if(B!==L.id){var Q=u[B];if(Q.class===L.class&&Q.startDate>L.startDate&&(!K||L.startDate<K.startDate))return Q}return K},null);C&&(I=wt(C.startDate,m),b=!0)}for(var w=Object.keys(L.attr),M=0;M<w.length;M++){var F=w[M];if(Zi(F)){var H=T[F];if(H)b&&!R.durationKnown&&(H.endTime=I);else if(g){var U=L.attr[F];Ji(F)&&(U=qn(U));var W=Mr(g,D,I,{key:F,data:U},Te.dateRange);W&&(W.id=S,r.id3Track.addCue(W),T[F]=W)}}}o[S]={cues:T,dateRange:L,durationKnown:b}},y=0;y<d.length;y++)p()}}},a}(),Xn=function(){function a(i){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=i,this.config=i.config,this.registerListeners()}var n=a.prototype;return n.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},n.registerListeners=function(){this.hls.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(x.ERROR,this.onError,this)},n.unregisterListeners=function(){this.hls.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(x.ERROR,this.onError,this)},n.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},n.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},n.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},n.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},n.onError=function(e,t){var r;t.details===_.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&A.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},n.timeupdate=function(){var e=this.media,t=this.levelDetails;if(!(!e||!t)){this.currentTime=e.currentTime;var r=this.computeLatency();if(r!==null){this._latency=r;var s=this.config,o=s.lowLatencyMode,l=s.maxLiveSyncPlaybackRate;if(!(!o||l===1||!t.live)){var u=this.targetLatency;if(u!==null){var d=r-u,f=Math.min(this.maxLatency,u+t.targetduration),h=d<f;if(h&&d>.05&&this.forwardBufferLength>1){var c=Math.min(2,Math.max(1,l)),v=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;e.playbackRate=Math.min(c,Math.max(1,v))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}}}}},n.estimateLiveEdge=function(){var e=this.levelDetails;return e===null?null:e.edge+e.age},n.computeLatency=function(){var e=this.estimateLiveEdge();return e===null?null:e-this.currentTime},he(a,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(e===null)return null;var t=e.holdBack,r=e.partHoldBack,s=e.targetduration,o=this.config,l=o.liveSyncDuration,u=o.liveSyncDurationCount,d=o.lowLatencyMode,f=this.hls.userConfig,h=d&&r||t;(f.liveSyncDuration||f.liveSyncDurationCount||h===0)&&(h=l!==void 0?l:u*s);var c=s,v=1;return h+Math.min(this.stallCount*v,c)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;var s=r.edge,o=e-t-this.edgeStalled,l=s-r.totalduration,u=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(l,o),u)}},{key:"drift",get:function(){var e=this.levelDetails;return e===null?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(e===null)return 0;var t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;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}}]),a}(),kt=["NONE","TYPE-0","TYPE-1",null];function zn(a){return kt.indexOf(a)>-1}var at=["SDR","PQ","HLG"];function $n(a){return!!a&&at.indexOf(a)>-1}var st={No:"",Yes:"YES",v2:"v2"};function Nr(a){var n=a.canSkipUntil,i=a.canSkipDateRanges,e=a.age,t=e<n/2;return n&&t?i?st.v2:st.Yes:st.No}var Br=function(){function a(i,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=i,this.part=e,this.skip=t}var n=a.prototype;return n.addDirectives=function(e){var t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},a}(),Ft=function(){function a(i){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[i.url],this._attrs=[i.attrs],this.bitrate=i.bitrate,i.details&&(this.details=i.details),this.id=i.id||0,this.name=i.name,this.width=i.width||0,this.height=i.height||0,this.frameRate=i.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=i.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=i.audioCodec,this.videoCodec=i.videoCodec,this.codecSet=[i.videoCodec,i.audioCodec].filter(function(e){return!!e}).map(function(e){return e.substring(0,4)}).join(","),this.addGroupId("audio",i.attrs.AUDIO),this.addGroupId("text",i.attrs.SUBTITLES)}var n=a.prototype;return n.hasAudioGroup=function(e){return Ur(this._audioGroups,e)},n.hasSubtitleGroup=function(e){return Ur(this._subtitleGroups,e)},n.addGroupId=function(e,t){if(t){if(e==="audio"){var r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){var s=this._subtitleGroups;s||(s=this._subtitleGroups=[]),s.indexOf(t)===-1&&s.push(t)}}},n.addFallback=function(){},he(a,[{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(e=this.audioGroups)==null?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}}]),a}();function Ur(a,n){return!n||!a?!1:a.indexOf(n)!==-1}function Ot(a,n){var i=n.startPTS;if(O(i)){var e=0,t;n.sn>a.sn?(e=i-a.start,t=a):(e=a.start-i,t=n),t.duration!==e&&(t.duration=e)}else if(n.sn>a.sn){var r=a.cc===n.cc;r&&a.minEndPTS?n.start=a.start+(a.minEndPTS-a.start):n.start=a.start+a.duration}else n.start=Math.max(a.start-n.duration,0)}function Gr(a,n,i,e,t,r){var s=e-i;s<=0&&(A.warn("Fragment should have a positive duration",n),e=i+n.duration,r=t+n.duration);var o=i,l=e,u=n.startPTS,d=n.endPTS;if(O(u)){var f=Math.abs(u-i);O(n.deltaPTS)?n.deltaPTS=Math.max(f,n.deltaPTS):n.deltaPTS=f,o=Math.max(i,u),i=Math.min(i,u),t=Math.min(t,n.startDTS),l=Math.min(e,d),e=Math.max(e,d),r=Math.max(r,n.endDTS)}var h=i-n.start;n.start!==0&&(n.start=i),n.duration=e-n.start,n.startPTS=i,n.maxStartPTS=o,n.startDTS=t,n.endPTS=e,n.minEndPTS=l,n.endDTS=r;var c=n.sn;if(!a||c<a.startSN||c>a.endSN)return 0;var v,m=c-a.startSN,g=a.fragments;for(g[m]=n,v=m;v>0;v--)Ot(g[v],g[v-1]);for(v=m;v<g.length-1;v++)Ot(g[v],g[v+1]);return a.fragmentHint&&Ot(g[g.length-1],a.fragmentHint),a.PTSKnown=a.alignedSliding=!0,h}function Qn(a,n){for(var i=null,e=a.fragments,t=e.length-1;t>=0;t--){var r=e[t].initSegment;if(r){i=r;break}}a.fragmentHint&&delete a.fragmentHint.endPTS;var s=0,o;if(ea(a,n,function(v,m){v.relurl&&(s=v.cc-m.cc),O(v.startPTS)&&O(v.endPTS)&&(m.start=m.startPTS=v.startPTS,m.startDTS=v.startDTS,m.maxStartPTS=v.maxStartPTS,m.endPTS=v.endPTS,m.endDTS=v.endDTS,m.minEndPTS=v.minEndPTS,m.duration=v.endPTS-v.startPTS,m.duration&&(o=m),n.PTSKnown=n.alignedSliding=!0),m.elementaryStreams=v.elementaryStreams,m.loader=v.loader,m.stats=v.stats,v.initSegment&&(m.initSegment=v.initSegment,i=v.initSegment)}),i){var l=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments;l.forEach(function(v){var m;v&&(!v.initSegment||v.initSegment.relurl===((m=i)==null?void 0:m.relurl))&&(v.initSegment=i)})}if(n.skippedSegments)if(n.deltaUpdateFailed=n.fragments.some(function(v){return!v}),n.deltaUpdateFailed){A.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var u=n.skippedSegments;u--;)n.fragments.shift();n.startSN=n.fragments[0].sn,n.startCC=n.fragments[0].cc}else n.canSkipDateRanges&&(n.dateRanges=Zn(a.dateRanges,n.dateRanges,n.recentlyRemovedDateranges));var d=n.fragments;if(s){A.warn("discontinuity sliding from playlist, take drift into account");for(var f=0;f<d.length;f++)d[f].cc+=s}n.skippedSegments&&(n.startCC=n.fragments[0].cc),Jn(a.partList,n.partList,function(v,m){m.elementaryStreams=v.elementaryStreams,m.stats=v.stats}),o?Gr(n,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):Hr(a,n),d.length&&(n.totalduration=n.edge-d[0].start),n.driftStartTime=a.driftStartTime,n.driftStart=a.driftStart;var h=n.advancedDateTime;if(n.advanced&&h){var c=n.edge;n.driftStart||(n.driftStartTime=h,n.driftStart=c),n.driftEndTime=h,n.driftEnd=c}else n.driftEndTime=a.driftEndTime,n.driftEnd=a.driftEnd,n.advancedDateTime=a.advancedDateTime}function Zn(a,n,i){var e=ye({},a);return i&&i.forEach(function(t){delete e[t]}),Object.keys(n).forEach(function(t){var r=new lr(n[t].attr,e[t]);r.isValid?e[t]=r:A.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(n[t].attr)+'"')}),e}function Jn(a,n,i){if(a&&n)for(var e=0,t=0,r=a.length;t<=r;t++){var s=a[t],o=n[t+e];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?i(s,o):e--}}function ea(a,n,i){for(var e=n.skippedSegments,t=Math.max(a.startSN,n.startSN)-n.startSN,r=(a.fragmentHint?1:0)+(e?n.endSN:Math.min(a.endSN,n.endSN))-n.startSN,s=n.startSN-a.startSN,o=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments,l=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments,u=t;u<=r;u++){var d=l[s+u],f=o[u];e&&!f&&u<e&&(f=n.fragments[u]=d),d&&f&&i(d,f)}}function Hr(a,n){var i=n.startSN+n.skippedSegments-a.startSN,e=a.fragments;i<0||i>=e.length||ta(n,e[i].start)}function ta(a,n){if(n){for(var i=a.fragments,e=a.skippedSegments;e<i.length;e++)i[e].start+=n;a.fragmentHint&&(a.fragmentHint.start+=n)}}function ra(a,n){n===void 0&&(n=1/0);var i=1e3*a.targetduration;if(a.updated){var e=a.fragments,t=4;if(e.length&&i*t>n){var r=e[e.length-1].duration*1e3;r<i&&(i=r)}}else i/=2;return Math.round(i)}function ia(a,n,i){if(!(a!=null&&a.details))return null;var e=a.details,t=e.fragments[n-e.startSN];return t||(t=e.fragmentHint,t&&t.sn===n)?t:n<e.startSN&&i&&i.sn===n?i:null}function Vr(a,n,i){var e;return a!=null&&a.details?Kr((e=a.details)==null?void 0:e.partList,n,i):null}function Kr(a,n,i){if(a)for(var e=a.length;e--;){var t=a[e];if(t.index===i&&t.fragment.sn===n)return t}return null}function Wr(a){a.forEach(function(n,i){var e=n.details;e!=null&&e.fragments&&e.fragments.forEach(function(t){t.level=i})})}function ot(a){switch(a.details){case _.FRAG_LOAD_TIMEOUT:case _.KEY_LOAD_TIMEOUT:case _.LEVEL_LOAD_TIMEOUT:case _.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Yr(a,n){var i=ot(n);return a.default[(i?"timeout":"error")+"Retry"]}function Mt(a,n){var i=a.backoff==="linear"?1:Math.pow(2,n);return Math.min(i*a.retryDelayMs,a.maxRetryDelayMs)}function qr(a){return ge(ge({},a),{errorRetry:null,timeoutRetry:null})}function lt(a,n,i,e){if(!a)return!1;var t=e?.code,r=n<a.maxNumRetry&&(na(t)||!!i);return a.shouldRetry?a.shouldRetry(a,n,i,e,r):r}function na(a){return a===0&&navigator.onLine===!1||!!a&&(a<400||a>499)}var jr={search:function(n,i){for(var e=0,t=n.length-1,r=null,s=null;e<=t;){r=(e+t)/2|0,s=n[r];var o=i(s);if(o>0)e=r+1;else if(o<0)t=r-1;else return s}return null}};function aa(a,n,i){if(n===null||!Array.isArray(a)||!a.length||!O(n))return null;var e=a[0].programDateTime;if(n<(e||0))return null;var t=a[a.length-1].endProgramDateTime;if(n>=(t||0))return null;i=i||0;for(var r=0;r<a.length;++r){var s=a[r];if(sa(n,i,s))return s}return null}function Xr(a,n,i,e){i===void 0&&(i=0),e===void 0&&(e=0);var t=null;if(a){t=n[a.sn-n[0].sn+1]||null;var r=a.endDTS-i;r>0&&r<15e-7&&(i+=15e-7)}else i===0&&n[0].start===0&&(t=n[0]);if(t&&(!a||a.level===t.level)&&zr(i,e,t)===0)return t;var s=jr.search(n,zr.bind(null,i,e));return s&&(s!==a||!t)?s:t}function zr(a,n,i){if(a===void 0&&(a=0),n===void 0&&(n=0),i.start<=a&&i.start+i.duration>a)return 0;var e=Math.min(n,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-e<=a?1:i.start-e>a&&i.start?-1:0}function sa(a,n,i){var e=Math.min(n,i.duration+(i.deltaPTS?i.deltaPTS:0))*1e3,t=i.endProgramDateTime||0;return t-e>a}function oa(a,n){return jr.search(a,function(i){return i.cc<n?1:i.cc>n?-1:0})}var ue={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Se={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},la=function(){function a(i){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=i,this.log=A.log.bind(A,"[info]:"),this.warn=A.warn.bind(A,"[warning]:"),this.error=A.error.bind(A,"[error]:"),this.registerListeners()}var n=a.prototype;return n.registerListeners=function(){var e=this.hls;e.on(x.ERROR,this.onError,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.ERROR,this.onError,this),e.off(x.ERROR,this.onErrorOut,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this))},n.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},n.startLoad=function(e){},n.stopLoad=function(){this.playlistError=0},n.getVariantLevelIndex=function(e){return e?.type===j.MAIN?e.level:this.hls.loadLevel},n.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},n.onLevelUpdated=function(){this.playlistError=0},n.onError=function(e,t){var r,s;if(!t.fatal){var o=this.hls,l=t.context;switch(t.details){case _.FRAG_LOAD_ERROR:case _.FRAG_LOAD_TIMEOUT:case _.KEY_LOAD_ERROR:case _.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case _.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:ue.DoNothing,flags:Se.None};return}case _.FRAG_GAP:case _.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=ue.SendAlternateToPenaltyBox;return}case _.LEVEL_EMPTY_ERROR:case _.LEVEL_PARSING_ERROR:{var u,d,f=t.parent===j.MAIN?t.level:o.loadLevel;t.details===_.LEVEL_EMPTY_ERROR&&((u=t.context)!=null&&(d=u.levelDetails)!=null&&d.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,f):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,f))}return;case _.LEVEL_LOAD_ERROR:case _.LEVEL_LOAD_TIMEOUT:typeof l?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,l.level));return;case _.AUDIO_TRACK_LOAD_ERROR:case _.AUDIO_TRACK_LOAD_TIMEOUT:case _.SUBTITLE_LOAD_ERROR:case _.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){var h=o.levels[o.loadLevel];if(h&&(l.type===Y.AUDIO_TRACK&&h.hasAudioGroup(l.groupId)||l.type===Y.SUBTITLE_TRACK&&h.hasSubtitleGroup(l.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o.loadLevel),t.errorAction.action=ue.SendAlternateToPenaltyBox,t.errorAction.flags=Se.MoveAllAlternatesMatchingHost;return}}return;case _.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var c=o.levels[o.loadLevel],v=c?.attrs["HDCP-LEVEL"];v?t.errorAction={action:ue.SendAlternateToPenaltyBox,flags:Se.MoveAllAlternatesMatchingHDCP,hdcpLevel:v}:this.keySystemError(t)}return;case _.BUFFER_ADD_CODEC_ERROR:case _.REMUX_ALLOC_ERROR:case _.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:o.loadLevel);return;case _.INTERNAL_EXCEPTION:case _.BUFFER_APPENDING_ERROR:case _.BUFFER_FULL_ERROR:case _.LEVEL_SWITCH_ERROR:case _.BUFFER_STALLED_ERROR:case _.BUFFER_SEEK_OVER_HOLE:case _.BUFFER_NUDGE_ON_STALL:t.errorAction={action:ue.DoNothing,flags:Se.None};return}t.type===V.KEY_SYSTEM_ERROR&&this.keySystemError(t)}},n.keySystemError=function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)},n.getPlaylistRetryOrSwitchAction=function(e,t){var r=this.hls,s=Yr(r.config.playlistLoadPolicy,e),o=this.playlistError++,l=lt(s,o,ot(e),e.response);if(l)return{action:ue.RetryRequest,flags:Se.None,retryConfig:s,retryCount:o};var u=this.getLevelSwitchAction(e,t);return s&&(u.retryConfig=s,u.retryCount=o),u},n.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],o=t.config,l=o.fragLoadPolicy,u=o.keyLoadPolicy,d=Yr(e.details.startsWith("key")?u:l,e),f=t.levels.reduce(function(v,m){return v+m.fragmentError},0);if(s){e.details!==_.FRAG_GAP&&s.fragmentError++;var h=lt(d,f,ot(e),e.response);if(h)return{action:ue.RetryRequest,flags:Se.None,retryConfig:d,retryCount:f}}var c=this.getLevelSwitchAction(e,r);return d&&(c.retryConfig=d,c.retryCount=f),c},n.getLevelSwitchAction=function(e,t){var r=this.hls;t==null&&(t=r.loadLevel);var s=this.hls.levels[t];if(s){var o,l,u=e.details;s.loadError++,u===_.BUFFER_APPEND_ERROR&&s.fragmentError++;var d=-1,f=r.levels,h=r.loadLevel,c=r.minAutoLevel,v=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var m=(o=e.frag)==null?void 0:o.type,g=m===j.AUDIO&&u===_.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(u===_.BUFFER_ADD_CODEC_ERROR||u===_.BUFFER_APPEND_ERROR),p=g&&f.some(function(I){var P=I.audioCodec;return s.audioCodec!==P}),y=e.sourceBufferName==="video"&&(u===_.BUFFER_ADD_CODEC_ERROR||u===_.BUFFER_APPEND_ERROR),E=y&&f.some(function(I){var P=I.codecSet,C=I.audioCodec;return s.codecSet!==P&&s.audioCodec===C}),S=(l=e.context)!=null?l:{},L=S.type,D=S.groupId,R=function(){var P=(b+h)%f.length;if(P!==h&&P>=c&&P<=v&&f[P].loadError===0){var C,w,M=f[P];if(u===_.FRAG_GAP&&e.frag){var F=f[P].details;if(F){var H=Xr(e.frag,F.fragments,e.frag.start);if(H!=null&&H.gap)return 0}}else{if(L===Y.AUDIO_TRACK&&M.hasAudioGroup(D)||L===Y.SUBTITLE_TRACK&&M.hasSubtitleGroup(D))return 0;if(m===j.AUDIO&&(C=s.audioGroups)!=null&&C.some(function(U){return M.hasAudioGroup(U)})||m===j.SUBTITLE&&(w=s.subtitleGroups)!=null&&w.some(function(U){return M.hasSubtitleGroup(U)})||p&&s.audioCodec===M.audioCodec||!p&&s.audioCodec!==M.audioCodec||E&&s.codecSet===M.codecSet)return 0}return d=P,1}},T,b=f.length;b--&&(T=R(),!(T!==0&&T===1)););if(d>-1&&r.loadLevel!==d)return e.levelRetry=!0,this.playlistError=0,{action:ue.SendAlternateToPenaltyBox,flags:Se.None,nextAutoLevel:d}}return{action:ue.SendAlternateToPenaltyBox,flags:Se.MoveAllAlternatesMatchingHost}},n.onErrorOut=function(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case ue.DoNothing:break;case ue.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==_.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn('MediaSource ended after "'+t.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError());break}if(t.fatal){this.hls.stopLoad();return}},n.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var s=r.flags,o=r.hdcpLevel,l=r.nextAutoLevel;switch(s){case Se.None:this.switchLevel(e,l);break;case Se.MoveAllAlternatesMatchingHDCP:o&&(t.maxHdcpLevel=kt[kt.indexOf(o)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower');break}r.resolved||this.switchLevel(e,l)}},n.switchLevel=function(e,t){t!==void 0&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},a}(),ua=function(){function a(i,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=A.log.bind(A,e+":"),this.warn=A.warn.bind(A,e+":"),this.hls=i}var n=a.prototype;return n.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},n.clearTimer=function(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)},n.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},n.stopLoad=function(){this.canLoad=!1,this.clearTimer()},n.switchParams=function(e,t,r){var s=t?.renditionReports;if(s){for(var o=-1,l=0;l<s.length;l++){var u=s[l],d=void 0;try{d=new self.URL(u.URI,t.url).href}catch(g){A.warn("Could not construct new URL for Rendition Report: "+g),d=u.URI||""}if(d===e){o=l;break}else d===e.substring(0,d.length)&&(o=l)}if(o!==-1){var f=s[o],h=parseInt(f["LAST-MSN"])||t?.lastPartSn,c=parseInt(f["LAST-PART"])||t?.lastPartIndex;if(this.hls.config.lowLatencyMode){var v=Math.min(t.age-t.partTarget,t.targetduration);c>=0&&v>t.partTarget&&(c+=1)}var m=r&&Nr(r);return new Br(h,c>=0?c:void 0,m)}}},n.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},n.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},n.shouldReloadPlaylist=function(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)},n.playlistLoaded=function(e,t,r){var s=this,o=t.details,l=t.stats,u=self.performance.now(),d=l.loading.first?Math.max(0,u-l.loading.first):0;if(o.advancedDateTime=Date.now()-d,o.live||r!=null&&r.live){if(o.reloaded(r),r&&this.log("live playlist "+e+" "+(o.advanced?"REFRESHED "+o.lastPartSn+"-"+o.lastPartIndex:o.updated?"UPDATED":"MISSED")),r&&o.fragments.length>0&&Qn(r,o),!this.canLoad||!o.live)return;var f,h=void 0,c=void 0;if(o.canBlockReload&&o.endSN&&o.advanced){var v=this.hls.config.lowLatencyMode,m=o.lastPartSn,g=o.endSN,p=o.lastPartIndex,y=p!==-1,E=m===g,S=v?0:p;y?(h=E?g+1:m,c=E?S:p+1):h=g+1;var L=o.age,D=L+o.ageHeader,R=Math.min(D-o.partTarget,o.targetduration*1.5);if(R>0){if(r&&R>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+R+" with playlist age: "+o.age),R=0;else{var T=Math.floor(R/o.targetduration);if(h+=T,c!==void 0){var b=Math.round(R%o.targetduration/o.partTarget);c+=b}this.log("CDN Tune-in age: "+o.ageHeader+"s last advanced "+L.toFixed(2)+"s goal: "+R+" skip sn "+T+" to part "+c)}o.tuneInGoal=R}if(f=this.getDeliveryDirectives(o,t.deliveryDirectives,h,c),v||!E){this.loadPlaylist(f);return}}else(o.canBlockReload||o.canSkipUntil)&&(f=this.getDeliveryDirectives(o,t.deliveryDirectives,h,c));var I=this.hls.mainForwardBufferInfo,P=I?I.end-I.len:0,C=(o.edge-P)*1e3,w=ra(o,C);o.updated&&u>this.requestScheduled+w&&(this.requestScheduled=l.loading.start),h!==void 0&&o.canBlockReload?this.requestScheduled=l.loading.first+w-(o.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+w<u?this.requestScheduled=u:this.requestScheduled-u<=0&&(this.requestScheduled+=w);var M=this.requestScheduled-u;M=Math.max(0,M),this.log("reload live playlist "+e+" in "+Math.round(M)+" ms"),this.timer=self.setTimeout(function(){return s.loadPlaylist(f)},M)}else this.clearTimer()},n.getDeliveryDirectives=function(e,t,r,s){var o=Nr(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,o=st.No),new Br(r,s,o)},n.checkRetry=function(e){var t=this,r=e.details,s=ot(e),o=e.errorAction,l=o||{},u=l.action,d=l.retryCount,f=d===void 0?0:d,h=l.retryConfig,c=!!o&&!!h&&(u===ue.RetryRequest||!o.resolved&&u===ue.SendAlternateToPenaltyBox);if(c){var v;if(this.requestScheduled=-1,f>=h.maxNumRetry)return!1;if(s&&(v=e.context)!=null&&v.deliveryDirectives)this.warn("Retrying playlist loading "+(f+1)+"/"+h.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var m=Mt(h,f);this.timer=self.setTimeout(function(){return t.loadPlaylist()},m),this.warn("Retrying playlist loading "+(f+1)+"/"+h.maxNumRetry+' after "'+r+'" in '+m+"ms")}e.levelRetry=!0,o.resolved=!0}return c},a}(),Ge=function(){function a(i,e,t){e===void 0&&(e=0),t===void 0&&(t=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=i,this.alpha_=i?Math.exp(Math.log(.5)/i):0,this.estimate_=e,this.totalWeight_=t}var n=a.prototype;return n.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},n.getTotalWeight=function(){return this.totalWeight_},n.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},a}(),fa=function(){function a(i,e,t,r){r===void 0&&(r=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_=t,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Ge(i),this.fast_=new Ge(e),this.defaultTTFB_=r,this.ttfb_=new Ge(i)}var n=a.prototype;return n.update=function(e,t){var r=this.slow_,s=this.fast_,o=this.ttfb_;r.halfLife!==e&&(this.slow_=new Ge(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new Ge(t,s.getEstimate(),s.getTotalWeight())),o.halfLife!==e&&(this.ttfb_=new Ge(e,o.getEstimate(),o.getTotalWeight()))},n.sample=function(e,t){e=Math.max(e,this.minDelayMs_);var r=8*t,s=e/1e3,o=r/s;this.fast_.sample(s,o),this.slow_.sample(s,o)},n.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))},n.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},n.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},n.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},n.destroy=function(){},a}();function da(){if(typeof matchMedia=="function"){var a=matchMedia("(dynamic-range: high)"),n=matchMedia("bad query");if(a.media!==n.media)return a.matches===!0}return!1}function ha(a,n){var i=!1,e=[];return a&&(i=a!=="SDR",e=[a]),n&&(e=n.allowedVideoRanges||at.slice(0),i=n.preferHDR!==void 0?n.preferHDR:da(),i?e=e.filter(function(t){return t!=="SDR"}):e=["SDR"]),{preferHDR:i,allowedVideoRanges:e}}function ca(a,n,i,e,t){for(var r=Object.keys(a),s=e?.channels,o=e?.audioCodec,l=s&&parseInt(s)===2,u=!0,d=!1,f=1/0,h=1/0,c=1/0,v=0,m=[],g=ha(n,t),p=g.preferHDR,y=g.allowedVideoRanges,E=function(){var b=a[r[S]];u=b.channels[2]>0,f=Math.min(f,b.minHeight),h=Math.min(h,b.minFramerate),c=Math.min(c,b.minBitrate);var I=y.filter(function(P){return b.videoRanges[P]>0});I.length>0&&(d=!0,m=I)},S=r.length;S--;)E();f=O(f)?f:0,h=O(h)?h:0;var L=Math.max(1080,f),D=Math.max(30,h);c=O(c)?c:i,i=Math.max(c,i),d||(n=void 0,m=[]);var R=r.reduce(function(T,b){var I=a[b];if(b===T)return T;if(I.minBitrate>i)return _e(b,"min bitrate of "+I.minBitrate+" > current estimate of "+i),T;if(!I.hasDefaultAudio)return _e(b,"no renditions with default or auto-select sound found"),T;if(o&&b.indexOf(o.substring(0,4))%5!==0)return _e(b,'audio codec preference "'+o+'" not found'),T;if(s&&!l){if(!I.channels[s])return _e(b,"no renditions with "+s+" channel sound found (channels options: "+Object.keys(I.channels)+")"),T}else if((!o||l)&&u&&I.channels[2]===0)return _e(b,"no renditions with stereo sound found"),T;return I.minHeight>L?(_e(b,"min resolution of "+I.minHeight+" > maximum of "+L),T):I.minFramerate>D?(_e(b,"min framerate of "+I.minFramerate+" > maximum of "+D),T):m.some(function(P){return I.videoRanges[P]>0})?I.maxScore<v?(_e(b,"max score of "+I.maxScore+" < selected max of "+v),T):T&&(rt(b)>=rt(T)||I.fragmentError>a[T].fragmentError)?T:(v=I.maxScore,b):(_e(b,"no variants with VIDEO-RANGE of "+JSON.stringify(m)+" found"),T)},void 0);return{codecSet:R,videoRanges:m,preferHDR:p,minFramerate:h,minBitrate:c}}function _e(a,n){A.log('[abr] start candidates with "'+a+'" ignored because '+n)}function va(a){return a.reduce(function(n,i){var e=n.groups[i.groupId];e||(e=n.groups[i.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),e.tracks.push(i);var t=i.channels||"2";return e.channels[t]=(e.channels[t]||0)+1,e.hasDefault=e.hasDefault||i.default,e.hasAutoSelect=e.hasAutoSelect||i.autoselect,e.hasDefault&&(n.hasDefaultAudio=!0),e.hasAutoSelect&&(n.hasAutoSelectAudio=!0),n},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function ga(a,n,i,e){return a.slice(i,e+1).reduce(function(t,r){if(!r.codecSet)return t;var s=r.audioGroups,o=t[r.codecSet];o||(t[r.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!s,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,r.bitrate);var l=Math.min(r.height,r.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,r.frameRate),o.maxScore=Math.max(o.maxScore,r.score),o.fragmentError+=r.fragmentError,o.videoRanges[r.videoRange]=(o.videoRanges[r.videoRange]||0)+1,t},{})}var ma=function(){function a(i){var e=this;this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=function(){var t=e.fragCurrent,r=e.partCurrent,s=e.hls,o=s.autoLevelEnabled,l=s.media;if(!(!t||!l)){var u=performance.now(),d=r?r.stats:t.stats,f=r?r.duration:t.duration,h=u-d.loading.start,c=s.minAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||t.level<=c){e.clearTimer(),e._nextAutoLevel=-1;return}if(!(!o||l.paused||!l.playbackRate||!l.readyState)){var v=s.mainForwardBufferInfo;if(v!==null){var m=e.bwEstimator.getEstimateTTFB(),g=Math.abs(l.playbackRate);if(!(h<=Math.max(m,1e3*(f/(g*2))))){var p=v.len/g,y=d.loading.first?d.loading.first-d.loading.start:-1,E=d.loaded&&y>-1,S=e.getBwEstimate(),L=s.levels,D=L[t.level],R=d.total||Math.max(d.loaded,Math.round(f*D.averageBitrate/8)),T=E?h-y:h;T<1&&E&&(T=Math.min(h,d.loaded*8/S));var b=E?d.loaded*1e3/T:0,I=b?(R-d.loaded)/b:R*8/S+m/1e3;if(!(I<=p)){var P=b?b*8:S,C=Number.POSITIVE_INFINITY,w;for(w=t.level-1;w>c;w--){var M=L[w].maxBitrate;if(C=e.getTimeToLoadFrag(m/1e3,P,f*M,!L[w].details),C<p)break}if(!(C>=I)&&!(C>f*10)){s.nextLoadLevel=s.nextAutoLevel=w,E?e.bwEstimator.sample(h-Math.min(m,y),d.loaded):e.bwEstimator.sampleTTFB(h);var F=L[w].maxBitrate;e.getBwEstimate()*e.hls.config.abrBandWidthUpFactor>F&&e.resetEstimator(F),e.clearTimer(),A.warn("[abr] Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+` is loading too slowly;
|
2
|
-
Time to underbuffer: `+p.toFixed(3)+` s
|
3
|
-
Estimated load time for current fragment: `+I.toFixed(3)+` s
|
4
|
-
Estimated load time for down switch fragment: `+C.toFixed(3)+` s
|
5
|
-
TTFB estimate: `+(y|0)+` ms
|
6
|
-
Current BW estimate: `+(O(S)?S|0:"Unknown")+` bps
|
7
|
-
New BW estimate: `+(e.getBwEstimate()|0)+` bps
|
8
|
-
Switching to level `+w+" @ "+(F|0)+" bps"),s.trigger(x.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:d})}}}}}}},this.hls=i,this.bwEstimator=this.initEstimator(),this.registerListeners()}var n=a.prototype;return n.resetEstimator=function(e){e&&(A.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},n.initEstimator=function(){var e=this.hls.config;return new fa(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},n.registerListeners=function(){var e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.FRAG_LOADING,this.onFragLoading,this),e.on(x.FRAG_LOADED,this.onFragLoaded,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this),e.on(x.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(x.LEVEL_LOADED,this.onLevelLoaded,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(x.ERROR,this.onError,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.FRAG_LOADING,this.onFragLoading,this),e.off(x.FRAG_LOADED,this.onFragLoaded,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this),e.off(x.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(x.LEVEL_LOADED,this.onLevelLoaded,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(x.ERROR,this.onError,this))},n.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},n.onManifestLoading=function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},n.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},n.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},n.onFragLoading=function(e,t){var r=t.frag;if(!this.ignoreFragment(r)){if(!r.bitrateTest){var s;this.fragCurrent=r,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}},n.onLevelSwitching=function(e,t){this.clearTimer()},n.onError=function(e,t){if(!t.fatal)switch(t.details){case _.BUFFER_ADD_CODEC_ERROR:case _.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case _.FRAG_LOAD_TIMEOUT:{var r=t.frag,s=this.fragCurrent,o=this.partCurrent;if(r&&s&&r.sn===s.sn&&r.level===s.level){var l=performance.now(),u=o?o.stats:r.stats,d=l-u.loading.start,f=u.loading.first?u.loading.first-u.loading.start:-1,h=u.loaded&&f>-1;if(h){var c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(d-Math.min(c,f),u.loaded)}else this.bwEstimator.sampleTTFB(d)}break}}},n.getTimeToLoadFrag=function(e,t,r,s){var o=e+r/t,l=s?this.lastLevelLoadSec:0;return o+l},n.onLevelLoaded=function(e,t){var r=this.hls.config,s=t.stats.loading,o=s.end-s.start;O(o)&&(this.lastLevelLoadSec=o/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},n.onFragLoaded=function(e,t){var r=t.frag,s=t.part,o=s?s.stats:r.stats;if(r.type===j.MAIN&&this.bwEstimator.sampleTTFB(o.loading.first-o.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var l=s?s.duration:r.duration,u=this.hls.levels[r.level],d=(u.loaded?u.loaded.bytes:0)+o.loaded,f=(u.loaded?u.loaded.duration:0)+l;u.loaded={bytes:d,duration:f},u.realBitrate=Math.round(8*d/f)}if(r.bitrateTest){var h={stats:o,frag:r,part:s,id:r.type};this.onFragBuffered(x.FRAG_BUFFERED,h),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}},n.onFragBuffered=function(e,t){var r=t.frag,s=t.part,o=s!=null&&s.stats.loaded?s.stats:r.stats;if(!o.aborted&&!this.ignoreFragment(r)){var l=o.parsing.end-o.loading.start-Math.min(o.loading.first-o.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(l,o.loaded),o.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}},n.ignoreFragment=function(e){return e.type!==j.MAIN||e.sn==="initSegment"},n.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},n.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},n.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,s=r.maxAutoLevel,o=r.config,l=r.minAutoLevel,u=t?t.duration:e?e.duration:0,d=this.getBwEstimate(),f=this.getStarvationDelay(),h=o.abrBandWidthFactor,c=o.abrBandWidthUpFactor;if(f){var v=this.findBestLevel(d,l,s,f,0,h,c);if(v>=0)return v}var m=u?Math.min(u,o.maxStarvationDelay):o.maxStarvationDelay;if(!f){var g=this.bitrateTestDelay;if(g){var p=u?Math.min(u,o.maxLoadingDelay):o.maxLoadingDelay;m=p-g,A.info("[abr] bitrate test took "+Math.round(1e3*g)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*m)+" ms"),h=c=1}}var y=this.findBestLevel(d,l,s,f,m,h,c);if(A.info("[abr] "+(f?"rebuffering expected":"buffer is empty")+", optimal quality level "+y),y>-1)return y;var E=r.levels[l],S=r.levels[r.loadLevel];return E?.bitrate<S?.bitrate?l:r.loadLevel},n.getStarvationDelay=function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/r},n.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},n.findBestLevel=function(e,t,r,s,o,l,u){var d,f=this,h=s+o,c=this.lastLoadedFragLevel,v=c===-1?this.hls.firstLevel:c,m=this.fragCurrent,g=this.partCurrent,p=this.hls,y=p.levels,E=p.allAudioTracks,S=p.loadLevel,L=p.config;if(y.length===1)return 0;var D=y[v],R=!!(D!=null&&(d=D.details)!=null&&d.live),T=S===-1||c===-1,b,I="SDR",P=D?.frameRate||0,C=L.audioPreference,w=L.videoPreference,M=this.audioTracksByGroup||(this.audioTracksByGroup=va(E));if(T){if(this.firstSelection!==-1)return this.firstSelection;var F=this.codecTiers||(this.codecTiers=ga(y,M,t,r)),H=ca(F,I,e,C,w),U=H.codecSet,W=H.videoRanges,K=H.minFramerate,B=H.minBitrate,Q=H.preferHDR;b=U,I=Q?W[W.length-1]:W[0],P=K,e=Math.max(e,B),A.log("[abr] picked start tier "+JSON.stringify(H))}else b=D?.codecSet,I=D?.videoRange;for(var q=g?g.duration:m?m.duration:0,J=this.bwEstimator.getEstimateTTFB()/1e3,ee=[],re=function(){var Ee,te=y[X],ce=X>v;if(!te)return 0;if(b&&te.codecSet!==b||I&&te.videoRange!==I||ce&&P>te.frameRate||!ce&&P>0&&P<te.frameRate||te.supportedResult&&!((Ee=te.supportedResult.decodingInfoResults)!=null&&Ee[0].smooth))return ee.push(X),0;var ve=te.details,ie=(g?ve?.partTarget:ve?.averagetargetduration)||q,z;ce?z=u*e:z=l*e;var pe=q&&s>=q*2&&o===0?y[X].averageBitrate:y[X].maxBitrate,de=f.getTimeToLoadFrag(J,z,pe*ie,ve===void 0),le=z>=pe&&(X===c||te.loadError===0&&te.fragmentError===0)&&(de<=J||!O(de)||R&&!f.bitrateTestDelay||de<h);if(le){var Ue=f.forcedAutoLevel;return X!==S&&(Ue===-1||Ue!==S)&&(ee.length&&A.trace("[abr] Skipped level(s) "+ee.join(",")+" of "+r+' max with CODECS and VIDEO-RANGE:"'+y[ee[0]].codecs+'" '+y[ee[0]].videoRange+'; not compatible with "'+D.codecs+'" '+I),A.info("[abr] switch candidate:"+v+"->"+X+" adjustedbw("+Math.round(z)+")-bitrate="+Math.round(z-pe)+" ttfb:"+J.toFixed(1)+" avgDuration:"+ie.toFixed(1)+" maxFetchDuration:"+h.toFixed(1)+" fetchDuration:"+de.toFixed(1)+" firstSelection:"+T+" codecSet:"+b+" videoRange:"+I+" hls.loadLevel:"+S)),T&&(f.firstSelection=X),{v:X}}},Z,X=r;X>=t;X--)if(Z=re(),Z!==0&&Z)return Z.v;return-1},he(a,[{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.minAutoLevel,s=this.getBwEstimate(),o=this.hls.config.maxStarvationDelay,l=this.findBestLevel(s,r,t,0,o,1,1);if(l>-1)return l;var u=this.hls.firstLevel,d=Math.min(Math.max(u,r),t);return A.warn("[abr] Could not find best starting auto level. Defaulting to first in playlist "+u+" clamped to "+d),d}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator,r=t.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!r||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;var o=r&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){var l=this.hls.levels;if(l.length>Math.max(e,o)&&l[e].loadError<=l[o].loadError)return e}return this._nextAutoLevel=o,this.nextAutoLevelKey=this.getAutoLevelKey(),o},set:function(e){var t=this.hls,r=t.maxAutoLevel,s=t.minAutoLevel,o=Math.min(Math.max(e,s),r);this._nextAutoLevel!==o&&(this.nextAutoLevelKey="",this._nextAutoLevel=o)}}]),a}(),pa={length:0,start:function(){return 0},end:function(){return 0}},ae=function(){function a(){}return a.isBuffered=function(i,e){try{if(i){for(var t=a.getBuffered(i),r=0;r<t.length;r++)if(e>=t.start(r)&&e<=t.end(r))return!0}}catch{}return!1},a.bufferInfo=function(i,e,t){try{if(i){var r=a.getBuffered(i),s=[],o;for(o=0;o<r.length;o++)s.push({start:r.start(o),end:r.end(o)});return this.bufferedInfo(s,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},a.bufferedInfo=function(i,e,t){e=Math.max(0,e),i.sort(function(g,p){var y=g.start-p.start;return y||p.end-g.end});var r=[];if(t)for(var s=0;s<i.length;s++){var o=r.length;if(o){var l=r[o-1].end;i[s].start-l<t?i[s].end>l&&(r[o-1].end=i[s].end):r.push(i[s])}else r.push(i[s])}else r=i;for(var u=0,d,f=e,h=e,c=0;c<r.length;c++){var v=r[c].start,m=r[c].end;if(e+t>=v&&e<m)f=v,h=m,u=h-e;else if(e+t<v){d=v;break}}return{len:u,start:f||0,end:h||0,nextStart:d}},a.getBuffered=function(i){try{return i.buffered}catch(e){return A.log("failed to get media.buffered",e),pa}},a}(),ya=function(){function a(i){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=i}var n=a.prototype;return n.append=function(e,t,r){var s=this.queues[t];s.push(e),s.length===1&&!r&&this.executeNext(t)},n.insertAbort=function(e,t){var r=this.queues[t];r.unshift(e),this.executeNext(t)},n.appendBlocker=function(e){var t,r=new Promise(function(o){t=o}),s={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(s,e),r},n.executeNext=function(e){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(o){A.warn('[buffer-operation-queue]: Exception executing "'+e+'" SourceBuffer operation: '+o),r.onError(o);var s=this.buffers[e];s!=null&&s.updating||this.shiftAndExecuteNext(e)}}},n.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},n.current=function(e){return this.queues[e][0]},a}(),$r=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Ea=function(){function a(i){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=function(r){e.hls&&e.hls.pauseBuffering()},this._onStartStreaming=function(r){e.hls&&e.hls.resumeBuffering()},this._onMediaSourceOpen=function(){var r=e.media,s=e.mediaSource;e.log("Media source opened"),r&&(r.removeEventListener("emptied",e._onMediaEmptied),e.updateMediaElementDuration(),e.hls.trigger(x.MEDIA_ATTACHED,{media:r,mediaSource:s})),s&&s.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){e.log("Media source closed")},this._onMediaSourceEnded=function(){e.log("Media source ended")},this._onMediaEmptied=function(){var r=e.mediaSrc,s=e._objectUrl;r!==s&&A.error("Media element src was set while attaching MediaSource ("+s+" > "+r+")")},this.hls=i;var t="[buffer-controller]";this.appendSource=Cn(Ne(i.config.preferManagedMediaSource)),this.log=A.log.bind(A,t),this.warn=A.warn.bind(A,t),this.error=A.error.bind(A,t),this._initSourceBuffer(),this.registerListeners()}var n=a.prototype;return n.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},n.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null},n.registerListeners=function(){var e=this.hls;e.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.BUFFER_RESET,this.onBufferReset,this),e.on(x.BUFFER_APPENDING,this.onBufferAppending,this),e.on(x.BUFFER_CODECS,this.onBufferCodecs,this),e.on(x.BUFFER_EOS,this.onBufferEos,this),e.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(x.FRAG_PARSED,this.onFragParsed,this),e.on(x.FRAG_CHANGED,this.onFragChanged,this)},n.unregisterListeners=function(){var e=this.hls;e.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.BUFFER_RESET,this.onBufferReset,this),e.off(x.BUFFER_APPENDING,this.onBufferAppending,this),e.off(x.BUFFER_CODECS,this.onBufferCodecs,this),e.off(x.BUFFER_EOS,this.onBufferEos,this),e.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(x.FRAG_PARSED,this.onFragParsed,this),e.off(x.FRAG_CHANGED,this.onFragChanged,this)},n._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new ya(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null},n.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},n.onManifestParsed=function(e,t){var r=2;t.audio&&!t.video||t.altAudio,r=1,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},n.onMediaAttaching=function(e,t){var r=this.media=t.media,s=Ne(this.appendSource);if(r&&s){var o,l=this.mediaSource=new s;this.log("created media source: "+((o=l.constructor)==null?void 0:o.name)),l.addEventListener("sourceopen",this._onMediaSourceOpen),l.addEventListener("sourceended",this._onMediaSourceEnded),l.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(l.addEventListener("startstreaming",this._onStartStreaming),l.addEventListener("endstreaming",this._onEndStreaming));var u=this._objectUrl=self.URL.createObjectURL(l);if(this.appendSource)try{r.removeAttribute("src");var d=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||d&&l instanceof d,Qr(r),xa(r,u),r.load()}catch{r.src=u}else r.src=u;r.addEventListener("emptied",this._onMediaEmptied)}},n.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){this.warn("onMediaDetaching: "+s.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&Qr(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(x.MEDIA_DETACHED,void 0)},n.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(t){e.resetBuffer(t)}),this._initSourceBuffer()},n.resetBuffer=function(e){var t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(s){this.warn("onBufferReset "+e,s)}},n.onBufferCodecs=function(e,t){var r=this,s=this.getSourceBufferTypes().length,o=Object.keys(t);if(o.forEach(function(u){if(s){var d=r.tracks[u];if(d&&typeof d.buffer.changeType=="function"){var f,h=t[u],c=h.id,v=h.codec,m=h.levelCodec,g=h.container,p=h.metadata,y=Rr(d.codec,d.levelCodec),E=y?.replace($r,"$1"),S=Rr(v,m),L=(f=S)==null?void 0:f.replace($r,"$1");if(S&&E!==L){u.slice(0,5)==="audio"&&(S=it(S,r.appendSource));var D=g+";codecs="+S;r.appendChangeType(u,D),r.log("switching codec "+y+" to "+S),r.tracks[u]={buffer:d.buffer,codec:v,container:g,levelCodec:m,metadata:p,id:c}}}}else r.pendingTracks[u]=t[u]}),!s){var l=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==l&&(this.log(l+" bufferCodec event(s) expected "+o.join(",")),this.bufferCodecEventsExpected=l),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}},n.appendChangeType=function(e,t){var r=this,s=this.operationQueue,o={execute:function(){var u=r.sourceBuffer[e];u&&(r.log("changing "+e+" sourceBuffer type to "+t),u.changeType(t)),s.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(u){r.warn("Failed to change "+e+" SourceBuffer type",u)}};s.append(o,e,!!this.pendingTracks[e])},n.onBufferAppending=function(e,t){var r=this,s=this.hls,o=this.operationQueue,l=this.tracks,u=t.data,d=t.type,f=t.frag,h=t.part,c=t.chunkMeta,v=c.buffering[d],m=self.performance.now();v.start=m;var g=f.stats.buffering,p=h?h.stats.buffering:null;g.start===0&&(g.start=m),p&&p.start===0&&(p.start=m);var y=l.audio,E=!1;d==="audio"&&y?.container==="audio/mpeg"&&(E=!this.lastMpegAudioChunk||c.id===1||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);var S=f.start,L={execute:function(){if(v.executeStart=self.performance.now(),E){var R=r.sourceBuffer[d];if(R){var T=S-R.timestampOffset;Math.abs(T)>=.1&&(r.log("Updating audio SourceBuffer timestampOffset to "+S+" (delta: "+T+") sn: "+f.sn+")"),R.timestampOffset=S)}}r.appendExecutor(u,d)},onStart:function(){},onComplete:function(){var R=self.performance.now();v.executeEnd=v.end=R,g.first===0&&(g.first=R),p&&p.first===0&&(p.first=R);var T=r.sourceBuffer,b={};for(var I in T)b[I]=ae.getBuffered(T[I]);r.appendErrors[d]=0,d==="audio"||d==="video"?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(x.BUFFER_APPENDED,{type:d,frag:f,part:h,chunkMeta:c,parent:f.type,timeRanges:b})},onError:function(R){var T={type:V.MEDIA_ERROR,parent:f.type,details:_.BUFFER_APPEND_ERROR,sourceBufferName:d,frag:f,part:h,chunkMeta:c,error:R,err:R,fatal:!1};if(R.code===DOMException.QUOTA_EXCEEDED_ERR)T.details=_.BUFFER_FULL_ERROR;else{var b=++r.appendErrors[d];T.details=_.BUFFER_APPEND_ERROR,r.warn("Failed "+b+"/"+s.config.appendErrorMaxRetry+' times to append segment in "'+d+'" sourceBuffer'),b>=s.config.appendErrorMaxRetry&&(T.fatal=!0)}s.trigger(x.ERROR,T)}};o.append(L,d,!!this.pendingTracks[d])},n.onBufferFlushing=function(e,t){var r=this,s=this.operationQueue,o=function(u){return{execute:r.removeExecutor.bind(r,u,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(x.BUFFER_FLUSHED,{type:u})},onError:function(f){r.warn("Failed to remove from "+u+" SourceBuffer",f)}}};t.type?s.append(o(t.type),t.type):this.getSourceBufferTypes().forEach(function(l){s.append(o(l),l)})},n.onFragParsed=function(e,t){var r=this,s=t.frag,o=t.part,l=[],u=o?o.elementaryStreams:s.elementaryStreams;u[$.AUDIOVIDEO]?l.push("audiovideo"):(u[$.AUDIO]&&l.push("audio"),u[$.VIDEO]&&l.push("video"));var d=function(){var h=self.performance.now();s.stats.buffering.end=h,o&&(o.stats.buffering.end=h);var c=o?o.stats:s.stats;r.hls.trigger(x.FRAG_BUFFERED,{frag:s,part:o,stats:c,id:s.type})};l.length===0&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+s.type+" level: "+s.level+" sn: "+s.sn),this.blockBuffers(d,l)},n.onFragChanged=function(e,t){this.trimBuffers()},n.onBufferEos=function(e,t){var r=this,s=this.getSourceBufferTypes().reduce(function(o,l){var u=r.sourceBuffer[l];return u&&(!t.type||t.type===l)&&(u.ending=!0,u.ended||(u.ended=!0,r.log(l+" sourceBuffer now EOS"))),o&&!!(!u||u.ended)},!0);s&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){r.getSourceBufferTypes().forEach(function(l){var u=r.sourceBuffer[l];u&&(u.ending=!1)});var o=r.mediaSource;if(!o||o.readyState!=="open"){o&&r.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+o.readyState);return}r.log("Calling mediaSource.endOfStream()"),o.endOfStream()}))},n.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},n.trimBuffers=function(){var e=this.hls,t=this.details,r=this.media;if(!(!r||t===null)){var s=this.getSourceBufferTypes();if(s.length){var o=e.config,l=r.currentTime,u=t.levelTargetDuration,d=t.live&&o.liveBackBufferLength!==null?o.liveBackBufferLength:o.backBufferLength;if(O(d)&&d>0){var f=Math.max(d,u),h=Math.floor(l/u)*u-f;this.flushBackBuffer(l,u,h)}if(O(o.frontBufferFlushThreshold)&&o.frontBufferFlushThreshold>0){var c=Math.max(o.maxBufferLength,o.frontBufferFlushThreshold),v=Math.max(c,u),m=Math.floor(l/u)*u+v;this.flushFrontBuffer(l,u,m)}}}},n.flushBackBuffer=function(e,t,r){var s=this,o=this.details,l=this.sourceBuffer,u=this.getSourceBufferTypes();u.forEach(function(d){var f=l[d];if(f){var h=ae.getBuffered(f);if(h.length>0&&r>h.start(0)){if(s.hls.trigger(x.BACK_BUFFER_REACHED,{bufferEnd:r}),o!=null&&o.live)s.hls.trigger(x.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(f.ended&&h.end(h.length-1)-e<t*2){s.log("Cannot flush "+d+" back buffer while SourceBuffer is in ended state");return}s.hls.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:d})}}})},n.flushFrontBuffer=function(e,t,r){var s=this,o=this.sourceBuffer,l=this.getSourceBufferTypes();l.forEach(function(u){var d=o[u];if(d){var f=ae.getBuffered(d),h=f.length;if(h<2)return;var c=f.start(h-1),v=f.end(h-1);if(r>c||e>=c&&e<=v)return;if(d.ended&&e-v<2*t){s.log("Cannot flush "+u+" front buffer while SourceBuffer is in ended state");return}s.hls.trigger(x.BUFFER_FLUSHING,{startOffset:c,endOffset:1/0,type:u})}})},n.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,t=this.hls,r=this.media,s=this.mediaSource,o=e.fragments[0].start+e.totalduration,l=r.duration,u=O(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(s.duration=1/0,this.updateSeekableRange(e)):(o>u&&o>l||!O(l))&&(this.log("Updating Media Source duration to "+o.toFixed(3)),s.duration=o)}},n.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments,s=r.length;if(s&&e.live&&t!=null&&t.setLiveSeekableRange){var o=Math.max(0,r[0].start),l=Math.max(o,o+e.totalduration);this.log("Media Source duration is set to "+t.duration+". Setting seekable range to "+o+"-"+l+"."),t.setLiveSeekableRange(o,l)}},n.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,s=Object.keys(r).length;if(s&&(!e||s===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};var o=this.getSourceBufferTypes();if(o.length)this.hls.trigger(x.BUFFER_CREATED,{tracks:this.tracks}),o.forEach(function(u){t.executeNext(u)});else{var l=new Error("could not create source buffer for media codec(s)");this.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:_.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:l,reason:l.message})}}},n.createSourceBuffers=function(e){var t=this,r=this.sourceBuffer,s=this.mediaSource;if(!s)throw Error("createSourceBuffers called when mediaSource was null");var o=function(d){if(!r[d]){var f,h=e[d];if(!h)throw Error("source buffer exists for track "+d+", however track does not");var c=((f=h.levelCodec)==null?void 0:f.indexOf(","))===-1?h.levelCodec:h.codec;c&&d.slice(0,5)==="audio"&&(c=it(c,t.appendSource));var v=h.container+";codecs="+c;t.log("creating sourceBuffer("+v+")");try{var m=r[d]=s.addSourceBuffer(v),g=d;t.addBufferListener(g,"updatestart",t._onSBUpdateStart),t.addBufferListener(g,"updateend",t._onSBUpdateEnd),t.addBufferListener(g,"error",t._onSBUpdateError),t.appendSource&&t.addBufferListener(g,"bufferedchange",function(p,y){var E=y.removedRanges;E!=null&&E.length&&t.hls.trigger(x.BUFFER_FLUSHED,{type:d})}),t.tracks[d]={buffer:m,codec:c,container:h.container,levelCodec:h.levelCodec,metadata:h.metadata,id:h.id}}catch(p){t.error("error while trying to add sourceBuffer: "+p.message),t.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:_.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:p,sourceBufferName:d,mimeType:v})}}};for(var l in e)o(l)},n._onSBUpdateStart=function(e){var t=this.operationQueue,r=t.current(e);r.onStart()},n._onSBUpdateEnd=function(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}var r=this.operationQueue,s=r.current(e);s.onComplete(),r.shiftAndExecuteNext(e)},n._onSBUpdateError=function(e,t){var r,s=new Error(e+" SourceBuffer error. MediaSource readyState: "+((r=this.mediaSource)==null?void 0:r.readyState));this.error(""+s,t),this.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:_.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});var o=this.operationQueue.current(e);o&&o.onError(s)},n.removeExecutor=function(e,t,r){var s=this.media,o=this.mediaSource,l=this.operationQueue,u=this.sourceBuffer,d=u[e];if(!s||!o||!d){this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),l.shiftAndExecuteNext(e);return}var f=O(s.duration)?s.duration:1/0,h=O(o.duration)?o.duration:1/0,c=Math.max(0,t),v=Math.min(r,f,h);v>c&&(!d.ending||d.ended)?(d.ended=!1,this.log("Removing ["+c+","+v+"] from the "+e+" SourceBuffer"),d.remove(c,v)):l.shiftAndExecuteNext(e)},n.appendExecutor=function(e,t){var r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw new Error("Attempting to append to the "+t+" SourceBuffer, but it does not exist");return}r.ended=!1,r.appendBuffer(e)},n.blockBuffers=function(e,t){var r=this;if(t===void 0&&(t=this.getSourceBufferTypes()),!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var s=this.operationQueue,o=t.map(function(l){return s.appendBlocker(l)});Promise.all(o).then(function(){e(),t.forEach(function(l){var u=r.sourceBuffer[l];u!=null&&u.updating||s.shiftAndExecuteNext(l)})})},n.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},n.addBufferListener=function(e,t,r){var s=this.sourceBuffer[e];if(s){var o=r.bind(this,e);this.listeners[e].push({event:t,listener:o}),s.addEventListener(t,o)}},n.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach(function(r){t.removeEventListener(r.event,r.listener)})},he(a,[{key:"mediaSrc",get:function(){var e,t=((e=this.media)==null?void 0:e.firstChild)||this.media;return t?.src}}]),a}();function Qr(a){var n=a.querySelectorAll("source");[].slice.call(n).forEach(function(i){a.removeChild(i)})}function xa(a,n){var i=self.document.createElement("source");i.type="video/mp4",i.src=n,a.appendChild(i)}var Ta=function(){function a(i){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=i,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var n=a.prototype;return n.setStreamController=function(e){this.streamController=e},n.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},n.registerListeners=function(){var e=this.hls;e.on(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(x.BUFFER_CODECS,this.onBufferCodecs,this),e.on(x.MEDIA_DETACHING,this.onMediaDetaching,this)},n.unregisterListener=function(){var e=this.hls;e.off(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(x.BUFFER_CODECS,this.onBufferCodecs,this),e.off(x.MEDIA_DETACHING,this.onMediaDetaching,this)},n.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})},n.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},n.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},n.onLevelsUpdated=function(e,t){this.timer&&O(this.autoLevelCapping)&&this.detectPlayerSize()},n.onBufferCodecs=function(e,t){var r=this.hls;r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},n.onMediaDetaching=function(){this.stopCapping()},n.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}var e=this.hls.levels;if(e.length){var t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&A.log("Setting autoLevelCapping to "+r+": "+e[r].height+"p@"+e[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},n.getMaxLevel=function(e){var t=this,r=this.hls.levels;if(!r.length)return-1;var s=r.filter(function(o,l){return t.isLevelAllowed(o)&&l<=e});return this.clientRect=null,a.getMaxLevelByMediaSize(s,this.mediaWidth,this.mediaHeight)},n.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},n.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},n.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},n.isLevelAllowed=function(e){var t=this.restrictedLevels;return!t.some(function(r){return e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height})},a.getMaxLevelByMediaSize=function(e,t,r){if(!(e!=null&&e.length))return-1;for(var s=function(h,c){return c?h.width!==c.width||h.height!==c.height:!0},o=e.length-1,l=Math.max(t,r),u=0;u<e.length;u+=1){var d=e[u];if((d.width>=l||d.height>=l)&&s(d,e[u+1])){o=u;break}}return o},he(a,[{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{}return e}}]),a}(),Sa=function(){function a(i){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=i,this.registerListeners()}var n=a.prototype;return n.setStreamController=function(e){this.streamController=e},n.registerListeners=function(){this.hls.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this)},n.unregisterListeners=function(){this.hls.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this)},n.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},n.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},n.checkFPS=function(e,t,r){var s=performance.now();if(t){if(this.lastTime){var o=s-this.lastTime,l=r-this.lastDroppedFrames,u=t-this.lastDecodedFrames,d=1e3*l/o,f=this.hls;if(f.trigger(x.FPS_DROP,{currentDropped:l,currentDecoded:u,totalDroppedFrames:r}),d>0&&l>f.config.fpsDroppedMonitoringThreshold*u){var h=f.currentLevel;A.warn("drop FPS ratio greater than max allowed value for currentLevel: "+h),h>0&&(f.autoLevelCapping===-1||f.autoLevelCapping>=h)&&(h=h-1,f.trigger(x.FPS_DROP_LEVEL_CAPPING,{level:h,droppedLevel:f.currentLevel}),f.autoLevelCapping=h,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},n.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)},a}(),La=3e5,Aa=function(){function a(i){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=i,this.log=A.log.bind(A,"[content-steering]:"),this.registerListeners()}var n=a.prototype;return n.registerListeners=function(){var e=this.hls;e.on(x.MANIFEST_LOADING,this.onManifestLoading,this),e.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(x.MANIFEST_PARSED,this.onManifestParsed,this),e.on(x.ERROR,this.onError,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(x.MANIFEST_LOADING,this.onManifestLoading,this),e.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(x.MANIFEST_PARSED,this.onManifestParsed,this),e.off(x.ERROR,this.onError,this))},n.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}},n.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},n.clearTimeout=function(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},n.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},n.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter(function(r){return r!==e}))},n.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},n.onManifestLoaded=function(e,t){var r=t.contentSteering;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},n.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},n.onError=function(e,t){var r=t.errorAction;if(r?.action===ue.SendAlternateToPenaltyBox&&r.flags===Se.MoveAllAlternatesMatchingHost){var s=this.levels,o=this.pathwayPriority,l=this.pathwayId;if(t.context){var u=t.context,d=u.groupId,f=u.pathwayId,h=u.type;d&&s?l=this.getPathwayForGroupId(d,h,l):f&&(l=f)}l in this.penalizedPathways||(this.penalizedPathways[l]=performance.now()),!o&&s&&(o=s.reduce(function(c,v){return c.indexOf(v.pathwayId)===-1&&c.push(v.pathwayId),c},[])),o&&o.length>1&&(this.updatePathwayPriority(o),r.resolved=this.pathwayId!==l),r.resolved||A.warn("Could not resolve "+t.details+' ("'+t.error.message+'") with content-steering for Pathway: '+l+" levels: "+(s&&s.length)+" priorities: "+JSON.stringify(o)+" penalized: "+JSON.stringify(this.penalizedPathways))}},n.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){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):e},n.getLevelsForPathway=function(e){return this.levels===null?[]:this.levels.filter(function(t){return e===t.pathwayId})},n.updatePathwayPriority=function(e){this.pathwayPriority=e;var t,r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(function(h){s-r[h]>La&&delete r[h]});for(var o=0;o<e.length;o++){var l=e[o];if(!(l in r)){if(l===this.pathwayId)return;var u=this.hls.nextLoadLevel,d=this.hls.levels[u];if(t=this.getLevelsForPathway(l),t.length>0){this.log('Setting Pathway to "'+l+'"'),this.pathwayId=l,Wr(t),this.hls.trigger(x.LEVELS_UPDATED,{levels:t});var f=this.hls.levels[u];d&&f&&this.levels&&(f.attrs["STABLE-VARIANT-ID"]!==d.attrs["STABLE-VARIANT-ID"]&&f.bitrate!==d.bitrate&&this.log("Unstable Pathways change from bitrate "+d.bitrate+" to "+f.bitrate),this.hls.nextLoadLevel=u);break}}}},n.getPathwayForGroupId=function(e,t,r){for(var s=this.getLevelsForPathway(r).concat(this.levels||[]),o=0;o<s.length;o++)if(t===Y.AUDIO_TRACK&&s[o].hasAudioGroup(e)||t===Y.SUBTITLE_TRACK&&s[o].hasSubtitleGroup(e))return s[o].pathwayId;return r},n.clonePathways=function(e){var t=this,r=this.levels;if(r){var s={},o={};e.forEach(function(l){var u=l.ID,d=l["BASE-ID"],f=l["URI-REPLACEMENT"];if(!r.some(function(c){return c.pathwayId===u})){var h=t.getLevelsForPathway(d).map(function(c){var v=new ne(c.attrs);v["PATHWAY-ID"]=u;var m=v.AUDIO&&v.AUDIO+"_clone_"+u,g=v.SUBTITLES&&v.SUBTITLES+"_clone_"+u;m&&(s[v.AUDIO]=m,v.AUDIO=m),g&&(o[v.SUBTITLES]=g,v.SUBTITLES=g);var p=Jr(c.uri,v["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f),y=new Ft({attrs:v,audioCodec:c.audioCodec,bitrate:c.bitrate,height:c.height,name:c.name,url:p,videoCodec:c.videoCodec,width:c.width});if(c.audioGroups)for(var E=1;E<c.audioGroups.length;E++)y.addGroupId("audio",c.audioGroups[E]+"_clone_"+u);if(c.subtitleGroups)for(var S=1;S<c.subtitleGroups.length;S++)y.addGroupId("text",c.subtitleGroups[S]+"_clone_"+u);return y});r.push.apply(r,h),Zr(t.audioTracks,s,f,u),Zr(t.subtitleTracks,o,f,u)}})}},n.loadSteeringManifest=function(e){var t=this,r=this.hls.config,s=r.loader;this.loader&&this.loader.destroy(),this.loader=new s(r);var o;try{o=new self.URL(e)}catch{this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+e);return}if(o.protocol!=="data:"){var l=(this.hls.bandwidthEstimate||r.abrEwmaDefaultEstimate)|0;o.searchParams.set("_HLS_pathway",this.pathwayId),o.searchParams.set("_HLS_throughput",""+l)}var u={responseType:"json",url:o.href},d=r.steeringManifestLoadPolicy.default,f=d.errorRetry||d.timeoutRetry||{},h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:f.maxNumRetry||0,retryDelay:f.retryDelayMs||0,maxRetryDelay:f.maxRetryDelayMs||0},c={onSuccess:function(m,g,p,y){t.log('Loaded steering manifest: "'+o+'"');var E=m.data;if(E.VERSION!==1){t.log("Steering VERSION "+E.VERSION+" not supported!");return}t.updated=performance.now(),t.timeToLoad=E.TTL;var S=E["RELOAD-URI"],L=E["PATHWAY-CLONES"],D=E["PATHWAY-PRIORITY"];if(S)try{t.uri=new self.URL(S,o).href}catch{t.enabled=!1,t.log("Failed to parse Steering Manifest RELOAD-URI: "+S);return}t.scheduleRefresh(t.uri||p.url),L&&t.clonePathways(L);var R={steeringManifest:E,url:o.toString()};t.hls.trigger(x.STEERING_MANIFEST_LOADED,R),D&&t.updatePathwayPriority(D)},onError:function(m,g,p,y){if(t.log("Error loading steering manifest: "+m.code+" "+m.text+" ("+g.url+")"),t.stopLoad(),m.code===410){t.enabled=!1,t.log("Steering manifest "+g.url+" no longer available");return}var E=t.timeToLoad*1e3;if(m.code===429){var S=t.loader;if(typeof S?.getResponseHeader=="function"){var L=S.getResponseHeader("Retry-After");L&&(E=parseFloat(L)*1e3)}t.log("Steering manifest "+g.url+" rate limited");return}t.scheduleRefresh(t.uri||g.url,E)},onTimeout:function(m,g,p){t.log("Timeout loading steering manifest ("+g.url+")"),t.scheduleRefresh(t.uri||g.url)}};this.log("Requesting steering manifest: "+o),this.loader.load(u,h,c)},n.scheduleRefresh=function(e,t){var r=this;t===void 0&&(t=this.timeToLoad*1e3),this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var s,o=(s=r.hls)==null?void 0:s.media;if(o&&!o.ended){r.loadSteeringManifest(e);return}r.scheduleRefresh(e,r.timeToLoad*1e3)},t)},a}();function Zr(a,n,i,e){a&&Object.keys(n).forEach(function(t){var r=a.filter(function(s){return s.groupId===t}).map(function(s){var o=ye({},s);return o.details=void 0,o.attrs=new ne(o.attrs),o.url=o.attrs.URI=Jr(s.url,s.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),o.groupId=o.attrs["GROUP-ID"]=n[t],o.attrs["PATHWAY-ID"]=e,o});a.push.apply(a,r)})}function Jr(a,n,i,e){var t=e.HOST,r=e.PARAMS,s=e[i],o;n&&(o=s?.[n],o&&(a=o));var l=new self.URL(a);return t&&!o&&(l.host=t),r&&Object.keys(r).sort().forEach(function(u){u&&l.searchParams.set(u,r[u])}),l.href}var Ra=/^age:\s*[\d.]+\s*$/im,ei=function(){function a(i){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=i&&i.xhrSetup||null,this.stats=new $e,this.retryDelay=0}var n=a.prototype;return n.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null,this.stats=null},n.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))},n.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},n.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()},n.loadInternal=function(){var e=this,t=this.config,r=this.context;if(!(!t||!r)){var s=this.loader=new self.XMLHttpRequest,o=this.stats;o.loading.first=0,o.loaded=0,o.aborted=!1;var l=this.xhrSetup;l?Promise.resolve().then(function(){if(!e.stats.aborted)return l(s,r.url)}).catch(function(u){return s.open("GET",r.url,!0),l(s,r.url)}).then(function(){e.stats.aborted||e.openAndSendXhr(s,r,t)}).catch(function(u){e.callbacks.onError({code:s.status,text:u.message},r,s,o)}):this.openAndSendXhr(s,r,t)}},n.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var s=t.headers,o=r.loadPolicy,l=o.maxTimeToFirstByteMs,u=o.maxLoadTimeMs;if(s)for(var d in s)e.setRequestHeader(d,s[d]);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=l&&O(l)?l:u,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},n.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(!(!e||!t)){var s=t.readyState,o=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),o.timeout!==o.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),o.timeout=o.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),o.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var l=t.status,u=t.responseType!=="text";if(l>=200&&l<300&&(u&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var d=u?t.response:t.responseText,f=t.responseType==="arraybuffer"?d.byteLength:d.length;if(r.loaded=r.total=f,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;var h=this.callbacks.onProgress;if(h&&h(r,e,d,t),!this.callbacks)return;var c={url:t.responseURL,data:d,code:l};this.callbacks.onSuccess(c,r,e,t)}else{var v=o.loadPolicy.errorRetry,m=r.retry,g={url:e.url,data:void 0,code:l};lt(v,m,!1,g)?this.retry(v):(A.error(l+" while loading "+e.url),this.callbacks.onError({code:l,text:t.statusText},e,t,r))}}}},n.loadtimeout=function(){var e,t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,r=this.stats.retry;if(lt(t,r,!0))this.retry(t);else{var s;A.warn("timeout while loading "+((s=this.context)==null?void 0:s.url));var o=this.callbacks;o&&(this.abortInternal(),o.onTimeout(this.stats,this.context,this.loader))}},n.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=Mt(e,r.retry),r.retry++,A.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+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)},n.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},n.getCacheAge=function(){var e=null;if(this.loader&&Ra.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},n.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},a}(),ba=function(){function a(){this.chunks=[],this.dataLength=0}var n=a.prototype;return n.push=function(e){this.chunks.push(e),this.dataLength+=e.length},n.flush=function(){var e=this.chunks,t=this.dataLength,r;if(e.length)e.length===1?r=e[0]:r=Ia(e,t);else return new Uint8Array(0);return this.reset(),r},n.reset=function(){this.chunks.length=0,this.dataLength=0},a}();function Ia(a,n){for(var i=new Uint8Array(n),e=0,t=0;t<a.length;t++){var r=a[t];i.set(r,e),e+=r.length}return i}function _a(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var Da=/(\d+)-(\d+)\/(\d+)/,ti=function(){function a(i){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=i.fetchSetup||ka,this.controller=new self.AbortController,this.stats=new $e}var n=a.prototype;return n.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},n.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},n.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},n.load=function(e,t,r){var s=this,o=this.stats;if(o.loading.start)throw new Error("Loader can only be used once.");o.loading.start=self.performance.now();var l=Ca(e,this.controller.signal),u=r.onProgress,d=e.responseType==="arraybuffer",f=d?"byteLength":"length",h=t.loadPolicy,c=h.maxTimeToFirstByteMs,v=h.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,l),self.clearTimeout(this.requestTimeout),t.timeout=c&&O(c)?c:v,this.requestTimeout=self.setTimeout(function(){s.abortInternal(),r.onTimeout(o,e,s.response)},t.timeout),self.fetch(this.request).then(function(m){s.response=s.loader=m;var g=Math.max(self.performance.now(),o.loading.start);if(self.clearTimeout(s.requestTimeout),t.timeout=v,s.requestTimeout=self.setTimeout(function(){s.abortInternal(),r.onTimeout(o,e,s.response)},v-(g-o.loading.start)),!m.ok){var p=m.status,y=m.statusText;throw new Fa(y||"fetch, bad network response",p,m)}return o.loading.first=g,o.total=wa(m.headers)||o.total,u&&O(t.highWaterMark)?s.loadProgressively(m,o,e,t.highWaterMark,u):d?m.arrayBuffer():e.responseType==="json"?m.json():m.text()}).then(function(m){var g=s.response;if(!g)throw new Error("loader destroyed");self.clearTimeout(s.requestTimeout),o.loading.end=Math.max(self.performance.now(),o.loading.first);var p=m[f];p&&(o.loaded=o.total=p);var y={url:g.url,data:m,code:g.status};u&&!O(t.highWaterMark)&&u(o,e,m,g),r.onSuccess(y,o,e,g)}).catch(function(m){if(self.clearTimeout(s.requestTimeout),!o.aborted){var g=m&&m.code||0,p=m?m.message:null;r.onError({code:g,text:p},e,m?m.details:null,o)}})},n.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},n.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},n.loadProgressively=function(e,t,r,s,o){s===void 0&&(s=0);var l=new ba,u=e.body.getReader(),d=function f(){return u.read().then(function(h){if(h.done)return l.dataLength&&o(t,r,l.flush(),e),Promise.resolve(new ArrayBuffer(0));var c=h.value,v=c.length;return t.loaded+=v,v<s||l.dataLength?(l.push(c),l.dataLength>=s&&o(t,r,l.flush(),e)):o(t,r,c,e),f()}).catch(function(){return Promise.reject()})};return d()},a}();function Ca(a,n){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:n,headers:new self.Headers(ye({},a.headers))};return a.rangeEnd&&i.headers.set("Range","bytes="+a.rangeStart+"-"+String(a.rangeEnd-1)),i}function Pa(a){var n=Da.exec(a);if(n)return parseInt(n[2])-parseInt(n[1])+1}function wa(a){var n=a.get("Content-Range");if(n){var i=Pa(n);if(O(i))return i}var e=a.get("Content-Length");if(e)return parseInt(e)}function ka(a,n){return new self.Request(a.url,n)}var Fa=function(a){Re(n,a);function n(i,e,t){var r;return r=a.call(this,i)||this,r.code=void 0,r.details=void 0,r.code=e,r.details=t,r}return n}(ze(Error)),Oa={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},ri=ge(ge({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:ei,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:ma,bufferController:Ea,capLevelController:Ta,errorController:la,fpsController:Sa,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!1,certLoadPolicy:{default:Oa},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},Ma()),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:Aa});function Ma(){return{cueHandler:an,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Na(a,n){if((n.liveSyncDurationCount||n.liveMaxLatencyDurationCount)&&(n.liveSyncDuration||n.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(n.liveMaxLatencyDurationCount!==void 0&&(n.liveSyncDurationCount===void 0||n.liveMaxLatencyDurationCount<=n.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(n.liveMaxLatencyDuration!==void 0&&(n.liveSyncDuration===void 0||n.liveMaxLatencyDuration<=n.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var i=Nt(a),e=["manifest","level","frag"],t=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return e.forEach(function(r){var s=(r==="level"?"playlist":r)+"LoadPolicy",o=n[s]===void 0,l=[];t.forEach(function(u){var d=r+"Loading"+u,f=n[d];if(f!==void 0&&o){l.push(d);var h=i[s].default;switch(n[s]={default:h},u){case"TimeOut":h.maxLoadTimeMs=f,h.maxTimeToFirstByteMs=f;break;case"MaxRetry":h.errorRetry.maxNumRetry=f,h.timeoutRetry.maxNumRetry=f;break;case"RetryDelay":h.errorRetry.retryDelayMs=f,h.timeoutRetry.retryDelayMs=f;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=f,h.timeoutRetry.maxRetryDelayMs=f;break}}}),l.length&&A.warn('hls.js config: "'+l.join('", "')+'" setting(s) are deprecated, use "'+s+'": '+JSON.stringify(n[s]))}),ge(ge({},i),n)}function Nt(a){return a&&typeof a=="object"?Array.isArray(a)?a.map(Nt):Object.keys(a).reduce(function(n,i){return n[i]=Nt(a[i]),n},{}):a}function Ba(a){var n=a.loader;if(n!==ti&&n!==ei)A.log("[config]: Custom loader detected, cannot enable progressive streaming"),a.progressive=!1;else{var i=_a();i&&(a.loader=ti,a.progressive=!0,a.enableSoftwareAES=!0,A.log("[config]: Progressive streaming enabled, using FetchLoader"))}}var Bt,Ua=function(a){Re(n,a);function n(e,t){var r;return r=a.call(this,e,"[level-controller]")||this,r._levels=[],r._firstLevel=-1,r._maxAutoLevel=-1,r._startLevel=void 0,r.currentLevel=null,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.steering=void 0,r.onParsedComplete=void 0,r.steering=t,r._registerListeners(),r}var i=n.prototype;return i._registerListeners=function(){var t=this.hls;t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(x.LEVEL_LOADED,this.onLevelLoaded,this),t.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(x.FRAG_BUFFERED,this.onFragBuffered,this),t.on(x.ERROR,this.onError,this)},i._unregisterListeners=function(){var t=this.hls;t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(x.LEVEL_LOADED,this.onLevelLoaded,this),t.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(x.FRAG_BUFFERED,this.onFragBuffered,this),t.off(x.ERROR,this.onError,this)},i.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),a.prototype.destroy.call(this)},i.stopLoad=function(){var t=this._levels;t.forEach(function(r){r.loadError=0,r.fragmentError=0}),a.prototype.stopLoad.call(this)},i.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},i.onManifestLoading=function(t,r){this.resetLevels()},i.onManifestLoaded=function(t,r){var s=this.hls.config.preferManagedMediaSource,o=[],l={},u={},d=!1,f=!1,h=!1;r.levels.forEach(function(c){var v,m,g=c.attrs,p=c.audioCodec,y=c.videoCodec;((v=p)==null?void 0:v.indexOf("mp4a.40.34"))!==-1&&(Bt||(Bt=/chrome|firefox/i.test(navigator.userAgent)),Bt&&(c.audioCodec=p=void 0)),p&&(c.audioCodec=p=it(p,s)),((m=y)==null?void 0:m.indexOf("avc1"))===0&&(y=c.videoCodec=Fn(y));var E=c.width,S=c.height,L=c.unknownCodecs;if(d||(d=!!(E&&S)),f||(f=!!y),h||(h=!!p),!(L!=null&&L.length||p&&!It(p,"audio",s)||y&&!It(y,"video",s))){var D=g.CODECS,R=g["FRAME-RATE"],T=g["HDCP-LEVEL"],b=g["PATHWAY-ID"],I=g.RESOLUTION,P=g["VIDEO-RANGE"],C=(b||".")+"-",w=""+C+c.bitrate+"-"+I+"-"+R+"-"+D+"-"+P+"-"+T;if(l[w])if(l[w].uri!==c.url&&!c.attrs["PATHWAY-ID"]){var F=u[w]+=1;c.attrs["PATHWAY-ID"]=new Array(F+1).join(".");var H=new Ft(c);l[w]=H,o.push(H)}else l[w].addGroupId("audio",g.AUDIO),l[w].addGroupId("text",g.SUBTITLES);else{var M=new Ft(c);l[w]=M,u[w]=1,o.push(M)}}}),this.filterAndSortMediaOptions(o,r,d,f,h)},i.filterAndSortMediaOptions=function(t,r,s,o,l){var u=this,d=[],f=[],h=t;if((s||o)&&l&&(h=h.filter(function(T){var b=T.videoCodec,I=T.videoRange,P=T.width,C=T.height;return(!!b||!!(P&&C))&&$n(I)})),h.length===0){Promise.resolve().then(function(){if(u.hls){r.levels.length&&u.warn("One or more CODECS in variant not supported: "+JSON.stringify(r.levels[0].attrs));var T=new Error("no level with compatible codecs found in manifest");u.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:_.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:T,reason:T.message})}});return}if(r.audioTracks){var c=this.hls.config.preferManagedMediaSource;d=r.audioTracks.filter(function(T){return!T.audioCodec||It(T.audioCodec,"audio",c)}),ii(d)}r.subtitles&&(f=r.subtitles,ii(f));var v=h.slice(0);h.sort(function(T,b){if(T.attrs["HDCP-LEVEL"]!==b.attrs["HDCP-LEVEL"])return(T.attrs["HDCP-LEVEL"]||"")>(b.attrs["HDCP-LEVEL"]||"")?1:-1;if(s&&T.height!==b.height)return T.height-b.height;if(T.frameRate!==b.frameRate)return T.frameRate-b.frameRate;if(T.videoRange!==b.videoRange)return at.indexOf(T.videoRange)-at.indexOf(b.videoRange);if(T.videoCodec!==b.videoCodec){var I=Ar(T.videoCodec),P=Ar(b.videoCodec);if(I!==P)return P-I}if(T.uri===b.uri&&T.codecSet!==b.codecSet){var C=rt(T.codecSet),w=rt(b.codecSet);if(C!==w)return w-C}return T.averageBitrate!==b.averageBitrate?T.averageBitrate-b.averageBitrate:0});var m=v[0];if(this.steering&&(h=this.steering.filterParsedLevels(h),h.length!==v.length)){for(var g=0;g<v.length;g++)if(v[g].pathwayId===h[0].pathwayId){m=v[g];break}}this._levels=h;for(var p=0;p<h.length;p++)if(h[p]===m){var y;this._firstLevel=p;var E=m.bitrate,S=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+h.length+" level(s) found, first bitrate: "+E),((y=this.hls.userConfig)==null?void 0:y.abrEwmaDefaultEstimate)===void 0){var L=Math.min(E,this.hls.config.abrEwmaDefaultEstimateMax);L>S&&S===ri.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=L)}break}var D=l&&!o,R={levels:h,audioTracks:d,subtitleTracks:f,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:l,video:o,altAudio:!D&&d.some(function(T){return!!T.url})};this.hls.trigger(x.MANIFEST_PARSED,R),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)},i.onError=function(t,r){r.fatal||!r.context||r.context.type===Y.LEVEL&&r.context.level===this.level&&this.checkRetry(r)},i.onFragBuffered=function(t,r){var s=r.frag;if(s!==void 0&&s.type===j.MAIN){var o=s.elementaryStreams;if(!Object.keys(o).some(function(u){return!!o[u]}))return;var l=this._levels[s.level];l!=null&&l.loadError&&(this.log("Resetting level error count of "+l.loadError+" on frag buffered"),l.loadError=0)}},i.onLevelLoaded=function(t,r){var s,o=r.level,l=r.details,u=this._levels[o];if(!u){var d;this.warn("Invalid level index "+o),(d=r.deliveryDirectives)!=null&&d.skip&&(l.deltaUpdateFailed=!0);return}o===this.currentLevelIndex?(u.fragmentError===0&&(u.loadError=0),this.playlistLoaded(o,r,u.details)):(s=r.deliveryDirectives)!=null&&s.skip&&(l.deltaUpdateFailed=!0)},i.loadPlaylist=function(t){a.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,s=this.currentLevel;if(s&&this.shouldLoadPlaylist(s)){var o=s.uri;if(t)try{o=t.addDirectives(o)}catch(u){this.warn("Could not construct new URL with HLS Delivery Directives: "+u)}var l=s.attrs["PATHWAY-ID"];this.log("Loading level index "+r+(t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:"")+" with"+(l?" Pathway "+l:"")+" "+o),this.clearTimer(),this.hls.trigger(x.LEVEL_LOADING,{url:o,level:r,pathwayId:s.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},i.removeLevel=function(t){var r=this,s,o=this._levels.filter(function(l,u){return u!==t?!0:(r.steering&&r.steering.removeLevel(l),l===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,l.details&&l.details.fragments.forEach(function(d){return d.level=-1})),!1)});Wr(o),this._levels=o,this.currentLevelIndex>-1&&(s=this.currentLevel)!=null&&s.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(x.LEVELS_UPDATED,{levels:o})},i.onLevelsUpdated=function(t,r){var s=r.levels;this._levels=s},i.checkMaxAutoUpdated=function(){var t=this.hls,r=t.autoLevelCapping,s=t.maxAutoLevel,o=t.maxHdcpLevel;this._maxAutoLevel!==s&&(this._maxAutoLevel=s,this.hls.trigger(x.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:r,levels:this.levels,maxAutoLevel:s,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:o}))},he(n,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var r=this._levels;if(r.length!==0){if(t<0||t>=r.length){var s=new Error("invalid level idx"),o=t<0;if(this.hls.trigger(x.ERROR,{type:V.OTHER_ERROR,details:_.LEVEL_SWITCH_ERROR,level:t,fatal:o,error:s,reason:s.message}),o)return;t=Math.min(t,r.length-1)}var l=this.currentLevelIndex,u=this.currentLevel,d=u?u.attrs["PATHWAY-ID"]:void 0,f=r[t],h=f.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=f,!(l===t&&f.details&&u&&d===h)){this.log("Switching to level "+t+" ("+(f.height?f.height+"p ":"")+(f.videoRange?f.videoRange+" ":"")+(f.codecSet?f.codecSet+" ":"")+"@"+f.bitrate+")"+(h?" with Pathway "+h:"")+" from level "+l+(d?" with Pathway "+d:""));var c={level:t,attrs:f.attrs,details:f.details,bitrate:f.bitrate,averageBitrate:f.averageBitrate,maxBitrate:f.maxBitrate,realBitrate:f.realBitrate,width:f.width,height:f.height,codecSet:f.codecSet,audioCodec:f.audioCodec,videoCodec:f.videoCodec,audioGroups:f.audioGroups,subtitleGroups:f.subtitleGroups,loaded:f.loaded,loadError:f.loadError,fragmentError:f.fragmentError,name:f.name,id:f.id,uri:f.uri,url:f.url,urlId:0,audioGroupIds:f.audioGroupIds,textGroupIds:f.textGroupIds};this.hls.trigger(x.LEVEL_SWITCHING,c);var v=f.details;if(!v||v.live){var m=this.switchParams(f.uri,u?.details,v);this.loadPlaylist(m)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var t=this.hls.config.startLevel;return t!==void 0?t:this.hls.firstAutoLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}}]),n}(ua);function ii(a){var n={};a.forEach(function(i){var e=i.groupId||"";i.id=n[e]=n[e]||0,n[e]++})}var me={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Ga=function(){function a(i){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=i,this._registerListeners()}var n=a.prototype;return n._registerListeners=function(){var e=this.hls;e.on(x.BUFFER_APPENDED,this.onBufferAppended,this),e.on(x.FRAG_BUFFERED,this.onFragBuffered,this),e.on(x.FRAG_LOADED,this.onFragLoaded,this)},n._unregisterListeners=function(){var e=this.hls;e.off(x.BUFFER_APPENDED,this.onBufferAppended,this),e.off(x.FRAG_BUFFERED,this.onFragBuffered,this),e.off(x.FRAG_LOADED,this.onFragLoaded,this)},n.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},n.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var s=r.length;s--;){var o=r[s];if(!o)break;var l=o.end;if(o.start<=e&&l!==null&&e<=l)return o}return this.getBufferedFrag(e,t)},n.getBufferedFrag=function(e,t){for(var r=this.fragments,s=Object.keys(r),o=s.length;o--;){var l=r[s[o]];if(l?.body.type===t&&l.buffered){var u=l.body;if(u.start<=e&&e<=u.end)return u}}return null},n.detectEvictedFragments=function(e,t,r,s){var o=this;this.timeRanges&&(this.timeRanges[e]=t);var l=s?.fragment.sn||-1;Object.keys(this.fragments).forEach(function(u){var d=o.fragments[u];if(d&&!(l>=d.body.sn)){if(!d.buffered&&!d.loaded){d.body.type===r&&o.removeFragment(d.body);return}var f=d.range[e];f&&f.time.some(function(h){var c=!o.isTimeBuffered(h.startPTS,h.endPTS,t);return c&&o.removeFragment(d.body),c})}})},n.detectPartialFragments=function(e){var t=this,r=this.timeRanges,s=e.frag,o=e.part;if(!(!r||s.sn==="initSegment")){var l=He(s),u=this.fragments[l];if(!(!u||u.buffered&&s.gap)){var d=!s.relurl;if(Object.keys(r).forEach(function(h){var c=s.elementaryStreams[h];if(c){var v=r[h],m=d||c.partial===!0;u.range[h]=t.getBufferedTimes(s,o,m,v)}}),u.loaded=null,Object.keys(u.range).length){u.buffered=!0;var f=u.body.endList=s.endList||u.body.endList;f&&(this.endListFragments[u.body.type]=u),ut(u)||this.removeParts(s.sn-1,s.type)}else this.removeFragment(u.body)}}},n.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(function(s){return s.fragment.sn>=e}))},n.fragBuffered=function(e,t){var r=He(e),s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)},n.getBufferedTimes=function(e,t,r,s){for(var o={time:[],partial:r},l=e.start,u=e.end,d=e.minEndPTS||u,f=e.maxStartPTS||l,h=0;h<s.length;h++){var c=s.start(h)-this.bufferPadding,v=s.end(h)+this.bufferPadding;if(f>=c&&d<=v){o.time.push({startPTS:Math.max(l,s.start(h)),endPTS:Math.min(u,s.end(h))});break}else if(l<v&&u>c){var m=Math.max(l,s.start(h)),g=Math.min(u,s.end(h));g>m&&(o.partial=!0,o.time.push({startPTS:m,endPTS:g}))}else if(u<=c)break}return o},n.getPartialFragment=function(e){var t=null,r,s,o,l=0,u=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(f){var h=d[f];h&&ut(h)&&(s=h.body.start-u,o=h.body.end+u,e>=s&&e<=o&&(r=Math.min(e-s,o-e),l<=r&&(t=h.body,l=r)))}),t},n.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||ut(t))},n.getState=function(e){var t=He(e),r=this.fragments[t];return r?r.buffered?ut(r)?me.PARTIAL:me.OK:me.APPENDING:me.NOT_LOADED},n.isTimeBuffered=function(e,t,r){for(var s,o,l=0;l<r.length;l++){if(s=r.start(l)-this.bufferPadding,o=r.end(l)+this.bufferPadding,e>=s&&t<=o)return!0;if(t<=s)return!1}return!1},n.onFragLoaded=function(e,t){var r=t.frag,s=t.part;if(!(r.sn==="initSegment"||r.bitrateTest)){var o=s?null:t,l=He(r);this.fragments[l]={body:r,appendedPTS:null,loaded:o,buffered:!1,range:Object.create(null)}}},n.onBufferAppended=function(e,t){var r=this,s=t.frag,o=t.part,l=t.timeRanges;if(s.sn!=="initSegment"){var u=s.type;if(o){var d=this.activePartLists[u];d||(this.activePartLists[u]=d=[]),d.push(o)}this.timeRanges=l,Object.keys(l).forEach(function(f){var h=l[f];r.detectEvictedFragments(f,h,u,o)})}},n.onFragBuffered=function(e,t){this.detectPartialFragments(t)},n.hasFragment=function(e){var t=He(e);return!!this.fragments[t]},n.hasParts=function(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)},n.removeFragmentsInRange=function(e,t,r,s,o){var l=this;s&&!this.hasGaps||Object.keys(this.fragments).forEach(function(u){var d=l.fragments[u];if(d){var f=d.body;f.type!==r||s&&!f.gap||f.start<t&&f.end>e&&(d.buffered||o)&&l.removeFragment(f)}})},n.removeFragment=function(e){var t=He(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var s=e.sn;this.activePartLists[e.type]=r.filter(function(o){return o.fragment.sn!==s})}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},n.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},a}();function ut(a){var n,i,e;return a.buffered&&(a.body.gap||((n=a.range.video)==null?void 0:n.partial)||((i=a.range.audio)==null?void 0:i.partial)||((e=a.range.audiovideo)==null?void 0:e.partial))}function He(a){return a.type+"_"+a.level+"_"+a.sn}var ni=Math.pow(2,17),Ha=function(){function a(i){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=i}var n=a.prototype;return n.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},n.abort=function(){this.loader&&this.loader.abort()},n.load=function(e,t){var r=this,s=e.url;if(!s)return Promise.reject(new De({type:V.NETWORK_ERROR,details:_.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(s?"part list":"url")),networkDetails:null}));this.abort();var o=this.config,l=o.fLoader,u=o.loader;return new Promise(function(d,f){if(r.loader&&r.loader.destroy(),e.gap)if(e.tagList.some(function(g){return g[0]==="GAP"})){f(si(e));return}else e.gap=!1;var h=r.loader=e.loader=l?new l(o):new u(o),c=ai(e),v=qr(o.fragLoadPolicy.default),m={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:ni};e.stats=h.stats,h.load(c,m,{onSuccess:function(p,y,E,S){r.resetLoader(e,h);var L=p.data;E.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(L.slice(0,16)),L=L.slice(16)),d({frag:e,part:null,payload:L,networkDetails:S})},onError:function(p,y,E,S){r.resetLoader(e,h),f(new De({type:V.NETWORK_ERROR,details:_.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:ge({url:s,data:void 0},p),error:new Error("HTTP Error "+p.code+" "+p.text),networkDetails:E,stats:S}))},onAbort:function(p,y,E){r.resetLoader(e,h),f(new De({type:V.NETWORK_ERROR,details:_.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:E,stats:p}))},onTimeout:function(p,y,E){r.resetLoader(e,h),f(new De({type:V.NETWORK_ERROR,details:_.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+m.timeout+"ms"),networkDetails:E,stats:p}))},onProgress:function(p,y,E,S){t&&t({frag:e,part:null,payload:E,networkDetails:S})}})})},n.loadPart=function(e,t,r){var s=this;this.abort();var o=this.config,l=o.fLoader,u=o.loader;return new Promise(function(d,f){if(s.loader&&s.loader.destroy(),e.gap||t.gap){f(si(e,t));return}var h=s.loader=e.loader=l?new l(o):new u(o),c=ai(e,t),v=qr(o.fragLoadPolicy.default),m={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:ni};t.stats=h.stats,h.load(c,m,{onSuccess:function(p,y,E,S){s.resetLoader(e,h),s.updateStatsFromPart(e,t);var L={frag:e,part:t,payload:p.data,networkDetails:S};r(L),d(L)},onError:function(p,y,E,S){s.resetLoader(e,h),f(new De({type:V.NETWORK_ERROR,details:_.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:ge({url:c.url,data:void 0},p),error:new Error("HTTP Error "+p.code+" "+p.text),networkDetails:E,stats:S}))},onAbort:function(p,y,E){e.stats.aborted=t.stats.aborted,s.resetLoader(e,h),f(new De({type:V.NETWORK_ERROR,details:_.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:E,stats:p}))},onTimeout:function(p,y,E){s.resetLoader(e,h),f(new De({type:V.NETWORK_ERROR,details:_.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+m.timeout+"ms"),networkDetails:E,stats:p}))}})})},n.updateStatsFromPart=function(e,t){var r=e.stats,s=t.stats,o=s.total;if(r.loaded+=s.loaded,o){var l=Math.round(e.duration/t.duration),u=Math.min(Math.round(r.loaded/o),l),d=l-u,f=d*Math.round(r.loaded/u);r.total=r.loaded+f}else r.total=Math.max(r.loaded,r.total);var h=r.loading,c=s.loading;h.start?h.first+=c.first-c.start:(h.start=c.start,h.first=c.first),h.end=c.end},n.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},a}();function ai(a,n){n===void 0&&(n=null);var i=n||a,e={frag:a,part:n,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},t=i.byteRangeStartOffset,r=i.byteRangeEndOffset;if(O(t)&&O(r)){var s,o=t,l=r;if(a.sn==="initSegment"&&((s=a.decryptdata)==null?void 0:s.method)==="AES-128"){var u=r-t;u%16&&(l=r+(16-u%16)),t!==0&&(e.resetIV=!0,o=t-16)}e.rangeStart=o,e.rangeEnd=l}return e}function si(a,n){var i=new Error("GAP "+(a.gap?"tag":"attribute")+" found"),e={type:V.MEDIA_ERROR,details:_.FRAG_GAP,fatal:!1,frag:a,error:i,networkDetails:null};return n&&(e.part=n),(n||a).stats.aborted=!0,new De(e)}var De=function(a){Re(n,a);function n(i){var e;return e=a.call(this,i.error.message)||this,e.data=void 0,e.data=i,e}return n}(ze(Error)),Va=function(){function a(i){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=i}var n=a.prototype;return n.abort=function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var s;if(e&&e!==((s=r.context)==null?void 0:s.frag.type))return;r.abort()}}},n.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},n.destroy=function(){this.detach();for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},n.createKeyLoadError=function(e,t,r,s,o){return t===void 0&&(t=_.KEY_LOAD_ERROR),new De({type:V.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:o,error:r,networkDetails:s})},n.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var s=e.sn,o=e.cc,l=function(){var f=t[u];if(o<=f.cc&&(s==="initSegment"||f.sn==="initSegment"||s<f.sn))return r.emeController.selectKeySystemFormat(f).then(function(h){f.setKeyFormat(h)}),1},u=0;u<t.length&&!l();u++);},n.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(function(r){return t.loadInternal(e,r)}):this.loadInternal(e)},n.loadInternal=function(e,t){var r,s;t&&e.setKeyFormat(t);var o=e.decryptdata;if(!o){var l=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,_.KEY_LOAD_ERROR,l))}var u=o.uri;if(!u)return Promise.reject(this.createKeyLoadError(e,_.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+u+'"')));var d=this.keyUriToKeyInfo[u];if((r=d)!=null&&r.decryptdata.key)return o.key=d.decryptdata.key,Promise.resolve({frag:e,keyInfo:d});if((s=d)!=null&&s.keyLoadPromise){var f;switch((f=d.mediaKeySessionContext)==null?void 0:f.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return d.keyLoadPromise.then(function(h){return o.key=h.keyInfo.decryptdata.key,{frag:e,keyInfo:d}})}}switch(d=this.keyUriToKeyInfo[u]={decryptdata:o,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},o.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return o.keyFormat==="identity"?this.loadKeyHTTP(d,e):this.loadKeyEME(d,e);case"AES-128":return this.loadKeyHTTP(d,e);default:return Promise.reject(this.createKeyLoadError(e,_.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+o.method+'"')))}},n.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(function(o){return e.mediaKeySessionContext=o,r})).catch(function(o){throw e.keyLoadPromise=null,o})}return Promise.resolve(r)},n.loadKeyHTTP=function(e,t){var r=this,s=this.config,o=s.loader,l=new o(s);return t.keyLoader=e.loader=l,e.keyLoadPromise=new Promise(function(u,d){var f={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},h=s.keyLoadPolicy.default,c={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:function(g,p,y,E){var S=y.frag,L=y.keyInfo,D=y.url;if(!S.decryptdata||L!==r.keyUriToKeyInfo[D])return d(r.createKeyLoadError(S,_.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),E));L.decryptdata.key=S.decryptdata.key=new Uint8Array(g.data),S.keyLoader=null,L.loader=null,u({frag:S,keyInfo:L})},onError:function(g,p,y,E){r.resetLoader(p),d(r.createKeyLoadError(t,_.KEY_LOAD_ERROR,new Error("HTTP Error "+g.code+" loading key "+g.text),y,ge({url:f.url,data:void 0},g)))},onTimeout:function(g,p,y){r.resetLoader(p),d(r.createKeyLoadError(t,_.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),y))},onAbort:function(g,p,y){r.resetLoader(p),d(r.createKeyLoadError(t,_.INTERNAL_ABORTED,new Error("key loading aborted"),y))}};l.load(f,c,v)})},n.resetLoader=function(e){var t=e.frag,r=e.keyInfo,s=e.url,o=r.loader;t.keyLoader===o&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],o&&o.destroy()},a}(),Ka=function(){function a(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var n=a.prototype;return n.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},n.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},n.onHandlerDestroyed=function(){},n.hasInterval=function(){return!!this._tickInterval},n.hasNextTick=function(){return!!this._tickTimer},n.setInterval=function(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},n.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},n.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},n.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},n.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},n.doTick=function(){},a}(),oi=function(n,i,e,t,r,s){t===void 0&&(t=0),r===void 0&&(r=-1),s===void 0&&(s=!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=ft(),this.buffering={audio:ft(),video:ft(),audiovideo:ft()},this.level=n,this.sn=i,this.id=e,this.size=t,this.part=r,this.partial=s};function ft(){return{start:0,executeStart:0,executeEnd:0,end:0}}function dt(a,n){for(var i=0,e=a.length;i<e;i++){var t;if(((t=a[i])==null?void 0:t.cc)===n)return a[i]}return null}function Wa(a,n,i){return!!(n&&(i.endCC>i.startCC||a&&a.cc<i.startCC))}function Ya(a,n){var i=a.fragments,e=n.fragments;if(!e.length||!i.length){A.log("No fragments to align");return}var t=dt(i,e[0].cc);if(!t||t&&!t.startPTS){A.log("No frag in previous level to align on");return}return t}function li(a,n){if(a){var i=a.start+n;a.start=a.startPTS=i,a.endPTS=i+a.duration}}function ui(a,n){for(var i=n.fragments,e=0,t=i.length;e<t;e++)li(i[e],a);n.fragmentHint&&li(n.fragmentHint,a),n.alignedSliding=!0}function qa(a,n,i){n&&(ja(a,i,n),!i.alignedSliding&&n&&Xa(i,n),!i.alignedSliding&&n&&!i.skippedSegments&&Hr(n,i))}function ja(a,n,i){if(Wa(a,i,n)){var e=Ya(i,n);e&&O(e.start)&&(A.log("Adjusting PTS using last level due to CC increase within current level "+n.url),ui(e.start,n))}}function Xa(a,n){if(!(!a.hasProgramDateTime||!n.hasProgramDateTime)){var i=a.fragments,e=n.fragments;if(!(!i.length||!e.length)){var t,r,s=Math.min(n.endCC,a.endCC);n.startCC<s&&a.startCC<s&&(t=dt(e,s),r=dt(i,s)),(!t||!r)&&(t=e[Math.floor(e.length/2)],r=dt(i,t.cc)||i[Math.floor(i.length/2)]);var o=t.programDateTime,l=r.programDateTime;if(!(!o||!l)){var u=(l-o)/1e3-(r.start-t.start);ui(u,a)}}}}var za=function(){function a(i,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=i,this.aesIV=e}var n=a.prototype;return n.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},a}(),$a=function(){function a(i,e){this.subtle=void 0,this.key=void 0,this.subtle=i,this.key=e}var n=a.prototype;return n.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},a}();function Qa(a){var n=a.byteLength,i=n&&new DataView(a.buffer).getUint8(n-1);return i?Me(a,0,n-i):a}var Za=function(){function a(){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 n=a.prototype;return n.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),s=0;s<4;s++)r[s]=t.getUint32(s*4);return r},n.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],o=r[1],l=r[2],u=r[3],d=this.invSubMix,f=d[0],h=d[1],c=d[2],v=d[3],m=new Uint32Array(256),g=0,p=0,y=0;for(y=0;y<256;y++)y<128?m[y]=y<<1:m[y]=y<<1^283;for(y=0;y<256;y++){var E=p^p<<1^p<<2^p<<3^p<<4;E=E>>>8^E&255^99,e[g]=E,t[E]=g;var S=m[g],L=m[S],D=m[L],R=m[E]*257^E*16843008;s[g]=R<<24|R>>>8,o[g]=R<<16|R>>>16,l[g]=R<<8|R>>>24,u[g]=R,R=D*16843009^L*65537^S*257^g*16843008,f[E]=R<<24|R>>>8,h[E]=R<<16|R>>>16,c[E]=R<<8|R>>>24,v[E]=R,g?(g=S^m[m[m[D^S]]],p^=m[m[p]]):g=p=1}},n.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,s=0;s<t.length&&r;)r=t[s]===this.key[s],s++;if(!r){this.key=t;var o=this.keySize=t.length;if(o!==4&&o!==6&&o!==8)throw new Error("Invalid aes key size="+o);var l=this.ksRows=(o+6+1)*4,u,d,f=this.keySchedule=new Uint32Array(l),h=this.invKeySchedule=new Uint32Array(l),c=this.sBox,v=this.rcon,m=this.invSubMix,g=m[0],p=m[1],y=m[2],E=m[3],S,L;for(u=0;u<l;u++){if(u<o){S=f[u]=t[u];continue}L=S,u%o===0?(L=L<<8|L>>>24,L=c[L>>>24]<<24|c[L>>>16&255]<<16|c[L>>>8&255]<<8|c[L&255],L^=v[u/o|0]<<24):o>6&&u%o===4&&(L=c[L>>>24]<<24|c[L>>>16&255]<<16|c[L>>>8&255]<<8|c[L&255]),f[u]=S=(f[u-o]^L)>>>0}for(d=0;d<l;d++)u=l-d,d&3?L=f[u]:L=f[u-4],d<4||u<=4?h[d]=L:h[d]=g[c[L>>>24]]^p[c[L>>>16&255]]^y[c[L>>>8&255]]^E[c[L&255]],h[d]=h[d]>>>0}},n.networkToHostOrderSwap=function(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24},n.decrypt=function(e,t,r){for(var s=this.keySize+6,o=this.invKeySchedule,l=this.invSBox,u=this.invSubMix,d=u[0],f=u[1],h=u[2],c=u[3],v=this.uint8ArrayToUint32Array_(r),m=v[0],g=v[1],p=v[2],y=v[3],E=new Int32Array(e),S=new Int32Array(E.length),L,D,R,T,b,I,P,C,w,M,F,H,U,W,K=this.networkToHostOrderSwap;t<E.length;){for(w=K(E[t]),M=K(E[t+1]),F=K(E[t+2]),H=K(E[t+3]),b=w^o[0],I=H^o[1],P=F^o[2],C=M^o[3],U=4,W=1;W<s;W++)L=d[b>>>24]^f[I>>16&255]^h[P>>8&255]^c[C&255]^o[U],D=d[I>>>24]^f[P>>16&255]^h[C>>8&255]^c[b&255]^o[U+1],R=d[P>>>24]^f[C>>16&255]^h[b>>8&255]^c[I&255]^o[U+2],T=d[C>>>24]^f[b>>16&255]^h[I>>8&255]^c[P&255]^o[U+3],b=L,I=D,P=R,C=T,U=U+4;L=l[b>>>24]<<24^l[I>>16&255]<<16^l[P>>8&255]<<8^l[C&255]^o[U],D=l[I>>>24]<<24^l[P>>16&255]<<16^l[C>>8&255]<<8^l[b&255]^o[U+1],R=l[P>>>24]<<24^l[C>>16&255]<<16^l[b>>8&255]<<8^l[I&255]^o[U+2],T=l[C>>>24]<<24^l[b>>16&255]<<16^l[I>>8&255]<<8^l[P&255]^o[U+3],S[t]=K(L^m),S[t+1]=K(T^g),S[t+2]=K(R^p),S[t+3]=K(D^y),m=w,g=M,p=F,y=H,t=t+4}return S.buffer},a}(),Ja=16,Ut=function(){function a(i,e){var t=e===void 0?{}:e,r=t.removePKCS7Padding,s=r===void 0?!0:r;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=i.enableSoftwareAES,this.removePKCS7Padding=s,s)try{var o=self.crypto;o&&(this.subtle=o.subtle||o.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var n=a.prototype;return n.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},n.isSync=function(){return this.useSoftware},n.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?Qa(r):r},n.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},n.decrypt=function(e,t,r){var s=this;return this.useSoftware?new Promise(function(o,l){s.softwareDecrypt(new Uint8Array(e),t,r);var u=s.flush();u?o(u.buffer):l(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)},n.softwareDecrypt=function(e,t,r){var s=this.currentIV,o=this.currentResult,l=this.remainderData;this.logOnce("JS AES decrypt"),l&&(e=xe(l,e),this.remainderData=null);var u=this.getValidChunk(e);if(!u.length)return null;s&&(r=s);var d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new Za),d.expandKey(t);var f=o;return this.currentResult=d.decrypt(u.buffer,0,r),this.currentIV=Me(u,-16).buffer,f||null},n.webCryptoDecrypt=function(e,t,r){var s=this,o=this.subtle;return(this.key!==t||!this.fastAesKey)&&(this.key=t,this.fastAesKey=new $a(o,t)),this.fastAesKey.expandKey().then(function(l){if(!o)return Promise.reject(new Error("web crypto not initialized"));s.logOnce("WebCrypto AES decrypt");var u=new za(o,new Uint8Array(r));return u.decrypt(e.buffer,l)}).catch(function(l){return A.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+l.name+": "+l.message),s.onWebCryptoError(e,t,r)})},n.onWebCryptoError=function(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);var s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},n.getValidChunk=function(e){var t=e,r=e.length-e.length%Ja;return r!==e.length&&(t=Me(e,0,r),this.remainderData=Me(e,r)),t},n.logOnce=function(e){this.logEnabled&&(A.log("[decrypter]: "+e),this.logEnabled=!1)},a}(),es={toString:function(n){for(var i="",e=n.length,t=0;t<e;t++)i+="["+n.start(t).toFixed(3)+"-"+n.end(t).toFixed(3)+"]";return i}},k={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},ts=function(a){Re(n,a);function n(e,t,r,s,o){var l;return l=a.call(this)||this,l.hls=void 0,l.fragPrevious=null,l.fragCurrent=null,l.fragmentTracker=void 0,l.transmuxer=null,l._state=k.STOPPED,l.playlistType=void 0,l.media=null,l.mediaBuffer=null,l.config=void 0,l.bitrateTest=!1,l.lastCurrentTime=0,l.nextLoadPosition=0,l.startPosition=0,l.startTimeOffset=null,l.loadedmetadata=!1,l.retryDate=0,l.levels=null,l.fragmentLoader=void 0,l.keyLoader=void 0,l.levelLastLoaded=null,l.startFragRequested=!1,l.decrypter=void 0,l.initPTS=[],l.onvseeking=null,l.onvended=null,l.logPrefix="",l.log=void 0,l.warn=void 0,l.playlistType=o,l.logPrefix=s,l.log=A.log.bind(A,s+":"),l.warn=A.warn.bind(A,s+":"),l.hls=e,l.fragmentLoader=new Ha(e.config),l.keyLoader=r,l.fragmentTracker=t,l.config=e.config,l.decrypter=new Ut(e.config),e.on(x.MANIFEST_LOADED,l.onManifestLoaded,qi(l)),l}var i=n.prototype;return i.doTick=function(){this.onTickEnd()},i.onTickEnd=function(){},i.startLoad=function(t){},i.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=k.STOPPED},i._streamEnded=function(t,r){if(r.live||t.nextStart||!t.end||!this.media)return!1;var s=r.partList;if(s!=null&&s.length){var o=s[s.length-1],l=ae.isBuffered(this.media,o.start+o.duration/2);return l}var u=r.fragments[r.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(u)},i.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null){var t;return(t=this.levelLastLoaded)==null?void 0:t.details}},i.onMediaAttached=function(t,r){var s=this.media=this.mediaBuffer=r.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),s.addEventListener("seeking",this.onvseeking),s.addEventListener("ended",this.onvended);var o=this.config;this.levels&&o.autoStartLoad&&this.state===k.STOPPED&&this.startLoad(o.startPosition)},i.onMediaDetaching=function(){var t=this.media;t!=null&&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()},i.onMediaSeeking=function(){var t=this.config,r=this.fragCurrent,s=this.media,o=this.mediaBuffer,l=this.state,u=s?s.currentTime:0,d=ae.bufferInfo(o||s,u,t.maxBufferHole);if(this.log("media seeking to "+(O(u)?u.toFixed(3):u)+", state: "+l),this.state===k.ENDED)this.resetLoadingState();else if(r){var f=t.maxFragLookUpTolerance,h=r.start-f,c=r.start+r.duration+f;if(!d.len||c<d.start||h>d.end){var v=u>c;(u<h||v)&&(v&&r.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),r.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}s&&(this.fragmentTracker.removeFragmentsInRange(u,1/0,this.playlistType,!0),this.lastCurrentTime=u),!this.loadedmetadata&&!d.len&&(this.nextLoadPosition=this.startPosition=u),this.tickImmediate()},i.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},i.onManifestLoaded=function(t,r){this.startTimeOffset=r.startTimeOffset,this.initPTS=[]},i.onHandlerDestroying=function(){this.hls.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),a.prototype.onHandlerDestroying.call(this),this.hls=null},i.onHandlerDestroyed=function(){this.state=k.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,a.prototype.onHandlerDestroyed.call(this)},i.loadFragment=function(t,r,s){this._loadFragForPlayback(t,r,s)},i._loadFragForPlayback=function(t,r,s){var o=this,l=function(d){if(o.fragContextChanged(t)){o.warn("Fragment "+t.sn+(d.part?" p: "+d.part.index:"")+" of level "+t.level+" was dropped during download."),o.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,o._handleFragmentLoadProgress(d)};this._doFragLoad(t,r,s,l).then(function(u){if(u){var d=o.state;if(o.fragContextChanged(t)){(d===k.FRAG_LOADING||!o.fragCurrent&&d===k.PARSING)&&(o.fragmentTracker.removeFragment(t),o.state=k.IDLE);return}"payload"in u&&(o.log("Loaded fragment "+t.sn+" of level "+t.level),o.hls.trigger(x.FRAG_LOADED,u)),o._handleFragmentLoadComplete(u)}}).catch(function(u){o.state===k.STOPPED||o.state===k.ERROR||(o.warn(u),o.resetFragmentLoading(t))})},i.clearTrackerIfNeeded=function(t){var r,s=this.fragmentTracker,o=s.getState(t);if(o===me.APPENDING){var l=t.type,u=this.getFwdBufferInfo(this.mediaBuffer,l),d=Math.max(t.duration,u?u.len:this.config.maxBufferLength);this.reduceMaxBufferLength(d)&&s.removeFragment(t)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0?s.removeAllFragments():s.hasParts(t.type)&&(s.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),s.getState(t)===me.PARTIAL&&s.removeFragment(t))},i.checkLiveUpdate=function(t){if(t.updated&&!t.live){var r=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:r,part:null,stats:r.stats,id:r.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)},i.flushMainBuffer=function(t,r,s){if(s===void 0&&(s=null),!!(t-r)){var o={startOffset:t,endOffset:r,type:s};this.hls.trigger(x.BUFFER_FLUSHING,o)}},i._loadInitSegment=function(t,r){var s=this;this._doFragLoad(t,r).then(function(o){if(!o||s.fragContextChanged(t)||!s.levels)throw new Error("init load aborted");return o}).then(function(o){var l=s.hls,u=o.payload,d=t.decryptdata;if(u&&u.byteLength>0&&d!=null&&d.key&&d.iv&&d.method==="AES-128"){var f=self.performance.now();return s.decrypter.decrypt(new Uint8Array(u),d.key.buffer,d.iv.buffer).catch(function(h){throw l.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:_.FRAG_DECRYPT_ERROR,fatal:!1,error:h,reason:h.message,frag:t}),h}).then(function(h){var c=self.performance.now();return l.trigger(x.FRAG_DECRYPTED,{frag:t,payload:h,stats:{tstart:f,tdecrypt:c}}),o.payload=h,s.completeInitSegmentLoad(o)})}return s.completeInitSegmentLoad(o)}).catch(function(o){s.state===k.STOPPED||s.state===k.ERROR||(s.warn(o),s.resetFragmentLoading(t))})},i.completeInitSegmentLoad=function(t){var r=this.levels;if(!r)throw new Error("init load aborted, missing levels");var s=t.frag.stats;this.state=k.IDLE,t.frag.data=new Uint8Array(t.payload),s.parsing.start=s.buffering.start=self.performance.now(),s.parsing.end=s.buffering.end=self.performance.now(),this.tick()},i.fragContextChanged=function(t){var r=this.fragCurrent;return!t||!r||t.sn!==r.sn||t.level!==r.level},i.fragBufferedComplete=function(t,r){var s,o,l,u,d=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+t.type+" sn: "+t.sn+(r?" part: "+r.index:"")+" of "+(this.playlistType===j.MAIN?"level":"track")+" "+t.level+" (frag:["+((s=t.startPTS)!=null?s:NaN).toFixed(3)+"-"+((o=t.endPTS)!=null?o:NaN).toFixed(3)+"] > buffer:"+(d?es.toString(ae.getBuffered(d)):"(detached)")+")"),t.sn!=="initSegment"){var f;if(t.type!==j.SUBTITLE){var h=t.elementaryStreams;if(!Object.keys(h).some(function(v){return!!h[v]})){this.state=k.IDLE;return}}var c=(f=this.levels)==null?void 0:f[t.level];c!=null&&c.fragmentError&&(this.log("Resetting level fragment error count of "+c.fragmentError+" on frag buffered"),c.fragmentError=0)}this.state=k.IDLE,d&&(!this.loadedmetadata&&t.type==j.MAIN&&d.buffered.length&&((l=this.fragCurrent)==null?void 0:l.sn)===((u=this.fragPrevious)==null?void 0:u.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},i.seekToStartPos=function(){},i._handleFragmentLoadComplete=function(t){var r=this.transmuxer;if(r){var s=t.frag,o=t.part,l=t.partsLoaded,u=!l||l.length===0||l.some(function(f){return!f}),d=new oi(s.level,s.sn,s.stats.chunkCount+1,0,o?o.index:-1,!u);r.flush(d)}},i._handleFragmentLoadProgress=function(t){},i._doFragLoad=function(t,r,s,o){var l,u=this;s===void 0&&(s=null);var d=r?.details;if(!this.levels||!d)throw new Error("frag load aborted, missing level"+(d?"":" detail")+"s");var f=null;if(t.encrypted&&!((l=t.decryptdata)!=null&&l.key)?(this.log("Loading key for "+t.sn+" of ["+d.startSN+"-"+d.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+t.level),this.state=k.KEY_LOADING,this.fragCurrent=t,f=this.keyLoader.load(t).then(function(y){if(!u.fragContextChanged(y.frag))return u.hls.trigger(x.KEY_LOADED,y),u.state===k.KEY_LOADING&&(u.state=k.IDLE),y}),this.hls.trigger(x.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(f=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!t.encrypted&&d.encryptedFragments.length&&this.keyLoader.loadClear(t,d.encryptedFragments),s=Math.max(t.start,s||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){var h=d.partList;if(h&&o){s>t.end&&d.fragmentHint&&(t=d.fragmentHint);var c=this.getNextPart(h,t,s);if(c>-1){var v=h[c];this.log("Loading part sn: "+t.sn+" p: "+v.index+" cc: "+t.cc+" of playlist ["+d.startSN+"-"+d.endSN+"] parts [0-"+c+"-"+(h.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(s.toFixed(3))),this.nextLoadPosition=v.start+v.duration,this.state=k.FRAG_LOADING;var m;return f?m=f.then(function(y){return!y||u.fragContextChanged(y.frag)?null:u.doFragPartsLoad(t,v,r,o)}).catch(function(y){return u.handleFragLoadError(y)}):m=this.doFragPartsLoad(t,v,r,o).catch(function(y){return u.handleFragLoadError(y)}),this.hls.trigger(x.FRAG_LOADING,{frag:t,part:v,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):m}else if(!t.url||this.loadedEndOfParts(h,s))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(d?"of ["+d.startSN+"-"+d.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(s.toFixed(3))),O(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=k.FRAG_LOADING;var g=this.config.progressive,p;return g&&f?p=f.then(function(y){return!y||u.fragContextChanged(y?.frag)?null:u.fragmentLoader.load(t,o)}).catch(function(y){return u.handleFragLoadError(y)}):p=Promise.all([this.fragmentLoader.load(t,g?o:void 0),f]).then(function(y){var E=y[0];return!g&&E&&o&&o(E),E}).catch(function(y){return u.handleFragLoadError(y)}),this.hls.trigger(x.FRAG_LOADING,{frag:t,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):p},i.doFragPartsLoad=function(t,r,s,o){var l=this;return new Promise(function(u,d){var f,h=[],c=(f=s.details)==null?void 0:f.partList,v=function m(g){l.fragmentLoader.loadPart(t,g,o).then(function(p){h[g.index]=p;var y=p.part;l.hls.trigger(x.FRAG_LOADED,p);var E=Vr(s,t.sn,g.index+1)||Kr(c,t.sn,g.index+1);if(E)m(E);else return u({frag:t,part:y,partsLoaded:h})}).catch(d)};v(r)})},i.handleFragLoadError=function(t){if("data"in t){var r=t.data;t.data&&r.details===_.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(x.ERROR,r)}else this.hls.trigger(x.ERROR,{type:V.OTHER_ERROR,details:_.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},i._handleTransmuxerFlush=function(t){var r=this.getCurrentContext(t);if(!r||this.state!==k.PARSING){!this.fragCurrent&&this.state!==k.STOPPED&&this.state!==k.ERROR&&(this.state=k.IDLE);return}var s=r.frag,o=r.part,l=r.level,u=self.performance.now();s.stats.parsing.end=u,o&&(o.stats.parsing.end=u),this.updateLevelTiming(s,o,l,t.partial)},i.getCurrentContext=function(t){var r=this.levels,s=this.fragCurrent,o=t.level,l=t.sn,u=t.part;if(!(r!=null&&r[o]))return this.warn("Levels object was unset while buffering fragment "+l+" of level "+o+". The current chunk will not be buffered."),null;var d=r[o],f=u>-1?Vr(d,l,u):null,h=f?f.fragment:ia(d,l,s);return h?(s&&s!==h&&(h.stats=s.stats),{frag:h,part:f,level:d}):null},i.bufferFragmentData=function(t,r,s,o,l){var u;if(!(!t||this.state!==k.PARSING)){var d=t.data1,f=t.data2,h=d;if(d&&f&&(h=xe(d,f)),!!((u=h)!=null&&u.length)){var c={type:t.type,frag:r,part:s,chunkMeta:o,parent:r.type,data:h};if(this.hls.trigger(x.BUFFER_APPENDING,c),t.dropped&&t.independent&&!s){if(l)return;this.flushBufferGap(r)}}}},i.flushBufferGap=function(t){var r=this.media;if(r){if(!ae.isBuffered(r,r.currentTime)){this.flushMainBuffer(0,t.start);return}var s=r.currentTime,o=ae.bufferInfo(r,s,0),l=t.duration,u=Math.min(this.config.maxFragLookUpTolerance*2,l*.25),d=Math.max(Math.min(t.start-u,o.end-u),s+u);t.start-d>u&&this.flushMainBuffer(d,t.start)}},i.getFwdBufferInfo=function(t,r){var s=this.getLoadPosition();return O(s)?this.getFwdBufferInfoAtPos(t,s,r):null},i.getFwdBufferInfoAtPos=function(t,r,s){var o=this.config.maxBufferHole,l=ae.bufferInfo(t,r,o);if(l.len===0&&l.nextStart!==void 0){var u=this.fragmentTracker.getBufferedFrag(r,s);if(u&&l.nextStart<u.end)return ae.bufferInfo(t,r,Math.max(l.nextStart,o))}return l},i.getMaxBufferLength=function(t){var r=this.config,s;return t?s=Math.max(8*r.maxBufferSize/t,r.maxBufferLength):s=r.maxBufferLength,Math.min(s,r.maxMaxBufferLength)},i.reduceMaxBufferLength=function(t){var r=this.config,s=t||r.maxBufferLength;return r.maxMaxBufferLength>=s?(r.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+r.maxMaxBufferLength+"s"),!0):!1},i.getAppendedFrag=function(t,r){var s=this.fragmentTracker.getAppendedFrag(t,j.MAIN);return s&&"fragment"in s?s.fragment:s},i.getNextFragment=function(t,r){var s=r.fragments,o=s.length;if(!o)return null;var l=this.config,u=s[0].start,d;if(r.live){var f=l.initialLiveManifestSize;if(o<f)return this.warn("Not enough fragments to start playback (have: "+o+", need: "+f+")"),null;(!r.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||t<u)&&(d=this.getInitialLiveFragment(r,s),this.startPosition=this.nextLoadPosition=d?this.hls.liveSyncPosition||d.start:t)}else t<=u&&(d=s[0]);if(!d){var h=l.lowLatencyMode?r.partEnd:r.fragmentEnd;d=this.getFragmentAtPosition(t,h,r)}return this.mapToInitFragWhenRequired(d)},i.isLoopLoading=function(t,r){var s=this.fragmentTracker.getState(t);return(s===me.OK||s===me.PARTIAL&&!!t.gap)&&this.nextLoadPosition>r},i.getNextFragmentLoopLoading=function(t,r,s,o,l){var u=t.gap,d=this.getNextFragment(this.nextLoadPosition,r);if(d===null)return d;if(t=d,u&&t&&!t.gap&&s.nextStart){var f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,s.nextStart,o);if(f!==null&&s.len+f.len>=l)return this.log('buffer full after gaps in "'+o+'" playlist starting at sn: '+t.sn),null}return t},i.mapToInitFragWhenRequired=function(t){return t!=null&&t.initSegment&&!(t!=null&&t.initSegment.data)&&!this.bitrateTest?t.initSegment:t},i.getNextPart=function(t,r,s){for(var o=-1,l=!1,u=!0,d=0,f=t.length;d<f;d++){var h=t[d];if(u=u&&!h.independent,o>-1&&s<h.start)break;var c=h.loaded;c?o=-1:(l||h.independent||u)&&h.fragment===r&&(o=d),l=c}return o},i.loadedEndOfParts=function(t,r){var s=t[t.length-1];return s&&r>s.start&&s.loaded},i.getInitialLiveFragment=function(t,r){var s=this.fragPrevious,o=null;if(s){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+s.programDateTime),o=aa(r,s.endProgramDateTime,this.config.maxFragLookUpTolerance)),!o){var l=s.sn+1;if(l>=t.startSN&&l<=t.endSN){var u=r[l-t.startSN];s.cc===u.cc&&(o=u,this.log("Live playlist, switching playlist, load frag with next SN: "+o.sn))}o||(o=oa(r,s.cc),o&&this.log("Live playlist, switching playlist, load frag with same CC: "+o.sn))}}else{var d=this.hls.liveSyncPosition;d!==null&&(o=this.getFragmentAtPosition(d,this.bitrateTest?t.fragmentEnd:t.edge,t))}return o},i.getFragmentAtPosition=function(t,r,s){var o=this.config,l=this.fragPrevious,u=s.fragments,d=s.endSN,f=s.fragmentHint,h=o.maxFragLookUpTolerance,c=s.partList,v=!!(o.lowLatencyMode&&c!=null&&c.length&&f);v&&f&&!this.bitrateTest&&(u=u.concat(f),d=f.sn);var m;if(t<r){var g=t>r-h?0:h;m=Xr(l,u,t,g)}else m=u[u.length-1];if(m){var p=m.sn-s.startSN,y=this.fragmentTracker.getState(m);if((y===me.OK||y===me.PARTIAL&&m.gap)&&(l=m),l&&m.sn===l.sn&&(!v||c[0].fragment.sn>m.sn)){var E=l&&m.level===l.level;if(E){var S=u[p+1];m.sn<d&&this.fragmentTracker.getState(S)!==me.OK?m=S:m=null}}}return m},i.synchronizeToLiveEdge=function(t){var r=this.config,s=this.media;if(s){var o=this.hls.liveSyncPosition,l=s.currentTime,u=t.fragments[0].start,d=t.edge,f=l>=u-r.maxFragLookUpTolerance&&l<=d;if(o!==null&&s.duration>o&&(l<o||!f)){var h=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*t.targetduration;(!f&&s.readyState<4||l<d-h)&&(this.loadedmetadata||(this.nextLoadPosition=o),s.readyState&&(this.warn("Playback: "+l.toFixed(3)+" is located too far from the end of live sliding playlist: "+d+", reset currentTime to : "+o.toFixed(3)),s.currentTime=o))}}},i.alignPlaylists=function(t,r,s){var o=t.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;var l=t.fragments[0].start,u=!r,d=t.alignedSliding&&O(l);if(u||!d&&!l){var f=this.fragPrevious;qa(f,s,t);var h=t.fragments[0].start;return this.log("Live playlist sliding: "+h.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+t.startSN+" prev-sn: "+(f?f.sn:"na")+" fragments: "+o),h}return l},i.waitForCdnTuneIn=function(t){var r=3;return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*r)},i.setStartPosition=function(t,r){var s=this.startPosition;if(s<r&&(s=-1),s===-1||this.lastCurrentTime===-1){var o=this.startTimeOffset!==null,l=o?this.startTimeOffset:t.startTimeOffset;l!==null&&O(l)?(s=r+l,l<0&&(s+=t.totalduration),s=Math.min(Math.max(r,s),r+t.totalduration),this.log("Start time offset "+l+" found in "+(o?"multivariant":"media")+" playlist, adjust startPosition to "+s),this.startPosition=s):t.live?s=this.hls.liveSyncPosition||r:this.startPosition=s=0,this.lastCurrentTime=s}this.nextLoadPosition=s},i.getLoadPosition=function(){var t=this.media,r=0;return this.loadedmetadata&&t?r=t.currentTime:this.nextLoadPosition&&(r=this.nextLoadPosition),r},i.handleFragLoadAborted=function(t,r){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},i.resetFragmentLoading=function(t){(!this.fragCurrent||!this.fragContextChanged(t)&&this.state!==k.FRAG_LOADING_WAITING_RETRY)&&(this.state=k.IDLE)},i.onFragmentOrKeyLoadError=function(t,r){if(r.chunkMeta&&!r.frag){var s=this.getCurrentContext(r.chunkMeta);s&&(r.frag=s.frag)}var o=r.frag;if(!(!o||o.type!==t||!this.levels)){if(this.fragContextChanged(o)){var l;this.warn("Frag load error must match current frag to retry "+o.url+" > "+((l=this.fragCurrent)==null?void 0:l.url));return}var u=r.details===_.FRAG_GAP;u&&this.fragmentTracker.fragBuffered(o,!0);var d=r.errorAction,f=d||{},h=f.action,c=f.retryCount,v=c===void 0?0:c,m=f.retryConfig;if(d&&h===ue.RetryRequest&&m){this.resetStartWhenNotLoaded(this.levelLastLoaded);var g=Mt(m,v);this.warn("Fragment "+o.sn+" of "+t+" "+o.level+" errored with "+r.details+", retrying loading "+(v+1)+"/"+m.maxNumRetry+" in "+g+"ms"),d.resolved=!0,this.retryDate=self.performance.now()+g,this.state=k.FRAG_LOADING_WAITING_RETRY}else if(m&&d)if(this.resetFragmentErrors(t),v<m.maxNumRetry)!u&&h!==ue.RemoveAlternatePermanently&&(d.resolved=!0);else{A.warn(r.details+" reached or exceeded max retry ("+v+")");return}else d?.action===ue.SendAlternateToPenaltyBox?this.state=k.WAITING_LEVEL:this.state=k.ERROR;this.tickImmediate()}},i.reduceLengthAndFlushBuffer=function(t){if(this.state===k.PARSING||this.state===k.PARSED){var r=t.parent,s=this.getFwdBufferInfo(this.mediaBuffer,r),o=s&&s.len>.5;o&&this.reduceMaxBufferLength(s.len);var l=!o;return l&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+r+" buffer"),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),l}return!1},i.resetFragmentErrors=function(t){t===j.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==k.STOPPED&&(this.state=k.IDLE)},i.afterBufferFlushed=function(t,r,s){if(t){var o=ae.getBuffered(t);this.fragmentTracker.detectEvictedFragments(r,o,s),this.state===k.ENDED&&this.resetLoadingState()}},i.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=k.IDLE},i.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var r=t?t.details:null;r!=null&&r.live?(this.startPosition=-1,this.setStartPosition(r,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},i.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(this.levelLastLoaded),this.resetLoadingState()},i.removeUnbufferedFrags=function(t){t===void 0&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},i.updateLevelTiming=function(t,r,s,o){var l=this,u,d=s.details;if(!d){this.warn("level.details undefined");return}var f=Object.keys(t.elementaryStreams).reduce(function(c,v){var m=t.elementaryStreams[v];if(m){var g=m.endPTS-m.startPTS;if(g<=0)return l.warn("Could not parse fragment "+t.sn+" "+v+" duration reliably ("+g+")"),c||!1;var p=o?0:Gr(d,t,m.startPTS,m.endPTS,m.startDTS,m.endDTS);return l.hls.trigger(x.LEVEL_PTS_UPDATED,{details:d,level:s,drift:p,type:v,frag:t,start:m.startPTS,end:m.endPTS}),!0}return c},!1);if(!f&&((u=this.transmuxer)==null?void 0:u.error)===null){var h=new Error("Found no media in fragment "+t.sn+" of level "+t.level+" resetting transmuxer to fallback to playlist timing");if(s.fragmentError===0&&(s.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(h.message),this.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,fatal:!1,error:h,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+s.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=k.PARSED,this.hls.trigger(x.FRAG_PARSED,{frag:t,part:r})},i.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},i.recoverWorkerError=function(t){t.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},he(n,[{key:"state",get:function(){return this._state},set:function(t){var r=this._state;r!==t&&(this._state=t,this.log(r+"->"+t))}}]),n}(Ka);function fi(){return self.SourceBuffer||self.WebKitSourceBuffer}function di(){var a=Ne();if(!a)return!1;var n=fi();return!n||n.prototype&&typeof n.prototype.appendBuffer=="function"&&typeof n.prototype.remove=="function"}function rs(){if(!di())return!1;var a=Ne();return typeof a?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(n){return a.isTypeSupported(_t(n,"video"))})||["mp4a.40.2","fLaC"].some(function(n){return a.isTypeSupported(_t(n,"audio"))}))}function is(){var a,n=fi();return typeof(n==null||(a=n.prototype)==null?void 0:a.changeType)=="function"}function Ie(a,n){return a===void 0&&(a=""),n===void 0&&(n=9e4),{type:a,id:-1,pid:-1,inputTimeScale:n,sequenceNumber:-1,samples:[],dropped:0}}var hi=function(){function a(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var n=a.prototype;return n.resetInitSegment=function(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},n.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},n.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},n.canParse=function(e,t){return!1},n.appendFrame=function(e,t,r){},n.demux=function(e,t){this.cachedData&&(e=xe(this.cachedData,e),this.cachedData=null);var r=Qe(e,0),s=r?r.length:0,o,l=this._audioTrack,u=this._id3Track,d=r?dr(r):void 0,f=e.length;for((this.basePTS===null||this.frameIndex===0&&O(d))&&(this.basePTS=ns(d,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Te.audioId3,duration:Number.POSITIVE_INFINITY});s<f;){if(this.canParse(e,s)){var h=this.appendFrame(l,e,s);h?(this.frameIndex++,this.lastPTS=h.sample.pts,s+=h.length,o=s):s=f}else sn(e,s)?(r=Qe(e,s),u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Te.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,o=s):s++;if(s===f&&o!==f){var c=Me(e,o);this.cachedData?this.cachedData=xe(this.cachedData,c):this.cachedData=c}}return{audioTrack:l,videoTrack:Ie(),id3Track:u,textTrack:Ie()}},n.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},n.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Ie(),id3Track:this._id3Track,textTrack:Ie()}},n.destroy=function(){},a}(),ns=function(n,i,e){if(O(n))return n*90;var t=e?e.baseTime*9e4/e.timescale:0;return i*9e4+t};function as(a,n,i,e){var t,r,s,o,l=navigator.userAgent.toLowerCase(),u=e,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];t=((n[i+2]&192)>>>6)+1;var f=(n[i+2]&60)>>>2;if(f>d.length-1){var h=new Error("invalid ADTS sampling index:"+f);a.emit(x.ERROR,x.ERROR,{type:V.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message});return}return s=(n[i+2]&1)<<2,s|=(n[i+3]&192)>>>6,A.log("manifest codec:"+e+", ADTS type:"+t+", samplingIndex:"+f),/firefox/i.test(l)?f>=6?(t=5,o=new Array(4),r=f-3):(t=2,o=new Array(2),r=f):l.indexOf("android")!==-1?(t=2,o=new Array(2),r=f):(t=5,o=new Array(4),e&&(e.indexOf("mp4a.40.29")!==-1||e.indexOf("mp4a.40.5")!==-1)||!e&&f>=6?r=f-3:((e&&e.indexOf("mp4a.40.2")!==-1&&(f>=6&&s===1||/vivaldi/i.test(l))||!e&&s===1)&&(t=2,o=new Array(2)),r=f)),o[0]=t<<3,o[0]|=(f&14)>>1,o[1]|=(f&1)<<7,o[1]|=s<<3,t===5&&(o[1]|=(r&14)>>1,o[2]=(r&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:d[f],channelCount:s,codec:"mp4a.40."+t,manifestCodec:u}}function ci(a,n){return a[n]===255&&(a[n+1]&246)===240}function vi(a,n){return a[n+1]&1?7:9}function Gt(a,n){return(a[n+3]&3)<<11|a[n+4]<<3|(a[n+5]&224)>>>5}function ss(a,n){return n+5<a.length}function ht(a,n){return n+1<a.length&&ci(a,n)}function os(a,n){return ss(a,n)&&ci(a,n)&&Gt(a,n)<=a.length-n}function ls(a,n){if(ht(a,n)){var i=vi(a,n);if(n+i>=a.length)return!1;var e=Gt(a,n);if(e<=i)return!1;var t=n+e;return t===a.length||ht(a,t)}return!1}function gi(a,n,i,e,t){if(!a.samplerate){var r=as(n,i,e,t);if(!r)return;a.config=r.config,a.samplerate=r.samplerate,a.channelCount=r.channelCount,a.codec=r.codec,a.manifestCodec=r.manifestCodec,A.log("parsed codec:"+a.codec+", rate:"+r.samplerate+", channels:"+r.channelCount)}}function mi(a){return 1024*9e4/a}function us(a,n){var i=vi(a,n);if(n+i<=a.length){var e=Gt(a,n)-i;if(e>0)return{headerLength:i,frameLength:e}}}function pi(a,n,i,e,t){var r=mi(a.samplerate),s=e+t*r,o=us(n,i),l;if(o){var u=o.frameLength,d=o.headerLength,f=d+u,h=Math.max(0,i+f-n.length);h?(l=new Uint8Array(f-d),l.set(n.subarray(i+d,n.length),0)):l=n.subarray(i+d,i+f);var c={unit:l,pts:s};return h||a.samples.push(c),{sample:c,length:f,missing:h}}var v=n.length-i;l=new Uint8Array(v),l.set(n.subarray(i,n.length),0);var m={unit:l,pts:s};return{sample:m,length:v,missing:-1}}var ct=null,fs=[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],ds=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],hs=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],cs=[0,1,1,4];function yi(a,n,i,e,t){if(!(i+24>n.length)){var r=Ei(n,i);if(r&&i+r.frameLength<=n.length){var s=r.samplesPerFrame*9e4/r.sampleRate,o=e+t*s,l={unit:n.subarray(i,i+r.frameLength),pts:o,dts:o};return a.config=[],a.channelCount=r.channelCount,a.samplerate=r.sampleRate,a.samples.push(l),{sample:l,length:r.frameLength,missing:0}}}}function Ei(a,n){var i=a[n+1]>>3&3,e=a[n+1]>>1&3,t=a[n+2]>>4&15,r=a[n+2]>>2&3;if(i!==1&&t!==0&&t!==15&&r!==3){var s=a[n+2]>>1&1,o=a[n+3]>>6,l=i===3?3-e:e===3?3:4,u=fs[l*14+t-1]*1e3,d=i===3?0:i===2?1:2,f=ds[d*3+r],h=o===3?1:2,c=hs[i][e],v=cs[e],m=c*8*v,g=Math.floor(c*u/f+s)*v;if(ct===null){var p=navigator.userAgent||"",y=p.match(/Chrome\/(\d+)/i);ct=y?parseInt(y[1]):0}var E=!!ct&&ct<=87;return E&&e===2&&u>=224e3&&o===0&&(a[n+3]=a[n+3]|128),{sampleRate:f,channelCount:h,frameLength:g,samplesPerFrame:m}}}function Ht(a,n){return a[n]===255&&(a[n+1]&224)===224&&(a[n+1]&6)!==0}function xi(a,n){return n+1<a.length&&Ht(a,n)}function vs(a,n){var i=4;return Ht(a,n)&&i<=a.length-n}function Ti(a,n){if(n+1<a.length&&Ht(a,n)){var i=4,e=Ei(a,n),t=i;e!=null&&e.frameLength&&(t=e.frameLength);var r=n+t;return r===a.length||xi(a,r)}return!1}var gs=function(a){Re(n,a);function n(e,t){var r;return r=a.call(this)||this,r.observer=void 0,r.config=void 0,r.observer=e,r.config=t,r}var i=n.prototype;return i.resetInitSegment=function(t,r,s,o){a.prototype.resetInitSegment.call(this,t,r,s,o),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:o,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;var r=Qe(t,0),s=r?.length||0;if(Ti(t,s))return!1;for(var o=t.length;s<o;s++)if(ls(t,s))return A.log("ADTS sync word found !"),!0;return!1},i.canParse=function(t,r){return os(t,r)},i.appendFrame=function(t,r,s){gi(t,this.observer,r,s,t.manifestCodec);var o=pi(t,r,s,this.basePTS,this.frameIndex);if(o&&o.missing===0)return o},n}(hi),ms=/\/emsg[-/]ID3/i,ps=function(){function a(i,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 n=a.prototype;return n.resetTimeStamp=function(){},n.resetInitSegment=function(e,t,r,s){var o=this.videoTrack=Ie("video",1),l=this.audioTrack=Ie("audio",1),u=this.txtTrack=Ie("text",1);if(this.id3Track=Ie("id3",1),this.timeOffset=0,!!(e!=null&&e.byteLength)){var d=Er(e);if(d.video){var f=d.video,h=f.id,c=f.timescale,v=f.codec;o.id=h,o.timescale=u.timescale=c,o.codec=v}if(d.audio){var m=d.audio,g=m.id,p=m.timescale,y=m.codec;l.id=g,l.timescale=p,l.codec=y}u.id=gr.text,o.sampleDuration=0,o.duration=l.duration=s}},n.resetContiguity=function(){this.remainderData=null},a.probe=function(e){return gn(e)},n.demux=function(e,t){this.timeOffset=t;var r=e,s=this.videoTrack,o=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=xe(this.remainderData,e));var l=An(r);this.remainderData=l.remainder,s.samples=l.valid||new Uint8Array}else s.samples=r;var u=this.extractID3Track(s,t);return o.samples=xr(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:u,textTrack:this.txtTrack}},n.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var s=this.extractID3Track(t,this.timeOffset);return r.samples=xr(e,t),{videoTrack:t,audioTrack:Ie(),id3Track:s,textTrack:Ie()}},n.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var s=G(e.samples,["emsg"]);s&&s.forEach(function(o){var l=In(o);if(ms.test(l.schemeIdUri)){var u=O(l.presentationTime)?l.presentationTime/l.timeScale:t+l.presentationTimeDelta/l.timeScale,d=l.eventDuration===4294967295?Number.POSITIVE_INFINITY:l.eventDuration/l.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);var f=l.payload;r.samples.push({data:f,len:f.byteLength,dts:u,pts:u,type:Te.emsg,duration:d})}})}return r},n.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},n.destroy=function(){},a}(),ys=function(n,i){var e=0,t=5;i+=t;for(var r=new Uint32Array(1),s=new Uint32Array(1),o=new Uint8Array(1);t>0;){o[0]=n[i];var l=Math.min(t,8),u=8-l;s[0]=4278190080>>>24+u<<u,r[0]=(o[0]&s[0])>>u,e=e?e<<l|r[0]:r[0],i+=1,t-=l}return e},Es=function(){function a(){this.VideoSample=null}var n=a.prototype;return n.createVideoSample=function(e,t,r,s){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:s,length:0}},n.getLastNalUnit=function(e){var t,r=this.VideoSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){var o=r.units;s=o[o.length-1]}return s},n.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){var r=t.samples,s=r.length;if(s){var o=r[s-1];e.pts=o.pts,e.dts=o.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&A.log(e.pts+"/"+e.dts+":"+e.debug)},a}(),Si=function(){function a(i){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=i,this.bytesAvailable=i.byteLength,this.word=0,this.bitsAvailable=0}var n=a.prototype;return n.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),o=Math.min(4,t);if(o===0)throw new Error("no bytes available");s.set(e.subarray(r,r+o)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=o*8,this.bytesAvailable-=o},n.skipBits=function(e){var t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},n.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&A.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r},n.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()},n.skipUEG=function(){this.skipBits(1+this.skipLZ())},n.skipEG=function(){this.skipBits(1+this.skipLZ())},n.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},n.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},n.readBoolean=function(){return this.readBits(1)===1},n.readUByte=function(){return this.readBits(8)},n.readUShort=function(){return this.readBits(16)},n.readUInt=function(){return this.readBits(32)},n.skipScalingList=function(e){for(var t=8,r=8,s,o=0;o<e;o++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r},n.readSPS=function(){var e=0,t=0,r=0,s=0,o,l,u,d=this.readUByte.bind(this),f=this.readBits.bind(this),h=this.readUEG.bind(this),c=this.readBoolean.bind(this),v=this.skipBits.bind(this),m=this.skipEG.bind(this),g=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);d();var y=d();if(f(5),v(3),d(),g(),y===100||y===110||y===122||y===244||y===44||y===83||y===86||y===118||y===128){var E=h();if(E===3&&v(1),g(),g(),v(1),c())for(l=E!==3?8:12,u=0;u<l;u++)c()&&(u<6?p(16):p(64))}g();var S=h();if(S===0)h();else if(S===1)for(v(1),m(),m(),o=h(),u=0;u<o;u++)m();g(),v(1);var L=h(),D=h(),R=f(1);R===0&&v(1),v(1),c()&&(e=h(),t=h(),r=h(),s=h());var T=[1,1];if(c()&&c()){var b=d();switch(b){case 1:T=[1,1];break;case 2:T=[12,11];break;case 3:T=[10,11];break;case 4:T=[16,11];break;case 5:T=[40,33];break;case 6:T=[24,11];break;case 7:T=[20,11];break;case 8:T=[32,11];break;case 9:T=[80,33];break;case 10:T=[18,11];break;case 11:T=[15,11];break;case 12:T=[64,33];break;case 13:T=[160,99];break;case 14:T=[4,3];break;case 15:T=[3,2];break;case 16:T=[2,1];break;case 255:{T=[d()<<8|d(),d()<<8|d()];break}}}return{width:Math.ceil((L+1)*16-e*2-t*2),height:(2-R)*(D+1)*16-(R?2:4)*(r+s),pixelRatio:T}},n.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},a}(),xs=function(a){Re(n,a);function n(){return a.apply(this,arguments)||this}var i=n.prototype;return i.parseAVCPES=function(t,r,s,o,l){var u=this,d=this.parseAVCNALu(t,s.data),f=this.VideoSample,h,c=!1;s.data=null,f&&d.length&&!t.audFound&&(this.pushAccessUnit(f,t),f=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts,"")),d.forEach(function(v){var m;switch(v.type){case 1:{var g=!1;h=!0;var p=v.data;if(c&&p.length>4){var y=new Si(p).readSliceType();(y===2||y===4||y===7||y===9)&&(g=!0)}if(g){var E;(E=f)!=null&&E.frame&&!f.key&&(u.pushAccessUnit(f,t),f=u.VideoSample=null)}f||(f=u.VideoSample=u.createVideoSample(!0,s.pts,s.dts,"")),f.frame=!0,f.key=g;break}case 5:h=!0,(m=f)!=null&&m.frame&&!f.key&&(u.pushAccessUnit(f,t),f=u.VideoSample=null),f||(f=u.VideoSample=u.createVideoSample(!0,s.pts,s.dts,"")),f.key=!0,f.frame=!0;break;case 6:{h=!0,Tr(v.data,1,s.pts,r.samples);break}case 7:{var S,L;h=!0,c=!0;var D=v.data,R=new Si(D),T=R.readSPS();if(!t.sps||t.width!==T.width||t.height!==T.height||((S=t.pixelRatio)==null?void 0:S[0])!==T.pixelRatio[0]||((L=t.pixelRatio)==null?void 0:L[1])!==T.pixelRatio[1]){t.width=T.width,t.height=T.height,t.pixelRatio=T.pixelRatio,t.sps=[D],t.duration=l;for(var b=D.subarray(1,4),I="avc1.",P=0;P<3;P++){var C=b[P].toString(16);C.length<2&&(C="0"+C),I+=C}t.codec=I}break}case 8:h=!0,t.pps=[v.data];break;case 9:h=!0,t.audFound=!0,f&&u.pushAccessUnit(f,t),f=u.VideoSample=u.createVideoSample(!1,s.pts,s.dts,"");break;case 12:h=!0;break;default:h=!1,f&&(f.debug+="unknown NAL "+v.type+" ");break}if(f&&h){var w=f.units;w.push(v)}}),o&&f&&(this.pushAccessUnit(f,t),this.VideoSample=null)},i.parseAVCNALu=function(t,r){var s=r.byteLength,o=t.naluState||0,l=o,u=[],d=0,f,h,c,v=-1,m=0;for(o===-1&&(v=0,m=r[0]&31,o=0,d=1);d<s;){if(f=r[d++],!o){o=f?0:1;continue}if(o===1){o=f?0:2;continue}if(!f)o=3;else if(f===1){if(h=d-o-1,v>=0){var g={data:r.subarray(v,h),type:m};u.push(g)}else{var p=this.getLastNalUnit(t.samples);p&&(l&&d<=4-l&&p.state&&(p.data=p.data.subarray(0,p.data.byteLength-l)),h>0&&(p.data=xe(p.data,r.subarray(0,h)),p.state=0))}d<s?(c=r[d]&31,v=d,m=c,o=0):o=-1}else o=0}if(v>=0&&o>=0){var y={data:r.subarray(v,s),type:m,state:o};u.push(y)}if(u.length===0){var E=this.getLastNalUnit(t.samples);E&&(E.data=xe(E.data,r))}return t.naluState=o,u},n}(Es),Ts=function(){function a(i,e,t){this.keyData=void 0,this.decrypter=void 0,this.keyData=t,this.decrypter=new Ut(e,{removePKCS7Padding:!1})}var n=a.prototype;return n.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},n.decryptAacSample=function(e,t,r){var s=this,o=e[t].unit;if(!(o.length<=16)){var l=o.subarray(16,o.length-o.length%16),u=l.buffer.slice(l.byteOffset,l.byteOffset+l.length);this.decryptBuffer(u).then(function(d){var f=new Uint8Array(d);o.set(f,16),s.decrypter.isSync()||s.decryptAacSamples(e,t+1,r)})}},n.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}},n.getAvcEncryptedData=function(e){for(var t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),s=0,o=32;o<e.length-16;o+=160,s+=16)r.set(e.subarray(o,o+16),s);return r},n.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),s=0,o=32;o<e.length-16;o+=160,s+=16)e.set(r.subarray(s,s+16),o);return e},n.decryptAvcSample=function(e,t,r,s,o){var l=this,u=Sr(o.data),d=this.getAvcEncryptedData(u);this.decryptBuffer(d.buffer).then(function(f){o.data=l.getAvcDecryptedUnit(u,f),l.decrypter.isSync()||l.decryptAvcSamples(e,t,r+1,s)})},n.decryptAvcSamples=function(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}for(var o=e[t].units;!(r>=o.length);r++){var l=o[r];if(!(l.data.length<=48||l.type!==1&&l.type!==5)&&(this.decryptAvcSample(e,t,r,s,l),!this.decrypter.isSync()))return}}},a}(),oe=188,Ss=function(){function a(i,e,t){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=i,this.config=e,this.typeSupported=t,this.videoParser=new xs}a.probe=function(e){var t=a.syncOffset(e);return t>0&&A.warn("MPEG2-TS detected but first sync word found @ offset "+t),t!==-1},a.syncOffset=function(e){for(var t=e.length,r=Math.min(oe*5,t-oe)+1,s=0;s<r;){for(var o=!1,l=-1,u=0,d=s;d<t;d+=oe)if(e[d]===71&&(t-d===oe||e[d+oe]===71)){if(u++,l===-1&&(l=d,l!==0&&(r=Math.min(l+oe*99,e.length-oe)+1)),o||(o=Vt(e,d)===0),o&&u>1&&(l===0&&u>2||d+oe>r))return l}else{if(u)return-1;break}s++}return-1},a.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:gr[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}};var n=a.prototype;return n.resetInitSegment=function(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=a.createTrack("video"),this._audioTrack=a.createTrack("audio",s),this._id3Track=a.createTrack("id3"),this._txtTrack=a.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s},n.resetTimeStamp=function(){},n.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},n.demux=function(e,t,r,s){r===void 0&&(r=!1),s===void 0&&(s=!1),r||(this.sampleAes=null);var o,l=this._videoTrack,u=this._audioTrack,d=this._id3Track,f=this._txtTrack,h=l.pid,c=l.pesData,v=u.pid,m=d.pid,g=u.pesData,p=d.pesData,y=null,E=this.pmtParsed,S=this._pmtId,L=e.length;if(this.remainderData&&(e=xe(this.remainderData,e),L=e.length,this.remainderData=null),L<oe&&!s)return this.remainderData=e,{audioTrack:u,videoTrack:l,id3Track:d,textTrack:f};var D=Math.max(0,a.syncOffset(e));L-=(L-D)%oe,L<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,L,e.buffer.byteLength-L));for(var R=0,T=D;T<L;T+=oe)if(e[T]===71){var b=!!(e[T+1]&64),I=Vt(e,T),P=(e[T+3]&48)>>4,C=void 0;if(P>1){if(C=T+5+e[T+4],C===T+oe)continue}else C=T+4;switch(I){case h:b&&(c&&(o=Ve(c))&&this.videoParser.parseAVCPES(l,f,o,!1,this._duration),c={data:[],size:0}),c&&(c.data.push(e.subarray(C,T+oe)),c.size+=T+oe-C);break;case v:if(b){if(g&&(o=Ve(g)))switch(u.segmentCodec){case"aac":this.parseAACPES(u,o);break;case"mp3":this.parseMPEGPES(u,o);break}g={data:[],size:0}}g&&(g.data.push(e.subarray(C,T+oe)),g.size+=T+oe-C);break;case m:b&&(p&&(o=Ve(p))&&this.parseID3PES(d,o),p={data:[],size:0}),p&&(p.data.push(e.subarray(C,T+oe)),p.size+=T+oe-C);break;case 0:b&&(C+=e[C]+1),S=this._pmtId=Ls(e,C);break;case S:{b&&(C+=e[C]+1);var w=As(e,C,this.typeSupported,r);h=w.videoPid,h>0&&(l.pid=h,l.segmentCodec=w.segmentVideoCodec),v=w.audioPid,v>0&&(u.pid=v,u.segmentCodec=w.segmentAudioCodec),m=w.id3Pid,m>0&&(d.pid=m),y!==null&&!E&&(A.warn("MPEG-TS PMT found at "+T+" after unknown PID '"+y+"'. Backtracking to sync byte @"+D+" to parse all TS packets."),y=null,T=D-188),E=this.pmtParsed=!0;break}case 17:case 8191:break;default:y=I;break}}else R++;if(R>0){var M=new Error("Found "+R+" TS packet/s that do not start with 0x47");this.observer.emit(x.ERROR,x.ERROR,{type:V.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,fatal:!1,error:M,reason:M.message})}l.pesData=c,u.pesData=g,d.pesData=p;var F={audioTrack:u,videoTrack:l,id3Track:d,textTrack:f};return s&&this.extractRemainingSamples(F),F},n.flush=function(){var e=this.remainderData;this.remainderData=null;var t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},n.extractRemainingSamples=function(e){var t=e.audioTrack,r=e.videoTrack,s=e.id3Track,o=e.textTrack,l=r.pesData,u=t.pesData,d=s.pesData,f;if(l&&(f=Ve(l))?(this.videoParser.parseAVCPES(r,o,f,!0,this._duration),r.pesData=null):r.pesData=l,u&&(f=Ve(u))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,f);break;case"mp3":this.parseMPEGPES(t,f);break}t.pesData=null}else u!=null&&u.size&&A.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=u;d&&(f=Ve(d))?(this.parseID3PES(s,f),s.pesData=null):s.pesData=d},n.demuxSampleAes=function(e,t,r){var s=this.demux(e,r,!0,!this.config.progressive),o=this.sampleAes=new Ts(this.observer,this.config,t);return this.decrypt(s,o)},n.decrypt=function(e,t){return new Promise(function(r){var s=e.audioTrack,o=e.videoTrack;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,function(){o.samples?t.decryptAvcSamples(o.samples,0,0,function(){r(e)}):r(e)}):o.samples&&t.decryptAvcSamples(o.samples,0,0,function(){r(e)})})},n.destroy=function(){this._duration=0},n.parseAACPES=function(e,t){var r=0,s=this.aacOverFlow,o=t.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;if(l===-1)o=xe(s.sample.unit,o);else{var d=u-l;s.sample.unit.set(o.subarray(0,l),d),e.samples.push(s.sample),r=s.missing}}var f,h;for(f=r,h=o.length;f<h-1&&!ht(o,f);f++);if(f!==r){var c,v=f<h-1;v?c="AAC PES did not start with ADTS header,offset:"+f:c="No ADTS header found in AAC PES";var m=new Error(c);if(A.warn("parsing error: "+c),this.observer.emit(x.ERROR,x.ERROR,{type:V.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,fatal:!1,levelRetry:v,error:m,reason:c}),!v)return}gi(e,this.observer,o,f,this.audioCodec);var g;if(t.pts!==void 0)g=t.pts;else if(s){var p=mi(e.samplerate);g=s.sample.pts+p}else{A.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var y=0,E;f<h;)if(E=pi(e,o,f,g,y),f+=E.length,E.missing){this.aacOverFlow=E;break}else for(y++;f<h-1&&!ht(o,f);f++);},n.parseMPEGPES=function(e,t){var r=t.data,s=r.length,o=0,l=0,u=t.pts;if(u===void 0){A.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<s;)if(xi(r,l)){var d=yi(e,r,l,u,o);if(d)l+=d.length,o++;else break}else l++},n.parseAC3PES=function(e,t){},n.parseID3PES=function(e,t){if(t.pts===void 0){A.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=ye({},t,{type:this._videoTrack?Te.emsg:Te.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)},a}();function Vt(a,n){return((a[n+1]&31)<<8)+a[n+2]}function Ls(a,n){return(a[n+10]&31)<<8|a[n+11]}function As(a,n,i,e){var t={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},r=(a[n+1]&15)<<8|a[n+2],s=n+3+r-4,o=(a[n+10]&15)<<8|a[n+11];for(n+=12+o;n<s;){var l=Vt(a,n),u=(a[n+3]&15)<<8|a[n+4];switch(a[n]){case 207:if(!e){Kt("ADTS AAC");break}case 15:t.audioPid===-1&&(t.audioPid=l);break;case 21:t.id3Pid===-1&&(t.id3Pid=l);break;case 219:if(!e){Kt("H.264");break}case 27:t.videoPid===-1&&(t.videoPid=l,t.segmentVideoCodec="avc");break;case 3:case 4:!i.mpeg&&!i.mp3?A.log("MPEG audio found, not supported in this browser"):t.audioPid===-1&&(t.audioPid=l,t.segmentAudioCodec="mp3");break;case 193:if(!e){Kt("AC-3");break}case 129:A.warn("AC-3 in M2TS support not included in build");break;case 6:if(t.audioPid===-1&&u>0)for(var d=n+5,f=u;f>2;){var h=a[d];switch(h){case 106:A.warn("AC-3 in M2TS support not included in build");break}var c=a[d+1]+2;d+=c,f-=c}break;case 194:case 135:A.warn("Unsupported EC-3 in M2TS found");break;case 36:A.warn("Unsupported HEVC in M2TS found");break}n+=u+5}return t}function Kt(a){A.log(a+" with AES-128-CBC encryption found in unencrypted stream")}function Ve(a){var n=0,i,e,t,r,s,o=a.data;if(!a||a.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=xe(o[0],o[1]),o.splice(1,1);i=o[0];var l=(i[0]<<16)+(i[1]<<8)+i[2];if(l===1){if(e=(i[4]<<8)+i[5],e&&e>a.size-6)return null;var u=i[7];u&192&&(r=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,u&64?(s=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,r-s>60*9e4&&(A.warn(Math.round((r-s)/9e4)+"s delta between PTS and DTS, align them"),r=s)):s=r),t=i[8];var d=t+9;if(a.size<=d)return null;a.size-=d;for(var f=new Uint8Array(a.size),h=0,c=o.length;h<c;h++){i=o[h];var v=i.byteLength;if(d)if(d>v){d-=v;continue}else i=i.subarray(d),v-=d,d=0;f.set(i,n),n+=v}return e&&(e-=t+3),{data:f,pts:r,dts:s,len:e}}return null}var Rs=function(a){Re(n,a);function n(){return a.apply(this,arguments)||this}var i=n.prototype;return i.resetInitSegment=function(t,r,s,o){a.prototype.resetInitSegment.call(this,t,r,s,o),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:o,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;var r=Qe(t,0),s=r?.length||0;if(r&&t[s]===11&&t[s+1]===119&&dr(r)!==void 0&&ys(t,s)<=16)return!1;for(var o=t.length;s<o;s++)if(Ti(t,s))return A.log("MPEG Audio sync word found !"),!0;return!1},i.canParse=function(t,r){return vs(t,r)},i.appendFrame=function(t,r,s){if(this.basePTS!==null)return yi(t,r,s,this.basePTS,this.frameIndex)},n}(hi),Li=function(){function a(){}return a.getSilentFrame=function(i,e){switch(i){case"mp4a.40.2":if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(e===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(e===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}},a}(),ke=Math.pow(2,32)-1,fe=function(){function a(){}return a.init=function(){a.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var i;for(i in a.types)a.types.hasOwnProperty(i)&&(a.types[i]=[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]);var e=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),t=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]);a.HDLR_TYPES={video:e,audio:t};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);a.STTS=a.STSC=a.STCO=s,a.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),a.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),a.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),a.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),l=new Uint8Array([97,118,99,49]),u=new Uint8Array([0,0,0,1]);a.FTYP=a.box(a.types.ftyp,o,u,o,l),a.DINF=a.box(a.types.dinf,a.box(a.types.dref,r))},a.box=function(i){for(var e=8,t=arguments.length,r=new Array(t>1?t-1:0),s=1;s<t;s++)r[s-1]=arguments[s];for(var o=r.length,l=o;o--;)e+=r[o].byteLength;var u=new Uint8Array(e);for(u[0]=e>>24&255,u[1]=e>>16&255,u[2]=e>>8&255,u[3]=e&255,u.set(i,4),o=0,e=8;o<l;o++)u.set(r[o],e),e+=r[o].byteLength;return u},a.hdlr=function(i){return a.box(a.types.hdlr,a.HDLR_TYPES[i])},a.mdat=function(i){return a.box(a.types.mdat,i)},a.mdhd=function(i,e){e*=i;var t=Math.floor(e/(ke+1)),r=Math.floor(e%(ke+1));return a.box(a.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,i&255,t>>24,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))},a.mdia=function(i){return a.box(a.types.mdia,a.mdhd(i.timescale,i.duration),a.hdlr(i.type),a.minf(i))},a.mfhd=function(i){return a.box(a.types.mfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255]))},a.minf=function(i){return i.type==="audio"?a.box(a.types.minf,a.box(a.types.smhd,a.SMHD),a.DINF,a.stbl(i)):a.box(a.types.minf,a.box(a.types.vmhd,a.VMHD),a.DINF,a.stbl(i))},a.moof=function(i,e,t){return a.box(a.types.moof,a.mfhd(i),a.traf(t,e))},a.moov=function(i){for(var e=i.length,t=[];e--;)t[e]=a.trak(i[e]);return a.box.apply(null,[a.types.moov,a.mvhd(i[0].timescale,i[0].duration)].concat(t).concat(a.mvex(i)))},a.mvex=function(i){for(var e=i.length,t=[];e--;)t[e]=a.trex(i[e]);return a.box.apply(null,[a.types.mvex].concat(t))},a.mvhd=function(i,e){e*=i;var t=Math.floor(e/(ke+1)),r=Math.floor(e%(ke+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,i&255,t>>24,t>>16&255,t>>8&255,t&255,r>>24,r>>16&255,r>>8&255,r&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return a.box(a.types.mvhd,s)},a.sdtp=function(i){var e=i.samples||[],t=new Uint8Array(4+e.length),r,s;for(r=0;r<e.length;r++)s=e[r].flags,t[r+4]=s.dependsOn<<4|s.isDependedOn<<2|s.hasRedundancy;return a.box(a.types.sdtp,t)},a.stbl=function(i){return a.box(a.types.stbl,a.stsd(i),a.box(a.types.stts,a.STTS),a.box(a.types.stsc,a.STSC),a.box(a.types.stsz,a.STSZ),a.box(a.types.stco,a.STCO))},a.avc1=function(i){var e=[],t=[],r,s,o;for(r=0;r<i.sps.length;r++)s=i.sps[r],o=s.byteLength,e.push(o>>>8&255),e.push(o&255),e=e.concat(Array.prototype.slice.call(s));for(r=0;r<i.pps.length;r++)s=i.pps[r],o=s.byteLength,t.push(o>>>8&255),t.push(o&255),t=t.concat(Array.prototype.slice.call(s));var l=a.box(a.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|i.sps.length].concat(e).concat([i.pps.length]).concat(t))),u=i.width,d=i.height,f=i.pixelRatio[0],h=i.pixelRatio[1];return a.box(a.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,u>>8&255,u&255,d>>8&255,d&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l,a.box(a.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),a.box(a.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,f&255,h>>24,h>>16&255,h>>8&255,h&255])))},a.esds=function(i){var e=i.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(i.config).concat([6,1,2]))},a.audioStsd=function(i){var e=i.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0])},a.mp4a=function(i){return a.box(a.types.mp4a,a.audioStsd(i),a.box(a.types.esds,a.esds(i)))},a.mp3=function(i){return a.box(a.types[".mp3"],a.audioStsd(i))},a.ac3=function(i){return a.box(a.types["ac-3"],a.audioStsd(i),a.box(a.types.dac3,i.config))},a.stsd=function(i){return i.type==="audio"?i.segmentCodec==="mp3"&&i.codec==="mp3"?a.box(a.types.stsd,a.STSD,a.mp3(i)):i.segmentCodec==="ac3"?a.box(a.types.stsd,a.STSD,a.ac3(i)):a.box(a.types.stsd,a.STSD,a.mp4a(i)):a.box(a.types.stsd,a.STSD,a.avc1(i))},a.tkhd=function(i){var e=i.id,t=i.duration*i.timescale,r=i.width,s=i.height,o=Math.floor(t/(ke+1)),l=Math.floor(t%(ke+1));return a.box(a.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,l>>24,l>>16&255,l>>8&255,l&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,r&255,0,0,s>>8&255,s&255,0,0]))},a.traf=function(i,e){var t=a.sdtp(i),r=i.id,s=Math.floor(e/(ke+1)),o=Math.floor(e%(ke+1));return a.box(a.types.traf,a.box(a.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),a.box(a.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,s&255,o>>24,o>>16&255,o>>8&255,o&255])),a.trun(i,t.length+16+20+8+16+8+8),t)},a.trak=function(i){return i.duration=i.duration||4294967295,a.box(a.types.trak,a.tkhd(i),a.mdia(i))},a.trex=function(i){var e=i.id;return a.box(a.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},a.trun=function(i,e){var t=i.samples||[],r=t.length,s=12+16*r,o=new Uint8Array(s),l,u,d,f,h,c;for(e+=8+s,o.set([i.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),l=0;l<r;l++)u=t[l],d=u.duration,f=u.size,h=u.flags,c=u.cts,o.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,h.degradPrio&61440,h.degradPrio&15,c>>>24&255,c>>>16&255,c>>>8&255,c&255],12+16*l);return a.box(a.types.trun,o)},a.initSegment=function(i){a.types||a.init();var e=a.moov(i),t=xe(a.FTYP,e);return t},a}();fe.types=void 0,fe.HDLR_TYPES=void 0,fe.STTS=void 0,fe.STSC=void 0,fe.STCO=void 0,fe.STSZ=void 0,fe.VMHD=void 0,fe.SMHD=void 0,fe.STSD=void 0,fe.FTYP=void 0,fe.DINF=void 0;var bs=9e4;function Is(a,n,i,e){i===void 0&&(i=1),e===void 0&&(e=!1);var t=a*n*i;return e?Math.round(t):t}function je(a,n){return n===void 0&&(n=!1),Is(a,1e3,1/bs,n)}var _s=10*1e3,Ai=1024,Ds=1152,Cs=1536,Ke=null,Wt=null,Yt=function(){function a(i,e,t,r){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=i,this.config=e,this.typeSupported=t,this.ISGenerated=!1,Ke===null){var s=navigator.userAgent||"",o=s.match(/Chrome\/(\d+)/i);Ke=o?parseInt(o[1]):0}if(Wt===null){var l=navigator.userAgent.match(/Safari\/(\d+)/i);Wt=l?parseInt(l[1]):0}}var n=a.prototype;return n.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},n.resetTimeStamp=function(e){A.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},n.resetNextTimestamp=function(){A.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},n.resetInitSegment=function(){A.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},n.getVideoStartPts=function(e){var t=!1,r=e.reduce(function(s,o){var l=o.pts-s;return l<-4294967296?(t=!0,Le(s,o.pts)):l>0?s:o.pts},e[0].pts);return t&&A.debug("PTS rollover detected"),r},n.remux=function(e,t,r,s,o,l,u,d){var f,h,c,v,m,g,p=o,y=o,E=e.pid>-1,S=t.pid>-1,L=t.samples.length,D=e.samples.length>0,R=u&&L>0||L>1,T=(!E||D)&&(!S||R)||this.ISGenerated||u;if(T){if(this.ISGenerated){var b,I,P,C,w=this.videoTrackConfig;w&&(t.width!==w.width||t.height!==w.height||((b=t.pixelRatio)==null?void 0:b[0])!==((I=w.pixelRatio)==null?void 0:I[0])||((P=t.pixelRatio)==null?void 0:P[1])!==((C=w.pixelRatio)==null?void 0:C[1]))&&this.resetInitSegment()}else c=this.generateIS(e,t,o,l);var M=this.isVideoContiguous,F=-1,H;if(R&&(F=Ps(t.samples),!M&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,F>0){A.warn("[mp4-remuxer]: Dropped "+F+" out of "+L+" video samples due to a missing keyframe");var U=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(F),t.dropped+=F,y+=(t.samples[0].pts-U)/t.inputTimeScale,H=y}else F===-1&&(A.warn("[mp4-remuxer]: No keyframe found out of "+L+" video samples"),g=!1);if(this.ISGenerated){if(D&&R){var W=this.getVideoStartPts(t.samples),K=Le(e.samples[0].pts,W)-W,B=K/t.inputTimeScale;p+=Math.max(0,B),y+=Math.max(0,-B)}if(D){if(e.samplerate||(A.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,o,l)),h=this.remuxAudio(e,p,this.isAudioContiguous,l,S||R||d===j.AUDIO?y:void 0),R){var Q=h?h.endPTS-h.startPTS:0;t.inputTimeScale||(A.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,o,l)),f=this.remuxVideo(t,y,M,Q)}}else R&&(f=this.remuxVideo(t,y,M,0));f&&(f.firstKeyFrame=F,f.independent=F!==-1,f.firstKeyFramePTS=H)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(m=Ri(r,o,this._initPTS,this._initDTS)),s.samples.length&&(v=bi(s,o,this._initPTS))),{audio:h,video:f,initSegment:c,independent:g,text:v,id3:m}},n.generateIS=function(e,t,r,s){var o=e.samples,l=t.samples,u=this.typeSupported,d={},f=this._initPTS,h=!f||s,c="audio/mp4",v,m,g;if(h&&(v=m=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";break}d.audio={id:"audio",container:c,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&u.mpeg?new Uint8Array(0):fe.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(g=e.inputTimeScale,!f||g!==f.timescale?v=m=o[0].pts-Math.round(g*r):h=!1)}if(t.sps&&t.pps&&l.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:fe.initSegment([t]),metadata:{width:t.width,height:t.height}},h)if(g=t.inputTimeScale,!f||g!==f.timescale){var p=this.getVideoStartPts(l),y=Math.round(g*r);m=Math.min(m,Le(l[0].dts,p)-y),v=Math.min(v,p-y)}else h=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,h?(this._initPTS={baseTime:v,timescale:g},this._initDTS={baseTime:m,timescale:g}):v=g=void 0,{tracks:d,initPTS:v,timescale:g}},n.remuxVideo=function(e,t,r,s){var o=e.inputTimeScale,l=e.samples,u=[],d=l.length,f=this._initPTS,h=this.nextAvcDts,c=8,v=this.videoSampleDuration,m,g,p=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,E=!1;if(!r||h===null){var S=t*o,L=l[0].pts-Le(l[0].dts,l[0].pts);Ke&&h!==null&&Math.abs(S-L-h)<15e3?r=!0:h=S-L}for(var D=f.baseTime*o/f.timescale,R=0;R<d;R++){var T=l[R];T.pts=Le(T.pts-D,h),T.dts=Le(T.dts-D,h),T.dts<l[R>0?R-1:R].dts&&(E=!0)}E&&l.sort(function(pt,Ui){var no=pt.dts-Ui.dts,ao=pt.pts-Ui.pts;return no||ao}),m=l[0].dts,g=l[l.length-1].dts;var b=g-m,I=b?Math.round(b/(d-1)):v||e.inputTimeScale/30;if(r){var P=m-h,C=P>I,w=P<-1;if((C||w)&&(C?A.warn("AVC: "+je(P,!0)+" ms ("+P+"dts) hole between fragments detected at "+t.toFixed(3)):A.warn("AVC: "+je(-P,!0)+" ms ("+P+"dts) overlapping between fragments detected at "+t.toFixed(3)),!w||h>=l[0].pts||Ke)){m=h;var M=l[0].pts-P;if(C)l[0].dts=m,l[0].pts=M;else for(var F=0;F<l.length&&!(l[F].dts>M);F++)l[F].dts-=P,l[F].pts-=P;A.log("Video: Initial PTS/DTS adjusted: "+je(M,!0)+"/"+je(m,!0)+", delta: "+je(P,!0)+" ms")}}m=Math.max(0,m);for(var H=0,U=0,W=m,K=0;K<d;K++){for(var B=l[K],Q=B.units,q=Q.length,J=0,ee=0;ee<q;ee++)J+=Q[ee].data.length;U+=J,H+=q,B.length=J,B.dts<W?(B.dts=W,W+=I/4|0||1):W=B.dts,p=Math.min(B.pts,p),y=Math.max(B.pts,y)}g=l[d-1].dts;var re=U+4*H+8,Z;try{Z=new Uint8Array(re)}catch(pt){this.observer.emit(x.ERROR,x.ERROR,{type:V.MUX_ERROR,details:_.REMUX_ALLOC_ERROR,fatal:!1,error:pt,bytes:re,reason:"fail allocating video mdat "+re});return}var X=new DataView(Z.buffer);X.setUint32(0,re),Z.set(fe.types.mdat,4);for(var Pe=!1,Ee=Number.POSITIVE_INFINITY,te=Number.POSITIVE_INFINITY,ce=Number.NEGATIVE_INFINITY,ve=Number.NEGATIVE_INFINITY,ie=0;ie<d;ie++){for(var z=l[ie],pe=z.units,de=0,le=0,Ue=pe.length;le<Ue;le++){var Fi=pe[le],$s=Fi.data,Qt=Fi.data.byteLength;X.setUint32(c,Qt),c+=4,Z.set($s,c),c+=Qt,de+=4+Qt}var gt=void 0;if(ie<d-1)v=l[ie+1].dts-z.dts,gt=l[ie+1].pts-z.pts;else{var Oi=this.config,mt=ie>0?z.dts-l[ie-1].dts:I;if(gt=ie>0?z.pts-l[ie-1].pts:I,Oi.stretchShortVideoTrack&&this.nextAudioPts!==null){var Qs=Math.floor(Oi.maxBufferHole*o),Zt=(s?p+s*o:this.nextAudioPts)-z.pts;Zt>Qs?(v=Zt-mt,v<0?v=mt:Pe=!0,A.log("[mp4-remuxer]: It is approximately "+Zt/90+" ms to the next segment; using duration "+v/90+" ms for the last video frame.")):v=mt}else v=mt}var Zs=Math.round(z.pts-z.dts);Ee=Math.min(Ee,v),ce=Math.max(ce,v),te=Math.min(te,gt),ve=Math.max(ve,gt),u.push(new Ii(z.key,v,de,Zs))}if(u.length){if(Ke){if(Ke<70){var Mi=u[0].flags;Mi.dependsOn=2,Mi.isNonSync=0}}else if(Wt&&ve-te<ce-Ee&&I/ce<.025&&u[0].cts===0){A.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Jt=m,Ae=0,Ni=u.length;Ae<Ni;Ae++){var Bi=Jt+u[Ae].duration,Js=Jt+u[Ae].cts;if(Ae<Ni-1){var eo=Bi+u[Ae+1].cts;u[Ae].duration=eo-Js}else u[Ae].duration=Ae?u[Ae-1].duration:I;u[Ae].cts=0,Jt=Bi}}}v=Pe||!v?I:v,this.nextAvcDts=h=g+v,this.videoSampleDuration=v,this.isVideoContiguous=!0;var to=fe.moof(e.sequenceNumber++,m,ye({},e,{samples:u})),ro="video",io={data1:to,data2:Z,startPTS:p/o,endPTS:(y+v)/o,startDTS:m/o,endDTS:h/o,type:ro,hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,io},n.getSamplesPerFrame=function(e){switch(e.segmentCodec){case"mp3":return Ds;case"ac3":return Cs;default:return Ai}},n.remuxAudio=function(e,t,r,s,o){var l=e.inputTimeScale,u=e.samplerate?e.samplerate:l,d=l/u,f=this.getSamplesPerFrame(e),h=f*d,c=this._initPTS,v=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,m=[],g=o!==void 0,p=e.samples,y=v?0:8,E=this.nextAudioPts||-1,S=t*l,L=c.baseTime*l/c.timescale;if(this.isAudioContiguous=r=r||p.length&&E>0&&(s&&Math.abs(S-E)<9e3||Math.abs(Le(p[0].pts-L,S)-E)<20*h),p.forEach(function(le){le.pts=Le(le.pts-L,S)}),!r||E<0){if(p=p.filter(function(le){return le.pts>=0}),!p.length)return;o===0?E=0:s&&!g?E=Math.max(0,S):E=p[0].pts}if(e.segmentCodec==="aac")for(var D=this.config.maxAudioFramesDrift,R=0,T=E;R<p.length;R++){var b=p[R],I=b.pts,P=I-T,C=Math.abs(1e3*P/l);if(P<=-D*h&&g)R===0&&(A.warn("Audio frame @ "+(I/l).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*P/l)+" ms."),this.nextAudioPts=E=T=I);else if(P>=D*h&&C<_s&&g){var w=Math.round(P/h);T=I-w*h,T<0&&(w--,T+=h),R===0&&(this.nextAudioPts=E=T),A.warn("[mp4-remuxer]: Injecting "+w+" audio frame @ "+(T/l).toFixed(3)+"s due to "+Math.round(1e3*P/l)+" ms gap.");for(var M=0;M<w;M++){var F=Math.max(T,0),H=Li.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);H||(A.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),H=b.unit.subarray()),p.splice(R,0,{unit:H,pts:F}),T+=h,R++}}b.pts=T,T+=h}for(var U=null,W=null,K,B=0,Q=p.length;Q--;)B+=p[Q].unit.byteLength;for(var q=0,J=p.length;q<J;q++){var ee=p[q],re=ee.unit,Z=ee.pts;if(W!==null){var X=m[q-1];X.duration=Math.round((Z-W)/d)}else if(r&&e.segmentCodec==="aac"&&(Z=E),U=Z,B>0){B+=y;try{K=new Uint8Array(B)}catch(le){this.observer.emit(x.ERROR,x.ERROR,{type:V.MUX_ERROR,details:_.REMUX_ALLOC_ERROR,fatal:!1,error:le,bytes:B,reason:"fail allocating audio mdat "+B});return}if(!v){var Pe=new DataView(K.buffer);Pe.setUint32(0,B),K.set(fe.types.mdat,4)}}else return;K.set(re,y);var Ee=re.byteLength;y+=Ee,m.push(new Ii(!0,f,Ee,0)),W=Z}var te=m.length;if(te){var ce=m[m.length-1];this.nextAudioPts=E=W+d*ce.duration;var ve=v?new Uint8Array(0):fe.moof(e.sequenceNumber++,U/d,ye({},e,{samples:m}));e.samples=[];var ie=U/l,z=E/l,pe="audio",de={data1:ve,data2:K,startPTS:ie,endPTS:z,startDTS:ie,endDTS:z,type:pe,hasAudio:!0,hasVideo:!1,nb:te};return this.isAudioContiguous=!0,de}},n.remuxEmptyAudio=function(e,t,r,s){var o=e.inputTimeScale,l=e.samplerate?e.samplerate:o,u=o/l,d=this.nextAudioPts,f=this._initDTS,h=f.baseTime*9e4/f.timescale,c=(d!==null?d:s.startDTS*o)+h,v=s.endDTS*o+h,m=u*Ai,g=Math.ceil((v-c)/m),p=Li.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(A.warn("[mp4-remuxer]: remux empty Audio"),!p){A.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var y=[],E=0;E<g;E++){var S=c+E*m;y.push({unit:p,pts:S,dts:S})}return e.samples=y,this.remuxAudio(e,t,r,!1)},a}();function Le(a,n){var i;if(n===null)return a;for(n<a?i=-8589934592:i=8589934592;Math.abs(a-n)>4294967296;)a+=i;return a}function Ps(a){for(var n=0;n<a.length;n++)if(a[n].key)return n;return-1}function Ri(a,n,i,e){var t=a.samples.length;if(t){for(var r=a.inputTimeScale,s=0;s<t;s++){var o=a.samples[s];o.pts=Le(o.pts-i.baseTime*r/i.timescale,n*r)/r,o.dts=Le(o.dts-e.baseTime*r/e.timescale,n*r)/r}var l=a.samples;return a.samples=[],{samples:l}}}function bi(a,n,i){var e=a.samples.length;if(e){for(var t=a.inputTimeScale,r=0;r<e;r++){var s=a.samples[r];s.pts=Le(s.pts-i.baseTime*t/i.timescale,n*t)/t}a.samples.sort(function(l,u){return l.pts-u.pts});var o=a.samples;return a.samples=[],{samples:o}}}var Ii=function(n,i,e,t){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=e,this.cts=t,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:n?2:1,isNonSync:n?0:1}},ws=function(){function a(){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 n=a.prototype;return n.destroy=function(){},n.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},n.resetNextTimestamp=function(){this.lastEndTime=null},n.resetInitSegment=function(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(yn(e,s)),this.emitInitSegment=!0},n.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}var s=this.initData=Er(e);s.audio&&(t=_i(s.audio,$.AUDIO)),s.video&&(r=_i(s.video,$.VIDEO));var o={};s.audio&&s.video?o.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?o.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?o.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:A.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},n.remux=function(e,t,r,s,o,l){var u,d,f=this.initPTS,h=this.lastEndTime,c={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};O(h)||(h=this.lastEndTime=o||0);var v=t.samples;if(!(v!=null&&v.length))return c;var m={initPTS:void 0,timescale:1},g=this.initData;if((u=g)!=null&&u.length||(this.generateInitSegment(v),g=this.initData),!((d=g)!=null&&d.length))return A.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(m.tracks=this.initTracks,this.emitInitSegment=!1);var p=Tn(v,g),y=xn(g,v),E=y===null?o:y;(ks(f,E,o,p)||m.timescale!==f.timescale&&l)&&(m.initPTS=E-o,f&&f.timescale===1&&A.warn("Adjusting initPTS by "+(m.initPTS-f.baseTime)),this.initPTS=f={baseTime:m.initPTS,timescale:1});var S=e?E-f.baseTime/f.timescale:h,L=S+p;Ln(g,v,f.baseTime/f.timescale),p>0?this.lastEndTime=L:(A.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var D=!!g.audio,R=!!g.video,T="";D&&(T+="audio"),R&&(T+="video");var b={data1:v,startPTS:S,startDTS:S,endPTS:L,endDTS:L,type:T,hasAudio:D,hasVideo:R,nb:1,dropped:0};return c.audio=b.type==="audio"?b:void 0,c.video=b.type!=="audio"?b:void 0,c.initSegment=m,c.id3=Ri(r,o,f,f),s.samples.length&&(c.text=bi(s,o,f)),c},a}();function ks(a,n,i,e){if(a===null)return!0;var t=Math.max(e,1),r=n-a.baseTime/a.timescale;return Math.abs(r-i)>t}function _i(a,n){var i=a?.codec;if(i&&i.length>4)return i;if(n===$.AUDIO){if(i==="ec-3"||i==="ac-3"||i==="alac")return i;if(i==="fLaC"||i==="Opus"){var e=!1;return it(i,e)}var t="mp4a.40.5";return A.info('Parsed audio codec "'+i+'" or audio object type not handled. Using "'+t+'"'),t}return A.warn('Unhandled video codec "'+i+'"'),i==="hvc1"||i==="hev1"?"hvc1.1.6.L120.90":i==="av01"?"av01.0.04M.08":"avc1.42e01e"}var Di=typeof self<"u"?self:void 0,Ce;try{Ce=self.performance.now.bind(self.performance)}catch{A.debug("Unable to use Performance API on this environment"),Ce=Di?.Date.now}var qt=[{demux:ps,remux:ws},{demux:Ss,remux:Yt},{demux:gs,remux:Yt},{demux:Rs,remux:Yt}],jt=function(){function a(i,e,t,r,s){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=i,this.typeSupported=e,this.config=t,this.vendor=r,this.id=s}var n=a.prototype;return n.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},n.push=function(e,t,r,s){var o=this,l=r.transmuxing;l.executeStart=Ce();var u=new Uint8Array(e),d=this.currentTransmuxState,f=this.transmuxConfig;s&&(this.currentTransmuxState=s);var h=s||d,c=h.contiguous,v=h.discontinuity,m=h.trackSwitch,g=h.accurateTimeOffset,p=h.timeOffset,y=h.initSegmentChange,E=f.audioCodec,S=f.videoCodec,L=f.defaultInitPts,D=f.duration,R=f.initSegmentData,T=Fs(u,t);if(T&&T.method==="AES-128"){var b=this.getDecrypter();if(b.isSync()){var I=b.softwareDecrypt(u,T.key.buffer,T.iv.buffer),P=r.part>-1;if(P&&(I=b.flush()),!I)return l.executeEnd=Ce(),Xt(r);u=new Uint8Array(I)}else return this.decryptionPromise=b.webCryptoDecrypt(u,T.key.buffer,T.iv.buffer).then(function(H){var U=o.push(H,null,r);return o.decryptionPromise=null,U}),this.decryptionPromise}var C=this.needsProbing(v,m);if(C){var w=this.configureTransmuxer(u);if(w)return A.warn("[transmuxer] "+w.message),this.observer.emit(x.ERROR,x.ERROR,{type:V.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,fatal:!1,error:w,reason:w.message}),l.executeEnd=Ce(),Xt(r)}(v||m||y||C)&&this.resetInitSegment(R,E,S,D,t),(v||y||C)&&this.resetInitialTimestamp(L),c||this.resetContiguity();var M=this.transmux(u,T,p,g,r),F=this.currentTransmuxState;return F.contiguous=!0,F.discontinuity=!1,F.trackSwitch=!1,l.executeEnd=Ce(),M},n.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=Ce();var s=this.decrypter,o=this.currentTransmuxState,l=this.decryptionPromise;if(l)return l.then(function(){return t.flush(e)});var u=[],d=o.timeOffset;if(s){var f=s.flush();f&&u.push(this.push(f,null,e))}var h=this.demuxer,c=this.remuxer;if(!h||!c)return r.executeEnd=Ce(),[Xt(e)];var v=h.flush(d);return Be(v)?v.then(function(m){return t.flushRemux(u,m,e),u}):(this.flushRemux(u,v,e),u)},n.flushRemux=function(e,t,r){var s=t.audioTrack,o=t.videoTrack,l=t.id3Track,u=t.textTrack,d=this.currentTransmuxState,f=d.accurateTimeOffset,h=d.timeOffset;A.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var c=this.remuxer.remux(s,o,l,u,h,f,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=Ce()},n.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))},n.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())},n.resetInitSegment=function(e,t,r,s,o){var l=this.demuxer,u=this.remuxer;!l||!u||(l.resetInitSegment(e,t,r,s),u.resetInitSegment(e,t,r,o))},n.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},n.transmux=function(e,t,r,s,o){var l;return t&&t.method==="SAMPLE-AES"?l=this.transmuxSampleAes(e,t,r,s,o):l=this.transmuxUnencrypted(e,r,s,o),l},n.transmuxUnencrypted=function(e,t,r,s){var o=this.demuxer.demux(e,t,!1,!this.config.progressive),l=o.audioTrack,u=o.videoTrack,d=o.id3Track,f=o.textTrack,h=this.remuxer.remux(l,u,d,f,t,r,!1,this.id);return{remuxResult:h,chunkMeta:s}},n.transmuxSampleAes=function(e,t,r,s,o){var l=this;return this.demuxer.demuxSampleAes(e,t,r).then(function(u){var d=l.remuxer.remux(u.audioTrack,u.videoTrack,u.id3Track,u.textTrack,r,s,!1,l.id);return{remuxResult:d,chunkMeta:o}})},n.configureTransmuxer=function(e){for(var t=this.config,r=this.observer,s=this.typeSupported,o=this.vendor,l,u=0,d=qt.length;u<d;u++){var f;if((f=qt[u].demux)!=null&&f.probe(e)){l=qt[u];break}}if(!l)return new Error("Failed to find demuxer by probing fragment data");var h=this.demuxer,c=this.remuxer,v=l.remux,m=l.demux;(!c||!(c instanceof v))&&(this.remuxer=new v(r,t,s,o)),(!h||!(h instanceof m))&&(this.demuxer=new m(r,t,s),this.probe=m.probe)},n.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},n.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new Ut(this.config)),e},a}();function Fs(a,n){var i=null;return a.byteLength>0&&n?.key!=null&&n.iv!==null&&n.method!=null&&(i=n),i}var Xt=function(n){return{remuxResult:{},chunkMeta:n}};function Be(a){return"then"in a&&a.then instanceof Function}var Os=function(n,i,e,t,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=n,this.videoCodec=i,this.initSegmentData=e,this.duration=t,this.defaultInitPts=r||null},Ms=function(n,i,e,t,r,s){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=n,this.contiguous=i,this.accurateTimeOffset=e,this.trackSwitch=t,this.timeOffset=r,this.initSegmentChange=s},Ci={exports:{}};(function(a){var n=Object.prototype.hasOwnProperty,i="~";function e(){}Object.create&&(e.prototype=Object.create(null),new e().__proto__||(i=!1));function t(l,u,d){this.fn=l,this.context=u,this.once=d||!1}function r(l,u,d,f,h){if(typeof d!="function")throw new TypeError("The listener must be a function");var c=new t(d,f||l,h),v=i?i+u:u;return l._events[v]?l._events[v].fn?l._events[v]=[l._events[v],c]:l._events[v].push(c):(l._events[v]=c,l._eventsCount++),l}function s(l,u){--l._eventsCount===0?l._events=new e:delete l._events[u]}function o(){this._events=new e,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)n.call(d,f)&&u.push(i?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},o.prototype.listeners=function(u){var d=i?i+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var h=0,c=f.length,v=new Array(c);h<c;h++)v[h]=f[h].fn;return v},o.prototype.listenerCount=function(u){var d=i?i+u:u,f=this._events[d];return f?f.fn?1:f.length:0},o.prototype.emit=function(u,d,f,h,c,v){var m=i?i+u:u;if(!this._events[m])return!1;var g=this._events[m],p=arguments.length,y,E;if(g.fn){switch(g.once&&this.removeListener(u,g.fn,void 0,!0),p){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,d),!0;case 3:return g.fn.call(g.context,d,f),!0;case 4:return g.fn.call(g.context,d,f,h),!0;case 5:return g.fn.call(g.context,d,f,h,c),!0;case 6:return g.fn.call(g.context,d,f,h,c,v),!0}for(E=1,y=new Array(p-1);E<p;E++)y[E-1]=arguments[E];g.fn.apply(g.context,y)}else{var S=g.length,L;for(E=0;E<S;E++)switch(g[E].once&&this.removeListener(u,g[E].fn,void 0,!0),p){case 1:g[E].fn.call(g[E].context);break;case 2:g[E].fn.call(g[E].context,d);break;case 3:g[E].fn.call(g[E].context,d,f);break;case 4:g[E].fn.call(g[E].context,d,f,h);break;default:if(!y)for(L=1,y=new Array(p-1);L<p;L++)y[L-1]=arguments[L];g[E].fn.apply(g[E].context,y)}}return!0},o.prototype.on=function(u,d,f){return r(this,u,d,f,!1)},o.prototype.once=function(u,d,f){return r(this,u,d,f,!0)},o.prototype.removeListener=function(u,d,f,h){var c=i?i+u:u;if(!this._events[c])return this;if(!d)return s(this,c),this;var v=this._events[c];if(v.fn)v.fn===d&&(!h||v.once)&&(!f||v.context===f)&&s(this,c);else{for(var m=0,g=[],p=v.length;m<p;m++)(v[m].fn!==d||h&&!v[m].once||f&&v[m].context!==f)&&g.push(v[m]);g.length?this._events[c]=g.length===1?g[0]:g:s(this,c)}return this},o.prototype.removeAllListeners=function(u){var d;return u?(d=i?i+u:u,this._events[d]&&s(this,d)):(this._events=new e,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,o.EventEmitter=o,a.exports=o})(Ci);var Ns=Ci.exports,zt=nr(Ns);typeof tr<"u"&&tr&&Bs(self);function Bs(a){var n=new zt,i=function(r,s){a.postMessage({event:r,data:s})};n.on(x.FRAG_DECRYPTED,i),n.on(x.ERROR,i);var e=function(){var r=function(l){var u=function(f){i("workerLog",{logType:l,message:f})};A[l]=u};for(var s in A)r(s)};a.addEventListener("message",function(t){var r=t.data;switch(r.cmd){case"init":{var s=JSON.parse(r.config);a.transmuxer=new jt(n,r.typeSupported,s,r.vendor,r.id),sr(s.debug,r.id),e(),i("init",null);break}case"configure":{a.transmuxer.configure(r.config);break}case"demux":{var o=a.transmuxer.push(r.data,r.decryptdata,r.chunkMeta,r.state);Be(o)?(a.transmuxer.async=!0,o.then(function(f){$t(a,f)}).catch(function(f){i(x.ERROR,{type:V.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,chunkMeta:r.chunkMeta,fatal:!1,error:f,err:f,reason:"transmuxer-worker push error"})})):(a.transmuxer.async=!1,$t(a,o));break}case"flush":{var l=r.chunkMeta,u=a.transmuxer.flush(l),d=Be(u);d||a.transmuxer.async?(Be(u)||(u=Promise.resolve(u)),u.then(function(f){wi(a,f,l)}).catch(function(f){i(x.ERROR,{type:V.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,chunkMeta:r.chunkMeta,fatal:!1,error:f,err:f,reason:"transmuxer-worker flush error"})})):wi(a,u,l);break}}})}function $t(a,n){if(Us(n.remuxResult))return!1;var i=[],e=n.remuxResult,t=e.audio,r=e.video;return t&&Pi(i,t),r&&Pi(i,r),a.postMessage({event:"transmuxComplete",data:n},i),!0}function Pi(a,n){n.data1&&a.push(n.data1.buffer),n.data2&&a.push(n.data2.buffer)}function wi(a,n,i){var e=n.reduce(function(t,r){return $t(a,r)||t},!1);e||a.postMessage({event:"transmuxComplete",data:n[0]}),a.postMessage({event:"flush",data:i})}function Us(a){return!a.audio&&!a.video&&!a.text&&!a.id3&&!a.initSegment}function Gs(){return typeof er=="function"}function Hs(){var a=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+er.toString()+")(true);"],{type:"text/javascript"}),n=self.URL.createObjectURL(a),i=new self.Worker(n);return{worker:i,objectURL:n}}function Vs(a){var n=new self.URL(a,self.location.href).href,i=new self.Worker(n);return{worker:i,scriptURL:n}}var Ks=function(){function a(i,e,t,r){var s=this;this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var o=i.config;this.hls=i,this.id=e,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=t,this.onFlush=r;var l=function(m,g){g=g||{},g.frag=s.frag,g.id=s.id,m===x.ERROR&&(s.error=g.error),s.hls.trigger(m,g)};this.observer=new zt,this.observer.on(x.FRAG_DECRYPTED,l),this.observer.on(x.ERROR,l);var u=Ne(o.preferManagedMediaSource)||{isTypeSupported:function(){return!1}},d={mpeg:u.isTypeSupported("audio/mpeg"),mp3:u.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1},f=navigator.vendor;if(this.useWorker&&typeof Worker<"u"){var h=o.workerPath||Gs();if(h){try{o.workerPath?(A.log("loading Web Worker "+o.workerPath+' for "'+e+'"'),this.workerContext=Vs(o.workerPath)):(A.log('injecting Web Worker for "'+e+'"'),this.workerContext=Hs()),this.onwmsg=function(v){return s.onWorkerMessage(v)};var c=this.workerContext.worker;c.addEventListener("message",this.onwmsg),c.onerror=function(v){var m=new Error(v.message+" ("+v.filename+":"+v.lineno+")");o.enableWorker=!1,A.warn('Error in "'+e+'" Web Worker, fallback to inline'),s.hls.trigger(x.ERROR,{type:V.OTHER_ERROR,details:_.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:m})},c.postMessage({cmd:"init",typeSupported:d,vendor:f,id:e,config:JSON.stringify(o)})}catch(v){A.warn('Error setting up "'+e+'" Web Worker, fallback to inline',v),this.resetWorker(),this.error=null,this.transmuxer=new jt(this.observer,d,o,f,e)}return}}this.transmuxer=new jt(this.observer,d,o,f,e)}var n=a.prototype;return n.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,r=e.objectURL;r&&self.URL.revokeObjectURL(r),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},n.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},n.push=function(e,t,r,s,o,l,u,d,f,h){var c,v,m=this;f.transmuxing.start=self.performance.now();var g=this.transmuxer,p=l?l.start:o.start,y=o.decryptdata,E=this.frag,S=!(E&&o.cc===E.cc),L=!(E&&f.level===E.level),D=E?f.sn-E.sn:-1,R=this.part?f.part-this.part.index:-1,T=D===0&&f.id>1&&f.id===E?.stats.chunkCount,b=!L&&(D===1||D===0&&(R===1||T&&R<=0)),I=self.performance.now();(L||D||o.stats.parsing.start===0)&&(o.stats.parsing.start=I),l&&(R||!b)&&(l.stats.parsing.start=I);var P=!(E&&((c=o.initSegment)==null?void 0:c.url)===((v=E.initSegment)==null?void 0:v.url)),C=new Ms(S,b,d,L,p,P);if(!b||S||P){A.log("[transmuxer-interface, "+o.type+"]: Starting new transmux session for sn: "+f.sn+" p: "+f.part+" level: "+f.level+" id: "+f.id+`
|
9
|
-
discontinuity: `+S+`
|
10
|
-
trackSwitch: `+L+`
|
11
|
-
contiguous: `+b+`
|
12
|
-
accurateTimeOffset: `+d+`
|
13
|
-
timeOffset: `+p+`
|
14
|
-
initSegmentChange: `+P);var w=new Os(r,s,t,u,h);this.configureTransmuxer(w)}if(this.frag=o,this.part=l,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:y,chunkMeta:f,state:C},e instanceof ArrayBuffer?[e]:[]);else if(g){var M=g.push(e,y,f,C);Be(M)?(g.async=!0,M.then(function(F){m.handleTransmuxComplete(F)}).catch(function(F){m.transmuxerError(F,f,"transmuxer-interface push error")})):(g.async=!1,this.handleTransmuxComplete(M))}},n.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(r){var s=r.flush(e),o=Be(s);o||r.async?(Be(s)||(s=Promise.resolve(s)),s.then(function(l){t.handleFlushResult(l,e)}).catch(function(l){t.transmuxerError(l,e,"transmuxer-interface flush error")})):this.handleFlushResult(s,e)}},n.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:r}))},n.handleFlushResult=function(e,t){var r=this;e.forEach(function(s){r.handleTransmuxComplete(s)}),this.onFlush(t)},n.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":{var s,o=(s=this.workerContext)==null?void 0:s.objectURL;o&&self.URL.revokeObjectURL(o);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":A[t.data.logType]&&A[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}},n.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},n.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},a}(),Ws=250,vt=2,Ys=.1,qs=.05,js=function(){function a(i,e,t,r){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=i,this.media=e,this.fragmentTracker=t,this.hls=r}var n=a.prototype;return n.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},n.poll=function(e,t){var r=this.config,s=this.media,o=this.stalled;if(s!==null){var l=s.currentTime,u=s.seeking,d=this.seeking&&!u,f=!this.seeking&&u;if(this.seeking=u,l!==e){if(this.moved=!0,u||(this.nudgeRetry=0),o!==null){if(this.stallReported){var h=self.performance.now()-o;A.warn("playback not stuck anymore @"+l+", after "+Math.round(h)+"ms"),this.stallReported=!1}this.stalled=null}return}if(f||d){this.stalled=null;return}if(s.paused&&!u||s.ended||s.playbackRate===0||!ae.getBuffered(s).length){this.nudgeRetry=0;return}var c=ae.bufferInfo(s,l,0),v=c.nextStart||0;if(u){var m=c.len>vt,g=!v||t&&t.start<=l||v-l>vt&&!this.fragmentTracker.getPartialFragment(l);if(m||g)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var p,y=c.len>0;if(!y&&!v)return;var E=Math.max(v,c.start||0)-l,S=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,L=S==null||(p=S.details)==null?void 0:p.live,D=L?S.details.targetduration*2:vt,R=this.fragmentTracker.getPartialFragment(l);if(E>0&&(E<=D||R)){s.paused||this._trySkipBufferHole(R);return}}var T=self.performance.now();if(o===null){this.stalled=T;return}var b=T-o;if(!(!u&&b>=Ws&&(this._reportStall(c),!this.media))){var I=ae.bufferInfo(s,l,r.maxBufferHole);this._tryFixBufferStall(I,b)}}},n._tryFixBufferStall=function(e,t){var r=this.config,s=this.fragmentTracker,o=this.media;if(o!==null){var l=o.currentTime,u=s.getPartialFragment(l);if(u){var d=this._trySkipBufferHole(u);if(d||!this.media)return}(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-l<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(A.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},n._reportStall=function(e){var t=this.hls,r=this.media,s=this.stallReported;if(!s&&r){this.stallReported=!0;var o=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")");A.warn(o.message),t.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:_.BUFFER_STALLED_ERROR,fatal:!1,error:o,buffer:e.len})}},n._trySkipBufferHole=function(e){var t=this.config,r=this.hls,s=this.media;if(s===null)return 0;var o=s.currentTime,l=ae.bufferInfo(s,o,0),u=o<l.start?l.start:l.nextStart;if(u){var d=l.len<=t.maxBufferHole,f=l.len>0&&l.len<1&&s.readyState<3,h=u-o;if(h>0&&(d||f)){if(h>t.maxBufferHole){var c=this.fragmentTracker,v=!1;if(o===0){var m=c.getAppendedFrag(0,j.MAIN);m&&u<m.end&&(v=!0)}if(!v){var g=e||c.getAppendedFrag(o,j.MAIN);if(g){for(var p=!1,y=g.end;y<u;){var E=c.getPartialFragment(y);if(E)y+=E.duration;else{p=!0;break}}if(p)return 0}}}var S=Math.max(u+qs,o+Ys);if(A.warn("skipping hole, adjusting currentTime from "+o+" to "+S),this.moved=!0,this.stalled=null,s.currentTime=S,e&&!e.gap){var L=new Error("fragment loaded with buffer holes, seeking from "+o+" to "+S);r.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:_.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:L,reason:L.message,frag:e})}return S}}return 0},n._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,s=this.nudgeRetry;if(r!==null){var o=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){var l=o+(s+1)*e.nudgeOffset,u=new Error("Nudging 'currentTime' from "+o+" to "+l);A.warn(u.message),r.currentTime=l,t.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:_.BUFFER_NUDGE_ON_STALL,error:u,fatal:!1})}else{var d=new Error("Playhead still not moving while enough data buffered @"+o+" after "+e.nudgeMaxRetry+" nudges");A.error(d.message),t.trigger(x.ERROR,{type:V.MEDIA_ERROR,details:_.BUFFER_STALLED_ERROR,error:d,fatal:!0})}}},a}(),Xs=100,zs=function(a){Re(n,a);function n(e,t,r){var s;return s=a.call(this,e,t,r,"[stream-controller]",j.MAIN)||this,s.audioCodecSwap=!1,s.gapController=null,s.level=-1,s._forceStartLoad=!1,s.altAudio=!1,s.audioOnly=!1,s.fragPlaying=null,s.onvplaying=null,s.onvseeked=null,s.fragLastKbps=0,s.couldBacktrack=!1,s.backtrackFragment=null,s.audioCodecSwitch=!1,s.videoBuffer=null,s._registerListeners(),s}var i=n.prototype;return i._registerListeners=function(){var t=this.hls;t.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.MANIFEST_PARSED,this.onManifestParsed,this),t.on(x.LEVEL_LOADING,this.onLevelLoading,this),t.on(x.LEVEL_LOADED,this.onLevelLoaded,this),t.on(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(x.ERROR,this.onError,this),t.on(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(x.BUFFER_CREATED,this.onBufferCreated,this),t.on(x.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(x.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var t=this.hls;t.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.MANIFEST_PARSED,this.onManifestParsed,this),t.off(x.LEVEL_LOADED,this.onLevelLoaded,this),t.off(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(x.ERROR,this.onError,this),t.off(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(x.BUFFER_CREATED,this.onBufferCreated,this),t.off(x.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(x.FRAG_BUFFERED,this.onFragBuffered,this)},i.onHandlerDestroying=function(){this._unregisterListeners(),a.prototype.onHandlerDestroying.call(this)},i.startLoad=function(t){if(this.levels){var r=this.lastCurrentTime,s=this.hls;if(this.stopLoad(),this.setInterval(Xs),this.level=-1,!this.startFragRequested){var o=s.startLevel;o===-1&&(s.config.testBandwidth&&this.levels.length>1?(o=0,this.bitrateTest=!0):o=s.firstAutoLevel),s.nextLoadLevel=o,this.level=s.loadLevel,this.loadedmetadata=!1}r>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),t=r),this.state=k.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=k.STOPPED},i.stopLoad=function(){this._forceStartLoad=!1,a.prototype.stopLoad.call(this)},i.doTick=function(){switch(this.state){case k.WAITING_LEVEL:{var t=this.levels,r=this.level,s=t?.[r],o=s?.details;if(o&&(!o.live||this.levelLastLoaded===s)){if(this.waitForCdnTuneIn(o))break;this.state=k.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=k.IDLE;break}break}case k.FRAG_LOADING_WAITING_RETRY:{var l,u=self.performance.now(),d=this.retryDate;if(!d||u>=d||(l=this.media)!=null&&l.seeking){var f=this.levels,h=this.level,c=f?.[h];this.resetStartWhenNotLoaded(c||null),this.state=k.IDLE}}break}this.state===k.IDLE&&this.doTickIdle(),this.onTickEnd()},i.onTickEnd=function(){a.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},i.doTickIdle=function(){var t=this.hls,r=this.levelLastLoaded,s=this.levels,o=this.media;if(!(r===null||!o&&(this.startFragRequested||!t.config.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)){var l=t.nextLoadLevel;if(s!=null&&s[l]){var u=s[l],d=this.getMainFwdBufferInfo();if(d!==null){var f=this.getLevelDetails();if(f&&this._streamEnded(d,f)){var h={};this.altAudio&&(h.type="video"),this.hls.trigger(x.BUFFER_EOS,h),this.state=k.ENDED;return}t.loadLevel!==l&&t.manualLevel===-1&&this.log("Adapting to level "+l+" from level "+this.level),this.level=t.nextLoadLevel=l;var c=u.details;if(!c||this.state===k.WAITING_LEVEL||c.live&&this.levelLastLoaded!==u){this.level=l,this.state=k.WAITING_LEVEL;return}var v=d.len,m=this.getMaxBufferLength(u.maxBitrate);if(!(v>=m)){this.backtrackFragment&&this.backtrackFragment.start>d.end&&(this.backtrackFragment=null);var g=this.backtrackFragment?this.backtrackFragment.start:d.end,p=this.getNextFragment(g,c);if(this.couldBacktrack&&!this.fragPrevious&&p&&p.sn!=="initSegment"&&this.fragmentTracker.getState(p)!==me.OK){var y,E=((y=this.backtrackFragment)!=null?y:p).sn,S=E-c.startSN,L=c.fragments[S-1];L&&p.cc===L.cc&&(p=L,this.fragmentTracker.removeFragment(L))}else this.backtrackFragment&&d.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,g)){var D=p.gap;if(!D){var R=this.audioOnly&&!this.altAudio?$.AUDIO:$.VIDEO,T=(R===$.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;T&&this.afterBufferFlushed(T,R,j.MAIN)}p=this.getNextFragmentLoopLoading(p,c,d,j.MAIN,m)}p&&(p.initSegment&&!p.initSegment.data&&!this.bitrateTest&&(p=p.initSegment),this.loadFragment(p,u,g))}}}}},i.loadFragment=function(t,r,s){var o=this.fragmentTracker.getState(t);this.fragCurrent=t,o===me.NOT_LOADED||o===me.PARTIAL?t.sn==="initSegment"?this._loadInitSegment(t,r):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)):(this.startFragRequested=!0,a.prototype.loadFragment.call(this,t,r,s)):this.clearTrackerIfNeeded(t)},i.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,j.MAIN)},i.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},i.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},i.nextLevelSwitch=function(){var t=this.levels,r=this.media;if(r!=null&&r.readyState){var s,o=this.getAppendedFrag(r.currentTime);o&&o.start>1&&this.flushMainBuffer(0,o.start-1);var l=this.getLevelDetails();if(l!=null&&l.live){var u=this.getMainFwdBufferInfo();if(!u||u.len<l.targetduration*2)return}if(!r.paused&&t){var d=this.hls.nextLoadLevel,f=t[d],h=this.fragLastKbps;h&&this.fragCurrent?s=this.fragCurrent.duration*f.maxBitrate/(1e3*h)+1:s=0}else s=0;var c=this.getBufferedFrag(r.currentTime+s);if(c){var v=this.followingBufferedFrag(c);if(v){this.abortCurrentFrag();var m=v.maxStartPTS?v.maxStartPTS:v.start,g=v.duration,p=Math.max(c.end,m+Math.min(Math.max(g-this.config.maxFragLookUpTolerance,g*(this.couldBacktrack?.5:.125)),g*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(p,Number.POSITIVE_INFINITY)}}}},i.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case k.KEY_LOADING:case k.FRAG_LOADING:case k.FRAG_LOADING_WAITING_RETRY:case k.PARSING:case k.PARSED:this.state=k.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},i.flushMainBuffer=function(t,r){a.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},i.onMediaAttached=function(t,r){a.prototype.onMediaAttached.call(this,t,r);var s=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),s.addEventListener("playing",this.onvplaying),s.addEventListener("seeked",this.onvseeked),this.gapController=new js(this.config,s,this.fragmentTracker,this.hls)},i.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),a.prototype.onMediaDetaching.call(this)},i.onMediaPlaying=function(){this.tick()},i.onMediaSeeked=function(){var t=this.media,r=t?t.currentTime:null;O(r)&&this.log("Media seeked to "+r.toFixed(3));var s=this.getMainFwdBufferInfo();if(s===null||s.len===0){this.warn('Main forward buffer length on "seeked" event '+(s?s.len:"empty")+")");return}this.tick()},i.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(x.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1},i.onManifestParsed=function(t,r){var s=!1,o=!1;r.levels.forEach(function(l){var u=l.audioCodec;u&&(s=s||u.indexOf("mp4a.40.2")!==-1,o=o||u.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=s&&o&&!is(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},i.onLevelLoading=function(t,r){var s=this.levels;if(!(!s||this.state!==k.IDLE)){var o=s[r.level];(!o.details||o.details.live&&this.levelLastLoaded!==o||this.waitForCdnTuneIn(o.details))&&(this.state=k.WAITING_LEVEL)}},i.onLevelLoaded=function(t,r){var s,o=this.levels,l=r.level,u=r.details,d=u.totalduration;if(!o){this.warn("Levels were reset while loading level "+l);return}this.log("Level "+l+" loaded ["+u.startSN+","+u.endSN+"]"+(u.lastPartSn?"[part-"+u.lastPartSn+"-"+u.lastPartIndex+"]":"")+", cc ["+u.startCC+", "+u.endCC+"] duration:"+d);var f=o[l],h=this.fragCurrent;h&&(this.state===k.FRAG_LOADING||this.state===k.FRAG_LOADING_WAITING_RETRY)&&h.level!==r.level&&h.loader&&this.abortCurrentFrag();var c=0;if(u.live||(s=f.details)!=null&&s.live){var v;if(this.checkLiveUpdate(u),u.deltaUpdateFailed)return;c=this.alignPlaylists(u,f.details,(v=this.levelLastLoaded)==null?void 0:v.details)}if(f.details=u,this.levelLastLoaded=f,this.hls.trigger(x.LEVEL_UPDATED,{details:u,level:l}),this.state===k.WAITING_LEVEL){if(this.waitForCdnTuneIn(u))return;this.state=k.IDLE}this.startFragRequested?u.live&&this.synchronizeToLiveEdge(u):this.setStartPosition(u,c),this.tick()},i._handleFragmentLoadProgress=function(t){var r,s=t.frag,o=t.part,l=t.payload,u=this.levels;if(!u){this.warn("Levels were reset while fragment load was in progress. Fragment "+s.sn+" of level "+s.level+" will not be buffered");return}var d=u[s.level],f=d.details;if(!f){this.warn("Dropping fragment "+s.sn+" of level "+s.level+" after level details were reset"),this.fragmentTracker.removeFragment(s);return}var h=d.videoCodec,c=f.PTSKnown||!f.live,v=(r=s.initSegment)==null?void 0:r.data,m=this._getAudioCodec(d),g=this.transmuxer=this.transmuxer||new Ks(this.hls,j.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),p=o?o.index:-1,y=p!==-1,E=new oi(s.level,s.sn,s.stats.chunkCount,l.byteLength,p,y),S=this.initPTS[s.cc];g.push(l,v,m,h,s,o,f.totalduration,c,E,S)},i.onAudioTrackSwitching=function(t,r){var s=this.altAudio,o=!!r.url;if(!o){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var l=this.fragCurrent;l&&(this.log("Switching to main audio track, cancel main fragment load"),l.abortRequests(),this.fragmentTracker.removeFragment(l)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var u=this.hls;s&&(u.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),u.trigger(x.AUDIO_TRACK_SWITCHED,r)}},i.onAudioTrackSwitched=function(t,r){var s=r.id,o=!!this.hls.audioTracks[s].url;if(o){var l=this.videoBuffer;l&&this.mediaBuffer!==l&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=l)}this.altAudio=o,this.tick()},i.onBufferCreated=function(t,r){var s=r.tracks,o,l,u=!1;for(var d in s){var f=s[d];if(f.id==="main"){if(l=d,o=f,d==="video"){var h=s[d];h&&(this.videoBuffer=h.buffer)}}else u=!0}u&&o?(this.log("Alternate track found, use "+l+".buffered to schedule main fragment loading"),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media},i.onFragBuffered=function(t,r){var s=r.frag,o=r.part;if(!(s&&s.type!==j.MAIN)){if(this.fragContextChanged(s)){this.warn("Fragment "+s.sn+(o?" p: "+o.index:"")+" of level "+s.level+" finished buffering, but was aborted. state: "+this.state),this.state===k.PARSED&&(this.state=k.IDLE);return}var l=o?o.stats:s.stats;this.fragLastKbps=Math.round(8*l.total/(l.buffering.end-l.loading.first)),s.sn!=="initSegment"&&(this.fragPrevious=s),this.fragBufferedComplete(s,o)}},i.onError=function(t,r){var s;if(r.fatal){this.state=k.ERROR;return}switch(r.details){case _.FRAG_GAP:case _.FRAG_PARSING_ERROR:case _.FRAG_DECRYPT_ERROR:case _.FRAG_LOAD_ERROR:case _.FRAG_LOAD_TIMEOUT:case _.KEY_LOAD_ERROR:case _.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(j.MAIN,r);break;case _.LEVEL_LOAD_ERROR:case _.LEVEL_LOAD_TIMEOUT:case _.LEVEL_PARSING_ERROR:!r.levelRetry&&this.state===k.WAITING_LEVEL&&((s=r.context)==null?void 0:s.type)===Y.LEVEL&&(this.state=k.IDLE);break;case _.BUFFER_APPEND_ERROR:case _.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="main")return;if(r.details===_.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case _.INTERNAL_EXCEPTION:this.recoverWorkerError(r);break}},i.checkBuffer=function(){var t=this.media,r=this.gapController;if(!(!t||!r||!t.readyState)){if(this.loadedmetadata||!ae.getBuffered(t).length){var s=this.state!==k.IDLE?this.fragCurrent:null;r.poll(this.lastCurrentTime,s)}this.lastCurrentTime=t.currentTime}},i.onFragLoadEmergencyAborted=function(){this.state=k.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},i.onBufferFlushed=function(t,r){var s=r.type;if(s!==$.AUDIO||this.audioOnly&&!this.altAudio){var o=(s===$.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(o,s,j.MAIN),this.tick()}},i.onLevelsUpdated=function(t,r){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=r.levels},i.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},i.seekToStartPos=function(){var t=this.media;if(t){var r=t.currentTime,s=this.startPosition;if(s>=0&&r<s){if(t.seeking){this.log("could not seek to "+s+", already seeking at "+r);return}var o=ae.getBuffered(t),l=o.length?o.start(0):0,u=l-s;u>0&&(u<this.config.maxBufferHole||u<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+u+" to match buffer start"),s+=u,this.startPosition=s),this.log("seek to target start position "+s+" from current time "+r),t.currentTime=s}}},i._getAudioCodec=function(t){var r=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r.indexOf("mp4a.40.5")!==-1?r="mp4a.40.2":r="mp4a.40.5"),r},i._loadBitrateTestFrag=function(t,r){var s=this;t.bitrateTest=!0,this._doFragLoad(t,r).then(function(o){var l=s.hls;if(!(!o||s.fragContextChanged(t))){r.fragmentError=0,s.state=k.IDLE,s.startFragRequested=!1,s.bitrateTest=!1;var u=t.stats;u.parsing.start=u.parsing.end=u.buffering.start=u.buffering.end=self.performance.now(),l.trigger(x.FRAG_LOADED,o),t.bitrateTest=!1}})},i._handleTransmuxComplete=function(t){var r,s="main",o=this.hls,l=t.remuxResult,u=t.chunkMeta,d=this.getCurrentContext(u);if(!d){this.resetWhenMissingContext(u);return}var f=d.frag,h=d.part,c=d.level,v=l.video,m=l.text,g=l.id3,p=l.initSegment,y=c.details,E=this.altAudio?void 0:l.audio;if(this.fragContextChanged(f)){this.fragmentTracker.removeFragment(f);return}if(this.state=k.PARSING,p){if(p!=null&&p.tracks){var S=f.initSegment||f;this._bufferInitSegment(c,p.tracks,S,u),o.trigger(x.FRAG_PARSING_INIT_SEGMENT,{frag:S,id:s,tracks:p.tracks})}var L=p.initPTS,D=p.timescale;O(L)&&(this.initPTS[f.cc]={baseTime:L,timescale:D},o.trigger(x.INIT_PTS_FOUND,{frag:f,id:s,initPTS:L,timescale:D}))}if(v&&y&&f.sn!=="initSegment"){var R=y.fragments[f.sn-1-y.startSN],T=f.sn===y.startSN,b=!R||f.cc>R.cc;if(l.independent!==!1){var I=v.startPTS,P=v.endPTS,C=v.startDTS,w=v.endDTS;if(h)h.elementaryStreams[v.type]={startPTS:I,endPTS:P,startDTS:C,endDTS:w};else if(v.firstKeyFrame&&v.independent&&u.id===1&&!b&&(this.couldBacktrack=!0),v.dropped&&v.independent){var M=this.getMainFwdBufferInfo(),F=(M?M.end:this.getLoadPosition())+this.config.maxBufferHole,H=v.firstKeyFramePTS?v.firstKeyFramePTS:I;if(!T&&F<H-this.config.maxBufferHole&&!b){this.backtrack(f);return}else b&&(f.gap=!0);f.setElementaryStreamInfo(v.type,f.start,P,f.start,w,!0)}else T&&I>vt&&(f.gap=!0);f.setElementaryStreamInfo(v.type,I,P,C,w),this.backtrackFragment&&(this.backtrackFragment=f),this.bufferFragmentData(v,f,h,u,T||b)}else if(T||b)f.gap=!0;else{this.backtrack(f);return}}if(E){var U=E.startPTS,W=E.endPTS,K=E.startDTS,B=E.endDTS;h&&(h.elementaryStreams[$.AUDIO]={startPTS:U,endPTS:W,startDTS:K,endDTS:B}),f.setElementaryStreamInfo($.AUDIO,U,W,K,B),this.bufferFragmentData(E,f,h,u)}if(y&&g!=null&&(r=g.samples)!=null&&r.length){var Q={id:s,frag:f,details:y,samples:g.samples};o.trigger(x.FRAG_PARSING_METADATA,Q)}if(y&&m){var q={id:s,frag:f,details:y,samples:m.samples};o.trigger(x.FRAG_PARSING_USERDATA,q)}},i._bufferInitSegment=function(t,r,s,o){var l=this;if(this.state===k.PARSING){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var u=r.audio,d=r.video,f=r.audiovideo;if(u){var h=t.audioCodec,c=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(h&&(h.indexOf("mp4a.40.5")!==-1?h="mp4a.40.2":h="mp4a.40.5"),u.metadata.channelCount!==1&&c.indexOf("firefox")===-1&&(h="mp4a.40.5")),h&&h.indexOf("mp4a.40.5")!==-1&&c.indexOf("android")!==-1&&u.container!=="audio/mpeg"&&(h="mp4a.40.2",this.log("Android: force audio codec to "+h)),t.audioCodec&&t.audioCodec!==h&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+h+'"'),u.levelCodec=h,u.id="main",this.log("Init audio buffer, container:"+u.container+", codecs[selected/level/parsed]=["+(h||"")+"/"+(t.audioCodec||"")+"/"+u.codec+"]")}d&&(d.levelCodec=t.videoCodec,d.id="main",this.log("Init video buffer, container:"+d.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+d.codec+"]")),f&&this.log("Init audiovideo buffer, container:"+f.container+", codecs[level/parsed]=["+t.codecs+"/"+f.codec+"]"),this.hls.trigger(x.BUFFER_CODECS,r),Object.keys(r).forEach(function(v){var m=r[v],g=m.initSegment;g!=null&&g.byteLength&&l.hls.trigger(x.BUFFER_APPENDING,{type:v,data:g,frag:s,part:null,chunkMeta:o,parent:s.type})}),this.tickImmediate()}},i.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,j.MAIN)},i.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=k.IDLE},i.checkFragmentChanged=function(){var t=this.media,r=null;if(t&&t.readyState>1&&t.seeking===!1){var s=t.currentTime;if(ae.isBuffered(t,s)?r=this.getAppendedFrag(s):ae.isBuffered(t,s+.1)&&(r=this.getAppendedFrag(s+.1)),r){this.backtrackFragment=null;var o=this.fragPlaying,l=r.level;(!o||r.sn!==o.sn||o.level!==l)&&(this.fragPlaying=r,this.hls.trigger(x.FRAG_CHANGED,{frag:r}),(!o||o.level!==l)&&this.hls.trigger(x.LEVEL_SWITCHED,{level:l}))}}},he(n,[{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 r=t.currentTime,s=this.currentFrag;if(s&&O(r)&&O(s.programDateTime)){var o=s.programDateTime+(r-s.start)*1e3;return new Date(o)}}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}}]),n}(ts),ki=function(){a.isMSESupported=function(){return di()},a.isSupported=function(){return rs()},a.getMediaSource=function(){return Ne()};function a(i){i===void 0&&(i={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new zt,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,sr(i.debug||!1,"Hls instance");var e=this.config=Na(a.DefaultConfig,i);this.userConfig=i,e.progressive&&Ba(e);var t=e.abrController,r=e.bufferController,s=e.capLevelController,o=e.errorController,l=e.fpsController,u=new o(this),d=this.abrController=new t(this),f=this.bufferController=new r(this),h=this.capLevelController=new s(this),c=new l(this),v=new Un(this),m=new jn(this),g=e.contentSteeringController,p=g?new g(this):null,y=this.levelController=new Ua(this,p),E=new Ga(this),S=new Va(this.config),L=this.streamController=new zs(this,E,S);h.setStreamController(L),c.setStreamController(L);var D=[v,y,L];p&&D.splice(1,0,p),this.networkControllers=D;var R=[d,f,h,c,m,E];this.audioTrackController=this.createController(e.audioTrackController,D);var T=e.audioStreamController;T&&D.push(new T(this,E,S)),this.subtitleTrackController=this.createController(e.subtitleTrackController,D);var b=e.subtitleStreamController;b&&D.push(new b(this,E,S)),this.createController(e.timelineController,R),S.emeController=this.emeController=this.createController(e.emeController,R),this.cmcdController=this.createController(e.cmcdController,R),this.latencyController=this.createController(Xn,R),this.coreComponents=R,D.push(u);var I=u.onErrorOut;typeof I=="function"&&this.on(x.ERROR,I,u)}var n=a.prototype;return n.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},n.on=function(e,t,r){r===void 0&&(r=this),this._emitter.on(e,t,r)},n.once=function(e,t,r){r===void 0&&(r=this),this._emitter.once(e,t,r)},n.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},n.off=function(e,t,r,s){r===void 0&&(r=this),this._emitter.off(e,t,r,s)},n.listeners=function(e){return this._emitter.listeners(e)},n.emit=function(e,t,r){return this._emitter.emit(e,t,r)},n.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(s){if(A.error("An internal error happened while handling event "+e+'. Error message: "'+s.message+'". Here is a stacktrace:',s),!this.triggeringException){this.triggeringException=!0;var r=e===x.ERROR;this.trigger(x.ERROR,{type:V.OTHER_ERROR,details:_.INTERNAL_EXCEPTION,fatal:r,event:e,error:s}),this.triggeringException=!1}}return!1},n.listenerCount=function(e){return this._emitter.listenerCount(e)},n.destroy=function(){A.log("destroy"),this.trigger(x.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 e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},n.attachMedia=function(e){A.log("attachMedia"),this._media=e,this.trigger(x.MEDIA_ATTACHING,{media:e})},n.detachMedia=function(){A.log("detachMedia"),this.trigger(x.MEDIA_DETACHING,void 0),this._media=null},n.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,s=this.url=xt.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,A.log("loadSource:"+s),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(x.MANIFEST_LOADING,{url:e})},n.startLoad=function(e){e===void 0&&(e=-1),A.log("startLoad("+e+")"),this.started=!0,this.networkControllers.forEach(function(t){t.startLoad(e)})},n.stopLoad=function(){A.log("stopLoad"),this.started=!1,this.networkControllers.forEach(function(e){e.stopLoad()})},n.resumeBuffering=function(){this.started&&this.networkControllers.forEach(function(e){"fragmentLoader"in e&&e.startLoad(-1)})},n.pauseBuffering=function(){this.networkControllers.forEach(function(e){"fragmentLoader"in e&&e.stopLoad()})},n.swapAudioCodec=function(){A.log("swapAudioCodec"),this.streamController.swapAudioCodec()},n.recoverMediaError=function(){A.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},n.removeLevel=function(e){this.levelController.removeLevel(e)},n.setAudioOption=function(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)},n.setSubtitleOption=function(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null},he(a,[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){A.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){A.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){A.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){A.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){A.log("set startLevel:"+e),e!==-1&&(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&&(A.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:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){zn(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping,r=this.maxHdcpLevel,s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,r)for(var o=s;o--;){var l=e[o].attrs["HDCP-LEVEL"];if(l&&l<=r)return o}return s}},{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:"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:!1},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}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.5.8"}},{key:"Events",get:function(){return x}},{key:"ErrorTypes",get:function(){return V}},{key:"ErrorDetails",get:function(){return _}},{key:"DefaultConfig",get:function(){return a.defaultConfig?a.defaultConfig:ri},set:function(e){a.defaultConfig=e}}]),a}();return ki.defaultConfig=void 0,ki})})(!1)})(Gi);var oo=Gi.exports;const Hi=so(oo);export{Hi as Hls,Hi as default};
|