import{p as wt,q as Wt}from"./index-DT8qTvyx.js";function Gt(Lt,Ot){for(var W=0;WM[T]})}}}return Object.freeze(Object.defineProperty(Lt,Symbol.toStringTag,{value:"Module"}))}var Mt={exports:{}};(function(Lt,Ot){typeof window<"u"&&function(M,T){Lt.exports=T()}(Wt,function(){return function(W){var M={};function T(C){if(M[C])return M[C].exports;var D=M[C]={i:C,l:!1,exports:{}};return W[C].call(D.exports,D,D.exports,T),D.l=!0,D.exports}return T.m=W,T.c=M,T.d=function(C,D,A){T.o(C,D)||Object.defineProperty(C,D,{enumerable:!0,get:A})},T.r=function(C){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(C,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(C,"__esModule",{value:!0})},T.t=function(C,D){if(D&1&&(C=T(C)),D&8||D&4&&typeof C=="object"&&C&&C.__esModule)return C;var A=Object.create(null);if(T.r(A),Object.defineProperty(A,"default",{enumerable:!0,value:C}),D&2&&typeof C!="string")for(var b in C)T.d(A,b,(function(I){return C[I]}).bind(null,b));return A},T.n=function(C){var D=C&&C.__esModule?function(){return C.default}:function(){return C};return T.d(D,"a",D),D},T.o=function(C,D){return Object.prototype.hasOwnProperty.call(C,D)},T.p="/dist/",T(T.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(W,M,T){var C=Object.prototype.hasOwnProperty,D="~";function A(){}Object.create&&(A.prototype=Object.create(null),new A().__proto__||(D=!1));function b(m,S,p){this.fn=m,this.context=S,this.once=p||!1}function I(m,S,p,y,E){if(typeof p!="function")throw new TypeError("The listener must be a function");var v=new b(p,y||m,E),n=D?D+S:S;return m._events[n]?m._events[n].fn?m._events[n]=[m._events[n],v]:m._events[n].push(v):(m._events[n]=v,m._eventsCount++),m}function O(m,S){--m._eventsCount===0?m._events=new A:delete m._events[S]}function L(){this._events=new A,this._eventsCount=0}L.prototype.eventNames=function(){var S=[],p,y;if(this._eventsCount===0)return S;for(y in p=this._events)C.call(p,y)&&S.push(D?y.slice(1):y);return Object.getOwnPropertySymbols?S.concat(Object.getOwnPropertySymbols(p)):S},L.prototype.listeners=function(S){var p=D?D+S:S,y=this._events[p];if(!y)return[];if(y.fn)return[y.fn];for(var E=0,v=y.length,n=new Array(v);E0},!1)}function m(S,p){for(var y={main:[p]},E={main:[]},v={main:{}};L(y);)for(var n=Object.keys(y),t=0;t=2*o/h||x<=P)){var _=Number.POSITIVE_INFINITY,F;for(F=n.level-1;F>a;F--){var B=u[F].maxBitrate;if(_=o*B/(8*.8*g),_=x)){var U=this.bwEstimator.getEstimate();L.logger.warn("Fragment "+n.sn+(t?" part "+t.index:"")+" of level "+n.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+F+` Current BW estimate: `+(Object(C.isFiniteNumber)(U)?(U/1024).toFixed(3):"Unknown")+` Kb/s Estimated load time for current fragment: `+x.toFixed(3)+` s Estimated load time for the next fragment: `+_.toFixed(3)+` s Time to underbuffer: `+P.toFixed(3)+" s"),r.nextLoadLevel=F,this.bwEstimator.sample(c,i.loaded),this.clearTimer(),n.loader&&(this.fragCurrent=this.partCurrent=null,n.loader.abort()),r.trigger(A.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:n,part:t,stats:i})}}}}}},E.onFragLoaded=function(n,t){var r=t.frag,e=t.part;if(r.type===O.PlaylistLevelType.MAIN&&Object(C.isFiniteNumber)(r.sn)){var f=e?e.stats:r.stats,s=e?e.duration:r.duration;if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var i=this.hls.levels[r.level],o=(i.loaded?i.loaded.bytes:0)+f.loaded,c=(i.loaded?i.loaded.duration:0)+s;i.loaded={bytes:o,duration:c},i.realBitrate=Math.round(8*o/c)}if(r.bitrateTest){var h={stats:f,frag:r,part:e,id:r.type};this.onFragBuffered(A.Events.FRAG_BUFFERED,h),r.bitrateTest=!1}}},E.onFragBuffered=function(n,t){var r=t.frag,e=t.part,f=e?e.stats:r.stats;if(!f.aborted&&!(r.type!==O.PlaylistLevelType.MAIN||r.sn==="initSegment")){var s=f.parsing.end-f.loading.start;this.bwEstimator.sample(s,f.loaded),f.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=s/1e3:this.bitrateTestDelay=0}},E.onError=function(n,t){switch(t.details){case I.ErrorDetails.FRAG_LOAD_ERROR:case I.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break}},E.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},E.getNextABRAutoLevel=function(){var n=this.fragCurrent,t=this.partCurrent,r=this.hls,e=r.maxAutoLevel,f=r.config,s=r.minAutoLevel,i=r.media,o=t?t.duration:n?n.duration:0,c=i?i.currentTime:0,h=i&&i.playbackRate!==0?Math.abs(i.playbackRate):1,u=this.bwEstimator?this.bwEstimator.getEstimate():f.abrEwmaDefaultEstimate,a=(b.BufferHelper.bufferInfo(i,c,f.maxBufferHole).end-c)/h,l=this.findBestLevel(u,s,e,a,f.abrBandWidthFactor,f.abrBandWidthUpFactor);if(l>=0)return l;L.logger.trace((a?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var d=o?Math.min(o,f.maxStarvationDelay):f.maxStarvationDelay,g=f.abrBandWidthFactor,x=f.abrBandWidthUpFactor;if(!a){var R=this.bitrateTestDelay;if(R){var P=o?Math.min(o,f.maxLoadingDelay):f.maxLoadingDelay;d=P-R,L.logger.trace("bitrate test took "+Math.round(1e3*R)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*d)+" ms"),g=x=1}}return l=this.findBestLevel(u,s,e,a+d,g,x),Math.max(l,0)},E.findBestLevel=function(n,t,r,e,f,s){for(var i,o=this.fragCurrent,c=this.partCurrent,h=this.lastLoadedFragLevel,u=this.hls.levels,a=u[h],l=!!(a!=null&&(i=a.details)!==null&&i!==void 0&&i.live),d=a==null?void 0:a.codecSet,g=c?c.duration:o?o.duration:0,x=r;x>=t;x--){var R=u[x];if(!(!R||d&&R.codecSet!==d)){var P=R.details,_=(c?P==null?void 0:P.partTarget:P==null?void 0:P.averagetargetduration)||g,F=void 0;x<=h?F=f*n:F=s*n;var B=u[x].maxBitrate,U=B*_/F;if(L.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+x+"/"+Math.round(F)+"/"+B+"/"+_+"/"+e+"/"+U),F>B&&(!U||l&&!this.bitrateTestDelay||U0&&a===-1?(this.log("Override startPosition with lastCurrentTime @"+l.toFixed(3)),this.state=D.State.IDLE):(this.loadedmetadata=!1,this.state=D.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=a,this.tick()},h.doTick=function(){switch(this.state){case D.State.IDLE:this.doTickIdle();break;case D.State.WAITING_TRACK:{var a,l=this.levels,d=this.trackId,g=l==null||(a=l[d])===null||a===void 0?void 0:a.details;if(g){if(this.waitForCdnTuneIn(g))break;this.state=D.State.WAITING_INIT_PTS}break}case D.State.FRAG_LOADING_WAITING_RETRY:{var x,R=performance.now(),P=this.retryDate;(!P||R>=P||(x=this.media)!==null&&x!==void 0&&x.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=D.State.IDLE);break}case D.State.WAITING_INIT_PTS:{var _=this.waitingData;if(_){var F=_.frag,B=_.part,U=_.cache,N=_.complete;if(this.initPTS[F.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=D.State.FRAG_LOADING;var k=U.flush(),w={frag:F,part:B,payload:k,networkDetails:null};this._handleFragmentLoadProgress(w),N&&o.prototype._handleFragmentLoadComplete.call(this,w)}else if(this.videoTrackCC!==this.waitingVideoCC)t.logger.log("Waiting fragment cc ("+F.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var K=this.getLoadPosition(),j=b.BufferHelper.bufferInfo(this.mediaBuffer,K,this.config.maxBufferHole),H=Object(E.fragmentWithinToleranceTest)(j.end,this.config.maxFragLookUpTolerance,F);H<0&&(t.logger.log("Waiting fragment cc ("+F.cc+") @ "+F.start+" cancelled because another fragment at "+j.end+" is needed"),this.clearWaitingFragment())}}else this.state=D.State.IDLE}}this.onTickEnd()},h.clearWaitingFragment=function(){var a=this.waitingData;a&&(this.fragmentTracker.removeFragment(a.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=D.State.IDLE)},h.onTickEnd=function(){var a=this.media;if(!(!a||!a.readyState)){var l=this.mediaBuffer?this.mediaBuffer:a,d=l.buffered;!this.loadedmetadata&&d.length&&(this.loadedmetadata=!0),this.lastCurrentTime=a.currentTime}},h.doTickIdle=function(){var a,l,d=this.hls,g=this.levels,x=this.media,R=this.trackId,P=d.config;if(!(!g||!g[R])&&!(!x&&(this.startFragRequested||!P.startFragPrefetch))){var _=g[R],F=_.details;if(!F||F.live&&this.levelLastLoaded!==R||this.waitForCdnTuneIn(F)){this.state=D.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,m.ElementaryStreamTypes.AUDIO,L.PlaylistLevelType.AUDIO));var B=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,L.PlaylistLevelType.AUDIO);if(B!==null){var U=B.len,N=this.getMaxBufferLength(),k=this.audioSwitch;if(!(U>=N&&!k)){if(!k&&this._streamEnded(B,F)){d.trigger(A.Events.BUFFER_EOS,{type:"audio"}),this.state=D.State.ENDED;return}var w=F.fragments,K=w[0].start,j=B.end;if(k){var H=this.getLoadPosition();j=H,F.PTSKnown&&HK||B.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),x.currentTime=K+.05)}var G=this.getNextFragment(j,F);if(!G){this.bufferFlushed=!0;return}((a=G.decryptdata)===null||a===void 0?void 0:a.keyFormat)==="identity"&&!((l=G.decryptdata)!==null&&l!==void 0&&l.key)?this.loadKey(G,F):this.loadFragment(G,F,j)}}}},h.getMaxBufferLength=function(){var a=o.prototype.getMaxBufferLength.call(this),l=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,L.PlaylistLevelType.MAIN);return l===null?a:Math.max(a,l.len)},h.onMediaDetaching=function(){this.videoBuffer=null,o.prototype.onMediaDetaching.call(this)},h.onAudioTracksUpdated=function(a,l){var d=l.audioTracks;this.resetTransmuxer(),this.levels=d.map(function(g){return new O.Level(g)})},h.onAudioTrackSwitching=function(a,l){var d=!!l.url;this.trackId=l.id;var g=this.fragCurrent;g!=null&&g.loader&&g.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),d?this.setInterval(s):this.resetTransmuxer(),d?(this.audioSwitch=!0,this.state=D.State.IDLE):this.state=D.State.STOPPED,this.tick()},h.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},h.onLevelLoaded=function(a,l){this.mainDetails=l.details},h.onAudioTrackLoaded=function(a,l){var d,g=this.levels,x=l.details,R=l.id;if(!g){this.warn("Audio tracks were reset while loading level "+R);return}this.log("Track "+R+" loaded ["+x.startSN+","+x.endSN+"],duration:"+x.totalduration);var P=g[R],_=0;if(x.live||(d=P.details)!==null&&d!==void 0&&d.live){var F=this.mainDetails;if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed||!F)return;!P.details&&x.hasProgramDateTime&&F.hasProgramDateTime?(Object(v.alignMediaPlaylistByPDT)(x,F),_=x.fragments[0].start):_=this.alignPlaylists(x,P.details)}P.details=x,this.levelLastLoaded=R,!this.startFragRequested&&(this.mainDetails||!x.live)&&this.setStartPosition(P.details,_),this.state===D.State.WAITING_TRACK&&!this.waitForCdnTuneIn(x)&&(this.state=D.State.IDLE),this.tick()},h._handleFragmentLoadProgress=function(a){var l,d=a.frag,g=a.part,x=a.payload,R=this.config,P=this.trackId,_=this.levels;if(!_){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+d.sn+" of level "+d.level+" will not be buffered");return}var F=_[P];console.assert(F,"Audio track is defined on fragment load progress");var B=F.details;console.assert(B,"Audio track details are defined on fragment load progress");var U=R.defaultAudioCodec||F.audioCodec||"mp4a.40.2",N=this.transmuxer;N||(N=this.transmuxer=new p.default(this.hls,L.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var k=this.initPTS[d.cc],w=(l=d.initSegment)===null||l===void 0?void 0:l.data;if(k!==void 0){var K=!1,j=g?g.index:-1,H=j!==-1,G=new y.ChunkMetadata(d.level,d.sn,d.stats.chunkCount,x.byteLength,j,H);N.push(x,w,U,"",d,g,B.totalduration,K,G,k)}else{t.logger.log("Unknown video PTS for cc "+d.cc+", waiting for video PTS before demuxing audio frag "+d.sn+" of ["+B.startSN+" ,"+B.endSN+"],track "+P);var X=this.waitingData=this.waitingData||{frag:d,part:g,cache:new S.default,complete:!1},V=X.cache;V.push(new Uint8Array(x)),this.waitingVideoCC=this.videoTrackCC,this.state=D.State.WAITING_INIT_PTS}},h._handleFragmentLoadComplete=function(a){if(this.waitingData){this.waitingData.complete=!0;return}o.prototype._handleFragmentLoadComplete.call(this,a)},h.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},h.onBufferCreated=function(a,l){var d=l.tracks.audio;d&&(this.mediaBuffer=d.buffer),l.tracks.video&&(this.videoBuffer=l.tracks.video.buffer)},h.onFragBuffered=function(a,l){var d=l.frag,g=l.part;if(d.type===L.PlaylistLevelType.AUDIO){if(this.fragContextChanged(d)){this.warn("Fragment "+d.sn+(g?" p: "+g.index:"")+" of level "+d.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}d.sn!=="initSegment"&&(this.fragPrevious=d,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(d,g)}},h.onError=function(a,l){switch(l.details){case n.ErrorDetails.FRAG_LOAD_ERROR:case n.ErrorDetails.FRAG_LOAD_TIMEOUT:case n.ErrorDetails.KEY_LOAD_ERROR:case n.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(L.PlaylistLevelType.AUDIO,l);break;case n.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case n.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==D.State.ERROR&&this.state!==D.State.STOPPED&&(this.state=l.fatal?D.State.ERROR:D.State.IDLE,this.warn(l.details+" while loading frag, switching to "+this.state+" state"));break;case n.ErrorDetails.BUFFER_FULL_ERROR:if(l.parent==="audio"&&(this.state===D.State.PARSING||this.state===D.State.PARSED)){var d=!0,g=this.getFwdBufferInfo(this.mediaBuffer,L.PlaylistLevelType.AUDIO);g&&g.len>.5&&(d=!this.reduceMaxBufferLength(g.len)),d&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,o.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break}},h.onBufferFlushed=function(a,l){var d=l.type;d===m.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},h._handleTransmuxComplete=function(a){var l,d="audio",g=this.hls,x=a.remuxResult,R=a.chunkMeta,P=this.getCurrentContext(R);if(!P){this.warn("The loading context changed while buffering fragment "+R.sn+" of level "+R.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(R.level);return}var _=P.frag,F=P.part,B=x.audio,U=x.text,N=x.id3,k=x.initSegment;if(!this.fragContextChanged(_)){if(this.state=D.State.PARSING,this.audioSwitch&&B&&this.completeAudioSwitch(),k!=null&&k.tracks&&(this._bufferInitSegment(k.tracks,_,R),g.trigger(A.Events.FRAG_PARSING_INIT_SEGMENT,{frag:_,id:d,tracks:k.tracks})),B){var w=B.startPTS,K=B.endPTS,j=B.startDTS,H=B.endDTS;F&&(F.elementaryStreams[m.ElementaryStreamTypes.AUDIO]={startPTS:w,endPTS:K,startDTS:j,endDTS:H}),_.setElementaryStreamInfo(m.ElementaryStreamTypes.AUDIO,w,K,j,H),this.bufferFragmentData(B,_,F,R)}if(N!=null&&(l=N.samples)!==null&&l!==void 0&&l.length){var G=r({frag:_,id:d},N);g.trigger(A.Events.FRAG_PARSING_METADATA,G)}if(U){var X=r({frag:_,id:d},U);g.trigger(A.Events.FRAG_PARSING_USERDATA,X)}}},h._bufferInitSegment=function(a,l,d){if(this.state===D.State.PARSING){a.video&&delete a.video;var g=a.audio;if(g){g.levelCodec=g.codec,g.id="audio",this.log("Init audio buffer, container:"+g.container+", codecs[parsed]=["+g.codec+"]"),this.hls.trigger(A.Events.BUFFER_CODECS,a);var x=g.initSegment;if(x!=null&&x.byteLength){var R={type:"audio",frag:l,part:null,chunkMeta:d,parent:l.type,data:x};this.hls.trigger(A.Events.BUFFER_APPENDING,R)}this.tick()}}},h.loadFragment=function(a,l,d){var g=this.fragmentTracker.getState(a);this.fragCurrent=a,(this.audioSwitch||g===I.FragmentState.NOT_LOADED||g===I.FragmentState.PARTIAL)&&(a.sn==="initSegment"?this._loadInitSegment(a):l.live&&!Object(C.isFiniteNumber)(this.initPTS[a.cc])?(this.log("Waiting for video PTS in continuity counter "+a.cc+" of live stream before loading audio fragment "+a.sn+" of level "+this.trackId),this.state=D.State.WAITING_INIT_PTS):(this.startFragRequested=!0,o.prototype.loadFragment.call(this,a,l,d)))},h.completeAudioSwitch=function(){var a=this.hls,l=this.media,d=this.trackId;l&&(this.log("Switching audio track : flushing all audio"),o.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,a.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:d})},c}(D.default);M.default=i},"./src/controller/audio-track-controller.ts":function(W,M,T){T.r(M);var C=T("./src/events.ts"),D=T("./src/errors.ts"),A=T("./src/controller/base-playlist-controller.ts"),b=T("./src/types/loader.ts");function I(p,y){for(var E=0;E=t.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var r=t[this.trackId];this.log("Now switching to audio-track index "+n);var e=t[n],f=e.id,s=e.groupId,i=s===void 0?"":s,o=e.name,c=e.type,h=e.url;if(this.trackId=n,this.trackName=o,this.selectDefaultTrack=!1,this.hls.trigger(C.Events.AUDIO_TRACK_SWITCHING,{id:f,groupId:i,name:o,type:c,url:h}),!(e.details&&!e.details.live)){var u=this.switchParams(e.url,r==null?void 0:r.details);this.loadPlaylist(u)}},E.selectInitialTrack=function(){var n=this.tracksInGroup;console.assert(n.length,"Initial audio track should be selected when tracks are known");var t=this.trackName,r=this.findTrackId(t)||this.findTrackId();r!==-1?this.setAudioTrack(r):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(C.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},E.findTrackId=function(n){for(var t=this.tracksInGroup,r=0;ry.partTarget&&(e+=1)}if(Object(C.isFiniteNumber)(r))return new D.HlsUrlParameters(r,Object(C.isFiniteNumber)(e)?e:void 0,D.HlsSkip.No)}}},m.loadPlaylist=function(p){},m.shouldLoadTrack=function(p){return this.canLoad&&p&&!!p.url&&(!p.details||p.details.live)},m.playlistLoaded=function(p,y,E){var v=this,n=y.details,t=y.stats,r=t.loading.end?Math.max(0,self.performance.now()-t.loading.end):0;if(n.advancedDateTime=Date.now()-r,n.live||E!=null&&E.live){if(n.reloaded(E),E&&this.log("live playlist "+p+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:"MISSED")),E&&n.fragments.length>0&&Object(A.mergeDetails)(E,n),!this.canLoad||!n.live)return;var e,f=void 0,s=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var i=this.hls.config.lowLatencyMode,o=n.lastPartSn,c=n.endSN,h=n.lastPartIndex,u=h!==-1,a=o===c,l=i?0:h;u?(f=a?c+1:o,s=a?l:h+1):f=c+1;var d=n.age,g=d+n.ageHeader,x=Math.min(g-n.partTarget,n.targetduration*1.5);if(x>0){if(E&&x>E.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+E.tuneInGoal+" to: "+x+" with playlist age: "+n.age),x=0;else{var R=Math.floor(x/n.targetduration);if(f+=R,s!==void 0){var P=Math.round(x%n.targetduration/n.partTarget);s+=P}this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+d.toFixed(2)+"s goal: "+x+" skip sn "+R+" to part "+s)}n.tuneInGoal=x}if(e=this.getDeliveryDirectives(n,y.deliveryDirectives,f,s),i||!a){this.loadPlaylist(e);return}}else e=this.getDeliveryDirectives(n,y.deliveryDirectives,f,s);var _=Object(A.computeReloadInterval)(n,t);f!==void 0&&n.canBlockReload&&(_-=n.partTarget||1),this.log("reload live playlist "+p+" in "+Math.round(_)+" ms"),this.timer=self.setTimeout(function(){return v.loadPlaylist(e)},_)}else this.clearTimer()},m.getDeliveryDirectives=function(p,y,E,v){var n=Object(D.getSkipValue)(p,E);return y!=null&&y.skip&&p.deltaUpdateFailed&&(E=y.msn,v=y.part,n=D.HlsSkip.No),new D.HlsUrlParameters(E,v,n)},m.retryLoadingOrFail=function(p){var y=this,E=this.hls.config,v=this.retryCount-1&&(n=p.context)!==null&&n!==void 0&&n.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+p.details+'"'),this.loadPlaylist();else{var t=Math.min(Math.pow(2,this.retryCount)*E.levelLoadingRetryDelay,E.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return y.loadPlaylist()},t),this.warn("retry playlist loading #"+this.retryCount+" in "+t+' ms after "'+p.details+'"')}}else this.warn('cannot recover from error "'+p.details+'"'),this.clearTimer(),p.fatal=!0;return v},L}()},"./src/controller/base-stream-controller.ts":function(W,M,T){T.r(M),T.d(M,"State",function(){return c}),T.d(M,"default",function(){return h});var C=T("./src/polyfills/number.ts"),D=T("./src/task-loop.ts"),A=T("./src/controller/fragment-tracker.ts"),b=T("./src/utils/buffer-helper.ts"),I=T("./src/utils/logger.ts"),O=T("./src/events.ts"),L=T("./src/errors.ts"),m=T("./src/types/transmuxer.ts"),S=T("./src/utils/mp4-tools.ts"),p=T("./src/utils/discontinuities.ts"),y=T("./src/controller/fragment-finders.ts"),E=T("./src/controller/level-helper.ts"),v=T("./src/loader/fragment-loader.ts"),n=T("./src/crypt/decrypter.ts"),t=T("./src/utils/time-ranges.ts"),r=T("./src/types/loader.ts");function e(u,a){for(var l=0;lk;(F0&&F&&F.key&&F.iv&&F.method==="AES-128"){var B=self.performance.now();return x.decrypter.webCryptoDecrypt(new Uint8Array(_),F.key.buffer,F.iv.buffer).then(function(U){var N=self.performance.now();return P.trigger(O.Events.FRAG_DECRYPTED,{frag:g,payload:U,stats:{tstart:B,tdecrypt:N}}),R.payload=U,R})}return R}).then(function(R){var P=x.fragCurrent,_=x.hls,F=x.levels;if(!F)throw new Error("init load aborted, missing levels");var B=F[g.level].details;console.assert(B,"Level details are defined when init segment is loaded");var U=g.stats;x.state=c.IDLE,x.fragLoadError=0,g.data=new Uint8Array(R.payload),U.parsing.start=U.buffering.start=self.performance.now(),U.parsing.end=U.buffering.end=self.performance.now(),R.frag===P&&_.trigger(O.Events.FRAG_BUFFERED,{stats:U,frag:P,part:null,id:g.type}),x.tick()}).catch(function(R){x.warn(R),x.resetFragmentLoading(g)})},l.fragContextChanged=function(g){var x=this.fragCurrent;return!g||!x||g.level!==x.level||g.sn!==x.sn||g.urlId!==x.urlId},l.fragBufferedComplete=function(g,x){var R=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+g.type+" sn: "+g.sn+(x?" part: "+x.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+g.level+" "+t.default.toString(b.BufferHelper.getBuffered(R))),this.state=c.IDLE,this.tick()},l._handleFragmentLoadComplete=function(g){var x=this.transmuxer;if(x){var R=g.frag,P=g.part,_=g.partsLoaded,F=!_||_.length===0||_.some(function(U){return!U}),B=new m.ChunkMetadata(R.level,R.sn,R.stats.chunkCount+1,0,P?P.index:-1,!F);x.flush(B)}},l._handleFragmentLoadProgress=function(g){},l._doFragLoad=function(g,x,R,P){var _=this;if(R===void 0&&(R=null),!this.levels)throw new Error("frag load aborted, missing levels");if(R=Math.max(g.start,R||0),this.config.lowLatencyMode&&x){var F=x.partList;if(F&&P){R>g.end&&x.fragmentHint&&(g=x.fragmentHint);var B=this.getNextPart(F,g,R);if(B>-1){var U=F[B];return this.log("Loading part sn: "+g.sn+" p: "+U.index+" cc: "+g.cc+" of playlist ["+x.startSN+"-"+x.endSN+"] parts [0-"+B+"-"+(F.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+g.level+", target: "+parseFloat(R.toFixed(3))),this.nextLoadPosition=U.start+U.duration,this.state=c.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:g,part:F[B],targetBufferTime:R}),this.doFragPartsLoad(g,F,B,P).catch(function(N){return _.handleFragLoadError(N)})}else if(!g.url||this.loadedEndOfParts(F,R))return Promise.resolve(null)}}return this.log("Loading fragment "+g.sn+" cc: "+g.cc+" "+(x?"of ["+x.startSN+"-"+x.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+g.level+", target: "+parseFloat(R.toFixed(3))),Object(C.isFiniteNumber)(g.sn)&&!this.bitrateTest&&(this.nextLoadPosition=g.start+g.duration),this.state=c.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:g,targetBufferTime:R}),this.fragmentLoader.load(g,P).catch(function(N){return _.handleFragLoadError(N)})},l.doFragPartsLoad=function(g,x,R,P){var _=this;return new Promise(function(F,B){var U=[],N=function k(w){var K=x[w];_.fragmentLoader.loadPart(g,K,P).then(function(j){U[K.index]=j;var H=j.part;_.hls.trigger(O.Events.FRAG_LOADED,j);var G=x[w+1];if(G&&G.fragment===g)k(w+1);else return F({frag:g,part:H,partsLoaded:U})}).catch(B)};N(R)})},l.handleFragLoadError=function(g){var x=g.data;return x&&x.details===L.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(x.frag,x.part):this.hls.trigger(O.Events.ERROR,x),null},l._handleTransmuxerFlush=function(g){var x=this.getCurrentContext(g);if(!x||this.state!==c.PARSING){this.fragCurrent||(this.state=c.IDLE);return}var R=x.frag,P=x.part,_=x.level,F=self.performance.now();R.stats.parsing.end=F,P&&(P.stats.parsing.end=F),this.updateLevelTiming(R,P,_,g.partial)},l.getCurrentContext=function(g){var x=this.levels,R=g.level,P=g.sn,_=g.part;if(!x||!x[R])return this.warn("Levels object was unset while buffering fragment "+P+" of level "+R+". The current chunk will not be buffered."),null;var F=x[R],B=_>-1?Object(E.getPartWith)(F,P,_):null,U=B?B.fragment:Object(E.getFragmentWithSN)(F,P,this.fragCurrent);return U?{frag:U,part:B,level:F}:null},l.bufferFragmentData=function(g,x,R,P){if(!(!g||this.state!==c.PARSING)){var _=g.data1,F=g.data2,B=_;if(_&&F&&(B=Object(S.appendUint8Array)(_,F)),!(!B||!B.length)){var U={type:g.type,frag:x,part:R,chunkMeta:P,parent:x.type,data:B};this.hls.trigger(O.Events.BUFFER_APPENDING,U),g.dropped&&g.independent&&!R&&this.flushBufferGap(x)}}},l.flushBufferGap=function(g){var x=this.media;if(x){if(!b.BufferHelper.isBuffered(x,x.currentTime)){this.flushMainBuffer(0,g.start);return}var R=x.currentTime,P=b.BufferHelper.bufferInfo(x,R,0),_=g.duration,F=Math.min(this.config.maxFragLookUpTolerance*2,_*.25),B=Math.max(Math.min(g.start-F,P.end-F),R+F);g.start-B>F&&this.flushMainBuffer(B,g.start)}},l.getFwdBufferInfo=function(g,x){var R=this.config,P=this.getLoadPosition();if(!Object(C.isFiniteNumber)(P))return null;var _=b.BufferHelper.bufferInfo(g,P,R.maxBufferHole);if(_.len===0&&_.nextStart!==void 0){var F=this.fragmentTracker.getBufferedFrag(P,x);if(F&&_.nextStart=R?(x.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+x.maxMaxBufferLength+"s"),!0):!1},l.getNextFragment=function(g,x){var R,P,_=x.fragments,F=_.length;if(!F)return null;var B=this.config,U=_[0].start,N;if(x.live){var k=B.initialLiveManifestSize;if(F-1&&RR.start&&R.loaded},l.getInitialLiveFragment=function(g,x){var R=this.fragPrevious,P=null;if(R){if(g.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+R.programDateTime),P=Object(y.findFragmentByPDT)(x,R.endProgramDateTime,this.config.maxFragLookUpTolerance)),!P){var _=R.sn+1;if(_>=g.startSN&&_<=g.endSN){var F=x[_-g.startSN];R.cc===F.cc&&(P=F,this.log("Live playlist, switching playlist, load frag with next SN: "+P.sn))}P||(P=Object(y.findFragWithCC)(x,R.cc),P&&this.log("Live playlist, switching playlist, load frag with same CC: "+P.sn))}}else{var B=this.hls.liveSyncPosition;B!==null&&(P=this.getFragmentAtPosition(B,this.bitrateTest?g.fragmentEnd:g.edge,g))}return P},l.getFragmentAtPosition=function(g,x,R){var P=this.config,_=this.fragPrevious,F=R.fragments,B=R.endSN,U=R.fragmentHint,N=P.maxFragLookUpTolerance,k=!!(P.lowLatencyMode&&R.partList&&U);k&&U&&!this.bitrateTest&&(F=F.concat(U),B=U.sn);var w;if(gx-N?0:N;w=Object(y.findFragmentByPTS)(_,F,g,K)}else w=F[F.length-1];if(w){var j=w.sn-R.startSN,H=_&&w.level===_.level,G=F[j+1],X=this.fragmentTracker.getState(w);if(X===A.FragmentState.BACKTRACKED){w=null;for(var V=j;F[V]&&this.fragmentTracker.getState(F[V])===A.FragmentState.BACKTRACKED;)_?w=F[V--]:w=F[--V];w||(w=G)}else _&&w.sn===_.sn&&!k&&H&&(w.sn=F-x.maxFragLookUpTolerance&&_<=B;if(P!==null&&R.duration>P&&(_"+g.startSN+" prev-sn: "+(_?_.sn:"na")+" fragments: "+B),w}return U},l.waitForCdnTuneIn=function(g){var x=3;return g.live&&g.canBlockReload&&g.tuneInGoal>Math.max(g.partHoldBack,g.partTarget*x)},l.setStartPosition=function(g,x){var R=this.startPosition;if(R"+g))}}]),a}(D.default)},"./src/controller/buffer-controller.ts":function(W,M,T){T.r(M),T.d(M,"default",function(){return y});var C=T("./src/polyfills/number.ts"),D=T("./src/events.ts"),A=T("./src/utils/logger.ts"),b=T("./src/errors.ts"),I=T("./src/utils/buffer-helper.ts"),O=T("./src/utils/mediasource-helper.ts"),L=T("./src/loader/fragment.ts"),m=T("./src/controller/buffer-operation-queue.ts"),S=Object(O.getMediaSource)(),p=/([ha]vc.)(?:\.[^.,]+)+/,y=function(){function E(n){var t=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.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var r=t.hls,e=t.media,f=t.mediaSource;A.logger.log("[buffer-controller]: Media source opened"),e&&(t.updateMediaElementDuration(),r.trigger(D.Events.MEDIA_ATTACHED,{media:e})),f&&f.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){A.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){A.logger.log("[buffer-controller]: Media source ended")},this.hls=n,this._initSourceBuffer(),this.registerListeners()}var v=E.prototype;return v.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},v.destroy=function(){this.unregisterListeners(),this.details=null},v.registerListeners=function(){var t=this.hls;t.on(D.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(D.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(D.Events.BUFFER_RESET,this.onBufferReset,this),t.on(D.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.on(D.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(D.Events.BUFFER_EOS,this.onBufferEos,this),t.on(D.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(D.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(D.Events.FRAG_PARSED,this.onFragParsed,this),t.on(D.Events.FRAG_CHANGED,this.onFragChanged,this)},v.unregisterListeners=function(){var t=this.hls;t.off(D.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(D.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(D.Events.BUFFER_RESET,this.onBufferReset,this),t.off(D.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.off(D.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(D.Events.BUFFER_EOS,this.onBufferEos,this),t.off(D.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(D.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(D.Events.FRAG_PARSED,this.onFragParsed,this),t.off(D.Events.FRAG_CHANGED,this.onFragChanged,this)},v._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new m.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},v.onManifestParsed=function(t,r){var e=2;(r.audio&&!r.video||!r.altAudio)&&(e=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=e,this.details=null,A.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},v.onMediaAttaching=function(t,r){var e=this.media=r.media;if(e&&S){var f=this.mediaSource=new S;f.addEventListener("sourceopen",this._onMediaSourceOpen),f.addEventListener("sourceended",this._onMediaSourceEnded),f.addEventListener("sourceclose",this._onMediaSourceClose),e.src=self.URL.createObjectURL(f),this._objectUrl=e.src}},v.onMediaDetaching=function(){var t=this.media,r=this.mediaSource,e=this._objectUrl;if(r){if(A.logger.log("[buffer-controller]: media source detaching"),r.readyState==="open")try{r.endOfStream()}catch(f){A.logger.warn("[buffer-controller]: onMediaDetaching: "+f.message+" while calling endOfStream")}this.onBufferReset(),r.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("sourceended",this._onMediaSourceEnded),r.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(e&&self.URL.revokeObjectURL(e),t.src===e?(t.removeAttribute("src"),t.load()):A.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(D.Events.MEDIA_DETACHED,void 0)},v.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach(function(r){var e=t.sourceBuffer[r];try{e&&(t.removeBufferListeners(r),t.mediaSource&&t.mediaSource.removeSourceBuffer(e),t.sourceBuffer[r]=void 0)}catch(f){A.logger.warn("[buffer-controller]: Failed to reset the "+r+" buffer",f)}}),this._initSourceBuffer()},v.onBufferCodecs=function(t,r){var e=this,f=this.getSourceBufferTypes().length;Object.keys(r).forEach(function(s){if(f){var i=e.tracks[s];if(i&&typeof i.buffer.changeType=="function"){var o=r[s],c=o.codec,h=o.levelCodec,u=o.container,a=(i.levelCodec||i.codec).replace(p,"$1"),l=(h||c).replace(p,"$1");if(a!==l){var d=u+";codecs="+(h||c);e.appendChangeType(s,d)}}}else e.pendingTracks[s]=r[s]}),!f&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},v.appendChangeType=function(t,r){var e=this,f=this.operationQueue,s={execute:function(){var o=e.sourceBuffer[t];o&&(A.logger.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+r),o.changeType(r)),f.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(o){A.logger.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",o)}};f.append(s,t)},v.onBufferAppending=function(t,r){var e=this,f=this.hls,s=this.operationQueue,i=this.tracks,o=r.data,c=r.type,h=r.frag,u=r.part,a=r.chunkMeta,l=a.buffering[c],d=self.performance.now();l.start=d;var g=h.stats.buffering,x=u?u.stats.buffering:null;g.start===0&&(g.start=d),x&&x.start===0&&(x.start=d);var R=i.audio,P=c==="audio"&&a.id===1&&(R==null?void 0:R.container)==="audio/mpeg",_={execute:function(){if(l.executeStart=self.performance.now(),P){var B=e.sourceBuffer[c];if(B){var U=h.start-B.timestampOffset;Math.abs(U)>=.1&&(A.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+h.start+" (delta: "+U+") sn: "+h.sn+")"),B.timestampOffset=h.start)}}e.appendExecutor(o,c)},onStart:function(){},onComplete:function(){var B=self.performance.now();l.executeEnd=l.end=B,g.first===0&&(g.first=B),x&&x.first===0&&(x.first=B);var U=e.sourceBuffer,N={};for(var k in U)N[k]=I.BufferHelper.getBuffered(U[k]);e.appendError=0,e.hls.trigger(D.Events.BUFFER_APPENDED,{type:c,frag:h,part:u,chunkMeta:a,parent:h.type,timeRanges:N})},onError:function(B){A.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",B);var U={type:b.ErrorTypes.MEDIA_ERROR,parent:h.type,details:b.ErrorDetails.BUFFER_APPEND_ERROR,err:B,fatal:!1};B.code===DOMException.QUOTA_EXCEEDED_ERR?U.details=b.ErrorDetails.BUFFER_FULL_ERROR:(e.appendError++,U.details=b.ErrorDetails.BUFFER_APPEND_ERROR,e.appendError>f.config.appendErrorMaxRetry&&(A.logger.error("[buffer-controller]: Failed "+f.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),U.fatal=!0)),f.trigger(D.Events.ERROR,U)}};s.append(_,c)},v.onBufferFlushing=function(t,r){var e=this,f=this.operationQueue,s=function(o){return{execute:e.removeExecutor.bind(e,o,r.startOffset,r.endOffset),onStart:function(){},onComplete:function(){e.hls.trigger(D.Events.BUFFER_FLUSHED,{type:o})},onError:function(h){A.logger.warn("[buffer-controller]: Failed to remove from "+o+" SourceBuffer",h)}}};r.type?f.append(s(r.type),r.type):this.getSourceBufferTypes().forEach(function(i){f.append(s(i),i)})},v.onFragParsed=function(t,r){var e=this,f=r.frag,s=r.part,i=[],o=s?s.elementaryStreams:f.elementaryStreams;o[L.ElementaryStreamTypes.AUDIOVIDEO]?i.push("audiovideo"):(o[L.ElementaryStreamTypes.AUDIO]&&i.push("audio"),o[L.ElementaryStreamTypes.VIDEO]&&i.push("video"));var c=function(){var u=self.performance.now();f.stats.buffering.end=u,s&&(s.stats.buffering.end=u);var a=s?s.stats:f.stats;e.hls.trigger(D.Events.FRAG_BUFFERED,{frag:f,part:s,stats:a,id:f.type})};i.length===0&&A.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+f.type+" level: "+f.level+" sn: "+f.sn),this.blockBuffers(c,i)},v.onFragChanged=function(t,r){this.flushBackBuffer()},v.onBufferEos=function(t,r){var e=this,f=this.getSourceBufferTypes().reduce(function(s,i){var o=e.sourceBuffer[i];return(!r.type||r.type===i)&&o&&!o.ended&&(o.ended=!0,A.logger.log("[buffer-controller]: "+i+" sourceBuffer now EOS")),s&&!!(!o||o.ended)},!0);f&&this.blockBuffers(function(){var s=e.mediaSource;!s||s.readyState!=="open"||s.endOfStream()})},v.onLevelUpdated=function(t,r){var e=r.details;e.fragments.length&&(this.details=e,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},v.flushBackBuffer=function(){var t=this.hls,r=this.details,e=this.media,f=this.sourceBuffer;if(!(!e||r===null)){var s=this.getSourceBufferTypes();if(s.length){var i=r.live&&t.config.liveBackBufferLength!==null?t.config.liveBackBufferLength:t.config.backBufferLength;if(!(!Object(C.isFiniteNumber)(i)||i<0)){var o=e.currentTime,c=r.levelTargetDuration,h=Math.max(i,c),u=Math.floor(o/c)*c-h;s.forEach(function(a){var l=f[a];if(l){var d=I.BufferHelper.getBuffered(l);d.length>0&&u>d.start(0)&&(t.trigger(D.Events.BACK_BUFFER_REACHED,{bufferEnd:u}),r.live&&t.trigger(D.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:u}),t.trigger(D.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:u,type:a}))}})}}}},v.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var t=this.details,r=this.hls,e=this.media,f=this.mediaSource,s=t.fragments[0].start+t.totalduration,i=e.duration,o=Object(C.isFiniteNumber)(f.duration)?f.duration:0;t.live&&r.config.liveDurationInfinity?(A.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),f.duration=1/0,this.updateSeekableRange(t)):(s>o&&s>i||!Object(C.isFiniteNumber)(i))&&(A.logger.log("[buffer-controller]: Updating Media Source duration to "+s.toFixed(3)),f.duration=s)}},v.updateSeekableRange=function(t){var r=this.mediaSource,e=t.fragments,f=e.length;if(f&&t.live&&r!==null&&r!==void 0&&r.setLiveSeekableRange){var s=Math.max(0,e[0].start),i=Math.max(s,s+t.totalduration);r.setLiveSeekableRange(s,i)}},v.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,r=this.operationQueue,e=this.pendingTracks,f=Object.keys(e).length;if(f&&!t||f===2){this.createSourceBuffers(e),this.pendingTracks={};var s=this.getSourceBufferTypes();if(s.length===0){this.hls.trigger(D.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}s.forEach(function(i){r.executeNext(i)})}},v.createSourceBuffers=function(t){var r=this.sourceBuffer,e=this.mediaSource;if(!e)throw Error("createSourceBuffers called when mediaSource was null");var f=0;for(var s in t)if(!r[s]){var i=t[s];if(!i)throw Error("source buffer exists for track "+s+", however track does not");var o=i.levelCodec||i.codec,c=i.container+";codecs="+o;A.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var h=r[s]=e.addSourceBuffer(c),u=s;this.addBufferListener(u,"updatestart",this._onSBUpdateStart),this.addBufferListener(u,"updateend",this._onSBUpdateEnd),this.addBufferListener(u,"error",this._onSBUpdateError),this.tracks[s]={buffer:h,codec:o,container:i.container,levelCodec:i.levelCodec,id:i.id},f++}catch(a){A.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+a.message),this.hls.trigger(D.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:a,mimeType:c})}}f&&this.hls.trigger(D.Events.BUFFER_CREATED,{tracks:this.tracks})},v._onSBUpdateStart=function(t){var r=this.operationQueue,e=r.current(t);e.onStart()},v._onSBUpdateEnd=function(t){var r=this.operationQueue,e=r.current(t);e.onComplete(),r.shiftAndExecuteNext(t)},v._onSBUpdateError=function(t,r){A.logger.error("[buffer-controller]: "+t+" SourceBuffer error",r),this.hls.trigger(D.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var e=this.operationQueue.current(t);e&&e.onError(r)},v.removeExecutor=function(t,r,e){var f=this.media,s=this.mediaSource,i=this.operationQueue,o=this.sourceBuffer,c=o[t];if(!f||!s||!c){A.logger.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),i.shiftAndExecuteNext(t);return}var h=Object(C.isFiniteNumber)(f.duration)?f.duration:1/0,u=Object(C.isFiniteNumber)(s.duration)?s.duration:1/0,a=Math.max(0,r),l=Math.min(e,h,u);l>a?(A.logger.log("[buffer-controller]: Removing ["+a+","+l+"] from the "+t+" SourceBuffer"),console.assert(!c.updating,t+" sourceBuffer must not be updating"),c.remove(a,l)):i.shiftAndExecuteNext(t)},v.appendExecutor=function(t,r){var e=this.operationQueue,f=this.sourceBuffer,s=f[r];if(!s){A.logger.warn("[buffer-controller]: Attempting to append to the "+r+" SourceBuffer, but it does not exist"),e.shiftAndExecuteNext(r);return}s.ended=!1,console.assert(!s.updating,r+" sourceBuffer must not be updating"),s.appendBuffer(t)},v.blockBuffers=function(t,r){var e=this;if(r===void 0&&(r=this.getSourceBufferTypes()),!r.length){A.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(t);return}var f=this.operationQueue,s=r.map(function(i){return f.appendBlocker(i)});Promise.all(s).then(function(){t(),r.forEach(function(i){var o=e.sourceBuffer[i];(!o||!o.updating)&&f.shiftAndExecuteNext(i)})})},v.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},v.addBufferListener=function(t,r,e){var f=this.sourceBuffer[t];if(f){var s=e.bind(this,t);this.listeners[t].push({event:r,listener:s}),f.addEventListener(r,s)}},v.removeBufferListeners=function(t){var r=this.sourceBuffer[t];r&&this.listeners[t].forEach(function(e){r.removeEventListener(e.event,e.listener)})},E}()},"./src/controller/buffer-operation-queue.ts":function(W,M,T){T.r(M),T.d(M,"default",function(){return D});var C=T("./src/utils/logger.ts"),D=function(){function A(I){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=I}var b=A.prototype;return b.append=function(O,L){var m=this.queues[L];m.push(O),m.length===1&&this.buffers[L]&&this.executeNext(L)},b.insertAbort=function(O,L){var m=this.queues[L];m.unshift(O),this.executeNext(L)},b.appendBlocker=function(O){var L,m=new Promise(function(p){L=p}),S={execute:L,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(S,O),m},b.executeNext=function(O){var L=this.buffers,m=this.queues,S=L[O],p=m[O];if(p.length){var y=p[0];try{y.execute()}catch(E){C.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),y.onError(E),(!S||!S.updating)&&(p.shift(),this.executeNext(O))}}},b.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},b.current=function(O){return this.queues[O][0]},A}()},"./src/controller/cap-level-controller.ts":function(W,M,T){T.r(M);var C=T("./src/events.ts");function D(I,O){for(var L=0;L0&&this.mediaWidth>0){var m=this.hls.levels;if(m.length){var S=this.hls;S.autoLevelCapping=this.getMaxLevel(m.length-1),S.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=S.autoLevelCapping}}},O.getMaxLevel=function(m){var S=this,p=this.hls.levels;if(!p.length)return-1;var y=p.filter(function(E,v){return I.isLevelAllowed(v,S.restrictedLevels)&&v<=m});return this.clientRect=null,I.getMaxLevelByMediaSize(y,this.mediaWidth,this.mediaHeight)},O.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},O.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},O.getDimensions=function(){if(this.clientRect)return this.clientRect;var m=this.media,S={width:0,height:0};if(m){var p=m.getBoundingClientRect();S.width=p.width,S.height=p.height,!S.width&&!S.height&&(S.width=p.right-p.left||m.width||0,S.height=p.bottom-p.top||m.height||0)}return this.clientRect=S,S},I.isLevelAllowed=function(m,S){return S===void 0&&(S=[]),S.indexOf(m)===-1},I.getMaxLevelByMediaSize=function(m,S,p){if(!m||!m.length)return-1;for(var y=function(r,e){return e?r.width!==e.width||r.height!==e.height:!0},E=m.length-1,v=0;v=S||n.height>=p)&&y(n,m[v+1])){E=v;break}}return E},A(I,[{key:"mediaWidth",get:function(){return this.getDimensions().width*I.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*I.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var m=1;try{m=self.devicePixelRatio}catch{}return m}}]),I}();M.default=b},"./src/controller/cmcd-controller.ts":function(W,M,T){T.r(M),T.d(M,"default",function(){return y});var C=T("./src/events.ts"),D=T("./src/types/cmcd.ts"),A=T("./src/utils/buffer-helper.ts"),b=T("./src/utils/logger.ts");function I(E,v){for(var n=0;n=E.length?{done:!0}:{done:!1,value:E[t++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function m(E,v){if(E){if(typeof E=="string")return S(E,v);var n=Object.prototype.toString.call(E).slice(8,-1);if(n==="Object"&&E.constructor&&(n=E.constructor.name),n==="Map"||n==="Set")return Array.from(E);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return S(E,v)}}function S(E,v){(v==null||v>E.length)&&(v=E.length);for(var n=0,t=new Array(v);n-1?s+1:f.levels.length;e=f.levels.slice(0,i)}for(var o=L(e),c;!(c=o()).done;){var h=c.value;h.bitrate>r&&(r=h.bitrate)}return r>0?r:NaN},v.getBufferLength=function(t){var r=this.hls.media,e=t===D.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!e||!r)return NaN;var f=A.BufferHelper.bufferInfo(e,r.currentTime,this.config.maxBufferHole);return f.len*1e3},v.createPlaylistLoader=function(){var t=this.config.pLoader,r=this.applyPlaylistData,e=t||this.config.loader;return function(){function f(i){this.loader=void 0,this.loader=new e(i)}var s=f.prototype;return s.destroy=function(){this.loader.destroy()},s.abort=function(){this.loader.abort()},s.load=function(o,c,h){r(o),this.loader.load(o,c,h)},O(f,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),f}()},v.createFragmentLoader=function(){var t=this.config.fLoader,r=this.applyFragmentData,e=t||this.config.loader;return function(){function f(i){this.loader=void 0,this.loader=new e(i)}var s=f.prototype;return s.destroy=function(){this.loader.destroy()},s.abort=function(){this.loader.abort()},s.load=function(o,c,h){r(o),this.loader.load(o,c,h)},O(f,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),f}()},E.uuid=function(){var t=URL.createObjectURL(new Blob),r=t.toString();return URL.revokeObjectURL(t),r.substr(r.lastIndexOf("/")+1)},E.serialize=function(t){for(var r=[],e=function(P){return!Number.isNaN(P)&&P!=null&&P!==""&&P!==!1},f=function(P){return Math.round(P)},s=function(P){return f(P/100)*100},i=function(P){return encodeURIComponent(P)},o={br:f,d:f,bl:s,dl:s,mtp:s,nor:i,rtp:s,tb:f},c=Object.keys(t||{}).sort(),h=L(c),u;!(u=h()).done;){var a=u.value,l=t[a];if(e(l)&&!(a==="v"&&l===1)&&!(a=="pr"&&l===1)){var d=o[a];d&&(l=d(l));var g=typeof l,x=void 0;a==="ot"||a==="sf"||a==="st"?x=a+"="+l:g==="boolean"?x=a:g==="number"?x=a+"="+l:x=a+"="+JSON.stringify(l),r.push(x)}}return r.join(",")},E.toHeaders=function(t){for(var r=Object.keys(t),e={},f=["Object","Request","Session","Status"],s=[{},{},{},{}],i={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},o=0,c=r;oL){this.hls.trigger(C.Events.ERROR,{type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var i=L-this._requestLicenseFailureCount+1;A.logger.warn("Retrying license request, "+i+" attempts left"),this._requestLicense(r,e)}break}},E._generateLicenseRequestChallenge=function(n,t){switch(n.mediaKeySystemDomain){case b.KeySystems.WIDEVINE:return t}throw new Error("unsupported key-system: "+n.mediaKeySystemDomain)},E._requestLicense=function(n,t){A.logger.log("Requesting content license for key-system");var r=this._mediaKeysList[0];if(!r){A.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(C.Events.ERROR,{type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var e=this.getLicenseServerUrl(r.mediaKeySystemDomain),f=this._createLicenseXhr(e,n,t);A.logger.log("Sending license request to URL: "+e);var s=this._generateLicenseRequestChallenge(r,n);f.send(s)}catch(i){A.logger.error("Failure requesting DRM license: "+i),this.hls.trigger(C.Events.ERROR,{type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},E.onMediaAttached=function(n,t){if(this._emeEnabled){var r=t.media;this._media=r,r.addEventListener("encrypted",this._onMediaEncrypted)}},E.onMediaDetached=function(){var n=this._media,t=this._mediaKeysList;n&&(n.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(t.map(function(r){if(r.mediaKeysSession)return r.mediaKeysSession.close().catch(function(){})})).then(function(){return n.setMediaKeys(null)}).catch(function(){}))},E.onManifestParsed=function(n,t){if(this._emeEnabled){var r=t.levels.map(function(f){return f.audioCodec}).filter(function(f){return!!f}),e=t.levels.map(function(f){return f.videoCodec}).filter(function(f){return!!f});this._attemptKeySystemAccess(b.KeySystems.WIDEVINE,r,e)}},O(y,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),y}();M.default=p},"./src/controller/fps-controller.ts":function(W,M,T){T.r(M);var C=T("./src/events.ts"),D=T("./src/utils/logger.ts"),A=function(){function b(O){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=O,this.registerListeners()}var I=b.prototype;return I.setStreamController=function(L){this.streamController=L},I.registerListeners=function(){this.hls.on(C.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},I.unregisterListeners=function(){this.hls.off(C.Events.MEDIA_ATTACHING,this.onMediaAttaching)},I.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},I.onMediaAttaching=function(L,m){var S=this.hls.config;if(S.capLevelOnFPSDrop){var p=m.media instanceof self.HTMLVideoElement?m.media:null;this.media=p,p&&typeof p.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),S.fpsDroppedMonitoringPeriod)}},I.checkFPS=function(L,m,S){var p=performance.now();if(m){if(this.lastTime){var y=p-this.lastTime,E=S-this.lastDroppedFrames,v=m-this.lastDecodedFrames,n=1e3*E/y,t=this.hls;if(t.trigger(C.Events.FPS_DROP,{currentDropped:E,currentDecoded:v,totalDroppedFrames:S}),n>0&&E>t.config.fpsDroppedMonitoringThreshold*v){var r=t.currentLevel;D.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+r),r>0&&(t.autoLevelCapping===-1||t.autoLevelCapping>=r)&&(r=r-1,t.trigger(C.Events.FPS_DROP_LEVEL_CAPPING,{level:r,droppedLevel:t.currentLevel}),t.autoLevelCapping=r,this.streamController.nextLevelSwitch())}}this.lastTime=p,this.lastDroppedFrames=S,this.lastDecodedFrames=m}},I.checkFPSInterval=function(){var L=this.media;if(L)if(this.isVideoPlaybackQualityAvailable){var m=L.getVideoPlaybackQuality();this.checkFPS(L,m.totalVideoFrames,m.droppedVideoFrames)}else this.checkFPS(L,L.webkitDecodedFrameCount,L.webkitDroppedFrameCount)},b}();M.default=A},"./src/controller/fragment-finders.ts":function(W,M,T){T.r(M),T.d(M,"findFragmentByPDT",function(){return A}),T.d(M,"findFragmentByPTS",function(){return b}),T.d(M,"fragmentWithinToleranceTest",function(){return I}),T.d(M,"pdtWithinToleranceTest",function(){return O}),T.d(M,"findFragWithCC",function(){return L});var C=T("./src/polyfills/number.ts"),D=T("./src/utils/binary-search.ts");function A(m,S,p){if(S===null||!Array.isArray(m)||!m.length||!Object(C.isFiniteNumber)(S))return null;var y=m[0].programDateTime;if(S<(y||0))return null;var E=m[m.length-1].endProgramDateTime;if(S>=(E||0))return null;p=p||0;for(var v=0;vm&&p.start?-1:0}function O(m,S,p){var y=Math.min(S,p.duration+(p.deltaPTS?p.deltaPTS:0))*1e3,E=p.endProgramDateTime||0;return E-y>m}function L(m,S){return D.default.search(m,function(p){return p.ccS?-1:0})}},"./src/controller/fragment-tracker.ts":function(W,M,T){T.r(M),T.d(M,"FragmentState",function(){return A}),T.d(M,"FragmentTracker",function(){return b});var C=T("./src/events.ts"),D=T("./src/types/loader.ts"),A;(function(L){L.NOT_LOADED="NOT_LOADED",L.BACKTRACKED="BACKTRACKED",L.APPENDING="APPENDING",L.PARTIAL="PARTIAL",L.OK="OK"})(A||(A={}));var b=function(){function L(S){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=S,this._registerListeners()}var m=L.prototype;return m._registerListeners=function(){var p=this.hls;p.on(C.Events.BUFFER_APPENDED,this.onBufferAppended,this),p.on(C.Events.FRAG_BUFFERED,this.onFragBuffered,this),p.on(C.Events.FRAG_LOADED,this.onFragLoaded,this)},m._unregisterListeners=function(){var p=this.hls;p.off(C.Events.BUFFER_APPENDED,this.onBufferAppended,this),p.off(C.Events.FRAG_BUFFERED,this.onFragBuffered,this),p.off(C.Events.FRAG_LOADED,this.onFragLoaded,this)},m.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},m.getAppendedFrag=function(p,y){if(y===D.PlaylistLevelType.MAIN){var E=this.activeFragment,v=this.activeParts;if(!E)return null;if(v)for(var n=v.length;n--;){var t=v[n],r=t?t.end:E.appendedPTS;if(t.start<=p&&r!==void 0&&p<=r)return n>9&&(this.activeParts=v.slice(n-9)),t}else if(E.start<=p&&E.appendedPTS!==void 0&&p<=E.appendedPTS)return E}return this.getBufferedFrag(p,y)},m.getBufferedFrag=function(p,y){for(var E=this.fragments,v=Object.keys(E),n=v.length;n--;){var t=E[v[n]];if((t==null?void 0:t.body.type)===y&&t.buffered){var r=t.body;if(r.start<=p&&p<=r.end)return r}}return null},m.detectEvictedFragments=function(p,y,E){var v=this;Object.keys(this.fragments).forEach(function(n){var t=v.fragments[n];if(t){if(!t.buffered){t.body.type===E&&v.removeFragment(t.body);return}var r=t.range[p];r&&r.time.some(function(e){var f=!v.isTimeBuffered(e.startPTS,e.endPTS,y);return f&&v.removeFragment(t.body),f})}})},m.detectPartialFragments=function(p){var y=this,E=this.timeRanges,v=p.frag,n=p.part;if(!(!E||v.sn==="initSegment")){var t=O(v),r=this.fragments[t];r&&(Object.keys(E).forEach(function(e){var f=v.elementaryStreams[e];if(f){var s=E[e],i=n!==null||f.partial===!0;r.range[e]=y.getBufferedTimes(v,n,i,s)}}),r.backtrack=r.loaded=null,Object.keys(r.range).length?r.buffered=!0:this.removeFragment(r.body))}},m.fragBuffered=function(p){var y=O(p),E=this.fragments[y];E&&(E.backtrack=E.loaded=null,E.buffered=!0)},m.getBufferedTimes=function(p,y,E,v){for(var n={time:[],partial:E},t=y?y.start:p.start,r=y?y.end:p.end,e=p.minEndPTS||r,f=p.maxStartPTS||t,s=0;s=i&&e<=o){n.time.push({startPTS:Math.max(t,v.start(s)),endPTS:Math.min(r,v.end(s))});break}else if(ti)n.partial=!0,n.time.push({startPTS:Math.max(t,v.start(s)),endPTS:Math.min(r,v.end(s))});else if(r<=i)break}return n},m.getPartialFragment=function(p){var y=null,E,v,n,t=0,r=this.bufferPadding,e=this.fragments;return Object.keys(e).forEach(function(f){var s=e[f];s&&I(s)&&(v=s.body.start-r,n=s.body.end+r,p>=v&&p<=n&&(E=Math.min(p-v,n-p),t<=E&&(y=s.body,t=E)))}),y},m.getState=function(p){var y=O(p),E=this.fragments[y];return E?E.buffered?I(E)?A.PARTIAL:A.OK:E.backtrack?A.BACKTRACKED:A.APPENDING:A.NOT_LOADED},m.backtrack=function(p,y){var E=O(p),v=this.fragments[E];if(!v||v.backtrack)return null;var n=v.backtrack=y||v.loaded;return v.loaded=null,n},m.getBacktrackData=function(p){var y=O(p),E=this.fragments[y];if(E){var v,n=E.backtrack;if(n!=null&&(v=n.payload)!==null&&v!==void 0&&v.byteLength)return n;this.removeFragment(p)}return null},m.isTimeBuffered=function(p,y,E){for(var v,n,t=0;t=v&&y<=n)return!0;if(y<=v)return!1}return!1},m.onFragLoaded=function(p,y){var E=y.frag,v=y.part;if(!(E.sn==="initSegment"||E.bitrateTest||v)){var n=O(E);this.fragments[n]={body:E,loaded:y,backtrack:null,buffered:!1,range:Object.create(null)}}},m.onBufferAppended=function(p,y){var E=this,v=y.frag,n=y.part,t=y.timeRanges;if(v.type===D.PlaylistLevelType.MAIN)if(this.activeFragment=v,n){var r=this.activeParts;r||(this.activeParts=r=[]),r.push(n)}else this.activeParts=null;this.timeRanges=t,Object.keys(t).forEach(function(e){var f=t[e];if(E.detectEvictedFragments(e,f),!n)for(var s=0;sp&&v.removeFragment(r)}})},m.removeFragment=function(p){var y=O(p);p.stats.loaded=0,p.clearElementaryStreamInfo(),delete this.fragments[y]},m.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},L}();function I(L){var m,S;return L.buffered&&(((m=L.range.video)===null||m===void 0?void 0:m.partial)||((S=L.range.audio)===null||S===void 0?void 0:S.partial))}function O(L){return L.type+"_"+L.level+"_"+L.urlId+"_"+L.sn}},"./src/controller/gap-controller.ts":function(W,M,T){T.r(M),T.d(M,"STALL_MINIMUM_DURATION_MS",function(){return I}),T.d(M,"MAX_START_GAP_JUMP",function(){return O}),T.d(M,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return L}),T.d(M,"SKIP_BUFFER_RANGE_START",function(){return m}),T.d(M,"default",function(){return S});var C=T("./src/utils/buffer-helper.ts"),D=T("./src/errors.ts"),A=T("./src/events.ts"),b=T("./src/utils/logger.ts"),I=250,O=2,L=.1,m=.05,S=function(){function p(E,v,n,t){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=E,this.media=v,this.fragmentTracker=n,this.hls=t}var y=p.prototype;return y.destroy=function(){this.hls=this.fragmentTracker=this.media=null},y.poll=function(v){var n=this.config,t=this.media,r=this.stalled,e=t.currentTime,f=t.seeking,s=this.seeking&&!f,i=!this.seeking&&f;if(this.seeking=f,e!==v){if(this.moved=!0,r!==null){if(this.stallReported){var o=self.performance.now()-r;b.logger.warn("playback not stuck anymore @"+e+", after "+Math.round(o)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((i||s)&&(this.stalled=null),!(t.paused||t.ended||t.playbackRate===0||!C.BufferHelper.getBuffered(t).length)){var c=C.BufferHelper.bufferInfo(t,e,0),h=c.len>0,u=c.nextStart||0;if(!(!h&&!u)){if(f){var a=c.len>O,l=!u||u-e>O&&!this.fragmentTracker.getPartialFragment(e);if(a||l)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var d,g=Math.max(u,c.start||0)-e,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,R=x==null||(d=x.details)===null||d===void 0?void 0:d.live,P=R?x.details.targetduration*2:O;if(g>0&&g<=P){this._trySkipBufferHole(null);return}}var _=self.performance.now();if(r===null){this.stalled=_;return}var F=_-r;!f&&F>=I&&this._reportStall(c.len);var B=C.BufferHelper.bufferInfo(t,e,n.maxBufferHole);this._tryFixBufferStall(B,F)}}},y._tryFixBufferStall=function(v,n){var t=this.config,r=this.fragmentTracker,e=this.media,f=e.currentTime,s=r.getPartialFragment(f);if(s){var i=this._trySkipBufferHole(s);if(i)return}v.len>t.maxBufferHole&&n>t.highBufferWatchdogPeriod*1e3&&(b.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},y._reportStall=function(v){var n=this.hls,t=this.media,r=this.stallReported;r||(this.stallReported=!0,b.logger.warn("Playback stalling at @"+t.currentTime+" due to low buffer (buffer="+v+")"),n.trigger(A.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:v}))},y._trySkipBufferHole=function(v){for(var n=this.config,t=this.hls,r=this.media,e=r.currentTime,f=0,s=C.BufferHelper.getBuffered(r),i=0;i=f&&e.05&&this.forwardBufferLength>1){var i=Math.min(2,Math.max(1,t)),o=Math.round(2/(1+Math.exp(-.75*e-this.edgeStalled))*20)/20;p.playbackRate=Math.min(i,Math.max(1,o))}else p.playbackRate!==1&&p.playbackRate!==0&&(p.playbackRate=1)}}}}},m.estimateLiveEdge=function(){var p=this.levelDetails;return p===null?null:p.edge+p.age},m.computeLatency=function(){var p=this.estimateLiveEdge();return p===null?null:p-this.currentTime},I(L,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var p=this.config,y=this.levelDetails;return p.liveMaxLatencyDuration!==void 0?p.liveMaxLatencyDuration:y?p.liveMaxLatencyDurationCount*y.targetduration:0}},{key:"targetLatency",get:function(){var p=this.levelDetails;if(p===null)return null;var y=p.holdBack,E=p.partHoldBack,v=p.targetduration,n=this.config,t=n.liveSyncDuration,r=n.liveSyncDurationCount,e=n.lowLatencyMode,f=this.hls.userConfig,s=e&&E||y;(f.liveSyncDuration||f.liveSyncDurationCount||s===0)&&(s=t!==void 0?t:r*v);var i=v,o=1;return s+Math.min(this.stallCount*o,i)}},{key:"liveSyncPosition",get:function(){var p=this.estimateLiveEdge(),y=this.targetLatency,E=this.levelDetails;if(p===null||y===null||E===null)return null;var v=E.edge,n=p-y-this.edgeStalled,t=v-E.totalduration,r=v-(this.config.lowLatencyMode&&E.partTarget||E.targetduration);return Math.min(Math.max(t,n),r)}},{key:"drift",get:function(){var p=this.levelDetails;return p===null?1:p.drift}},{key:"edgeStalled",get:function(){var p=this.levelDetails;if(p===null)return 0;var y=(this.config.lowLatencyMode&&p.partTarget||p.targetduration)*3;return Math.max(p.age-y,0)}},{key:"forwardBufferLength",get:function(){var p=this.media,y=this.levelDetails;if(!p||!y)return 0;var E=p.buffered.length;return E?p.buffered.end(E-1):y.edge-this.currentTime}}]),L}()},"./src/controller/level-controller.ts":function(W,M,T){T.r(M),T.d(M,"default",function(){return n});var C=T("./src/types/level.ts"),D=T("./src/events.ts"),A=T("./src/errors.ts"),b=T("./src/utils/codecs.ts"),I=T("./src/controller/level-helper.ts"),O=T("./src/controller/base-playlist-controller.ts"),L=T("./src/types/loader.ts");function m(){return m=Object.assign||function(t){for(var r=1;r0){u=o[0].bitrate,o.sort(function(F,B){return F.bitrate-B.bitrate}),this._levels=o;for(var R=0;Rthis.hls.config.fragLoadingMaxRetry&&(a=i.frag.level)):a=i.frag.level}break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:o&&(o.deliveryDirectives&&(u=!1),a=o.level),h=!0;break;case A.ErrorDetails.REMUX_ALLOC_ERROR:a=i.level,h=!0;break}a!==void 0&&this.recoverLevel(i,a,h,u)}},e.recoverLevel=function(s,i,o,c){var h=s.details,u=this._levels[i];if(u.loadError++,o){var a=this.retryLoadingOrFail(s);if(a)s.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(c){var l=u.url.length;if(l>1&&u.loadError1){var c=(i.urlId+1)%o;this.warn("Switching to redundant URL-id "+c),this._levels.forEach(function(h){h.urlId=c}),this.level=s}},e.onFragLoaded=function(s,i){var o=i.frag;if(o!==void 0&&o.type===L.PlaylistLevelType.MAIN){var c=this._levels[o.level];c!==void 0&&(c.fragmentError=0,c.loadError=0)}},e.onLevelLoaded=function(s,i){var o,c=i.level,h=i.details,u=this._levels[c];if(!u){var a;this.warn("Invalid level index "+c),(a=i.deliveryDirectives)!==null&&a!==void 0&&a.skip&&(h.deltaUpdateFailed=!0);return}c===this.currentLevelIndex?(u.fragmentError===0&&(u.loadError=0,this.retryCount=0),this.playlistLoaded(c,i,u.details)):(o=i.deliveryDirectives)!==null&&o!==void 0&&o.skip&&(h.deltaUpdateFailed=!0)},e.onAudioTrackSwitched=function(s,i){var o=this.hls.levels[this.currentLevelIndex];if(o&&o.audioGroupIds){for(var c=-1,h=this.hls.audioTracks[i.id].groupId,u=0;u0){var c=o.urlId,h=o.url[c];if(s)try{h=s.addDirectives(h)}catch(u){this.warn("Could not construct new URL with HLS Delivery Directives: "+u)}this.log("Attempt loading level index "+i+(s?" at sn "+s.msn+" part "+s.part:"")+" with URL-id "+c+" "+h),this.clearTimer(),this.hls.trigger(D.Events.LEVEL_LOADING,{url:h,level:i,id:c,deliveryDirectives:s||null})}},e.removeLevel=function(s,i){var o=function(u,a){return a!==i},c=this._levels.filter(function(h,u){return u!==s?!0:h.url.length>1&&i!==void 0?(h.url=h.url.filter(o),h.audioGroupIds&&(h.audioGroupIds=h.audioGroupIds.filter(o)),h.textGroupIds&&(h.textGroupIds=h.textGroupIds.filter(o)),h.urlId=0,!0):!1}).map(function(h,u){var a=h.details;return a!=null&&a.fragments&&a.fragments.forEach(function(l){l.level=u}),h});this._levels=c,this.hls.trigger(D.Events.LEVELS_UPDATED,{levels:c})},p(r,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(s){var i,o=this._levels;if(o.length!==0&&!(this.currentLevelIndex===s&&(i=o[s])!==null&&i!==void 0&&i.details)){if(s<0||s>=o.length){var c=s<0;if(this.hls.trigger(D.Events.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.LEVEL_SWITCH_ERROR,level:s,fatal:c,reason:"invalid level idx"}),c)return;s=Math.min(s,o.length-1)}this.clearTimer();var h=this.currentLevelIndex,u=o[h],a=o[s];this.log("switching to level "+s+" from "+h),this.currentLevelIndex=s;var l=m({},a,{level:s,maxBitrate:a.maxBitrate,uri:a.uri,urlId:a.urlId});delete l._urlId,this.hls.trigger(D.Events.LEVEL_SWITCHING,l);var d=a.details;if(!d||d.live){var g=this.switchParams(a.uri,u==null?void 0:u.details);this.loadPlaylist(g)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(s){this.manualLevelIndex=s,this._startLevel===void 0&&(this._startLevel=s),s!==-1&&(this.level=s)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(s){this._firstLevel=s}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var s=this.hls.config.startLevel;return s!==void 0?s:this._firstLevel}else return this._startLevel},set:function(s){this._startLevel=s}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(s){this.level=s,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=s)}}]),r}(O.default)},"./src/controller/level-helper.ts":function(W,M,T){T.r(M),T.d(M,"addGroupId",function(){return A}),T.d(M,"assignTrackIdsByGroup",function(){return b}),T.d(M,"updatePTS",function(){return I}),T.d(M,"updateFragPTSDTS",function(){return L}),T.d(M,"mergeDetails",function(){return m}),T.d(M,"mapPartIntersection",function(){return S}),T.d(M,"mapFragmentIntersection",function(){return p}),T.d(M,"adjustSliding",function(){return y}),T.d(M,"addSliding",function(){return E}),T.d(M,"computeReloadInterval",function(){return v}),T.d(M,"getFragmentWithSN",function(){return n}),T.d(M,"getPartWith",function(){return t});var C=T("./src/polyfills/number.ts"),D=T("./src/utils/logger.ts");function A(r,e,f){switch(e){case"audio":r.audioGroupIds||(r.audioGroupIds=[]),r.audioGroupIds.push(f);break;case"text":r.textGroupIds||(r.textGroupIds=[]),r.textGroupIds.push(f);break}}function b(r){var e={};r.forEach(function(f){var s=f.groupId||"";f.id=e[s]=e[s]||0,e[s]++})}function I(r,e,f){var s=r[e],i=r[f];O(s,i)}function O(r,e){var f=e.startPTS;if(Object(C.isFiniteNumber)(f)){var s=0,i;e.sn>r.sn?(s=f-r.start,i=r):(s=r.start-f,i=e),i.duration!==s&&(i.duration=s)}else if(e.sn>r.sn){var o=r.cc===e.cc;o&&r.minEndPTS?e.start=r.start+(r.minEndPTS-r.start):e.start=r.start+r.duration}else e.start=Math.max(r.start-e.duration,0)}function L(r,e,f,s,i,o){var c=s-f;c<=0&&(D.logger.warn("Fragment should have a positive duration",e),s=f+e.duration,o=i+e.duration);var h=f,u=s,a=e.startPTS,l=e.endPTS;if(Object(C.isFiniteNumber)(a)){var d=Math.abs(a-f);Object(C.isFiniteNumber)(e.deltaPTS)?e.deltaPTS=Math.max(d,e.deltaPTS):e.deltaPTS=d,h=Math.max(f,a),f=Math.min(f,a),i=Math.min(i,e.startDTS),u=Math.min(s,l),s=Math.max(s,l),o=Math.max(o,e.endDTS)}e.duration=s-f;var g=f-e.start;e.appendedPTS=s,e.start=e.startPTS=f,e.maxStartPTS=h,e.startDTS=i,e.endPTS=s,e.minEndPTS=u,e.endDTS=o;var x=e.sn;if(!r||xr.endSN)return 0;var R,P=x-r.startSN,_=r.fragments;for(_[P]=e,R=P;R>0;R--)O(_[R],_[R-1]);for(R=P;R<_.length-1;R++)O(_[R],_[R+1]);return r.fragmentHint&&O(_[_.length-1],r.fragmentHint),r.PTSKnown=r.alignedSliding=!0,g}function m(r,e){for(var f=null,s=r.fragments,i=s.length-1;i>=0;i--){var o=s[i].initSegment;if(o){f=o;break}}r.fragmentHint&&delete r.fragmentHint.endPTS;var c=0,h;if(p(r,e,function(R,P){R.relurl&&(c=R.cc-P.cc),Object(C.isFiniteNumber)(R.startPTS)&&Object(C.isFiniteNumber)(R.endPTS)&&(P.start=P.startPTS=R.startPTS,P.startDTS=R.startDTS,P.appendedPTS=R.appendedPTS,P.maxStartPTS=R.maxStartPTS,P.endPTS=R.endPTS,P.endDTS=R.endDTS,P.minEndPTS=R.minEndPTS,P.duration=R.endPTS-R.startPTS,P.duration&&(h=P),e.PTSKnown=e.alignedSliding=!0),P.elementaryStreams=R.elementaryStreams,P.loader=R.loader,P.stats=R.stats,P.urlId=R.urlId,R.initSegment&&(P.initSegment=R.initSegment,f=R.initSegment)}),f){var u=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;u.forEach(function(R){var P;(!R.initSegment||R.initSegment.relurl===((P=f)===null||P===void 0?void 0:P.relurl))&&(R.initSegment=f)})}if(e.skippedSegments&&(e.deltaUpdateFailed=e.fragments.some(function(R){return!R}),e.deltaUpdateFailed)){D.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var a=e.skippedSegments;a--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}var l=e.fragments;if(c){D.logger.warn("discontinuity sliding from playlist, take drift into account");for(var d=0;d=s.length||E(e,s[f].start)}function E(r,e){if(e){for(var f=r.fragments,s=r.skippedSegments;s0&&i0&&u===-1&&(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),u=a),this.state=D.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=u,this.tick()}else this._forceStartLoad=!0,this.state=D.State.STOPPED},c.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},c.doTick=function(){switch(this.state){case D.State.IDLE:this.doTickIdle();break;case D.State.WAITING_LEVEL:{var u,a=this.levels,l=this.level,d=a==null||(u=a[l])===null||u===void 0?void 0:u.details;if(d&&(!d.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(d))break;this.state=D.State.IDLE;break}break}case D.State.FRAG_LOADING_WAITING_RETRY:{var g,x=self.performance.now(),R=this.retryDate;(!R||x>=R||(g=this.media)!==null&&g!==void 0&&g.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=D.State.IDLE)}break}this.onTickEnd()},c.onTickEnd=function(){i.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},c.doTickIdle=function(){var u,a,l=this.hls,d=this.levelLastLoaded,g=this.levels,x=this.media,R=l.config,P=l.nextLoadLevel;if(!(d===null||!x&&(this.startFragRequested||!R.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!g||!g[P])){var _=g[P];this.level=l.nextLoadLevel=P;var F=_.details;if(!F||this.state===D.State.WAITING_LEVEL||F.live&&this.levelLastLoaded!==P){this.state=D.State.WAITING_LEVEL;return}var B=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:x,L.PlaylistLevelType.MAIN);if(B!==null){var U=B.len,N=this.getMaxBufferLength(_.maxBitrate);if(!(U>=N)){if(this._streamEnded(B,F)){var k={};this.altAudio&&(k.type="video"),this.hls.trigger(b.Events.BUFFER_EOS,k),this.state=D.State.ENDED;return}var w=B.end,K=this.getNextFragment(w,F);if(this.couldBacktrack&&!this.fragPrevious&&K&&K.sn!=="initSegment"){var j=K.sn-F.startSN;j>1&&(K=F.fragments[j-1],this.fragmentTracker.removeFragment(K))}if(K&&this.fragmentTracker.getState(K)===O.FragmentState.OK&&this.nextLoadPosition>w){var H=this.audioOnly&&!this.altAudio?m.ElementaryStreamTypes.AUDIO:m.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(x,H,L.PlaylistLevelType.MAIN),K=this.getNextFragment(this.nextLoadPosition,F)}K&&(K.initSegment&&!K.initSegment.data&&!this.bitrateTest&&(K=K.initSegment),((u=K.decryptdata)===null||u===void 0?void 0:u.keyFormat)==="identity"&&!((a=K.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(K,F):this.loadFragment(K,F,w))}}}},c.loadFragment=function(u,a,l){var d,g=this.fragmentTracker.getState(u);if(this.fragCurrent=u,g===O.FragmentState.BACKTRACKED){var x=this.fragmentTracker.getBacktrackData(u);if(x){this._handleFragmentLoadProgress(x),this._handleFragmentLoadComplete(x);return}else g=O.FragmentState.NOT_LOADED}g===O.FragmentState.NOT_LOADED||g===O.FragmentState.PARTIAL?u.sn==="initSegment"?this._loadInitSegment(u):this.bitrateTest?(u.bitrateTest=!0,this.log("Fragment "+u.sn+" of level "+u.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(u)):(this.startFragRequested=!0,i.prototype.loadFragment.call(this,u,a,l)):g===O.FragmentState.APPENDING?this.reduceMaxBufferLength(u.duration)&&this.fragmentTracker.removeFragment(u):((d=this.media)===null||d===void 0?void 0:d.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},c.getAppendedFrag=function(u){var a=this.fragmentTracker.getAppendedFrag(u,L.PlaylistLevelType.MAIN);return a&&"fragment"in a?a.fragment:a},c.getBufferedFrag=function(u){return this.fragmentTracker.getBufferedFrag(u,L.PlaylistLevelType.MAIN)},c.followingBufferedFrag=function(u){return u?this.getBufferedFrag(u.end+.5):null},c.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},c.nextLevelSwitch=function(){var u=this.levels,a=this.media;if(a!=null&&a.readyState){var l,d=this.getAppendedFrag(a.currentTime);if(d&&d.start>1&&this.flushMainBuffer(0,d.start-1),!a.paused&&u){var g=this.hls.nextLoadLevel,x=u[g],R=this.fragLastKbps;R&&this.fragCurrent?l=this.fragCurrent.duration*x.maxBitrate/(1e3*R)+1:l=0}else l=0;var P=this.getBufferedFrag(a.currentTime+l);if(P){var _=this.followingBufferedFrag(P);if(_){this.abortCurrentFrag();var F=_.maxStartPTS?_.maxStartPTS:_.start,B=_.duration,U=Math.max(P.end,F+Math.min(Math.max(B-this.config.maxFragLookUpTolerance,B*.5),B*.75));this.flushMainBuffer(U,Number.POSITIVE_INFINITY)}}}},c.abortCurrentFrag=function(){var u=this.fragCurrent;this.fragCurrent=null,u!=null&&u.loader&&u.loader.abort(),this.state===D.State.KEY_LOADING&&(this.state=D.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},c.flushMainBuffer=function(u,a){i.prototype.flushMainBuffer.call(this,u,a,this.altAudio?"video":null)},c.onMediaAttached=function(u,a){i.prototype.onMediaAttached.call(this,u,a);var l=a.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),l.addEventListener("playing",this.onvplaying),l.addEventListener("seeked",this.onvseeked),this.gapController=new y.default(this.config,l,this.fragmentTracker,this.hls)},c.onMediaDetaching=function(){var u=this.media;u&&(u.removeEventListener("playing",this.onvplaying),u.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),i.prototype.onMediaDetaching.call(this)},c.onMediaPlaying=function(){this.tick()},c.onMediaSeeked=function(){var u=this.media,a=u?u.currentTime:null;Object(C.isFiniteNumber)(a)&&this.log("Media seeked to "+a.toFixed(3)),this.tick()},c.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(b.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},c.onManifestParsed=function(u,a){var l=!1,d=!1,g;a.levels.forEach(function(x){g=x.audioCodec,g&&(g.indexOf("mp4a.40.2")!==-1&&(l=!0),g.indexOf("mp4a.40.5")!==-1&&(d=!0))}),this.audioCodecSwitch=l&&d&&!Object(A.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=a.levels,this.startFragRequested=!1},c.onLevelLoading=function(u,a){var l=this.levels;if(!(!l||this.state!==D.State.IDLE)){var d=l[a.level];(!d.details||d.details.live&&this.levelLastLoaded!==a.level||this.waitForCdnTuneIn(d.details))&&(this.state=D.State.WAITING_LEVEL)}},c.onLevelLoaded=function(u,a){var l,d=this.levels,g=a.level,x=a.details,R=x.totalduration;if(!d){this.warn("Levels were reset while loading level "+g);return}this.log("Level "+g+" loaded ["+x.startSN+","+x.endSN+"], cc ["+x.startCC+", "+x.endCC+"] duration:"+R);var P=this.fragCurrent;P&&(this.state===D.State.FRAG_LOADING||this.state===D.State.FRAG_LOADING_WAITING_RETRY)&&P.level!==a.level&&P.loader&&(this.state=D.State.IDLE,P.loader.abort());var _=d[g],F=0;if(x.live||(l=_.details)!==null&&l!==void 0&&l.live){if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed)return;F=this.alignPlaylists(x,_.details)}if(_.details=x,this.levelLastLoaded=g,this.hls.trigger(b.Events.LEVEL_UPDATED,{details:x,level:g}),this.state===D.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(x))return;this.state=D.State.IDLE}this.startFragRequested?x.live&&this.synchronizeToLiveEdge(x):this.setStartPosition(x,F),this.tick()},c._handleFragmentLoadProgress=function(u){var a,l=u.frag,d=u.part,g=u.payload,x=this.levels;if(!x){this.warn("Levels were reset while fragment load was in progress. Fragment "+l.sn+" of level "+l.level+" will not be buffered");return}var R=x[l.level],P=R.details;if(!P){this.warn("Dropping fragment "+l.sn+" of level "+l.level+" after level details were reset");return}var _=R.videoCodec,F=P.PTSKnown||!P.live,B=(a=l.initSegment)===null||a===void 0?void 0:a.data,U=this._getAudioCodec(R),N=this.transmuxer=this.transmuxer||new S.default(this.hls,L.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),k=d?d.index:-1,w=k!==-1,K=new p.ChunkMetadata(l.level,l.sn,l.stats.chunkCount,g.byteLength,k,w),j=this.initPTS[l.cc];N.push(g,B,U,_,l,d,P.totalduration,F,K,j)},c.onAudioTrackSwitching=function(u,a){var l=this.altAudio,d=!!a.url,g=a.id;if(!d){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var x=this.fragCurrent;x!=null&&x.loader&&(this.log("Switching to main audio track, cancel main fragment load"),x.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var R=this.hls;l&&R.trigger(b.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),R.trigger(b.Events.AUDIO_TRACK_SWITCHED,{id:g})}},c.onAudioTrackSwitched=function(u,a){var l=a.id,d=!!this.hls.audioTracks[l].url;if(d){var g=this.videoBuffer;g&&this.mediaBuffer!==g&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=g)}this.altAudio=d,this.tick()},c.onBufferCreated=function(u,a){var l=a.tracks,d,g,x=!1;for(var R in l){var P=l[R];if(P.id==="main"){if(g=R,d=P,R==="video"){var _=l[R];_&&(this.videoBuffer=_.buffer)}}else x=!0}x&&d?(this.log("Alternate track found, use "+g+".buffered to schedule main fragment loading"),this.mediaBuffer=d.buffer):this.mediaBuffer=this.media},c.onFragBuffered=function(u,a){var l=a.frag,d=a.part;if(!(l&&l.type!==L.PlaylistLevelType.MAIN)){if(this.fragContextChanged(l)){this.warn("Fragment "+l.sn+(d?" p: "+d.index:"")+" of level "+l.level+" finished buffering, but was aborted. state: "+this.state),this.state===D.State.PARSED&&(this.state=D.State.IDLE);return}var g=d?d.stats:l.stats;this.fragLastKbps=Math.round(8*g.total/(g.buffering.end-g.loading.first)),l.sn!=="initSegment"&&(this.fragPrevious=l),this.fragBufferedComplete(l,d)}},c.onError=function(u,a){switch(a.details){case E.ErrorDetails.FRAG_LOAD_ERROR:case E.ErrorDetails.FRAG_LOAD_TIMEOUT:case E.ErrorDetails.KEY_LOAD_ERROR:case E.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(L.PlaylistLevelType.MAIN,a);break;case E.ErrorDetails.LEVEL_LOAD_ERROR:case E.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==D.State.ERROR&&(a.fatal?(this.warn(""+a.details),this.state=D.State.ERROR):!a.levelRetry&&this.state===D.State.WAITING_LEVEL&&(this.state=D.State.IDLE));break;case E.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="main"&&(this.state===D.State.PARSING||this.state===D.State.PARSED)){var l=!0,d=this.getFwdBufferInfo(this.media,L.PlaylistLevelType.MAIN);d&&d.len>.5&&(l=!this.reduceMaxBufferLength(d.len)),l&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break}},c.checkBuffer=function(){var u=this.media,a=this.gapController;if(!(!u||!a||!u.readyState)){var l=I.BufferHelper.getBuffered(u);!this.loadedmetadata&&l.length?(this.loadedmetadata=!0,this.seekToStartPos()):a.poll(this.lastCurrentTime),this.lastCurrentTime=u.currentTime}},c.onFragLoadEmergencyAborted=function(){this.state=D.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},c.onBufferFlushed=function(u,a){var l=a.type;if(l!==m.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var d=(l===m.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(d,l,L.PlaylistLevelType.MAIN)}},c.onLevelsUpdated=function(u,a){this.levels=a.levels},c.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},c.seekToStartPos=function(){var u=this.media,a=u.currentTime,l=this.startPosition;if(l>=0&&a0&&(x1&&u.seeking===!1){var l=u.currentTime;if(I.BufferHelper.isBuffered(u,l)?a=this.getAppendedFrag(l):I.BufferHelper.isBuffered(u,l+.1)&&(a=this.getAppendedFrag(l+.1)),a){var d=this.fragPlaying,g=a.level;(!d||a.sn!==d.sn||d.level!==g||a.urlId!==d.urlId)&&(this.hls.trigger(b.Events.FRAG_CHANGED,{frag:a}),(!d||d.level!==g)&&this.hls.trigger(b.Events.LEVEL_SWITCHED,{level:g}),this.fragPlaying=a)}}},t(o,[{key:"nextLevel",get:function(){var u=this.nextBufferedFrag;return u?u.level:-1}},{key:"currentLevel",get:function(){var u=this.media;if(u){var a=this.getAppendedFrag(u.currentTime);if(a)return a.level}return-1}},{key:"nextBufferedFrag",get:function(){var u=this.media;if(u){var a=this.getAppendedFrag(u.currentTime);return this.followingBufferedFrag(a)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),o}(D.default)},"./src/controller/subtitle-stream-controller.ts":function(W,M,T){T.r(M),T.d(M,"SubtitleStreamController",function(){return r});var C=T("./src/events.ts"),D=T("./src/utils/logger.ts"),A=T("./src/utils/buffer-helper.ts"),b=T("./src/controller/fragment-finders.ts"),I=T("./src/utils/discontinuities.ts"),O=T("./src/controller/level-helper.ts"),L=T("./src/controller/fragment-tracker.ts"),m=T("./src/controller/base-stream-controller.ts"),S=T("./src/types/loader.ts"),p=T("./src/types/level.ts");function y(e,f){for(var s=0;s=a[g].start&&d<=a[g].end){l=a[g];break}var x=h.start+h.duration;l?l.end=x:(l={start:d,end:x},a.push(l)),this.fragmentTracker.fragBuffered(h)}}},s.onBufferFlushing=function(o,c){var h=c.startOffset,u=c.endOffset;if(h===0&&u!==Number.POSITIVE_INFINITY){var a=this.currentTrackId,l=this.levels;if(!l.length||!l[a]||!l[a].details)return;var d=l[a].details,g=d.targetduration,x=u-g;if(x<=0)return;c.endOffsetSubtitles=Math.max(0,x),this.tracksBuffered.forEach(function(R){for(var P=0;P=d.length||a!==l||!g)){if(this.mediaBuffer=this.mediaBufferTimeRanges,u.live||(h=g.details)!==null&&h!==void 0&&h.live){var x=this.mainDetails;if(u.deltaUpdateFailed||!x)return;var R=x.fragments[0];if(!g.details)u.hasProgramDateTime&&x.hasProgramDateTime?Object(I.alignMediaPlaylistByPDT)(u,x):R&&Object(O.addSliding)(u,R.start);else{var P=this.alignPlaylists(u,g.details);P===0&&R&&Object(O.addSliding)(u,R.start)}}if(g.details=u,this.levelLastLoaded=a,this.tick(),u.live&&!this.fragCurrent&&this.media&&this.state===m.State.IDLE){var _=Object(b.findFragmentByPTS)(null,u.fragments,this.media.currentTime,0);_||(this.warn("Subtitle playlist not aligned with playback"),g.details=void 0)}}}},s._handleFragmentLoadComplete=function(o){var c=o.frag,h=o.payload,u=c.decryptdata,a=this.hls;if(!this.fragContextChanged(c)&&h&&h.byteLength>0&&u&&u.key&&u.iv&&u.method==="AES-128"){var l=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(h),u.key.buffer,u.iv.buffer).then(function(d){var g=performance.now();a.trigger(C.Events.FRAG_DECRYPTED,{frag:c,payload:d,stats:{tstart:l,tdecrypt:g}})})}},s.doTick=function(){if(!this.media){this.state=m.State.IDLE;return}if(this.state===m.State.IDLE){var o,c=this.currentTrackId,h=this.levels;if(!h.length||!h[c]||!h[c].details)return;var u=h[c].details,a=u.targetduration,l=this.config,d=this.media,g=A.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,d.currentTime-a,l.maxBufferHole),x=g.end,R=g.len,P=this.getMaxBufferLength()+a;if(R>P)return;console.assert(u,"Subtitle track details are defined on idle subtitle stream controller tick");var _=u.fragments,F=_.length,B=u.edge,U,N=this.fragPrevious;if(x-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},v.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},v.onMediaDetaching=function(){if(this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var t=p(this.media.textTracks);t.forEach(function(r){Object(D.clearCurrentCues)(r)}),this.subtitleTrack=-1,this.media=null}},v.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},v.onManifestParsed=function(t,r){this.tracks=r.subtitleTracks},v.onSubtitleTrackLoaded=function(t,r){var e=r.id,f=r.details,s=this.trackId,i=this.tracksInGroup[s];if(!i){this.warn("Invalid subtitle track id "+e);return}var o=i.details;i.details=r.details,this.log("subtitle track "+e+" loaded ["+f.startSN+"-"+f.endSN+"]"),e===this.trackId&&(this.retryCount=0,this.playlistLoaded(e,r,o))},v.onLevelLoading=function(t,r){this.switchLevel(r.level)},v.onLevelSwitching=function(t,r){this.switchLevel(r.level)},v.switchLevel=function(t){var r=this.hls.levels[t];if(r!=null&&r.textGroupIds){var e=r.textGroupIds[r.urlId];if(this.groupId!==e){var f=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,s=this.tracks.filter(function(c){return!e||c.groupId===e});this.tracksInGroup=s;var i=this.findTrackId(f==null?void 0:f.name)||this.findTrackId();this.groupId=e;var o={subtitleTracks:s};this.log("Updating subtitle tracks, "+s.length+' track(s) found in "'+e+'" group-id'),this.hls.trigger(C.Events.SUBTITLE_TRACKS_UPDATED,o),i!==-1&&this.setSubtitleTrack(i,f)}}},v.findTrackId=function(t){for(var r=this.tracksInGroup,e=0;e=f.length)){this.clearTimer();var s=f[t];if(this.log("Switching to subtitle track "+t),this.trackId=t,s){var i=s.id,o=s.groupId,c=o===void 0?"":o,h=s.name,u=s.type,a=s.url;this.hls.trigger(C.Events.SUBTITLE_TRACK_SWITCH,{id:i,groupId:c,name:h,type:u,url:a});var l=this.switchParams(s.url,r==null?void 0:r.details);this.loadPlaylist(l)}else this.hls.trigger(C.Events.SUBTITLE_TRACK_SWITCH,{id:t})}},v.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var t=-1,r=p(this.media.textTracks),e=0;e=0&&(u[0]=Math.min(u[0],f),u[1]=Math.max(u[1],s),c=!0,a/(s-f)>.5))return}if(c||o.push([f,s]),this.config.renderTextTracksNatively){var l=this.captionsTracks[e];this.Cues.newCue(l,f,s,i)}else{var d=this.Cues.newCue(null,f,s,i);this.hls.trigger(D.Events.CUES_PARSED,{type:"captions",cues:d,track:e})}},t.onInitPtsFound=function(e,f){var s=this,i=f.frag,o=f.id,c=f.initPTS,h=f.timescale,u=this.unparsedVttFrags;o==="main"&&(this.initPTS[i.cc]=c,this.timescale[i.cc]=h),u.length&&(this.unparsedVttFrags=[],u.forEach(function(a){s.onFragLoaded(D.Events.FRAG_LOADED,a)}))},t.getExistingTrack=function(e){var f=this.media;if(f)for(var s=0;s>>8^h&255^99,L[i]=h,m[h]=i;var u=s[i],a=s[u],l=s[a],d=s[h]*257^h*16843008;p[i]=d<<24|d>>>8,y[i]=d<<16|d>>>16,E[i]=d<<8|d>>>24,v[i]=d,d=l*16843009^a*65537^u*257^i*16843008,t[h]=d<<24|d>>>8,r[h]=d<<16|d>>>16,e[h]=d<<8|d>>>24,f[h]=d,i?(i=u^s[s[s[l^u]]],o^=s[s[o]]):i=o=1}},I.expandKey=function(L){for(var m=this.uint8ArrayToUint32Array_(L),S=!0,p=0;p>>6)+1;var d=(e[f+2]&60)>>>2;if(d>l.length-1){r.trigger(A.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d});return}return c=(e[f+2]&1)<<2,c|=(e[f+3]&192)>>>6,C.logger.log("manifest codec:"+s+", ADTS type:"+i+", samplingIndex:"+d),/firefox/i.test(u)?d>=6?(i=5,h=new Array(4),o=d-3):(i=2,h=new Array(2),o=d):u.indexOf("android")!==-1?(i=2,h=new Array(2),o=d):(i=5,h=new Array(4),s&&(s.indexOf("mp4a.40.29")!==-1||s.indexOf("mp4a.40.5")!==-1)||!s&&d>=6?o=d-3:((s&&s.indexOf("mp4a.40.2")!==-1&&(d>=6&&c===1||/vivaldi/i.test(u))||!s&&c===1)&&(i=2,h=new Array(2)),o=d)),h[0]=i<<3,h[0]|=(d&14)>>1,h[1]|=(d&1)<<7,h[1]|=c<<3,i===5&&(h[1]|=(o&14)>>1,h[2]=(o&1)<<7,h[2]|=8,h[3]=0),{config:h,samplerate:l[d],channelCount:c,codec:"mp4a.40."+i,manifestCodec:a}}function I(r,e){return r[e]===255&&(r[e+1]&246)===240}function O(r,e){return r[e+1]&1?7:9}function L(r,e){return(r[e+3]&3)<<11|r[e+4]<<3|(r[e+5]&224)>>>5}function m(r,e){return e+5=r.length)return!1;var s=L(r,e);if(s<=f)return!1;var i=e+s;return i===r.length||S(r,i)}return!1}function E(r,e,f,s,i){if(!r.samplerate){var o=b(e,f,s,i);if(!o)return;r.config=o.config,r.samplerate=o.samplerate,r.channelCount=o.channelCount,r.codec=o.codec,r.manifestCodec=o.manifestCodec,C.logger.log("parsed codec:"+r.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function v(r){return 1024*9e4/r}function n(r,e,f,s,i){var o=O(r,e),c=L(r,e);if(c-=o,c>0){var h=f+s*i;return{headerLength:o,frameLength:c,stamp:h}}}function t(r,e,f,s,i){var o=v(r.samplerate),c=n(e,f,s,i,o);if(c){var h=c.frameLength,u=c.headerLength,a=c.stamp,l=u+h,d=Math.max(0,f+l-e.length),g;d?(g=new Uint8Array(l-u),g.set(e.subarray(f+u,e.length),0)):g=e.subarray(f+u,f+l);var x={unit:g,pts:a};return d||r.samples.push(x),{sample:x,length:l,missing:d}}}},"./src/demux/base-audio-demuxer.ts":function(W,M,T){T.r(M),T.d(M,"initPTSFn",function(){return L});var C=T("./src/polyfills/number.ts"),D=T("./src/demux/id3.ts"),A=T("./src/demux/dummy-demuxed-track.ts"),b=T("./src/utils/mp4-tools.ts"),I=T("./src/utils/typed-array.ts"),O=function(){function m(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var S=m.prototype;return S.resetInitSegment=function(y,E,v){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},S.resetTimeStamp=function(){},S.resetContiguity=function(){},S.canParse=function(y,E){return!1},S.appendFrame=function(y,E,v){},S.demux=function(y,E){this.cachedData&&(y=Object(b.appendUint8Array)(this.cachedData,y),this.cachedData=null);var v=D.getID3Data(y,0),n=v?v.length:0,t,r,e=this._audioTrack,f=this._id3Track,s=v?D.getTimeStamp(v):void 0,i=y.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=L(s,E)),v&&v.length>0&&f.samples.push({pts:this.initPTS,dts:this.initPTS,data:v}),r=this.initPTS;nO?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,L=O>>3,O-=L>>3,this.bytesAvailable-=L,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},b.readBits=function(O){var L=Math.min(this.bitsAvailable,O),m=this.word>>>32-L;return O>32&&C.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=L,this.bitsAvailable>0?this.word<<=L:this.bytesAvailable>0&&this.loadWord(),L=O-L,L>0&&this.bitsAvailable?m<>>O)return this.word<<=O,this.bitsAvailable-=O,O;return this.loadWord(),O+this.skipLZ()},b.skipUEG=function(){this.skipBits(1+this.skipLZ())},b.skipEG=function(){this.skipBits(1+this.skipLZ())},b.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},b.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>1)},b.readBoolean=function(){return this.readBits(1)===1},b.readUByte=function(){return this.readBits(8)},b.readUShort=function(){return this.readBits(16)},b.readUInt=function(){return this.readBits(32)},b.skipScalingList=function(O){for(var L=8,m=8,S,p=0;p0)return i.subarray(c,c+h)},b=function(i,o){var c=0;return c=(i[o]&127)<<21,c|=(i[o+1]&127)<<14,c|=(i[o+2]&127)<<7,c|=i[o+3]&127,c},I=function(i,o){return C(i,o)&&b(i,o+6)+10<=i.length-o},O=function(i){for(var o=S(i),c=0;c>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:x+=String.fromCharCode(l);break;case 12:case 13:d=i[R++],x+=String.fromCharCode((l&31)<<6|d&63);break;case 14:d=i[R++],g=i[R++],x+=String.fromCharCode((l&15)<<12|(d&63)<<6|(g&63)<<0);break}}return x},r={decodeTextFrame:E},e;function f(){return!e&&typeof self.TextDecoder<"u"&&(e=new self.TextDecoder("utf-8")),e}},"./src/demux/mp3demuxer.ts":function(W,M,T){T.r(M);var C=T("./src/demux/base-audio-demuxer.ts"),D=T("./src/demux/id3.ts"),A=T("./src/utils/logger.ts"),b=T("./src/demux/mpegaudio.ts");function I(m,S){m.prototype=Object.create(S.prototype),m.prototype.constructor=m,O(m,S)}function O(m,S){return O=Object.setPrototypeOf||function(y,E){return y.__proto__=E,y},O(m,S)}var L=function(m){I(S,m);function S(){return m.apply(this,arguments)||this}var p=S.prototype;return p.resetInitSegment=function(E,v,n){m.prototype.resetInitSegment.call(this,E,v,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:E,duration:n,inputTimeScale:9e4,dropped:0}},S.probe=function(E){if(!E)return!1;for(var v=D.getID3Data(E,0)||[],n=v.length,t=E.length;n0},I.demux=function(L){var m=L,S=Object(D.dummyTrack)();if(this.config.progressive){this.remainderData&&(m=Object(C.appendUint8Array)(this.remainderData,L));var p=Object(C.segmentValidRange)(m);this.remainderData=p.remainder,S.samples=p.valid||new Uint8Array}else S.samples=m;return{audioTrack:Object(D.dummyTrack)(),avcTrack:S,id3Track:Object(D.dummyTrack)(),textTrack:Object(D.dummyTrack)()}},I.flush=function(){var L=Object(D.dummyTrack)();return L.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(D.dummyTrack)(),avcTrack:L,id3Track:Object(D.dummyTrack)(),textTrack:Object(D.dummyTrack)()}},I.demuxSampleAes=function(L,m,S){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},I.destroy=function(){},b}();A.minProbeByteLength=1024,M.default=A},"./src/demux/mpegaudio.ts":function(W,M,T){T.r(M),T.d(M,"appendFrame",function(){return O}),T.d(M,"parseHeader",function(){return L}),T.d(M,"isHeaderPattern",function(){return m}),T.d(M,"isHeader",function(){return S}),T.d(M,"canParse",function(){return p}),T.d(M,"probe",function(){return y});var C=null,D=[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],A=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],b=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],I=[0,1,1,4];function O(E,v,n,t,r){if(!(n+24>v.length)){var e=L(v,n);if(e&&n+e.frameLength<=v.length){var f=e.samplesPerFrame*9e4/e.sampleRate,s=t+r*f,i={unit:v.subarray(n,n+e.frameLength),pts:s,dts:s};return E.config=[],E.channelCount=e.channelCount,E.samplerate=e.sampleRate,E.samples.push(i),{sample:i,length:e.frameLength,missing:0}}}}function L(E,v){var n=E[v+1]>>3&3,t=E[v+1]>>1&3,r=E[v+2]>>4&15,e=E[v+2]>>2&3;if(n!==1&&r!==0&&r!==15&&e!==3){var f=E[v+2]>>1&1,s=E[v+3]>>6,i=n===3?3-t:t===3?3:4,o=D[i*14+r-1]*1e3,c=n===3?0:n===2?1:2,h=A[c*3+e],u=s===3?1:2,a=b[n][t],l=I[t],d=a*8*l,g=Math.floor(a*o/h+f)*l;if(C===null){var x=navigator.userAgent||"",R=x.match(/Chrome\/(\d+)/i);C=R?parseInt(R[1]):0}var P=!!C&&C<=87;return P&&t===2&&o>=224e3&&s===0&&(E[v+3]=E[v+3]|128),{sampleRate:h,channelCount:u,frameLength:g,samplesPerFrame:d}}}function m(E,v){return E[v]===255&&(E[v+1]&224)===224&&(E[v+1]&6)!==0}function S(E,v){return v+1=L.length){S();return}if(!(L[m].unit.length<32)){var p=this.decrypter.isSync();if(this.decryptAacSample(L,m,S,p),!p)return}}},I.getAvcEncryptedData=function(L){for(var m=Math.floor((L.length-48)/160)*16+16,S=new Int8Array(m),p=0,y=32;y=L.length){p();return}for(var y=L[m].units;!(S>=y.length);S++){var E=y[S];if(!(E.data.length<=48||E.type!==1&&E.type!==5)){var v=this.decrypter.isSync();if(this.decryptAvcSample(L,m,S,p,E,v),!v)return}}}},b}();M.default=A},"./src/demux/transmuxer-interface.ts":function(W,M,T){T.r(M),T.d(M,"default",function(){return S});var C=T("./node_modules/webworkify-webpack/index.js"),D=T("./src/events.ts"),A=T("./src/demux/transmuxer.ts"),b=T("./src/utils/logger.ts"),I=T("./src/errors.ts"),O=T("./src/utils/mediasource-helper.ts"),L=T("./node_modules/eventemitter3/index.js"),m=Object(O.getMediaSource)()||{isTypeSupported:function(){return!1}},S=function(){function p(E,v,n,t){var r=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=E,this.id=v,this.onTransmuxComplete=n,this.onFlush=t;var e=E.config,f=function(h,u){u=u||{},u.frag=r.frag,u.id=r.id,E.trigger(h,u)};this.observer=new L.EventEmitter,this.observer.on(D.Events.FRAG_DECRYPTED,f),this.observer.on(D.Events.ERROR,f);var s={mp4:m.isTypeSupported("video/mp4"),mpeg:m.isTypeSupported("audio/mpeg"),mp3:m.isTypeSupported('audio/mp4; codecs="mp3"')},i=navigator.vendor;if(e.enableWorker&&typeof Worker<"u"){b.logger.log("demuxing in webworker");var o;try{o=this.worker=C("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),o.addEventListener("message",this.onwmsg),o.onerror=function(c){E.trigger(D.Events.ERROR,{type:I.ErrorTypes.OTHER_ERROR,details:I.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},o.postMessage({cmd:"init",typeSupported:s,vendor:i,id:v,config:JSON.stringify(e)})}catch(c){b.logger.warn("Error in worker:",c),b.logger.error("Error while initializing DemuxerWorker, fallback to inline"),o&&self.URL.revokeObjectURL(o.objectURL),this.transmuxer=new A.default(this.observer,s,e,i,v),this.worker=null}}else this.transmuxer=new A.default(this.observer,s,e,i,v)}var y=p.prototype;return y.destroy=function(){var v=this.worker;if(v)v.removeEventListener("message",this.onwmsg),v.terminate(),this.worker=null;else{var n=this.transmuxer;n&&(n.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.observer=null},y.push=function(v,n,t,r,e,f,s,i,o,c){var h,u,a=this;o.transmuxing.start=self.performance.now();var l=this.transmuxer,d=this.worker,g=f?f.start:e.start,x=e.decryptdata,R=this.frag,P=!(R&&e.cc===R.cc),_=!(R&&o.level===R.level),F=R?o.sn-R.sn:-1,B=this.part?o.part-this.part.index:1,U=!_&&(F===1||F===0&&B===1),N=self.performance.now();(_||F||e.stats.parsing.start===0)&&(e.stats.parsing.start=N),f&&(B||!U)&&(f.stats.parsing.start=N);var k=!(R&&((h=e.initSegment)===null||h===void 0?void 0:h.url)===((u=R.initSegment)===null||u===void 0?void 0:u.url)),w=new A.TransmuxState(P,U,i,_,g,k);if(!U||P||k){b.logger.log("[transmuxer-interface, "+e.type+"]: Starting new transmux session for sn: "+o.sn+" p: "+o.part+" level: "+o.level+" id: "+o.id+` discontinuity: `+P+` trackSwitch: `+_+` contiguous: `+U+` accurateTimeOffset: `+i+` timeOffset: `+g+` initSegmentChange: `+k);var K=new A.TransmuxConfig(t,r,n,s,c);this.configureTransmuxer(K)}if(this.frag=e,this.part=f,d)d.postMessage({cmd:"demux",data:v,decryptdata:x,chunkMeta:o,state:w},v instanceof ArrayBuffer?[v]:[]);else if(l){var j=l.push(v,x,o,w);Object(A.isPromise)(j)?j.then(function(H){a.handleTransmuxComplete(H)}):this.handleTransmuxComplete(j)}},y.flush=function(v){var n=this;v.transmuxing.start=self.performance.now();var t=this.transmuxer,r=this.worker;if(r)r.postMessage({cmd:"flush",chunkMeta:v});else if(t){var e=t.flush(v);Object(A.isPromise)(e)?e.then(function(f){n.handleFlushResult(f,v)}):this.handleFlushResult(e,v)}},y.handleFlushResult=function(v,n){var t=this;v.forEach(function(r){t.handleTransmuxComplete(r)}),this.onFlush(n)},y.onWorkerMessage=function(v){var n=v.data,t=this.hls;switch(n.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(n.data);break}case"flush":{this.onFlush(n.data);break}default:{n.data=n.data||{},n.data.frag=this.frag,n.data.id=this.id,t.trigger(n.event,n.data);break}}},y.configureTransmuxer=function(v){var n=this.worker,t=this.transmuxer;n?n.postMessage({cmd:"configure",config:v}):t&&t.configure(v)},y.handleTransmuxComplete=function(v){v.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(v)},p}()},"./src/demux/transmuxer-worker.ts":function(W,M,T){T.r(M),T.d(M,"default",function(){return I});var C=T("./src/demux/transmuxer.ts"),D=T("./src/events.ts"),A=T("./src/utils/logger.ts"),b=T("./node_modules/eventemitter3/index.js");function I(p){var y=new b.EventEmitter,E=function(n,t){p.postMessage({event:n,data:t})};y.on(D.Events.FRAG_DECRYPTED,E),y.on(D.Events.ERROR,E),p.addEventListener("message",function(v){var n=v.data;switch(n.cmd){case"init":{var t=JSON.parse(n.config);p.transmuxer=new C.default(y,n.typeSupported,t,n.vendor,n.id),Object(A.enableLogs)(t.debug),E("init",null);break}case"configure":{p.transmuxer.configure(n.config);break}case"demux":{var r=p.transmuxer.push(n.data,n.decryptdata,n.chunkMeta,n.state);Object(C.isPromise)(r)?r.then(function(s){O(p,s)}):O(p,r);break}case"flush":{var e=n.chunkMeta,f=p.transmuxer.flush(e);Object(C.isPromise)(f)?f.then(function(s){m(p,s,e)}):m(p,f,e);break}}})}function O(p,y){if(!S(y.remuxResult)){var E=[],v=y.remuxResult,n=v.audio,t=v.video;n&&L(E,n),t&&L(E,t),p.postMessage({event:"transmuxComplete",data:y},E)}}function L(p,y){y.data1&&p.push(y.data1.buffer),y.data2&&p.push(y.data2.buffer)}function m(p,y,E){y.forEach(function(v){O(p,v)}),p.postMessage({event:"flush",data:E})}function S(p){return!p.audio&&!p.video&&!p.text&&!p.id3&&!p.initSegment}},"./src/demux/transmuxer.ts":function(W,M,T){T.r(M),T.d(M,"default",function(){return r}),T.d(M,"isPromise",function(){return s}),T.d(M,"TransmuxConfig",function(){return i}),T.d(M,"TransmuxState",function(){return o});var C=T("./src/events.ts"),D=T("./src/errors.ts"),A=T("./src/crypt/decrypter.ts"),b=T("./src/demux/aacdemuxer.ts"),I=T("./src/demux/mp4demuxer.ts"),O=T("./src/demux/tsdemuxer.ts"),L=T("./src/demux/mp3demuxer.ts"),m=T("./src/remux/mp4-remuxer.ts"),S=T("./src/remux/passthrough-remuxer.ts"),p=T("./src/demux/chunk-cache.ts"),y=T("./src/utils/mp4-tools.ts"),E=T("./src/utils/logger.ts"),v;try{v=self.performance.now.bind(self.performance)}catch{E.logger.debug("Unable to use Performance API on this environment"),v=self.Date.now}var n=[{demux:O.default,remux:m.default},{demux:I.default,remux:S.default},{demux:b.default,remux:m.default},{demux:L.default,remux:m.default}],t=1024;n.forEach(function(c){var h=c.demux;t=Math.max(t,h.minProbeByteLength)});var r=function(){function c(u,a,l,d,g){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.cache=new p.default,this.observer=u,this.typeSupported=a,this.config=l,this.vendor=d,this.id=g}var h=c.prototype;return h.configure=function(a){this.transmuxConfig=a,this.decrypter&&this.decrypter.reset()},h.push=function(a,l,d,g){var x=this,R=d.transmuxing;R.executeStart=v();var P=new Uint8Array(a),_=this.cache,F=this.config,B=this.currentTransmuxState,U=this.transmuxConfig;g&&(this.currentTransmuxState=g);var N=e(P,l);if(N&&N.method==="AES-128"){var k=this.getDecrypter();if(F.enableSoftwareAES){var w=k.softwareDecrypt(P,N.key.buffer,N.iv.buffer);if(!w)return R.executeEnd=v(),f(d);P=new Uint8Array(w)}else return this.decryptionPromise=k.webCryptoDecrypt(P,N.key.buffer,N.iv.buffer).then(function(rt){var at=x.push(rt,null,d);return x.decryptionPromise=null,at}),this.decryptionPromise}var K=g||B,j=K.contiguous,H=K.discontinuity,G=K.trackSwitch,X=K.accurateTimeOffset,V=K.timeOffset,Y=K.initSegmentChange,z=U.audioCodec,Q=U.videoCodec,$=U.defaultInitPts,Z=U.duration,tt=U.initSegmentData;if((H||G||Y)&&this.resetInitSegment(tt,z,Q,Z),(H||Y)&&this.resetInitialTimestamp($),j||this.resetContiguity(),this.needsProbing(P,H,G)){if(_.dataLength){var J=_.flush();P=Object(y.appendUint8Array)(J,P)}this.configureTransmuxer(P,U)}var et=this.transmux(P,N,V,X,d),nt=this.currentTransmuxState;return nt.contiguous=!0,nt.discontinuity=!1,nt.trackSwitch=!1,R.executeEnd=v(),et},h.flush=function(a){var l=this,d=a.transmuxing;d.executeStart=v();var g=this.decrypter,x=this.cache,R=this.currentTransmuxState,P=this.decryptionPromise;if(P)return P.then(function(){return l.flush(a)});var _=[],F=R.timeOffset;if(g){var B=g.flush();B&&_.push(this.push(B,null,a))}var U=x.dataLength;x.reset();var N=this.demuxer,k=this.remuxer;if(!N||!k)return U>=t&&this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),d.executeEnd=v(),[f(a)];var w=N.flush(F);return s(w)?w.then(function(K){return l.flushRemux(_,K,a),_}):(this.flushRemux(_,w,a),_)},h.flushRemux=function(a,l,d){var g=l.audioTrack,x=l.avcTrack,R=l.id3Track,P=l.textTrack,_=this.currentTransmuxState,F=_.accurateTimeOffset,B=_.timeOffset;E.logger.log("[transmuxer.ts]: Flushed fragment "+d.sn+(d.part>-1?" p: "+d.part:"")+" of level "+d.level);var U=this.remuxer.remux(g,x,R,P,B,F,!0,this.id);a.push({remuxResult:U,chunkMeta:d}),d.transmuxing.executeEnd=v()},h.resetInitialTimestamp=function(a){var l=this.demuxer,d=this.remuxer;!l||!d||(l.resetTimeStamp(a),d.resetTimeStamp(a))},h.resetContiguity=function(){var a=this.demuxer,l=this.remuxer;!a||!l||(a.resetContiguity(),l.resetNextTimestamp())},h.resetInitSegment=function(a,l,d,g){var x=this.demuxer,R=this.remuxer;!x||!R||(x.resetInitSegment(l,d,g),R.resetInitSegment(a,l,d))},h.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},h.transmux=function(a,l,d,g,x){var R;return l&&l.method==="SAMPLE-AES"?R=this.transmuxSampleAes(a,l,d,g,x):R=this.transmuxUnencrypted(a,d,g,x),R},h.transmuxUnencrypted=function(a,l,d,g){var x=this.demuxer.demux(a,l,!1,!this.config.progressive),R=x.audioTrack,P=x.avcTrack,_=x.id3Track,F=x.textTrack,B=this.remuxer.remux(R,P,_,F,l,d,!1,this.id);return{remuxResult:B,chunkMeta:g}},h.transmuxSampleAes=function(a,l,d,g,x){var R=this;return this.demuxer.demuxSampleAes(a,l,d).then(function(P){var _=R.remuxer.remux(P.audioTrack,P.avcTrack,P.id3Track,P.textTrack,d,g,!1,R.id);return{remuxResult:_,chunkMeta:x}})},h.configureTransmuxer=function(a,l){for(var d=this.config,g=this.observer,x=this.typeSupported,R=this.vendor,P=l.audioCodec,_=l.defaultInitPts,F=l.duration,B=l.initSegmentData,U=l.videoCodec,N,k=0,w=n.length;k0&&h!=null&&h.key!=null&&h.iv!==null&&h.method!=null&&(u=h),u}var f=function(h){return{remuxResult:{},chunkMeta:h}};function s(c){return"then"in c&&c.then instanceof Function}var i=function(h,u,a,l,d){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=h,this.videoCodec=u,this.initSegmentData=a,this.duration=l,this.defaultInitPts=d},o=function(h,u,a,l,d,g){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=h,this.contiguous=u,this.accurateTimeOffset=a,this.trackSwitch=l,this.timeOffset=d,this.initSegmentChange=g}},"./src/demux/tsdemuxer.ts":function(W,M,T){T.r(M),T.d(M,"discardEPB",function(){return f});var C=T("./src/demux/adts.ts"),D=T("./src/demux/mpegaudio.ts"),A=T("./src/demux/exp-golomb.ts"),b=T("./src/demux/id3.ts"),I=T("./src/demux/sample-aes.ts"),O=T("./src/events.ts"),L=T("./src/utils/mp4-tools.ts"),m=T("./src/utils/logger.ts"),S=T("./src/errors.ts"),p={video:1,audio:2,id3:3,text:4},y=function(){function s(o,c,h){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.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=o,this.config=c,this.typeSupported=h}s.probe=function(c){var h=s.syncOffset(c);return h<0?!1:(h&&m.logger.warn("MPEG2-TS detected but first sync word found @ offset "+h+", junk ahead ?"),!0)},s.syncOffset=function(c){for(var h=Math.min(1e3,c.length-564),u=0;u>4,z=void 0;if(Y>1){if(z=G+5+c[G+4],z===G+188)continue}else z=G+4;switch(V){case R:X&&(P&&(l=t(P))&&this.parseAVCPES(l,!1),P={data:[],size:0}),P&&(P.data.push(c.subarray(z,G+188)),P.size+=G+188-z);break;case _:X&&(B&&(l=t(B))&&(g.isAAC?this.parseAACPES(l):this.parseMPEGPES(l)),B={data:[],size:0}),B&&(B.data.push(c.subarray(z,G+188)),B.size+=G+188-z);break;case F:X&&(U&&(l=t(U))&&this.parseID3PES(l),U={data:[],size:0}),U&&(U.data.push(c.subarray(z,G+188)),U.size+=G+188-z);break;case 0:X&&(z+=c[z]+1),w=this._pmtId=v(c,z);break;case w:{X&&(z+=c[z]+1);var Q=n(c,z,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,u);R=Q.avc,R>0&&(d.pid=R),_=Q.audio,_>0&&(g.pid=_,g.isAAC=Q.isAAC),F=Q.id3,F>0&&(x.pid=F),N&&!k&&(m.logger.log("reparse from beginning"),N=!1,G=j-188),k=this.pmtParsed=!0;break}case 17:case 8191:break;default:N=!0;break}}else H++;H>0&&this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:S.ErrorTypes.MEDIA_ERROR,details:S.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+H+" TS packet/s that do not start with 0x47"}),d.pesData=P,g.pesData=B,x.pesData=U;var $={audioTrack:g,avcTrack:d,id3Track:x,textTrack:this._txtTrack};return a&&this.extractRemainingSamples($),$},i.flush=function(){var c=this.remainderData;this.remainderData=null;var h;return c?h=this.demux(c,-1,!1,!0):h={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(h),this.sampleAes?this.decrypt(h,this.sampleAes):h},i.extractRemainingSamples=function(c){var h=c.audioTrack,u=c.avcTrack,a=c.id3Track,l=u.pesData,d=h.pesData,g=a.pesData,x;l&&(x=t(l))?(this.parseAVCPES(x,!0),u.pesData=null):u.pesData=l,d&&(x=t(d))?(h.isAAC?this.parseAACPES(x):this.parseMPEGPES(x),h.pesData=null):(d!=null&&d.size&&m.logger.log("last AAC PES packet truncated,might overlap between fragments"),h.pesData=d),g&&(x=t(g))?(this.parseID3PES(x),a.pesData=null):a.pesData=g},i.demuxSampleAes=function(c,h,u){var a=this.demux(c,u,!0,!this.config.progressive),l=this.sampleAes=new I.default(this.observer,this.config,h);return this.decrypt(a,l)},i.decrypt=function(c,h){return new Promise(function(u){var a=c.audioTrack,l=c.avcTrack;a.samples&&a.isAAC?h.decryptAacSamples(a.samples,0,function(){l.samples?h.decryptAvcSamples(l.samples,0,0,function(){u(c)}):u(c)}):l.samples&&h.decryptAvcSamples(l.samples,0,0,function(){u(c)})})},i.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},i.parseAVCPES=function(c,h){var u=this,a=this._avcTrack,l=this.parseAVCNALu(c.data),d=this.avcSample,g,x=!1;c.data=null,d&&l.length&&!a.audFound&&(r(d,a),d=this.avcSample=E(!1,c.pts,c.dts,"")),l.forEach(function(R){switch(R.type){case 1:{g=!0,d||(d=u.avcSample=E(!0,c.pts,c.dts,"")),d.frame=!0;var P=R.data;if(x&&P.length>4){var _=new A.default(P).readSliceType();(_===2||_===4||_===7||_===9)&&(d.key=!0)}break}case 5:g=!0,d||(d=u.avcSample=E(!0,c.pts,c.dts,"")),d.key=!0,d.frame=!0;break;case 6:{g=!0;var F=new A.default(f(R.data));F.readUByte();for(var B=0,U=0,N=!1,k=0;!N&&F.bytesAvailable>1;){B=0;do k=F.readUByte(),B+=k;while(k===255);U=0;do k=F.readUByte(),U+=k;while(k===255);if(B===4&&F.bytesAvailable!==0){N=!0;var w=F.readUByte();if(w===181){var K=F.readUShort();if(K===49){var j=F.readUInt();if(j===1195456820){var H=F.readUByte();if(H===3){for(var G=F.readUByte(),X=F.readUByte(),V=31&G,Y=[G,X],z=0;z16){for(var Q=[],$=0;$<16;$++)Q.push(F.readUByte().toString(16)),($===3||$===5||$===7||$===9)&&Q.push("-");for(var Z=U-16,tt=new Uint8Array(Z),J=0;J=0){var B={data:c.subarray(_,g-a-1),type:F};d.push(B)}else{var U=this.getLastNalUnit();if(U&&(l&&g<=4-l&&U.state&&(U.data=U.data.subarray(0,U.data.byteLength-l)),R=g-a-1,R>0)){var N=new Uint8Array(U.data.byteLength+R);N.set(U.data,0),N.set(c.subarray(0,R),U.data.byteLength),U.data=N,U.state=0}}g=0&&a>=0){var k={data:c.subarray(_,h),type:F,state:a};d.push(k)}if(d.length===0){var w=this.getLastNalUnit();if(w){var K=new Uint8Array(w.data.byteLength+c.byteLength);K.set(w.data,0),K.set(c,w.data.byteLength),w.data=K}}return u.naluState=a,d},i.parseAACPES=function(c){var h=0,u=this._audioTrack,a=this.aacOverFlow,l=c.data;if(a){this.aacOverFlow=null;var d=a.sample.unit.byteLength,g=Math.min(a.missing,d),x=d-g;a.sample.unit.set(l.subarray(0,g),x),u.samples.push(a.sample),h=a.missing}var R,P;for(R=h,P=l.length;R1;){var d=new Uint8Array(l[0].length+l[1].length);d.set(l[0]),d.set(l[1],l[0].length),l[0]=d,l.splice(1,1)}o=l[0];var g=(o[0]<<16)+(o[1]<<8)+o[2];if(g===1){if(c=(o[4]<<8)+o[5],c&&c>s.size-6)return null;var x=o[7];x&192&&(u=(o[9]&14)*536870912+(o[10]&255)*4194304+(o[11]&254)*16384+(o[12]&255)*128+(o[13]&254)/2,x&64?(a=(o[14]&14)*536870912+(o[15]&255)*4194304+(o[16]&254)*16384+(o[17]&255)*128+(o[18]&254)/2,u-a>60*9e4&&(m.logger.warn(Math.round((u-a)/9e4)+"s delta between PTS and DTS, align them"),u=a)):a=u),h=o[8];var R=h+9;if(s.size<=R)return null;s.size-=R;for(var P=new Uint8Array(s.size),_=0,F=l.length;_B){R-=B;continue}else o=o.subarray(R),B-=R,R=0;P.set(o,i),i+=B}return c&&(c-=h+3),{data:P,pts:u,dts:a,len:c}}return null}function r(s,i){if(s.units.length&&s.frame){if(s.pts===void 0){var o=i.samples,c=o.length;if(c){var h=o[c-1];s.pts=h.pts,s.dts=h.dts}else{i.dropped++;return}}i.samples.push(s)}s.debug.length&&m.logger.log(s.pts+"/"+s.dts+":"+s.debug)}function e(s,i){var o=s.length;if(o>0){if(i.pts>=s[o-1].pts)s.push(i);else for(var c=o-1;c>=0;c--)if(i.ptsc)return u;return 0}},{key:"maxAutoLevel",get:function(){var o=this.levels,c=this.autoLevelCapping,h;return c===-1&&o&&o.length?h=o.length-1:h=c,h}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(o){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,o)}},{key:"audioTracks",get:function(){var o=this.audioTrackController;return o?o.audioTracks:[]}},{key:"audioTrack",get:function(){var o=this.audioTrackController;return o?o.audioTrack:-1},set:function(o){var c=this.audioTrackController;c&&(c.audioTrack=o)}},{key:"subtitleTracks",get:function(){var o=this.subtitleTrackController;return o?o.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var o=this.subtitleTrackController;return o?o.subtitleTrack:-1},set:function(o){var c=this.subtitleTrackController;c&&(c.subtitleTrack=o)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var o=this.subtitleTrackController;return o?o.subtitleDisplay:!1},set:function(o){var c=this.subtitleTrackController;c&&(c.subtitleDisplay=o)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(o){this.config.lowLatencyMode=o}},{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.1.3"}},{key:"Events",get:function(){return v.Events}},{key:"ErrorTypes",get:function(){return n.ErrorTypes}},{key:"ErrorDetails",get:function(){return n.ErrorDetails}},{key:"DefaultConfig",get:function(){return f.defaultConfig?f.defaultConfig:y.hlsDefaultConfig},set:function(o){f.defaultConfig=o}}]),f}();e.defaultConfig=void 0},"./src/is-supported.ts":function(W,M,T){T.r(M),T.d(M,"isSupported",function(){return A}),T.d(M,"changeTypeSupported",function(){return b});var C=T("./src/utils/mediasource-helper.ts");function D(){return self.SourceBuffer||self.WebKitSourceBuffer}function A(){var I=Object(C.getMediaSource)();if(!I)return!1;var O=D(),L=I&&typeof I.isTypeSupported=="function"&&I.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),m=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!L&&!!m}function b(){var I,O=D();return typeof(O==null||(I=O.prototype)===null||I===void 0?void 0:I.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(W,M,T){T.r(M),T.d(M,"default",function(){return y}),T.d(M,"LoadError",function(){return v});var C=T("./src/polyfills/number.ts"),D=T("./src/errors.ts");function A(n,t){n.prototype=Object.create(t.prototype),n.prototype.constructor=n,m(n,t)}function b(n){var t=typeof Map=="function"?new Map:void 0;return b=function(e){if(e===null||!L(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(e))return t.get(e);t.set(e,f)}function f(){return I(e,arguments,S(this).constructor)}return f.prototype=Object.create(e.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}}),m(f,e)},b(n)}function I(n,t,r){return O()?I=Reflect.construct:I=function(f,s,i){var o=[null];o.push.apply(o,s);var c=Function.bind.apply(f,o),h=new c;return i&&m(h,i.prototype),h},I.apply(null,arguments)}function O(){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 L(n){return Function.toString.call(n).indexOf("[native code]")!==-1}function m(n,t){return m=Object.setPrototypeOf||function(e,f){return e.__proto__=f,e},m(n,t)}function S(n){return S=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},S(n)}var p=Math.pow(2,17),y=function(){function n(r){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=r}var t=n.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,f){var s=this,i=e.url;if(!i)return Promise.reject(new v({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,networkDetails:null},"Fragment does not have a "+(i?"part list":"url")));this.abort();var o=this.config,c=o.fLoader,h=o.loader;return new Promise(function(u,a){s.loader&&s.loader.destroy();var l=s.loader=e.loader=c?new c(o):new h(o),d=E(e),g={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:p};e.stats=l.stats,l.load(d,g,{onSuccess:function(R,P,_,F){s.resetLoader(e,l),u({frag:e,part:null,payload:R.data,networkDetails:F})},onError:function(R,P,_){s.resetLoader(e,l),a(new v({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:R,networkDetails:_}))},onAbort:function(R,P,_){s.resetLoader(e,l),a(new v({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:_}))},onTimeout:function(R,P,_){s.resetLoader(e,l),a(new v({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:_}))},onProgress:function(R,P,_,F){f&&f({frag:e,part:null,payload:_,networkDetails:F})}})})},t.loadPart=function(e,f,s){var i=this;this.abort();var o=this.config,c=o.fLoader,h=o.loader;return new Promise(function(u,a){i.loader&&i.loader.destroy();var l=i.loader=e.loader=c?new c(o):new h(o),d=E(e,f),g={timeout:o.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:o.fragLoadingMaxRetryTimeout,highWaterMark:p};f.stats=l.stats,l.load(d,g,{onSuccess:function(R,P,_,F){i.resetLoader(e,l),i.updateStatsFromPart(e,f);var B={frag:e,part:f,payload:R.data,networkDetails:F};s(B),u(B)},onError:function(R,P,_){i.resetLoader(e,l),a(new v({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:f,response:R,networkDetails:_}))},onAbort:function(R,P,_){e.stats.aborted=f.stats.aborted,i.resetLoader(e,l),a(new v({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:f,networkDetails:_}))},onTimeout:function(R,P,_){i.resetLoader(e,l),a(new v({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:f,networkDetails:_}))}})})},t.updateStatsFromPart=function(e,f){var s=e.stats,i=f.stats,o=i.total;if(s.loaded+=i.loaded,o){var c=Math.round(e.duration/f.duration),h=Math.min(Math.round(s.loaded/o),c),u=c-h,a=u*Math.round(s.loaded/h);s.total=s.loaded+a}else s.total=Math.max(s.loaded,s.total);var l=s.loading,d=i.loading;l.start?l.first+=d.first-d.start:(l.start=d.start,l.first=d.first),l.end=d.end},t.resetLoader=function(e,f){e.loader=null,this.loader===f&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),f.destroy()},n}();function E(n,t){t===void 0&&(t=null);var r=t||n,e={frag:n,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},f=r.byteRangeStartOffset,s=r.byteRangeEndOffset;return Object(C.isFiniteNumber)(f)&&Object(C.isFiniteNumber)(s)&&(e.rangeStart=f,e.rangeEnd=s),e}var v=function(n){A(t,n);function t(r){for(var e,f=arguments.length,s=new Array(f>1?f-1:0),i=1;i>8*(15-i)&255;return s},r.setDecryptDataFromLevelKey=function(f,s){var i=f;return(f==null?void 0:f.method)==="AES-128"&&f.uri&&!f.iv&&(i=b.LevelKey.fromURI(f.uri),i.method=f.method,i.iv=this.createInitializationVector(s),i.keyFormat="identity"),i},r.setElementaryStreamInfo=function(f,s,i,o,c,h){h===void 0&&(h=!1);var u=this.elementaryStreams,a=u[f];if(!a){u[f]={startPTS:s,endPTS:i,startDTS:o,endDTS:c,partial:h};return}a.startPTS=Math.min(a.startPTS,s),a.endPTS=Math.max(a.endPTS,i),a.startDTS=Math.min(a.startDTS,o),a.endDTS=Math.max(a.endDTS,c)},r.clearElementaryStreamInfo=function(){var f=this.elementaryStreams;f[p.AUDIO]=null,f[p.VIDEO]=null,f[p.AUDIOVIDEO]=null},S(t,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var f=this.sn;typeof f!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&A.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),f=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,f)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(C.isFiniteNumber)(this.programDateTime))return null;var f=Object(C.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+f*1e3}},{key:"encrypted",get:function(){var f;return!!((f=this.decryptdata)!==null&&f!==void 0&&f.keyFormat&&this.decryptdata.uri)}}]),t}(y),v=function(n){O(t,n);function t(r,e,f,s,i){var o;o=n.call(this,f)||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 I.LoadStats,o.duration=r.decimalFloatingPoint("DURATION"),o.gap=r.bool("GAP"),o.independent=r.bool("INDEPENDENT"),o.relurl=r.enumeratedString("URI"),o.fragment=e,o.index=s;var c=r.enumeratedString("BYTERANGE");return c&&o.setByteRange(c,i),i&&(o.fragOffset=i.fragOffset+i.duration),o}return S(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),t}(y)},"./src/loader/key-loader.ts":function(W,M,T){T.r(M),T.d(M,"default",function(){return b});var C=T("./src/events.ts"),D=T("./src/errors.ts"),A=T("./src/utils/logger.ts"),b=function(){function I(L){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=L,this._registerListeners()}var O=I.prototype;return O._registerListeners=function(){this.hls.on(C.Events.KEY_LOADING,this.onKeyLoading,this)},O._unregisterListeners=function(){this.hls.off(C.Events.KEY_LOADING,this.onKeyLoading)},O.destroy=function(){this._unregisterListeners();for(var m in this.loaders){var S=this.loaders[m];S&&S.destroy()}this.loaders={}},O.onKeyLoading=function(m,S){var p=S.frag,y=p.type,E=this.loaders[y];if(!p.decryptdata){A.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var v=p.decryptdata.uri;if(v!==this.decrypturl||this.decryptkey===null){var n=this.hls.config;if(E&&(A.logger.warn("abort previous key loader for type:"+y),E.abort()),!v){A.logger.warn("key uri is falsy");return}var t=n.loader,r=p.loader=this.loaders[y]=new t(n);this.decrypturl=v,this.decryptkey=null;var e={url:v,frag:p,responseType:"arraybuffer"},f={timeout:n.fragLoadingTimeOut,maxRetry:0,retryDelay:n.fragLoadingRetryDelay,maxRetryDelay:n.fragLoadingMaxRetryTimeout,highWaterMark:0},s={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};r.load(e,f,s)}else this.decryptkey&&(p.decryptdata.key=this.decryptkey,this.hls.trigger(C.Events.KEY_LOADED,{frag:p}))},O.loadsuccess=function(m,S,p){var y=p.frag;if(!y.decryptdata){A.logger.error("after key load, decryptdata unset");return}this.decryptkey=y.decryptdata.key=new Uint8Array(m.data),y.loader=null,delete this.loaders[y.type],this.hls.trigger(C.Events.KEY_LOADED,{frag:y})},O.loaderror=function(m,S){var p=S.frag,y=p.loader;y&&y.abort(),delete this.loaders[p.type],this.hls.trigger(C.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:p,response:m})},O.loadtimeout=function(m,S){var p=S.frag,y=p.loader;y&&y.abort(),delete this.loaders[p.type],this.hls.trigger(C.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:p})},I}()},"./src/loader/level-details.ts":function(W,M,T){T.r(M),T.d(M,"LevelDetails",function(){return I});var C=T("./src/polyfills/number.ts");function D(O,L){for(var m=0;mS.endSN||p>0||p===0&&y>0,this.updated||this.advanced?this.misses=Math.floor(S.misses*.6):this.misses=S.misses+1,this.availabilityDelay=S.availabilityDelay},A(O,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(C.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||b}},{key:"drift",get:function(){var S=this.driftEndTime-this.driftStartTime;if(S>0){var p=this.driftEnd-this.driftStart;return p*1e3/S}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var S;return(S=this.partList)!==null&&S!==void 0&&S.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var S;return(S=this.fragments)!==null&&S!==void 0&&S.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 S;return(S=this.partList)!==null&&S!==void 0&&S.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var S;return(S=this.partList)!==null&&S!==void 0&&S.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),O}()},"./src/loader/level-key.ts":function(W,M,T){T.r(M),T.d(M,"LevelKey",function(){return b});var C=T("./node_modules/url-toolkit/src/url-toolkit.js");function D(I,O){for(var L=0;L2){var u=h.shift()+".";return u+=parseInt(h.shift()).toString(16),u+=("000"+parseInt(h.shift()).toString(16)).substr(-4),u}return c},i.resolve=function(c,h){return D.buildAbsoluteURL(h,c,{alwaysNormalize:!0})},i.parseMasterPlaylist=function(c,h){var u=[],a={},l=!1;S.lastIndex=0;for(var d;(d=S.exec(c))!=null;)if(d[1]){var g=new O.AttrList(d[1]),x={attrs:g,bitrate:g.decimalInteger("AVERAGE-BANDWIDTH")||g.decimalInteger("BANDWIDTH"),name:g.NAME,url:i.resolve(d[2],h)},R=g.decimalResolution("RESOLUTION");R&&(x.width=R.width,x.height=R.height),r((g.CODECS||"").split(/[ ,]+/).filter(function(_){return _}),x),x.videoCodec&&x.videoCodec.indexOf("avc1")!==-1&&(x.videoCodec=i.convertAVC1ToAVCOTI(x.videoCodec)),u.push(x)}else if(d[3]){var P=new O.AttrList(d[3]);P["DATA-ID"]&&(l=!0,a[P["DATA-ID"]]=P)}return{levels:u,sessionData:l?a:null}},i.parseMasterPlaylistMedia=function(c,h,u,a){a===void 0&&(a=[]);var l,d=[],g=0;for(p.lastIndex=0;(l=p.exec(c))!==null;){var x=new O.AttrList(l[1]);if(x.TYPE===u){var R={attrs:x,bitrate:0,id:g++,groupId:x["GROUP-ID"],instreamId:x["INSTREAM-ID"],name:x.NAME||x.LANGUAGE||"",type:u,default:x.bool("DEFAULT"),autoselect:x.bool("AUTOSELECT"),forced:x.bool("FORCED"),lang:x.LANGUAGE,url:x.URI?i.resolve(x.URI,h):""};if(a.length){var P=i.findGroup(a,R.groupId)||a[0];e(R,P,"audioCodec"),e(R,P,"textCodec")}d.push(R)}}return d},i.parseLevelPlaylist=function(c,h,u,a,l){var d=new b.LevelDetails(h),g=d.fragments,x=null,R=0,P=0,_=0,F=0,B=null,U=new A.Fragment(a,h),N,k,w,K=-1,j=!1;for(y.lastIndex=0,d.m3u8=c;(N=y.exec(c))!==null;){j&&(j=!1,U=new A.Fragment(a,h),U.start=_,U.sn=R,U.cc=F,U.level=u,x&&(U.initSegment=x,U.rawProgramDateTime=x.rawProgramDateTime));var H=N[1];if(H){U.duration=parseFloat(H);var G=(" "+N[2]).slice(1);U.title=G||null,U.tagList.push(G?["INF",H,G]:["INF",H])}else if(N[3])Object(C.isFiniteNumber)(U.duration)&&(U.start=_,w&&(U.levelkey=w),U.sn=R,U.level=u,U.cc=F,U.urlId=l,g.push(U),U.relurl=(" "+N[3]).slice(1),s(U,B),B=U,_+=U.duration,R++,P=0,j=!0);else if(N[4]){var X=(" "+N[4]).slice(1);B?U.setByteRange(X,B):U.setByteRange(X)}else if(N[5])U.rawProgramDateTime=(" "+N[5]).slice(1),U.tagList.push(["PROGRAM-DATE-TIME",U.rawProgramDateTime]),K===-1&&(K=g.length);else{if(N=N[0].match(E),!N){L.logger.warn("No matches on slow regex match for level playlist!");continue}for(k=1;k-1){L.logger.warn("Keyformat "+q+" is not supported from the manifest");continue}else if(q!=="identity")continue;nt&&(w=I.LevelKey.fromURL(h,rt),rt&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(nt)>=0&&(w.method=nt,w.keyFormat=q,st&&(w.keyID=st),it&&(w.keyFormatVersions=it),w.iv=at));break}case"START":{var pt=new O.AttrList(Y),vt=pt.decimalFloatingPoint("TIME-OFFSET");Object(C.isFiniteNumber)(vt)&&(d.startTimeOffset=vt);break}case"MAP":{var lt=new O.AttrList(Y);U.relurl=lt.URI,lt.BYTERANGE&&U.setByteRange(lt.BYTERANGE),U.level=u,U.sn="initSegment",w&&(U.levelkey=w),U.initSegment=null,x=U,j=!0;break}case"SERVER-CONTROL":{var ut=new O.AttrList(Y);d.canBlockReload=ut.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=ut.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&ut.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=ut.optionalFloat("PART-HOLD-BACK",0),d.holdBack=ut.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var ct=new O.AttrList(Y);d.partTarget=ct.decimalFloatingPoint("PART-TARGET");break}case"PART":{var ft=d.partList;ft||(ft=d.partList=[]);var ot=P>0?ft[ft.length-1]:void 0,dt=P++,Tt=new A.Part(new O.AttrList(Y),U,h,dt,ot);ft.push(Tt),U.duration+=Tt.duration;break}case"PRELOAD-HINT":{var yt=new O.AttrList(Y);d.preloadHint=yt;break}case"RENDITION-REPORT":{var Et=new O.AttrList(Y);d.renditionReports=d.renditionReports||[],d.renditionReports.push(Et);break}default:L.logger.warn("line parsed but not handled: "+N);break}}}B&&!B.relurl?(g.pop(),_-=B.duration,d.partList&&(d.fragmentHint=B)):d.partList&&(s(U,B),U.cc=F,d.fragmentHint=U);var xt=g.length,gt=g[0],ht=g[xt-1];if(_+=d.skippedSegments*d.targetduration,_>0&&xt&&ht){d.averagetargetduration=_/xt;var St=ht.sn;d.endSN=St!=="initSegment"?St:0,gt&&(d.startCC=gt.cc,gt.initSegment||d.fragments.every(function(At){return At.relurl&&n(At.relurl)})&&(L.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),U=new A.Fragment(a,h),U.relurl=ht.relurl,U.level=u,U.sn="initSegment",gt.initSegment=U,d.needSidxRanges=!0))}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(_+=d.fragmentHint.duration),d.totalduration=_,d.endCC=F,K>0&&f(g,K),d},i}();function r(i,o){["video","audio","text"].forEach(function(c){var h=i.filter(function(a){return Object(m.isCodecType)(a,c)});if(h.length){var u=h.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});o[c+"Codec"]=u.length>0?u[0]:h[0],i=i.filter(function(a){return h.indexOf(a)===-1})}}),o.unknownCodecs=i}function e(i,o,c){var h=o[c];h&&(i[c]=h)}function f(i,o){for(var c=i[o],h=o;h--;){var u=i[h];if(!u)return;u.programDateTime=c.programDateTime-u.duration*1e3,c=u}}function s(i,o){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):o!=null&&o.programDateTime&&(i.programDateTime=o.endProgramDateTime),Object(C.isFiniteNumber)(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(W,M,T){T.r(M);var C=T("./src/polyfills/number.ts"),D=T("./src/events.ts"),A=T("./src/errors.ts"),b=T("./src/utils/logger.ts"),I=T("./src/utils/mp4-tools.ts"),O=T("./src/loader/m3u8-parser.ts"),L=T("./src/types/loader.ts"),m=T("./src/utils/attr-list.ts");function S(E){var v=E.type;switch(v){case L.PlaylistContextType.AUDIO_TRACK:return L.PlaylistLevelType.AUDIO;case L.PlaylistContextType.SUBTITLE_TRACK:return L.PlaylistLevelType.SUBTITLE;default:return L.PlaylistLevelType.MAIN}}function p(E,v){var n=E.url;return(n===void 0||n.indexOf("data:")===0)&&(n=v.url),n}var y=function(){function E(n){this.hls=void 0,this.loaders=Object.create(null),this.hls=n,this.registerListeners()}var v=E.prototype;return v.registerListeners=function(){var t=this.hls;t.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(D.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(D.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(D.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},v.unregisterListeners=function(){var t=this.hls;t.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(D.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(D.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(D.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},v.createInternalLoader=function(t){var r=this.hls.config,e=r.pLoader,f=r.loader,s=e||f,i=new s(r);return t.loader=i,this.loaders[t.type]=i,i},v.getInternalLoader=function(t){return this.loaders[t.type]},v.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},v.destroyInternalLoaders=function(){for(var t in this.loaders){var r=this.loaders[t];r&&r.destroy(),this.resetInternalLoader(t)}},v.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},v.onManifestLoading=function(t,r){var e=r.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:L.PlaylistContextType.MANIFEST,url:e,deliveryDirectives:null})},v.onLevelLoading=function(t,r){var e=r.id,f=r.level,s=r.url,i=r.deliveryDirectives;this.load({id:e,groupId:null,level:f,responseType:"text",type:L.PlaylistContextType.LEVEL,url:s,deliveryDirectives:i})},v.onAudioTrackLoading=function(t,r){var e=r.id,f=r.groupId,s=r.url,i=r.deliveryDirectives;this.load({id:e,groupId:f,level:null,responseType:"text",type:L.PlaylistContextType.AUDIO_TRACK,url:s,deliveryDirectives:i})},v.onSubtitleTrackLoading=function(t,r){var e=r.id,f=r.groupId,s=r.url,i=r.deliveryDirectives;this.load({id:e,groupId:f,level:null,responseType:"text",type:L.PlaylistContextType.SUBTITLE_TRACK,url:s,deliveryDirectives:i})},v.load=function(t){var r,e=this.hls.config,f=this.getInternalLoader(t);if(f){var s=f.context;if(s&&s.url===t.url){b.logger.trace("[playlist-loader]: playlist request ongoing");return}b.logger.log("[playlist-loader]: aborting previous loader for type: "+t.type),f.abort()}var i,o,c,h;switch(t.type){case L.PlaylistContextType.MANIFEST:i=e.manifestLoadingMaxRetry,o=e.manifestLoadingTimeOut,c=e.manifestLoadingRetryDelay,h=e.manifestLoadingMaxRetryTimeout;break;case L.PlaylistContextType.LEVEL:case L.PlaylistContextType.AUDIO_TRACK:case L.PlaylistContextType.SUBTITLE_TRACK:i=0,o=e.levelLoadingTimeOut;break;default:i=e.levelLoadingMaxRetry,o=e.levelLoadingTimeOut,c=e.levelLoadingRetryDelay,h=e.levelLoadingMaxRetryTimeout;break}if(f=this.createInternalLoader(t),(r=t.deliveryDirectives)!==null&&r!==void 0&&r.part){var u;if(t.type===L.PlaylistContextType.LEVEL&&t.level!==null?u=this.hls.levels[t.level].details:t.type===L.PlaylistContextType.AUDIO_TRACK&&t.id!==null?u=this.hls.audioTracks[t.id].details:t.type===L.PlaylistContextType.SUBTITLE_TRACK&&t.id!==null&&(u=this.hls.subtitleTracks[t.id].details),u){var a=u.partTarget,l=u.targetduration;a&&l&&(o=Math.min(Math.max(a*3,l*.8)*1e3,o))}}var d={timeout:o,maxRetry:i,retryDelay:c,maxRetryDelay:h,highWaterMark:0},g={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};f.load(t,d,g)},v.loadsuccess=function(t,r,e,f){if(f===void 0&&(f=null),e.isSidxRequest){this.handleSidxRequest(t,e),this.handlePlaylistLoaded(t,r,e,f);return}this.resetInternalLoader(e.type);var s=t.data;if(s.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(t,e,"no EXTM3U delimiter",f);return}r.parsing.start=performance.now(),s.indexOf("#EXTINF:")>0||s.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(t,r,e,f):this.handleMasterPlaylist(t,r,e,f)},v.loaderror=function(t,r,e){e===void 0&&(e=null),this.handleNetworkError(r,e,!1,t)},v.loadtimeout=function(t,r,e){e===void 0&&(e=null),this.handleNetworkError(r,e,!0)},v.handleMasterPlaylist=function(t,r,e,f){var s=this.hls,i=t.data,o=p(t,e),c=O.default.parseMasterPlaylist(i,o),h=c.levels,u=c.sessionData;if(!h.length){this.handleManifestParsingError(t,e,"no level found in manifest",f);return}var a=h.map(function(P){return{id:P.attrs.AUDIO,audioCodec:P.audioCodec}}),l=h.map(function(P){return{id:P.attrs.SUBTITLES,textCodec:P.textCodec}}),d=O.default.parseMasterPlaylistMedia(i,o,"AUDIO",a),g=O.default.parseMasterPlaylistMedia(i,o,"SUBTITLES",l),x=O.default.parseMasterPlaylistMedia(i,o,"CLOSED-CAPTIONS");if(d.length){var R=d.some(function(P){return!P.url});!R&&h[0].audioCodec&&!h[0].attrs.AUDIO&&(b.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),d.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new m.AttrList({}),bitrate:0,url:""}))}s.trigger(D.Events.MANIFEST_LOADED,{levels:h,audioTracks:d,subtitles:g,captions:x,url:o,stats:r,networkDetails:f,sessionData:u})},v.handleTrackOrLevelPlaylist=function(t,r,e,f){var s=this.hls,i=e.id,o=e.level,c=e.type,h=p(t,e),u=Object(C.isFiniteNumber)(i)?i:0,a=Object(C.isFiniteNumber)(o)?o:u,l=S(e),d=O.default.parseLevelPlaylist(t.data,h,a,l,u);if(!d.fragments.length){s.trigger(D.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:h,reason:"no fragments found in level",level:typeof e.level=="number"?e.level:void 0});return}if(c===L.PlaylistContextType.MANIFEST){var g={attrs:new m.AttrList({}),bitrate:0,details:d,name:"",url:h};s.trigger(D.Events.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:h,stats:r,networkDetails:f,sessionData:null})}if(r.parsing.end=performance.now(),d.needSidxRanges){var x,R=(x=d.fragments[0].initSegment)===null||x===void 0?void 0:x.url;this.load({url:R,isSidxRequest:!0,type:c,level:o,levelDetails:d,id:i,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}e.levelDetails=d,this.handlePlaylistLoaded(t,r,e,f)},v.handleSidxRequest=function(t,r){var e=Object(I.parseSegmentIndex)(new Uint8Array(t.data));if(e){var f=e.references,s=r.levelDetails;f.forEach(function(i,o){var c=i.info,h=s.fragments[o];h.byteRange.length===0&&h.setByteRange(String(1+c.end-c.start)+"@"+String(c.start)),h.initSegment&&h.initSegment.setByteRange(String(e.moovEndOffset)+"@0")})}},v.handleManifestParsingError=function(t,r,e,f){this.hls.trigger(D.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:r.type===L.PlaylistContextType.MANIFEST,url:t.url,reason:e,response:t,context:r,networkDetails:f})},v.handleNetworkError=function(t,r,e,f){e===void 0&&(e=!1),b.logger.warn("[playlist-loader]: A network "+(e?"timeout":"error")+" occurred while loading "+t.type+" level: "+t.level+" id: "+t.id+' group-id: "'+t.groupId+'"');var s=A.ErrorDetails.UNKNOWN,i=!1,o=this.getInternalLoader(t);switch(t.type){case L.PlaylistContextType.MANIFEST:s=e?A.ErrorDetails.MANIFEST_LOAD_TIMEOUT:A.ErrorDetails.MANIFEST_LOAD_ERROR,i=!0;break;case L.PlaylistContextType.LEVEL:s=e?A.ErrorDetails.LEVEL_LOAD_TIMEOUT:A.ErrorDetails.LEVEL_LOAD_ERROR,i=!1;break;case L.PlaylistContextType.AUDIO_TRACK:s=e?A.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:A.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,i=!1;break;case L.PlaylistContextType.SUBTITLE_TRACK:s=e?A.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:A.ErrorDetails.SUBTITLE_LOAD_ERROR,i=!1;break}o&&this.resetInternalLoader(t.type);var c={type:A.ErrorTypes.NETWORK_ERROR,details:s,fatal:i,url:t.url,loader:o,context:t,networkDetails:r};f&&(c.response=f),this.hls.trigger(D.Events.ERROR,c)},v.handlePlaylistLoaded=function(t,r,e,f){var s=e.type,i=e.level,o=e.id,c=e.groupId,h=e.loader,u=e.levelDetails,a=e.deliveryDirectives;if(!(u!=null&&u.targetduration)){this.handleManifestParsingError(t,e,"invalid target duration",f);return}if(h)switch(u.live&&(h.getCacheAge&&(u.ageHeader=h.getCacheAge()||0),(!h.getCacheAge||isNaN(u.ageHeader))&&(u.ageHeader=0)),s){case L.PlaylistContextType.MANIFEST:case L.PlaylistContextType.LEVEL:this.hls.trigger(D.Events.LEVEL_LOADED,{details:u,level:i||0,id:o||0,stats:r,networkDetails:f,deliveryDirectives:a});break;case L.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(D.Events.AUDIO_TRACK_LOADED,{details:u,id:o||0,groupId:c||"",stats:r,networkDetails:f,deliveryDirectives:a});break;case L.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(D.Events.SUBTITLE_TRACK_LOADED,{details:u,id:o||0,groupId:c||"",stats:r,networkDetails:f,deliveryDirectives:a});break}},E}();M.default=y},"./src/polyfills/number.ts":function(W,M,T){T.r(M),T.d(M,"isFiniteNumber",function(){return C}),T.d(M,"MAX_SAFE_INTEGER",function(){return D});var C=Number.isFinite||function(A){return typeof A=="number"&&isFinite(A)},D=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(W,M,T){T.r(M);var C=function(){function D(){}return D.getSilentFrame=function(b,I){switch(b){case"mp4a.40.2":if(I===1)return new Uint8Array([0,200,0,128,35,128]);if(I===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(I===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(I===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(I===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(I===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(I===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(I===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(I===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}},D}();M.default=C},"./src/remux/mp4-generator.ts":function(W,M,T){T.r(M);var C=Math.pow(2,32)-1,D=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":[],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 O=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]),L=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:O,audio:L};var m=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 p=new Uint8Array([105,115,111,109]),y=new Uint8Array([97,118,99,49]),E=new Uint8Array([0,0,0,1]);A.FTYP=A.box(A.types.ftyp,p,E,p,y),A.DINF=A.box(A.types.dinf,A.box(A.types.dref,m))},A.box=function(I){for(var O=8,L=arguments.length,m=new Array(L>1?L-1:0),S=1;S>24&255,E[1]=O>>16&255,E[2]=O>>8&255,E[3]=O&255,E.set(I,4),p=0,O=8;p>24&255,I>>16&255,I>>8&255,I&255,L>>24,L>>16&255,L>>8&255,L&255,m>>24,m>>16&255,m>>8&255,m&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,O,L){return A.box(A.types.moof,A.mfhd(I),A.traf(L,O))},A.moov=function(I){for(var O=I.length,L=[];O--;)L[O]=A.trak(I[O]);return A.box.apply(null,[A.types.moov,A.mvhd(I[0].timescale,I[0].duration)].concat(L).concat(A.mvex(I)))},A.mvex=function(I){for(var O=I.length,L=[];O--;)L[O]=A.trex(I[O]);return A.box.apply(null,[A.types.mvex].concat(L))},A.mvhd=function(I,O){O*=I;var L=Math.floor(O/(C+1)),m=Math.floor(O%(C+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,L>>24,L>>16&255,L>>8&255,L&255,m>>24,m>>16&255,m>>8&255,m&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 O=I.samples||[],L=new Uint8Array(4+O.length),m,S;for(m=0;m>>8&255),O.push(p&255),O=O.concat(Array.prototype.slice.call(S));for(m=0;m>>8&255),L.push(p&255),L=L.concat(Array.prototype.slice.call(S));var y=A.box(A.types.avcC,new Uint8Array([1,O[3],O[4],O[5],255,224|I.sps.length].concat(O).concat([I.pps.length]).concat(L))),E=I.width,v=I.height,n=I.pixelRatio[0],t=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,E>>8&255,E&255,v>>8&255,v&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]),y,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([n>>24,n>>16&255,n>>8&255,n&255,t>>24,t>>16&255,t>>8&255,t&255])))},A.esds=function(I){var O=I.config.length;return new Uint8Array([0,0,0,0,3,23+O,0,1,0,4,15+O,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([O]).concat(I.config).concat([6,1,2]))},A.mp4a=function(I){var O=I.samplerate;return A.box(A.types.mp4a,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,O>>8&255,O&255,0,0]),A.box(A.types.esds,A.esds(I)))},A.mp3=function(I){var O=I.samplerate;return A.box(A.types[".mp3"],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,O>>8&255,O&255,0,0]))},A.stsd=function(I){return I.type==="audio"?!I.isAAC&&I.codec==="mp3"?A.box(A.types.stsd,A.STSD,A.mp3(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 O=I.id,L=I.duration*I.timescale,m=I.width,S=I.height,p=Math.floor(L/(C+1)),y=Math.floor(L%(C+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,O>>24&255,O>>16&255,O>>8&255,O&255,0,0,0,0,p>>24,p>>16&255,p>>8&255,p&255,y>>24,y>>16&255,y>>8&255,y&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,m>>8&255,m&255,0,0,S>>8&255,S&255,0,0]))},A.traf=function(I,O){var L=A.sdtp(I),m=I.id,S=Math.floor(O/(C+1)),p=Math.floor(O%(C+1));return A.box(A.types.traf,A.box(A.types.tfhd,new Uint8Array([0,0,0,0,m>>24,m>>16&255,m>>8&255,m&255])),A.box(A.types.tfdt,new Uint8Array([1,0,0,0,S>>24,S>>16&255,S>>8&255,S&255,p>>24,p>>16&255,p>>8&255,p&255])),A.trun(I,L.length+16+20+8+16+8+8),L)},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 O=I.id;return A.box(A.types.trex,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},A.trun=function(I,O){var L=I.samples||[],m=L.length,S=12+16*m,p=new Uint8Array(S),y,E,v,n,t,r;for(O+=8+S,p.set([0,0,15,1,m>>>24&255,m>>>16&255,m>>>8&255,m&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255],0),y=0;y>>24&255,v>>>16&255,v>>>8&255,v&255,n>>>24&255,n>>>16&255,n>>>8&255,n&255,t.isLeading<<2|t.dependsOn,t.isDependedOn<<6|t.hasRedundancy<<4|t.paddingValue<<1|t.isNonSync,t.degradPrio&61440,t.degradPrio&15,r>>>24&255,r>>>16&255,r>>>8&255,r&255],12+16*y);return A.box(A.types.trun,p)},A.initSegment=function(I){A.types||A.init();var O=A.moov(I),L=new Uint8Array(A.FTYP.byteLength+O.byteLength);return L.set(A.FTYP),L.set(O,A.FTYP.byteLength),L},A}();D.types=void 0,D.HDLR_TYPES=void 0,D.STTS=void 0,D.STSC=void 0,D.STCO=void 0,D.STSZ=void 0,D.VMHD=void 0,D.SMHD=void 0,D.STSD=void 0,D.FTYP=void 0,D.DINF=void 0,M.default=D},"./src/remux/mp4-remuxer.ts":function(W,M,T){T.r(M),T.d(M,"default",function(){return r}),T.d(M,"normalizePts",function(){return e});var C=T("./src/polyfills/number.ts"),D=T("./src/remux/aac-helper.ts"),A=T("./src/remux/mp4-generator.ts"),b=T("./src/events.ts"),I=T("./src/errors.ts"),O=T("./src/utils/logger.ts"),L=T("./src/types/loader.ts"),m=T("./src/utils/timescale-conversion.ts");function S(){return S=Object.assign||function(o){for(var c=1;c0?d:g.pts},u[0].pts);return a&&O.logger.debug("PTS rollover detected"),l},c.remux=function(u,a,l,d,g,x,R,P){var _,F,B,U,N,k,w=g,K=g,j=u.pid>-1,H=a.pid>-1,G=a.samples.length,X=u.samples.length>0,V=G>1,Y=(!j||X)&&(!H||V)||this.ISGenerated||R;if(Y){this.ISGenerated||(B=this.generateIS(u,a,g));var z=this.isVideoContiguous,Q=-1;if(V&&(Q=f(a.samples),!z&&this.config.forceKeyFrameOnDiscontinuity))if(k=!0,Q>0){O.logger.warn("[mp4-remuxer]: Dropped "+Q+" out of "+G+" video samples due to a missing keyframe");var $=this.getVideoStartPts(a.samples);a.samples=a.samples.slice(Q),a.dropped+=Q,K+=(a.samples[0].pts-$)/(a.timescale||9e4)}else Q===-1&&(O.logger.warn("[mp4-remuxer]: No keyframe found out of "+G+" video samples"),k=!1);if(this.ISGenerated){if(X&&V){var Z=this.getVideoStartPts(a.samples),tt=e(u.samples[0].pts,Z)-Z,J=tt/a.inputTimeScale;w+=Math.max(0,J),K+=Math.max(0,-J)}if(X){if(u.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),B=this.generateIS(u,a,g)),F=this.remuxAudio(u,w,this.isAudioContiguous,x,H||V||P===L.PlaylistLevelType.AUDIO?K:void 0),V){var et=F?F.endPTS-F.startPTS:0;a.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),B=this.generateIS(u,a,g)),_=this.remuxVideo(a,K,z,et)}}else V&&(_=this.remuxVideo(a,K,z,0));_&&(_.firstKeyFrame=Q,_.independent=Q!==-1)}}return this.ISGenerated&&(l.samples.length&&(N=this.remuxID3(l,g)),d.samples.length&&(U=this.remuxText(d,g))),{audio:F,video:_,initSegment:B,independent:k,text:U,id3:N}},c.generateIS=function(u,a,l){var d=u.samples,g=a.samples,x=this.typeSupported,R={},P=!Object(C.isFiniteNumber)(this._initPTS),_="audio/mp4",F,B,U;if(P&&(F=B=1/0),u.config&&d.length&&(u.timescale=u.samplerate,u.isAAC||(x.mpeg?(_="audio/mpeg",u.codec=""):x.mp3&&(u.codec="mp3")),R.audio={id:"audio",container:_,codec:u.codec,initSegment:!u.isAAC&&x.mpeg?new Uint8Array(0):A.default.initSegment([u]),metadata:{channelCount:u.channelCount}},P&&(U=u.inputTimeScale,F=B=d[0].pts-Math.round(U*l))),a.sps&&a.pps&&g.length&&(a.timescale=a.inputTimeScale,R.video={id:"main",container:"video/mp4",codec:a.codec,initSegment:A.default.initSegment([a]),metadata:{width:a.width,height:a.height}},P)){U=a.inputTimeScale;var N=this.getVideoStartPts(g),k=Math.round(U*l);B=Math.min(B,e(g[0].dts,N)-k),F=Math.min(F,N-k)}if(Object.keys(R).length)return this.ISGenerated=!0,P&&(this._initPTS=F,this._initDTS=B),{tracks:R,initPTS:F,timescale:U}},c.remuxVideo=function(u,a,l,d){var g=u.inputTimeScale,x=u.samples,R=[],P=x.length,_=this._initPTS,F=this.nextAvcDts,B=8,U,N,k,w=Number.POSITIVE_INFINITY,K=Number.NEGATIVE_INFINITY,j=0,H=!1;if(!l||F===null){var G=a*g,X=x[0].pts-e(x[0].dts,x[0].pts);F=G-X}for(var V=0;VY.pts){var z=18e3;j=Math.max(Math.min(j,Y.pts-Y.dts),-1*z)}Y.dts0?V-1:V].dts&&(H=!0)}H&&x.sort(function(It,Ct){var kt=It.dts-Ct.dts,Kt=It.pts-Ct.pts;return kt||Kt}),N=x[0].dts,k=x[x.length-1].dts;var Q=Math.round((k-N)/(P-1));if(j<0){if(jQ,nt=J<-1;if(et||nt){et?O.logger.warn("AVC: "+Object(m.toMsFromMpegTsClock)(J,!0)+" ms ("+J+"dts) hole between fragments detected, filling it"):O.logger.warn("AVC: "+Object(m.toMsFromMpegTsClock)(-J,!0)+" ms ("+J+"dts) overlapping between fragments detected"),N=F;var rt=x[0].pts-J;x[0].dts=N,x[0].pts=rt,O.logger.log("Video: First PTS/DTS adjusted: "+Object(m.toMsFromMpegTsClock)(rt,!0)+"/"+Object(m.toMsFromMpegTsClock)(N,!0)+", delta: "+Object(m.toMsFromMpegTsClock)(J,!0)+" ms")}}t&&(N=Math.max(0,N));for(var at=0,it=0,st=0;st0?ot-1:ot].dts;if(At.stretchShortVideoTrack&&this.nextAudioPts!==null){var _t=Math.floor(At.maxBufferHole*g),Rt=(d?w+d*g:this.nextAudioPts)-dt.pts;Rt>_t?(U=Rt-Dt,U<0&&(U=Dt),O.logger.log("[mp4-remuxer]: It is approximately "+Rt/90+" ms to the next segment; using duration "+U/90+" ms for the last video frame.")):U=Dt}else U=Dt}var Ft=Math.round(dt.pts-dt.dts);R.push(new s(dt.key,U,yt,Ft))}if(R.length&&v&&v<70){var Pt=R[0].flags;Pt.dependsOn=2,Pt.isNonSync=0}console.assert(U!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=F=k+U,this.isVideoContiguous=!0;var Bt=A.default.moof(u.sequenceNumber++,N,S({},u,{samples:R})),Ut="video",Nt={data1:Bt,data2:ct,startPTS:w/g,endPTS:(K+U)/g,startDTS:N/g,endDTS:F/g,type:Ut,hasAudio:!1,hasVideo:!0,nb:R.length,dropped:u.dropped};return u.samples=[],u.dropped=0,console.assert(ct.length,"MDAT length must not be zero"),Nt},c.remuxAudio=function(u,a,l,d,g){var x=u.inputTimeScale,R=u.samplerate?u.samplerate:x,P=x/R,_=u.isAAC?y:E,F=_*P,B=this._initPTS,U=!u.isAAC&&this.typeSupported.mpeg,N=[],k=u.samples,w=U?0:8,K=this.nextAudioPts||-1,j=a*x;if(this.isAudioContiguous=l=l||k.length&&K>0&&(d&&Math.abs(j-K)<9e3||Math.abs(e(k[0].pts-B,j)-K)<20*F),k.forEach(function(ht){ht.pts=e(ht.pts-B,j)}),!l||K<0){if(k=k.filter(function(ht){return ht.pts>=0}),!k.length)return;g===0?K=0:d?K=Math.max(0,j):K=k[0].pts}if(u.isAAC)for(var H=g!==void 0,G=this.config.maxAudioFramesDrift,X=0,V=K;X=G*F&&$0){it+=w;try{at=new Uint8Array(it)}catch{this.observer.emit(b.Events.ERROR,b.Events.ERROR,{type:I.ErrorTypes.MUX_ERROR,details:I.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:it,reason:"fail allocating audio mdat "+it});return}if(!U){var ct=new DataView(at.buffer);ct.setUint32(0,it),at.set(A.default.types.mdat,4)}}else return;at.set(vt,w);var ft=vt.byteLength;w+=ft,N.push(new s(!0,_,ft,0)),rt=lt}var ot=N.length;if(ot){var dt=N[N.length-1];this.nextAudioPts=K=rt+P*dt.duration;var Tt=U?new Uint8Array(0):A.default.moof(u.sequenceNumber++,nt/P,S({},u,{samples:N}));u.samples=[];var yt=nt/x,Et=K/x,xt="audio",gt={data1:Tt,data2:at,startPTS:yt,endPTS:Et,startDTS:yt,endDTS:Et,type:xt,hasAudio:!0,hasVideo:!1,nb:ot};return this.isAudioContiguous=!0,console.assert(at.length,"MDAT length must not be zero"),gt}},c.remuxEmptyAudio=function(u,a,l,d){var g=u.inputTimeScale,x=u.samplerate?u.samplerate:g,R=g/x,P=this.nextAudioPts,_=(P!==null?P:d.startDTS*g)+this._initDTS,F=d.endDTS*g+this._initDTS,B=R*y,U=Math.ceil((F-_)/B),N=D.default.getSilentFrame(u.manifestCodec||u.codec,u.channelCount);if(O.logger.warn("[mp4-remuxer]: remux empty Audio"),!N){O.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var k=[],w=0;w4294967296;)o+=h;return o}function f(o){for(var c=0;c0?this.lastEndDTS=u:(b.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var a=!!o.audio,l=!!o.video,d="";a&&(d+="audio"),l&&(d+="video");var g={data1:s,startPTS:h,startDTS:h,endPTS:u,endDTS:u,type:d,hasAudio:a,hasVideo:l,nb:1,dropped:0};return f.audio=g.type==="audio"?g:void 0,f.video=g.type!=="audio"?g:void 0,f.text=n,f.id3=v,f.initSegment=i,f},m}(),O=function(S,p,y){return Object(D.getStartDTS)(S,p)-y};function L(m,S){var p=m==null?void 0:m.codec;return p&&p.length>4?p:p==="hvc1"?"hvc1.1.c.L120.90":p==="av01"?"av01.0.04M.08":p==="avc1"||S===A.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}M.default=I},"./src/task-loop.ts":function(W,M,T){T.r(M),T.d(M,"default",function(){return C});var C=function(){function D(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var A=D.prototype;return A.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},A.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},A.onHandlerDestroyed=function(){},A.hasInterval=function(){return!!this._tickInterval},A.hasNextTick=function(){return!!this._tickTimer},A.setInterval=function(I){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,I),!0)},A.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},A.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},A.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},A.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},A.doTick=function(){},D}()},"./src/types/cmcd.ts":function(W,M,T){T.r(M),T.d(M,"CMCDVersion",function(){return C}),T.d(M,"CMCDObjectType",function(){return D}),T.d(M,"CMCDStreamingFormat",function(){return A}),T.d(M,"CMCDStreamType",function(){return b});var C=1,D;(function(I){I.MANIFEST="m",I.AUDIO="a",I.VIDEO="v",I.MUXED="av",I.INIT="i",I.CAPTION="c",I.TIMED_TEXT="tt",I.KEY="k",I.OTHER="o"})(D||(D={}));var A;(function(I){I.DASH="d",I.HLS="h",I.SMOOTH="s",I.OTHER="o"})(A||(A={}));var b;(function(I){I.VOD="v",I.LIVE="l"})(b||(b={}))},"./src/types/level.ts":function(W,M,T){T.r(M),T.d(M,"HlsSkip",function(){return A}),T.d(M,"getSkipValue",function(){return b}),T.d(M,"HlsUrlParameters",function(){return I}),T.d(M,"Level",function(){return O});function C(L,m){for(var S=0;SNumber.MAX_SAFE_INTEGER?1/0:m},I.hexadecimalInteger=function(L){if(this[L]){var m=(this[L]||"0x").slice(2);m=(m.length&1?"0":"")+m;for(var S=new Uint8Array(m.length/2),p=0;pNumber.MAX_SAFE_INTEGER?1/0:m},I.decimalFloatingPoint=function(L){return parseFloat(this[L])},I.optionalFloat=function(L,m){var S=this[L];return S?parseFloat(S):m},I.enumeratedString=function(L){return this[L]},I.bool=function(L){return this[L]==="YES"},I.decimalResolution=function(L){var m=C.exec(this[L]);if(m!==null)return{width:parseInt(m[1],10),height:parseInt(m[2],10)}},b.parseAttrList=function(L){var m,S={},p='"';for(D.lastIndex=0;(m=D.exec(L))!==null;){var y=m[2];y.indexOf(p)===0&&y.lastIndexOf(p)===y.length-1&&(y=y.slice(1,-1)),S[m[1]]=y}return S},b}()},"./src/utils/binary-search.ts":function(W,M,T){T.r(M);var C={search:function(A,b){for(var I=0,O=A.length-1,L=null,m=null;I<=O;){L=(I+O)/2|0,m=A[L];var S=b(m);if(S>0)I=L+1;else if(S<0)O=L-1;else return m}return null}};M.default=C},"./src/utils/buffer-helper.ts":function(W,M,T){T.r(M),T.d(M,"BufferHelper",function(){return A});var C=T("./src/utils/logger.ts"),D={length:0,start:function(){return 0},end:function(){return 0}},A=function(){function b(){}return b.isBuffered=function(O,L){try{if(O){for(var m=b.getBuffered(O),S=0;S=m.start(S)&&L<=m.end(S))return!0}}catch{}return!1},b.bufferInfo=function(O,L,m){try{if(O){var S=b.getBuffered(O),p=[],y;for(y=0;yE&&(S[y-1].end=O[p].end):S.push(O[p])}else S.push(O[p])}else S=O;for(var v=0,n,t=L,r=L,e=0;e=f&&L=l&&C.logger.log(this.time+" ["+l+"] "+d)},h}(),v=function(u){for(var a=[],l=0;lI&&(this.logger.log(y.DEBUG,"Too large cursor position "+this.pos),this.pos=I)},u.moveCursor=function(l){var d=this.pos+l;if(l>1)for(var g=this.pos+1;g=144&&this.backSpace();var d=A(l);if(this.pos>=I){this.logger.log(y.ERROR,"Cannot insert "+l.toString(16)+" ("+d+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(d,this.currPenState),this.moveCursor(1)},u.clearFromPos=function(l){var d;for(d=l;d0&&(l?g="["+d.join(" | ")+"]":g=d.join(` `)),g},u.getTextAndFormat=function(){return this.rows},h}(),f=function(){function h(a,l,d){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=a,this.outputFilter=l,this.mode=null,this.verbose=0,this.displayedMemory=new e(d),this.nonDisplayedMemory=new e(d),this.lastOutputScreen=new e(d),this.currRollUpRow=this.displayedMemory.rows[b-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=d}var u=h.prototype;return u.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[b-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},u.getHandler=function(){return this.outputFilter},u.setHandler=function(l){this.outputFilter=l},u.setPAC=function(l){this.writeScreen.setPAC(l)},u.setBkgData=function(l){this.writeScreen.setBkgData(l)},u.setMode=function(l){l!==this.mode&&(this.mode=l,this.logger.log(y.INFO,"MODE="+l),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=l)},u.insertChars=function(l){for(var d=0;d=46,d.italics)d.foreground="white";else{var g=Math.floor(l/2)-16,x=["white","green","blue","cyan","red","yellow","magenta"];d.foreground=x[g]}this.logger.log(y.INFO,"MIDROW: "+JSON.stringify(d)),this.writeScreen.setPen(d)},u.outputDataUpdate=function(l){l===void 0&&(l=!1);var d=this.logger.time;d!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=d:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,d,this.lastOutputScreen),l&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:d),this.lastOutputScreen.copy(this.displayedMemory))},u.cueSplitAtTime=function(l){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,l,this.displayedMemory),this.cueStartTime=l))},h}(),s=function(){function h(a,l,d){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var g=new E;this.channels=[null,new f(a,l,g),new f(a+1,d,g)],this.cmdHistory=c(),this.logger=g}var u=h.prototype;return u.getHandler=function(l){return this.channels[l].getHandler()},u.setHandler=function(l,d){this.channels[l].setHandler(d)},u.addData=function(l,d){var g,x,R,P=!1;this.logger.time=l;for(var _=0;_ ("+v([x,R])+")"),g=this.parseCmd(x,R),g||(g=this.parseMidrow(x,R)),g||(g=this.parsePAC(x,R)),g||(g=this.parseBackgroundAttributes(x,R)),!g&&(P=this.parseChars(x,R),P)){var F=this.currentChannel;if(F&&F>0){var B=this.channels[F];B.insertChars(P)}else this.logger.log(y.WARNING,"No channel found yet. TEXT-MODE?")}!g&&!P&&this.logger.log(y.WARNING,"Couldn't parse cleaned data "+v([x,R])+" orig: "+v([d[_],d[_+1]]))}},u.parseCmd=function(l,d){var g=this.cmdHistory,x=(l===20||l===28||l===21||l===29)&&d>=32&&d<=47,R=(l===23||l===31)&&d>=33&&d<=35;if(!(x||R))return!1;if(o(l,d,g))return i(null,null,g),this.logger.log(y.DEBUG,"Repeated command ("+v([l,d])+") is dropped"),!0;var P=l===20||l===21||l===23?1:2,_=this.channels[P];return l===20||l===21||l===28||l===29?d===32?_.ccRCL():d===33?_.ccBS():d===34?_.ccAOF():d===35?_.ccAON():d===36?_.ccDER():d===37?_.ccRU(2):d===38?_.ccRU(3):d===39?_.ccRU(4):d===40?_.ccFON():d===41?_.ccRDC():d===42?_.ccTR():d===43?_.ccRTD():d===44?_.ccEDM():d===45?_.ccCR():d===46?_.ccENM():d===47&&_.ccEOC():_.ccTO(d-32),i(l,d,g),this.currentChannel=P,!0},u.parseMidrow=function(l,d){var g=0;if((l===17||l===25)&&d>=32&&d<=47){if(l===17?g=1:g=2,g!==this.currentChannel)return this.logger.log(y.ERROR,"Mismatch channel in midrow parsing"),!1;var x=this.channels[g];return x?(x.ccMIDROW(d),this.logger.log(y.DEBUG,"MIDROW ("+v([l,d])+")"),!0):!1}return!1},u.parsePAC=function(l,d){var g,x=this.cmdHistory,R=(l>=17&&l<=23||l>=25&&l<=31)&&d>=64&&d<=127,P=(l===16||l===24)&&d>=64&&d<=95;if(!(R||P))return!1;if(o(l,d,x))return i(null,null,x),!0;var _=l<=23?1:2;d>=64&&d<=95?g=_===1?O[l]:m[l]:g=_===1?L[l]:S[l];var F=this.channels[_];return F?(F.setPAC(this.interpretPAC(g,d)),i(l,d,x),this.currentChannel=_,!0):!1},u.interpretPAC=function(l,d){var g,x={color:null,italics:!1,indent:null,underline:!1,row:l};return d>95?g=d-96:g=d-64,x.underline=(g&1)===1,g<=13?x.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(g/2)]:g<=15?(x.italics=!0,x.color="white"):x.indent=Math.floor((g-16)/2)*4,x},u.parseChars=function(l,d){var g,x=null,R=null;if(l>=25?(g=2,R=l-8):(g=1,R=l),R>=17&&R<=19){var P;R===17?P=d+80:R===18?P=d+112:P=d+144,this.logger.log(y.INFO,"Special char '"+A(P)+"' in channel "+g),x=[P]}else l>=32&&l<=127&&(x=d===0?[l]:[l,d]);if(x){var _=v(x);this.logger.log(y.DEBUG,"Char codes = "+_.join(",")),i(l,d,this.cmdHistory)}return x},u.parseBackgroundAttributes=function(l,d){var g=(l===16||l===24)&&d>=32&&d<=47,x=(l===23||l===31)&&d>=45&&d<=47;if(!(g||x))return!1;var R,P={};l===16||l===24?(R=Math.floor((d-32)/2),P.background=p[R],d%2===1&&(P.background=P.background+"_semi")):d===45?P.background="transparent":(P.foreground="black",d===47&&(P.underline=!0));var _=l<=23?1:2,F=this.channels[_];return F.setBkgData(P),i(l,d,this.cmdHistory),!0},u.reset=function(){for(var l=0;l=16?t--:t++;var i=Object(C.fixLineBreaks)(r.trim()),o=Object(D.generateCueId)(m,S,i);(!L||!L.cues||!L.cues.getCueById(o))&&(v=new e(m,S,i),v.id=o,v.line=f+1,v.align="left",v.position=10+Math.min(80,Math.floor(t*8/32)*10),y.push(v))}return L&&y.length&&(y.sort(function(c,h){return c.line==="auto"||h.line==="auto"?0:c.line>8&&h.line>8?h.line-c.line:c.line-h.line}),y.forEach(function(c){return Object(A.addCueToTrack)(L,c)})),y}};M.default=I},"./src/utils/discontinuities.ts":function(W,M,T){T.r(M),T.d(M,"findFirstFragWithCC",function(){return b}),T.d(M,"shouldAlignOnDiscontinuities",function(){return I}),T.d(M,"findDiscontinuousReferenceFrag",function(){return O}),T.d(M,"adjustSlidingStart",function(){return m}),T.d(M,"alignStream",function(){return S}),T.d(M,"alignPDT",function(){return y}),T.d(M,"alignFragmentByPDTDelta",function(){return E}),T.d(M,"alignMediaPlaylistByPDT",function(){return v});var C=T("./src/polyfills/number.ts"),D=T("./src/utils/logger.ts"),A=T("./src/controller/level-helper.ts");function b(n,t){for(var r=null,e=0,f=n.length;er.startCC||n&&n.cc=this.minWeight_},b.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},b.destroy=function(){},A}();M.default=D},"./src/utils/ewma.ts":function(W,M,T){T.r(M);var C=function(){function D(b,I,O){I===void 0&&(I=0),O===void 0&&(O=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=b,this.alpha_=b?Math.exp(Math.log(.5)/b):0,this.estimate_=I,this.totalWeight_=O}var A=D.prototype;return A.sample=function(I,O){var L=Math.pow(this.alpha_,I);this.estimate_=O*(1-L)+L*this.estimate_,this.totalWeight_+=I},A.getTotalWeight=function(){return this.totalWeight_},A.getEstimate=function(){if(this.alpha_){var I=1-Math.pow(this.alpha_,this.totalWeight_);if(I)return this.estimate_/I}return this.estimate_},D}();M.default=C},"./src/utils/fetch-loader.ts":function(W,M,T){T.r(M),T.d(M,"fetchSupported",function(){return E});var C=T("./src/polyfills/number.ts"),D=T("./src/loader/load-stats.ts"),A=T("./src/demux/chunk-cache.ts");function b(e,f){e.prototype=Object.create(f.prototype),e.prototype.constructor=e,S(e,f)}function I(e){var f=typeof Map=="function"?new Map:void 0;return I=function(i){if(i===null||!m(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(typeof f<"u"){if(f.has(i))return f.get(i);f.set(i,o)}function o(){return O(i,arguments,p(this).constructor)}return o.prototype=Object.create(i.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),S(o,i)},I(e)}function O(e,f,s){return L()?O=Reflect.construct:O=function(o,c,h){var u=[null];u.push.apply(u,c);var a=Function.bind.apply(o,u),l=new a;return h&&S(l,h.prototype),l},O.apply(null,arguments)}function L(){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 m(e){return Function.toString.call(e).indexOf("[native code]")!==-1}function S(e,f){return S=Object.setPrototypeOf||function(i,o){return i.__proto__=o,i},S(e,f)}function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},p(e)}function y(){return y=Object.assign||function(e){for(var f=1;f=h&&u(o,c,a.flush(),i)):u(o,c,R,i),g()}).catch(function(){return Promise.reject()})};return d()},e}();function n(e,f){var s={method:"GET",mode:"cors",credentials:"same-origin",signal:f,headers:new self.Headers(y({},e.headers))};return e.rangeEnd&&s.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),s}function t(e,f){return new self.Request(e.url,f)}var r=function(e){b(f,e);function f(s,i,o){var c;return c=e.call(this,s)||this,c.code=void 0,c.details=void 0,c.code=i,c.details=o,c}return f}(I(Error));M.default=v},"./src/utils/imsc1-ttml-parser.ts":function(W,M,T){T.r(M),T.d(M,"IMSC1_CODEC",function(){return m}),T.d(M,"parseIMSC1",function(){return E});var C=T("./src/utils/mp4-tools.ts"),D=T("./src/utils/vttparser.ts"),A=T("./src/utils/vttcue.ts"),b=T("./src/demux/id3.ts"),I=T("./src/utils/timescale-conversion.ts"),O=T("./src/utils/webvtt-parser.ts");function L(){return L=Object.assign||function(h){for(var u=1;u"):C}function I(m){for(var S=arguments.length,p=new Array(S>1?S-1:0),y=1;y>24,f[s+1]=i>>16&255,f[s+2]=i>>8&255,f[s+3]=i&255}function S(f,s){var i=[];if(!s.length)return i;var o,c,h;"data"in f?(o=f.data,c=f.start,h=f.end):(o=f,c=0,h=o.byteLength);for(var u=c;u1?u+a:h;if(l===s[0])if(s.length===1)i.push({data:o,start:u+8,end:d});else{var g=S({data:o,start:u+8,end:d},s.slice(1));g.length&&b.apply(i,g)}u=d}return i}function p(f){var s=S(f,["moov"]),i=s[0],o=i?i.end:null,c=S(f,["sidx"]);if(!c||!c[0])return null;var h=[],u=c[0],a=u.data[0],l=a===0?8:16,d=L(u,l);l+=4;var g=0,x=0;a===0?l+=8:l+=16,l+=2;var R=u.end+x,P=O(u,l);l+=2;for(var _=0;_>>31;if(N===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var k=L(u,F);F+=4,h.push({referenceSize:U,subsegmentDuration:k,info:{duration:k/d,start:R,end:R+U-1}}),R+=U,F+=4,l=F}return{earliestPresentationTime:g,timescale:d,version:a,referencesCount:P,references:h,moovEndOffset:o}}function y(f){for(var s=[],i=S(f,["moov","trak"]),o=0;oI)&&(this.startTime=I),this.endTime=O,this.screen=L,this.timelineController.createCaptionsTrack(this.trackName)},A.reset=function(){this.cueRanges=[],this.startTime=null},D}()},"./src/utils/texttrack-utils.ts":function(W,M,T){T.r(M),T.d(M,"sendAddTrackEvent",function(){return D}),T.d(M,"addCueToTrack",function(){return A}),T.d(M,"clearCurrentCues",function(){return b}),T.d(M,"removeCuesInRange",function(){return I}),T.d(M,"getCuesInRange",function(){return L});var C=T("./src/utils/logger.ts");function D(m,S){var p;try{p=new Event("addtrack")}catch{p=document.createEvent("Event"),p.initEvent("addtrack",!1,!1)}p.track=m,S.dispatchEvent(p)}function A(m,S){var p=m.mode;if(p==="disabled"&&(m.mode="hidden"),m.cues&&!m.cues.getCueById(S.id))try{if(m.addCue(S),!m.cues.getCueById(S.id))throw new Error("addCue is failed for: "+S)}catch(E){C.logger.debug("[texttrack-utils]: "+E);var y=new self.TextTrackCue(S.startTime,S.endTime,S.text);y.id=S.id,m.addCue(y)}p==="disabled"&&(m.mode=p)}function b(m){var S=m.mode;if(S==="disabled"&&(m.mode="hidden"),m.cues)for(var p=m.cues.length;p--;)m.removeCue(m.cues[p]);S==="disabled"&&(m.mode=S)}function I(m,S,p){var y=m.mode;if(y==="disabled"&&(m.mode="hidden"),m.cues&&m.cues.length>0)for(var E=L(m.cues,S,p),v=0;vm[p].endTime)return-1;for(var y=0,E=p;y<=E;){var v=Math.floor((E+y)/2);if(Sm[v].startTime&&y-1)for(var v=E,n=m.length;v=S&&t.endTime<=p)y.push(t);else if(t.startTime>p)return y}return y}},"./src/utils/time-ranges.ts":function(W,M,T){T.r(M);var C={toString:function(A){for(var b="",I=A.length,O=0;O1?S-1:0),y=1;y100)throw new Error("Position must be between 0 and 100.");h=g,this.hasBeenReset=!0}})),Object.defineProperty(y,"positionAlign",O({},E,{get:function(){return u},set:function(g){var x=I(g);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");u=x,this.hasBeenReset=!0}})),Object.defineProperty(y,"size",O({},E,{get:function(){return a},set:function(g){if(g<0||g>100)throw new Error("Size must be between 0 and 100.");a=g,this.hasBeenReset=!0}})),Object.defineProperty(y,"align",O({},E,{get:function(){return l},set:function(g){var x=I(g);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");l=x,this.hasBeenReset=!0}})),y.displayState=void 0}return L.prototype.getCueAsHTML=function(){var m=self.WebVTT;return m.convertCueToDOMTree(self,this.text)},L}()},"./src/utils/vttparser.ts":function(W,M,T){T.r(M),T.d(M,"parseTimeStamp",function(){return A}),T.d(M,"fixLineBreaks",function(){return S}),T.d(M,"VTTParser",function(){return p});var C=T("./src/utils/vttcue.ts"),D=function(){function y(){}var E=y.prototype;return E.decode=function(n,t){if(!n)return"";if(typeof n!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(n))},y}();function A(y){function E(n,t,r,e){return(n|0)*3600+(t|0)*60+(r|0)+parseFloat(e||0)}var v=y.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return v?parseFloat(v[2])>59?E(v[2],v[3],0,v[4]):E(v[1],v[2],v[3],v[4]):null}var b=function(){function y(){this.values=Object.create(null)}var E=y.prototype;return E.set=function(n,t){!this.get(n)&&t!==""&&(this.values[n]=t)},E.get=function(n,t,r){return r?this.has(n)?this.values[n]:t[r]:this.has(n)?this.values[n]:t},E.has=function(n){return n in this.values},E.alt=function(n,t,r){for(var e=0;e=0&&r<=100)return this.set(n,r),!0}return!1},y}();function I(y,E,v,n){var t=n?y.split(n):[y];for(var r in t)if(typeof t[r]=="string"){var e=t[r].split(v);if(e.length===2){var f=e[0],s=e[1];E(f,s)}}}var O=new C.default(0,0,""),L=O.align==="middle"?"middle":"center";function m(y,E,v){var n=y;function t(){var f=A(y);if(f===null)throw new Error("Malformed timestamp: "+n);return y=y.replace(/^[^\sa-zA-Z-]+/,""),f}function r(f,s){var i=new b;I(f,function(h,u){var a;switch(h){case"region":for(var l=v.length-1;l>=0;l--)if(v[l].id===u){i.set(h,v[l].region);break}break;case"vertical":i.alt(h,u,["rl","lr"]);break;case"line":a=u.split(","),i.integer(h,a[0]),i.percent(h,a[0])&&i.set("snapToLines",!1),i.alt(h,a[0],["auto"]),a.length===2&&i.alt("lineAlign",a[1],["start",L,"end"]);break;case"position":a=u.split(","),i.percent(h,a[0]),a.length===2&&i.alt("positionAlign",a[1],["start",L,"end","line-left","line-right","auto"]);break;case"size":i.percent(h,u);break;case"align":i.alt(h,u,["start",L,"end","left","right"]);break}},/:/,/\s/),s.region=i.get("region",null),s.vertical=i.get("vertical","");var o=i.get("line","auto");o==="auto"&&O.line===-1&&(o=-1),s.line=o,s.lineAlign=i.get("lineAlign","start"),s.snapToLines=i.get("snapToLines",!0),s.size=i.get("size",100),s.align=i.get("align",L);var c=i.get("position","auto");c==="auto"&&O.position===50&&(c=s.align==="start"||s.align==="left"?0:s.align==="end"||s.align==="right"?100:50),s.position=c}function e(){y=y.replace(/^\s+/,"")}if(e(),E.startTime=t(),e(),y.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+n);y=y.substr(3),e(),E.endTime=t(),e(),r(y,E)}function S(y){return y.replace(//gi,` `)}var p=function(){function y(){this.state="INITIAL",this.buffer="",this.decoder=new D,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var E=y.prototype;return E.parse=function(n){var t=this;n&&(t.buffer+=t.decoder.decode(n,{stream:!0}));function r(){var c=t.buffer,h=0;for(c=S(c);h")===-1){t.cue.id=f;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{m(f,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{var o=f.indexOf("-->")!==-1;if(!f||o&&(i=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=` `),t.cue.text+=f}continue;case"BADCUE":f||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},E.flush=function(){var n=this;try{if((n.cue||n.state==="HEADER")&&(n.buffer+=` `,n.parse()),n.state==="INITIAL"||n.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){n.onparsingerror&&n.onparsingerror(t)}return n.onflush&&n.onflush(),this},y}()},"./src/utils/webvtt-parser.ts":function(W,M,T){T.r(M),T.d(M,"generateCueId",function(){return p}),T.d(M,"parseWebVTT",function(){return E});var C=T("./src/polyfills/number.ts"),D=T("./src/utils/vttparser.ts"),A=T("./src/demux/id3.ts"),b=T("./src/utils/timescale-conversion.ts"),I=T("./src/remux/mp4-remuxer.ts"),O=/\r\n|\n\r|\n|\r/g,L=function(n,t,r){return r===void 0&&(r=0),n.substr(r,t.length)===t},m=function(n){var t=parseInt(n.substr(-3)),r=parseInt(n.substr(-6,2)),e=parseInt(n.substr(-9,2)),f=n.length>9?parseInt(n.substr(0,n.indexOf(":"))):0;if(!Object(C.isFiniteNumber)(t)||!Object(C.isFiniteNumber)(r)||!Object(C.isFiniteNumber)(e)||!Object(C.isFiniteNumber)(f))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+n);return t+=1e3*r,t+=60*1e3*e,t+=60*60*1e3*f,t},S=function(n){for(var t=5381,r=n.length;r;)t=t*33^n.charCodeAt(--r);return(t>>>0).toString()};function p(v,n,t){return S(v.toString())+S(n.toString())+S(t)}var y=function(n,t,r){var e=n[t],f=n[e.prevCC];if(!f||!f.new&&e.new){n.ccOffset=n.presentationOffset=e.start,e.new=!1;return}for(;(s=f)!==null&&s!==void 0&&s.new;){var s;n.ccOffset+=e.start-f.start,e.new=!1,e=f,f=n[e.prevCC]}n.presentationOffset=r};function E(v,n,t,r,e,f,s,i){var o=new D.VTTParser,c=Object(A.utf8ArrayToStr)(new Uint8Array(v)).trim().replace(O,` `).split(` `),h=[],u=Object(b.toMpegTsClockFromTimescale)(n,t),a="00:00.000",l=0,d=0,g,x=!0,R=!1;o.oncue=function(P){var _=r[e],F=r.ccOffset,B=(l-u)/9e4;if(_!=null&&_.new&&(d!==void 0?F=r.ccOffset=_.start:y(r,e,B)),B&&(F=B-r.presentationOffset),R){var U=P.endTime-P.startTime,N=Object(I.normalizePts)((P.startTime+F-d)*9e4,f*9e4)/9e4;P.startTime=N,P.endTime=N+U}var k=P.text.trim();P.text=decodeURIComponent(encodeURIComponent(k)),P.id||(P.id=p(P.startTime,P.endTime,k)),P.endTime>0&&h.push(P)},o.onparsingerror=function(P){g=P},o.onflush=function(){if(g){i(g);return}s(h)},c.forEach(function(P){if(x)if(L(P,"X-TIMESTAMP-MAP=")){x=!1,R=!0,P.substr(16).split(",").forEach(function(_){L(_,"LOCAL:")?a=_.substr(6):L(_,"MPEGTS:")&&(l=parseInt(_.substr(7)))});try{d=m(a)/1e3}catch(_){R=!1,g=_}return}else P===""&&(x=!1);o.parse(P+` `)}),o.flush()}},"./src/utils/xhr-loader.ts":function(W,M,T){T.r(M);var C=T("./src/utils/logger.ts"),D=T("./src/loader/load-stats.ts"),A=/^age:\s*[\d.]+\s*$/m,b=function(){function I(L){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=L?L.xhrSetup:null,this.stats=new D.LoadStats,this.retryDelay=0}var O=I.prototype;return O.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},O.abortInternal=function(){var m=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),m&&(m.onreadystatechange=null,m.onprogress=null,m.readyState!==4&&(this.stats.aborted=!0,m.abort()))},O.abort=function(){var m;this.abortInternal(),(m=this.callbacks)!==null&&m!==void 0&&m.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},O.load=function(m,S,p){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=m,this.config=S,this.callbacks=p,this.retryDelay=S.retryDelay,this.loadInternal()},O.loadInternal=function(){var m=this.config,S=this.context;if(m){var p=this.loader=new self.XMLHttpRequest,y=this.stats;y.loading.first=0,y.loaded=0;var E=this.xhrSetup;try{if(E)try{E(p,S.url)}catch{p.open("GET",S.url,!0),E(p,S.url)}p.readyState||p.open("GET",S.url,!0);var v=this.context.headers;if(v)for(var n in v)p.setRequestHeader(n,v[n])}catch(t){this.callbacks.onError({code:p.status,text:t.message},S,p);return}S.rangeEnd&&p.setRequestHeader("Range","bytes="+S.rangeStart+"-"+(S.rangeEnd-1)),p.onreadystatechange=this.readystatechange.bind(this),p.onprogress=this.loadprogress.bind(this),p.responseType=S.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),m.timeout),p.send()}},O.readystatechange=function(){var m=this.context,S=this.loader,p=this.stats;if(!(!m||!S)){var y=S.readyState,E=this.config;if(!p.aborted&&y>=2)if(self.clearTimeout(this.requestTimeout),p.loading.first===0&&(p.loading.first=Math.max(self.performance.now(),p.loading.start)),y===4){S.onreadystatechange=null,S.onprogress=null;var v=S.status;if(v>=200&&v<300){p.loading.end=Math.max(self.performance.now(),p.loading.first);var n,t;if(m.responseType==="arraybuffer"?(n=S.response,t=n.byteLength):(n=S.responseText,t=n.length),p.loaded=p.total=t,!this.callbacks)return;var r=this.callbacks.onProgress;if(r&&r(p,m,n,S),!this.callbacks)return;var e={url:S.responseURL,data:n};this.callbacks.onSuccess(e,p,m,S)}else p.retry>=E.maxRetry||v>=400&&v<499?(C.logger.error(v+" while loading "+m.url),this.callbacks.onError({code:v,text:S.statusText},m,S)):(C.logger.warn(v+" while loading "+m.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,E.maxRetryDelay),p.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),E.timeout)}},O.loadtimeout=function(){C.logger.warn("timeout while loading "+this.context.url);var m=this.callbacks;m&&(this.abortInternal(),m.onTimeout(this.stats,this.context,this.loader))},O.loadprogress=function(m){var S=this.stats;S.loaded=m.loaded,m.lengthComputable&&(S.total=m.total)},O.getCacheAge=function(){var m=null;if(this.loader&&A.test(this.loader.getAllResponseHeaders())){var S=this.loader.getResponseHeader("age");m=S?parseFloat(S):null}return m},I}();M.default=b}}).default})})(Mt);var bt=Mt.exports;const jt=wt(bt),Vt=Gt({__proto__:null,default:jt},[bt]);export{Vt as h};