/* empty css *//* empty css */import{v as ve,T as at,a as It,w as Ze,u as ut}from"./error-492b6a5b.js";import{c as Ce,e as Q,n as Se,h as Ue,u as G,v as ce,d as we,L as ge,f as K,q,x as J,r as me,C as ue,M as Te,w as ze,o as mt,O as yt,p as Z,F as Pe,t as je,b as $,as as Ke,at as Ve,A as Et,l as Ct,y as Tt,m as De,K as wt,g as xt,ab as _e}from"./runtime-core.esm-bundler-7c3fd514.js";/* empty css *//* empty css */import"./el-overlay-f7f710bd.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{b as Ot,q as Pt,v as Ft,k as Mt,l as Nt,j as Bt}from"./index-aae906bf.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{t as ie}from"./index-5f4ce139.js";import{a as st}from"./index-be5dc120.js";import{E as St}from"./index-95693143.js";import{E as bt}from"./index-4862d1b3.js";import{E as Ut}from"./index-be5868d6.js";import{a as Gt,u as jt,d as Kt,b as Vt,m as Ht,g as Wt,c as Yt}from"./sys-aa893c6b.js";import{g as qt,a as zt,i as tt,d as dt}from"./common-465e36b3.js";import{E as ct}from"./index-548a7823.js";import{E as Xt}from"./index-2f0b1bf3.js";import{a as $t}from"./index-9bac81c5.js";import{E as Qt,a as Zt}from"./index-f97852b4.js";import{E as Jt}from"./index-cf47f151.js";import{E as er}from"./index-381e0c1f.js";import{E as tr}from"./index-470ade69.js";import{E as rr}from"./index-800b62de.js";import{a as ir,E as nr}from"./index-9fbce820.js";import{a as ar,E as sr}from"./index-624573cc.js";import{E as or}from"./index-4683bff4.js";import{v as lr}from"./directive-a07a10ed.js";import{_ as ur}from"./_plugin-vue_export-helper-c27b6911.js";var dr=Object.defineProperty,cr=Object.defineProperties,hr=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertySymbols,fr=Object.prototype.hasOwnProperty,gr=Object.prototype.propertyIsEnumerable,ft=(N,C,f)=>C in N?dr(N,C,{enumerable:!0,configurable:!0,writable:!0,value:f}):N[C]=f,ot=(N,C)=>{for(var f in C||(C={}))fr.call(C,f)&&ft(N,f,C[f]);if(ht)for(var f of ht(C))gr.call(C,f)&&ft(N,f,C[f]);return N},lt=(N,C)=>cr(N,hr(C));function gt(N,C,f,R){var E,A=!1,D=0;function I(){E&&clearTimeout(E)}function _(){for(var l=arguments.length,L=new Array(l),m=0;mN?y():C!==!0&&(E=setTimeout(R?c:y,R===void 0?N-T:N)))}return typeof C!="boolean"&&(R=f,f=C,C=void 0),_.cancel=function(){I(),A=!0},_}function vt(N,C,f){return f===void 0?gt(N,C,!1):gt(N,f,C!==!1)}function vr(N){return N&&N.__esModule&&Object.prototype.hasOwnProperty.call(N,"default")?N.default:N}var Lt={exports:{}};typeof window<"u"&&(Lt.exports=function(N){var C={};function f(R){if(C[R])return C[R].exports;var E=C[R]={i:R,l:!1,exports:{}};return N[R].call(E.exports,E,E.exports,f),E.l=!0,E.exports}return f.m=N,f.c=C,f.d=function(R,E,A){f.o(R,E)||Object.defineProperty(R,E,{enumerable:!0,get:A})},f.r=function(R){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(R,"__esModule",{value:!0})},f.t=function(R,E){if(1&E&&(R=f(R)),8&E||4&E&&typeof R=="object"&&R&&R.__esModule)return R;var A=Object.create(null);if(f.r(A),Object.defineProperty(A,"default",{enumerable:!0,value:R}),2&E&&typeof R!="string")for(var D in R)f.d(A,D,function(I){return R[I]}.bind(null,D));return A},f.n=function(R){var E=R&&R.__esModule?function(){return R.default}:function(){return R};return f.d(E,"a",E),E},f.o=function(R,E){return Object.prototype.hasOwnProperty.call(R,E)},f.p="/dist/",f(f.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(N,C,f){var R=Object.prototype.hasOwnProperty,E="~";function A(){}function D(L,m,h){this.fn=L,this.context=m,this.once=h||!1}function I(L,m,h,T,y){if(typeof h!="function")throw new TypeError("The listener must be a function");var c=new D(h,T||L,y),e=E?E+m:m;return L._events[e]?L._events[e].fn?L._events[e]=[L._events[e],c]:L._events[e].push(c):(L._events[e]=c,L._eventsCount++),L}function _(L,m){--L._eventsCount==0?L._events=new A:delete L._events[m]}function l(){this._events=new A,this._eventsCount=0}Object.create&&(A.prototype=Object.create(null),new A().__proto__||(E=!1)),l.prototype.eventNames=function(){var L,m,h=[];if(this._eventsCount===0)return h;for(m in L=this._events)R.call(L,m)&&h.push(E?m.slice(1):m);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(L)):h},l.prototype.listeners=function(L){var m=E?E+L:L,h=this._events[m];if(!h)return[];if(h.fn)return[h.fn];for(var T=0,y=h.length,c=new Array(y);T0},!1)}N.exports=function(l,L){L=L||{};var m={main:f.m},h=L.all?{main:Object.keys(m.main)}:function(a,t){for(var s={main:[t]},d={main:[]},n={main:{}};_(s);)for(var u=Object.keys(s),p=0;p=2*p/v||k<=w)){var O,P=Number.POSITIVE_INFINITY;for(O=e.level-1;O>r&&!((P=p*i[O].maxBitrate/(6.4*b))=k)){var F=this.bwEstimator.getEstimate();l.logger.warn("Fragment "+e.sn+(a?" part "+a.index:"")+" of level "+e.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+O+` Current BW estimate: `+(Object(R.isFiniteNumber)(F)?(F/1024).toFixed(3):"Unknown")+` Kb/s Estimated load time for current fragment: `+k.toFixed(3)+` s Estimated load time for the next fragment: `+P.toFixed(3)+` s Time to underbuffer: `+w.toFixed(3)+" s"),t.nextLoadLevel=O,this.bwEstimator.sample(g,u.loaded),this.clearTimer(),e.loader&&(this.fragCurrent=this.partCurrent=null,e.loader.abort()),t.trigger(A.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:a,stats:u})}}}}}},c.onFragLoaded=function(e,a){var t=a.frag,s=a.part;if(t.type===_.PlaylistLevelType.MAIN&&Object(R.isFiniteNumber)(t.sn)){var d=s?s.stats:t.stats,n=s?s.duration:t.duration;if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[t.level],p=(u.loaded?u.loaded.bytes:0)+d.loaded,g=(u.loaded?u.loaded.duration:0)+n;u.loaded={bytes:p,duration:g},u.realBitrate=Math.round(8*p/g)}if(t.bitrateTest){var v={stats:d,frag:t,part:s,id:t.type};this.onFragBuffered(A.Events.FRAG_BUFFERED,v),t.bitrateTest=!1}}},c.onFragBuffered=function(e,a){var t=a.frag,s=a.part,d=s?s.stats:t.stats;if(!d.aborted&&t.type===_.PlaylistLevelType.MAIN&&t.sn!=="initSegment"){var n=d.parsing.end-d.loading.start;this.bwEstimator.sample(n,d.loaded),d.bwEstimate=this.bwEstimator.getEstimate(),t.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}},c.onError=function(e,a){switch(a.details){case I.ErrorDetails.FRAG_LOAD_ERROR:case I.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},c.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},c.getNextABRAutoLevel=function(){var e=this.fragCurrent,a=this.partCurrent,t=this.hls,s=t.maxAutoLevel,d=t.config,n=t.minAutoLevel,u=t.media,p=a?a.duration:e?e.duration:0,g=u?u.currentTime:0,v=u&&u.playbackRate!==0?Math.abs(u.playbackRate):1,i=this.bwEstimator?this.bwEstimator.getEstimate():d.abrEwmaDefaultEstimate,r=(D.BufferHelper.bufferInfo(u,g,d.maxBufferHole).end-g)/v,o=this.findBestLevel(i,n,s,r,d.abrBandWidthFactor,d.abrBandWidthUpFactor);if(o>=0)return o;l.logger.trace((r?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var S=p?Math.min(p,d.maxStarvationDelay):d.maxStarvationDelay,b=d.abrBandWidthFactor,k=d.abrBandWidthUpFactor;if(!r){var x=this.bitrateTestDelay;x&&(S=(p?Math.min(p,d.maxLoadingDelay):d.maxLoadingDelay)-x,l.logger.trace("bitrate test took "+Math.round(1e3*x)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*S)+" ms"),b=k=1)}return o=this.findBestLevel(i,n,s,r+S,b,k),Math.max(o,0)},c.findBestLevel=function(e,a,t,s,d,n){for(var u,p=this.fragCurrent,g=this.partCurrent,v=this.lastLoadedFragLevel,i=this.hls.levels,r=i[v],o=!(r==null||(u=r.details)===null||u===void 0||!u.live),S=r==null?void 0:r.codecSet,b=g?g.duration:p?p.duration:0,k=t;k>=a;k--){var x=i[k];if(x&&(!S||x.codecSet===S)){var w=x.details,O=(g?w==null?void 0:w.partTarget:w==null?void 0:w.averagetargetduration)||b,P=void 0;P=k<=v?d*e:n*e;var F=i[k].maxBitrate,M=F*O/P;if(l.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+k+"/"+Math.round(P)+"/"+F+"/"+O+"/"+s+"/"+M),P>F&&(!M||o&&!this.bitrateTestDelay||M0&&i===-1?(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),this.state=E.State.IDLE):(this.loadedmetadata=!1,this.state=E.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=i,this.tick()},v.doTick=function(){switch(this.state){case E.State.IDLE:this.doTickIdle();break;case E.State.WAITING_TRACK:var i,r=this.levels,o=this.trackId,S=r==null||(i=r[o])===null||i===void 0?void 0:i.details;if(S){if(this.waitForCdnTuneIn(S))break;this.state=E.State.WAITING_INIT_PTS}break;case E.State.FRAG_LOADING_WAITING_RETRY:var b,k=performance.now(),x=this.retryDate;(!x||k>=x||(b=this.media)!==null&&b!==void 0&&b.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=E.State.IDLE);break;case E.State.WAITING_INIT_PTS:var w=this.waitingData;if(w){var O=w.frag,P=w.part,F=w.cache,M=w.complete;if(this.initPTS[O.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=E.State.FRAG_LOADING;var B={frag:O,part:P,payload:F.flush(),networkDetails:null};this._handleFragmentLoadProgress(B),M&&n.prototype._handleFragmentLoadComplete.call(this,B)}else if(this.videoTrackCC!==this.waitingVideoCC)a.logger.log("Waiting fragment cc ("+O.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var U=this.getLoadPosition(),j=D.BufferHelper.bufferInfo(this.mediaBuffer,U,this.config.maxBufferHole);Object(y.fragmentWithinToleranceTest)(j.end,this.config.maxFragLookUpTolerance,O)<0&&(a.logger.log("Waiting fragment cc ("+O.cc+") @ "+O.start+" cancelled because another fragment at "+j.end+" is needed"),this.clearWaitingFragment())}}else this.state=E.State.IDLE}this.onTickEnd()},v.clearWaitingFragment=function(){var i=this.waitingData;i&&(this.fragmentTracker.removeFragment(i.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=E.State.IDLE)},v.onTickEnd=function(){var i=this.media;if(i&&i.readyState){var r=(this.mediaBuffer?this.mediaBuffer:i).buffered;!this.loadedmetadata&&r.length&&(this.loadedmetadata=!0),this.lastCurrentTime=i.currentTime}},v.doTickIdle=function(){var i,r,o=this.hls,S=this.levels,b=this.media,k=this.trackId,x=o.config;if(S&&S[k]&&(b||!this.startFragRequested&&x.startFragPrefetch)){var w=S[k].details;if(!w||w.live&&this.levelLastLoaded!==k||this.waitForCdnTuneIn(w))this.state=E.State.WAITING_TRACK;else{this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,L.ElementaryStreamTypes.AUDIO,l.PlaylistLevelType.AUDIO));var O=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,l.PlaylistLevelType.AUDIO);if(O!==null){var P=O.len,F=this.getMaxBufferLength(),M=this.audioSwitch;if(!(P>=F)||M){if(!M&&this._streamEnded(O,w))return o.trigger(A.Events.BUFFER_EOS,{type:"audio"}),void(this.state=E.State.ENDED);var B=w.fragments[0].start,U=O.end;if(M){var j=this.getLoadPosition();U=j,w.PTSKnown&&jB||O.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),b.currentTime=B+.05)}var V=this.getNextFragment(U,w);V?((i=V.decryptdata)===null||i===void 0?void 0:i.keyFormat)!=="identity"||(r=V.decryptdata)!==null&&r!==void 0&&r.key?this.loadFragment(V,w,U):this.loadKey(V,w):this.bufferFlushed=!0}}}}},v.getMaxBufferLength=function(){var i=n.prototype.getMaxBufferLength.call(this),r=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,l.PlaylistLevelType.MAIN);return r===null?i:Math.max(i,r.len)},v.onMediaDetaching=function(){this.videoBuffer=null,n.prototype.onMediaDetaching.call(this)},v.onAudioTracksUpdated=function(i,r){var o=r.audioTracks;this.resetTransmuxer(),this.levels=o.map(function(S){return new _.Level(S)})},v.onAudioTrackSwitching=function(i,r){var o=!!r.url;this.trackId=r.id;var S=this.fragCurrent;S!=null&&S.loader&&S.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),o?this.setInterval(100):this.resetTransmuxer(),o?(this.audioSwitch=!0,this.state=E.State.IDLE):this.state=E.State.STOPPED,this.tick()},v.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},v.onLevelLoaded=function(i,r){this.mainDetails=r.details},v.onAudioTrackLoaded=function(i,r){var o,S=this.levels,b=r.details,k=r.id;if(S){this.log("Track "+k+" loaded ["+b.startSN+","+b.endSN+"],duration:"+b.totalduration);var x=S[k],w=0;if(b.live||(o=x.details)!==null&&o!==void 0&&o.live){var O=this.mainDetails;if(b.fragments[0]||(b.deltaUpdateFailed=!0),b.deltaUpdateFailed||!O)return;!x.details&&b.hasProgramDateTime&&O.hasProgramDateTime?(Object(c.alignPDT)(b,O),w=b.fragments[0].start):w=this.alignPlaylists(b,x.details)}x.details=b,this.levelLastLoaded=k,this.startFragRequested||!this.mainDetails&&b.live||this.setStartPosition(x.details,w),this.state!==E.State.WAITING_TRACK||this.waitForCdnTuneIn(b)||(this.state=E.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+k)},v._handleFragmentLoadProgress=function(i){var r,o=i.frag,S=i.part,b=i.payload,k=this.config,x=this.trackId,w=this.levels;if(w){var O=w[x];console.assert(O,"Audio track is defined on fragment load progress");var P=O.details;console.assert(P,"Audio track details are defined on fragment load progress");var F=k.defaultAudioCodec||O.audioCodec||"mp4a.40.2",M=this.transmuxer;M||(M=this.transmuxer=new h.default(this.hls,l.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var B=this.initPTS[o.cc],U=(r=o.initSegment)===null||r===void 0?void 0:r.data;if(B!==void 0){var j=S?S.index:-1,V=j!==-1,H=new T.ChunkMetadata(o.level,o.sn,o.stats.chunkCount,b.byteLength,j,V);M.push(b,U,F,"",o,S,P.totalduration,!1,H,B)}else a.logger.log("Unknown video PTS for cc "+o.cc+", waiting for video PTS before demuxing audio frag "+o.sn+" of ["+P.startSN+" ,"+P.endSN+"],track "+x),(this.waitingData=this.waitingData||{frag:o,part:S,cache:new m.default,complete:!1}).cache.push(new Uint8Array(b)),this.waitingVideoCC=this.videoTrackCC,this.state=E.State.WAITING_INIT_PTS}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered")},v._handleFragmentLoadComplete=function(i){this.waitingData?this.waitingData.complete=!0:n.prototype._handleFragmentLoadComplete.call(this,i)},v.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},v.onBufferCreated=function(i,r){var o=r.tracks.audio;o&&(this.mediaBuffer=o.buffer),r.tracks.video&&(this.videoBuffer=r.tracks.video.buffer)},v.onFragBuffered=function(i,r){var o=r.frag,S=r.part;o.type===l.PlaylistLevelType.AUDIO&&(this.fragContextChanged(o)?this.warn("Fragment "+o.sn+(S?" p: "+S.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):(o.sn!=="initSegment"&&(this.fragPrevious=o,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(o,S)))},v.onError=function(i,r){switch(r.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.AUDIO,r);break;case e.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case e.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==E.State.ERROR&&this.state!==E.State.STOPPED&&(this.state=r.fatal?E.State.ERROR:E.State.IDLE,this.warn(r.details+" while loading frag, switching to "+this.state+" state"));break;case e.ErrorDetails.BUFFER_FULL_ERROR:if(r.parent==="audio"&&(this.state===E.State.PARSING||this.state===E.State.PARSED)){var o=!0,S=this.getFwdBufferInfo(this.mediaBuffer,l.PlaylistLevelType.AUDIO);S&&S.len>.5&&(o=!this.reduceMaxBufferLength(S.len)),o&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,n.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}},v.onBufferFlushed=function(i,r){r.type===L.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},v._handleTransmuxComplete=function(i){var r,o="audio",S=this.hls,b=i.remuxResult,k=i.chunkMeta,x=this.getCurrentContext(k);if(!x)return this.warn("The loading context changed while buffering fragment "+k.sn+" of level "+k.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(k.level);var w=x.frag,O=x.part,P=b.audio,F=b.text,M=b.id3,B=b.initSegment;if(!this.fragContextChanged(w)){if(this.state=E.State.PARSING,this.audioSwitch&&P&&this.completeAudioSwitch(),B!=null&&B.tracks&&(this._bufferInitSegment(B.tracks,w,k),S.trigger(A.Events.FRAG_PARSING_INIT_SEGMENT,{frag:w,id:o,tracks:B.tracks})),P){var U=P.startPTS,j=P.endPTS,V=P.startDTS,H=P.endDTS;O&&(O.elementaryStreams[L.ElementaryStreamTypes.AUDIO]={startPTS:U,endPTS:j,startDTS:V,endDTS:H}),w.setElementaryStreamInfo(L.ElementaryStreamTypes.AUDIO,U,j,V,H),this.bufferFragmentData(P,w,O,k)}if(M!=null&&(r=M.samples)!==null&&r!==void 0&&r.length){var z=t({frag:w,id:o},M);S.trigger(A.Events.FRAG_PARSING_METADATA,z)}if(F){var W=t({frag:w,id:o},F);S.trigger(A.Events.FRAG_PARSING_USERDATA,W)}}},v._bufferInitSegment=function(i,r,o){if(this.state===E.State.PARSING){i.video&&delete i.video;var S=i.audio;if(S){S.levelCodec=S.codec,S.id="audio",this.log("Init audio buffer, container:"+S.container+", codecs[parsed]=["+S.codec+"]"),this.hls.trigger(A.Events.BUFFER_CODECS,i);var b=S.initSegment;if(b!=null&&b.byteLength){var k={type:"audio",frag:r,part:null,chunkMeta:o,parent:r.type,data:b};this.hls.trigger(A.Events.BUFFER_APPENDING,k)}this.tick()}}},v.loadFragment=function(i,r,o){var S=this.fragmentTracker.getState(i);this.fragCurrent=i,(this.audioSwitch||S===I.FragmentState.NOT_LOADED||S===I.FragmentState.PARTIAL)&&(i.sn==="initSegment"?this._loadInitSegment(i):r.live&&!Object(R.isFiniteNumber)(this.initPTS[i.cc])?(this.log("Waiting for video PTS in continuity counter "+i.cc+" of live stream before loading audio fragment "+i.sn+" of level "+this.trackId),this.state=E.State.WAITING_INIT_PTS):(this.startFragRequested=!0,n.prototype.loadFragment.call(this,i,r,o)))},v.completeAudioSwitch=function(){var i=this.hls,r=this.media,o=this.trackId;r&&(this.log("Switching audio track : flushing all audio"),n.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,i.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:o})},g}(E.default);C.default=d},"./src/controller/audio-track-controller.ts":function(N,C,f){f.r(C);var R=f("./src/events.ts"),E=f("./src/errors.ts"),A=f("./src/controller/base-playlist-controller.ts"),D=f("./src/types/loader.ts");function I(L,m){for(var h=0;h=t.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var s=t[this.trackId];this.log("Now switching to audio-track index "+a);var d=t[a],n=d.id,u=d.groupId,p=u===void 0?"":u,g=d.name,v=d.type,i=d.url;if(this.trackId=a,this.trackName=g,this.selectDefaultTrack=!1,this.hls.trigger(R.Events.AUDIO_TRACK_SWITCHING,{id:n,groupId:p,name:g,type:v,url:i}),!d.details||d.details.live){var r=this.switchParams(d.url,s==null?void 0:s.details);this.loadPlaylist(r)}}},e.selectInitialTrack=function(){var a=this.tracksInGroup;console.assert(a.length,"Initial audio track should be selected when tracks are known");var t=this.trackName,s=this.findTrackId(t)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.MEDIA_ERROR,details:E.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},e.findTrackId=function(a){for(var t=this.tracksInGroup,s=0;sh.partTarget&&(t+=1)}if(Object(R.isFiniteNumber)(a))return new E.HlsUrlParameters(a,Object(R.isFiniteNumber)(t)?t:void 0,E.HlsSkip.No)}}},L.loadPlaylist=function(m){},L.shouldLoadTrack=function(m){return this.canLoad&&m&&!!m.url&&(!m.details||m.details.live)},L.playlistLoaded=function(m,h,T){var y=this,c=h.details,e=h.stats,a=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(c.advancedDateTime=Date.now()-a,c.live||T!=null&&T.live){if(c.reloaded(T),T&&this.log("live playlist "+m+" "+(c.advanced?"REFRESHED "+c.lastPartSn+"-"+c.lastPartIndex:"MISSED")),T&&c.fragments.length>0&&Object(A.mergeDetails)(T,c),!this.canLoad||!c.live)return;var t,s=void 0,d=void 0;if(c.canBlockReload&&c.endSN&&c.advanced){var n=this.hls.config.lowLatencyMode,u=c.lastPartSn,p=c.endSN,g=c.lastPartIndex,v=u===p;g!==-1?(s=v?p+1:u,d=v?n?0:g:g+1):s=p+1;var i=c.age,r=i+c.ageHeader,o=Math.min(r-c.partTarget,1.5*c.targetduration);if(o>0){if(T&&o>T.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+T.tuneInGoal+" to: "+o+" with playlist age: "+c.age),o=0;else{var S=Math.floor(o/c.targetduration);s+=S,d!==void 0&&(d+=Math.round(o%c.targetduration/c.partTarget)),this.log("CDN Tune-in age: "+c.ageHeader+"s last advanced "+i.toFixed(2)+"s goal: "+o+" skip sn "+S+" to part "+d)}c.tuneInGoal=o}if(t=this.getDeliveryDirectives(c,h.deliveryDirectives,s,d),n||!v)return void this.loadPlaylist(t)}else t=this.getDeliveryDirectives(c,h.deliveryDirectives,s,d);var b=Object(A.computeReloadInterval)(c,e);s!==void 0&&c.canBlockReload&&(b-=c.partTarget||1),this.log("reload live playlist "+m+" in "+Math.round(b)+" ms"),this.timer=self.setTimeout(function(){return y.loadPlaylist(t)},b)}else this.clearTimer()},L.getDeliveryDirectives=function(m,h,T,y){var c=Object(E.getSkipValue)(m,T);return h!=null&&h.skip&&m.deltaUpdateFailed&&(T=h.msn,y=h.part,c=E.HlsSkip.No),new E.HlsUrlParameters(T,y,c)},L.retryLoadingOrFail=function(m){var h,T=this,y=this.hls.config,c=this.retryCount-1&&(h=m.context)!==null&&h!==void 0&&h.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+m.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*y.levelLoadingRetryDelay,y.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return T.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+m.details+'"')}else this.warn('cannot recover from error "'+m.details+'"'),this.clearTimer(),m.fatal=!0;return c},l}()},"./src/controller/base-stream-controller.ts":function(N,C,f){f.r(C),f.d(C,"State",function(){return n}),f.d(C,"default",function(){return u});var R=f("./src/polyfills/number.ts"),E=f("./src/task-loop.ts"),A=f("./src/controller/fragment-tracker.ts"),D=f("./src/utils/buffer-helper.ts"),I=f("./src/utils/logger.ts"),_=f("./src/events.ts"),l=f("./src/errors.ts"),L=f("./src/types/transmuxer.ts"),m=f("./src/utils/mp4-tools.ts"),h=f("./src/utils/discontinuities.ts"),T=f("./src/controller/fragment-finders.ts"),y=f("./src/controller/level-helper.ts"),c=f("./src/loader/fragment-loader.ts"),e=f("./src/crypt/decrypter.ts"),a=f("./src/utils/time-ranges.ts"),t=f("./src/types/loader.ts");function s(p,g){for(var v=0;vk.start+k.duration+M;(P0&&P&&P.key&&P.iv&&P.method==="AES-128"){var F=self.performance.now();return k.decrypter.webCryptoDecrypt(new Uint8Array(O),P.key.buffer,P.iv.buffer).then(function(M){var B=self.performance.now();return w.trigger(_.Events.FRAG_DECRYPTED,{frag:b,payload:M,stats:{tstart:F,tdecrypt:B}}),x.payload=M,x})}return x}).then(function(x){var w=k.fragCurrent,O=k.hls,P=k.levels;if(!P)throw new Error("init load aborted, missing levels");var F=P[b.level].details;console.assert(F,"Level details are defined when init segment is loaded");var M=b.stats;k.state=n.IDLE,k.fragLoadError=0,b.data=new Uint8Array(x.payload),M.parsing.start=M.buffering.start=self.performance.now(),M.parsing.end=M.buffering.end=self.performance.now(),x.frag===w&&O.trigger(_.Events.FRAG_BUFFERED,{stats:M,frag:w,part:null,id:b.type}),k.tick()}).catch(function(x){k.warn(x),k.resetFragmentLoading(b)})},S.fragContextChanged=function(b){var k=this.fragCurrent;return!b||!k||b.level!==k.level||b.sn!==k.sn||b.urlId!==k.urlId},S.fragBufferedComplete=function(b,k){var x=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+b.type+" sn: "+b.sn+(k?" part: "+k.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+b.level+" "+a.default.toString(D.BufferHelper.getBuffered(x))),this.state=n.IDLE,this.tick()},S._handleFragmentLoadComplete=function(b){var k=this.transmuxer;if(k){var x=b.frag,w=b.part,O=b.partsLoaded,P=!O||O.length===0||O.some(function(M){return!M}),F=new L.ChunkMetadata(x.level,x.sn,x.stats.chunkCount+1,0,w?w.index:-1,!P);k.flush(F)}},S._handleFragmentLoadProgress=function(b){},S._doFragLoad=function(b,k,x,w){var O=this;if(x===void 0&&(x=null),!this.levels)throw new Error("frag load aborted, missing levels");if(x=Math.max(b.start,x||0),this.config.lowLatencyMode&&k){var P=k.partList;if(P&&w){x>b.end&&k.fragmentHint&&(b=k.fragmentHint);var F=this.getNextPart(P,b,x);if(F>-1){var M=P[F];return this.log("Loading part sn: "+b.sn+" p: "+M.index+" cc: "+b.cc+" of playlist ["+k.startSN+"-"+k.endSN+"] parts [0-"+F+"-"+(P.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+b.level+", target: "+parseFloat(x.toFixed(3))),this.nextLoadPosition=M.start+M.duration,this.state=n.FRAG_LOADING,this.hls.trigger(_.Events.FRAG_LOADING,{frag:b,part:P[F],targetBufferTime:x}),this.doFragPartsLoad(b,P,F,w).catch(function(B){return O.handleFragLoadError(B)})}if(!b.url||this.loadedEndOfParts(P,x))return Promise.resolve(null)}}return this.log("Loading fragment "+b.sn+" cc: "+b.cc+" "+(k?"of ["+k.startSN+"-"+k.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+b.level+", target: "+parseFloat(x.toFixed(3))),Object(R.isFiniteNumber)(b.sn)&&!this.bitrateTest&&(this.nextLoadPosition=b.start+b.duration),this.state=n.FRAG_LOADING,this.hls.trigger(_.Events.FRAG_LOADING,{frag:b,targetBufferTime:x}),this.fragmentLoader.load(b,w).catch(function(B){return O.handleFragLoadError(B)})},S.doFragPartsLoad=function(b,k,x,w){var O=this;return new Promise(function(P,F){var M=[];(function B(U){var j=k[U];O.fragmentLoader.loadPart(b,j,w).then(function(V){M[j.index]=V;var H=V.part;O.hls.trigger(_.Events.FRAG_LOADED,V);var z=k[U+1];if(!z||z.fragment!==b)return P({frag:b,part:H,partsLoaded:M});B(U+1)}).catch(F)})(x)})},S.handleFragLoadError=function(b){var k=b.data;return k&&k.details===l.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(k.frag,k.part):this.hls.trigger(_.Events.ERROR,k),null},S._handleTransmuxerFlush=function(b){var k=this.getCurrentContext(b);if(k&&this.state===n.PARSING){var x=k.frag,w=k.part,O=k.level,P=self.performance.now();x.stats.parsing.end=P,w&&(w.stats.parsing.end=P),this.updateLevelTiming(x,w,O,b.partial)}else this.fragCurrent||(this.state=n.IDLE)},S.getCurrentContext=function(b){var k=this.levels,x=b.level,w=b.sn,O=b.part;if(!k||!k[x])return this.warn("Levels object was unset while buffering fragment "+w+" of level "+x+". The current chunk will not be buffered."),null;var P=k[x],F=O>-1?Object(y.getPartWith)(P,w,O):null,M=F?F.fragment:Object(y.getFragmentWithSN)(P,w,this.fragCurrent);return M?{frag:M,part:F,level:P}:null},S.bufferFragmentData=function(b,k,x,w){if(b&&this.state===n.PARSING){var O=b.data1,P=b.data2,F=O;if(O&&P&&(F=Object(m.appendUint8Array)(O,P)),F&&F.length){var M={type:b.type,frag:k,part:x,chunkMeta:w,parent:k.type,data:F};this.hls.trigger(_.Events.BUFFER_APPENDING,M),b.dropped&&b.independent&&!x&&this.flushBufferGap(k)}}},S.flushBufferGap=function(b){var k=this.media;if(k)if(D.BufferHelper.isBuffered(k,k.currentTime)){var x=k.currentTime,w=D.BufferHelper.bufferInfo(k,x,0),O=b.duration,P=Math.min(2*this.config.maxFragLookUpTolerance,.25*O),F=Math.max(Math.min(b.start-P,w.end-P),x+P);b.start-F>P&&this.flushMainBuffer(F,b.start)}else this.flushMainBuffer(0,b.start)},S.getFwdBufferInfo=function(b,k){var x=this.config,w=this.getLoadPosition();if(!Object(R.isFiniteNumber)(w))return null;var O=D.BufferHelper.bufferInfo(b,w,x.maxBufferHole);if(O.len===0&&O.nextStart!==void 0){var P=this.fragmentTracker.getBufferedFrag(w,k);if(P&&O.nextStart=x&&(k.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+k.maxMaxBufferLength+"s"),!0)},S.getNextFragment=function(b,k){var x,w,O=k.fragments,P=O.length;if(!P)return null;var F,M=this.config,B=O[0].start;if(k.live){var U=M.initialLiveManifestSize;if(P-1&&xx.start&&x.loaded},S.getInitialLiveFragment=function(b,k){var x=this.fragPrevious,w=null;if(x){if(b.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+x.programDateTime),w=Object(T.findFragmentByPDT)(k,x.endProgramDateTime,this.config.maxFragLookUpTolerance)),!w){var O=x.sn+1;if(O>=b.startSN&&O<=b.endSN){var P=k[O-b.startSN];x.cc===P.cc&&(w=P,this.log("Live playlist, switching playlist, load frag with next SN: "+w.sn))}w||(w=Object(T.findFragWithCC)(k,x.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+w.sn)}}else{var F=this.hls.liveSyncPosition;F!==null&&(w=this.getFragmentAtPosition(F,this.bitrateTest?b.fragmentEnd:b.edge,b))}return w},S.getFragmentAtPosition=function(b,k,x){var w,O=this.config,P=this.fragPrevious,F=x.fragments,M=x.endSN,B=x.fragmentHint,U=O.maxFragLookUpTolerance,j=!!(O.lowLatencyMode&&x.partList&&B);if(j&&B&&!this.bitrateTest&&(F=F.concat(B),M=B.sn),bk-U?0:U;w=Object(T.findFragmentByPTS)(P,F,b,V)}else w=F[F.length-1];if(w){var H=w.sn-x.startSN,z=P&&w.level===P.level,W=F[H+1];if(this.fragmentTracker.getState(w)===A.FragmentState.BACKTRACKED){w=null;for(var X=H;F[X]&&this.fragmentTracker.getState(F[X])===A.FragmentState.BACKTRACKED;)w=P?F[X--]:F[--X];w||(w=W)}else P&&w.sn===P.sn&&!j&&z&&(w.sn=P-k.maxFragLookUpTolerance&&O<=F;if(w!==null&&x.duration>w&&(O"+b.startSN+" prev-sn: "+(O?O.sn:"na")+" fragments: "+F),j}return M},S.waitForCdnTuneIn=function(b){return b.live&&b.canBlockReload&&b.tuneInGoal>Math.max(b.partHoldBack,3*b.partTarget)},S.setStartPosition=function(b,k){var x=this.startPosition;if(x"+b))}}])&&s(r.prototype,o),i}(E.default)},"./src/controller/buffer-controller.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return T});var R=f("./src/polyfills/number.ts"),E=f("./src/events.ts"),A=f("./src/utils/logger.ts"),D=f("./src/errors.ts"),I=f("./src/utils/buffer-helper.ts"),_=f("./src/utils/mediasource-helper.ts"),l=f("./src/loader/fragment.ts"),L=f("./src/controller/buffer-operation-queue.ts"),m=Object(_.getMediaSource)(),h=/([ha]vc.)(?:\.[^.,]+)+/,T=function(){function y(e){var a=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 t=a.hls,s=a.media,d=a.mediaSource;A.logger.log("[buffer-controller]: Media source opened"),s&&(a.updateMediaElementDuration(),t.trigger(E.Events.MEDIA_ATTACHED,{media:s})),d&&d.removeEventListener("sourceopen",a._onMediaSourceOpen),a.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=e,this._initSourceBuffer(),this.registerListeners()}var c=y.prototype;return c.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},c.destroy=function(){this.unregisterListeners(),this.details=null},c.registerListeners=function(){var e=this.hls;e.on(E.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.Events.BUFFER_RESET,this.onBufferReset,this),e.on(E.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(E.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.Events.BUFFER_EOS,this.onBufferEos,this),e.on(E.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.Events.FRAG_PARSED,this.onFragParsed,this),e.on(E.Events.FRAG_CHANGED,this.onFragChanged,this)},c.unregisterListeners=function(){var e=this.hls;e.off(E.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.Events.BUFFER_RESET,this.onBufferReset,this),e.off(E.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(E.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.Events.BUFFER_EOS,this.onBufferEos,this),e.off(E.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.Events.FRAG_PARSED,this.onFragParsed,this),e.off(E.Events.FRAG_CHANGED,this.onFragChanged,this)},c._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new L.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},c.onManifestParsed=function(e,a){var t=2;(a.audio&&!a.video||!a.altAudio)&&(t=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=t,this.details=null,A.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},c.onMediaAttaching=function(e,a){var t=this.media=a.media;if(t&&m){var s=this.mediaSource=new m;s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),t.src=self.URL.createObjectURL(s),this._objectUrl=t.src}},c.onMediaDetaching=function(){var e=this.media,a=this.mediaSource,t=this._objectUrl;if(a){if(A.logger.log("[buffer-controller]: media source detaching"),a.readyState==="open")try{a.endOfStream()}catch(s){A.logger.warn("[buffer-controller]: onMediaDetaching: "+s.message+" while calling endOfStream")}this.onBufferReset(),a.removeEventListener("sourceopen",this._onMediaSourceOpen),a.removeEventListener("sourceended",this._onMediaSourceEnded),a.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(t&&self.URL.revokeObjectURL(t),e.src===t?(e.removeAttribute("src"),e.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(E.Events.MEDIA_DETACHED,void 0)},c.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(a){var t=e.sourceBuffer[a];try{t&&(e.removeBufferListeners(a),e.mediaSource&&e.mediaSource.removeSourceBuffer(t),e.sourceBuffer[a]=void 0)}catch(s){A.logger.warn("[buffer-controller]: Failed to reset the "+a+" buffer",s)}}),this._initSourceBuffer()},c.onBufferCodecs=function(e,a){var t=this,s=this.getSourceBufferTypes().length;Object.keys(a).forEach(function(d){if(s){var n=t.tracks[d];if(n&&typeof n.buffer.changeType=="function"){var u=a[d],p=u.codec,g=u.levelCodec,v=u.container;if((n.levelCodec||n.codec).replace(h,"$1")!==(g||p).replace(h,"$1")){var i=v+";codecs="+(g||p);t.appendChangeType(d,i)}}}else t.pendingTracks[d]=a[d]}),s||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},c.appendChangeType=function(e,a){var t=this,s=this.operationQueue,d={execute:function(){var n=t.sourceBuffer[e];n&&(A.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+a),n.changeType(a)),s.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(n){A.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",n)}};s.append(d,e)},c.onBufferAppending=function(e,a){var t=this,s=this.hls,d=this.operationQueue,n=this.tracks,u=a.data,p=a.type,g=a.frag,v=a.part,i=a.chunkMeta,r=i.buffering[p],o=self.performance.now();r.start=o;var S=g.stats.buffering,b=v?v.stats.buffering:null;S.start===0&&(S.start=o),b&&b.start===0&&(b.start=o);var k=n.audio,x=p==="audio"&&i.id===1&&(k==null?void 0:k.container)==="audio/mpeg",w={execute:function(){if(r.executeStart=self.performance.now(),x){var O=t.sourceBuffer[p];if(O){var P=g.start-O.timestampOffset;Math.abs(P)>=.1&&(A.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+g.start+" (delta: "+P+") sn: "+g.sn+")"),O.timestampOffset=g.start)}}t.appendExecutor(u,p)},onStart:function(){},onComplete:function(){var O=self.performance.now();r.executeEnd=r.end=O,S.first===0&&(S.first=O),b&&b.first===0&&(b.first=O);var P=t.sourceBuffer,F={};for(var M in P)F[M]=I.BufferHelper.getBuffered(P[M]);t.appendError=0,t.hls.trigger(E.Events.BUFFER_APPENDED,{type:p,frag:g,part:v,chunkMeta:i,parent:g.type,timeRanges:F})},onError:function(O){A.logger.error("[buffer-controller]: Error encountered while trying to append to the "+p+" SourceBuffer",O);var P={type:D.ErrorTypes.MEDIA_ERROR,parent:g.type,details:D.ErrorDetails.BUFFER_APPEND_ERROR,err:O,fatal:!1};O.code===DOMException.QUOTA_EXCEEDED_ERR?P.details=D.ErrorDetails.BUFFER_FULL_ERROR:(t.appendError++,P.details=D.ErrorDetails.BUFFER_APPEND_ERROR,t.appendError>s.config.appendErrorMaxRetry&&(A.logger.error("[buffer-controller]: Failed "+s.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),P.fatal=!0)),s.trigger(E.Events.ERROR,P)}};d.append(w,p)},c.onBufferFlushing=function(e,a){var t=this,s=this.operationQueue,d=function(n){return{execute:t.removeExecutor.bind(t,n,a.startOffset,a.endOffset),onStart:function(){},onComplete:function(){t.hls.trigger(E.Events.BUFFER_FLUSHED,{type:n})},onError:function(u){A.logger.warn("[buffer-controller]: Failed to remove from "+n+" SourceBuffer",u)}}};a.type?s.append(d(a.type),a.type):this.getSourceBufferTypes().forEach(function(n){s.append(d(n),n)})},c.onFragParsed=function(e,a){var t=this,s=a.frag,d=a.part,n=[],u=d?d.elementaryStreams:s.elementaryStreams;u[l.ElementaryStreamTypes.AUDIOVIDEO]?n.push("audiovideo"):(u[l.ElementaryStreamTypes.AUDIO]&&n.push("audio"),u[l.ElementaryStreamTypes.VIDEO]&&n.push("video")),n.length===0&&A.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+s.type+" level: "+s.level+" sn: "+s.sn),this.blockBuffers(function(){var p=self.performance.now();s.stats.buffering.end=p,d&&(d.stats.buffering.end=p);var g=d?d.stats:s.stats;t.hls.trigger(E.Events.FRAG_BUFFERED,{frag:s,part:d,stats:g,id:s.type})},n)},c.onFragChanged=function(e,a){this.flushBackBuffer()},c.onBufferEos=function(e,a){var t=this;this.getSourceBufferTypes().reduce(function(s,d){var n=t.sourceBuffer[d];return a.type&&a.type!==d||n&&!n.ended&&(n.ended=!0,A.logger.log("[buffer-controller]: "+d+" sourceBuffer now EOS")),s&&!(n&&!n.ended)},!0)&&this.blockBuffers(function(){var s=t.mediaSource;s&&s.readyState==="open"&&s.endOfStream()})},c.onLevelUpdated=function(e,a){var t=a.details;t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},c.flushBackBuffer=function(){var e=this.hls,a=this.details,t=this.media,s=this.sourceBuffer;if(t&&a!==null){var d=this.getSourceBufferTypes();if(d.length){var n=a.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(Object(R.isFiniteNumber)(n)&&!(n<0)){var u=t.currentTime,p=a.levelTargetDuration,g=Math.max(n,p),v=Math.floor(u/p)*p-g;d.forEach(function(i){var r=s[i];if(r){var o=I.BufferHelper.getBuffered(r);o.length>0&&v>o.start(0)&&(e.trigger(E.Events.BACK_BUFFER_REACHED,{bufferEnd:v}),a.live&&e.trigger(E.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:v}),e.trigger(E.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:v,type:i}))}})}}}},c.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&this.mediaSource.readyState==="open"){var e=this.details,a=this.hls,t=this.media,s=this.mediaSource,d=e.fragments[0].start+e.totalduration,n=t.duration,u=Object(R.isFiniteNumber)(s.duration)?s.duration:0;e.live&&a.config.liveDurationInfinity?(A.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(e)):(d>u&&d>n||!Object(R.isFiniteNumber)(n))&&(A.logger.log("[buffer-controller]: Updating Media Source duration to "+d.toFixed(3)),s.duration=d)}},c.updateSeekableRange=function(e){var a=this.mediaSource,t=e.fragments;if(t.length&&e.live&&a!=null&&a.setLiveSeekableRange){var s=Math.max(0,t[0].start),d=Math.max(s,s+e.totalduration);a.setLiveSeekableRange(s,d)}},c.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,a=this.operationQueue,t=this.pendingTracks,s=Object.keys(t).length;if(s&&!e||s===2){this.createSourceBuffers(t),this.pendingTracks={};var d=this.getSourceBufferTypes();if(d.length===0)return void this.hls.trigger(E.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});d.forEach(function(n){a.executeNext(n)})}},c.createSourceBuffers=function(e){var a=this.sourceBuffer,t=this.mediaSource;if(!t)throw Error("createSourceBuffers called when mediaSource was null");var s=0;for(var d in e)if(!a[d]){var n=e[d];if(!n)throw Error("source buffer exists for track "+d+", however track does not");var u=n.levelCodec||n.codec,p=n.container+";codecs="+u;A.logger.log("[buffer-controller]: creating sourceBuffer("+p+")");try{var g=a[d]=t.addSourceBuffer(p),v=d;this.addBufferListener(v,"updatestart",this._onSBUpdateStart),this.addBufferListener(v,"updateend",this._onSBUpdateEnd),this.addBufferListener(v,"error",this._onSBUpdateError),this.tracks[d]={buffer:g,codec:u,container:n.container,levelCodec:n.levelCodec,id:n.id},s++}catch(i){A.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+i.message),this.hls.trigger(E.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:i,mimeType:p})}}s&&this.hls.trigger(E.Events.BUFFER_CREATED,{tracks:this.tracks})},c._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},c._onSBUpdateEnd=function(e){var a=this.operationQueue;a.current(e).onComplete(),a.shiftAndExecuteNext(e)},c._onSBUpdateError=function(e,a){A.logger.error("[buffer-controller]: "+e+" SourceBuffer error",a),this.hls.trigger(E.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var t=this.operationQueue.current(e);t&&t.onError(a)},c.removeExecutor=function(e,a,t){var s=this.media,d=this.mediaSource,n=this.operationQueue,u=this.sourceBuffer[e];if(!s||!d||!u)return A.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void n.shiftAndExecuteNext(e);var p=Object(R.isFiniteNumber)(s.duration)?s.duration:1/0,g=Object(R.isFiniteNumber)(d.duration)?d.duration:1/0,v=Math.max(0,a),i=Math.min(t,p,g);i>v?(A.logger.log("[buffer-controller]: Removing ["+v+","+i+"] from the "+e+" SourceBuffer"),console.assert(!u.updating,e+" sourceBuffer must not be updating"),u.remove(v,i)):n.shiftAndExecuteNext(e)},c.appendExecutor=function(e,a){var t=this.operationQueue,s=this.sourceBuffer[a];if(!s)return A.logger.warn("[buffer-controller]: Attempting to append to the "+a+" SourceBuffer, but it does not exist"),void t.shiftAndExecuteNext(a);s.ended=!1,console.assert(!s.updating,a+" sourceBuffer must not be updating"),s.appendBuffer(e)},c.blockBuffers=function(e,a){var t=this;if(a===void 0&&(a=this.getSourceBufferTypes()),!a.length)return A.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve(e);var s=this.operationQueue,d=a.map(function(n){return s.appendBlocker(n)});Promise.all(d).then(function(){e(),a.forEach(function(n){var u=t.sourceBuffer[n];u&&u.updating||s.shiftAndExecuteNext(n)})})},c.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},c.addBufferListener=function(e,a,t){var s=this.sourceBuffer[e];if(s){var d=t.bind(this,e);this.listeners[e].push({event:a,listener:d}),s.addEventListener(a,d)}},c.removeBufferListeners=function(e){var a=this.sourceBuffer[e];a&&this.listeners[e].forEach(function(t){a.removeEventListener(t.event,t.listener)})},y}()},"./src/controller/buffer-operation-queue.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return E});var R=f("./src/utils/logger.ts"),E=function(){function A(I){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=I}var D=A.prototype;return D.append=function(I,_){var l=this.queues[_];l.push(I),l.length===1&&this.buffers[_]&&this.executeNext(_)},D.insertAbort=function(I,_){this.queues[_].unshift(I),this.executeNext(_)},D.appendBlocker=function(I){var _,l=new Promise(function(m){_=m}),L={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(L,I),l},D.executeNext=function(I){var _=this.buffers,l=this.queues,L=_[I],m=l[I];if(m.length){var h=m[0];try{h.execute()}catch(T){R.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),h.onError(T),L&&L.updating||(m.shift(),this.executeNext(I))}}},D.shiftAndExecuteNext=function(I){this.queues[I].shift(),this.executeNext(I)},D.current=function(I){return this.queues[I][0]},A}()},"./src/controller/cap-level-controller.ts":function(N,C,f){f.r(C);var R=f("./src/events.ts");function E(D,I){for(var _=0;_0&&this.mediaWidth>0){var m=this.hls.levels;if(m.length){var h=this.hls;h.autoLevelCapping=this.getMaxLevel(m.length-1),h.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=h.autoLevelCapping}}},L.getMaxLevel=function(m){var h=this,T=this.hls.levels;if(!T.length)return-1;var y=T.filter(function(c,e){return D.isLevelAllowed(e,h.restrictedLevels)&&e<=m});return this.clientRect=null,D.getMaxLevelByMediaSize(y,this.mediaWidth,this.mediaHeight)},L.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())},L.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},L.getDimensions=function(){if(this.clientRect)return this.clientRect;var m=this.media,h={width:0,height:0};if(m){var T=m.getBoundingClientRect();h.width=T.width,h.height=T.height,h.width||h.height||(h.width=T.right-T.left||m.width||0,h.height=T.bottom-T.top||m.height||0)}return this.clientRect=h,h},D.isLevelAllowed=function(m,h){return h===void 0&&(h=[]),h.indexOf(m)===-1},D.getMaxLevelByMediaSize=function(m,h,T){if(!m||!m.length)return-1;for(var y,c,e=m.length-1,a=0;a=h||t.height>=T)&&(y=t,!(c=m[a+1])||y.width!==c.width||y.height!==c.height)){e=a;break}}return e},I=D,l=[{key:"contentScaleFactor",get:function(){var m=1;try{m=self.devicePixelRatio}catch{}return m}}],(_=[{key:"mediaWidth",get:function(){return this.getDimensions().width*D.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*D.contentScaleFactor}}])&&E(I.prototype,_),l&&E(I,l),D}();C.default=A},"./src/controller/eme-controller.ts":function(N,C,f){f.r(C);var R=f("./src/events.ts"),E=f("./src/errors.ts"),A=f("./src/utils/logger.ts"),D=f("./src/utils/mediakeys-helper.ts");function I(l,L){for(var m=0;m3)return void this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.KEY_SYSTEM_ERROR,details:E.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var s=3-this._requestLicenseFailureCount+1;A.logger.warn("Retrying license request, "+s+" attempts left"),this._requestLicense(c,e)}}},h._generateLicenseRequestChallenge=function(T,y){switch(T.mediaKeySystemDomain){case D.KeySystems.WIDEVINE:return y}throw new Error("unsupported key-system: "+T.mediaKeySystemDomain)},h._requestLicense=function(T,y){A.logger.log("Requesting content license for key-system");var c=this._mediaKeysList[0];if(!c)return A.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.KEY_SYSTEM_ERROR,details:E.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var e=this.getLicenseServerUrl(c.mediaKeySystemDomain),a=this._createLicenseXhr(e,T,y);A.logger.log("Sending license request to URL: "+e);var t=this._generateLicenseRequestChallenge(c,T);a.send(t)}catch(s){A.logger.error("Failure requesting DRM license: "+s),this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.KEY_SYSTEM_ERROR,details:E.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},h.onMediaAttached=function(T,y){if(this._emeEnabled){var c=y.media;this._media=c,c.addEventListener("encrypted",this._onMediaEncrypted)}},h.onMediaDetached=function(){var T=this._media,y=this._mediaKeysList;T&&(T.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(y.map(function(c){if(c.mediaKeysSession)return c.mediaKeysSession.close().catch(function(){})})).then(function(){return T.setMediaKeys(null)}).catch(function(){}))},h.onManifestParsed=function(T,y){if(this._emeEnabled){var c=y.levels.map(function(a){return a.audioCodec}).filter(function(a){return!!a}),e=y.levels.map(function(a){return a.videoCodec}).filter(function(a){return!!a});this._attemptKeySystemAccess(D.KeySystems.WIDEVINE,c,e)}},L=l,(m=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&I(L.prototype,m),l}();C.default=_},"./src/controller/fps-controller.ts":function(N,C,f){f.r(C);var R=f("./src/events.ts"),E=f("./src/utils/logger.ts"),A=function(){function D(_){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=_,this.registerListeners()}var I=D.prototype;return I.setStreamController=function(_){this.streamController=_},I.registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},I.unregisterListeners=function(){this.hls.off(R.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){var L=this.hls.config;if(L.capLevelOnFPSDrop){var m=l.media instanceof self.HTMLVideoElement?l.media:null;this.media=m,m&&typeof m.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),L.fpsDroppedMonitoringPeriod)}},I.checkFPS=function(_,l,L){var m=performance.now();if(l){if(this.lastTime){var h=m-this.lastTime,T=L-this.lastDroppedFrames,y=l-this.lastDecodedFrames,c=1e3*T/h,e=this.hls;if(e.trigger(R.Events.FPS_DROP,{currentDropped:T,currentDecoded:y,totalDroppedFrames:L}),c>0&&T>e.config.fpsDroppedMonitoringThreshold*y){var a=e.currentLevel;E.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+a),a>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=a)&&(a-=1,e.trigger(R.Events.FPS_DROP_LEVEL_CAPPING,{level:a,droppedLevel:e.currentLevel}),e.autoLevelCapping=a,this.streamController.nextLevelSwitch())}}this.lastTime=m,this.lastDroppedFrames=L,this.lastDecodedFrames=l}},I.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var l=_.getVideoPlaybackQuality();this.checkFPS(_,l.totalVideoFrames,l.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},D}();C.default=A},"./src/controller/fragment-finders.ts":function(N,C,f){f.r(C),f.d(C,"findFragmentByPDT",function(){return A}),f.d(C,"findFragmentByPTS",function(){return D}),f.d(C,"fragmentWithinToleranceTest",function(){return I}),f.d(C,"pdtWithinToleranceTest",function(){return _}),f.d(C,"findFragWithCC",function(){return l});var R=f("./src/polyfills/number.ts"),E=f("./src/utils/binary-search.ts");function A(L,m,h){if(m===null||!Array.isArray(L)||!L.length||!Object(R.isFiniteNumber)(m)||m<(L[0].programDateTime||0)||m>=(L[L.length-1].endProgramDateTime||0))return null;h=h||0;for(var T=0;TL&&h.start?-1:0}function _(L,m,h){var T=1e3*Math.min(m,h.duration+(h.deltaPTS?h.deltaPTS:0));return(h.endProgramDateTime||0)-T>L}function l(L,m){return E.default.search(L,function(h){return h.ccm?-1:0})}},"./src/controller/fragment-tracker.ts":function(N,C,f){f.r(C),f.d(C,"FragmentState",function(){return R}),f.d(C,"FragmentTracker",function(){return I});var R,E,A=f("./src/events.ts"),D=f("./src/types/loader.ts");(E=R||(R={})).NOT_LOADED="NOT_LOADED",E.BACKTRACKED="BACKTRACKED",E.APPENDING="APPENDING",E.PARTIAL="PARTIAL",E.OK="OK";var I=function(){function L(h){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=h,this._registerListeners()}var m=L.prototype;return m._registerListeners=function(){var h=this.hls;h.on(A.Events.BUFFER_APPENDED,this.onBufferAppended,this),h.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.on(A.Events.FRAG_LOADED,this.onFragLoaded,this)},m._unregisterListeners=function(){var h=this.hls;h.off(A.Events.BUFFER_APPENDED,this.onBufferAppended,this),h.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.off(A.Events.FRAG_LOADED,this.onFragLoaded,this)},m.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},m.getAppendedFrag=function(h,T){if(T===D.PlaylistLevelType.MAIN){var y=this.activeFragment,c=this.activeParts;if(!y)return null;if(c)for(var e=c.length;e--;){var a=c[e],t=a?a.end:y.appendedPTS;if(a.start<=h&&t!==void 0&&h<=t)return e>9&&(this.activeParts=c.slice(e-9)),a}else if(y.start<=h&&y.appendedPTS!==void 0&&h<=y.appendedPTS)return y}return this.getBufferedFrag(h,T)},m.getBufferedFrag=function(h,T){for(var y=this.fragments,c=Object.keys(y),e=c.length;e--;){var a=y[c[e]];if((a==null?void 0:a.body.type)===T&&a.buffered){var t=a.body;if(t.start<=h&&h<=t.end)return t}}return null},m.detectEvictedFragments=function(h,T,y){var c=this;Object.keys(this.fragments).forEach(function(e){var a=c.fragments[e];if(a)if(a.buffered){var t=a.range[h];t&&t.time.some(function(s){var d=!c.isTimeBuffered(s.startPTS,s.endPTS,T);return d&&c.removeFragment(a.body),d})}else a.body.type===y&&c.removeFragment(a.body)})},m.detectPartialFragments=function(h){var T=this,y=this.timeRanges,c=h.frag,e=h.part;if(y&&c.sn!=="initSegment"){var a=l(c),t=this.fragments[a];t&&(Object.keys(y).forEach(function(s){var d=c.elementaryStreams[s];if(d){var n=y[s],u=e!==null||d.partial===!0;t.range[s]=T.getBufferedTimes(c,e,u,n)}}),t.backtrack=t.loaded=null,Object.keys(t.range).length?t.buffered=!0:this.removeFragment(t.body))}},m.fragBuffered=function(h){var T=l(h),y=this.fragments[T];y&&(y.backtrack=y.loaded=null,y.buffered=!0)},m.getBufferedTimes=function(h,T,y,c){for(var e={time:[],partial:y},a=T?T.start:h.start,t=T?T.end:h.end,s=h.minEndPTS||t,d=h.maxStartPTS||a,n=0;n=u&&s<=p){e.time.push({startPTS:Math.max(a,c.start(n)),endPTS:Math.min(t,c.end(n))});break}if(au)e.partial=!0,e.time.push({startPTS:Math.max(a,c.start(n)),endPTS:Math.min(t,c.end(n))});else if(t<=u)break}return e},m.getPartialFragment=function(h){var T,y,c,e=null,a=0,t=this.bufferPadding,s=this.fragments;return Object.keys(s).forEach(function(d){var n=s[d];n&&_(n)&&(y=n.body.start-t,c=n.body.end+t,h>=y&&h<=c&&(T=Math.min(h-y,c-h),a<=T&&(e=n.body,a=T)))}),e},m.getState=function(h){var T=l(h),y=this.fragments[T];return y?y.buffered?_(y)?R.PARTIAL:R.OK:y.backtrack?R.BACKTRACKED:R.APPENDING:R.NOT_LOADED},m.backtrack=function(h,T){var y=l(h),c=this.fragments[y];if(!c||c.backtrack)return null;var e=c.backtrack=T||c.loaded;return c.loaded=null,e},m.getBacktrackData=function(h){var T=l(h),y=this.fragments[T];if(y){var c,e=y.backtrack;if(e!=null&&(c=e.payload)!==null&&c!==void 0&&c.byteLength)return e;this.removeFragment(h)}return null},m.isTimeBuffered=function(h,T,y){for(var c,e,a=0;a=c&&T<=e)return!0;if(T<=c)return!1}return!1},m.onFragLoaded=function(h,T){var y=T.frag,c=T.part;if(y.sn!=="initSegment"&&!y.bitrateTest&&!c){var e=l(y);this.fragments[e]={body:y,loaded:T,backtrack:null,buffered:!1,range:Object.create(null)}}},m.onBufferAppended=function(h,T){var y=this,c=T.frag,e=T.part,a=T.timeRanges;if(c.type===D.PlaylistLevelType.MAIN)if(this.activeFragment=c,e){var t=this.activeParts;t||(this.activeParts=t=[]),t.push(e)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach(function(s){var d=a[s];if(y.detectEvictedFragments(s,d),!e)for(var n=0;nh&&c.removeFragment(t)}})},m.removeFragment=function(h){var T=l(h);h.stats.loaded=0,h.clearElementaryStreamInfo(),delete this.fragments[T]},m.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},L}();function _(L){var m,h;return L.buffered&&(((m=L.range.video)===null||m===void 0?void 0:m.partial)||((h=L.range.audio)===null||h===void 0?void 0:h.partial))}function l(L){return L.type+"_"+L.level+"_"+L.urlId+"_"+L.sn}},"./src/controller/gap-controller.ts":function(N,C,f){f.r(C),f.d(C,"STALL_MINIMUM_DURATION_MS",function(){return I}),f.d(C,"MAX_START_GAP_JUMP",function(){return _}),f.d(C,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return l}),f.d(C,"SKIP_BUFFER_RANGE_START",function(){return L}),f.d(C,"default",function(){return m});var R=f("./src/utils/buffer-helper.ts"),E=f("./src/errors.ts"),A=f("./src/events.ts"),D=f("./src/utils/logger.ts"),I=250,_=2,l=.1,L=.05,m=function(){function h(y,c,e,a){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=y,this.media=c,this.fragmentTracker=e,this.hls=a}var T=h.prototype;return T.destroy=function(){this.hls=this.fragmentTracker=this.media=null},T.poll=function(y){var c=this.config,e=this.media,a=this.stalled,t=e.currentTime,s=e.seeking,d=this.seeking&&!s,n=!this.seeking&&s;if(this.seeking=s,t===y){if((n||d)&&(this.stalled=null),!e.paused&&!e.ended&&e.playbackRate!==0&&R.BufferHelper.getBuffered(e).length){var u=R.BufferHelper.bufferInfo(e,t,0),p=u.len>0,g=u.nextStart||0;if(p||g){if(s){var v=u.len>_,i=!g||g-t>_&&!this.fragmentTracker.getPartialFragment(t);if(v||i)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var r,o=Math.max(g,u.start||0)-t,S=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,b=!(S==null||(r=S.details)===null||r===void 0)&&r.live?2*S.details.targetduration:_;if(o>0&&o<=b)return void this._trySkipBufferHole(null)}var k=self.performance.now();if(a!==null){var x=k-a;!s&&x>=I&&this._reportStall(u.len);var w=R.BufferHelper.bufferInfo(e,t,c.maxBufferHole);this._tryFixBufferStall(w,x)}else this.stalled=k}}}else if(this.moved=!0,a!==null){if(this.stallReported){var O=self.performance.now()-a;D.logger.warn("playback not stuck anymore @"+t+", after "+Math.round(O)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},T._tryFixBufferStall=function(y,c){var e=this.config,a=this.fragmentTracker,t=this.media.currentTime,s=a.getPartialFragment(t);s&&this._trySkipBufferHole(s)||y.len>e.maxBufferHole&&c>1e3*e.highBufferWatchdogPeriod&&(D.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},T._reportStall=function(y){var c=this.hls,e=this.media;this.stallReported||(this.stallReported=!0,D.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer (buffer="+y+")"),c.trigger(A.Events.ERROR,{type:E.ErrorTypes.MEDIA_ERROR,details:E.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:y}))},T._trySkipBufferHole=function(y){for(var c=this.config,e=this.hls,a=this.media,t=a.currentTime,s=0,d=R.BufferHelper.getBuffered(a),n=0;n=s&&t.05&&this.forwardBufferLength>1){var n=Math.min(2,Math.max(1,a)),u=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20;h.playbackRate=Math.min(n,Math.max(1,u))}else h.playbackRate!==1&&h.playbackRate!==0&&(h.playbackRate=1)}}}}},m.estimateLiveEdge=function(){var h=this.levelDetails;return h===null?null:h.edge+h.age},m.computeLatency=function(){var h=this.estimateLiveEdge();return h===null?null:h-this.currentTime},l=_,(L=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var h=this.config,T=this.levelDetails;return h.liveMaxLatencyDuration!==void 0?h.liveMaxLatencyDuration:T?h.liveMaxLatencyDurationCount*T.targetduration:0}},{key:"targetLatency",get:function(){var h=this.levelDetails;if(h===null)return null;var T=h.holdBack,y=h.partHoldBack,c=h.targetduration,e=this.config,a=e.liveSyncDuration,t=e.liveSyncDurationCount,s=e.lowLatencyMode,d=this.hls.userConfig,n=s&&y||T;(d.liveSyncDuration||d.liveSyncDurationCount||n===0)&&(n=a!==void 0?a:t*c);var u=c;return n+Math.min(1*this.stallCount,u)}},{key:"liveSyncPosition",get:function(){var h=this.estimateLiveEdge(),T=this.targetLatency,y=this.levelDetails;if(h===null||T===null||y===null)return null;var c=y.edge,e=h-T-this.edgeStalled,a=c-y.totalduration,t=c-(this.config.lowLatencyMode&&y.partTarget||y.targetduration);return Math.min(Math.max(a,e),t)}},{key:"drift",get:function(){var h=this.levelDetails;return h===null?1:h.drift}},{key:"edgeStalled",get:function(){var h=this.levelDetails;if(h===null)return 0;var T=3*(this.config.lowLatencyMode&&h.partTarget||h.targetduration);return Math.max(h.age-T,0)}},{key:"forwardBufferLength",get:function(){var h=this.media,T=this.levelDetails;if(!h||!T)return 0;var y=h.buffered.length;return y?h.buffered.end(y-1):T.edge-this.currentTime}}])&&D(l.prototype,L),_}()},"./src/controller/level-controller.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return y});var R=f("./src/types/level.ts"),E=f("./src/events.ts"),A=f("./src/errors.ts"),D=f("./src/utils/codecs.ts"),I=f("./src/controller/level-helper.ts"),_=f("./src/controller/base-playlist-controller.ts"),l=f("./src/types/loader.ts");function L(){return(L=Object.assign||function(c){for(var e=1;e0){g=i[0].bitrate,i.sort(function(F,M){return F.bitrate-M.bitrate}),this._levels=i;for(var w=0;wthis.hls.config.fragLoadingMaxRetry&&(i=p.frag.level)):i=p.frag.level}break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:g&&(g.deliveryDirectives&&(o=!1),i=g.level),r=!0;break;case A.ErrorDetails.REMUX_ALLOC_ERROR:i=p.level,r=!0}i!==void 0&&this.recoverLevel(p,i,r,o)}}},n.recoverLevel=function(u,p,g,v){var i=u.details,r=this._levels[p];if(r.loadError++,g){if(!this.retryLoadingOrFail(u))return void(this.currentLevelIndex=-1);u.levelRetry=!0}if(v){var o=r.url.length;if(o>1&&r.loadError1){var v=(p.urlId+1)%g;this.warn("Switching to redundant URL-id "+v),this._levels.forEach(function(i){i.urlId=v}),this.level=u}},n.onFragLoaded=function(u,p){var g=p.frag;if(g!==void 0&&g.type===l.PlaylistLevelType.MAIN){var v=this._levels[g.level];v!==void 0&&(v.fragmentError=0,v.loadError=0)}},n.onLevelLoaded=function(u,p){var g,v,i=p.level,r=p.details,o=this._levels[i];if(!o)return this.warn("Invalid level index "+i),void((v=p.deliveryDirectives)!==null&&v!==void 0&&v.skip&&(r.deltaUpdateFailed=!0));i===this.currentLevelIndex?(o.fragmentError===0&&(o.loadError=0,this.retryCount=0),this.playlistLoaded(i,p,o.details)):(g=p.deliveryDirectives)!==null&&g!==void 0&&g.skip&&(r.deltaUpdateFailed=!0)},n.onAudioTrackSwitched=function(u,p){var g=this.hls.levels[this.currentLevelIndex];if(g&&g.audioGroupIds){for(var v=-1,i=this.hls.audioTracks[p.id].groupId,r=0;r0){var v=g.urlId,i=g.url[v];if(u)try{i=u.addDirectives(i)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log("Attempt loading level index "+p+(u?" at sn "+u.msn+" part "+u.part:"")+" with URL-id "+v+" "+i),this.clearTimer(),this.hls.trigger(E.Events.LEVEL_LOADING,{url:i,level:p,id:v,deliveryDirectives:u||null})}},n.removeLevel=function(u,p){var g=function(i,r){return r!==p},v=this._levels.filter(function(i,r){return r!==u||i.url.length>1&&p!==void 0&&(i.url=i.url.filter(g),i.audioGroupIds&&(i.audioGroupIds=i.audioGroupIds.filter(g)),i.textGroupIds&&(i.textGroupIds=i.textGroupIds.filter(g)),i.urlId=0,!0)}).map(function(i,r){var o=i.details;return o!=null&&o.fragments&&o.fragments.forEach(function(S){S.level=r}),i});this._levels=v,this.hls.trigger(E.Events.LEVELS_UPDATED,{levels:v})},s=t,(d=[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(u){var p,g=this._levels;if(g.length!==0&&(this.currentLevelIndex!==u||(p=g[u])===null||p===void 0||!p.details)){if(u<0||u>=g.length){var v=u<0;if(this.hls.trigger(E.Events.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.LEVEL_SWITCH_ERROR,level:u,fatal:v,reason:"invalid level idx"}),v)return;u=Math.min(u,g.length-1)}this.clearTimer();var i=this.currentLevelIndex,r=g[i],o=g[u];this.log("switching to level "+u+" from "+i),this.currentLevelIndex=u;var S=L({},o,{level:u,maxBitrate:o.maxBitrate,uri:o.uri,urlId:o.urlId});delete S._urlId,this.hls.trigger(E.Events.LEVEL_SWITCHING,S);var b=o.details;if(!b||b.live){var k=this.switchParams(o.uri,r==null?void 0:r.details);this.loadPlaylist(k)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(u){this.manualLevelIndex=u,this._startLevel===void 0&&(this._startLevel=u),u!==-1&&(this.level=u)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(u){this._firstLevel=u}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var u=this.hls.config.startLevel;return u!==void 0?u:this._firstLevel}return this._startLevel},set:function(u){this._startLevel=u}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(u){this.level=u,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=u)}}])&&m(s.prototype,d),t}(_.default)},"./src/controller/level-helper.ts":function(N,C,f){f.r(C),f.d(C,"addGroupId",function(){return A}),f.d(C,"assignTrackIdsByGroup",function(){return D}),f.d(C,"updatePTS",function(){return I}),f.d(C,"updateFragPTSDTS",function(){return l}),f.d(C,"mergeDetails",function(){return L}),f.d(C,"mapPartIntersection",function(){return m}),f.d(C,"mapFragmentIntersection",function(){return h}),f.d(C,"adjustSliding",function(){return T}),f.d(C,"addSliding",function(){return y}),f.d(C,"computeReloadInterval",function(){return c}),f.d(C,"getFragmentWithSN",function(){return e}),f.d(C,"getPartWith",function(){return a});var R=f("./src/polyfills/number.ts"),E=f("./src/utils/logger.ts");function A(t,s,d){switch(s){case"audio":t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds.push(d);break;case"text":t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds.push(d)}}function D(t){var s={};t.forEach(function(d){var n=d.groupId||"";d.id=s[n]=s[n]||0,s[n]++})}function I(t,s,d){_(t[s],t[d])}function _(t,s){var d=s.startPTS;if(Object(R.isFiniteNumber)(d)){var n,u=0;s.sn>t.sn?(u=d-t.start,n=t):(u=t.start-d,n=s),n.duration!==u&&(n.duration=u)}else s.sn>t.sn?t.cc===s.cc&&t.minEndPTS?s.start=t.start+(t.minEndPTS-t.start):s.start=t.start+t.duration:s.start=Math.max(t.start-s.duration,0)}function l(t,s,d,n,u,p){n-d<=0&&(E.logger.warn("Fragment should have a positive duration",s),n=d+s.duration,p=u+s.duration);var g=d,v=n,i=s.startPTS,r=s.endPTS;if(Object(R.isFiniteNumber)(i)){var o=Math.abs(i-d);Object(R.isFiniteNumber)(s.deltaPTS)?s.deltaPTS=Math.max(o,s.deltaPTS):s.deltaPTS=o,g=Math.max(d,i),d=Math.min(d,i),u=Math.min(u,s.startDTS),v=Math.min(n,r),n=Math.max(n,r),p=Math.max(p,s.endDTS)}s.duration=n-d;var S=d-s.start;s.appendedPTS=n,s.start=s.startPTS=d,s.maxStartPTS=g,s.startDTS=u,s.endPTS=n,s.minEndPTS=v,s.endDTS=p;var b,k=s.sn;if(!t||kt.endSN)return 0;var x=k-t.startSN,w=t.fragments;for(w[x]=s,b=x;b>0;b--)_(w[b],w[b-1]);for(b=x;b=0;u--){var p=n[u].initSegment;if(p){d=p;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var g,v=0;if(h(t,s,function(k,x){var w;k.relurl&&(v=k.cc-x.cc),Object(R.isFiniteNumber)(k.startPTS)&&Object(R.isFiniteNumber)(k.endPTS)&&(x.start=x.startPTS=k.startPTS,x.startDTS=k.startDTS,x.appendedPTS=k.appendedPTS,x.maxStartPTS=k.maxStartPTS,x.endPTS=k.endPTS,x.endDTS=k.endDTS,x.minEndPTS=k.minEndPTS,x.duration=k.endPTS-k.startPTS,x.duration&&(g=x),s.PTSKnown=s.alignedSliding=!0),x.elementaryStreams=k.elementaryStreams,x.loader=k.loader,x.stats=k.stats,x.urlId=k.urlId,k.initSegment?(x.initSegment=k.initSegment,d=k.initSegment):x.initSegment&&x.initSegment.relurl!=((w=d)===null||w===void 0?void 0:w.relurl)||(x.initSegment=d)}),s.skippedSegments&&(s.deltaUpdateFailed=s.fragments.some(function(k){return!k}),s.deltaUpdateFailed)){E.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var i=s.skippedSegments;i--;)s.fragments.shift();s.startSN=s.fragments[0].sn,s.startCC=s.fragments[0].cc}var r=s.fragments;if(v){E.logger.warn("discontinuity sliding from playlist, take drift into account");for(var o=0;o=n.length||y(s,n[d].start)}function y(t,s){if(s){for(var d=t.fragments,n=t.skippedSegments;n0&&p<3*n,v=s.loading.end-s.loading.start,i=t.availabilityDelay;if(t.updated===!1)if(g){var r=333*t.misses;d=Math.max(Math.min(u,2*v),r),t.availabilityDelay=(t.availabilityDelay||0)+d}else d=u;else g?(i=Math.min(i||n/2,p),t.availabilityDelay=i,d=i+n-p):d=n-v;return Math.round(d)}function e(t,s,d){if(!t||!t.details)return null;var n=t.details,u=n.fragments[s-n.startSN];return u||((u=n.fragmentHint)&&u.sn===s?u:s0&&i===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),i=r),this.state=E.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=i,this.tick()}else this._forceStartLoad=!0,this.state=E.State.STOPPED},v.stopLoad=function(){this._forceStartLoad=!1,s.prototype.stopLoad.call(this)},v.doTick=function(){switch(this.state){case E.State.IDLE:this.doTickIdle();break;case E.State.WAITING_LEVEL:var i,r=this.levels,o=this.level,S=r==null||(i=r[o])===null||i===void 0?void 0:i.details;if(S&&(!S.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(S))break;this.state=E.State.IDLE;break}break;case E.State.FRAG_LOADING_WAITING_RETRY:var b,k=self.performance.now(),x=this.retryDate;(!x||k>=x||(b=this.media)!==null&&b!==void 0&&b.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=E.State.IDLE)}this.onTickEnd()},v.onTickEnd=function(){s.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},v.doTickIdle=function(){var i,r,o=this.hls,S=this.levelLastLoaded,b=this.levels,k=this.media,x=o.config,w=o.nextLoadLevel;if(S!==null&&(k||!this.startFragRequested&&x.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&b&&b[w]){var O=b[w];this.level=o.nextLoadLevel=w;var P=O.details;if(!P||this.state===E.State.WAITING_LEVEL||P.live&&this.levelLastLoaded!==w)this.state=E.State.WAITING_LEVEL;else{var F=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:k,l.PlaylistLevelType.MAIN);if(F!==null&&!(F.len>=this.getMaxBufferLength(O.maxBitrate))){if(this._streamEnded(F,P)){var M={};return this.altAudio&&(M.type="video"),this.hls.trigger(D.Events.BUFFER_EOS,M),void(this.state=E.State.ENDED)}var B=F.end,U=this.getNextFragment(B,P);if(this.couldBacktrack&&!this.fragPrevious&&U&&U.sn!=="initSegment"){var j=U.sn-P.startSN;j>1&&(U=P.fragments[j-1],this.fragmentTracker.removeFragment(U))}if(U&&this.fragmentTracker.getState(U)===_.FragmentState.OK&&this.nextLoadPosition>B){var V=this.audioOnly&&!this.altAudio?L.ElementaryStreamTypes.AUDIO:L.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(k,V,l.PlaylistLevelType.MAIN),U=this.getNextFragment(this.nextLoadPosition,P)}U&&(!U.initSegment||U.initSegment.data||this.bitrateTest||(U=U.initSegment),((i=U.decryptdata)===null||i===void 0?void 0:i.keyFormat)!=="identity"||(r=U.decryptdata)!==null&&r!==void 0&&r.key?this.loadFragment(U,P,B):this.loadKey(U,P))}}}},v.loadFragment=function(i,r,o){var S,b=this.fragmentTracker.getState(i);if(this.fragCurrent=i,b===_.FragmentState.BACKTRACKED){var k=this.fragmentTracker.getBacktrackData(i);if(k)return this._handleFragmentLoadProgress(k),void this._handleFragmentLoadComplete(k);b=_.FragmentState.NOT_LOADED}b===_.FragmentState.NOT_LOADED||b===_.FragmentState.PARTIAL?i.sn==="initSegment"?this._loadInitSegment(i):this.bitrateTest?(i.bitrateTest=!0,this.log("Fragment "+i.sn+" of level "+i.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(i)):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,i,r,o)):b===_.FragmentState.APPENDING?this.reduceMaxBufferLength(i.duration)&&this.fragmentTracker.removeFragment(i):((S=this.media)===null||S===void 0?void 0:S.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},v.getAppendedFrag=function(i){var r=this.fragmentTracker.getAppendedFrag(i,l.PlaylistLevelType.MAIN);return r&&"fragment"in r?r.fragment:r},v.getBufferedFrag=function(i){return this.fragmentTracker.getBufferedFrag(i,l.PlaylistLevelType.MAIN)},v.followingBufferedFrag=function(i){return i?this.getBufferedFrag(i.end+.5):null},v.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},v.nextLevelSwitch=function(){var i=this.levels,r=this.media;if(r!=null&&r.readyState){var o,S=this.getAppendedFrag(r.currentTime);if(S&&S.start>1&&this.flushMainBuffer(0,S.start-1),!r.paused&&i){var b=i[this.hls.nextLoadLevel],k=this.fragLastKbps;o=k&&this.fragCurrent?this.fragCurrent.duration*b.maxBitrate/(1e3*k)+1:0}else o=0;var x=this.getBufferedFrag(r.currentTime+o);if(x){var w=this.followingBufferedFrag(x);if(w){this.abortCurrentFrag();var O=w.maxStartPTS?w.maxStartPTS:w.start,P=w.duration,F=Math.max(x.end,O+Math.min(Math.max(P-this.config.maxFragLookUpTolerance,.5*P),.75*P));this.flushMainBuffer(F,Number.POSITIVE_INFINITY)}}}},v.abortCurrentFrag=function(){var i=this.fragCurrent;this.fragCurrent=null,i!=null&&i.loader&&i.loader.abort(),this.state===E.State.KEY_LOADING&&(this.state=E.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},v.flushMainBuffer=function(i,r){s.prototype.flushMainBuffer.call(this,i,r,this.altAudio?"video":null)},v.onMediaAttached=function(i,r){s.prototype.onMediaAttached.call(this,i,r);var o=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),o.addEventListener("playing",this.onvplaying),o.addEventListener("seeked",this.onvseeked),this.gapController=new T.default(this.config,o,this.fragmentTracker,this.hls)},v.onMediaDetaching=function(){var i=this.media;i&&(i.removeEventListener("playing",this.onvplaying),i.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),s.prototype.onMediaDetaching.call(this)},v.onMediaPlaying=function(){this.tick()},v.onMediaSeeked=function(){var i=this.media,r=i?i.currentTime:null;Object(R.isFiniteNumber)(r)&&this.log("Media seeked to "+r.toFixed(3)),this.tick()},v.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(D.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},v.onManifestParsed=function(i,r){var o,S=!1,b=!1;r.levels.forEach(function(k){(o=k.audioCodec)&&(o.indexOf("mp4a.40.2")!==-1&&(S=!0),o.indexOf("mp4a.40.5")!==-1&&(b=!0))}),this.audioCodecSwitch=S&&b&&!Object(A.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},v.onLevelLoading=function(i,r){var o=this.levels;if(o&&this.state===E.State.IDLE){var S=o[r.level];(!S.details||S.details.live&&this.levelLastLoaded!==r.level||this.waitForCdnTuneIn(S.details))&&(this.state=E.State.WAITING_LEVEL)}},v.onLevelLoaded=function(i,r){var o,S=this.levels,b=r.level,k=r.details,x=k.totalduration;if(S){this.log("Level "+b+" loaded ["+k.startSN+","+k.endSN+"], cc ["+k.startCC+", "+k.endCC+"] duration:"+x);var w=this.fragCurrent;!w||this.state!==E.State.FRAG_LOADING&&this.state!==E.State.FRAG_LOADING_WAITING_RETRY||w.level!==r.level&&w.loader&&(this.state=E.State.IDLE,w.loader.abort());var O=S[b],P=0;if(k.live||(o=O.details)!==null&&o!==void 0&&o.live){if(k.fragments[0]||(k.deltaUpdateFailed=!0),k.deltaUpdateFailed)return;P=this.alignPlaylists(k,O.details)}if(O.details=k,this.levelLastLoaded=b,this.hls.trigger(D.Events.LEVEL_UPDATED,{details:k,level:b}),this.state===E.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(k))return;this.state=E.State.IDLE}this.startFragRequested?k.live&&this.synchronizeToLiveEdge(k):this.setStartPosition(k,P),this.tick()}else this.warn("Levels were reset while loading level "+b)},v._handleFragmentLoadProgress=function(i){var r,o=i.frag,S=i.part,b=i.payload,k=this.levels;if(k){var x=k[o.level],w=x.details;if(w){var O=x.videoCodec,P=w.PTSKnown||!w.live,F=(r=o.initSegment)===null||r===void 0?void 0:r.data,M=this._getAudioCodec(x),B=this.transmuxer=this.transmuxer||new m.default(this.hls,l.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),U=S?S.index:-1,j=U!==-1,V=new h.ChunkMetadata(o.level,o.sn,o.stats.chunkCount,b.byteLength,U,j),H=this.initPTS[o.cc];B.push(b,F,M,O,o,S,w.totalduration,P,V,H)}else this.warn("Dropping fragment "+o.sn+" of level "+o.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered")},v.onAudioTrackSwitching=function(i,r){var o=this.altAudio,S=!!r.url,b=r.id;if(!S){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var k=this.fragCurrent;k!=null&&k.loader&&(this.log("Switching to main audio track, cancel main fragment load"),k.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var x=this.hls;o&&x.trigger(D.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),x.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:b})}},v.onAudioTrackSwitched=function(i,r){var o=r.id,S=!!this.hls.audioTracks[o].url;if(S){var b=this.videoBuffer;b&&this.mediaBuffer!==b&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=b)}this.altAudio=S,this.tick()},v.onBufferCreated=function(i,r){var o,S,b=r.tracks,k=!1;for(var x in b){var w=b[x];if(w.id==="main"){if(S=x,o=w,x==="video"){var O=b[x];O&&(this.videoBuffer=O.buffer)}}else k=!0}k&&o?(this.log("Alternate track found, use "+S+".buffered to schedule main fragment loading"),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media},v.onFragBuffered=function(i,r){var o=r.frag,S=r.part;if(!o||o.type===l.PlaylistLevelType.MAIN){if(this.fragContextChanged(o))return this.warn("Fragment "+o.sn+(S?" p: "+S.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===E.State.PARSED&&(this.state=E.State.IDLE));var b=S?S.stats:o.stats;this.fragLastKbps=Math.round(8*b.total/(b.buffering.end-b.loading.first)),o.sn!=="initSegment"&&(this.fragPrevious=o),this.fragBufferedComplete(o,S)}},v.onError=function(i,r){switch(r.details){case y.ErrorDetails.FRAG_LOAD_ERROR:case y.ErrorDetails.FRAG_LOAD_TIMEOUT:case y.ErrorDetails.KEY_LOAD_ERROR:case y.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(l.PlaylistLevelType.MAIN,r);break;case y.ErrorDetails.LEVEL_LOAD_ERROR:case y.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==E.State.ERROR&&(r.fatal?(this.warn(""+r.details),this.state=E.State.ERROR):r.levelRetry||this.state!==E.State.WAITING_LEVEL||(this.state=E.State.IDLE));break;case y.ErrorDetails.BUFFER_FULL_ERROR:if(r.parent==="main"&&(this.state===E.State.PARSING||this.state===E.State.PARSED)){var o=!0,S=this.getFwdBufferInfo(this.media,l.PlaylistLevelType.MAIN);S&&S.len>.5&&(o=!this.reduceMaxBufferLength(S.len)),o&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}},v.checkBuffer=function(){var i=this.media,r=this.gapController;if(i&&r&&i.readyState){var o=I.BufferHelper.getBuffered(i);!this.loadedmetadata&&o.length?(this.loadedmetadata=!0,this.seekToStartPos()):r.poll(this.lastCurrentTime),this.lastCurrentTime=i.currentTime}},v.onFragLoadEmergencyAborted=function(){this.state=E.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},v.onBufferFlushed=function(i,r){var o=r.type;if(o!==L.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var S=(o===L.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(S,o,l.PlaylistLevelType.MAIN)}},v.onLevelsUpdated=function(i,r){this.levels=r.levels},v.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},v.seekToStartPos=function(){var i=this.media,r=i.currentTime,o=this.startPosition;if(o>=0&&r0&&b1&&i.seeking===!1){var o=i.currentTime;if(I.BufferHelper.isBuffered(i,o)?r=this.getAppendedFrag(o):I.BufferHelper.isBuffered(i,o+.1)&&(r=this.getAppendedFrag(o+.1)),r){var S=this.fragPlaying,b=r.level;S&&r.sn===S.sn&&S.level===b&&r.urlId===S.urlId||(this.hls.trigger(D.Events.FRAG_CHANGED,{frag:r}),S&&S.level===b||this.hls.trigger(D.Events.LEVEL_SWITCHED,{level:b}),this.fragPlaying=r)}}},p=u,(g=[{key:"nextLevel",get:function(){var i=this.nextBufferedFrag;return i?i.level:-1}},{key:"currentLevel",get:function(){var i=this.media;if(i){var r=this.getAppendedFrag(i.currentTime);if(r)return r.level}return-1}},{key:"nextBufferedFrag",get:function(){var i=this.media;if(i){var r=this.getAppendedFrag(i.currentTime);return this.followingBufferedFrag(r)}return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&e(p.prototype,g),u}(E.default)},"./src/controller/subtitle-stream-controller.ts":function(N,C,f){f.r(C),f.d(C,"SubtitleStreamController",function(){return c});var R=f("./src/events.ts"),E=f("./src/utils/logger.ts"),A=f("./src/utils/buffer-helper.ts"),D=f("./src/controller/fragment-finders.ts"),I=f("./src/utils/discontinuities.ts"),_=f("./src/controller/level-helper.ts"),l=f("./src/controller/fragment-tracker.ts"),L=f("./src/controller/base-stream-controller.ts"),m=f("./src/types/loader.ts"),h=f("./src/types/level.ts");function T(e,a){for(var t=0;t=r[b].start&&S<=r[b].end){o=r[b];break}var k=v.start+v.duration;o?o.end=k:(o={start:S,end:k},r.push(o)),this.fragmentTracker.fragBuffered(v)}}},u.onBufferFlushing=function(p,g){var v=g.startOffset,i=g.endOffset;if(v===0&&i!==Number.POSITIVE_INFINITY){var r=this.currentTrackId,o=this.levels;if(!o.length||!o[r]||!o[r].details)return;var S=i-o[r].details.targetduration;if(S<=0)return;g.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(b){for(var k=0;k=S.length||r!==o)&&b){if(this.mediaBuffer=this.mediaBufferTimeRanges,i.live||(v=b.details)!==null&&v!==void 0&&v.live){var k=this.mainDetails;if(i.deltaUpdateFailed||!k)return;var x=k.fragments[0];b.details?this.alignPlaylists(i,b.details)===0&&x&&Object(_.addSliding)(i,x.start):i.hasProgramDateTime&&k.hasProgramDateTime?Object(I.alignPDT)(i,k):x&&Object(_.addSliding)(i,x.start)}b.details=i,this.levelLastLoaded=r,this.tick(),i.live&&!this.fragCurrent&&this.media&&this.state===L.State.IDLE&&(Object(D.findFragmentByPTS)(null,i.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),b.details=void 0))}}},u._handleFragmentLoadComplete=function(p){var g=p.frag,v=p.payload,i=g.decryptdata,r=this.hls;if(!this.fragContextChanged(g)&&v&&v.byteLength>0&&i&&i.key&&i.iv&&i.method==="AES-128"){var o=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(v),i.key.buffer,i.iv.buffer).then(function(S){var b=performance.now();r.trigger(R.Events.FRAG_DECRYPTED,{frag:g,payload:S,stats:{tstart:o,tdecrypt:b}})})}},u.doTick=function(){if(this.media){if(this.state===L.State.IDLE){var p,g=this.currentTrackId,v=this.levels;if(!v.length||!v[g]||!v[g].details)return;var i=v[g].details,r=i.targetduration,o=this.config,S=this.media,b=A.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,S.currentTime-r,o.maxBufferHole),k=b.end;if(b.len>this.getMaxBufferLength()+r)return;console.assert(i,"Subtitle track details are defined on idle subtitle stream controller tick");var x,w=i.fragments,O=w.length,P=i.edge,F=this.fragPrevious;if(k-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))},a.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},a.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),L(this.media.textTracks).forEach(function(t){Object(E.clearCurrentCues)(t)}),this.subtitleTrack=-1,this.media=null)},a.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},a.onManifestParsed=function(t,s){this.tracks=s.subtitleTracks},a.onSubtitleTrackLoaded=function(t,s){var d=s.id,n=s.details,u=this.trackId,p=this.tracksInGroup[u];if(p){var g=p.details;p.details=s.details,this.log("subtitle track "+d+" loaded ["+n.startSN+"-"+n.endSN+"]"),d===this.trackId&&(this.retryCount=0,this.playlistLoaded(d,s,g))}else this.warn("Invalid subtitle track id "+d)},a.onLevelLoading=function(t,s){this.switchLevel(s.level)},a.onLevelSwitching=function(t,s){this.switchLevel(s.level)},a.switchLevel=function(t){var s=this.hls.levels[t];if(s!=null&&s.textGroupIds){var d=s.textGroupIds[s.urlId];if(this.groupId!==d){var n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,u=this.tracks.filter(function(v){return!d||v.groupId===d});this.tracksInGroup=u;var p=this.findTrackId(n==null?void 0:n.name)||this.findTrackId();this.groupId=d;var g={subtitleTracks:u};this.log("Updating subtitle tracks, "+u.length+' track(s) found in "'+d+'" group-id'),this.hls.trigger(R.Events.SUBTITLE_TRACKS_UPDATED,g),p!==-1&&this.setSubtitleTrack(p,n)}}},a.findTrackId=function(t){for(var s=this.tracksInGroup,d=0;d=n.length)){this.clearTimer();var u=n[t];if(this.log("Switching to subtitle track "+t),this.trackId=t,u){var p=u.id,g=u.groupId,v=g===void 0?"":g,i=u.name,r=u.type,o=u.url;this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:p,groupId:v,name:i,type:r,url:o});var S=this.switchParams(u.url,s==null?void 0:s.details);this.loadPlaylist(S)}else this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t},a.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,s=L(this.media.textTracks),d=0;d=0&&(r[0]=Math.min(r[0],a),r[1]=Math.max(r[1],t),v=!0,o/(t-a)>.5))return}if(v||d.push([a,t]),this.config.renderTextTracksNatively){var S=this.captionsTracks[e];this.Cues.newCue(S,a,t,s)}else{var b=this.Cues.newCue(null,a,t,s);this.hls.trigger(E.Events.CUES_PARSED,{type:"captions",cues:b,track:e})}},c.onInitPtsFound=function(e,a){var t=this,s=a.frag,d=a.id,n=a.initPTS,u=a.timescale,p=this.unparsedVttFrags;d==="main"&&(this.initPTS[s.cc]=n,this.timescale[s.cc]=u),p.length&&(this.unparsedVttFrags=[],p.forEach(function(g){t.onFragLoaded(E.Events.FRAG_LOADED,g)}))},c.getExistingTrack=function(e){var a=this.media;if(a)for(var t=0;t>>8^255&g^99,_[n]=g,l[g]=n;var v=d[n],i=d[v],r=d[i],o=257*d[g]^16843008*g;m[n]=o<<24|o>>>8,h[n]=o<<16|o>>>16,T[n]=o<<8|o>>>24,y[n]=o,o=16843009*r^65537*i^257*v^16843008*n,e[g]=o<<24|o>>>8,a[g]=o<<16|o>>>16,t[g]=o<<8|o>>>24,s[g]=o,n?(n=v^d[d[d[r^v]]],u^=d[d[u]]):n=u=1}},I.expandKey=function(_){for(var l=this.uint8ArrayToUint32Array_(_),L=!0,m=0;m>>6);var S=(60&s[d+2])>>>2;if(!(S>o.length-1))return g=(1&s[d+2])<<2,g|=(192&s[d+3])>>>6,R.logger.log("manifest codec:"+n+", ADTS type:"+u+", samplingIndex:"+S),/firefox/i.test(i)?S>=6?(u=5,v=new Array(4),p=S-3):(u=2,v=new Array(2),p=S):i.indexOf("android")!==-1?(u=2,v=new Array(2),p=S):(u=5,v=new Array(4),n&&(n.indexOf("mp4a.40.29")!==-1||n.indexOf("mp4a.40.5")!==-1)||!n&&S>=6?p=S-3:((n&&n.indexOf("mp4a.40.2")!==-1&&(S>=6&&g===1||/vivaldi/i.test(i))||!n&&g===1)&&(u=2,v=new Array(2)),p=S)),v[0]=u<<3,v[0]|=(14&S)>>1,v[1]|=(1&S)<<7,v[1]|=g<<3,u===5&&(v[1]|=(14&p)>>1,v[2]=(1&p)<<7,v[2]|=8,v[3]=0),{config:v,samplerate:o[S],channelCount:g,codec:"mp4a.40."+u,manifestCodec:r};t.trigger(A.Events.ERROR,{type:E.ErrorTypes.MEDIA_ERROR,details:E.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+S})}function I(t,s){return t[s]===255&&(246&t[s+1])==240}function _(t,s){return 1&t[s+1]?7:9}function l(t,s){return(3&t[s+3])<<11|t[s+4]<<3|(224&t[s+5])>>>5}function L(t,s){return s+5=t.length)return!1;var n=l(t,s);if(n<=d)return!1;var u=s+n;return u===t.length||m(t,u)}return!1}function y(t,s,d,n,u){if(!t.samplerate){var p=D(s,d,n,u);if(!p)return;t.config=p.config,t.samplerate=p.samplerate,t.channelCount=p.channelCount,t.codec=p.codec,t.manifestCodec=p.manifestCodec,R.logger.log("parsed codec:"+t.codec+", rate:"+p.samplerate+", channels:"+p.channelCount)}}function c(t){return 9216e4/t}function e(t,s,d,n,u){var p=_(t,s),g=l(t,s);if((g-=p)>0)return{headerLength:p,frameLength:g,stamp:d+n*u}}function a(t,s,d,n,u){var p=e(s,d,n,u,c(t.samplerate));if(p){var g,v=p.frameLength,i=p.headerLength,r=p.stamp,o=i+v,S=Math.max(0,d+o-s.length);S?(g=new Uint8Array(o-i)).set(s.subarray(d+i,s.length),0):g=s.subarray(d+i,d+o);var b={unit:g,pts:r};return S||t.samples.push(b),{sample:b,length:o,missing:S}}}},"./src/demux/base-audio-demuxer.ts":function(N,C,f){f.r(C),f.d(C,"initPTSFn",function(){return l});var R=f("./src/polyfills/number.ts"),E=f("./src/demux/id3.ts"),A=f("./src/demux/dummy-demuxed-track.ts"),D=f("./src/utils/mp4-tools.ts"),I=f("./src/utils/typed-array.ts"),_=function(){function L(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var m=L.prototype;return m.resetInitSegment=function(h,T,y){this._id3Track={type:"id3",id:0,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},m.resetTimeStamp=function(){},m.resetContiguity=function(){},m.canParse=function(h,T){return!1},m.appendFrame=function(h,T,y){},m.demux=function(h,T){this.cachedData&&(h=Object(D.appendUint8Array)(this.cachedData,h),this.cachedData=null);var y,c,e=E.getID3Data(h,0),a=e?e.length:0,t=this._audioTrack,s=this._id3Track,d=e?E.getTimeStamp(e):void 0,n=h.length;for(this.frameIndex!==0&&this.initPTS!==null||(this.initPTS=l(d,T)),e&&e.length>0&&s.samples.push({pts:this.initPTS,dts:this.initPTS,data:e}),c=this.initPTS;aI?(this.word<<=I,this.bitsAvailable-=I):(I-=this.bitsAvailable,I-=(_=I>>3)>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=I,this.bitsAvailable-=I)},D.readBits=function(I){var _=Math.min(this.bitsAvailable,I),l=this.word>>>32-_;return I>32&&R.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=_,this.bitsAvailable>0?this.word<<=_:this.bytesAvailable>0&&this.loadWord(),(_=I-_)>0&&this.bitsAvailable?l<<_|this.readBits(_):l},D.skipLZ=function(){var I;for(I=0;I>>I)return this.word<<=I,this.bitsAvailable-=I,I;return this.loadWord(),I+this.skipLZ()},D.skipUEG=function(){this.skipBits(1+this.skipLZ())},D.skipEG=function(){this.skipBits(1+this.skipLZ())},D.readUEG=function(){var I=this.skipLZ();return this.readBits(I+1)-1},D.readEG=function(){var I=this.readUEG();return 1&I?1+I>>>1:-1*(I>>>1)},D.readBoolean=function(){return this.readBits(1)===1},D.readUByte=function(){return this.readBits(8)},D.readUShort=function(){return this.readBits(16)},D.readUInt=function(){return this.readBits(32)},D.skipScalingList=function(I){for(var _=8,l=8,L=0;L0)return d.subarray(u,u+p)},I=function(d,n){var u=0;return u=(127&d[n])<<21,u|=(127&d[n+1])<<14,u|=(127&d[n+2])<<7,u|=127&d[n+3]},_=function(d,n){return E(d,n)&&I(d,n+6)+10<=d.length-n},l=function(d){for(var n=h(d),u=0;u>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:S+=String.fromCharCode(v);break;case 12:case 13:i=d[b++],S+=String.fromCharCode((31&v)<<6|63&i);break;case 14:i=d[b++],r=d[b++],S+=String.fromCharCode((15&v)<<12|(63&i)<<6|(63&r)<<0)}}return S},s={decodeTextFrame:c}},"./src/demux/mp3demuxer.ts":function(N,C,f){f.r(C);var R=f("./src/demux/base-audio-demuxer.ts"),E=f("./src/demux/id3.ts"),A=f("./src/utils/logger.ts"),D=f("./src/demux/mpegaudio.ts");function I(l,L){return(I=Object.setPrototypeOf||function(m,h){return m.__proto__=h,m})(l,L)}var _=function(l){var L,m;function h(){return l.apply(this,arguments)||this}m=l,(L=h).prototype=Object.create(m.prototype),L.prototype.constructor=L,I(L,m);var T=h.prototype;return T.resetInitSegment=function(y,c,e){l.prototype.resetInitSegment.call(this,y,c,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:0,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:y,duration:e,inputTimeScale:9e4,dropped:0}},h.probe=function(y){if(!y)return!1;for(var c=(E.getID3Data(y,0)||[]).length,e=y.length;c0},I.demux=function(_){var l=_,L=Object(E.dummyTrack)();if(this.config.progressive){this.remainderData&&(l=Object(R.appendUint8Array)(this.remainderData,_));var m=Object(R.segmentValidRange)(l);this.remainderData=m.remainder,L.samples=m.valid||new Uint8Array}else L.samples=l;return{audioTrack:Object(E.dummyTrack)(),avcTrack:L,id3Track:Object(E.dummyTrack)(),textTrack:Object(E.dummyTrack)()}},I.flush=function(){var _=Object(E.dummyTrack)();return _.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(E.dummyTrack)(),avcTrack:_,id3Track:Object(E.dummyTrack)(),textTrack:Object(E.dummyTrack)()}},I.demuxSampleAes=function(_,l,L){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},I.destroy=function(){},D}();A.minProbeByteLength=1024,C.default=A},"./src/demux/mpegaudio.ts":function(N,C,f){f.r(C),f.d(C,"appendFrame",function(){return _}),f.d(C,"parseHeader",function(){return l}),f.d(C,"isHeaderPattern",function(){return L}),f.d(C,"isHeader",function(){return m}),f.d(C,"canParse",function(){return h}),f.d(C,"probe",function(){return T});var R=null,E=[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],D=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],I=[0,1,1,4];function _(y,c,e,a,t){if(!(e+24>c.length)){var s=l(c,e);if(s&&e+s.frameLength<=c.length){var d=a+t*(9e4*s.samplesPerFrame/s.sampleRate),n={unit:c.subarray(e,e+s.frameLength),pts:d,dts:d};return y.config=[],y.channelCount=s.channelCount,y.samplerate=s.sampleRate,y.samples.push(n),{sample:n,length:s.frameLength,missing:0}}}}function l(y,c){var e=y[c+1]>>3&3,a=y[c+1]>>1&3,t=y[c+2]>>4&15,s=y[c+2]>>2&3;if(e!==1&&t!==0&&t!==15&&s!==3){var d=y[c+2]>>1&1,n=y[c+3]>>6,u=1e3*E[14*(e===3?3-a:a===3?3:4)+t-1],p=A[3*(e===3?0:e===2?1:2)+s],g=n===3?1:2,v=D[e][a],i=I[a],r=8*v*i,o=Math.floor(v*u/p+d)*i;if(R===null){var S=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);R=S?parseInt(S[1]):0}return R&&R<=87&&a===2&&u>=224e3&&n===0&&(y[c+3]=128|y[c+3]),{sampleRate:p,channelCount:g,frameLength:o,samplesPerFrame:r}}}function L(y,c){return y[c]===255&&(224&y[c+1])==224&&(6&y[c+1])!=0}function m(y,c){return c+1=_.length)return void L();if(!(_[l].unit.length<32)){var m=this.decrypter.isSync();if(this.decryptAacSample(_,l,L,m),!m)return}}},I.getAvcEncryptedData=function(_){for(var l=16*Math.floor((_.length-48)/160)+16,L=new Int8Array(l),m=0,h=32;h<=_.length-16;h+=160,m+=16)L.set(_.subarray(h,h+16),m);return L},I.getAvcDecryptedUnit=function(_,l){for(var L=new Uint8Array(l),m=0,h=32;h<=_.length-16;h+=160,m+=16)_.set(L.subarray(m,m+16),h);return _},I.decryptAvcSample=function(_,l,L,m,h,T){var y=Object(E.discardEPB)(h.data),c=this.getAvcEncryptedData(y),e=this;this.decryptBuffer(c.buffer,function(a){h.data=e.getAvcDecryptedUnit(y,a),T||e.decryptAvcSamples(_,l,L+1,m)})},I.decryptAvcSamples=function(_,l,L,m){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;l++,L=0){if(l>=_.length)return void m();for(var h=_[l].units;!(L>=h.length);L++){var T=h[L];if(!(T.data.length<=48||T.type!==1&&T.type!==5)){var y=this.decrypter.isSync();if(this.decryptAvcSample(_,l,L,m,T,y),!y)return}}}},D}();C.default=A},"./src/demux/transmuxer-interface.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return m});var R=f("./node_modules/webworkify-webpack/index.js"),E=f("./src/events.ts"),A=f("./src/demux/transmuxer.ts"),D=f("./src/utils/logger.ts"),I=f("./src/errors.ts"),_=f("./src/utils/mediasource-helper.ts"),l=f("./node_modules/eventemitter3/index.js"),L=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},m=function(){function h(y,c,e,a){var t=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=y,this.id=c,this.onTransmuxComplete=e,this.onFlush=a;var s=y.config,d=function(g,v){(v=v||{}).frag=t.frag,v.id=t.id,y.trigger(g,v)};this.observer=new l.EventEmitter,this.observer.on(E.Events.FRAG_DECRYPTED,d),this.observer.on(E.Events.ERROR,d);var n={mp4:L.isTypeSupported("video/mp4"),mpeg:L.isTypeSupported("audio/mpeg"),mp3:L.isTypeSupported('audio/mp4; codecs="mp3"')},u=navigator.vendor;if(s.enableWorker&&typeof Worker<"u"){var p;D.logger.log("demuxing in webworker");try{p=this.worker=R("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),p.addEventListener("message",this.onwmsg),p.onerror=function(g){y.trigger(E.Events.ERROR,{type:I.ErrorTypes.OTHER_ERROR,details:I.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(g.message+" ("+g.filename+":"+g.lineno+")")})},p.postMessage({cmd:"init",typeSupported:n,vendor:u,id:c,config:JSON.stringify(s)})}catch(g){D.logger.warn("Error in worker:",g),D.logger.error("Error while initializing DemuxerWorker, fallback to inline"),p&&self.URL.revokeObjectURL(p.objectURL),this.transmuxer=new A.default(this.observer,n,s,u,c),this.worker=null}}else this.transmuxer=new A.default(this.observer,n,s,u,c)}var T=h.prototype;return T.destroy=function(){var y=this.worker;if(y)y.removeEventListener("message",this.onwmsg),y.terminate(),this.worker=null;else{var c=this.transmuxer;c&&(c.destroy(),this.transmuxer=null)}var e=this.observer;e&&e.removeAllListeners(),this.observer=null},T.push=function(y,c,e,a,t,s,d,n,u,p){var g=this;u.transmuxing.start=self.performance.now();var v=this.transmuxer,i=this.worker,r=s?s.start:t.start,o=t.decryptdata,S=this.frag,b=!(S&&t.cc===S.cc),k=!(S&&u.level===S.level),x=S?u.sn-S.sn:-1,w=this.part?u.part-this.part.index:1,O=!k&&(x===1||x===0&&w===1),P=self.performance.now();(k||x||t.stats.parsing.start===0)&&(t.stats.parsing.start=P),!s||!w&&O||(s.stats.parsing.start=P);var F=new A.TransmuxState(b,O,n,k,r);if(!O||b){D.logger.log("[transmuxer-interface, "+t.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+` discontinuity: `+b+` trackSwitch: `+k+` contiguous: `+O+` accurateTimeOffset: `+n+` timeOffset: `+r);var M=new A.TransmuxConfig(e,a,c,d,p);this.configureTransmuxer(M)}if(this.frag=t,this.part=s,i)i.postMessage({cmd:"demux",data:y,decryptdata:o,chunkMeta:u,state:F},y instanceof ArrayBuffer?[y]:[]);else if(v){var B=v.push(y,o,u,F);Object(A.isPromise)(B)?B.then(function(U){g.handleTransmuxComplete(U)}):this.handleTransmuxComplete(B)}},T.flush=function(y){var c=this;y.transmuxing.start=self.performance.now();var e=this.transmuxer,a=this.worker;if(a)a.postMessage({cmd:"flush",chunkMeta:y});else if(e){var t=e.flush(y);Object(A.isPromise)(t)?t.then(function(s){c.handleFlushResult(s,y)}):this.handleFlushResult(t,y)}},T.handleFlushResult=function(y,c){var e=this;y.forEach(function(a){e.handleTransmuxComplete(a)}),this.onFlush(c)},T.onWorkerMessage=function(y){var c=y.data,e=this.hls;switch(c.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(c.data);break;case"flush":this.onFlush(c.data);break;default:c.data=c.data||{},c.data.frag=this.frag,c.data.id=this.id,e.trigger(c.event,c.data)}},T.configureTransmuxer=function(y){var c=this.worker,e=this.transmuxer;c?c.postMessage({cmd:"configure",config:y}):e&&e.configure(y)},T.handleTransmuxComplete=function(y){y.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(y)},h}()},"./src/demux/transmuxer-worker.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return I});var R=f("./src/demux/transmuxer.ts"),E=f("./src/events.ts"),A=f("./src/utils/logger.ts"),D=f("./node_modules/eventemitter3/index.js");function I(m){var h=new D.EventEmitter,T=function(y,c){m.postMessage({event:y,data:c})};h.on(E.Events.FRAG_DECRYPTED,T),h.on(E.Events.ERROR,T),m.addEventListener("message",function(y){var c=y.data;switch(c.cmd){case"init":var e=JSON.parse(c.config);m.transmuxer=new R.default(h,c.typeSupported,e,c.vendor,c.id),Object(A.enableLogs)(e.debug),T("init",null);break;case"configure":m.transmuxer.configure(c.config);break;case"demux":var a=m.transmuxer.push(c.data,c.decryptdata,c.chunkMeta,c.state);Object(R.isPromise)(a)?a.then(function(d){_(m,d)}):_(m,a);break;case"flush":var t=c.chunkMeta,s=m.transmuxer.flush(t);Object(R.isPromise)(s)?s.then(function(d){L(m,d,t)}):L(m,s,t)}})}function _(m,h){if((T=h.remuxResult).audio||T.video||T.text||T.id3||T.initSegment){var T,y=[],c=h.remuxResult,e=c.audio,a=c.video;e&&l(y,e),a&&l(y,a),m.postMessage({event:"transmuxComplete",data:h},y)}}function l(m,h){h.data1&&m.push(h.data1.buffer),h.data2&&m.push(h.data2.buffer)}function L(m,h,T){h.forEach(function(y){_(m,y)}),m.postMessage({event:"flush",data:T})}},"./src/demux/transmuxer.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return t}),f.d(C,"isPromise",function(){return d}),f.d(C,"TransmuxConfig",function(){return n}),f.d(C,"TransmuxState",function(){return u});var R,E=f("./src/events.ts"),A=f("./src/errors.ts"),D=f("./src/crypt/decrypter.ts"),I=f("./src/demux/aacdemuxer.ts"),_=f("./src/demux/mp4demuxer.ts"),l=f("./src/demux/tsdemuxer.ts"),L=f("./src/demux/mp3demuxer.ts"),m=f("./src/remux/mp4-remuxer.ts"),h=f("./src/remux/passthrough-remuxer.ts"),T=f("./src/demux/chunk-cache.ts"),y=f("./src/utils/mp4-tools.ts"),c=f("./src/utils/logger.ts");try{R=self.performance.now.bind(self.performance)}catch{c.logger.debug("Unable to use Performance API on this environment"),R=self.Date.now}var e=[{demux:l.default,remux:m.default},{demux:_.default,remux:h.default},{demux:I.default,remux:m.default},{demux:L.default,remux:m.default}],a=1024;e.forEach(function(p){var g=p.demux;a=Math.max(a,g.minProbeByteLength)});var t=function(){function p(v,i,r,o,S){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 T.default,this.observer=v,this.typeSupported=i,this.config=r,this.vendor=o,this.id=S}var g=p.prototype;return g.configure=function(v){this.transmuxConfig=v,this.decrypter&&this.decrypter.reset()},g.push=function(v,i,r,o){var S=this,b=r.transmuxing;b.executeStart=R();var k=new Uint8Array(v),x=this.cache,w=this.config,O=this.currentTransmuxState,P=this.transmuxConfig;o&&(this.currentTransmuxState=o);var F=function(Y,ee){var le=null;return Y.byteLength>0&&ee!=null&&ee.key!=null&&ee.iv!==null&&ee.method!=null&&(le=ee),le}(k,i);if(F&&F.method==="AES-128"){var M=this.getDecrypter();if(!w.enableSoftwareAES)return this.decryptionPromise=M.webCryptoDecrypt(k,F.key.buffer,F.iv.buffer).then(function(Y){var ee=S.push(Y,null,r);return S.decryptionPromise=null,ee}),this.decryptionPromise;var B=M.softwareDecrypt(k,F.key.buffer,F.iv.buffer);if(!B)return b.executeEnd=R(),s(r);k=new Uint8Array(B)}var U=o||O,j=U.contiguous,V=U.discontinuity,H=U.trackSwitch,z=U.accurateTimeOffset,W=U.timeOffset,X=P.audioCodec,ne=P.videoCodec,se=P.defaultInitPts,oe=P.duration,te=P.initSegmentData;if((V||H)&&this.resetInitSegment(te,X,ne,oe),V&&this.resetInitialTimestamp(se),j||this.resetContiguity(),this.needsProbing(k,V,H)){if(x.dataLength){var de=x.flush();k=Object(y.appendUint8Array)(de,k)}this.configureTransmuxer(k,P)}var re=this.transmux(k,F,W,z,r),ae=this.currentTransmuxState;return ae.contiguous=!0,ae.discontinuity=!1,ae.trackSwitch=!1,b.executeEnd=R(),re},g.flush=function(v){var i=this,r=v.transmuxing;r.executeStart=R();var o=this.decrypter,S=this.cache,b=this.currentTransmuxState,k=this.decryptionPromise;if(k)return k.then(function(){return i.flush(v)});var x=[],w=b.timeOffset;if(o){var O=o.flush();O&&x.push(this.push(O,null,v))}var P=S.dataLength;S.reset();var F=this.demuxer,M=this.remuxer;if(!F||!M)return P>=a&&this.observer.emit(E.Events.ERROR,E.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),r.executeEnd=R(),[s(v)];var B=F.flush(w);return d(B)?B.then(function(U){return i.flushRemux(x,U,v),x}):(this.flushRemux(x,B,v),x)},g.flushRemux=function(v,i,r){var o=i.audioTrack,S=i.avcTrack,b=i.id3Track,k=i.textTrack,x=this.currentTransmuxState,w=x.accurateTimeOffset,O=x.timeOffset;c.logger.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var P=this.remuxer.remux(o,S,b,k,O,w,!0,this.id);v.push({remuxResult:P,chunkMeta:r}),r.transmuxing.executeEnd=R()},g.resetInitialTimestamp=function(v){var i=this.demuxer,r=this.remuxer;i&&r&&(i.resetTimeStamp(v),r.resetTimeStamp(v))},g.resetContiguity=function(){var v=this.demuxer,i=this.remuxer;v&&i&&(v.resetContiguity(),i.resetNextTimestamp())},g.resetInitSegment=function(v,i,r,o){var S=this.demuxer,b=this.remuxer;S&&b&&(S.resetInitSegment(i,r,o),b.resetInitSegment(v,i,r))},g.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},g.transmux=function(v,i,r,o,S){return i&&i.method==="SAMPLE-AES"?this.transmuxSampleAes(v,i,r,o,S):this.transmuxUnencrypted(v,r,o,S)},g.transmuxUnencrypted=function(v,i,r,o){var S=this.demuxer.demux(v,i,!1,!this.config.progressive),b=S.audioTrack,k=S.avcTrack,x=S.id3Track,w=S.textTrack;return{remuxResult:this.remuxer.remux(b,k,x,w,i,r,!1,this.id),chunkMeta:o}},g.transmuxSampleAes=function(v,i,r,o,S){var b=this;return this.demuxer.demuxSampleAes(v,i,r).then(function(k){return{remuxResult:b.remuxer.remux(k.audioTrack,k.avcTrack,k.id3Track,k.textTrack,r,o,!1,b.id),chunkMeta:S}})},g.configureTransmuxer=function(v,i){for(var r,o=this.config,S=this.observer,b=this.typeSupported,k=this.vendor,x=i.audioCodec,w=i.defaultInitPts,O=i.duration,P=i.initSegmentData,F=i.videoCodec,M=0,B=e.length;M>4>1){if((X=H+5+p[H+4])===H+188)continue}else X=H+4;switch(W){case k:z&&(x&&(r=a(x))&&this.parseAVCPES(r,!1),x={data:[],size:0}),x&&(x.data.push(p.subarray(X,H+188)),x.size+=H+188-X);break;case w:z&&(P&&(r=a(P))&&(S.isAAC?this.parseAACPES(r):this.parseMPEGPES(r)),P={data:[],size:0}),P&&(P.data.push(p.subarray(X,H+188)),P.size+=H+188-X);break;case O:z&&(F&&(r=a(F))&&this.parseID3PES(r),F={data:[],size:0}),F&&(F.data.push(p.subarray(X,H+188)),F.size+=H+188-X);break;case 0:z&&(X+=p[X]+1),U=this._pmtId=c(p,X);break;case U:z&&(X+=p[X]+1);var ne=e(p,X,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,v);(k=ne.avc)>0&&(o.pid=k),(w=ne.audio)>0&&(S.pid=w,S.isAAC=ne.isAAC),(O=ne.id3)>0&&(b.pid=O),M&&!B&&(L.logger.log("reparse from beginning"),M=!1,H=V-188),B=this.pmtParsed=!0;break;case 17:case 8191:break;default:M=!0}}else this.observer.emit(_.Events.ERROR,_.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});o.pesData=x,S.pesData=P,b.pesData=F;var se={audioTrack:S,avcTrack:o,id3Track:b,textTrack:this._txtTrack};return i&&this.extractRemainingSamples(se),se},u.flush=function(){var p,g=this.remainderData;return this.remainderData=null,p=g?this.demux(g,-1,!1,!0):{audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(p),this.sampleAes?this.decrypt(p,this.sampleAes):p},u.extractRemainingSamples=function(p){var g,v=p.audioTrack,i=p.avcTrack,r=p.id3Track,o=i.pesData,S=v.pesData,b=r.pesData;o&&(g=a(o))?(this.parseAVCPES(g,!0),i.pesData=null):i.pesData=o,S&&(g=a(S))?(v.isAAC?this.parseAACPES(g):this.parseMPEGPES(g),v.pesData=null):(S!=null&&S.size&&L.logger.log("last AAC PES packet truncated,might overlap between fragments"),v.pesData=S),b&&(g=a(b))?(this.parseID3PES(g),r.pesData=null):r.pesData=b},u.demuxSampleAes=function(p,g,v){var i=this.demux(p,v,!0,!this.config.progressive),r=this.sampleAes=new I.default(this.observer,this.config,g);return this.decrypt(i,r)},u.decrypt=function(p,g){return new Promise(function(v){var i=p.audioTrack,r=p.avcTrack;i.samples&&i.isAAC?g.decryptAacSamples(i.samples,0,function(){r.samples?g.decryptAvcSamples(r.samples,0,0,function(){v(p)}):v(p)}):r.samples&&g.decryptAvcSamples(r.samples,0,0,function(){v(p)})})},u.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},u.parseAVCPES=function(p,g){var v,i=this,r=this._avcTrack,o=this.parseAVCNALu(p.data),S=this.avcSample,b=!1;p.data=null,S&&o.length&&!r.audFound&&(t(S,r),S=this.avcSample=y(!1,p.pts,p.dts,"")),o.forEach(function(k){switch(k.type){case 1:v=!0,S||(S=i.avcSample=y(!0,p.pts,p.dts,"")),S.frame=!0;var x=k.data;if(b&&x.length>4){var w=new A.default(x).readSliceType();w!==2&&w!==4&&w!==7&&w!==9||(S.key=!0)}break;case 5:v=!0,S||(S=i.avcSample=y(!0,p.pts,p.dts,"")),S.key=!0,S.frame=!0;break;case 6:v=!0;var O=new A.default(d(k.data));O.readUByte();for(var P=0,F=0,M=!1,B=0;!M&&O.bytesAvailable>1;){P=0;do P+=B=O.readUByte();while(B===255);F=0;do F+=B=O.readUByte();while(B===255);if(P===4&&O.bytesAvailable!==0){if(M=!0,O.readUByte()===181&&O.readUShort()===49&&O.readUInt()===1195456820&&O.readUByte()===3){for(var U=O.readUByte(),j=31&U,V=[U,O.readUByte()],H=0;H16){for(var z=[],W=0;W<16;W++)z.push(O.readUByte().toString(16)),W!==3&&W!==5&&W!==7&&W!==9||z.push("-");for(var X=F-16,ne=new Uint8Array(X),se=0;se=0){var O={data:p.subarray(x,k-o-1),type:w};b.push(O)}else{var P=this.getLastNalUnit();if(P&&(S&&k<=4-S&&P.state&&(P.data=P.data.subarray(0,P.data.byteLength-S)),(v=k-o-1)>0)){var F=new Uint8Array(P.data.byteLength+v);F.set(P.data,0),F.set(p.subarray(0,v),P.data.byteLength),P.data=F}}k=0&&o>=0){var M={data:p.subarray(x,i),type:w,state:o};b.push(M)}if(b.length===0){var B=this.getLastNalUnit();if(B){var U=new Uint8Array(B.data.byteLength+p.byteLength);U.set(B.data,0),U.set(p,B.data.byteLength),B.data=U}}return r.naluState=o,b},u.parseAACPES=function(p){var g,v,i,r,o,S=0,b=this._audioTrack,k=this.aacOverFlow,x=p.data;if(k){this.aacOverFlow=null;var w=k.sample.unit.byteLength,O=Math.min(k.missing,w),P=w-O;k.sample.unit.set(x.subarray(0,O),P),b.samples.push(k.sample),S=k.missing}for(g=S,v=x.length;g1;){var S=new Uint8Array(o[0].length+o[1].length);S.set(o[0]),S.set(o[1],o[0].length),o[0]=S,o.splice(1,1)}if(((u=o[0])[0]<<16)+(u[1]<<8)+u[2]===1){if((p=(u[4]<<8)+u[5])&&p>n.size-6)return null;var b=u[7];192&b&&(v=536870912*(14&u[9])+4194304*(255&u[10])+16384*(254&u[11])+128*(255&u[12])+(254&u[13])/2,64&b?v-(i=536870912*(14&u[14])+4194304*(255&u[15])+16384*(254&u[16])+128*(255&u[17])+(254&u[18])/2)>54e5&&(L.logger.warn(Math.round((v-i)/9e4)+"s delta between PTS and DTS, align them"),v=i):i=v);var k=(g=u[8])+9;if(n.size<=k)return null;n.size-=k;for(var x=new Uint8Array(n.size),w=0,O=o.length;wP){k-=P;continue}u=u.subarray(k),P-=k,k=0}x.set(u,r),r+=P}return p&&(p-=g+3),{data:x,pts:v,dts:i,len:p}}return null}function t(n,u){if(n.units.length&&n.frame){if(n.pts===void 0){var p=u.samples,g=p.length;if(!g)return void u.dropped++;var v=p[g-1];n.pts=v.pts,n.dts=v.dts}u.samples.push(n)}n.debug.length&&L.logger.log(n.pts+"/"+n.dts+":"+n.debug)}function s(n,u){var p=n.length;if(p>0){if(u.pts>=n[p-1].pts)n.push(u);else for(var g=p-1;g>=0;g--)if(u.ptsv)return r;return 0}},{key:"maxAutoLevel",get:function(){var g=this.levels,v=this.autoLevelCapping;return v===-1&&g&&g.length?g.length-1:v}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(g){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,g)}},{key:"audioTracks",get:function(){var g=this.audioTrackController;return g?g.audioTracks:[]}},{key:"audioTrack",get:function(){var g=this.audioTrackController;return g?g.audioTrack:-1},set:function(g){var v=this.audioTrackController;v&&(v.audioTrack=g)}},{key:"subtitleTracks",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTrack:-1},set:function(g){var v=this.subtitleTrackController;v&&(v.subtitleTrack=g)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var g=this.subtitleTrackController;return!!g&&g.subtitleDisplay},set:function(g){var v=this.subtitleTrackController;v&&(v.subtitleDisplay=g)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(g){this.config.lowLatencyMode=g}},{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}}])&&a(d.prototype,n),u&&a(d,u),s}();t.defaultConfig=void 0},"./src/is-supported.ts":function(N,C,f){f.r(C),f.d(C,"isSupported",function(){return A}),f.d(C,"changeTypeSupported",function(){return D});var R=f("./src/utils/mediasource-helper.ts");function E(){return self.SourceBuffer||self.WebKitSourceBuffer}function A(){var I=Object(R.getMediaSource)();if(!I)return!1;var _=E(),l=I&&typeof I.isTypeSupported=="function"&&I.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),L=!_||_.prototype&&typeof _.prototype.appendBuffer=="function"&&typeof _.prototype.remove=="function";return!!l&&!!L}function D(){var I,_=E();return typeof(_==null||(I=_.prototype)===null||I===void 0?void 0:I.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return m}),f.d(C,"LoadError",function(){return T});var R=f("./src/polyfills/number.ts"),E=f("./src/errors.ts");function A(y){var c=typeof Map=="function"?new Map:void 0;return(A=function(e){if(e===null||(a=e,Function.toString.call(a).indexOf("[native code]")===-1))return e;var a;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(c!==void 0){if(c.has(e))return c.get(e);c.set(e,t)}function t(){return D(e,arguments,l(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_(t,e)})(y)}function D(y,c,e){return(D=I()?Reflect.construct:function(a,t,s){var d=[null];d.push.apply(d,t);var n=new(Function.bind.apply(a,d));return s&&_(n,s.prototype),n}).apply(null,arguments)}function I(){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 _(y,c){return(_=Object.setPrototypeOf||function(e,a){return e.__proto__=a,e})(y,c)}function l(y){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(c){return c.__proto__||Object.getPrototypeOf(c)})(y)}var L=Math.pow(2,17),m=function(){function y(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var c=y.prototype;return c.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},c.abort=function(){this.loader&&this.loader.abort()},c.load=function(e,a){var t=this,s=e.url;if(!s)return Promise.reject(new T({type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,networkDetails:null},"Fragment does not have a "+(s?"part list":"url")));this.abort();var d=this.config,n=d.fLoader,u=d.loader;return new Promise(function(p,g){t.loader&&t.loader.destroy();var v=t.loader=e.loader=n?new n(d):new u(d),i=h(e),r={timeout:d.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:d.fragLoadingMaxRetryTimeout,highWaterMark:L};e.stats=v.stats,v.load(i,r,{onSuccess:function(o,S,b,k){t.resetLoader(e,v),p({frag:e,part:null,payload:o.data,networkDetails:k})},onError:function(o,S,b){t.resetLoader(e,v),g(new T({type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:o,networkDetails:b}))},onAbort:function(o,S,b){t.resetLoader(e,v),g(new T({type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:b}))},onTimeout:function(o,S,b){t.resetLoader(e,v),g(new T({type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:b}))},onProgress:function(o,S,b,k){a&&a({frag:e,part:null,payload:b,networkDetails:k})}})})},c.loadPart=function(e,a,t){var s=this;this.abort();var d=this.config,n=d.fLoader,u=d.loader;return new Promise(function(p,g){s.loader&&s.loader.destroy();var v=s.loader=e.loader=n?new n(d):new u(d),i=h(e,a),r={timeout:d.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:d.fragLoadingMaxRetryTimeout,highWaterMark:L};a.stats=v.stats,v.load(i,r,{onSuccess:function(o,S,b,k){s.resetLoader(e,v),s.updateStatsFromPart(e,a);var x={frag:e,part:a,payload:o.data,networkDetails:k};t(x),p(x)},onError:function(o,S,b){s.resetLoader(e,v),g(new T({type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:a,response:o,networkDetails:b}))},onAbort:function(o,S,b){e.stats.aborted=a.stats.aborted,s.resetLoader(e,v),g(new T({type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:a,networkDetails:b}))},onTimeout:function(o,S,b){s.resetLoader(e,v),g(new T({type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:a,networkDetails:b}))}})})},c.updateStatsFromPart=function(e,a){var t=e.stats,s=a.stats,d=s.total;if(t.loaded+=s.loaded,d){var n=Math.round(e.duration/a.duration),u=Math.min(Math.round(t.loaded/d),n),p=(n-u)*Math.round(t.loaded/u);t.total=t.loaded+p}else t.total=Math.max(t.loaded,t.total);var g=t.loading,v=s.loading;g.start?g.first+=v.first-v.start:(g.start=v.start,g.first=v.first),g.end=v.end},c.resetLoader=function(e,a){e.loader=null,this.loader===a&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),a.destroy()},y}();function h(y,c){c===void 0&&(c=null);var e=c||y,a={frag:y,part:c,responseType:"arraybuffer",url:e.url,rangeStart:0,rangeEnd:0},t=e.byteRangeStartOffset,s=e.byteRangeEndOffset;return Object(R.isFiniteNumber)(t)&&Object(R.isFiniteNumber)(s)&&(a.rangeStart=t,a.rangeEnd=s),a}var T=function(y){var c,e;function a(t){for(var s,d=arguments.length,n=new Array(d>1?d-1:0),u=1;u>8*(15-u)&255;return n},s.setDecryptDataFromLevelKey=function(d,n){var u=d;return(d==null?void 0:d.method)==="AES-128"&&d.uri&&!d.iv&&((u=_.LevelKey.fromURI(d.uri)).method=d.method,u.iv=this.createInitializationVector(n),u.keyFormat="identity"),u},s.setElementaryStreamInfo=function(d,n,u,p,g,v){v===void 0&&(v=!1);var i=this.elementaryStreams,r=i[d];r?(r.startPTS=Math.min(r.startPTS,n),r.endPTS=Math.max(r.endPTS,u),r.startDTS=Math.min(r.startDTS,p),r.endDTS=Math.max(r.endDTS,g)):i[d]={startPTS:n,endPTS:u,startDTS:p,endDTS:g,partial:v}},s.clearElementaryStreamInfo=function(){var d=this.elementaryStreams;d[R.AUDIO]=null,d[R.VIDEO]=null,d[R.AUDIOVIDEO]=null},T(t,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var d=this.sn;typeof d!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&I.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),d=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,d)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(A.isFiniteNumber)(this.programDateTime))return null;var d=Object(A.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*d}},{key:"encrypted",get:function(){var d;return!((d=this.decryptdata)===null||d===void 0||!d.keyFormat||!this.decryptdata.uri)}}]),t}(y),e=function(a){function t(s,d,n,u,p){var g;(g=a.call(this,n)||this).fragOffset=0,g.duration=0,g.gap=!1,g.independent=!1,g.relurl=void 0,g.fragment=void 0,g.index=void 0,g.stats=new l.LoadStats,g.duration=s.decimalFloatingPoint("DURATION"),g.gap=s.bool("GAP"),g.independent=s.bool("INDEPENDENT"),g.relurl=s.enumeratedString("URI"),g.fragment=d,g.index=u;var v=s.enumeratedString("BYTERANGE");return v&&g.setByteRange(v,p),p&&(g.fragOffset=p.fragOffset+p.duration),g}return L(t,a),T(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 s=this.elementaryStreams;return!!(s.audio||s.video||s.audiovideo)}}]),t}(y)},"./src/loader/key-loader.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return D});var R=f("./src/events.ts"),E=f("./src/errors.ts"),A=f("./src/utils/logger.ts"),D=function(){function I(l){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=l,this._registerListeners()}var _=I.prototype;return _._registerListeners=function(){this.hls.on(R.Events.KEY_LOADING,this.onKeyLoading,this)},_._unregisterListeners=function(){this.hls.off(R.Events.KEY_LOADING,this.onKeyLoading)},_.destroy=function(){for(var l in this._unregisterListeners(),this.loaders){var L=this.loaders[l];L&&L.destroy()}this.loaders={}},_.onKeyLoading=function(l,L){var m=L.frag,h=m.type,T=this.loaders[h];if(m.decryptdata){var y=m.decryptdata.uri;if(y!==this.decrypturl||this.decryptkey===null){var c=this.hls.config;if(T&&(A.logger.warn("abort previous key loader for type:"+h),T.abort()),!y)return void A.logger.warn("key uri is falsy");var e=c.loader,a=m.loader=this.loaders[h]=new e(c);this.decrypturl=y,this.decryptkey=null;var t={url:y,frag:m,responseType:"arraybuffer"},s={timeout:c.fragLoadingTimeOut,maxRetry:0,retryDelay:c.fragLoadingRetryDelay,maxRetryDelay:c.fragLoadingMaxRetryTimeout,highWaterMark:0},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};a.load(t,s,d)}else this.decryptkey&&(m.decryptdata.key=this.decryptkey,this.hls.trigger(R.Events.KEY_LOADED,{frag:m}))}else A.logger.warn("Missing decryption data on fragment in onKeyLoading")},_.loadsuccess=function(l,L,m){var h=m.frag;h.decryptdata?(this.decryptkey=h.decryptdata.key=new Uint8Array(l.data),h.loader=null,delete this.loaders[h.type],this.hls.trigger(R.Events.KEY_LOADED,{frag:h})):A.logger.error("after key load, decryptdata unset")},_.loaderror=function(l,L){var m=L.frag,h=m.loader;h&&h.abort(),delete this.loaders[m.type],this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:m,response:l})},_.loadtimeout=function(l,L){var m=L.frag,h=m.loader;h&&h.abort(),delete this.loaders[m.type],this.hls.trigger(R.Events.ERROR,{type:E.ErrorTypes.NETWORK_ERROR,details:E.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:m})},I}()},"./src/loader/level-details.ts":function(N,C,f){f.r(C),f.d(C,"LevelDetails",function(){return A});var R=f("./src/polyfills/number.ts");function E(D,I){for(var _=0;_l.endSN||L>0||L===0&&m>0,this.updated||this.advanced?this.misses=Math.floor(.6*l.misses):this.misses=l.misses+1,this.availabilityDelay=l.availabilityDelay},I=D,(_=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&Object(R.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var l=this.driftEndTime-this.driftStartTime;return l>0?1e3*(this.driftEnd-this.driftStart)/l:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var l;return(l=this.partList)!==null&&l!==void 0&&l.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var l;return(l=this.fragments)!==null&&l!==void 0&&l.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 l;return(l=this.partList)!==null&&l!==void 0&&l.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var l;return(l=this.partList)!==null&&l!==void 0&&l.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&E(I.prototype,_),D}()},"./src/loader/level-key.ts":function(N,C,f){f.r(C),f.d(C,"LevelKey",function(){return A});var R=f("./node_modules/url-toolkit/src/url-toolkit.js");function E(D,I){for(var _=0;_2){var p=u.shift()+".";return p+=parseInt(u.shift()).toString(16),p+=("000"+parseInt(u.shift()).toString(16)).substr(-4)}return n},d.resolve=function(n,u){return E.buildAbsoluteURL(u,n,{alwaysNormalize:!0})},d.parseMasterPlaylist=function(n,u){var p,g=[],v={},i=!1;for(m.lastIndex=0;(p=m.exec(n))!=null;)if(p[1]){var r=new _.AttrList(p[1]),o={attrs:r,bitrate:r.decimalInteger("AVERAGE-BANDWIDTH")||r.decimalInteger("BANDWIDTH"),name:r.NAME,url:d.resolve(p[2],u)},S=r.decimalResolution("RESOLUTION");S&&(o.width=S.width,o.height=S.height),a((r.CODECS||"").split(/[ ,]+/).filter(function(k){return k}),o),o.videoCodec&&o.videoCodec.indexOf("avc1")!==-1&&(o.videoCodec=d.convertAVC1ToAVCOTI(o.videoCodec)),g.push(o)}else if(p[3]){var b=new _.AttrList(p[3]);b["DATA-ID"]&&(i=!0,v[b["DATA-ID"]]=b)}return{levels:g,sessionData:i?v:null}},d.parseMasterPlaylistMedia=function(n,u,p,g){var v;g===void 0&&(g=[]);var i=[],r=0;for(h.lastIndex=0;(v=h.exec(n))!==null;){var o=new _.AttrList(v[1]);if(o.TYPE===p){var S={attrs:o,bitrate:0,id:r++,groupId:o["GROUP-ID"],instreamId:o["INSTREAM-ID"],name:o.NAME||o.LANGUAGE||"",type:p,default:o.bool("DEFAULT"),autoselect:o.bool("AUTOSELECT"),forced:o.bool("FORCED"),lang:o.LANGUAGE,url:o.URI?d.resolve(o.URI,u):""};if(g.length){var b=d.findGroup(g,S.groupId)||g[0];t(S,b,"audioCodec"),t(S,b,"textCodec")}i.push(S)}}return i},d.parseLevelPlaylist=function(n,u,p,g,v){var i,r,o,S=new D.LevelDetails(u),b=S.fragments,k=null,x=0,w=0,O=0,P=0,F=null,M=new A.Fragment(g,u),B=-1,U=!1;for(T.lastIndex=0,S.m3u8=n;(i=T.exec(n))!==null;){U&&(U=!1,(M=new A.Fragment(g,u)).start=O,M.sn=x,M.cc=P,M.level=p,k&&(M.initSegment=k,M.rawProgramDateTime=k.rawProgramDateTime));var j=i[1];if(j){M.duration=parseFloat(j);var V=(" "+i[2]).slice(1);M.title=V||null,M.tagList.push(V?["INF",j,V]:["INF",j])}else if(i[3])Object(R.isFiniteNumber)(M.duration)&&(M.start=O,o&&(M.levelkey=o),M.sn=x,M.level=p,M.cc=P,M.urlId=v,b.push(M),M.relurl=(" "+i[3]).slice(1),s(M,F),F=M,O+=M.duration,x++,w=0,U=!0);else if(i[4]){var H=(" "+i[4]).slice(1);F?M.setByteRange(H,F):M.setByteRange(H)}else if(i[5])M.rawProgramDateTime=(" "+i[5]).slice(1),M.tagList.push(["PROGRAM-DATE-TIME",M.rawProgramDateTime]),B===-1&&(B=b.length);else{if(!(i=i[0].match(y))){l.logger.warn("No matches on slow regex match for level playlist!");continue}for(r=1;r-1){l.logger.warn("Keyformat "+Ee+" is not supported from the manifest");continue}if(Ee!=="identity")continue;ae&&(o=I.LevelKey.fromURL(u,Y),Y&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(ae)>=0&&(o.method=ae,o.keyFormat=Ee,ye&&(o.keyID=ye),le&&(o.keyFormatVersions=le),o.iv=ee));break;case"START":var Le=new _.AttrList(W).decimalFloatingPoint("TIME-OFFSET");Object(R.isFiniteNumber)(Le)&&(S.startTimeOffset=Le);break;case"MAP":var fe=new _.AttrList(W);M.relurl=fe.URI,fe.BYTERANGE&&M.setByteRange(fe.BYTERANGE),M.level=p,M.sn="initSegment",o&&(M.levelkey=o),M.initSegment=null,k=M,U=!0;break;case"SERVER-CONTROL":var he=new _.AttrList(W);S.canBlockReload=he.bool("CAN-BLOCK-RELOAD"),S.canSkipUntil=he.optionalFloat("CAN-SKIP-UNTIL",0),S.canSkipDateRanges=S.canSkipUntil>0&&he.bool("CAN-SKIP-DATERANGES"),S.partHoldBack=he.optionalFloat("PART-HOLD-BACK",0),S.holdBack=he.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var He=new _.AttrList(W);S.partTarget=He.decimalFloatingPoint("PART-TARGET");break;case"PART":var Ae=S.partList;Ae||(Ae=S.partList=[]);var xe=w>0?Ae[Ae.length-1]:void 0,We=w++,Fe=new A.Part(new _.AttrList(W),M,u,We,xe);Ae.push(Fe),M.duration+=Fe.duration;break;case"PRELOAD-HINT":var Re=new _.AttrList(W);S.preloadHint=Re;break;case"RENDITION-REPORT":var $e=new _.AttrList(W);S.renditionReports=S.renditionReports||[],S.renditionReports.push($e);break;default:l.logger.warn("line parsed but not handled: "+i)}}}F&&!F.relurl?(b.pop(),O-=F.duration,S.partList&&(S.fragmentHint=F)):S.partList&&(s(M,F),M.cc=P,S.fragmentHint=M);var Ye=b.length,Ie=b[0],Qe=b[Ye-1];if((O+=S.skippedSegments*S.targetduration)>0&&Ye&&Qe){S.averagetargetduration=O/Ye;var qe=Qe.sn;S.endSN=qe!=="initSegment"?qe:0,Ie&&(S.startCC=Ie.cc,Ie.initSegment||S.fragments.every(function(Me){return Me.relurl&&(Oe=Me.relurl,c.test((Ne=(ke=E.parseURL(Oe))===null||ke===void 0?void 0:ke.path)!=null?Ne:""));var Oe,Ne,ke})&&(l.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(M=new A.Fragment(g,u)).relurl=Qe.relurl,M.level=p,M.sn="initSegment",Ie.initSegment=M,S.needSidxRanges=!0))}else S.endSN=0,S.startCC=0;return S.fragmentHint&&(O+=S.fragmentHint.duration),S.totalduration=O,S.endCC=P,B>0&&function(Me,Oe){for(var Ne=Me[Oe],ke=Oe;ke--;){var Be=Me[ke];if(!Be)return;Be.programDateTime=Ne.programDateTime-1e3*Be.duration,Ne=Be}}(b,B),S},d}();function a(d,n){["video","audio","text"].forEach(function(u){var p=d.filter(function(v){return Object(L.isCodecType)(v,u)});if(p.length){var g=p.filter(function(v){return v.lastIndexOf("avc1",0)===0||v.lastIndexOf("mp4a",0)===0});n[u+"Codec"]=g.length>0?g[0]:p[0],d=d.filter(function(v){return p.indexOf(v)===-1})}}),n.unknownCodecs=d}function t(d,n,u){var p=n[u];p&&(d[u]=p)}function s(d,n){d.rawProgramDateTime?d.programDateTime=Date.parse(d.rawProgramDateTime):n!=null&&n.programDateTime&&(d.programDateTime=n.endProgramDateTime),Object(R.isFiniteNumber)(d.programDateTime)||(d.programDateTime=null,d.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(N,C,f){f.r(C);var R=f("./src/polyfills/number.ts"),E=f("./src/events.ts"),A=f("./src/errors.ts"),D=f("./src/utils/logger.ts"),I=f("./src/utils/mp4-tools.ts"),_=f("./src/loader/m3u8-parser.ts"),l=f("./src/types/loader.ts"),L=f("./src/utils/attr-list.ts");function m(T,y){var c=T.url;return c!==void 0&&c.indexOf("data:")!==0||(c=y.url),c}var h=function(){function T(c){this.hls=void 0,this.loaders=Object.create(null),this.hls=c,this.registerListeners()}var y=T.prototype;return y.registerListeners=function(){var c=this.hls;c.on(E.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(E.Events.LEVEL_LOADING,this.onLevelLoading,this),c.on(E.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),c.on(E.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.unregisterListeners=function(){var c=this.hls;c.off(E.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(E.Events.LEVEL_LOADING,this.onLevelLoading,this),c.off(E.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),c.off(E.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.createInternalLoader=function(c){var e=this.hls.config,a=e.pLoader,t=e.loader,s=new(a||t)(e);return c.loader=s,this.loaders[c.type]=s,s},y.getInternalLoader=function(c){return this.loaders[c.type]},y.resetInternalLoader=function(c){this.loaders[c]&&delete this.loaders[c]},y.destroyInternalLoaders=function(){for(var c in this.loaders){var e=this.loaders[c];e&&e.destroy(),this.resetInternalLoader(c)}},y.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},y.onManifestLoading=function(c,e){var a=e.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:l.PlaylistContextType.MANIFEST,url:a,deliveryDirectives:null})},y.onLevelLoading=function(c,e){var a=e.id,t=e.level,s=e.url,d=e.deliveryDirectives;this.load({id:a,groupId:null,level:t,responseType:"text",type:l.PlaylistContextType.LEVEL,url:s,deliveryDirectives:d})},y.onAudioTrackLoading=function(c,e){var a=e.id,t=e.groupId,s=e.url,d=e.deliveryDirectives;this.load({id:a,groupId:t,level:null,responseType:"text",type:l.PlaylistContextType.AUDIO_TRACK,url:s,deliveryDirectives:d})},y.onSubtitleTrackLoading=function(c,e){var a=e.id,t=e.groupId,s=e.url,d=e.deliveryDirectives;this.load({id:a,groupId:t,level:null,responseType:"text",type:l.PlaylistContextType.SUBTITLE_TRACK,url:s,deliveryDirectives:d})},y.load=function(c){var e,a,t,s,d,n,u=this.hls.config,p=this.getInternalLoader(c);if(p){var g=p.context;if(g&&g.url===c.url)return void D.logger.trace("[playlist-loader]: playlist request ongoing");D.logger.log("[playlist-loader]: aborting previous loader for type: "+c.type),p.abort()}switch(c.type){case l.PlaylistContextType.MANIFEST:a=u.manifestLoadingMaxRetry,t=u.manifestLoadingTimeOut,s=u.manifestLoadingRetryDelay,d=u.manifestLoadingMaxRetryTimeout;break;case l.PlaylistContextType.LEVEL:case l.PlaylistContextType.AUDIO_TRACK:case l.PlaylistContextType.SUBTITLE_TRACK:a=0,t=u.levelLoadingTimeOut;break;default:a=u.levelLoadingMaxRetry,t=u.levelLoadingTimeOut,s=u.levelLoadingRetryDelay,d=u.levelLoadingMaxRetryTimeout}if(p=this.createInternalLoader(c),(e=c.deliveryDirectives)!==null&&e!==void 0&&e.part&&(c.type===l.PlaylistContextType.LEVEL&&c.level!==null?n=this.hls.levels[c.level].details:c.type===l.PlaylistContextType.AUDIO_TRACK&&c.id!==null?n=this.hls.audioTracks[c.id].details:c.type===l.PlaylistContextType.SUBTITLE_TRACK&&c.id!==null&&(n=this.hls.subtitleTracks[c.id].details),n)){var v=n.partTarget,i=n.targetduration;v&&i&&(t=Math.min(1e3*Math.max(3*v,.8*i),t))}var r={timeout:t,maxRetry:a,retryDelay:s,maxRetryDelay:d,highWaterMark:0},o={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};p.load(c,r,o)},y.loadsuccess=function(c,e,a,t){if(t===void 0&&(t=null),a.isSidxRequest)return this.handleSidxRequest(c,a),void this.handlePlaylistLoaded(c,e,a,t);this.resetInternalLoader(a.type);var s=c.data;s.indexOf("#EXTM3U")===0?(e.parsing.start=performance.now(),s.indexOf("#EXTINF:")>0||s.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(c,e,a,t):this.handleMasterPlaylist(c,e,a,t)):this.handleManifestParsingError(c,a,"no EXTM3U delimiter",t)},y.loaderror=function(c,e,a){a===void 0&&(a=null),this.handleNetworkError(e,a,!1,c)},y.loadtimeout=function(c,e,a){a===void 0&&(a=null),this.handleNetworkError(e,a,!0)},y.handleMasterPlaylist=function(c,e,a,t){var s=this.hls,d=c.data,n=m(c,a),u=_.default.parseMasterPlaylist(d,n),p=u.levels,g=u.sessionData;if(p.length){var v=p.map(function(b){return{id:b.attrs.AUDIO,audioCodec:b.audioCodec}}),i=p.map(function(b){return{id:b.attrs.SUBTITLES,textCodec:b.textCodec}}),r=_.default.parseMasterPlaylistMedia(d,n,"AUDIO",v),o=_.default.parseMasterPlaylistMedia(d,n,"SUBTITLES",i),S=_.default.parseMasterPlaylistMedia(d,n,"CLOSED-CAPTIONS");r.length&&(r.some(function(b){return!b.url})||!p[0].audioCodec||p[0].attrs.AUDIO||(D.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),r.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new L.AttrList({}),bitrate:0,url:""}))),s.trigger(E.Events.MANIFEST_LOADED,{levels:p,audioTracks:r,subtitles:o,captions:S,url:n,stats:e,networkDetails:t,sessionData:g})}else this.handleManifestParsingError(c,a,"no level found in manifest",t)},y.handleTrackOrLevelPlaylist=function(c,e,a,t){var s=this.hls,d=a.id,n=a.level,u=a.type,p=m(c,a),g=Object(R.isFiniteNumber)(d)?d:0,v=Object(R.isFiniteNumber)(n)?n:g,i=function(k){switch(k.type){case l.PlaylistContextType.AUDIO_TRACK:return l.PlaylistLevelType.AUDIO;case l.PlaylistContextType.SUBTITLE_TRACK:return l.PlaylistLevelType.SUBTITLE;default:return l.PlaylistLevelType.MAIN}}(a),r=_.default.parseLevelPlaylist(c.data,p,v,i,g);if(r.fragments.length){if(u===l.PlaylistContextType.MANIFEST){var o={attrs:new L.AttrList({}),bitrate:0,details:r,name:"",url:p};s.trigger(E.Events.MANIFEST_LOADED,{levels:[o],audioTracks:[],url:p,stats:e,networkDetails:t,sessionData:null})}if(e.parsing.end=performance.now(),r.needSidxRanges){var S,b=(S=r.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:b,isSidxRequest:!0,type:u,level:n,levelDetails:r,id:d,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null})}else a.levelDetails=r,this.handlePlaylistLoaded(c,e,a,t)}else s.trigger(E.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:p,reason:"no fragments found in level",level:typeof a.level=="number"?a.level:void 0})},y.handleSidxRequest=function(c,e){var a=Object(I.parseSegmentIndex)(new Uint8Array(c.data));if(a){var t=a.references,s=e.levelDetails;t.forEach(function(d,n){var u=d.info,p=s.fragments[n];p.byteRange.length===0&&p.setByteRange(String(1+u.end-u.start)+"@"+String(u.start)),p.initSegment&&p.initSegment.setByteRange(String(a.moovEndOffset)+"@0")})}},y.handleManifestParsingError=function(c,e,a,t){this.hls.trigger(E.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:e.type===l.PlaylistContextType.MANIFEST,url:c.url,reason:a,response:c,context:e,networkDetails:t})},y.handleNetworkError=function(c,e,a,t){a===void 0&&(a=!1),D.logger.warn("[playlist-loader]: A network "+(a?"timeout":"error")+" occurred while loading "+c.type+" level: "+c.level+" id: "+c.id+' group-id: "'+c.groupId+'"');var s=A.ErrorDetails.UNKNOWN,d=!1,n=this.getInternalLoader(c);switch(c.type){case l.PlaylistContextType.MANIFEST:s=a?A.ErrorDetails.MANIFEST_LOAD_TIMEOUT:A.ErrorDetails.MANIFEST_LOAD_ERROR,d=!0;break;case l.PlaylistContextType.LEVEL:s=a?A.ErrorDetails.LEVEL_LOAD_TIMEOUT:A.ErrorDetails.LEVEL_LOAD_ERROR,d=!1;break;case l.PlaylistContextType.AUDIO_TRACK:s=a?A.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:A.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case l.PlaylistContextType.SUBTITLE_TRACK:s=a?A.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:A.ErrorDetails.SUBTITLE_LOAD_ERROR,d=!1}n&&this.resetInternalLoader(c.type);var u={type:A.ErrorTypes.NETWORK_ERROR,details:s,fatal:d,url:c.url,loader:n,context:c,networkDetails:e};t&&(u.response=t),this.hls.trigger(E.Events.ERROR,u)},y.handlePlaylistLoaded=function(c,e,a,t){var s=a.type,d=a.level,n=a.id,u=a.groupId,p=a.loader,g=a.levelDetails,v=a.deliveryDirectives;if(g!=null&&g.targetduration){if(p)switch(g.live&&(p.getCacheAge&&(g.ageHeader=p.getCacheAge()||0),p.getCacheAge&&!isNaN(g.ageHeader)||(g.ageHeader=0)),s){case l.PlaylistContextType.MANIFEST:case l.PlaylistContextType.LEVEL:this.hls.trigger(E.Events.LEVEL_LOADED,{details:g,level:d||0,id:n||0,stats:e,networkDetails:t,deliveryDirectives:v});break;case l.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(E.Events.AUDIO_TRACK_LOADED,{details:g,id:n||0,groupId:u||"",stats:e,networkDetails:t,deliveryDirectives:v});break;case l.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(E.Events.SUBTITLE_TRACK_LOADED,{details:g,id:n||0,groupId:u||"",stats:e,networkDetails:t,deliveryDirectives:v})}}else this.handleManifestParsingError(c,a,"invalid target duration",t)},T}();C.default=h},"./src/polyfills/number.ts":function(N,C,f){f.r(C),f.d(C,"isFiniteNumber",function(){return R}),f.d(C,"MAX_SAFE_INTEGER",function(){return E});var R=Number.isFinite||function(A){return typeof A=="number"&&isFinite(A)},E=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(N,C,f){f.r(C);var R=function(){function E(){}return E.getSilentFrame=function(A,D){switch(A){case"mp4a.40.2":if(D===1)return new Uint8Array([0,200,0,128,35,128]);if(D===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(D===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(D===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(D===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(D===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(D===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(D===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(D===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])}},E}();C.default=R},"./src/remux/mp4-generator.ts":function(N,C,f){f.r(C);var R=Math.pow(2,32)-1,E=function(){function A(){}return A.init=function(){var D;for(D in 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:[]},A.types)A.types.hasOwnProperty(D)&&(A.types[D]=[D.charCodeAt(0),D.charCodeAt(1),D.charCodeAt(2),D.charCodeAt(3)]);var I=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]),_=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:I,audio:_};var l=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),L=new Uint8Array([0,0,0,0,0,0,0,0]);A.STTS=A.STSC=A.STCO=L,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 m=new Uint8Array([105,115,111,109]),h=new Uint8Array([97,118,99,49]),T=new Uint8Array([0,0,0,1]);A.FTYP=A.box(A.types.ftyp,m,T,m,h),A.DINF=A.box(A.types.dinf,A.box(A.types.dref,l))},A.box=function(D){for(var I=8,_=arguments.length,l=new Array(_>1?_-1:0),L=1;L<_;L++)l[L-1]=arguments[L];for(var m=l.length,h=m;m--;)I+=l[m].byteLength;var T=new Uint8Array(I);for(T[0]=I>>24&255,T[1]=I>>16&255,T[2]=I>>8&255,T[3]=255&I,T.set(D,4),m=0,I=8;m>24&255,D>>16&255,D>>8&255,255&D,_>>24,_>>16&255,_>>8&255,255&_,l>>24,l>>16&255,l>>8&255,255&l,85,196,0,0]))},A.mdia=function(D){return A.box(A.types.mdia,A.mdhd(D.timescale,D.duration),A.hdlr(D.type),A.minf(D))},A.mfhd=function(D){return A.box(A.types.mfhd,new Uint8Array([0,0,0,0,D>>24,D>>16&255,D>>8&255,255&D]))},A.minf=function(D){return D.type==="audio"?A.box(A.types.minf,A.box(A.types.smhd,A.SMHD),A.DINF,A.stbl(D)):A.box(A.types.minf,A.box(A.types.vmhd,A.VMHD),A.DINF,A.stbl(D))},A.moof=function(D,I,_){return A.box(A.types.moof,A.mfhd(D),A.traf(_,I))},A.moov=function(D){for(var I=D.length,_=[];I--;)_[I]=A.trak(D[I]);return A.box.apply(null,[A.types.moov,A.mvhd(D[0].timescale,D[0].duration)].concat(_).concat(A.mvex(D)))},A.mvex=function(D){for(var I=D.length,_=[];I--;)_[I]=A.trex(D[I]);return A.box.apply(null,[A.types.mvex].concat(_))},A.mvhd=function(D,I){I*=D;var _=Math.floor(I/(R+1)),l=Math.floor(I%(R+1)),L=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,D>>24&255,D>>16&255,D>>8&255,255&D,_>>24,_>>16&255,_>>8&255,255&_,l>>24,l>>16&255,l>>8&255,255&l,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,L)},A.sdtp=function(D){var I,_,l=D.samples||[],L=new Uint8Array(4+l.length);for(I=0;I>>8&255),L.push(255&l),L=L.concat(Array.prototype.slice.call(_));for(I=0;I>>8&255),m.push(255&l),m=m.concat(Array.prototype.slice.call(_));var h=A.box(A.types.avcC,new Uint8Array([1,L[3],L[4],L[5],255,224|D.sps.length].concat(L).concat([D.pps.length]).concat(m))),T=D.width,y=D.height,c=D.pixelRatio[0],e=D.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,T>>8&255,255&T,y>>8&255,255&y,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]),h,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([c>>24,c>>16&255,c>>8&255,255&c,e>>24,e>>16&255,e>>8&255,255&e])))},A.esds=function(D){var I=D.config.length;return new Uint8Array([0,0,0,0,3,23+I,0,1,0,4,15+I,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([I]).concat(D.config).concat([6,1,2]))},A.mp4a=function(D){var I=D.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,D.channelCount,0,16,0,0,0,0,I>>8&255,255&I,0,0]),A.box(A.types.esds,A.esds(D)))},A.mp3=function(D){var I=D.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,D.channelCount,0,16,0,0,0,0,I>>8&255,255&I,0,0]))},A.stsd=function(D){return D.type==="audio"?D.isAAC||D.codec!=="mp3"?A.box(A.types.stsd,A.STSD,A.mp4a(D)):A.box(A.types.stsd,A.STSD,A.mp3(D)):A.box(A.types.stsd,A.STSD,A.avc1(D))},A.tkhd=function(D){var I=D.id,_=D.duration*D.timescale,l=D.width,L=D.height,m=Math.floor(_/(R+1)),h=Math.floor(_%(R+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,I>>24&255,I>>16&255,I>>8&255,255&I,0,0,0,0,m>>24,m>>16&255,m>>8&255,255&m,h>>24,h>>16&255,h>>8&255,255&h,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,l>>8&255,255&l,0,0,L>>8&255,255&L,0,0]))},A.traf=function(D,I){var _=A.sdtp(D),l=D.id,L=Math.floor(I/(R+1)),m=Math.floor(I%(R+1));return A.box(A.types.traf,A.box(A.types.tfhd,new Uint8Array([0,0,0,0,l>>24,l>>16&255,l>>8&255,255&l])),A.box(A.types.tfdt,new Uint8Array([1,0,0,0,L>>24,L>>16&255,L>>8&255,255&L,m>>24,m>>16&255,m>>8&255,255&m])),A.trun(D,_.length+16+20+8+16+8+8),_)},A.trak=function(D){return D.duration=D.duration||4294967295,A.box(A.types.trak,A.tkhd(D),A.mdia(D))},A.trex=function(D){var I=D.id;return A.box(A.types.trex,new Uint8Array([0,0,0,0,I>>24,I>>16&255,I>>8&255,255&I,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},A.trun=function(D,I){var _,l,L,m,h,T,y=D.samples||[],c=y.length,e=12+16*c,a=new Uint8Array(e);for(I+=8+e,a.set([0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,I>>>24&255,I>>>16&255,I>>>8&255,255&I],0),_=0;_>>24&255,L>>>16&255,L>>>8&255,255&L,m>>>24&255,m>>>16&255,m>>>8&255,255&m,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,61440&h.degradPrio,15&h.degradPrio,T>>>24&255,T>>>16&255,T>>>8&255,255&T],12+16*_);return A.box(A.types.trun,a)},A.initSegment=function(D){A.types||A.init();var I=A.moov(D),_=new Uint8Array(A.FTYP.byteLength+I.byteLength);return _.set(A.FTYP),_.set(I,A.FTYP.byteLength),_},A}();E.types=void 0,E.HDLR_TYPES=void 0,E.STTS=void 0,E.STSC=void 0,E.STCO=void 0,E.STSZ=void 0,E.VMHD=void 0,E.SMHD=void 0,E.STSD=void 0,E.FTYP=void 0,E.DINF=void 0,C.default=E},"./src/remux/mp4-remuxer.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return c}),f.d(C,"normalizePts",function(){return e});var R=f("./src/polyfills/number.ts"),E=f("./src/remux/aac-helper.ts"),A=f("./src/remux/mp4-generator.ts"),D=f("./src/events.ts"),I=f("./src/errors.ts"),_=f("./src/utils/logger.ts"),l=f("./src/types/loader.ts"),L=f("./src/utils/timescale-conversion.ts");function m(){return(m=Object.assign||function(s){for(var d=1;d0?g:v.pts},n[0].pts);return u&&_.logger.debug("PTS rollover detected"),p},d.remux=function(n,u,p,g,v,i,r,o){var S,b,k,x,w,O,P=v,F=v,M=n.pid>-1,B=u.pid>-1,U=u.samples.length,j=n.samples.length>0,V=U>1;if((!M||j)&&(!B||V)||this.ISGenerated||r){this.ISGenerated||(k=this.generateIS(n,u,v));var H=this.isVideoContiguous,z=-1;if(V&&(z=function(oe){for(var te=0;te0){_.logger.warn("[mp4-remuxer]: Dropped "+z+" out of "+U+" video samples due to a missing keyframe");var W=this.getVideoStartPts(u.samples);u.samples=u.samples.slice(z),u.dropped+=z,F+=(u.samples[0].pts-W)/(u.timescale||9e4)}else z===-1&&(_.logger.warn("[mp4-remuxer]: No keyframe found out of "+U+" video samples"),O=!1);if(this.ISGenerated){if(j&&V){var X=this.getVideoStartPts(u.samples),ne=(e(n.samples[0].pts,X)-X)/u.inputTimeScale;P+=Math.max(0,ne),F+=Math.max(0,-ne)}if(j){if(n.samplerate||(_.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),k=this.generateIS(n,u,v)),b=this.remuxAudio(n,P,this.isAudioContiguous,i,B||V||o===l.PlaylistLevelType.AUDIO?F:void 0),V){var se=b?b.endPTS-b.startPTS:0;u.inputTimeScale||(_.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),k=this.generateIS(n,u,v)),S=this.remuxVideo(u,F,H,se)}}else V&&(S=this.remuxVideo(u,F,H,0));S&&(S.firstKeyFrame=z,S.independent=z!==-1)}}return this.ISGenerated&&(p.samples.length&&(w=this.remuxID3(p,v)),g.samples.length&&(x=this.remuxText(g,v))),{audio:b,video:S,initSegment:k,independent:O,text:x,id3:w}},d.generateIS=function(n,u,p){var g,v,i,r=n.samples,o=u.samples,S=this.typeSupported,b={},k=!Object(R.isFiniteNumber)(this._initPTS),x="audio/mp4";if(k&&(g=v=1/0),n.config&&r.length&&(n.timescale=n.samplerate,n.isAAC||(S.mpeg?(x="audio/mpeg",n.codec=""):S.mp3&&(n.codec="mp3")),b.audio={id:"audio",container:x,codec:n.codec,initSegment:!n.isAAC&&S.mpeg?new Uint8Array(0):A.default.initSegment([n]),metadata:{channelCount:n.channelCount}},k&&(i=n.inputTimeScale,g=v=r[0].pts-Math.round(i*p))),u.sps&&u.pps&&o.length&&(u.timescale=u.inputTimeScale,b.video={id:"main",container:"video/mp4",codec:u.codec,initSegment:A.default.initSegment([u]),metadata:{width:u.width,height:u.height}},k)){i=u.inputTimeScale;var w=this.getVideoStartPts(o),O=Math.round(i*p);v=Math.min(v,e(o[0].dts,w)-O),g=Math.min(g,w-O)}if(Object.keys(b).length)return this.ISGenerated=!0,k&&(this._initPTS=g,this._initDTS=v),{tracks:b,initPTS:g,timescale:i}},d.remuxVideo=function(n,u,p,g){var v,i,r,o=n.inputTimeScale,S=n.samples,b=[],k=S.length,x=this._initPTS,w=this.nextAvcDts,O=8,P=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY,M=0,B=!1;p&&w!==null||(w=u*o-(S[0].pts-e(S[0].dts,S[0].pts)));for(var U=0;Uj.pts&&(M=Math.max(Math.min(M,j.pts-j.dts),-18e3)),j.dts0?U-1:U].dts&&(B=!0)}B&&S.sort(function(ke,Be){var Dt=ke.dts-Be.dts,Rt=ke.pts-Be.pts;return Dt||Rt}),i=S[0].dts,r=S[S.length-1].dts;var V=Math.round((r-i)/(k-1));if(M<0){if(M<-2*V){_.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(L.toMsFromMpegTsClock)(-V,!0)+" ms");for(var H=M,z=0;zV;if(ne||X<-1){ne?_.logger.warn("AVC: "+Object(L.toMsFromMpegTsClock)(X,!0)+" ms ("+X+"dts) hole between fragments detected, filling it"):_.logger.warn("AVC: "+Object(L.toMsFromMpegTsClock)(-X,!0)+" ms ("+X+"dts) overlapping between fragments detected"),i=w;var se=S[0].pts-X;S[0].dts=i,S[0].pts=se,_.logger.log("Video: First PTS/DTS adjusted: "+Object(L.toMsFromMpegTsClock)(se,!0)+"/"+Object(L.toMsFromMpegTsClock)(i,!0)+", delta: "+Object(L.toMsFromMpegTsClock)(X,!0)+" ms")}}y&&(i=Math.max(0,i));for(var oe=0,te=0,de=0;de0?fe-1:fe].dts;if(Ye.stretchShortVideoTrack&&this.nextAudioPts!==null){var Qe=Math.floor(Ye.maxBufferHole*o),qe=(g?P+g*o:this.nextAudioPts)-he.pts;qe>Qe?((v=qe-Ie)<0&&(v=Ie),_.logger.log("[mp4-remuxer]: It is approximately "+qe/90+" ms to the next segment; using duration "+v/90+" ms for the last video frame.")):v=Ie}else v=Ie}var Me=Math.round(he.pts-he.dts);b.push(new a(he.key,v,Ae,Me))}if(b.length&&h&&h<70){var Oe=b[0].flags;Oe.dependsOn=2,Oe.isNonSync=0}console.assert(v!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=w=r+v,this.isVideoContiguous=!0;var Ne={data1:A.default.moof(n.sequenceNumber++,i,m({},n,{samples:b})),data2:ye,startPTS:P/o,endPTS:(F+v)/o,startDTS:i/o,endDTS:w/o,type:"video",hasAudio:!1,hasVideo:!0,nb:b.length,dropped:n.dropped};return n.samples=[],n.dropped=0,console.assert(ye.length,"MDAT length must not be zero"),Ne},d.remuxAudio=function(n,u,p,g,v){var i=n.inputTimeScale,r=i/(n.samplerate?n.samplerate:i),o=n.isAAC?1024:1152,S=o*r,b=this._initPTS,k=!n.isAAC&&this.typeSupported.mpeg,x=[],w=n.samples,O=k?0:8,P=this.nextAudioPts||-1,F=u*i;if(this.isAudioContiguous=p=p||w.length&&P>0&&(g&&Math.abs(F-P)<9e3||Math.abs(e(w[0].pts-b,F)-P)<20*S),w.forEach(function(Re){Re.pts=e(Re.pts-b,F)}),!p||P<0){if(!(w=w.filter(function(Re){return Re.pts>=0})).length)return;P=v===0?0:g?Math.max(0,F):w[0].pts}if(n.isAAC)for(var M=v!==void 0,B=this.config.maxAudioFramesDrift,U=0,j=P;U=B*S&&W<1e4&&M){var X=Math.round(z/S);(j=H-X*S)<0&&(X--,j+=S),U===0&&(this.nextAudioPts=P=j),_.logger.warn("[mp4-remuxer]: Injecting "+X+" audio frame @ "+(j/i).toFixed(3)+"s due to "+Math.round(1e3*z/i)+" ms gap.");for(var ne=0;ne0))return;ae+=O;try{te=new Uint8Array(ae)}catch{return void this.observer.emit(D.Events.ERROR,D.Events.ERROR,{type:I.ErrorTypes.MUX_ERROR,details:I.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ae,reason:"fail allocating audio mdat "+ae})}k||(new DataView(te.buffer).setUint32(0,ae),te.set(A.default.types.mdat,4))}te.set(Ee,O);var fe=Ee.byteLength;O+=fe,x.push(new a(!0,o,fe,0)),re=Le}var he=x.length;if(he){var He=x[x.length-1];this.nextAudioPts=P=re+r*He.duration;var Ae=k?new Uint8Array(0):A.default.moof(n.sequenceNumber++,de/r,m({},n,{samples:x}));n.samples=[];var xe=de/i,We=P/i,Fe={data1:Ae,data2:te,startPTS:xe,endPTS:We,startDTS:xe,endDTS:We,type:"audio",hasAudio:!0,hasVideo:!1,nb:he};return this.isAudioContiguous=!0,console.assert(te.length,"MDAT length must not be zero"),Fe}},d.remuxEmptyAudio=function(n,u,p,g){var v=n.inputTimeScale,i=v/(n.samplerate?n.samplerate:v),r=this.nextAudioPts,o=(r!==null?r:g.startDTS*v)+this._initDTS,S=g.endDTS*v+this._initDTS,b=1024*i,k=Math.ceil((S-o)/b),x=E.default.getSilentFrame(n.manifestCodec||n.codec,n.channelCount);if(_.logger.warn("[mp4-remuxer]: remux empty Audio"),x){for(var w=[],O=0;O4294967296;)s+=n;return s}var a=function(s,d,n,u){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=d,this.size=n,this.cts=u,this.flags=new t(s)},t=function(s){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=s?2:1,this.isNonSync=s?0:1}},"./src/remux/passthrough-remuxer.ts":function(N,C,f){f.r(C);var R=f("./src/polyfills/number.ts"),E=f("./src/utils/mp4-tools.ts"),A=f("./src/loader/fragment.ts"),D=f("./src/utils/logger.ts"),I=function(){function L(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var m=L.prototype;return m.destroy=function(){},m.resetTimeStamp=function(h){this.initPTS=h,this.lastEndDTS=null},m.resetNextTimestamp=function(){this.lastEndDTS=null},m.resetInitSegment=function(h,T,y){this.audioCodec=T,this.videoCodec=y,this.generateInitSegment(h),this.emitInitSegment=!0},m.generateInitSegment=function(h){var T=this.audioCodec,y=this.videoCodec;if(!h||!h.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var c=this.initData=Object(E.parseInitSegment)(h);T||(T=l(c.audio,A.ElementaryStreamTypes.AUDIO)),y||(y=l(c.video,A.ElementaryStreamTypes.VIDEO));var e={};c.audio&&c.video?e.audiovideo={container:"video/mp4",codec:T+","+y,initSegment:h,id:"main"}:c.audio?e.audio={container:"audio/mp4",codec:T,initSegment:h,id:"audio"}:c.video?e.video={container:"video/mp4",codec:y,initSegment:h,id:"main"}:D.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},m.remux=function(h,T,y,c,e){var a=this.initPTS,t=this.lastEndDTS,s={audio:void 0,video:void 0,text:c,id3:y,initSegment:void 0};Object(R.isFiniteNumber)(t)||(t=this.lastEndDTS=e||0);var d=T.samples;if(!d||!d.length)return s;var n={initPTS:void 0,timescale:1},u=this.initData;if(u&&u.length||(this.generateInitSegment(d),u=this.initData),!u||!u.length)return D.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),s;this.emitInitSegment&&(n.tracks=this.initTracks,this.emitInitSegment=!1),Object(R.isFiniteNumber)(a)||(this.initPTS=n.initPTS=a=_(u,d,t));var p=Object(E.getDuration)(d,u),g=t,v=p+g;Object(E.offsetStartDTS)(u,d,a),p>0?this.lastEndDTS=v:(D.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var i=!!u.audio,r=!!u.video,o="";i&&(o+="audio"),r&&(o+="video");var S={data1:d,startPTS:g,startDTS:g,endPTS:v,endDTS:v,type:o,hasAudio:i,hasVideo:r,nb:1,dropped:0};return s.audio=S.type==="audio"?S:void 0,s.video=S.type!=="audio"?S:void 0,s.text=c,s.id3=y,s.initSegment=n,s},L}(),_=function(L,m,h){return Object(E.getStartDTS)(L,m)-h};function l(L,m){var h=L==null?void 0:L.codec;return h&&h.length>4?h:h==="hvc1"?"hvc1.1.c.L120.90":h==="av01"?"av01.0.04M.08":h==="avc1"||m===A.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}C.default=I},"./src/task-loop.ts":function(N,C,f){f.r(C),f.d(C,"default",function(){return R});var R=function(){function E(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var A=E.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(D){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,D),!0)},A.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},A.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},A.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},A.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},A.doTick=function(){},E}()},"./src/types/level.ts":function(N,C,f){function R(l,L){for(var m=0;mNumber.MAX_SAFE_INTEGER?1/0:l},I.hexadecimalInteger=function(_){if(this[_]){var l=(this[_]||"0x").slice(2);l=(1&l.length?"0":"")+l;for(var L=new Uint8Array(l.length/2),m=0;mNumber.MAX_SAFE_INTEGER?1/0:l},I.decimalFloatingPoint=function(_){return parseFloat(this[_])},I.optionalFloat=function(_,l){var L=this[_];return L?parseFloat(L):l},I.enumeratedString=function(_){return this[_]},I.bool=function(_){return this[_]==="YES"},I.decimalResolution=function(_){var l=R.exec(this[_]);if(l!==null)return{width:parseInt(l[1],10),height:parseInt(l[2],10)}},D.parseAttrList=function(_){var l,L={};for(E.lastIndex=0;(l=E.exec(_))!==null;){var m=l[2];m.indexOf('"')===0&&m.lastIndexOf('"')===m.length-1&&(m=m.slice(1,-1)),L[l[1]]=m}return L},D}()},"./src/utils/binary-search.ts":function(N,C,f){f.r(C),C.default={search:function(R,E){for(var A=0,D=R.length-1,I=null,_=null;A<=D;){var l=E(_=R[I=(A+D)/2|0]);if(l>0)A=I+1;else{if(!(l<0))return _;D=I-1}}return null}}},"./src/utils/buffer-helper.ts":function(N,C,f){f.r(C),f.d(C,"BufferHelper",function(){return A});var R=f("./src/utils/logger.ts"),E={length:0,start:function(){return 0},end:function(){return 0}},A=function(){function D(){}return D.isBuffered=function(I,_){try{if(I){for(var l=D.getBuffered(I),L=0;L=l.start(L)&&_<=l.end(L))return!0}}catch{}return!1},D.bufferInfo=function(I,_,l){try{if(I){var L,m=D.getBuffered(I),h=[];for(L=0;LT&&(L[h-1].end=I[m].end):L.push(I[m])}else L.push(I[m])}else L=I;for(var y,c=0,e=_,a=_,t=0;t=s&&_=i&&A.logger.log(this.time+" ["+i+"] "+r)},v}(),e=function(v){for(var i=[],r=0;rl&&(this.logger.log(R.DEBUG,"Too large cursor position "+this.pos),this.pos=l)},i.moveCursor=function(r){var o=this.pos+r;if(r>1)for(var S=this.pos+1;S=144&&this.backSpace();var o=I(r);this.pos>=l?this.logger.log(R.ERROR,"Cannot insert "+r.toString(16)+" ("+o+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(o,this.currPenState),this.moveCursor(1))},i.clearFromPos=function(r){var o;for(o=r;o0&&(S=r?"["+o.join(" | ")+"]":o.join(` `)),S},i.getTextAndFormat=function(){return this.rows},v}(),n=function(){function v(r,o,S){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=r,this.outputFilter=o,this.mode=null,this.verbose=0,this.displayedMemory=new d(S),this.nonDisplayedMemory=new d(S),this.lastOutputScreen=new d(S),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=S}var i=v.prototype;return i.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},i.getHandler=function(){return this.outputFilter},i.setHandler=function(r){this.outputFilter=r},i.setPAC=function(r){this.writeScreen.setPAC(r)},i.setBkgData=function(r){this.writeScreen.setBkgData(r)},i.setMode=function(r){r!==this.mode&&(this.mode=r,this.logger.log(R.INFO,"MODE="+r),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=r)},i.insertChars=function(r){for(var o=0;o=46,o.italics)o.foreground="white";else{var S=Math.floor(r/2)-16;o.foreground=["white","green","blue","cyan","red","yellow","magenta"][S]}this.logger.log(R.INFO,"MIDROW: "+JSON.stringify(o)),this.writeScreen.setPen(o)},i.outputDataUpdate=function(r){r===void 0&&(r=!1);var o=this.logger.time;o!==null&&this.outputFilter&&(this.cueStartTime!==null||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,o,this.lastOutputScreen),r&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:o):this.cueStartTime=o,this.lastOutputScreen.copy(this.displayedMemory))},i.cueSplitAtTime=function(r){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,r,this.displayedMemory),this.cueStartTime=r))},v}(),u=function(){function v(r,o,S){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var b=new c;this.channels=[null,new n(r,o,b),new n(r+1,S,b)],this.cmdHistory={a:null,b:null},this.logger=b}var i=v.prototype;return i.getHandler=function(r){return this.channels[r].getHandler()},i.setHandler=function(r,o){this.channels[r].setHandler(o)},i.addData=function(r,o){var S,b,k,x=!1;this.logger.time=r;for(var w=0;w ("+e([b,k])+")"),(S=this.parseCmd(b,k))||(S=this.parseMidrow(b,k)),S||(S=this.parsePAC(b,k)),S||(S=this.parseBackgroundAttributes(b,k)),!S&&(x=this.parseChars(b,k))){var O=this.currentChannel;O&&O>0?this.channels[O].insertChars(x):this.logger.log(R.WARNING,"No channel found yet. TEXT-MODE?")}S||x||this.logger.log(R.WARNING,"Couldn't parse cleaned data "+e([b,k])+" orig: "+e([o[w],o[w+1]]))}},i.parseCmd=function(r,o){var S=this.cmdHistory;if(!((r===20||r===28||r===21||r===29)&&o>=32&&o<=47||(r===23||r===31)&&o>=33&&o<=35))return!1;if(g(r,o,S))return p(null,null,S),this.logger.log(R.DEBUG,"Repeated command ("+e([r,o])+") is dropped"),!0;var b=r===20||r===21||r===23?1:2,k=this.channels[b];return r===20||r===21||r===28||r===29?o===32?k.ccRCL():o===33?k.ccBS():o===34?k.ccAOF():o===35?k.ccAON():o===36?k.ccDER():o===37?k.ccRU(2):o===38?k.ccRU(3):o===39?k.ccRU(4):o===40?k.ccFON():o===41?k.ccRDC():o===42?k.ccTR():o===43?k.ccRTD():o===44?k.ccEDM():o===45?k.ccCR():o===46?k.ccENM():o===47&&k.ccEOC():k.ccTO(o-32),p(r,o,S),this.currentChannel=b,!0},i.parseMidrow=function(r,o){var S=0;if((r===17||r===25)&&o>=32&&o<=47){if((S=r===17?1:2)!==this.currentChannel)return this.logger.log(R.ERROR,"Mismatch channel in midrow parsing"),!1;var b=this.channels[S];return!!b&&(b.ccMIDROW(o),this.logger.log(R.DEBUG,"MIDROW ("+e([r,o])+")"),!0)}return!1},i.parsePAC=function(r,o){var S,b=this.cmdHistory;if(!((r>=17&&r<=23||r>=25&&r<=31)&&o>=64&&o<=127||(r===16||r===24)&&o>=64&&o<=95))return!1;if(g(r,o,b))return p(null,null,b),!0;var k=r<=23?1:2;S=o>=64&&o<=95?k===1?L[r]:h[r]:k===1?m[r]:T[r];var x=this.channels[k];return!!x&&(x.setPAC(this.interpretPAC(S,o)),p(r,o,b),this.currentChannel=k,!0)},i.interpretPAC=function(r,o){var S,b={color:null,italics:!1,indent:null,underline:!1,row:r};return S=o>95?o-96:o-64,b.underline=(1&S)==1,S<=13?b.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(S/2)]:S<=15?(b.italics=!0,b.color="white"):b.indent=4*Math.floor((S-16)/2),b},i.parseChars=function(r,o){var S,b,k=null,x=null;if(r>=25?(S=2,x=r-8):(S=1,x=r),x>=17&&x<=19?(b=x===17?o+80:x===18?o+112:o+144,this.logger.log(R.INFO,"Special char '"+I(b)+"' in channel "+S),k=[b]):r>=32&&r<=127&&(k=o===0?[r]:[r,o]),k){var w=e(k);this.logger.log(R.DEBUG,"Char codes = "+w.join(",")),p(r,o,this.cmdHistory)}return k},i.parseBackgroundAttributes=function(r,o){var S;if(!((r===16||r===24)&&o>=32&&o<=47||(r===23||r===31)&&o>=45&&o<=47))return!1;var b={};r===16||r===24?(S=Math.floor((o-32)/2),b.background=y[S],o%2==1&&(b.background=b.background+"_semi")):o===45?b.background="transparent":(b.foreground="black",o===47&&(b.underline=!0));var k=r<=23?1:2;return this.channels[k].setBkgData(b),p(r,o,this.cmdHistory),!0},i.reset=function(){for(var r=0;r=16?c--:c++;var n=Object(R.fixLineBreaks)(e.trim()),u=Object(E.generateCueId)(l,L,n);_&&_.cues&&_.cues.getCueById(u)||((T=new t(l,L,n)).id=u,T.line=s+1,T.align="left",T.position=10+Math.min(80,10*Math.floor(8*c/32)),a.push(T))}return _&&a.length&&(a.sort(function(p,g){return p.line==="auto"||g.line==="auto"?0:p.line>8&&g.line>8?g.line-p.line:p.line-g.line}),a.forEach(function(p){return Object(A.addCueToTrack)(_,p)})),a}};C.default=I},"./src/utils/discontinuities.ts":function(N,C,f){f.r(C),f.d(C,"findFirstFragWithCC",function(){return D}),f.d(C,"shouldAlignOnDiscontinuities",function(){return I}),f.d(C,"findDiscontinuousReferenceFrag",function(){return _}),f.d(C,"adjustSlidingStart",function(){return L}),f.d(C,"alignStream",function(){return m}),f.d(C,"alignPDT",function(){return h});var R=f("./src/polyfills/number.ts"),E=f("./src/utils/logger.ts"),A=f("./src/controller/level-helper.ts");function D(T,y){for(var c=null,e=0,a=T.length;ec.startCC||T&&T.cc=this.minWeight_},D.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},D.destroy=function(){},A}();C.default=E},"./src/utils/ewma.ts":function(N,C,f){f.r(C);var R=function(){function E(D,I,_){I===void 0&&(I=0),_===void 0&&(_=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=D,this.alpha_=D?Math.exp(Math.log(.5)/D):0,this.estimate_=I,this.totalWeight_=_}var A=E.prototype;return A.sample=function(D,I){var _=Math.pow(this.alpha_,D);this.estimate_=I*(1-_)+_*this.estimate_,this.totalWeight_+=D},A.getTotalWeight=function(){return this.totalWeight_},A.getEstimate=function(){if(this.alpha_){var D=1-Math.pow(this.alpha_,this.totalWeight_);if(D)return this.estimate_/D}return this.estimate_},E}();C.default=R},"./src/utils/fetch-loader.ts":function(N,C,f){f.r(C),f.d(C,"fetchSupported",function(){return m});var R=f("./src/polyfills/number.ts"),E=f("./src/loader/load-stats.ts"),A=f("./src/demux/chunk-cache.ts");function D(c){var e=typeof Map=="function"?new Map:void 0;return(D=function(a){if(a===null||(t=a,Function.toString.call(t).indexOf("[native code]")===-1))return a;var t;if(typeof a!="function")throw new TypeError("Super expression must either be null or a function");if(e!==void 0){if(e.has(a))return e.get(a);e.set(a,s)}function s(){return I(a,arguments,L(this).constructor)}return s.prototype=Object.create(a.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),l(s,a)})(c)}function I(c,e,a){return(I=_()?Reflect.construct:function(t,s,d){var n=[null];n.push.apply(n,s);var u=new(Function.bind.apply(t,n));return d&&l(u,d.prototype),u}).apply(null,arguments)}function _(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function l(c,e){return(l=Object.setPrototypeOf||function(a,t){return a.__proto__=t,a})(c,e)}function L(c){return(L=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(c)}function m(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var h=function(){function c(a){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=a.fetchSetup||T,this.controller=new self.AbortController,this.stats=new E.LoadStats}var e=c.prototype;return e.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},e.abortInternal=function(){var a=this.response;a&&a.ok||(this.stats.aborted=!0,this.controller.abort())},e.abort=function(){var a;this.abortInternal(),(a=this.callbacks)!==null&&a!==void 0&&a.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},e.load=function(a,t,s){var d=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var u=function(i,r){var o={method:"GET",mode:"cors",credentials:"same-origin",signal:r};return i.rangeEnd&&(o.headers=new self.Headers({Range:"bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)})),o}(a,this.controller.signal),p=s.onProgress,g=a.responseType==="arraybuffer",v=g?"byteLength":"length";this.context=a,this.config=t,this.callbacks=s,this.request=this.fetchSetup(a,u),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){d.abortInternal(),s.onTimeout(n,a,d.response)},t.timeout),self.fetch(this.request).then(function(i){if(d.response=d.loader=i,!i.ok){var r=i.status,o=i.statusText;throw new y(o||"fetch, bad network response",r,i)}return n.loading.first=Math.max(self.performance.now(),n.loading.start),n.total=parseInt(i.headers.get("Content-Length")||"0"),p&&Object(R.isFiniteNumber)(t.highWaterMark)?d.loadProgressively(i,n,a,t.highWaterMark,p):g?i.arrayBuffer():i.text()}).then(function(i){var r=d.response;self.clearTimeout(d.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first),n.loaded=n.total=i[v];var o={url:r.url,data:i};p&&!Object(R.isFiniteNumber)(t.highWaterMark)&&p(n,a,i,r),s.onSuccess(o,n,a,r)}).catch(function(i){if(self.clearTimeout(d.requestTimeout),!n.aborted){var r=i.code||0;s.onError({code:r,text:i.message},a,i.details)}})},e.getCacheAge=function(){var a=null;if(this.response){var t=this.response.headers.get("age");a=t?parseFloat(t):null}return a},e.loadProgressively=function(a,t,s,d,n){d===void 0&&(d=0);var u=new A.default,p=a.body.getReader();return function g(){return p.read().then(function(v){if(v.done)return u.dataLength&&n(t,s,u.flush(),a),Promise.resolve(new ArrayBuffer(0));var i=v.value,r=i.length;return t.loaded+=r,r=d&&n(t,s,u.flush(),a)):n(t,s,i,a),g()}).catch(function(){return Promise.reject()})}()},c}();function T(c,e){return new self.Request(c.url,e)}var y=function(c){var e,a;function t(s,d,n){var u;return(u=c.call(this,s)||this).code=void 0,u.details=void 0,u.code=d,u.details=n,u}return a=c,(e=t).prototype=Object.create(a.prototype),e.prototype.constructor=e,l(e,a),t}(D(Error));C.default=h},"./src/utils/imsc1-ttml-parser.ts":function(N,C,f){f.r(C),f.d(C,"IMSC1_CODEC",function(){return L}),f.d(C,"parseIMSC1",function(){return y});var R=f("./src/utils/mp4-tools.ts"),E=f("./src/utils/vttparser.ts"),A=f("./src/utils/vttcue.ts"),D=f("./src/demux/id3.ts"),I=f("./src/utils/timescale-conversion.ts"),_=f("./src/utils/webvtt-parser.ts");function l(){return(l=Object.assign||function(n){for(var u=1;u"):R}function I(l){if(self.console&&l===!0||typeof l=="object"){(function(L){for(var m=arguments.length,h=new Array(m>1?m-1:0),T=1;T>24,d[n+1]=u>>16&255,d[n+2]=u>>8&255,d[n+3]=255&u}function m(d,n){var u,p,g,v=[];if(!n.length)return v;"data"in d?(u=d.data,p=d.start,g=d.end):(p=0,g=(u=d).byteLength);for(var i=p;i1?i+r:g;if(I(u.subarray(i+4,i+8))===n[0])if(n.length===1)v.push({data:u,start:i+8,end:o});else{var S=m({data:u,start:i+8,end:o},n.slice(1));S.length&&D.apply(v,S)}i=o}return v}function h(d){var n=m(d,["moov"])[0],u=n?n.end:null,p=m(d,["sidx"]);if(!p||!p[0])return null;var g=[],v=p[0],i=v.data[0],r=i===0?8:16,o=l(v,r);r+=4,r+=i===0?8:16,r+=2;var S=v.end+0,b=_(v,r);r+=2;for(var k=0;k>>31==1)return console.warn("SIDX has hierarchical references (not supported)"),null;var P=l(v,x);x+=4,g.push({referenceSize:O,subsegmentDuration:P,info:{duration:P/o,start:S,end:S+O-1}}),S+=O,r=x+=4}return{earliestPresentationTime:0,timescale:o,version:i,referencesCount:b,references:g,moovEndOffset:u}}function T(d){for(var n=[],u=m(d,["moov","trak"]),p=0;pD)&&(this.startTime=D),this.endTime=I,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},A.reset=function(){this.cueRanges=[]},E}()},"./src/utils/texttrack-utils.ts":function(N,C,f){f.r(C),f.d(C,"sendAddTrackEvent",function(){return E}),f.d(C,"addCueToTrack",function(){return A}),f.d(C,"clearCurrentCues",function(){return D}),f.d(C,"removeCuesInRange",function(){return I}),f.d(C,"getCuesInRange",function(){return _});var R=f("./src/utils/logger.ts");function E(l,L){var m;try{m=new Event("addtrack")}catch{(m=document.createEvent("Event")).initEvent("addtrack",!1,!1)}m.track=l,L.dispatchEvent(m)}function A(l,L){var m=l.mode;if(m==="disabled"&&(l.mode="hidden"),l.cues&&!l.cues.getCueById(L.id))try{if(l.addCue(L),!l.cues.getCueById(L.id))throw new Error("addCue is failed for: "+L)}catch(T){R.logger.debug("[texttrack-utils]: "+T);var h=new self.TextTrackCue(L.startTime,L.endTime,L.text);h.id=L.id,l.addCue(h)}m==="disabled"&&(l.mode=m)}function D(l){var L=l.mode;if(L==="disabled"&&(l.mode="hidden"),l.cues)for(var m=l.cues.length;m--;)l.removeCue(l.cues[m]);L==="disabled"&&(l.mode=L)}function I(l,L,m){var h=l.mode;if(h==="disabled"&&(l.mode="hidden"),l.cues&&l.cues.length>0)for(var T=_(l.cues,L,m),y=0;ya[s].endTime)return-1;for(var d=0,n=s;d<=n;){var u=Math.floor((n+d)/2);if(ta[u].startTime&&d-1)for(var y=T,c=l.length;y=L&&e.endTime<=m)h.push(e);else if(e.startTime>m)return h}return h}},"./src/utils/time-ranges.ts":function(N,C,f){f.r(C),C.default={toString:function(R){for(var E="",A=R.length,D=0;D1?L-1:0),h=1;h100)throw new Error("Position must be between 0 and 100.");g=o,this.hasBeenReset=!0}})),Object.defineProperty(h,"positionAlign",I({},T,{get:function(){return v},set:function(o){var S=D(o);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");v=S,this.hasBeenReset=!0}})),Object.defineProperty(h,"size",I({},T,{get:function(){return i},set:function(o){if(o<0||o>100)throw new Error("Size must be between 0 and 100.");i=o,this.hasBeenReset=!0}})),Object.defineProperty(h,"align",I({},T,{get:function(){return r},set:function(o){var S=D(o);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");r=S,this.hasBeenReset=!0}})),h.displayState=void 0}return _.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(N,C,f){f.r(C),f.d(C,"parseTimeStamp",function(){return A}),f.d(C,"fixLineBreaks",function(){return m}),f.d(C,"VTTParser",function(){return h});var R=f("./src/utils/vttcue.ts"),E=function(){function T(){}return T.prototype.decode=function(y,c){if(!y)return"";if(typeof y!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(y))},T}();function A(T){function y(e,a,t,s){return 3600*(0|e)+60*(0|a)+(0|t)+parseFloat(s||0)}var c=T.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return c?parseFloat(c[2])>59?y(c[2],c[3],0,c[4]):y(c[1],c[2],c[3],c[4]):null}var D=function(){function T(){this.values=Object.create(null)}var y=T.prototype;return y.set=function(c,e){this.get(c)||e===""||(this.values[c]=e)},y.get=function(c,e,a){return a?this.has(c)?this.values[c]:e[a]:this.has(c)?this.values[c]:e},y.has=function(c){return c in this.values},y.alt=function(c,e,a){for(var t=0;t=0&&a<=100)return this.set(c,a),!0}return!1},T}();function I(T,y,c,e){var a=e?T.split(e):[T];for(var t in a)if(typeof a[t]=="string"){var s=a[t].split(c);s.length===2&&y(s[0],s[1])}}var _=new R.default(0,0,""),l=_.align==="middle"?"middle":"center";function L(T,y,c){var e=T;function a(){var s=A(T);if(s===null)throw new Error("Malformed timestamp: "+e);return T=T.replace(/^[^\sa-zA-Z-]+/,""),s}function t(){T=T.replace(/^\s+/,"")}if(t(),y.startTime=a(),t(),T.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+e);T=T.substr(3),t(),y.endTime=a(),t(),function(s,d){var n=new D;I(s,function(g,v){var i;switch(g){case"region":for(var r=c.length-1;r>=0;r--)if(c[r].id===v){n.set(g,c[r].region);break}break;case"vertical":n.alt(g,v,["rl","lr"]);break;case"line":i=v.split(","),n.integer(g,i[0]),n.percent(g,i[0])&&n.set("snapToLines",!1),n.alt(g,i[0],["auto"]),i.length===2&&n.alt("lineAlign",i[1],["start",l,"end"]);break;case"position":i=v.split(","),n.percent(g,i[0]),i.length===2&&n.alt("positionAlign",i[1],["start",l,"end","line-left","line-right","auto"]);break;case"size":n.percent(g,v);break;case"align":n.alt(g,v,["start",l,"end","left","right"])}},/:/,/\s/),d.region=n.get("region",null),d.vertical=n.get("vertical","");var u=n.get("line","auto");u==="auto"&&_.line===-1&&(u=-1),d.line=u,d.lineAlign=n.get("lineAlign","start"),d.snapToLines=n.get("snapToLines",!0),d.size=n.get("size",100),d.align=n.get("align",l);var p=n.get("position","auto");p==="auto"&&_.position===50&&(p=d.align==="start"||d.align==="left"?0:d.align==="end"||d.align==="right"?100:50),d.position=p}(T,y)}function m(T){return T.replace(//gi,` `)}var h=function(){function T(){this.state="INITIAL",this.buffer="",this.decoder=new E,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var y=T.prototype;return y.parse=function(c){var e=this;function a(){var u=e.buffer,p=0;for(u=m(u);p")===-1){e.cue.id=t;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{L(t,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":var n=t.indexOf("-->")!==-1;if(!t||n&&(d=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=` `),e.cue.text+=t;continue;case"BADCUE":t||(e.state="ID")}}}catch{e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},y.flush=function(){var c=this;try{if((c.cue||c.state==="HEADER")&&(c.buffer+=` `,c.parse()),c.state==="INITIAL"||c.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){c.onparsingerror&&c.onparsingerror(e)}return c.onflush&&c.onflush(),this},T}()},"./src/utils/webvtt-parser.ts":function(N,C,f){f.r(C),f.d(C,"generateCueId",function(){return m}),f.d(C,"parseWebVTT",function(){return h});var R=f("./src/polyfills/number.ts"),E=f("./src/utils/vttparser.ts"),A=f("./src/demux/id3.ts"),D=f("./src/utils/timescale-conversion.ts"),I=f("./src/remux/mp4-remuxer.ts"),_=/\r\n|\n\r|\n|\r/g,l=function(T,y,c){return c===void 0&&(c=0),T.substr(c,y.length)===y},L=function(T){for(var y=5381,c=T.length;c;)y=33*y^T.charCodeAt(--c);return(y>>>0).toString()};function m(T,y,c){return L(T.toString())+L(y.toString())+L(c)}function h(T,y,c,e,a,t,s,d){var n,u=new E.VTTParser,p=Object(A.utf8ArrayToStr)(new Uint8Array(T)).trim().replace(_,` `).split(` `),g=[],v=Object(D.toMpegTsClockFromTimescale)(y,c),i="00:00.000",r=0,o=0,S=!0,b=!1;u.oncue=function(k){var x=e[a],w=e.ccOffset,O=(r-v)/9e4;if(x!=null&&x.new&&(o!==void 0?w=e.ccOffset=x.start:function(B,U,j){var V=B[U],H=B[V.prevCC];if(!H||!H.new&&V.new)return B.ccOffset=B.presentationOffset=V.start,void(V.new=!1);for(;(z=H)!==null&&z!==void 0&&z.new;){var z;B.ccOffset+=V.start-H.start,V.new=!1,H=B[(V=H).prevCC]}B.presentationOffset=j}(e,a,O)),O&&(w=O-e.presentationOffset),b){var P=k.endTime-k.startTime,F=Object(I.normalizePts)(9e4*(k.startTime+w-o),9e4*t)/9e4;k.startTime=F,k.endTime=F+P}var M=k.text.trim();k.text=decodeURIComponent(encodeURIComponent(M)),k.id||(k.id=m(k.startTime,k.endTime,M)),k.endTime>0&&g.push(k)},u.onparsingerror=function(k){n=k},u.onflush=function(){n?d(n):s(g)},p.forEach(function(k){if(S){if(l(k,"X-TIMESTAMP-MAP=")){S=!1,b=!0,k.substr(16).split(",").forEach(function(x){l(x,"LOCAL:")?i=x.substr(6):l(x,"MPEGTS:")&&(r=parseInt(x.substr(7)))});try{o=function(x){var w=parseInt(x.substr(-3)),O=parseInt(x.substr(-6,2)),P=parseInt(x.substr(-9,2)),F=x.length>9?parseInt(x.substr(0,x.indexOf(":"))):0;if(!(Object(R.isFiniteNumber)(w)&&Object(R.isFiniteNumber)(O)&&Object(R.isFiniteNumber)(P)&&Object(R.isFiniteNumber)(F)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+x);return w+=1e3*O,(w+=6e4*P)+36e5*F}(i)/1e3}catch(x){b=!1,n=x}return}k===""&&(S=!1)}u.parse(k+` `)}),u.flush()}},"./src/utils/xhr-loader.ts":function(N,C,f){f.r(C);var R=f("./src/utils/logger.ts"),E=f("./src/loader/load-stats.ts"),A=/^age:\s*[\d.]+\s*$/m,D=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 E.LoadStats,this.retryDelay=0}var _=I.prototype;return _.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},_.abortInternal=function(){var l=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),l&&(l.onreadystatechange=null,l.onprogress=null,l.readyState!==4&&(this.stats.aborted=!0,l.abort()))},_.abort=function(){var l;this.abortInternal(),(l=this.callbacks)!==null&&l!==void 0&&l.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},_.load=function(l,L,m){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=l,this.config=L,this.callbacks=m,this.retryDelay=L.retryDelay,this.loadInternal()},_.loadInternal=function(){var l=this.config,L=this.context;if(l){var m=this.loader=new self.XMLHttpRequest,h=this.stats;h.loading.first=0,h.loaded=0;var T=this.xhrSetup;try{if(T)try{T(m,L.url)}catch{m.open("GET",L.url,!0),T(m,L.url)}m.readyState||m.open("GET",L.url,!0)}catch(y){return void this.callbacks.onError({code:m.status,text:y.message},L,m)}L.rangeEnd&&m.setRequestHeader("Range","bytes="+L.rangeStart+"-"+(L.rangeEnd-1)),m.onreadystatechange=this.readystatechange.bind(this),m.onprogress=this.loadprogress.bind(this),m.responseType=L.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),l.timeout),m.send()}},_.readystatechange=function(){var l=this.context,L=this.loader,m=this.stats;if(l&&L){var h=L.readyState,T=this.config;if(!m.aborted&&h>=2)if(self.clearTimeout(this.requestTimeout),m.loading.first===0&&(m.loading.first=Math.max(self.performance.now(),m.loading.start)),h===4){L.onreadystatechange=null,L.onprogress=null;var y=L.status;if(y>=200&&y<300){var c,e;if(m.loading.end=Math.max(self.performance.now(),m.loading.first),e=l.responseType==="arraybuffer"?(c=L.response).byteLength:(c=L.responseText).length,m.loaded=m.total=e,!this.callbacks)return;var a=this.callbacks.onProgress;if(a&&a(m,l,c,L),!this.callbacks)return;var t={url:L.responseURL,data:c};this.callbacks.onSuccess(t,m,l,L)}else m.retry>=T.maxRetry||y>=400&&y<499?(R.logger.error(y+" while loading "+l.url),this.callbacks.onError({code:y,text:L.statusText},l,L)):(R.logger.warn(y+" while loading "+l.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,T.maxRetryDelay),m.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),T.timeout)}},_.loadtimeout=function(){R.logger.warn("timeout while loading "+this.context.url);var l=this.callbacks;l&&(this.abortInternal(),l.onTimeout(this.stats,this.context,this.loader))},_.loadprogress=function(l){var L=this.stats;L.loaded=l.loaded,l.lengthComputable&&(L.total=l.total)},_.getCacheAge=function(){var l=null;if(this.loader&&A.test(this.loader.getAllResponseHeaders())){var L=this.loader.getResponseHeader("age");l=L?parseFloat(L):null}return l},I}();C.default=D}}).default);var it=vr(Lt.exports);const pr={name:"d-icon"},be=Object.assign(pr,{props:{icon:String,size:[Number,String]},setup:function(N){const C=N,f=Ce(()=>({fontSize:/^\d+$/.test(C.size)?C.size+"px":C.size}));return(R,E)=>($(),Q("i",{class:Se(["d-icon iconfont",N.icon]),style:Ue(G(f))},null,6))}});be.__scopeId="data-v-0c690e66";Ke("data-v-4cb76d59");const mr={class:"d-player-top"},yr={class:"top-title"},Er={class:"top-title"};Ve();const Tr={props:{title:{default:""}},setup(N){Date.prototype.format=function(R){let E={"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds()};for(var A in E)new RegExp("("+A+")").test(R)&&(R=R.replace(RegExp.$1,RegExp.$1.length==1?E[A]:("00"+E[A]).substr((""+E[A]).length)));return R};let C=me("00:00:00");C.value=new Date().format("hh:mm:ss");let f=null;return f=setInterval(()=>{C.value=new Date().format("hh:mm:ss")},1e3),yt(()=>{clearInterval(f)}),(R,E)=>($(),Q("div",mr,[K("p",yr,J(N.title||""),1),K("p",Er,J(G(C)),1)]))},__scopeId:"data-v-4cb76d59"};Ke("data-v-ac2469ec");const Sr={class:"d-status"},br={class:"d-flex-center"},Lr={class:"d-flex-center"},Ar=ce("5X速播放中 ");Ve();var At=we({props:["state"],setup:N=>(C,f)=>ge(($(),Q("div",Sr,[ge(K("li",br,[q(be,{size:"18",class:"d-status-icon",icon:"icon-volume-"+(N.state.volume==0?"mute":N.state.volume>.5?"up":"down")},null,8,["icon"]),ce(" "+J(~~(100*N.state.volume))+"% ",1)],512),[[ve,N.state.handleType=="volume"]]),ge(K("li",Lr,[q(be,{size:"12",icon:"icon-play"}),q(be,{size:"12",icon:"icon-play",style:{"margin-right":"5px"}}),Ar],512),[[ve,N.state.handleType=="playbackRate"||N.state.isMultiplesPlay]])],512)),[[ve,N.state.handleType||N.state.isMultiplesPlay]])});At.__scopeId="data-v-ac2469ec",Ke("data-v-385f7870");const kr=["checked","true-value","false-value"],_r=K("span",{class:"d-switch_action"},null,-1);Ve();var rt=we({props:{modelValue:{type:[Number,String,Boolean]},width:{type:String,default:"40px"},trueValue:{type:[Number,String,Boolean],default:!0},falseValue:{type:[Number,String,Boolean],default:!0},activeColor:{type:[String],default:"#409EFF"}},emits:["update:modelValue","change"],setup(N,{emit:C}){const f=N;ut(D=>({"014e5dc0":N.width,e4e32852:N.activeColor}));const R=me(null),E=Ce(()=>f.modelValue===f.trueValue),A=()=>{Et(()=>{const D=R.value.checked;C("update:modelValue",D),C("change",D)})};return(D,I)=>($(),Q("div",{class:Se(["d-switch",{"is-checked":G(E)}])},[K("input",{class:"d-switch__input",ref:R,type:"checkbox",checked:G(E),onChange:A,"true-value":N.trueValue,"false-value":N.falseValue},null,40,kr),_r],2))}});rt.__scopeId="data-v-385f7870",Ke("data-v-b2384226");const Dr={key:0},Rr=K("i",{class:"rotating iconfont icon-loading f50"},null,-1),Ir=[K("i",{class:"rotating iconfont icon-loading f50"},null,-1),K("p",null,"正在缓冲...",-1)],Cr=[K("i",{class:"iconfont icon-replay f24 mr5"},null,-1),ce("重新播放 ")],wr=[K("i",{class:"iconfont icon-replay f24 mr5"},null,-1),ce("请求错误 ")];Ve();var kt=we({props:{loadType:String,text:{type:String,default:""}},setup(N){const C=N,{proxy:f}=wt(),R=["loadstart","waiting","ended","error","stalled"],E=()=>{f.$parent.play()},A=Ce(()=>{let D="background: rgba(0, 0, 0, .1);z-index:1";return C.loadType=="loadstart"&&(D="background: rgba(0, 0, 0, 1);;z-index:3"),D});return(D,I)=>ge(($(),Q("div",{class:"d-loading",style:Ue(G(A))},[K("div",null,[N.loadType=="loadstart"?($(),Q("span",Dr,[Rr,K("p",null,J(N.text),1)])):ue("",!0),ge(K("span",null,Ir,512),[[ve,N.loadType=="waiting"]]),ge(K("span",null,[K("p",{onClick:E,class:"d-flex-x d-pointer"},Cr)],512),[[ve,N.loadType=="ended"]]),ge(K("span",null,[K("p",{onClick:E,class:"d-flex-x d-pointer"},wr)],512),[[ve,N.loadType=="error"||N.loadType=="stalled"]])])],4)),[[ve,R.includes(N.loadType)]])}});kt.__scopeId="data-v-b2384226";const Ge=function(N,C,f,R=!1){N&&C&&f&&N.addEventListener(C,f,R)},pe=function(N,C,f,R=!1){N&&C&&f&&N.removeEventListener(C,f,R)};Ke("data-v-5a794390");const xr=["onMousedown"];Ve();var Xe=we(lt(ot({},{name:"DSlider"}),{props:{modelValue:{required:!0,type:Number,default:0},disabled:{type:Boolean,default:!1},vertical:{type:Boolean,default:!1},hover:{type:Boolean,default:!0},hoverText:{type:String,default:""},preload:{type:Number,default:0},size:{type:String,default:"10px"}},emits:["update:modelValue","change","onMousemove"],setup:function(N,{emit:C}){const f=N;ut(e=>({"5242b67b":N.size}));const R=me(null),E=me(null),A=Te({dragging:!1,hoverPosition:0,hoverTipsLeft:"50%"}),D=Ce(()=>{let e=f.modelValue<0?0:f.modelValue>1?1:f.modelValue;return f.vertical?`height:${100*e}%`:`width:${100*e}%`}),I=Ce(()=>{let e=f.preload<0?0:f.preload>1?1:f.preload;return f.vertical?`height:${100*e}%`:`width:${100*e}%`}),_=Ce(()=>{let e=A.hoverPosition<0?0:A.hoverPosition>1?1:A.hoverPosition;return f.vertical?`bottom:${100*e}%`:`left:${100*e}%`}),l=e=>{e.preventDefault()},L=e=>{f.disabled||(e.preventDefault(),A.dragging=!0,h(e),Ge(window,"mousemove",y),Ge(window,"touchmove",y),Ge(window,"mouseup",c),Ge(window,"touchend",c))},m=e=>{if(!f.hover)return;let a=T(e);if(C("onMousemove",e,a),A.hoverPosition=a,f.vertical)return;let t=R.value,s=E.value.clientWidth/2,d=e.clientX-t.getBoundingClientRect().left;d{let a=T(e);C("update:modelValue",a),C("change",e,a)},T=e=>{let a=R.value,t=0;if(f.vertical){let s=a.clientHeight;t=(a.getBoundingClientRect().bottom-e.clientY)/s}else t=(e.clientX-a.getBoundingClientRect().left)/a.clientWidth;return t<0?0:t>1?1:t},y=e=>{h(e)},c=e=>{A.dragging&&(pe(window,"mousemove",y),pe(window,"touchmove",y),pe(window,"mouseup",c),pe(window,"touchend",c),pe(window,"contextmenu",c),setTimeout(()=>{A.dragging=!1},0))};return(e,a)=>($(),Q("div",{ref:R,class:Se(["d-slider",{"is-vertical":f.vertical}]),onMousedown:It(L,["stop"]),onContextmenu:l},[K("div",{class:"d-slider__runway",onMousemove:m},[ge(K("div",{class:"d-slider__cursor",style:Ue(G(_))},[ge(K("div",{class:"d-slider__tips",ref:E,style:Ue({left:G(A).hoverTipsLeft})},J(f.hoverText),5),[[ve,f.hoverText]])],4),[[ve,f.hover]]),K("div",{class:"d-slider__preload",style:Ue(G(I))},null,4),K("div",{class:"d-slider__bar",style:Ue(G(D))},null,4)],32)],42,xr))}}));Xe.__scopeId="data-v-5a794390";Ke("data-v-570fa0d1");const Or={key:0,class:"d-player-dialog"},Pr={class:"d-player-dialog-body"},Fr={class:"d-player-dialog-title"},Mr={class:"d-player-hotkey-panel"},Nr={class:"d-player-filter-panel"},Br={class:"d-player-filter-panel-item"},Ur=K("span",null,"饱和度",-1),Gr={class:"d-player-filter-panel-item"},jr=K("span",null,"亮度",-1),Kr={class:"d-player-filter-panel-item"},Vr=K("span",null,"对比度",-1),Hr={key:0,class:"d-player-contextmenu"},Wr=["dplayerKeyCode"],Yr=K("input",{class:"d-player-copyText"},null,-1);Ve();var _t=we({setup(N){const C=Te({show:!1,dialogType:"",dialogTitle:"",version:"1.3.1-beta.6",mouseX:0,mouseY:0}),f=[{label:"视频色彩调整",key:"filter"},{label:"快捷键说明",key:"hotkey"},{label:"复制视频网址",key:"copy"},{label:"版本:1.3.1-beta.6",key:"version"}],R=[{key:"Space",label:"播放/暂停"},{key:"→",label:"单次快进10s,长按5倍速播放"},{key:"←",label:"快退5s"},{key:"↑",label:"音量增加10%"},{key:"↓",label:"音量增加降低10%"},{key:"Esc",label:"退出全屏/退出网页全屏"},{key:"F",label:"全屏/退出全屏"}],E=Te({saturate:.392,brightness:.392,contrast:.392}),A=Ce(()=>({left:C.mouseX+"px",top:C.mouseY+"px"}));ze(E,L=>{let m=document.querySelector("#dPlayerVideo"),h=(2.55*L.saturate).toFixed(2),T=(2.55*L.brightness).toFixed(2),y=(2.55*L.contrast).toFixed(2);m.style.filter=`saturate(${h}) brightness(${T}) contrast(${y})`});const D=()=>{E.saturate=.392,E.brightness=.392,E.contrast=.392},I=L=>{L.key=="Escape"&&l(0)},_=L=>{L.preventDefault(),Ge(window,"keydown",I),Ge(window,"click",l);let m=document.querySelector("#refPlayerWrap"),h=m.clientWidth;m.clientHeight,C.mouseX=L.clientX-m.getBoundingClientRect().left,h-C.mouseX<130&&(C.mouseX=C.mouseX+(h-C.mouseX-130)),C.mouseY=L.clientY-m.getBoundingClientRect().top,C.show=!0},l=L=>{let m=L.path[0].tagName=="LI",h=L.path[0].attributes.dplayerKeyCode&&L.path[0].attributes.dplayerKeyCode.value,T=f.map(y=>y.key);if(m&&T.includes(h))if(C.dialogTitle=L.path[0].innerText,C.dialogType=h,h=="copy"){let y=document.querySelector(".d-player-copyText");y.value=window.location.href,y.select(),document.execCommand("copy"),C.dialogType=""}else h=="version"&&(C.dialogType="");C.show=!1,pe(window,"keydown",I),pe(window,"click",l)};return mt(()=>{let L=document.querySelector("#refPlayerWrap");pe(window,"keydown",I),pe(window,"click",l),pe(L,"contextmenu",_),Ge(L,"contextmenu",_)}),yt(()=>{let L=document.querySelector("#refPlayerWrap");pe(window,"keydown",I),pe(window,"click",l),pe(L,"contextmenu",_)}),(L,m)=>($(),Q("div",null,[q(at,{name:"d-fade-in"},{default:Z(()=>[G(C).dialogType?($(),Q("div",Or,[K("div",Pr,[K("h5",Fr,[ce(J(G(C).dialogTitle)+" ",1),K("i",{onClick:m[0]||(m[0]=h=>G(C).dialogType=!1),class:"icon icon-close"},"X")]),ge(K("ul",Mr,[($(),Q(Pe,null,je(R,h=>K("li",{class:"d-player-hotkey-panel-item",key:h.key},[K("span",null,J(h.key),1),K("span",null,J(h.label),1)])),64))],512),[[ve,G(C).dialogType=="hotkey"]]),ge(K("ul",Nr,[K("li",Br,[Ur,q(Xe,{class:"filter-panel-slider",size:"5px",modelValue:G(E).saturate,"onUpdate:modelValue":m[1]||(m[1]=h=>G(E).saturate=h)},null,8,["modelValue"]),K("span",null,J(Math.round(255*G(E).saturate)),1)]),K("li",Gr,[jr,q(Xe,{class:"filter-panel-slider",size:"5px",modelValue:G(E).brightness,"onUpdate:modelValue":m[2]||(m[2]=h=>G(E).brightness=h)},null,8,["modelValue"]),K("span",null,J(Math.round(255*G(E).brightness)),1)]),K("li",Kr,[Vr,q(Xe,{class:"filter-panel-slider",size:"5px",modelValue:G(E).contrast,"onUpdate:modelValue":m[3]||(m[3]=h=>G(E).contrast=h)},null,8,["modelValue"]),K("span",null,J(Math.round(255*G(E).contrast)),1)]),K("span",{onClick:D,title:"重置","aria-label":"重置",class:"d-player-filter-reset"},"重置")],512),[[ve,G(C).dialogType=="filter"]])])])):ue("",!0)]),_:1}),G(C).show?($(),Q("div",Hr,[K("ul",{class:"d-player-contextmenu-body",style:Ue(G(A))},[($(),Q(Pe,null,je(f,h=>K("li",{dplayerKeyCode:h.key,key:h.key},J(h.label),9,Wr)),64))],4),Yr])):ue("",!0)]))}});_t.__scopeId="data-v-570fa0d1";const nt=N=>{let C=~~(N/3600),f=~~(N%3600/60),R=~~(N%60);return C=C<10?"0"+C:C,f=f<10?"0"+f:f,R=R<10?"0"+R:R,`${C}:${f}:${R}`},Je="ontouchstart"in window,pt=["loadstart","play","pause","playing","seeking","seeked","waiting","durationchange","progress","canplay","timeupdate","ended","error","stalled"],qr={width:{type:String,default:"800px"},height:{type:String,default:"450px"},color:{type:String,default:"#409eff"},src:{required:!0,type:String,default:""},title:{type:String,default:""},type:{type:String,default:"video/mp4"},poster:{type:String,default:""},webFullScreen:{type:Boolean,default:!1},speed:{type:Boolean,default:!0},currentTime:{type:Number,default:0},playsinline:{type:Boolean,default:!1},muted:{type:Boolean,default:!1},speedRate:{type:Array,default:()=>["2.0","1.5","1.25","1.0","0.75","0.5"]},autoPlay:{type:Boolean,default:!1},loop:{type:Boolean,default:!1},mirror:{type:Boolean,default:!1},ligthOff:{type:Boolean,default:!1},volume:{type:[String,Number],default:.3},control:{type:Boolean,default:!0},controlBtns:{type:Array,default:["audioTrack","quality","speedRate","volume","setting","pip","pageFullScreen","fullScreen"]},preload:{type:String,default:"auto"}};Ke("data-v-01791e9e");const zr={class:"d-player-video",id:"dPlayerVideo"},Xr=["controls","webkit-playsinline","playsinline","volume","muted","loop","preload","src","poster"],$r={class:"d-player-lightoff"},Qr={key:1,class:"d-player-state"},Zr={class:"d-play-btn"},Jr=["onKeyup","onKeydown"],ei={class:"d-control-progress"},ti={class:"d-tool-bar"},ri={key:0,class:"d-tool-item d-tool-time audioTrack-btn"},ii=K("span",{style:{margin:"0 3px"}},"/",-1),ni={class:"total-time"},ai={class:"d-tool-bar"},si={key:0,class:"d-tool-item quality-btn"},oi={class:"d-tool-item-main"},li={class:"speed-main",style:{"text-align":"center"}},ui=["onClick"],di={key:1,class:"d-tool-item speedRate-btn"},ci={class:"d-tool-item-main"},hi={class:"speed-main"},fi=["onClick"],gi={key:2,class:"d-tool-item volume-btn"},vi={class:"d-tool-item-main volume-box",style:{width:"52px"}},pi={class:"volume-text-size"},mi={key:3,class:"d-tool-item setting-btn"},yi={class:"d-tool-item-main"},Ei={class:"speed-main"},Ti=ce(" 镜像画面 "),Si=ce(" 循环播放 "),bi=ce(" 关灯模式 "),Li=K("div",{class:"d-tool-item-main"},"画中画",-1),Ai=K("div",{class:"d-tool-item-main"},"网页全屏",-1),ki=K("div",{class:"d-tool-item-main"},"全屏",-1);Ve();var et=we(lt(ot({},{name:"vue3VideoPlay",inheritAttrs:!1}),{props:qr,emits:[...pt,"mirrorChange","loopChange","lightOffChange"],setup:function(N,{expose:C,emit:f}){const R=N;ut(w=>({"51d4439c":G(T),"77e758a6":w.width,b8a1afc0:w.height}));const E=new it({fragLoadingTimeOut:2e3}),A=me(null),D=me(null),I=me(null),_=me(null),l=Te(lt(ot({dVideo:null},R),{muted:R.muted,playBtnState:R.autoPlay?"pause":"play",loadStateType:"loadstart",fullScreen:!1,handleType:"",currentTime:"00:00:00",preloadBar:0,totalTime:"00:00:00",isVideoHovering:!0,speedActive:"1.0",playProgress:0,isMultiplesPlay:!1,longPressTimeout:null,progressCursorTime:"00:00:00",qualityLevels:[],currentLevel:0})),L=(...w)=>O=>w.reverse().reduce((P,F)=>F(P),O),m=pt.reduce((w,O)=>{var P;return w[`on${P=O,P.charAt(0).toUpperCase()+P.slice(1)}`]=F=>{l.loadStateType=O,f(O,F)},w},{});m.onCanplay=L(m.onCanplay,()=>{l.playBtnState!="play"&&l.dVideo.play(),l.autoPlay&&(l.dVideo.play(),l.playBtnState="pause")}),m.onEnded=L(m.onEnded,()=>{l.playBtnState="replay"}),m.onDurationchange=w=>{f("durationchange",w),R.currentTime!=0&&(l.dVideo.currentTime=R.currentTime),m.onTimeupdate(w)},m.onProgress=w=>{console.log("缓冲中..."),f("progress",w);let O=w.target.duration,P=w.target.buffered,F=w.target.buffered.length&&w.target.buffered.end(P-1);l.preloadBar=F/O},m.onTimeupdate=w=>{f("timeupdate",w);let O=w.duration||w.target.duration||0,P=w.currentTime||w.target.currentTime;l.playProgress=P/O,l.currentTime=nt(P),l.totalTime=nt(O)},m.onError=L(m.onError,()=>{l.playBtnState="replay"});let h=Ct();for(let w in h)m[w]=h[w];const T=(y=l.color,`${parseInt("0x"+y.slice(1,3))},${parseInt("0x"+y.slice(3,5))},${parseInt("0x"+y.slice(5,7))}`);var y;const c=vt(500,()=>{l.handleType=""}),e=w=>{w.preventDefault(),w.code=="ArrowUp"?l.volume=l.volume+.1>1?1:l.volume+.1:l.volume=l.volume-.1<0?0:l.volume-.1,l.muted=!1,l.handleType="volume",c()},a=w=>{R.speed&&(l.dVideo.currentTime=l.dVideo.currentTime<10?.1:l.dVideo.currentTime-10,m.onTimeupdate(l.dVideo),d())},t=w=>{w.preventDefault();let O=w.type;if(w.key=="ArrowRight"){if(d(),O=="keyup"){if(clearTimeout(l.longPressTimeout),!R.speed&&!l.longPressTimeout)return;l.isMultiplesPlay?(l.dVideo.playbackRate=l.speedActive,l.isMultiplesPlay=!1):(l.dVideo.currentTime=l.dVideo.currentTime+10,m.onTimeupdate(l.dVideo))}else if(O=="keydown"){if(!R.speed)return;l.isMultiplesPlay&&clearTimeout(l.longPressTimeout),l.longPressTimeout=setTimeout(()=>{l.isMultiplesPlay=!0,l.dVideo.playbackRate=5,l.handleType="playbackRate",c()},500)}}},s=()=>{Je||_.value.focus()},d=()=>{l.loadStateType="play",l.dVideo.play().catch(()=>{setTimeout(()=>{l.playBtnState="replay",l.loadStateType="error"},500)}),l.playBtnState="pause"},n=()=>{l.dVideo.pause(),l.playBtnState="play"},u=w=>{w&&w.preventDefault(),l.playBtnState=="play"||l.playBtnState=="replay"?d():l.playBtnState=="pause"&&n()},p=()=>{l.muted=!l.muted,l.volume==0&&(l.volume=.05)},g=(w,O)=>{let P=l.dVideo.duration||l.dVideo.target.duration;l.dVideo.currentTime=P*O,l.playBtnState=="play"&&(l.dVideo.play(),l.playBtnState="pause")},v=(w,O)=>{l.progressCursorTime=nt(l.dVideo.duration*O)},i=vt(2500,()=>{l.isVideoHovering=!1}),r=w=>{l.isVideoHovering=!0,i()},o=w=>{f("mirrorChange",w,l.dVideo)},S=w=>{f("loopChange",w,l.dVideo)},b=w=>{f("lightOffChange",w,l.dVideo)},k=()=>{var w;w=l.dVideo,document.pictureInPictureElement?document.exitPictureInPicture().catch(O=>{console.log(O,"Video failed to leave Picture-in-Picture mode.")}):w.requestPictureInPicture().catch(O=>{console.log(O,"Video failed to enter Picture-in-Picture mode.")})},x=()=>{l.fullScreen=(w=>{let O=document,P=O.webkitIsFullScreen||O.fullscreen;return P?(document.exitFullscreen||O.webkitExitFullScreen).call(O):(w.requestFullscreen||w.webkitRequestFullScreen).call(w),!P})(A.value)};return ze(()=>R.src,()=>{Et(()=>{l.dVideo.canPlayType(R.type)||l.dVideo.canPlayType("application/vnd.apple.mpegurl")?l.muted=R.autoPlay:it.isSupported()&&(E.detachMedia(),E.attachMedia(l.dVideo),E.on(it.Events.MEDIA_ATTACHED,()=>{E.loadSource(R.src),E.on("hlsManifestParsed",(w,O)=>{console.log(O),l.currentLevel=O.level,l.qualityLevels=O.levels||[]})}),E.on("hlsLevelSwitching",(w,O)=>{console.log(O),console.log("LEVEL_SWITCHING")}),E.on("hlsLevelSwitched",(w,O)=>{l.currentLevel=O.level,console.log("LEVEL_SWITCHED")}))})},{immediate:!0}),mt(()=>{l.dVideo=D,s()}),C({play:d,pause:n,togglePlay:u}),(w,O)=>($(),Q("div",{ref:A,id:"refPlayerWrap",class:Se(["d-player-wrap",{"web-full-screen":G(l).webFullScreen,"is-lightoff":G(l).lightOff,"d-player-wrap-hover":G(l).playBtnState=="play"||G(l).isVideoHovering}]),onMousemove:r},[K("div",zr,[K("video",Tt({ref:D,class:["d-player-video-main",{"video-mirror":G(l).mirror}],id:"dPlayerVideoMain",controls:!(!G(Je)||!G(l).speed),"webkit-playsinline":R.playsinline,playsinline:R.playsinline},G(m),{volume:G(l).volume,muted:G(l).muted,loop:G(l).loop,preload:w.preload,width:"100%",height:"100%",src:R.src,poster:R.poster}),"您的浏览器不支持Video标签。",16,Xr)]),q(at,{name:"d-fade-in"},{default:Z(()=>[ge(K("div",$r,null,512),[[ve,G(l).lightOff]])]),_:1}),G(l).fullScreen?($(),De(Tr,{key:0,title:R.title},null,8,["title"])):ue("",!0),G(Je)?ue("",!0):($(),Q("div",Qr,[q(at,{name:"d-scale-out"},{default:Z(()=>[ge(K("div",Zr,[q(be,{icon:"icon-play",size:40})],512),[[ve,G(l).playBtnState=="play"]])]),_:1}),q(At,{state:G(l)},null,8,["state"])])),G(Je)?ue("",!0):($(),Q("input",{key:2,type:"input",readonly:"readonly",ref:_,onDblclick:x,onKeyup:[Ze(x,["f"]),O[0]||(O[0]=Ze(P=>G(l).webFullScreen=!1,["esc"])),t],onClick:u,onKeydown:[Ze(u,["space"]),Ze(a,["arrow-left"]),Ze(e,["arrow-up","arrow-down"]),t],class:"d-player-input",maxlength:"0"},null,40,Jr)),q(kt,{loadType:G(l).loadStateType},null,8,["loadType"]),q(_t),!G(Je)&&G(l).control?($(),Q("div",{key:3,class:"d-player-control",ref:I},[K("div",ei,[q(Xe,{class:"d-progress-bar",onOnMousemove:v,onChange:g,disabled:!G(l).speed,hoverText:G(l).progressCursorTime,modelValue:G(l).playProgress,"onUpdate:modelValue":O[1]||(O[1]=P=>G(l).playProgress=P),preload:G(l).preloadBar},null,8,["disabled","hoverText","modelValue","preload"])]),K("div",{class:"d-control-tool",onClick:s},[K("div",ti,[K("div",{class:"d-tool-item",onClick:u},[q(be,{size:"24",icon:`icon-${G(l).playBtnState}`},null,8,["icon"])]),R.controlBtns.includes("audioTrack")?($(),Q("div",ri,[K("span",null,J(G(l).currentTime),1),ii,K("span",ni,J(G(l).totalTime),1)])):ue("",!0)]),K("div",ai,[G(l).qualityLevels.length&&R.controlBtns.includes("quality")?($(),Q("div",si,[ce(J(G(l).qualityLevels.length&&(G(l).qualityLevels[G(l).currentLevel]||{}).height)+"P ",1),K("div",oi,[K("ul",li,[($(!0),Q(Pe,null,je(G(l).qualityLevels,(P,F)=>($(),Q("li",{class:Se({"speed-active":G(l).currentLevel==F}),onClick:M=>((B,U)=>{E.currentLevel=U,l.currentLevel=U})(0,F),key:P},J(P.height)+"P",11,ui))),128))])])])):ue("",!0),R.controlBtns.includes("speedRate")?($(),Q("div",di,[ce(J(G(l).speedActive=="1.0"?"倍速":G(l).speedActive+"x")+" ",1),K("div",ci,[K("ul",hi,[($(!0),Q(Pe,null,je(G(l).speedRate,P=>($(),Q("li",{class:Se({"speed-active":G(l).speedActive==P}),onClick:F=>(M=>{l.speedActive=M,l.dVideo.playbackRate=M})(P),key:P},J(P)+"x",11,fi))),128))])])])):ue("",!0),R.controlBtns.includes("volume")?($(),Q("div",gi,[K("div",vi,[K("div",{class:Se(["volume-main",{"is-muted":G(l).muted}])},[K("span",pi,J(G(l).muted?0:~~(100*G(l).volume))+"%",1),q(Xe,{onChange:O[2]||(O[2]=P=>G(l).muted=!1),hover:!1,size:"5px",vertical:!0,modelValue:G(l).volume,"onUpdate:modelValue":O[3]||(O[3]=P=>G(l).volume=P)},null,8,["modelValue"])],2)]),K("span",{onClick:p,style:{display:"flex"}},[q(be,{size:"20",icon:"icon-volume-"+(G(l).volume==0||G(l).muted?"mute":G(l).volume>.5?"up":"down")},null,8,["icon"])])])):ue("",!0),R.controlBtns.includes("setting")?($(),Q("div",mi,[q(be,{size:"20",class:"rotateHover",icon:"icon-settings"}),K("div",yi,[K("ul",Ei,[K("li",null,[Ti,q(rt,{onChange:o,modelValue:G(l).mirror,"onUpdate:modelValue":O[4]||(O[4]=P=>G(l).mirror=P)},null,8,["modelValue"])]),K("li",null,[Si,q(rt,{onChange:S,modelValue:G(l).loop,"onUpdate:modelValue":O[5]||(O[5]=P=>G(l).loop=P)},null,8,["modelValue"])]),K("li",null,[bi,q(rt,{onChange:b,modelValue:G(l).lightOff,"onUpdate:modelValue":O[6]||(O[6]=P=>G(l).lightOff=P)},null,8,["modelValue"])])])])])):ue("",!0),R.controlBtns.includes("pip")?($(),Q("div",{key:4,class:"d-tool-item pip-btn",onClick:k},[q(be,{size:"20",icon:"icon-pip"}),Li])):ue("",!0),R.controlBtns.includes("pageFullScreen")?($(),Q("div",{key:5,class:"d-tool-item pip-btn",onClick:O[7]||(O[7]=P=>G(l).webFullScreen=!G(l).webFullScreen)},[q(be,{size:"20",icon:"icon-web-screen"}),Ai])):ue("",!0),R.controlBtns.includes("fullScreen")?($(),Q("div",{key:6,class:"d-tool-item fullScreen-btn",onClick:x},[ki,q(be,{size:"20",icon:"icon-screen"})])):ue("",!0)])])],512)):ue("",!0)],34))}}));function _i(N){N.component(et.name,et)}et.__scopeId="data-v-01791e9e",et.install=_i;const Di=we({__name:"index",setup(N){return(C,f)=>($(),De(G(et)))}});const Ri={class:"text-right mt-[15px]"},Ii=we({__name:"index",props:{width:{type:String,default:"350px"},value:{type:String,default:""},placeholder:{type:String,default:""},required:{type:Boolean,default:!0},maxlength:{type:Number,default:10}},emits:["confirm"],setup(N,{emit:C}){const f=N,R=me(f.value),E=me(!1);ze(E,()=>{E.value||(R.value="")});const A=()=>{if(!/[\S]+/.test(R.value)){st.error(f.placeholder||"不能为空");return}C("confirm",R.value),E.value=!1};return(D,I)=>{const _=St,l=bt,L=Ut;return $(),De(L,{placement:"top",trigger:"click",width:f.width,visible:E.value,"onUpdate:visible":I[2]||(I[2]=m=>E.value=m)},{reference:Z(()=>[xt(D.$slots,"default")]),default:Z(()=>[q(_,{modelValue:R.value,"onUpdate:modelValue":I[0]||(I[0]=m=>R.value=m),placeholder:f.placeholder,clearable:"",class:"mr-[10px]",maxlength:f.maxlength,"show-word-limit":!0},null,8,["modelValue","placeholder","maxlength"]),K("div",Ri,[q(l,{onClick:I[1]||(I[1]=m=>E.value=!1)},{default:Z(()=>[ce(J(G(ie)("cancel")),1)]),_:1}),q(l,{type:"primary",onClick:A},{default:Z(()=>[ce(J(G(ie)("confirm")),1)]),_:1})])]),_:3},8,["width","visible"])}}}),Ci={class:"group-wrap w-[180px] p-[15px] h-full border-r border-color flex flex-col"},wi={class:"group-list flex-1 my-[10px]"},xi=["onClick"],Oi={key:0,class:"leading-none operate py-[10px]"},Pi={class:"text-primary"},Fi=["onClick"],Mi={class:"attachment-list-wrap flex flex-col p-[15px] flex-1"},Ni={class:"flex-1 my-[15px] h-0"},Bi={key:0,class:"flex flex-wrap"},Ui=["onClick"],Gi=["src"],ji={class:"absolute z-[1] flex items-center justify-center w-full h-full inset-0 bg-black bg-opacity-60"},Ki={class:"flex items-center"},Vi={class:"truncate my-[10px] cursor-pointer text-base flex-1"},Hi={class:"text-center w-full"},Wi={class:"text-center w-full"},Yi={class:"text-center w-full"},qi={class:"text-center w-full"},zi={key:1,class:"flex items-center justify-center"},Xi={class:"flex items-center"},$i={class:"flex h-full justify-end items-center"},Qi={class:"dialog-footer"},Zi=we({__name:"attachment",props:{limit:{type:Number,default:1},type:{type:String,default:"image"},scene:{type:String,default:"select"}},setup(N,{expose:C}){const f=N,R=Te({}),E=Te({data:[]}),A=Te({loading:!1,page:1,total:0,limit:f.scene=="select"?10:20,data:[]}),D=Te({name:""}),I=Te({real_name:"",cate_id:0}),_=dt(()=>{Wt({type:f.type,...D}).then(r=>{E.data=r.data}).catch(()=>{})});_();const l=dt((r=1)=>{A.loading=!0,A.page=r,Yt({page:A.page,limit:A.limit,att_type:f.type,...I}).then(o=>{A.data=o.data.data,A.total=o.data.total,A.loading=!1,f.scene=="attachment"&&e()}).catch(()=>{A.loading=!1})});l(),ze(()=>I.cate_id,()=>{l()});const L=r=>{Gt({type:f.type,name:r}).then(o=>{_(1)}).catch(()=>{})},m=(r,o)=>{jt({id:E.data[o].id,name:r}).then(S=>{E.data[o].name=r}).catch(()=>{})},h=r=>{ct.confirm(ie("upload.deleteCategoryTips"),ie("warning"),{confirmButtonText:ie("confirm"),cancelButtonText:ie("cancel"),type:"warning"}).then(()=>{Kt(E.data[r].id).then(()=>{E.data.splice(r,1)}).catch(()=>{})})},T=me(null),y=Ce(()=>{const r={};return r.token=qt(),r["site-id"]=zt.get("siteId")||0,{action:`/adminapi//sys/${f.type}`,multiple:!0,data:{cate_id:I.cate_id},headers:r,onSuccess:(o,S,b)=>{var k;o.code==200?(l(),(k=T.value)==null||k.handleRemove(S)):(S.status="fail",st({message:o.msg,type:"error"}))}}}),c=me(!1);ze(c,()=>{if(c.value){const r=Object.keys(_e(R));A.data.forEach(o=>{r.includes(o.att_id)||(R[o.att_id]=_e(o))})}else e()});const e=()=>{const r=Object.keys(_e(R));r.length&&(r.forEach(o=>{delete R[o]}),c.value=!1)},a=r=>{if(R[r.att_id])delete R[r.att_id];else if(f.scene=="select"){const o=Object.keys(_e(R)),S=o.length;if(f.limit==1&&S==f.limit)delete R[o[0]];else if(S>=f.limit){st.info(ie("upload.triggerUpperLimit"));return}R[r.att_id]=_e(r)}else R[r.att_id]=_e(r)},t=(r=null)=>{const o=r===null?Object.keys(_e(R)):[A.data[r].att_id];ct.confirm(ie("upload.deleteAttachmentTips"),ie("warning"),{confirmButtonText:ie("confirm"),cancelButtonText:ie("cancel"),type:"warning"}).then(()=>{Vt({att_ids:o}).then(()=>{l()}).catch(()=>{})})},s=Te({cateId:"",loading:!1,visible:!1}),d=(r=null)=>{const o=r===null?Object.keys(_e(R)):[A.data[r].att_id];s.visible=!0,s.cateId=E.data[0].id,s.confirm=()=>{s.loading=!0,Ht({cate_id:s.cateId,att_ids:o}).then(()=>{s.visible=!1,s.loading=!1,l()}).catch(()=>{s.loading=!1})}},n=me(!0);ze(R,()=>{n.value=Object.keys(_e(R)).length==0});const u=Te({show:!1,index:0}),p=r=>{u.show=!0,u.index=r},g=Ce(()=>_e(A.data).map(r=>tt(r.url))),v=Te({visible:!1,src:""}),i=r=>{v.visible=!0,v.src=tt(A.data[r].url)};return C({selectedFile:R}),(r,o)=>{const S=St,b=Ii,k=Xt,x=bt,w=$t,O=Ot,P=Pt,F=Qt,M=Ft,B=Jt,U=Mt,j=Nt,V=Bt,H=er,z=tr,W=rr,X=ir,ne=nr,se=ar,oe=sr,te=or,de=Zt,re=Di,ae=lr;return $(),Q("div",{class:Se(["flex border-t border-b main-wrap border-color w-full",N.scene=="select"?"h-[40vh]":"h-full"])},[K("div",Ci,[q(S,{modelValue:D.name,"onUpdate:modelValue":o[0]||(o[0]=Y=>D.name=Y),class:"m-0",placeholder:G(ie)("upload.attachmentCategoryPlaceholder"),"prefix-icon":"Search",onInput:o[1]||(o[1]=Y=>G(_)())},null,8,["modelValue","placeholder"]),K("div",wi,[q(k,null,{default:Z(()=>[K("div",{class:Se(["group-item p-[10px] leading-none text-xs rounded cursor-pointer",{active:I.cate_id==0}]),onClick:o[2]||(o[2]=Y=>I.cate_id=0)},J(G(ie)("selectPlaceholder")),3),($(!0),Q(Pe,null,je(E.data,(Y,ee)=>($(),Q("div",{class:Se(["group-item px-[10px] text-xs rounded cursor-pointer flex",{active:I.cate_id==Y.id}]),key:ee},[K("div",{class:"flex-1 leading-none truncate py-[10px]",onClick:le=>I.cate_id=Y.id},J(Y.name),9,xi),N.scene=="attachment"?($(),Q("div",Oi,[q(b,{placeholder:G(ie)("upload.attachmentCategoryPlaceholder"),onConfirm:le=>m(le,ee),value:Y.name},{default:Z(()=>[K("span",Pi,J(G(ie)("edit")),1)]),_:2},1032,["placeholder","onConfirm","value"]),K("span",{class:"text-danger ml-[5px]",onClick:le=>h(ee)},J(G(ie)("delete")),9,Fi)])):ue("",!0)],2))),128))]),_:1})]),q(b,{placeholder:G(ie)("upload.attachmentCategoryPlaceholder"),onConfirm:L},{default:Z(()=>[q(x,null,{default:Z(()=>[ce(J(G(ie)("upload.addAttachmentCategory")),1)]),_:1})]),_:1},8,["placeholder"])]),K("div",Mi,[q(P,{gutter:15,class:"h-[32px]"},{default:Z(()=>[q(O,{span:12},{default:Z(()=>[q(w,Tt(G(y),{ref_key:"uploadRef",ref:T}),{default:Z(()=>[q(x,{type:"primary"},{default:Z(()=>[ce(J(G(ie)("upload.upload"+N.type)),1)]),_:1})]),_:1},16)]),_:1}),q(O,{span:12,class:"text-right"},{default:Z(()=>[q(S,{modelValue:I.real_name,"onUpdate:modelValue":o[3]||(o[3]=Y=>I.real_name=Y),class:"m-0 w-[200px]",placeholder:G(ie)("upload.placeholder"+N.type+"Name"),"prefix-icon":"Search",onInput:o[4]||(o[4]=Y=>G(l)())},null,8,["modelValue","placeholder"])]),_:1})]),_:1}),ge(($(),Q("div",Ni,[q(k,null,{default:Z(()=>[A.data.length?($(),Q("div",Bi,[($(!0),Q(Pe,null,je(A.data,(Y,ee)=>($(),Q("div",{class:Se(["attachment-item mr-[10px]",N.scene=="select"?"w-[100px]":"w-[120px]"]),key:ee},[K("div",{class:Se(["attachment-wrap w-full rounded cursor-pointer overflow-hidden relative flex items-center justify-center",N.scene=="select"?"h-[100px]":"h-[120px]"]),onClick:le=>a(Y)},[N.type=="image"?($(),De(F,{key:0,src:G(tt)(Y.url),fit:"contain"},null,8,["src"])):($(),Q("video",{key:1,src:G(tt)(Y.url)},null,8,Gi)),ge(K("div",ji,[q(M,{name:"element-Select",color:"#fff",size:"25px"})],512),[[ve,R[Y.att_id]]])],10,Ui),K("div",Ki,[q(B,{placement:"top"},{content:Z(()=>[ce(J(Y.real_name),1)]),default:Z(()=>[K("div",Vi,J(Y.real_name),1)]),_:2},1024),N.scene=="attachment"?($(),De(V,{key:0,"hide-on-click":!1},{dropdown:Z(()=>[q(j,null,{default:Z(()=>[Y.att_type=="image"?($(),De(U,{key:0,class:"text-center",onClick:le=>p(ee)},{default:Z(()=>[K("div",Hi,J(G(ie)("lookOver")),1)]),_:2},1032,["onClick"])):ue("",!0),Y.att_type=="video"?($(),De(U,{key:1,class:"text-center",onClick:le=>i(ee)},{default:Z(()=>[K("div",Wi,J(G(ie)("lookOver")),1)]),_:2},1032,["onClick"])):ue("",!0),q(U,{class:"text-center",onClick:le=>d(ee)},{default:Z(()=>[K("div",Yi,J(G(ie)("upload.move")),1)]),_:2},1032,["onClick"]),q(U,{onClick:le=>t(ee)},{default:Z(()=>[K("div",qi,J(G(ie)("delete")),1)]),_:2},1032,["onClick"])]),_:2},1024)]),default:Z(()=>[q(M,{name:"element-MoreFilled",class:"cursor-pointer ml-[10px]",size:"14px"})]),_:2},1024)):ue("",!0)])],2))),128))])):($(),Q("div",zi,[q(H,{description:G(ie)("upload.attachmentEmpty"),"image-size":100},null,8,["description"])]))]),_:1})])),[[ae,A.loading]]),q(P,{gutter:20},{default:Z(()=>[N.scene=="attachment"?($(),De(O,{key:0,span:8},{default:Z(()=>[K("div",Xi,[q(z,{modelValue:c.value,"onUpdate:modelValue":o[5]||(o[5]=Y=>c.value=Y),label:G(ie)("selectAll"),size:"large"},null,8,["modelValue","label"]),q(x,{class:"ml-[15px]",disabled:n.value,onClick:o[6]||(o[6]=Y=>t())},{default:Z(()=>[ce(J(G(ie)("delete")),1)]),_:1},8,["disabled"]),q(x,{disabled:n.value,onClick:o[7]||(o[7]=Y=>d())},{default:Z(()=>[ce(J(G(ie)("upload.move")),1)]),_:1},8,["disabled"])])]),_:1})):ue("",!0),q(O,{span:N.scene=="attachment"?16:24},{default:Z(()=>[K("div",$i,[q(W,{"current-page":A.page,"onUpdate:currentPage":o[8]||(o[8]=Y=>A.page=Y),small:!0,"page-size":A.limit,"onUpdate:pageSize":o[9]||(o[9]=Y=>A.limit=Y),"page-sizes":[10,20,40,60],layout:"total, sizes, prev, pager, next, jumper",total:A.total,onSizeChange:o[10]||(o[10]=Y=>G(l)()),onCurrentChange:G(l)},null,8,["current-page","page-size","total","onCurrentChange"])])]),_:1},8,["span"])]),_:1})]),N.scene=="attachment"?($(),Q(Pe,{key:0},[q(te,{modelValue:s.visible,"onUpdate:modelValue":o[14]||(o[14]=Y=>s.visible=Y),title:G(ie)("upload.moveCategory"),width:"350px"},{footer:Z(()=>[K("span",Qi,[q(x,{onClick:o[12]||(o[12]=Y=>s.visible=!1)},{default:Z(()=>[ce(J(G(ie)("cancel")),1)]),_:1}),q(x,{type:"primary",loading:s.loading,onClick:o[13]||(o[13]=Y=>s.confirm())},{default:Z(()=>[ce(J(G(ie)("confirm")),1)]),_:1},8,["loading"])])]),default:Z(()=>[q(oe,{"label-width":"60px"},{default:Z(()=>[q(se,{label:G(ie)("upload.moveTo"),style:{"margin-bottom":"0"}},{default:Z(()=>[q(ne,{modelValue:s.cateId,"onUpdate:modelValue":o[11]||(o[11]=Y=>s.cateId=Y),class:"input-width"},{default:Z(()=>[($(!0),Q(Pe,null,je(E.data,(Y,ee)=>($(),De(X,{label:Y.name,value:Y.id,key:ee},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])]),_:1})]),_:1},8,["modelValue","title"]),u.show?($(),De(de,{key:0,"url-list":G(g),onClose:o[15]||(o[15]=Y=>u.show=!1),"initial-index":u.index,"zoom-rate":1},null,8,["url-list","initial-index"])):ue("",!0),q(te,{modelValue:v.visible,"onUpdate:modelValue":o[16]||(o[16]=Y=>v.visible=Y),width:"50%","align-center":"","destroy-on-close":!0,"custom-class":"video-preview"},{default:Z(()=>[q(re,{src:v.src,width:"100%"},null,8,["src"])]),_:1},8,["modelValue"])],64)):ue("",!0)],2)}}});const Un=ur(Zi,[["__scopeId","data-v-179a13a7"]]);export{Di as _,Un as a};