>>24&255,n>>>16&255,n>>>8&255,255&n,o>>>24&255,o>>>16&255,o>>>8&255,255&o,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);
return t.box(t.types.trun,f)},t.initSegment=function(e){t.types||t.init();var r,i=t.moov(e);return r=new Uint8Array(t.FTYP.byteLength+i.byteLength),r.set(t.FTYP),r.set(i,t.FTYP.byteLength),r},t}(),nt=at,ot=1e4,st=function(){function t(e,r,i,a){w(this,t),this.observer=e,this.config=r,this.typeSupported=i;var n=navigator.userAgent;this.isSafari=a&&a.indexOf("Apple")>-1&&n&&!n.match("CriOS"),this.ISGenerated=!1}return t.prototype.destroy=function(){},t.prototype.resetTimeStamp=function(t){this._initPTS=this._initDTS=t},t.prototype.resetInitSegment=function(){this.ISGenerated=!1},t.prototype.remux=function(t,e,r,i,a,n,o){if(this.ISGenerated||this.generateIS(t,e,a),this.ISGenerated){var s=t.samples.length,l=e.samples.length,u=a,d=a;if(s&&l){var c=(t.samples[0].dts-e.samples[0].dts)/e.inputTimeScale;u+=Math.max(0,c),d+=Math.max(0,-c)}if(s){t.timescale||(N.b.warn("regenerate InitSegment as audio detected"),this.generateIS(t,e,a));var f=this.remuxAudio(t,u,n,o);if(l){var h=void 0;f&&(h=f.endPTS-f.startPTS),e.timescale||(N.b.warn("regenerate InitSegment as video detected"),this.generateIS(t,e,a)),this.remuxVideo(e,d,n,h,o)}}else{var p=void 0;l&&(p=this.remuxVideo(e,d,n,o)),p&&t.codec&&this.remuxEmptyAudio(t,u,n,p)}}r.samples.length&&this.remuxID3(r,a),i.samples.length&&this.remuxText(i,a),this.observer.trigger(k.a.FRAG_PARSED)},t.prototype.generateIS=function(t,e,r){var i,a,n=this.observer,o=t.samples,s=e.samples,l=this.typeSupported,u="audio/mp4",d={},c={tracks:d},f=void 0===this._initPTS;if(f&&(i=a=1/0),t.config&&o.length&&(t.timescale=t.samplerate,N.b.log("audio sampling rate : "+t.samplerate),t.isAAC||(l.mpeg?(u="audio/mpeg",t.codec=""):l.mp3&&(t.codec="mp3")),d.audio={container:u,codec:t.codec,initSegment:!t.isAAC&&l.mpeg?new Uint8Array:nt.initSegment([t]),metadata:{channelCount:t.channelCount}},f&&(i=a=o[0].pts-t.inputTimeScale*r)),e.sps&&e.pps&&s.length){var h=e.inputTimeScale;e.timescale=h,d.video={container:"video/mp4",codec:e.codec,initSegment:nt.initSegment([e]),metadata:{width:e.width,height:e.height}},f&&(i=Math.min(i,s[0].pts-h*r),a=Math.min(a,s[0].dts-h*r),this.observer.trigger(k.a.INIT_PTS_FOUND,{initPTS:i}))}Object.keys(d).length?(n.trigger(k.a.FRAG_PARSING_INIT_SEGMENT,c),this.ISGenerated=!0,f&&(this._initPTS=i,this._initDTS=a)):n.trigger(k.a.ERROR,{type:D.b.MEDIA_ERROR,details:D.a.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},t.prototype.remuxVideo=function(t,e,r,i,a){var n,o,s,l,u,d,c,f,h=8,p=t.timescale,g=t.samples,v=[],m=g.length,y=this._PTSNormalize,b=this._initDTS,E=this.nextAvcDts,T=this.isSafari;T&&(r|=g.length&&E&&(a&&Math.abs(e-E/p)<.1||Math.abs(g[0].pts-E-b)1?N.b.log("AVC:"+w+" ms hole between fragments detected,filling it"):w<-1&&N.b.log("AVC:"+-w+" ms overlapping between fragments detected"),u=E,g[0].dts=u,l=Math.max(l-w,E),g[0].pts=l,N.b.log("Video/PTS/DTS adjusted: "+Math.round(l/90)+"/"+Math.round(u/90)+",delta:"+w+" ms")),d=u,A=g[g.length-1],f=Math.max(A.dts,0),c=Math.max(A.pts,0,f),T&&(n=Math.round((f-u)/(g.length-1)));for(var _=0,L=0,I=0;I0?B-1:B].dts;if(X.stretchShortVideoTrack){var J=X.maxBufferHole,$=X.maxSeekHole,Z=Math.floor(Math.min(J,$)*p),tt=(i?l+i*p:this.nextAudioPts)-G.pts;tt>Z?(n=tt-Q,n<0&&(n=Q),N.b.log("It is approximately "+tt/90+" ms to the next segment; using duration "+n/90+" ms for the last video frame.")):n=Q}else n=Q}H=Math.round(G.pts-G.dts)}v.push({size:K,duration:n,cts:H,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:G.key?2:1,isNonSync:G.key?0:1}})}this.nextAvcDts=f+n;var et=t.dropped;if(t.len=0,t.nbNalu=0,t.dropped=0,v.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var rt=v[0].flags;rt.dependsOn=2,rt.isNonSync=0}t.samples=v,s=nt.moof(t.sequenceNumber++,u,t),t.samples=[];var it={data1:s,data2:o,startPTS:l/p,endPTS:(c+n)/p,startDTS:u/p,endDTS:this.nextAvcDts/p,type:"video",nb:v.length,dropped:et};return this.observer.trigger(k.a.FRAG_PARSING_DATA,it),it},t.prototype.remuxAudio=function(t,e,r,i){var a,n,o,s,l,u,d,c=t.inputTimeScale,f=t.timescale,h=c/f,p=t.isAAC?1024:1152,g=p*h,v=this._PTSNormalize,m=this._initDTS,y=!t.isAAC&&this.typeSupported.mpeg,b=t.samples,E=[],T=this.nextAudioPts;if(r|=b.length&&T&&(i&&Math.abs(e-T/c)<.1||Math.abs(b[0].pts-T-m)<20*g),r||(T=e*c),b.forEach(function(t){t.pts=t.dts=v(t.pts-m,T)}),b.sort(function(t,e){return t.pts-e.pts}),i&&t.isAAC)for(var R=this.config.maxAudioFramesDrift,S=0,A=T;S=R*g&&I.1*g,_.pts=_.dts=A,A+=g,S++}for(var P=0,F=b.length;P0&&G0&&(o=rt.getSilentFrame(t.manifestCodec||t.codec,t.channelCount),o||(o=U.subarray()),t.len+=j*o.length);else if(G<-12){N.b.log("drop overlapping AAC sample, expected/parsed/delta:"+(T/c).toFixed(3)+"s/"+(B/c).toFixed(3)+"s/"+-G+"ms"),t.len-=U.byteLength;continue}B=T}if(u=Math.max(0,B),!(t.len>0))return;var K=y?t.len:t.len+8;a=y?0:8;try{s=new Uint8Array(K)}catch(t){return void this.observer.trigger(k.a.ERROR,{type:D.b.MUX_ERROR,details:D.a.REMUX_ALLOC_ERROR,fatal:!1,bytes:K,reason:"fail allocating audio mdat "+K})}if(!y){var H=new DataView(s.buffer);H.setUint32(0,K),s.set(nt.types.mdat,4)}for(var W=0;W=2&&(q=E[Y-2].duration,n.duration=q),Y){this.nextAudioPts=T=d+h*q,t.len=0,t.samples=E,l=y?new Uint8Array:nt.moof(t.sequenceNumber++,u/h,t),t.samples=[];var z=u/c,X=T/c,Q={data1:l,data2:s,startPTS:z,endPTS:X,startDTS:z,endDTS:X,type:"audio",nb:Y};return this.observer.trigger(k.a.FRAG_PARSING_DATA,Q),Q}return null},t.prototype.remuxEmptyAudio=function(t,e,r,i){var a=t.inputTimeScale,n=t.samplerate?t.samplerate:a,o=a/n,s=this.nextAudioPts,l=(void 0!==s?s:i.startDTS*a)+this._initDTS,u=i.endDTS*a+this._initDTS,d=1024,c=o*d,f=Math.ceil((u-l)/c),h=rt.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(N.b.warn("remux empty Audio"),!h)return void N.b.trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!");for(var p=[],g=0;g4294967296;)t+=r;return t},t}(),lt=st,ut=function(){function t(e){_(this,t),this.observer=e}return t.prototype.destroy=function(){},t.prototype.resetTimeStamp=function(){},t.prototype.resetInitSegment=function(){},t.prototype.remux=function(t,e,r,i,a,n,o,s){var l=this.observer,u="";t&&(u+="audio"),e&&(u+="video"),l.trigger(k.a.FRAG_PARSING_DATA,{data1:s,startPTS:a,startDTS:a,type:u,nb:1,dropped:0}),l.trigger(k.a.FRAG_PARSED)},t}(),dt=ut,ct=function(){function t(e,r,i,a){L(this,t),this.observer=e,this.typeSupported=r,this.config=i,this.vendor=a}return t.prototype.destroy=function(){var t=this.demuxer;t&&t.destroy()},t.prototype.push=function(t,e,r,i,a,n,o,s,l,u,d,c){if(t.byteLength>0&&null!=e&&null!=e.key&&"AES-128"===e.method){var f=this.decrypter;null==f&&(f=this.decrypter=new U(this.observer,this.config));var h,p=this;try{h=performance.now()}catch(t){h=Date.now()}f.decrypt(t,e.key.buffer,e.iv.buffer,function(t){var f;try{f=performance.now()}catch(t){f=Date.now()}p.observer.trigger(k.a.FRAG_DECRYPTED,{stats:{tstart:h,tdecrypt:f}}),p.pushDecrypted(new Uint8Array(t),e,new Uint8Array(r),i,a,n,o,s,l,u,d,c)})}else this.pushDecrypted(new Uint8Array(t),e,new Uint8Array(r),i,a,n,o,s,l,u,d,c)},t.prototype.pushDecrypted=function(t,e,r,i,a,n,o,s,l,u,d,c){var f=this.demuxer;if(!f||o&&!this.probe(t)){for(var h=this.observer,p=this.typeSupported,g=this.config,v=[{demux:$,remux:lt},{demux:j,remux:lt},{demux:tt,remux:lt},{demux:W,remux:dt}],m=0,y=v.length;me?a.start=i.start+i.duration:a.start=Math.max(i.start-a.duration,0):r>e?(i.duration=n-i.start,i.duration<0&&Dt.b.warn("negative duration computed for frag "+i.sn+",level "+i.level+", there should be some duration drift between playlist and fragment!")):(a.duration=i.start-n,a.duration<0&&Dt.b.warn("negative duration computed for frag "+a.sn+",level "+a.level+", there should be some duration drift between playlist and fragment!"))}function y(t,e,r,i,a,n){var o=r;if(!isNaN(e.startPTS)){var s=Math.abs(e.startPTS-r);isNaN(e.deltaPTS)?e.deltaPTS=s:e.deltaPTS=Math.max(s,e.deltaPTS),o=Math.max(r,e.startPTS),r=Math.min(r,e.startPTS),i=Math.max(i,e.endPTS),a=Math.min(a,e.startDTS),n=Math.max(n,e.endDTS)}var l=r-e.start;e.start=e.startPTS=r,e.maxStartPTS=o,e.endPTS=i,e.startDTS=a,e.endDTS=n,e.duration=i-r;var u=e.sn;if(!t||ut.endSN)return 0;var d,c,f;for(d=u-t.startSN,c=t.fragments,c[d]=e,f=d;f>0;f--)m(c,f,f-1);for(f=d;f=0&&ne?-1:0})}function R(t,e,r){var i=!1;return e&&e.details&&r&&(r.endCC>r.startCC||t&&t.cc59?e(r[1],r[2],0,r[4]):e(0,r[1],r[2],r[4]):null}function at(){this.values=Object.create(null)}function nt(t,e,r,i){var a=i?t.split(i):[t];for(var n in a)if("string"==typeof a[n]){var o=a[n].split(r);if(2===o.length){var s=o[0],l=o[1];e(s,l)}}}function ot(t,e,r){function i(){var e=it(t);if(null===e)throw new Error("Malformed timestamp: "+o);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function a(t,e){var i=new at;nt(t,function(t,e){switch(t){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===e){i.set(t,r[a].region);break}break;case"vertical":i.alt(t,e,["rl","lr"]);break;case"line":var n=e.split(","),o=n[0];i.integer(t,o),i.percent(t,o)&&i.set("snapToLines",!1),i.alt(t,o,["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",qe,"end"]);break;case"position":n=e.split(","),i.percent(t,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",qe,"end","line-left","line-right","auto"]);break;case"size":i.percent(t,e);break;case"align":i.alt(t,e,["start",qe,"end","left","right"])}},/:/,/\s/),e.region=i.get("region",null),e.vertical=i.get("vertical","");var a=i.get("line","auto");"auto"===a&&Ve.line===-1&&(a=-1),e.line=a,e.lineAlign=i.get("lineAlign","start"),e.snapToLines=i.get("snapToLines",!0),e.size=i.get("size",100),e.align=i.get("align",qe);var n=i.get("position","auto");"auto"===n&&50===Ve.position&&(n="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=n}function n(){t=t.replace(/^\s+/,"")}var o=t;if(n(),e.startTime=i(),n(),"-->"!==t.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+o);t=t.substr(3),n(),e.endTime=i(),n(),a(t,e)}function st(t){return t.replace(/
/gi,"\n")}function lt(t,e,r,i){for(var a,n,o,s,l,u=window.VTTCue||window.TextTrackCue,d=0;d=16?s--:s++,navigator.userAgent.match(/Firefox\//)?n.line=d+1:n.line=d>7?d-2:d+1,n.align="left",n.position=Math.max(0,Math.min(100,100*(s/32)+(navigator.userAgent.match(/Firefox\//)?50:0))),t.addCue(n)}}function ut(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function dt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ct(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function ft(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function ht(t){if(t&&t.cues)for(;t.cues.length>0;)t.removeCue(t.cues[0])}function pt(t,e){return t&&t.label===e.name&&!(t.textTrack1||t.textTrack2)}function gt(t,e,r,i){return Math.min(e,i)-Math.max(t,r)}function vt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function mt(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function yt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function bt(t){for(var e=[],r=0;r1?r-1:0),n=1;nNumber.MAX_SAFE_INTEGER?1/0:e},t.prototype.hexadecimalInteger=function(t){if(this[t]){var e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var r=new Uint8Array(e.length/2),i=0;iNumber.MAX_SAFE_INTEGER?1/0:e},t.prototype.decimalFloatingPoint=function(t){return parseFloat(this[t])},t.prototype.enumeratedString=function(t){return this[t]},t.prototype.decimalResolution=function(t){var e=xt.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},t.parseAttrList=function(t){var e,r={};for(Pt.lastIndex=0;null!==(e=Pt.exec(t));){var i=e[2],a='"';0===i.indexOf(a)&&i.lastIndexOf(a)===i.length-1&&(i=i.slice(1,-1)),r[e[1]]=i}return r},t}(),Nt=Ft,Mt={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0}},Ut=function(){function t(t,e){for(var r=0;r>8*(15-r)&255;return e},t.prototype.fragmentDecryptdataFromLevelkey=function(t,e){var r=t;return t&&t.method&&t.uri&&!t.iv&&(r=new Ht,r.method=t.method,r.baseuri=t.baseuri,r.reluri=t.reluri,r.iv=this.createInitializationVector(e)),r},t.prototype.cloneObj=function(t){return JSON.parse(JSON.stringify(t))},Ut(t,[{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=_t.a.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(t){this._url=t}},{key:"programDateTime",get:function(){return!this._programDateTime&&this.rawProgramDateTime&&(this._programDateTime=new Date(Date.parse(this.rawProgramDateTime))),this._programDateTime}},{key:"byteRange",get:function(){if(!this._byteRange){var t=this._byteRange=[];if(this.rawByteRange){var e=this.rawByteRange.split("@",2);if(1===e.length){var r=this.lastByteRangeEndOffset;t[0]=r?r:0}else t[0]=parseInt(e[1]);t[1]=parseInt(e[0])+t[0]}}return this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"decryptdata",
get:function(){return this._decryptdata||(this._decryptdata=this.fragmentDecryptdataFromLevelkey(this.levelkey,this.sn)),this._decryptdata}}]),t}(),Vt=function(t){function e(r){u(this,e);var i=s(this,t.call(this,r,Lt.a.MANIFEST_LOADING,Lt.a.LEVEL_LOADING,Lt.a.AUDIO_TRACK_LOADING,Lt.a.SUBTITLE_TRACK_LOADING));return i.loaders={},i}return l(e,t),e.prototype.destroy=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy()}this.loaders={},Ct.prototype.destroy.call(this)},e.prototype.onManifestLoading=function(t){this.load(t.url,{type:"manifest"})},e.prototype.onLevelLoading=function(t){this.load(t.url,{type:"level",level:t.level,id:t.id})},e.prototype.onAudioTrackLoading=function(t){this.load(t.url,{type:"audioTrack",id:t.id})},e.prototype.onSubtitleTrackLoading=function(t){this.load(t.url,{type:"subtitleTrack",id:t.id})},e.prototype.load=function(t,e){var r=this.loaders[e.type];if(r){var i=r.context;if(i&&i.url===t)return void Dt.b.trace("playlist request ongoing");Dt.b.warn("abort previous loader for type:"+e.type),r.abort()}var a=this.hls.config,n=void 0,o=void 0,s=void 0,l=void 0;"manifest"===e.type?(n=a.manifestLoadingMaxRetry,o=a.manifestLoadingTimeOut,s=a.manifestLoadingRetryDelay,l=a.manifestLoadingMaxRetryTimeout):(n=a.levelLoadingMaxRetry,o=a.levelLoadingTimeOut,s=a.levelLoadingRetryDelay,l=a.levelLoadingMaxRetryTimeout,Dt.b.log("loading playlist for "+e.type+" "+(e.level||e.id))),r=this.loaders[e.type]=e.loader="undefined"!=typeof a.pLoader?new a.pLoader(a):new a.loader(a),e.url=t,e.responseType="";var u=void 0,d=void 0;u={timeout:o,maxRetry:n,retryDelay:s,maxRetryDelay:l},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},r.load(e,u,d)},e.prototype.resolve=function(t,e){return _t.a.buildAbsoluteURL(e,t,{alwaysNormalize:!0})},e.prototype.parseMasterPlaylist=function(t,e){function r(t,e){["video","audio"].forEach(function(r){var i=t.filter(function(t){return n(t,r)});if(i.length){var a=i.filter(function(t){return 0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)});e[r+"Codec"]=a.length>0?a[0]:i[0],t=t.filter(function(t){return i.indexOf(t)===-1})}}),e.unknownCodecs=t}var i=[],a=void 0;for(Bt.lastIndex=0;null!=(a=Bt.exec(t));){var o={},s=o.attrs=new Nt(a[1]);o.url=this.resolve(a[2],e);var l=s.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),o.bitrate=s.decimalInteger("AVERAGE-BANDWIDTH")||s.decimalInteger("BANDWIDTH"),o.name=s.NAME,r([].concat((s.CODECS||"").split(/[ ,]+/)),o),o.videoCodec&&o.videoCodec.indexOf("avc1")!==-1&&(o.videoCodec=this.avc1toavcoti(o.videoCodec)),i.push(o)}return i},e.prototype.parseMasterPlaylistMedia=function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=void 0,n=[],o=0;for(Gt.lastIndex=0;null!=(a=Gt.exec(t));){var s={},l=new Nt(a[1]);l.TYPE===r&&(s.groupId=l["GROUP-ID"],s.name=l.NAME,s.type=r,s.default="YES"===l.DEFAULT,s.autoselect="YES"===l.AUTOSELECT,s.forced="YES"===l.FORCED,l.URI&&(s.url=this.resolve(l.URI,e)),s.lang=l.LANGUAGE,s.name||(s.name=s.lang),i&&(s.audioCodec=i),s.id=o++,n.push(s))}return n},e.prototype.avc1toavcoti=function(t){var e,r=t.split(".");return r.length>2?(e=r.shift()+".",e+=parseInt(r.shift()).toString(16),e+=("000"+parseInt(r.shift()).toString(16)).substr(-4)):e=t,e},e.prototype.parseLevelPlaylist=function(t,e,r,i){var a,n,o=0,s=0,l={type:null,version:null,url:e,fragments:[],live:!0,startSN:0},u=new Ht,d=0,c=null,f=new Wt;for(jt.lastIndex=0;null!==(a=jt.exec(t));){var h=a[1];if(h){f.duration=parseFloat(h);var p=(" "+a[2]).slice(1);f.title=p?p:null,f.tagList.push(p?["INF",h,p]:["INF",h])}else if(a[3]){if(!isNaN(f.duration)){var g=o++;f.type=i,f.start=s,f.levelkey=u,f.sn=g,f.level=r,f.cc=d,f.baseurl=e,f.relurl=(" "+a[3]).slice(1),l.fragments.push(f),c=f,s+=f.duration,f=new Wt}}else if(a[4]){if(f.rawByteRange=(" "+a[4]).slice(1),c){var v=c.byteRangeEndOffset;v&&(f.lastByteRangeEndOffset=v)}}else if(a[5])f.rawProgramDateTime=(" "+a[5]).slice(1),f.tagList.push(["PROGRAM-DATE-TIME",f.rawProgramDateTime]),void 0===l.programDateTime&&(l.programDateTime=new Date(new Date(Date.parse(a[5]))-1e3*s));else{for(a=a[0].match(Kt),n=1;n=0&&(u.method=T,u.baseuri=e,u.reluri=R,u.key=null,u.iv=S));break;case"START":var A=m,w=new Nt(A),_=w.decimalFloatingPoint("TIME-OFFSET");isNaN(_)||(l.startTimeOffset=_);break;case"MAP":var L=new Nt(m);f.relurl=L.URI,f.rawByteRange=L.BYTERANGE,f.baseurl=e,f.level=r,f.type=i,f.sn="initSegment",l.initSegment=f,f=new Wt;break;default:Dt.b.warn("line parsed but not handled: "+a)}}}return f=c,f&&!f.relurl&&(l.fragments.pop(),s-=f.duration),l.totalduration=s,l.averagetargetduration=s/l.fragments.length,l.endSN=o-1,l.startCC=l.fragments[0]?l.fragments[0].cc:0,l.endCC=d,l},e.prototype.loadsuccess=function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=t.data,n=t.url,o=r.type,s=r.id,l=r.level,u=this.hls;if(this.loaders[o]=void 0,void 0!==n&&0!==n.indexOf("data:")||(n=r.url),e.tload=performance.now(),0===a.indexOf("#EXTM3U"))if(a.indexOf("#EXTINF:")>0){var d="audioTrack"!==o&&"subtitleTrack"!==o,c=isNaN(l)?isNaN(s)?0:s:l,f=this.parseLevelPlaylist(a,n,c,"audioTrack"===o?"audio":"subtitleTrack"===o?"subtitle":"main");f.tload=e.tload,"manifest"===o&&u.trigger(Lt.a.MANIFEST_LOADED,{levels:[{url:n,details:f}],audioTracks:[],url:n,stats:e,networkDetails:i}),e.tparsed=performance.now(),f.targetduration?d?u.trigger(Lt.a.LEVEL_LOADED,{details:f,level:l||0,id:s||0,stats:e,networkDetails:i}):"audioTrack"===o?u.trigger(Lt.a.AUDIO_TRACK_LOADED,{details:f,id:s,stats:e,networkDetails:i}):"subtitleTrack"===o&&u.trigger(Lt.a.SUBTITLE_TRACK_LOADED,{details:f,id:s,stats:e,networkDetails:i}):u.trigger(Lt.a.ERROR,{type:kt.b.NETWORK_ERROR,details:kt.a.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"invalid targetduration",networkDetails:i})}else{var h=this.parseMasterPlaylist(a,n);if(h.length){var p=this.parseMasterPlaylistMedia(a,n,"AUDIO",h[0].audioCodec),g=this.parseMasterPlaylistMedia(a,n,"SUBTITLES");if(p.length){var v=!1;p.forEach(function(t){t.url||(v=!0)}),v===!1&&h[0].audioCodec&&!h[0].attrs.AUDIO&&(Dt.b.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main"}))}u.trigger(Lt.a.MANIFEST_LOADED,{levels:h,audioTracks:p,subtitles:g,url:n,stats:e,networkDetails:i})}else u.trigger(Lt.a.ERROR,{type:kt.b.NETWORK_ERROR,details:kt.a.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"no level found in manifest",networkDetails:i})}else u.trigger(Lt.a.ERROR,{type:kt.b.NETWORK_ERROR,details:kt.a.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"no EXTM3U delimiter",networkDetails:i})},e.prototype.loaderror=function(t,e){var r,i,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=e.loader;switch(e.type){case"manifest":r=kt.a.MANIFEST_LOAD_ERROR,i=!0;break;case"level":r=kt.a.LEVEL_LOAD_ERROR,i=!1;break;case"audioTrack":r=kt.a.AUDIO_TRACK_LOAD_ERROR,i=!1}n&&(n.abort(),this.loaders[e.type]=void 0),this.hls.trigger(Lt.a.ERROR,{type:kt.b.NETWORK_ERROR,details:r,fatal:i,url:n.url,loader:n,response:t,context:e,networkDetails:a})},e.prototype.loadtimeout=function(t,e){var r,i,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=e.loader;switch(e.type){case"manifest":r=kt.a.MANIFEST_LOAD_TIMEOUT,i=!0;break;case"level":r=kt.a.LEVEL_LOAD_TIMEOUT,i=!1;break;case"audioTrack":r=kt.a.AUDIO_TRACK_LOAD_TIMEOUT,i=!1}n&&(n.abort(),this.loaders[e.type]=void 0),this.hls.trigger(Lt.a.ERROR,{type:kt.b.NETWORK_ERROR,details:r,fatal:i,url:n.url,loader:n,context:e,networkDetails:a})},e}(Ct),qt=Vt,Yt=function(t){function e(r){d(this,e);var i=c(this,t.call(this,r,Lt.a.FRAG_LOADING));return i.loaders={},i}return f(e,t),e.prototype.destroy=function(){var t=this.loaders;for(var e in t){var r=t[e];r&&r.destroy()}this.loaders={},Ct.prototype.destroy.call(this)},e.prototype.onFragLoading=function(t){var e=t.frag,r=e.type,i=this.loaders[r],a=this.hls.config;e.loaded=0,i&&(Dt.b.warn("abort previous fragment loader for type:"+r),i.abort()),i=this.loaders[r]=e.loader="undefined"!=typeof a.fLoader?new a.fLoader(a):new a.loader(a);var n=void 0,o=void 0,s=void 0;n={url:e.url,frag:e,responseType:"arraybuffer",progressData:!1};var l=e.byteRangeStartOffset,u=e.byteRangeEndOffset;isNaN(l)||isNaN(u)||(n.rangeStart=l,n.rangeEnd=u),o={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout},s={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},i.load(n,o,s)},e.prototype.loadsuccess=function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=t.data,n=r.frag;n.loader=void 0,this.loaders[n.type]=void 0,this.hls.trigger(Lt.a.FRAG_LOADED,{payload:a,frag:n,stats:e,networkDetails:i})},e.prototype.loaderror=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=e.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(Lt.a.ERROR,{type:kt.b.NETWORK_ERROR,details:kt.a.FRAG_LOAD_ERROR,fatal:!1,frag:e.frag,response:t,networkDetails:r})},e.prototype.loadtimeout=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=e.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(Lt.a.ERROR,{type:kt.b.NETWORK_ERROR,details:kt.a.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e.frag,networkDetails:r})},e.prototype.loadprogress=function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=e.frag;a.loaded=t.loaded,this.hls.trigger(Lt.a.FRAG_LOAD_PROGRESS,{frag:a,stats:t,networkDetails:i})},e}(Ct),zt=Yt,Xt=function(t){function e(r){h(this,e);var i=p(this,t.call(this,r,Lt.a.KEY_LOADING));return i.loaders={},i.decryptkey=null,i.decrypturl=null,i}return g(e,t),e.prototype.destroy=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy()}this.loaders={},Ct.prototype.destroy.call(this)},e.prototype.onKeyLoading=function(t){var e=t.frag,r=e.type,i=this.loaders[r],a=e.decryptdata,n=a.uri;if(n!==this.decrypturl||null===this.decryptkey){var o=this.hls.config;i&&(Dt.b.warn("abort previous key loader for type:"+r),i.abort()),e.loader=this.loaders[r]=new o.loader(o),this.decrypturl=n,this.decryptkey=null;var s=void 0,l=void 0,u=void 0;s={url:n,frag:e,responseType:"arraybuffer"},l={timeout:o.fragLoadingTimeOut,maxRetry:o.fragLoadingMaxRetry,retryDelay:o.fragLoadingRetryDelay,maxRetryDelay:o.fragLoadingMaxRetryTimeout},u={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},e.loader.load(s,l,u)}else this.decryptkey&&(a.key=this.decryptkey,this.hls.trigger(Lt.a.KEY_LOADED,{frag:e}))},e.prototype.loadsuccess=function(t,e,r){var i=r.frag;this.decryptkey=i.decryptdata.key=new Uint8Array(t.data),i.loader=void 0,this.loaders[i.type]=void 0,this.hls.trigger(Lt.a.KEY_LOADED,{frag:i})},e.prototype.loaderror=function(t,e){var r=e.frag,i=r.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(Lt.a.ERROR,{type:kt.b.NETWORK_ERROR,details:kt.a.KEY_LOAD_ERROR,fatal:!1,frag:r,response:t})},e.prototype.loadtimeout=function(t,e){var r=e.frag,i=r.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(Lt.a.ERROR,{type:kt.b.NETWORK_ERROR,details:kt.a.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},e}(Ct),Qt=Xt,Jt={search:function(t,e){for(var r=0,i=t.length-1,a=null,n=null;r<=i;){a=(r+i)/2|0,n=t[a];var o=e(n);if(o>0)r=a+1;else{if(!(o<0))return n;i=a-1}}return null}},$t=Jt,Zt={isBuffered:function(t,e){if(t)for(var r=t.buffered,i=0;i=r.start(i)&&e<=r.end(i))return!0;return!1},bufferInfo:function(t,e,r){if(t){var i,a=t.buffered,n=[];for(i=0;id&&(l[u-1].end=t[s].end):l.push(t[s])}else l.push(t[s])}for(s=0,i=0,a=n=e;s=c&&e1?e-1:0),a=1;a1?e-1:0),a=1;a0&&t===-1&&(Dt.b.log("override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e),this.state=ce.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this.forceStartLoad=!0,this.state=ce.STOPPED},e.prototype.stopLoad=function(){var t=this.fragCurrent;t&&(t.loader&&t.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=ce.STOPPED,this.forceStartLoad=!1},e.prototype.tick=function(){this.ticks++,1===this.ticks&&(this.doTick(),this.ticks>1&&setTimeout(this.tick,1),this.ticks=0)},e.prototype.doTick=function(){switch(this.state){case ce.ERROR:break;case ce.BUFFER_FLUSHING:this.fragLoadError=0;break;case ce.IDLE:this._doTickIdle();break;case ce.WAITING_LEVEL:var t=this.levels[this.level];t&&t.details&&(this.state=ce.IDLE);break;case ce.FRAG_LOADING_WAITING_RETRY:var e=performance.now(),r=this.retryDate;(!r||e>=r||this.media&&this.media.seeking)&&(Dt.b.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=ce.IDLE);break;case ce.ERROR:case ce.STOPPED:case ce.FRAG_LOADING:case ce.PARSING:case ce.PARSED:case ce.ENDED:}this._checkBuffer(),this._checkFragmentChanged()},e.prototype._doTickIdle=function(){var t=this.hls,e=t.config,r=this.media;if(void 0!==this.levelLastLoaded&&(r||!this.startFragRequested&&e.startFragPrefetch)){var i=void 0;i=this.loadedmetadata?r.currentTime:this.nextLoadPosition;var a=t.nextLoadLevel,n=this.levels[a];if(n){var o=n.bitrate,s=void 0;s=o?Math.max(8*e.maxBufferSize/o,e.maxBufferLength):e.maxBufferLength,s=Math.min(s,e.maxMaxBufferLength);var l=te.bufferInfo(this.mediaBuffer?this.mediaBuffer:r,i,e.maxBufferHole),u=l.len;if(!(u>=s)){Dt.b.trace("buffer length of "+u.toFixed(3)+" is below max of "+s.toFixed(3)+". checking for more payload ..."),this.level=t.nextLoadLevel=a;var d=n.details;if("undefined"==typeof d||d.live&&this.levelLastLoaded!==a)return void(this.state=ce.WAITING_LEVEL);var c=this.fragPrevious;if(!d.live&&c&&!c.backtracked&&c.sn===d.endSN&&!l.nextStart){var f=Math.min(r.duration,c.start+c.duration);if(f-Math.max(l.end,c.start)<=Math.max(.2,c.duration)){var h={};return this.altAudio&&(h.type="video"),this.hls.trigger(Lt.a.BUFFER_EOS,h),void(this.state=ce.ENDED)}}this._fetchPayloadOrEos(i,l,d)}}}},e.prototype._fetchPayloadOrEos=function(t,e,r){var i=this.fragPrevious,a=this.level,n=r.fragments,o=n.length;if(0!==o){var s=n[0].start,l=n[o-1].start+n[o-1].duration,u=e.end,d=void 0;if(r.initSegment&&!r.initSegment.data)d=r.initSegment;else if(r.live){var c=this.config.initialLiveManifestSize;if(oc&&(l.currentTime=c),this.nextLoadPosition=c}if(t.PTSKnown&&e>i&&l&&l.readyState)return null;if(this.startFragRequested&&!t.PTSKnown){if(a){var f=a.sn+1;if(f>=t.startSN&&f<=t.endSN){var h=n[f-t.startSN];a.cc===h.cc&&(u=h,Dt.b.log("live playlist, switching playlist, load frag with next SN: "+u.sn))}u||(u=$t.search(n,function(t){return a.cc-t.cc}),u&&Dt.b.log("live playlist, switching playlist, load frag with same CC: "+u.sn))}u||(u=n[Math.min(o-1,Math.round(o/2))],Dt.b.log("live playlist, switching playlist, unknown, load middle frag : "+u.sn))}return u},e.prototype._findFragment=function(t,e,r,i,a,n,o){var s=this.hls.config,l=void 0,u=void 0,d=s.maxFragLookUpTolerance,c=e?i[e.sn-i[0].sn+1]:void 0,f=function(t){var e=Math.min(d,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-e<=a?1:t.start-e>a&&t.start?-1:0};if(an-d&&(d=0),u=c&&!f(c)?c:$t.search(i,f)):u=i[r-1],u){l=u;var h=l.sn-o.startSN,p=e&&l.level===e.level,g=i[h-1],v=i[h+1];if(e&&l.sn===e.sn)if(p&&!l.backtracked)if(l.sns.maxBufferHole&&e.dropped&&h?(l=g,Dt.b.warn("SN just loaded, with large PTS gap between audio and video, maybe frag is not starting with a keyframe ? load previous one to try to overcome this"),e.loadCounter--):(l=v,Dt.b.log("SN just loaded, load next one: "+l.sn))}else l=null;else l.backtracked&&(v&&v.backtracked?(Dt.b.warn("Already backtracked from fragment "+v.sn+", will not backtrack to fragment "+l.sn+". Loading fragment "+v.sn),l=v):(Dt.b.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),l.dropped=0,g?(g.loadCounter&&g.loadCounter--,l=g,l.backtracked=!0):h&&(l=null)))}return l},e.prototype._loadFragmentOrKey=function(t,e,r,i,a){var n=this.hls,o=n.config;if(!t.decryptdata||null==t.decryptdata.uri||null!=t.decryptdata.key){if(Dt.b.log("Loading "+t.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+e+", currentTime:"+i.toFixed(3)+",bufferEnd:"+a.toFixed(3)),void 0!==this.fragLoadIdx?this.fragLoadIdx++:this.fragLoadIdx=0,t.loadCounter){t.loadCounter++;var s=o.fragLoadingLoopThreshold;if(t.loadCounter>s&&Math.abs(this.fragLoadIdx-t.loadIdx)e.endPTS?1:0})},e.prototype.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.endPTS+.5):null},e.prototype._checkFragmentChanged=function(){var t,e,r=this.media;if(r&&r.readyState&&r.seeking===!1&&(e=r.currentTime,e>r.playbackRate*this.lastCurrentTime&&(this.lastCurrentTime=e),te.isBuffered(r,e)?t=this.getBufferedFrag(e):te.isBuffered(r,e+.1)&&(t=this.getBufferedFrag(e+.1)),t)){var i=t;if(i!==this.fragPlaying){this.hls.trigger(Lt.a.FRAG_CHANGED,{frag:i});var a=i.level;this.fragPlaying&&this.fragPlaying.level===a||this.hls.trigger(Lt.a.LEVEL_SWITCHED,{level:a}),this.fragPlaying=i}}},e.prototype.immediateLevelSwitch=function(){if(Dt.b.log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var t=this.media,e=void 0;t?(e=t.paused,t.pause()):e=!0,this.previouslyPaused=e}var r=this.fragCurrent;r&&r.loader&&r.loader.abort(),this.fragCurrent=null,void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},e.prototype.immediateLevelSwitchEnd=function(){var t=this.media;t&&t.buffered.length&&(this.immediateSwitch=!1,te.isBuffered(t,t.currentTime)&&(t.currentTime-=1e-4),this.previouslyPaused||t.play())},e.prototype.nextLevelSwitch=function(){var t=this.media;if(t&&t.readyState){var e=void 0,r=void 0,i=void 0;if(void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold),r=this.getBufferedFrag(t.currentTime),r&&r.startPTS>1&&this.flushMainBuffer(0,r.startPTS-1),t.paused)e=0;else{var a=this.hls.nextLoadLevel,n=this.levels[a],o=this.fragLastKbps;e=o&&this.fragCurrent?this.fragCurrent.duration*n.bitrate/(1e3*o)+1:0}if(i=this.getBufferedFrag(t.currentTime+e),i&&(i=this.followingBufferedFrag(i))){var s=this.fragCurrent;s&&s.loader&&s.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(i.maxStartPTS,Number.POSITIVE_INFINITY)}}},e.prototype.flushMainBuffer=function(t,e){this.state=ce.BUFFER_FLUSHING;var r={startOffset:t,endOffset:e};this.altAudio&&(r.type="video"),this.hls.trigger(Lt.a.BUFFER_FLUSHING,r)},e.prototype.onMediaAttached=function(t){var e=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),e.addEventListener("seeking",this.onvseeking),e.addEventListener("seeked",this.onvseeked),e.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.hls.startLoad(r.startPosition)},e.prototype.onMediaDetaching=function(){var t=this.media;t&&t.ended&&(Dt.b.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var e=this.levels;e&&e.forEach(function(t){t.details&&t.details.fragments.forEach(function(t){t.loadCounter=void 0,t.backtracked=void 0})}),t&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("seeked",this.onvseeked),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()},e.prototype.onMediaSeeking=function(){var t=this.media,e=t?t.currentTime:void 0,r=this.config;isNaN(e)||Dt.b.log("media seeking to "+e.toFixed(3));var i=this.mediaBuffer?this.mediaBuffer:t,a=te.bufferInfo(i,e,this.config.maxBufferHole);if(this.state===ce.FRAG_LOADING){var n=this.fragCurrent;if(0===a.len&&n){var o=r.maxFragLookUpTolerance,s=n.start-o,l=n.start+n.duration+o;el?(n.loader&&(Dt.b.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),n.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=ce.IDLE):Dt.b.log("seeking outside of buffer but within currently loaded fragment range")}}else this.state===ce.ENDED&&(0===a.len&&(this.fragPrevious=0),this.state=ce.IDLE);t&&(this.lastCurrentTime=e),this.state!==ce.FRAG_LOADING&&void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*r.fragLoadingLoopThreshold),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=e),this.tick()},e.prototype.onMediaSeeked=function(){var t=this.media,e=t?t.currentTime:void 0;isNaN(e)||Dt.b.log("media seeked to "+e.toFixed(3)),this.tick()},e.prototype.onMediaEnded=function(){Dt.b.log("media ended"),this.startPosition=this.lastCurrentTime=0},e.prototype.onManifestLoading=function(){Dt.b.log("trigger BUFFER_RESET"),this.hls.trigger(Lt.a.BUFFER_RESET),this._bufferedFrags=[],this.stalled=!1,this.startPosition=this.lastCurrentTime=0},e.prototype.onManifestParsed=function(t){var e,r=!1,i=!1;t.levels.forEach(function(t){e=t.audioCodec,e&&(e.indexOf("mp4a.40.2")!==-1&&(r=!0),e.indexOf("mp4a.40.5")!==-1&&(i=!0))}),this.audioCodecSwitch=r&&i,this.audioCodecSwitch&&Dt.b.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1;var a=this.config;(a.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(a.startPosition)},e.prototype.onLevelLoaded=function(t){var e=t.details,r=t.level,i=this.levels[this.levelLastLoaded],a=this.levels[r],n=e.totalduration,o=0;if(Dt.b.log("level "+r+" loaded ["+e.startSN+","+e.endSN+"],duration:"+n),e.live){var s=a.details;s&&e.fragments.length>0?(b(s,e),o=e.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(o,s),e.PTSKnown&&!isNaN(o)?Dt.b.log("live playlist sliding:"+o.toFixed(3)):(Dt.b.log("live playlist - outdated PTS, unknown sliding"),w(this.fragPrevious,i,e))):(Dt.b.log("live playlist - first load, unknown sliding"),e.PTSKnown=!1,w(this.fragPrevious,i,e))}else e.PTSKnown=!1;if(a.details=e,this.levelLastLoaded=r,this.hls.trigger(Lt.a.LEVEL_UPDATED,{details:e,level:r}),this.startFragRequested===!1){if(this.startPosition===-1||this.lastCurrentTime===-1){var l=e.startTimeOffset;isNaN(l)?e.live?(this.startPosition=this.computeLivePosition(o,e),Dt.b.log("configure startPosition to "+this.startPosition)):this.startPosition=0:(l<0&&(Dt.b.log("negative start time offset "+l+", count from end of last fragment"),l=o+n+l),Dt.b.log("start time offset found in playlist, adjust startPosition to "+l),this.startPosition=l),this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===ce.WAITING_LEVEL&&(this.state=ce.IDLE),this.tick()},e.prototype.onKeyLoaded=function(){this.state===ce.KEY_LOADING&&(this.state=ce.IDLE,this.tick())},e.prototype.onFragLoaded=function(t){var e=this.fragCurrent,r=t.frag;if(this.state===ce.FRAG_LOADING&&e&&"main"===r.type&&r.level===e.level&&r.sn===e.sn){var i=t.stats,a=this.levels[e.level],n=a.details;if(Dt.b.log("Loaded "+e.sn+" of ["+n.startSN+" ,"+n.endSN+"],level "+e.level),this.bitrateTest=!1,this.stats=i,r.bitrateTest===!0&&this.hls.nextLoadLevel)this.state=ce.IDLE,this.startFragRequested=!1,i.tparsed=i.tbuffered=performance.now(),this.hls.trigger(Lt.a.FRAG_BUFFERED,{stats:i,frag:e,id:"main"}),this.tick();else if("initSegment"===r.sn)this.state=ce.IDLE,i.tparsed=i.tbuffered=performance.now(),n.initSegment.data=t.payload,this.hls.trigger(Lt.a.FRAG_BUFFERED,{stats:i,frag:e,id:"main"}),this.tick();else{this.state=ce.PARSING;var o=n.totalduration,s=e.level,l=e.sn,u=this.config.defaultAudioCodec||a.audioCodec;this.audioCodecSwap&&(Dt.b.log("swapping playlist audio codec"),void 0===u&&(u=this.lastAudioCodec),u&&(u=u.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5")),this.pendingBuffering=!0,this.appended=!1,Dt.b.log("Parsing "+l+" of ["+n.startSN+" ,"+n.endSN+"],level "+s+", cc "+e.cc);var d=this.demuxer;d||(d=this.demuxer=new se(this.hls,"main"));var c=this.media,f=c&&c.seeking,h=!f&&(n.PTSKnown||!n.live),p=n.initSegment?n.initSegment.data:[];d.push(t.payload,p,u,a.videoCodec,e,o,h,void 0)}}this.fragLoadError=0},e.prototype.onFragParsingInitSegment=function(t){var e=this.fragCurrent,r=t.frag;if(e&&"main"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===ce.PARSING){var i,a,n=t.tracks;if(n.audio&&this.altAudio&&delete n.audio,a=n.audio){var o=this.levels[this.level].audioCodec,s=navigator.userAgent.toLowerCase();o&&this.audioCodecSwap&&(Dt.b.log("swapping playlist audio codec"),o=o.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==a.metadata.channelCount&&s.indexOf("firefox")===-1&&(o="mp4a.40.5"),s.indexOf("android")!==-1&&"audio/mpeg"!==a.container&&(o="mp4a.40.2",Dt.b.log("Android: force audio codec to "+o)),a.levelCodec=o,a.id=t.id}a=n.video,a&&(a.levelCodec=this.levels[this.level].videoCodec,a.id=t.id),this.hls.trigger(Lt.a.BUFFER_CODECS,n);for(i in n){a=n[i],Dt.b.log("main track:"+i+",container:"+a.container+",codecs[level/parsed]=["+a.levelCodec+"/"+a.codec+"]");
var l=a.initSegment;l&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(Lt.a.BUFFER_APPENDING,{type:i,data:l,parent:"main",content:"initSegment"}))}this.tick()}},e.prototype.onFragParsingData=function(t){var e=this,r=this.fragCurrent,i=t.frag;if(r&&"main"===t.id&&i.sn===r.sn&&i.level===r.level&&("audio"!==t.type||!this.altAudio)&&this.state===ce.PARSING){var a=this.levels[this.level],n=r;if(isNaN(t.endPTS)&&(t.endPTS=t.startPTS+r.duration,t.endDTS=t.startDTS+r.duration),Dt.b.log("Parsed "+t.type+",PTS:["+t.startPTS.toFixed(3)+","+t.endPTS.toFixed(3)+"],DTS:["+t.startDTS.toFixed(3)+"/"+t.endDTS.toFixed(3)+"],nb:"+t.nb+",dropped:"+(t.dropped||0)),"video"===t.type)if(n.dropped=t.dropped,n.dropped){if(!n.backtracked)return Dt.b.warn("missing video frame(s), backtracking fragment"),n.backtracked=!0,this.nextLoadPosition=t.startPTS,this.state=ce.IDLE,this.fragPrevious=n,void this.tick();Dt.b.warn("Already backtracked on this fragment, appending with the gap")}else n.backtracked=!1;var o=y(a.details,n,t.startPTS,t.endPTS,t.startDTS,t.endDTS),s=this.hls;s.trigger(Lt.a.LEVEL_PTS_UPDATED,{details:a.details,level:this.level,drift:o,type:t.type,start:t.startPTS,end:t.endPTS}),[t.data1,t.data2].forEach(function(r){r&&r.length&&e.state===ce.PARSING&&(e.appended=!0,e.pendingBuffering=!0,s.trigger(Lt.a.BUFFER_APPENDING,{type:t.type,data:r,parent:"main",content:"data"}))}),this.tick()}},e.prototype.onFragParsed=function(t){var e=this.fragCurrent,r=t.frag;e&&"main"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===ce.PARSING&&(this.stats.tparsed=performance.now(),this.state=ce.PARSED,this._checkAppendedParsed())},e.prototype.onAudioTrackSwitching=function(t){var e=!!t.url,r=t.id;if(!e){if(this.mediaBuffer!==this.media){Dt.b.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i.loader&&(Dt.b.log("switching to main audio track, cancel main fragment load"),i.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=ce.IDLE}var a=this.hls;a.trigger(Lt.a.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),a.trigger(Lt.a.AUDIO_TRACK_SWITCHED,{id:r}),this.altAudio=!1}},e.prototype.onAudioTrackSwitched=function(t){var e=t.id,r=!!this.hls.audioTracks[e].url;if(r){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(Dt.b.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r,this.tick()},e.prototype.onBufferCreated=function(t){var e=t.tracks,r=void 0,i=void 0,a=!1;for(var n in e){var o=e[n];"main"===o.id?(i=n,r=o,"video"===n&&(this.videoBuffer=e[n].buffer)):a=!0}a&&r?(Dt.b.log("alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},e.prototype.onBufferAppended=function(t){if("main"===t.parent){var e=this.state;e!==ce.PARSING&&e!==ce.PARSED||(this.pendingBuffering=t.pending>0,this._checkAppendedParsed())}},e.prototype._checkAppendedParsed=function(){if(!(this.state!==ce.PARSED||this.appended&&this.pendingBuffering)){var t=this.fragCurrent;if(t){var e=this.mediaBuffer?this.mediaBuffer:this.media;Dt.b.log("main buffered : "+ue.toString(e.buffered));var r=this._bufferedFrags.filter(function(t){return te.isBuffered(e,(t.startPTS+t.endPTS)/2)});r.push(t),this._bufferedFrags=r.sort(function(t,e){return t.startPTS-e.startPTS}),this.fragPrevious=t;var i=this.stats;i.tbuffered=performance.now(),this.fragLastKbps=Math.round(8*i.total/(i.tbuffered-i.tfirst)),this.hls.trigger(Lt.a.FRAG_BUFFERED,{stats:i,frag:t,id:"main"}),this.state=ce.IDLE}this.tick()}},e.prototype.onError=function(t){var e=t.frag||this.fragCurrent;if(!e||"main"===e.type){var r=!!this.media&&te.isBuffered(this.media,this.media.currentTime)&&te.isBuffered(this.media,this.media.currentTime+.5);switch(t.details){case kt.a.FRAG_LOAD_ERROR:case kt.a.FRAG_LOAD_TIMEOUT:case kt.a.KEY_LOAD_ERROR:case kt.a.KEY_LOAD_TIMEOUT:if(!t.fatal)if(this.fragLoadError+1<=this.config.fragLoadingMaxRetry){var i=Math.min(Math.pow(2,this.fragLoadError)*this.config.fragLoadingRetryDelay,this.config.fragLoadingMaxRetryTimeout);e.loadCounter=0,Dt.b.warn("mediaController: frag loading failed, retry in "+i+" ms"),this.retryDate=performance.now()+i,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.fragLoadError++,this.state=ce.FRAG_LOADING_WAITING_RETRY}else Dt.b.error("mediaController: "+t.details+" reaches max retry, redispatch as fatal ..."),t.fatal=!0,this.state=ce.ERROR;break;case kt.a.FRAG_LOOP_LOADING_ERROR:t.fatal||(r?(this._reduceMaxBufferLength(e.duration),this.state=ce.IDLE):e.autoLevel&&0!==e.level||(t.fatal=!0,this.state=ce.ERROR));break;case kt.a.LEVEL_LOAD_ERROR:case kt.a.LEVEL_LOAD_TIMEOUT:this.state!==ce.ERROR&&(t.fatal?(this.state=ce.ERROR,Dt.b.warn("streamController: "+t.details+",switch to "+this.state+" state ...")):t.levelRetry||this.state!==ce.WAITING_LEVEL||(this.state=ce.IDLE));break;case kt.a.BUFFER_FULL_ERROR:"main"!==t.parent||this.state!==ce.PARSING&&this.state!==ce.PARSED||(r?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=ce.IDLE):(Dt.b.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)))}}},e.prototype._reduceMaxBufferLength=function(t){var e=this.config;e.maxMaxBufferLength>=t&&(e.maxMaxBufferLength/=2,Dt.b.warn("main:reduce max buffer length to "+e.maxMaxBufferLength+"s"),void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*e.fragLoadingLoopThreshold))},e.prototype._checkBuffer=function(){var t=this.media,e=this.config;if(t&&t.readyState){var r=t.currentTime,i=this.mediaBuffer?this.mediaBuffer:t,a=i.buffered;if(!this.loadedmetadata&&a.length){this.loadedmetadata=!0;var n=t.seeking?r:this.startPosition,o=te.isBuffered(i,n),s=a.start(0),l=!o&&Math.abs(n-s)1e3*e.lowBufferWatchdogPeriod){this.stallReported||(this.stallReported=!0,Dt.b.warn("playback stalling in low buffer @"+r),p.trigger(Lt.a.ERROR,{type:kt.b.MEDIA_ERROR,details:kt.a.BUFFER_STALLED_ERROR,fatal:!1,buffer:v}));var y=u.nextStart,b=y-r;if(y&&b0){this.nudgeRetry=++m;var E=m*e.nudgeOffset;Dt.b.log("adjust currentTime from "+t.currentTime+" to next buffered @ "+y+" + nudge "+E),t.currentTime=y+E,this.stalled=void 0,p.trigger(Lt.a.ERROR,{type:kt.b.MEDIA_ERROR,details:kt.a.BUFFER_SEEK_OVER_HOLE,fatal:!1,hole:y+E-r})}}else if(v>c&&g>1e3*e.highBufferWatchdogPeriod)if(this.stallReported||(this.stallReported=!0,Dt.b.warn("playback stalling in high buffer @"+r),p.trigger(Lt.a.ERROR,{type:kt.b.MEDIA_ERROR,details:kt.a.BUFFER_STALLED_ERROR,fatal:!1,buffer:v})),this.stalled=void 0,this.nudgeRetry=++m,m"+t),this.hls.trigger(Lt.a.STREAM_STATE_TRANSITION,{previousState:e,nextState:t})}},get:function(){return this._state}},{key:"currentLevel",get:function(){var t=this.media;if(t){var e=this.getBufferedFrag(t.currentTime);if(e)return e.level}return-1}},{key:"nextBufferedFrag",get:function(){var t=this.media;return t?this.followingBufferedFrag(this.getBufferedFrag(t.currentTime)):null}},{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"liveSyncPosition",get:function(){return this._liveSyncPosition},set:function(t){this._liveSyncPosition=t}}]),e}(Ct),he=fe,pe=function(){function t(t,e){for(var r=0;r0){r=e[0].bitrate,e.sort(function(t,e){return t.bitrate-e.bitrate}),this._levels=e;for(var u=0;u0})}else this.hls.trigger(Lt.a.ERROR,{type:kt.b.MEDIA_ERROR,details:kt.a.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:this.hls.url,reason:"no level with compatible codecs found in manifest"})},e.prototype.setLevelInternal=function(t){var e=this._levels,r=this.hls;if(t>=0&&t1&&o.loadErrort&&(this._level===t&&void 0!==e[t].details||this.setLevelInternal(t))}},{key:"manualLevel",get:function(){return this._manualLevel},set:function(t){this._manualLevel=t,void 0===this._startLevel&&(this._startLevel=t),t!==-1&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return this._manualLevel!==-1?this._manualLevel:this.hls.nextAutoLevel},set:function(t){this.level=t,this._manualLevel===-1&&(this.hls.nextAutoLevel=t)}}]),e}(Ct),ve=ge,me=r(3),ye=function(t){function e(r){C(this,e);var i=x(this,t.call(this,r,Lt.a.MEDIA_ATTACHED,Lt.a.MEDIA_DETACHING,Lt.a.FRAG_PARSING_METADATA));return i.id3Track=void 0,i.media=void 0,i}return P(e,t),e.prototype.destroy=function(){Ct.prototype.destroy.call(this)},e.prototype.onMediaAttached=function(t){this.media=t.media,!this.media},e.prototype.onMediaDetaching=function(){this.media=void 0},e.prototype.onFragParsingMetadata=function(t){var e=t.frag,r=t.samples;this.id3Track||(this.id3Track=this.media.addTextTrack("metadata","id3"),this.id3Track.mode="hidden");for(var i=window.WebKitDataCue||window.VTTCue||window.TextTrackCue,a=0;a=this.minWeight_},t.prototype.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.prototype.destroy=function(){},t}(),Se=Re,Ae=function(){function t(t,e){for(var r=0;r500*r.duration/s){var l=t.levels,u=Math.max(1,n.bw?n.bw/8:1e3*n.loaded/o),d=l[r.level],c=d.realBitrate?Math.max(d.realBitrate,d.bitrate):d.bitrate,f=n.total?n.total:Math.max(n.loaded,Math.round(r.duration*c/8)),h=e.currentTime,p=(f-n.loaded)/u,g=(te.bufferInfo(e,h,t.config.maxBufferHole).end-h)/s;if(g<2*r.duration/s&&p>g){var v=void 0,m=void 0;for(m=r.level-1;m>a;m--){var y=l[m].realBitrate?Math.max(l[m].realBitrate,l[m].bitrate):l[m].bitrate;if(v=r.duration*y/(6.4*u),v=i;u--){var d=l[u],c=d.details,f=c?c.totalduration/c.fragments.length:e,h=!!c&&c.live,p=void 0;p=u<=t?o*r:s*r;var g=l[u].realBitrate?Math.max(l[u].realBitrate,l[u].bitrate):l[u].bitrate,v=g*f/p;if(Dt.b.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+u+"/"+Math.round(p)+"/"+g+"/"+f+"/"+n+"/"+v),p>g&&(!v||h&&!this.bitrateTestDelay||v=0)return f;Dt.b.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var h=s?Math.min(s,i.maxStarvationDelay):i.maxStarvationDelay,p=i.abrBandWidthFactor,g=i.abrBandWidthUpFactor;if(0===c){var v=this.bitrateTestDelay;if(v){var m=s?Math.min(s,i.maxLoadingDelay):i.maxLoadingDelay;h=m-v,Dt.b.trace("bitrate test took "+Math.round(1e3*v)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*h)+" ms"),p=g=1}}return f=this._findBestLevel(o,s,d,a,e,c+h,p,g,r),Math.max(f,0)}}]),e}(Ct),_e=we,Le=function(t){function e(r){G(this,e);var i=j(this,t.call(this,r,Lt.a.MEDIA_ATTACHING,Lt.a.MEDIA_DETACHING,Lt.a.MANIFEST_PARSED,Lt.a.BUFFER_RESET,Lt.a.BUFFER_APPENDING,Lt.a.BUFFER_CODECS,Lt.a.BUFFER_EOS,Lt.a.BUFFER_FLUSHING,Lt.a.LEVEL_PTS_UPDATED,Lt.a.LEVEL_UPDATED));return i._msDuration=null,i._levelDuration=null,i.onsbue=i.onSBUpdateEnd.bind(i),i.onsbe=i.onSBUpdateError.bind(i),i.pendingTracks={},i.tracks={},i}return K(e,t),e.prototype.destroy=function(){Ct.prototype.destroy.call(this)},e.prototype.onLevelPtsUpdated=function(t){var e=t.type,r=this.tracks.audio;if("audio"===e&&r&&"audio/mpeg"===r.container){var i=this.sourceBuffer.audio,a=Math.abs(i.timestampOffset-t.start);if(a>.1){var n=i.updating;try{i.abort()}catch(t){n=!0,Dt.b.warn("can not abort audio buffer: "+t)}n?this.audioTimestampOffset=t.start:(Dt.b.warn("change mpeg audio timestamp offset from "+i.timestampOffset+" to "+t.start),i.timestampOffset=t.start)}}},e.prototype.onManifestParsed=function(t){var e=t.audio,r=t.video||t.levels.length&&t.audio,i=0;t.altAudio&&(e||r)&&(i=(e?1:0)+(r?1:0),Dt.b.log(i+" sourceBuffer(s) expected")),this.sourceBufferNb=i},e.prototype.onMediaAttaching=function(t){var e=this.media=t.media;if(e){var r=this.mediaSource=new MediaSource;this.onmso=this.onMediaSourceOpen.bind(this),this.onmse=this.onMediaSourceEnded.bind(this),this.onmsc=this.onMediaSourceClose.bind(this),r.addEventListener("sourceopen",this.onmso),r.addEventListener("sourceended",this.onmse),r.addEventListener("sourceclose",this.onmsc),e.src=URL.createObjectURL(r)}},e.prototype.onMediaDetaching=function(){Dt.b.log("media source detaching");var t=this.mediaSource;if(t){if("open"===t.readyState)try{t.endOfStream()}catch(t){Dt.b.warn("onMediaDetaching:"+t.message+" while calling endOfStream")}t.removeEventListener("sourceopen",this.onmso),t.removeEventListener("sourceended",this.onmse),t.removeEventListener("sourceclose",this.onmsc),this.media&&(URL.revokeObjectURL(this.media.src),this.media.removeAttribute("src"),this.media.load()),this.mediaSource=null,this.media=null,this.pendingTracks={},this.tracks={},this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}this.onmso=this.onmse=this.onmsc=null,this.hls.trigger(Lt.a.MEDIA_DETACHED)},e.prototype.onMediaSourceOpen=function(){Dt.b.log("media source opened"),this.hls.trigger(Lt.a.MEDIA_ATTACHED,{media:this.media});var t=this.mediaSource;t&&t.removeEventListener("sourceopen",this.onmso),this.checkPendingTracks()},e.prototype.checkPendingTracks=function(){var t=this.pendingTracks,e=Object.keys(t).length;e&&(this.sourceBufferNb<=e||0===this.sourceBufferNb)&&(this.createSourceBuffers(t),this.pendingTracks={},this.doAppending())},e.prototype.onMediaSourceClose=function(){Dt.b.log("media source closed")},e.prototype.onMediaSourceEnded=function(){Dt.b.log("media source ended")},e.prototype.onSBUpdateEnd=function(){if(this.audioTimestampOffset){var t=this.sourceBuffer.audio;Dt.b.warn("change mpeg audio timestamp offset from "+t.timestampOffset+" to "+this.audioTimestampOffset),t.timestampOffset=this.audioTimestampOffset,delete this.audioTimestampOffset}this._needsFlush&&this.doFlush(),this._needsEos&&this.checkEos(),this.appending=!1;var e=this.parent,r=this.segments.reduce(function(t,r){return r.parent===e?t+1:t},0);this.hls.trigger(Lt.a.BUFFER_APPENDED,{parent:e,pending:r}),this._needsFlush||this.doAppending(),this.updateMediaElementDuration()},e.prototype.onSBUpdateError=function(t){Dt.b.error("sourceBuffer error:",t),this.hls.trigger(Lt.a.ERROR,{type:kt.b.MEDIA_ERROR,details:kt.a.BUFFER_APPENDING_ERROR,fatal:!1})},e.prototype.onBufferReset=function(){var t=this.sourceBuffer;for(var e in t){var r=t[e];try{this.mediaSource.removeSourceBuffer(r),r.removeEventListener("updateend",this.onsbue),r.removeEventListener("error",this.onsbe)}catch(t){}}this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0},e.prototype.onBufferCodecs=function(t){if(0===Object.keys(this.sourceBuffer).length){for(var e in t)this.pendingTracks[e]=t[e];var r=this.mediaSource;r&&"open"===r.readyState&&this.checkPendingTracks()}},e.prototype.createSourceBuffers=function(t){var e=this.sourceBuffer,r=this.mediaSource;for(var i in t)if(!e[i]){var a=t[i],n=a.levelCodec||a.codec,o=a.container+";codecs="+n;Dt.b.log("creating sourceBuffer("+o+")");try{var s=e[i]=r.addSourceBuffer(o);s.addEventListener("updateend",this.onsbue),s.addEventListener("error",this.onsbe),this.tracks[i]={codec:n,container:a.container},a.buffer=s}catch(t){Dt.b.error("error while trying to add sourceBuffer:"+t.message),this.hls.trigger(Lt.a.ERROR,{type:kt.b.MEDIA_ERROR,details:kt.a.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:t,mimeType:o})}}this.hls.trigger(Lt.a.BUFFER_CREATED,{tracks:t})},e.prototype.onBufferAppending=function(t){this._needsFlush||(this.segments?this.segments.push(t):this.segments=[t],this.doAppending())},e.prototype.onBufferAppendFail=function(t){Dt.b.error("sourceBuffer error:",t.event),this.hls.trigger(Lt.a.ERROR,{type:kt.b.MEDIA_ERROR,details:kt.a.BUFFER_APPENDING_ERROR,fatal:!1})},e.prototype.onBufferEos=function(t){var e=this.sourceBuffer,r=t.type;for(var i in e)r&&i!==r||e[i].ended||(e[i].ended=!0,Dt.b.log(i+" sourceBuffer now EOS"));this.checkEos()},e.prototype.checkEos=function(){var t=this.sourceBuffer,e=this.mediaSource;if(!e||"open"!==e.readyState)return void(this._needsEos=!1);for(var r in t){var i=t[r];if(!i.ended)return;if(i.updating)return void(this._needsEos=!0)}Dt.b.log("all media data available, signal endOfStream() to MediaSource and stop loading fragment");try{e.endOfStream()}catch(t){Dt.b.warn("exception while calling mediaSource.endOfStream()")}this._needsEos=!1},e.prototype.onBufferFlushing=function(t){this.flushRange.push({start:t.startOffset,end:t.endOffset,type:t.type}),this.flushBufferCounter=0,this.doFlush()},e.prototype.onLevelUpdated=function(t){var e=t.details;0!==e.fragments.length&&(this._levelDuration=e.totalduration+e.fragments[0].start,this.updateMediaElementDuration())},e.prototype.updateMediaElementDuration=function(){var t=this.media,e=this.mediaSource,r=this.sourceBuffer,i=this._levelDuration;if(null!==i&&t&&e&&r&&0!==t.readyState&&"open"===e.readyState){for(var a in r)if(r[a].updating)return;null===this._msDuration&&(this._msDuration=e.duration);var n=t.duration;(i>this._msDuration&&i>n||n===1/0||isNaN(n))&&(Dt.b.log("Updating mediasource duration to "+i.toFixed(3)),this._msDuration=e.duration=i)}},e.prototype.doFlush=function(){for(;this.flushRange.length;){var t=this.flushRange[0];if(!this.flushBuffer(t.start,t.end,t.type))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var e=0,r=this.sourceBuffer;try{for(var i in r)e+=r[i].buffered.length}catch(t){Dt.b.error("error while accessing sourceBuffer.buffered")}this.appended=e,this.hls.trigger(Lt.a.BUFFER_FLUSHED)}},e.prototype.doAppending=function(){var t=this.hls,e=this.sourceBuffer,r=this.segments;if(Object.keys(e).length){if(this.media.error)return this.segments=[],void Dt.b.error("trying to append although a media error occured, flush segment and abort");if(this.appending)return;if(r&&r.length){var i=r.shift();try{var a=i.type,n=e[a];n?n.updating?r.unshift(i):(n.ended=!1,this.parent=i.parent,n.appendBuffer(i.data),this.appendError=0,this.appended++,this.appending=!0):this.onSBUpdateEnd()}catch(e){Dt.b.error("error while trying to append buffer:"+e.message),r.unshift(i);var o={type:kt.b.MEDIA_ERROR,parent:i.parent};if(22===e.code)return this.segments=[],o.details=kt.a.BUFFER_FULL_ERROR,o.fatal=!1,void t.trigger(Lt.a.ERROR,o);if(this.appendError?this.appendError++:this.appendError=1,o.details=kt.a.BUFFER_APPEND_ERROR,this.appendError>t.config.appendErrorMaxRetry)return Dt.b.log("fail "+t.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),r=[],o.fatal=!0,void t.trigger(Lt.a.ERROR,o);o.fatal=!1,t.trigger(Lt.a.ERROR,o)}}}},e.prototype.flushBuffer=function(t,e,r){var i,a,n,o,s,l,u=this.sourceBuffer;if(Object.keys(u).length){if(Dt.b.log("flushBuffer,pos/start/end: "+this.media.currentTime.toFixed(3)+"/"+t+"/"+e),this.flushBufferCounter.5)return this.flushBufferCounter++,Dt.b.log("flush "+d+" ["+s+","+l+"], of ["+n+","+o+"], pos:"+this.media.currentTime),i.remove(s,l),!1}catch(t){Dt.b.warn("exception while accessing sourcebuffer, it might have been removed from MediaSource")}}}else Dt.b.warn("abort flushing too many retries");Dt.b.log("buffer flushed")}return!0},e}(Ct),ke=Le,De=function(){function t(t,e){for(var r=0;rthis.autoLevelCapping&&e.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},e.prototype.getMaxLevel=function(t){var r=this;if(!this.levels)return-1;var i=this.levels.filter(function(i,a){return e.isLevelAllowed(a,r.restrictedLevels)&&a<=t});return e.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},e.isLevelAllowed=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.indexOf(t)===-1},e.getMaxLevelByMediaSize=function(t,e,r){if(!t||t&&!t.length)return-1;for(var i=function(t,e){return!e||(t.width!==e.width||t.height!==e.height)},a=t.length-1,n=0;n=e||o.height>=r)&&i(o,t[n+1])){a=n;break}}return a},De(e,[{key:"mediaWidth",get:function(){var t=void 0,r=this.media;return r&&(t=r.width||r.clientWidth||r.offsetWidth,t*=e.contentScaleFactor),t}},{key:"mediaHeight",get:function(){var t=void 0,r=this.media;return r&&(t=r.height||r.clientHeight||r.offsetHeight,t*=e.contentScaleFactor),t}}],[{key:"contentScaleFactor",get:function(){var t=1;try{t=window.devicePixelRatio}catch(t){}return t}}]),e}(Ct),Oe=Ie,Ce=function(t){function e(r){return q(this,e),Y(this,t.call(this,r,Lt.a.MEDIA_ATTACHING))}return z(e,t),e.prototype.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},e.prototype.onMediaAttaching=function(t){var e=this.hls.config;if(e.capLevelOnFPSDrop){var r=this.video=t.media instanceof HTMLVideoElement?t.media:null;"function"==typeof r.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),e.fpsDroppedMonitoringPeriod)}},e.prototype.checkFPS=function(t,e,r){var i=performance.now();if(e){if(this.lastTime){var a=i-this.lastTime,n=r-this.lastDroppedFrames,o=e-this.lastDecodedFrames,s=1e3*n/a,l=this.hls;if(l.trigger(Lt.a.FPS_DROP,{currentDropped:n,currentDecoded:o,totalDroppedFrames:r}),s>0&&n>l.config.fpsDroppedMonitoringThreshold*o){var u=l.currentLevel;Dt.b.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(l.autoLevelCapping===-1||l.autoLevelCapping>=u)&&(u-=1,l.trigger(Lt.a.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,l.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},e.prototype.checkFPSInterval=function(){var t=this.video;if(t)if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},e}(Ct),xe=Ce,Pe=function(){function t(e){X(this,t),e&&e.xhrSetup&&(this.xhrSetup=e.xhrSetup)}return t.prototype.destroy=function(){this.abort(),this.loader=null},t.prototype.abort=function(){var t=this.loader;t&&4!==t.readyState&&(this.stats.aborted=!0,t.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null},t.prototype.load=function(t,e,r){this.context=t,this.config=e,this.callbacks=r,this.stats={trequest:performance.now(),retry:0},this.retryDelay=e.retryDelay,this.loadInternal()},t.prototype.loadInternal=function(){var t,e=this.context;t=this.loader=new XMLHttpRequest;var r=this.stats;r.tfirst=0,r.loaded=0;var i=this.xhrSetup;try{if(i)try{i(t,e.url)}catch(r){t.open("GET",e.url,!0),i(t,e.url)}t.readyState||t.open("GET",e.url,!0)}catch(r){return void this.callbacks.onError({code:t.status,text:r.message},e,t)}e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),t.send()},t.prototype.readystatechange=function(t){var e=t.currentTarget,r=e.readyState,i=this.stats,a=this.context,n=this.config;if(!i.aborted&&r>=2)if(window.clearTimeout(this.requestTimeout),0===i.tfirst&&(i.tfirst=Math.max(performance.now(),i.trequest)),4===r){var o=e.status;if(o>=200&&o<300){i.tload=Math.max(i.tfirst,performance.now());var s=void 0,l=void 0;"arraybuffer"===a.responseType?(s=e.response,l=s.byteLength):(s=e.responseText,l=s.length),i.loaded=i.total=l;var u={url:e.responseURL,data:s};this.callbacks.onSuccess(u,i,a,e)}else i.retry>=n.maxRetry||o>=400&&o<499?(Dt.b.error(o+" while loading "+a.url),this.callbacks.onError({code:o,text:e.statusText},a,e)):(Dt.b.warn(o+" while loading "+a.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,n.maxRetryDelay),i.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),n.timeout)},t.prototype.loadtimeout=function(){Dt.b.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)},t.prototype.loadprogress=function(t){var e=t.currentTarget,r=this.stats;r.loaded=t.loaded,t.lengthComputable&&(r.total=t.total);var i=this.callbacks.onProgress;i&&i(r,this.context,null,e)},t}(),Fe=Pe,Ne=function(){function t(t,e){for(var r=0;r1&&setTimeout(this.tick,1),this.ticks=0)},e.prototype.doTick=function(){this.updateTrack(this.trackId)},e.prototype.onError=function(t){t.fatal&&t.type===kt.b.NETWORK_ERROR&&this.cleanTimer()},e.prototype.onManifestLoading=function(){this.tracks=[],this.trackId=-1},e.prototype.onManifestLoaded=function(t){var e=this,r=t.audioTracks||[],i=!1;this.tracks=r,this.hls.trigger(Lt.a.AUDIO_TRACKS_UPDATED,{audioTracks:r});var a=0;r.forEach(function(t){return t.default&&!i?(e.audioTrack=a,void(i=!0)):void a++}),i===!1&&r.length&&(Dt.b.log("no default audio track defined, use first audio track as default"),this.audioTrack=0)},e.prototype.onAudioTrackLoaded=function(t){t.id=0&&t=0&&t0&&t===-1?(Dt.b.log("audio:override startPosition with lastCurrentTime @"+e.toFixed(3)),this.state=Ge.IDLE):(this.lastCurrentTime=this.startPosition?this.startPosition:t,this.state=Ge.STARTING),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else this.startPosition=t,this.state=Ge.STOPPED},e.prototype.stopLoad=function(){var t=this.fragCurrent;t&&(t.loader&&t.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=Ge.STOPPED},e.prototype.tick=function(){this.ticks++,1===this.ticks&&(this.doTick(),this.ticks>1&&setTimeout(this.tick,1),this.ticks=0)},e.prototype.doTick=function(){var t,e,r,i=this.hls,a=i.config;switch(this.state){case Ge.ERROR:case Ge.PAUSED:case Ge.BUFFER_FLUSHING:break;case Ge.STARTING:this.state=Ge.WAITING_TRACK,this.loadedmetadata=!1;break;case Ge.IDLE:var n=this.tracks;if(!n)break;if(!this.media&&(this.startFragRequested||!a.startFragPrefetch))break;if(this.loadedmetadata)t=this.media.currentTime;else if(t=this.nextLoadPosition,void 0===t)break;var o=this.mediaBuffer?this.mediaBuffer:this.media,s=this.videoBuffer?this.videoBuffer:this.media,l=te.bufferInfo(o,t,a.maxBufferHole),u=te.bufferInfo(s,t,a.maxBufferHole),d=l.len,c=l.end,f=this.fragPrevious,h=Math.max(a.maxBufferLength,u.len),p=this.audioSwitch,g=this.trackId;if((dy||l.nextStart))return;Dt.b.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=y+.05}if(r.initSegment&&!r.initSegment.data)E=r.initSegment;else if(c<=y){if(E=v[0],null!==this.videoTrackCC&&E.cc!==this.videoTrackCC&&(E=T(v,this.videoTrackCC)),r.live&&E.loadIdx&&E.loadIdx===this.fragLoadIdx){var R=l.nextStart?l.nextStart:y;return Dt.b.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(R+.05)),void(this.media.currentTime=R+.05)}}else{var S=void 0,A=a.maxFragLookUpTolerance,w=f?v[f.sn-v[0].sn+1]:void 0,_=function(t){var e=Math.min(A,t.duration);return t.start+t.duration-e<=c?1:t.start-e>c&&t.start?-1:0};cb-A&&(A=0),S=w&&!_(w)?w:$t.search(v,_)):S=v[m-1],S&&(E=S,y=S.start,f&&E.level===f.level&&E.sn===f.sn&&(E.snL&&Math.abs(this.fragLoadIdx-E.loadIdx)=D||I)&&(Dt.b.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=Ge.IDLE);break;case Ge.WAITING_INIT_PTS:var O=this.videoTrackCC;if(void 0===this.initPTS[O])break;var C=this.waitingFragment;if(C){var x=C.frag.cc;O!==x?(e=this.tracks[this.trackId],e.details&&e.details.live&&(Dt.b.warn("Waiting fragment CC ("+x+") does not match video track CC ("+O+")"),this.waitingFragment=null,this.state=Ge.IDLE)):(this.state=Ge.FRAG_LOADING,this.onFragLoaded(this.waitingFragment),this.waitingFragment=null)}else this.state=Ge.IDLE;break;case Ge.STOPPED:case Ge.FRAG_LOADING:case Ge.PARSING:case Ge.PARSED:case Ge.ENDED:}},e.prototype.onMediaAttached=function(t){var e=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),e.addEventListener("seeking",this.onvseeking),e.addEventListener("ended",this.onvended);var r=this.config;this.tracks&&r.autoStartLoad&&this.startLoad(r.startPosition)},e.prototype.onMediaDetaching=function(){var t=this.media;t&&t.ended&&(Dt.b.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var e=this.tracks;e&&e.forEach(function(t){t.details&&t.details.fragments.forEach(function(t){t.loadCounter=void 0})}),t&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1,this.stopLoad()},e.prototype.onMediaSeeking=function(){this.state===Ge.ENDED&&(this.state=Ge.IDLE),this.media&&(this.lastCurrentTime=this.media.currentTime),void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold),this.tick()},e.prototype.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},e.prototype.onAudioTracksUpdated=function(t){Dt.b.log("audio tracks updated"),this.tracks=t.audioTracks},e.prototype.onAudioTrackSwitching=function(t){var e=!!t.url;this.trackId=t.id,this.fragCurrent=null,this.state=Ge.PAUSED,this.waitingFragment=null,e?this.timer||(this.timer=setInterval(this.ontick,100)):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),e&&(this.audioSwitch=!0,this.state=Ge.IDLE,void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold)),this.tick()},e.prototype.onAudioTrackLoaded=function(t){var e=t.details,r=t.id,i=this.tracks[r],a=e.totalduration,n=0;if(Dt.b.log("track "+r+" loaded ["+e.startSN+","+e.endSN+"],duration:"+a),e.live){var o=i.details;o&&e.fragments.length>0?(b(o,e),n=e.fragments[0].start,e.PTSKnown?Dt.b.log("live audio playlist sliding:"+n.toFixed(3)):Dt.b.log("live audio playlist - outdated PTS, unknown sliding")):(e.PTSKnown=!1,Dt.b.log("live audio playlist - first load, unknown sliding"))}else e.PTSKnown=!1;if(i.details=e,!this.startFragRequested){if(this.startPosition===-1){var s=e.startTimeOffset;isNaN(s)?this.startPosition=0:(Dt.b.log("start time offset found in playlist, adjust startPosition to "+s),this.startPosition=s)}this.nextLoadPosition=this.startPosition}this.state===Ge.WAITING_TRACK&&(this.state=Ge.IDLE),this.tick()},e.prototype.onKeyLoaded=function(){this.state===Ge.KEY_LOADING&&(this.state=Ge.IDLE,this.tick())},e.prototype.onFragLoaded=function(t){var e=this.fragCurrent,r=t.frag;if(this.state===Ge.FRAG_LOADING&&e&&"audio"===r.type&&r.level===e.level&&r.sn===e.sn){var i=this.tracks[this.trackId],a=i.details,n=a.totalduration,o=e.level,s=e.sn,l=e.cc,u=this.config.defaultAudioCodec||i.audioCodec||"mp4a.40.2",d=this.stats=t.stats;if("initSegment"===s)this.state=Ge.IDLE,d.tparsed=d.tbuffered=performance.now(),a.initSegment.data=t.payload,this.hls.trigger(Lt.a.FRAG_BUFFERED,{stats:d,frag:e,id:"audio"}),this.tick();else{this.state=Ge.PARSING,this.appended=!1,this.demuxer||(this.demuxer=new se(this.hls,"audio"));var c=this.initPTS[l],f=a.initSegment?a.initSegment.data:[];if(a.initSegment||void 0!==c){this.pendingBuffering=!0,Dt.b.log("Demuxing "+s+" of ["+a.startSN+" ,"+a.endSN+"],track "+o);var h=!1;this.demuxer.push(t.payload,f,u,null,e,n,h,c)}else Dt.b.log("unknown video PTS for continuity counter "+l+", waiting for video PTS before demuxing audio frag "+s+" of ["+a.startSN+" ,"+a.endSN+"],track "+o),this.waitingFragment=t,this.state=Ge.WAITING_INIT_PTS}}this.fragLoadError=0},e.prototype.onFragParsingInitSegment=function(t){var e=this.fragCurrent,r=t.frag;if(e&&"audio"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===Ge.PARSING){var i=t.tracks,a=void 0;if(i.video&&delete i.video,a=i.audio){a.levelCodec=a.codec,a.id=t.id,this.hls.trigger(Lt.a.BUFFER_CODECS,i),Dt.b.log("audio track:audio,container:"+a.container+",codecs[level/parsed]=["+a.levelCodec+"/"+a.codec+"]");var n=a.initSegment;if(n){var o={type:"audio",data:n,parent:"audio",content:"initSegment"};this.audioSwitch?this.pendingData=[o]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(Lt.a.BUFFER_APPENDING,o))}this.tick()}}},e.prototype.onFragParsingData=function(t){var e=this,r=this.fragCurrent,i=t.frag;if(r&&"audio"===t.id&&"audio"===t.type&&i.sn===r.sn&&i.level===r.level&&this.state===Ge.PARSING){var a=this.trackId,n=this.tracks[a],o=this.hls;isNaN(t.endPTS)&&(t.endPTS=t.startPTS+r.duration,t.endDTS=t.startDTS+r.duration),Dt.b.log("parsed "+t.type+",PTS:["+t.startPTS.toFixed(3)+","+t.endPTS.toFixed(3)+"],DTS:["+t.startDTS.toFixed(3)+"/"+t.endDTS.toFixed(3)+"],nb:"+t.nb),y(n.details,r,t.startPTS,t.endPTS);var s=this.audioSwitch,l=this.media,u=!1;if(s&&l)if(l.readyState){var d=l.currentTime;Dt.b.log("switching audio track : currentTime:"+d),d>=t.startPTS&&(Dt.b.log("switching audio track : flushing all audio"),this.state=Ge.BUFFER_FLUSHING,o.trigger(Lt.a.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),u=!0,this.audioSwitch=!1,o.trigger(Lt.a.AUDIO_TRACK_SWITCHED,{id:a}))}else this.audioSwitch=!1,o.trigger(Lt.a.AUDIO_TRACK_SWITCHED,{id:a});var c=this.pendingData;this.audioSwitch||([t.data1,t.data2].forEach(function(e){e&&e.length&&c.push({type:t.type,data:e,parent:"audio",content:"data"})}),!u&&c.length&&(c.forEach(function(t){e.state===Ge.PARSING&&(e.pendingBuffering=!0,e.hls.trigger(Lt.a.BUFFER_APPENDING,t))}),this.pendingData=[],this.appended=!0)),this.tick()}},e.prototype.onFragParsed=function(t){var e=this.fragCurrent,r=t.frag;e&&"audio"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===Ge.PARSING&&(this.stats.tparsed=performance.now(),this.state=Ge.PARSED,this._checkAppendedParsed())},e.prototype.onBufferCreated=function(t){var e=t.tracks.audio;e&&(this.mediaBuffer=e.buffer,this.loadedmetadata=!0),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer)},e.prototype.onBufferAppended=function(t){if("audio"===t.parent){var e=this.state;e!==Ge.PARSING&&e!==Ge.PARSED||(this.pendingBuffering=t.pending>0,this._checkAppendedParsed())}},e.prototype._checkAppendedParsed=function(){if(!(this.state!==Ge.PARSED||this.appended&&this.pendingBuffering)){var t=this.fragCurrent,e=this.stats,r=this.hls;if(t){this.fragPrevious=t,e.tbuffered=performance.now(),r.trigger(Lt.a.FRAG_BUFFERED,{stats:e,frag:t,id:"audio"});var i=this.mediaBuffer?this.mediaBuffer:this.media;Dt.b.log("audio buffered : "+ue.toString(i.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,r.trigger(Lt.a.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=Ge.IDLE}this.tick()}},e.prototype.onError=function(t){var e=t.frag;if(!e||"audio"===e.type)switch(t.details){case kt.a.FRAG_LOAD_ERROR:case kt.a.FRAG_LOAD_TIMEOUT:if(!t.fatal){var r=this.fragLoadError;r?r++:r=1;var i=this.config;if(r<=i.fragLoadingMaxRetry){this.fragLoadError=r,e.loadCounter=0;var a=Math.min(Math.pow(2,r-1)*i.fragLoadingRetryDelay,i.fragLoadingMaxRetryTimeout);Dt.b.warn("audioStreamController: frag loading failed, retry in "+a+" ms"),this.retryDate=performance.now()+a,this.state=Ge.FRAG_LOADING_WAITING_RETRY}else Dt.b.error("audioStreamController: "+t.details+" reaches max retry, redispatch as fatal ..."),t.fatal=!0,this.state=Ge.ERROR}break;case kt.a.FRAG_LOOP_LOADING_ERROR:case kt.a.AUDIO_TRACK_LOAD_ERROR:case kt.a.AUDIO_TRACK_LOAD_TIMEOUT:case kt.a.KEY_LOAD_ERROR:case kt.a.KEY_LOAD_TIMEOUT:this.state!==Ge.ERROR&&(this.state=t.fatal?Ge.ERROR:Ge.IDLE,Dt.b.warn("audioStreamController: "+t.details+" while loading frag,switch to "+this.state+" state ..."));break;case kt.a.BUFFER_FULL_ERROR:if("audio"===t.parent&&(this.state===Ge.PARSING||this.state===Ge.PARSED)){var n=this.mediaBuffer,o=this.media.currentTime,s=n&&te.isBuffered(n,o)&&te.isBuffered(n,o+.5);if(s){var l=this.config;l.maxMaxBufferLength>=l.maxBufferLength&&(l.maxMaxBufferLength/=2,Dt.b.warn("audio:reduce max buffer length to "+l.maxMaxBufferLength+"s"),this.fragLoadIdx+=2*l.fragLoadingLoopThreshold),this.state=Ge.IDLE}else Dt.b.warn("buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=Ge.BUFFER_FLUSHING,this.hls.trigger(Lt.a.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})}}},e.prototype.onBufferFlushed=function(){var t=this,e=this.pendingData;e&&e.length?(Dt.b.log("appending pending audio data on Buffer Flushed"),e.forEach(function(e){t.hls.trigger(Lt.a.BUFFER_APPENDING,e)}),this.appended=!0,this.pendingData=[],this.state=Ge.PARSED):(this.state=Ge.IDLE,this.fragPrevious=null,this.tick())},Be(e,[{key:"state",set:function(t){if(this.state!==t){var e=this.state;this._state=t,Dt.b.log("audio stream:"+e+"->"+t)}},get:function(){return this._state}}]),e}(Ct),Ke=je,He=function(){function t(t){if("string"!=typeof t)return!1;var e=n[t.toLowerCase()];return!!e&&t.toLowerCase()}function e(t){if("string"!=typeof t)return!1;var e=o[t.toLowerCase()];return!!e&&t.toLowerCase()}function r(t){for(var e=1;e100)throw new Error("Position must be between 0 and 100.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"positionAlign",r({},u,{get:function(){return T},set:function(t){var r=e(t);if(!r)throw new SyntaxError("An invalid or illegal string was specified.");T=r,this.hasBeenReset=!0}})),Object.defineProperty(s,"size",r({},u,{get:function(){return R},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");R=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"align",r({},u,{get:function(){return S},set:function(t){var r=e(t);if(!r)throw new SyntaxError("An invalid or illegal string was specified.");S=r,this.hasBeenReset=!0}})),s.displayState=void 0,l)return s}if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var a="auto",n={"":!0,lr:!0,rl:!0},o={start:!0,middle:!0,end:!0,left:!0,right:!0};return i.prototype.getCueAsHTML=function(){var t=window.WebVTT;return t.convertCueToDOMTree(window,this.text)},i}(),We=function(){return{decode:function(t){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}};at.prototype={set:function(t,e){this.get(t)||""===e||(this.values[t]=e)},get:function(t,e,r){return r?this.has(t)?this.values[t]:e[r]:this.has(t)?this.values[t]:e},has:function(t){return t in this.values},alt:function(t,e,r){for(var i=0;i=0&&e<=100))&&(this.set(t,e),!0)}};var Ve=new He(0,0,0),qe="middle"===Ve.align?"middle":"center";rt.prototype={parse:function(t){function e(){var t=i.buffer,e=0;for(t=st(t);e")===-1){i.cue.id=a;continue}case"CUE":try{ot(a,i.cue,i.regionList)}catch(t){i.cue=null,i.state="BADCUE";continue}i.state="CUETEXT";continue;case"CUETEXT":var s=a.indexOf("-->")!==-1;if(!a||s&&(o=!0)){i.oncue&&i.oncue(i.cue),i.cue=null,i.state="ID";continue}i.cue.text&&(i.cue.text+="\n"),i.cue.text+=a;continue;case"BADCUE":a||(i.state="ID");continue}}}catch(t){"CUETEXT"===i.state&&i.cue&&i.oncue&&i.oncue(i.cue),i.cue=null,i.state="INITIAL"===i.state?"BADWEBVTT":"BADCUE"}return this},flush:function(){var t=this;try{if(t.buffer+=t.decoder.decode(),(t.cue||"HEADER"===t.state)&&(t.buffer+="\n\n",t.parse()),"INITIAL"===t.state)throw new Error("Malformed WebVTT signature.")}catch(t){throw t}return t.onflush&&t.onflush(),this}};var Ye=rt,ze={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},Xe=function(t){var e=t;return ze.hasOwnProperty(t)&&(e=ze[t]),String.fromCharCode(e)},Qe=15,Je=100,$e={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Ze={17:2,18:4,21:6,22:8,23:10,19:13,20:15},tr={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},er={25:2,26:4,29:6,30:8,31:10,27:13,28:15},rr=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],ir={verboseFilter:{DATA:3,DEBUG:3,INFO:2,WARNING:2,TEXT:1,ERROR:0},time:null,verboseLevel:0,setTime:function(t){this.time=t},log:function(t,e){var r=this.verboseFilter[t];this.verboseLevel>=r&&console.log(this.time+" ["+t+"] "+e)}},ar=function(t){for(var e=[],r=0;rJe&&(ir.log("ERROR","Too large cursor position "+this.pos),this.pos=Je)},t.prototype.moveCursor=function(t){var e=this.pos+t;if(t>1)for(var r=this.pos+1;r=144&&this.backSpace();var e=Xe(t);return this.pos>=Je?void ir.log("ERROR","Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(e,this.currPenState),void this.moveCursor(1))},t.prototype.clearFromPos=function(t){var e;for(e=t;e0&&(r=t?"["+e.join(" | ")+"]":e.join("\n")),r},t.prototype.getTextAndFormat=function(){return this.rows},t}(),ur=function(){function t(e,r){ut(this,t),this.chNr=e,this.outputFilter=r,this.mode=null,this.verbose=0,this.displayedMemory=new lr,this.nonDisplayedMemory=new lr,this.lastOutputScreen=new lr,this.currRollUpRow=this.displayedMemory.rows[Qe-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}return t.prototype.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[Qe-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.lastCueEndTime=null},t.prototype.getHandler=function(){return this.outputFilter},t.prototype.setHandler=function(t){this.outputFilter=t},t.prototype.setPAC=function(t){this.writeScreen.setPAC(t)},t.prototype.setBkgData=function(t){this.writeScreen.setBkgData(t)},t.prototype.setMode=function(t){t!==this.mode&&(this.mode=t,ir.log("INFO","MODE="+t),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)},t.prototype.insertChars=function(t){for(var e=0;e=46,e.italics)e.foreground="white";else{var r=Math.floor(t/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=i[r]}ir.log("INFO","MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)},t.prototype.outputDataUpdate=function(){var t=ir.time;null!==t&&this.outputFilter&&(this.outputFilter.updateData&&this.outputFilter.updateData(t,this.displayedMemory),null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},t.prototype.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},t}(),dr=function(){function t(e,r,i){ut(this,t),this.field=e||1,this.outputs=[r,i],this.channels=[new ur(1,r),new ur(2,i)],this.currChNr=-1,this.lastCmdA=null,this.lastCmdB=null,this.bufferedData=[],this.startTime=null,this.lastTime=null,this.dataCounters={padding:0,char:0,cmd:0,other:0}}return t.prototype.getHandler=function(t){return this.channels[t].getHandler()},t.prototype.setHandler=function(t,e){this.channels[t].setHandler(e)},t.prototype.addData=function(t,e){var r,i,a,n=!1;this.lastTime=t,ir.setTime(t);for(var o=0;o ("+ar([i,a])+")"),r=this.parseCmd(i,a),r||(r=this.parseMidrow(i,a)),r||(r=this.parsePAC(i,a)),r||(r=this.parseBackgroundAttributes(i,a)),!r&&(n=this.parseChars(i,a)))if(this.currChNr&&this.currChNr>=0){var s=this.channels[this.currChNr-1];s.insertChars(n)}else ir.log("WARNING","No channel found yet. TEXT-MODE?");r?this.dataCounters.cmd+=2:n?this.dataCounters.char+=2:(this.dataCounters.other+=2,ir.log("WARNING","Couldn't parse cleaned data "+ar([i,a])+" orig: "+ar([e[o],e[o+1]])))}else this.dataCounters.padding+=2},t.prototype.parseCmd=function(t,e){var r=null,i=(20===t||28===t)&&32<=e&&e<=47,a=(23===t||31===t)&&33<=e&&e<=35;if(!i&&!a)return!1;if(t===this.lastCmdA&&e===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,ir.log("DEBUG","Repeated command ("+ar([t,e])+") is dropped"),!0;r=20===t||23===t?1:2;var n=this.channels[r-1];return 20===t||28===t?32===e?n.ccRCL():33===e?n.ccBS():34===e?n.ccAOF():35===e?n.ccAON():36===e?n.ccDER():37===e?n.ccRU(2):38===e?n.ccRU(3):39===e?n.ccRU(4):40===e?n.ccFON():41===e?n.ccRDC():42===e?n.ccTR():43===e?n.ccRTD():44===e?n.ccEDM():45===e?n.ccCR():46===e?n.ccENM():47===e&&n.ccEOC():n.ccTO(e-32),this.lastCmdA=t,this.lastCmdB=e,this.currChNr=r,!0},t.prototype.parseMidrow=function(t,e){var r=null;if((17===t||25===t)&&32<=e&&e<=47){if(r=17===t?1:2,r!==this.currChNr)return ir.log("ERROR","Mismatch channel in midrow parsing"),!1;var i=this.channels[r-1];return i.ccMIDROW(e),ir.log("DEBUG","MIDROW ("+ar([t,e])+")"),!0}return!1},t.prototype.parsePAC=function(t,e){var r=null,i=null,a=(17<=t&&t<=23||25<=t&&t<=31)&&64<=e&&e<=127,n=(16===t||24===t)&&64<=e&&e<=95;if(!a&&!n)return!1;if(t===this.lastCmdA&&e===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,!0;r=t<=23?1:2,i=64<=e&&e<=95?1===r?$e[t]:tr[t]:1===r?Ze[t]:er[t];var o=this.interpretPAC(i,e),s=this.channels[r-1];return s.setPAC(o),this.lastCmdA=t,this.lastCmdB=e,this.currChNr=r,!0},t.prototype.interpretPAC=function(t,e){var r=e,i={color:null,italics:!1,indent:null,underline:!1,row:t};return r=e>95?e-96:e-64,i.underline=1===(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},t.prototype.parseChars=function(t,e){var r=null,i=null,a=null;if(t>=25?(r=2,a=t-8):(r=1,a=t),17<=a&&a<=19){var n=e;n=17===a?e+80:18===a?e+112:e+144,ir.log("INFO","Special char '"+Xe(n)+"' in channel "+r),i=[n]}else 32<=t&&t<=127&&(i=0===e?[t]:[t,e]);if(i){var o=ar(i);ir.log("DEBUG","Char codes = "+o.join(",")),this.lastCmdA=null,this.lastCmdB=null}return i},t.prototype.parseBackgroundAttributes=function(t,e){var r,i,a,n,o=(16===t||24===t)&&32<=e&&e<=47,s=(23===t||31===t)&&45<=e&&e<=47;return!(!o&&!s)&&(r={},16===t||24===t?(i=Math.floor((e-32)/2),r.background=rr[i],e%2===1&&(r.background=r.background+"_semi")):45===e?r.background="transparent":(r.foreground="black",47===e&&(r.underline=!0)),a=t<24?1:2,n=this.channels[a-1],n.setBkgData(r),this.lastCmdA=null,this.lastCmdB=null,!0)},t.prototype.reset=function(){for(var t=0;t9?parseInt(t.substr(0,t.indexOf(":"))):0;return isNaN(e)||isNaN(r)||isNaN(i)||isNaN(a)?-1:(e+=1e3*r,e+=6e4*i,e+=36e5*a)},pr=function t(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()},gr=function(t,e,r){var i=t[e],a=t[i.prevCC];if(!a||!a.new&&i.new)return t.ccOffset=t.presentationOffset=i.start,void(i.new=!1);for(;a&&a.new;)t.ccOffset+=i.start-a.start,i.new=!1,i=a,a=t[i.prevCC];t.presentationOffset=r},vr={parse:function(t,e,r,i,a,n){var o=/\r\n|\n\r|\n|\r/g,s=String.fromCharCode.apply(null,new Uint8Array(t)).trim().replace(o,"\n").split("\n"),l="00:00.000",u=0,d=0,c=0,f=[],h=void 0,p=!0,g=new Ye;g.oncue=function(t){var e=r[i],a=r.ccOffset;e&&e.new&&(void 0!==d?a=r.ccOffset=e.start:gr(r,i,c)),c&&(a=c+r.ccOffset-r.presentationOffset),t.startTime+=a-d,t.endTime+=a-d,t.id=pr(t.startTime)+pr(t.endTime)+pr(t.text),t.text=decodeURIComponent(escape(t.text)),t.endTime>0&&f.push(t)},g.onparsingerror=function(t){h=t},g.onflush=function(){return h&&n?void n(h):void a(f)},s.forEach(function(t){if(p){if(fr(t,"X-TIMESTAMP-MAP=")){p=!1,t.substr(16).split(",").forEach(function(t){fr(t,"LOCAL:")?l=t.substr(6):fr(t,"MPEGTS:")&&(u=parseInt(t.substr(7)))});try{e=e<0?e+8589934592:e,u-=e,d=hr(l)/1e3,c=u/9e4,d===-1&&(h=new Error("Malformed X-TIMESTAMP-MAP: "+t))}catch(e){h=new Error("Malformed X-TIMESTAMP-MAP: "+t)}return}""===t&&(p=!1)}g.parse(t+"\n")}),g.flush()}},mr=vr,yr=function(t){function e(r){dt(this,e);var i=ct(this,t.call(this,r,Lt.a.MEDIA_ATTACHING,Lt.a.MEDIA_DETACHING,Lt.a.FRAG_PARSING_USERDATA,Lt.a.MANIFEST_LOADING,Lt.a.MANIFEST_LOADED,Lt.a.FRAG_LOADED,Lt.a.LEVEL_SWITCHING,Lt.a.INIT_PTS_FOUND));if(i.hls=r,i.config=r.config,i.enabled=!0,i.Cues=r.config.cueHandler,i.textTracks=[],i.tracks=[],i.unparsedVttFrags=[],i.initPTS=void 0,i.cueRanges=[],i.config.enableCEA708Captions){var a=i,n=function(t,e){var r=null;try{r=new window.Event("addtrack")}catch(t){r=document.createEvent("Event"),r.initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)},o={newCue:function(t,e,r){if(!a.textTrack1){var i=a.getExistingTrack("1");if(i)a.textTrack1=i,ht(a.textTrack1),n(a.textTrack1,a.media);else{var o=a.createTextTrack("captions",a.config.captionsTextTrack1Label,a.config.captionsTextTrack1LanguageCode);o&&(o.textTrack1=!0,a.textTrack1=o)}}a.addCues("textTrack1",t,e,r)}},s={newCue:function(t,e,r){if(!a.textTrack2){var i=a.getExistingTrack("2");if(i)a.textTrack2=i,ht(a.textTrack2),n(a.textTrack2,a.media);else{var o=a.createTextTrack("captions",a.config.captionsTextTrack2Label,a.config.captionsTextTrack1LanguageCode);o&&(o.textTrack2=!0,a.textTrack2=o)}}a.addCues("textTrack2",t,e,r)}};i.cea608Parser=new cr(0,o,s)}return i}return ft(e,t),e.prototype.addCues=function(t,e,r,i){for(var a=this.cueRanges,n=!1,o=a.length;o--;){var s=a[o],l=gt(s[0],s[1],e,r);if(l>=0&&(s[0]=Math.min(s[0],e),s[1]=Math.max(s[1],r),n=!0,l/(r-e)>.5))return}n||a.push([e,r]),this.Cues.newCue(this[t],e,r,i)},e.prototype.onInitPtsFound=function(t){var e=this;"undefined"==typeof this.initPTS&&(this.initPTS=t.initPTS),this.unparsedVttFrags.length&&(this.unparsedVttFrags.forEach(function(t){e.onFragLoaded(t)}),this.unparsedVttFrags=[])},e.prototype.getExistingTrack=function(t){var e=this.media;if(e)for(var r=0;r=0&&t-1&&this.vttFragQueues[this.currentTrackId].length){var t=this.currentlyProcessing=this.vttFragQueues[this.currentTrackId].shift();this.hls.trigger(Lt.a.FRAG_LOADING,{frag:t})}},e.prototype.onSubtitleFragProcessed=function(t){t.success&&this.vttFragSNsProcessed[t.frag.trackId].push(t.frag.sn),this.currentlyProcessing=null,this.nextFrag()},e.prototype.onError=function(t){var e=t.frag;e&&"subtitle"!==e.type||this.currentlyProcessing&&(this.currentlyProcessing=null,this.nextFrag())},e.prototype.onSubtitleTracksUpdated=function(t){var e=this;Dt.b.log("subtitle tracks updated"),this.tracks=t.subtitleTracks,this.clearVttFragQueues(),this.vttFragSNsProcessed={},this.tracks.forEach(function(t){e.vttFragSNsProcessed[t.id]=[]})},e.prototype.onSubtitleTrackSwitch=function(t){this.currentTrackId=t.id,this.clearVttFragQueues()},e.prototype.onSubtitleTrackLoaded=function(t){var e=this.vttFragSNsProcessed[t.id],r=this.vttFragQueues[t.id],i=this.currentlyProcessing?this.currentlyProcessing.sn:-1,a=function(t){return e.indexOf(t.sn)>-1},n=function(t){return r.some(function(e){return e.sn===t.sn})};t.details.fragments.forEach(function(e){a(e)||e.sn===i||n(e)||(e.trackId=t.id,r.push(e))}),this.nextFrag()},e}(Ct),Ar=Sr,wr={autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,maxBufferSize:6e7,maxBufferHole:.5,maxSeekHole:2,lowBufferWatchdogPeriod:.5,highBufferWatchdogPeriod:3,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.2,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,fragLoadingLoopThreshold:3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Fe,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,fetchSetup:void 0,abrController:_e,bufferController:ke,capLevelController:Oe,fpsController:xe,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0};wr.subtitleStreamController=Ar,wr.subtitleTrackController=Rr,wr.timelineController=br,wr.cueHandler=At,wr.enableCEA708Captions=!0,wr.enableWebVTT=!0,wr.captionsTextTrack1Label="English",wr.captionsTextTrack1LanguageCode="en",wr.captionsTextTrack2Label="Spanish",wr.captionsTextTrack2LanguageCode="es",wr.audioStreamController=Ke,wr.audioTrackController=Ue;var _r=function(){function t(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};St(this,t);var i=t.DefaultConfig;if((r.liveSyncDurationCount||r.liveMaxLatencyDurationCount)&&(r.liveSyncDuration||r.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");for(var a in i)a in r||(r[a]=i[a]);if(void 0!==r.liveMaxLatencyDurationCount&&r.liveMaxLatencyDurationCount<=r.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(void 0!==r.liveMaxLatencyDuration&&(r.liveMaxLatencyDuration<=r.liveSyncDuration||void 0===r.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');Object(Dt.a)(r.debug),this.config=r,this._autoLevelCapping=-1;var n=this.observer=new ie.a;n.trigger=function(t){for(var e=arguments.length,r=Array(e>1?e-1:0),i=1;i1?e-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:-1;Dt.b.log("startLoad("+t+")"),this.networkControllers.forEach(function(e){e.startLoad(t)})},t.prototype.stopLoad=function(){Dt.b.log("stopLoad"),this.networkControllers.forEach(function(t){t.stopLoad()})},t.prototype.swapAudioCodec=function(){Dt.b.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.prototype.recoverMediaError=function(){Dt.b.log("recoverMediaError");var t=this.media;this.detachMedia(),this.attachMedia(t)},_r(t,[{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){Dt.b.log("set currentLevel:"+t),this.loadLevel=t,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){Dt.b.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){Dt.b.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){Dt.b.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){Dt.b.log("set startLevel:"+t);var e=this;t!==-1&&(t=Math.max(t,e.minAutoLevel)),e.levelController.startLevel=t}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){Dt.b.log("set autoLevelCapping:"+t),this._autoLevelCapping=t}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){for(var t=this,e=t.levels,r=t.config.minAutoBitrate,i=e?e.length:0,a=0;ar)return a}return 0}},{key:"maxAutoLevel",get:function(){var t=this,e=t.levels,r=t.autoLevelCapping,i=void 0;return i=r===-1&&e&&e.length?e.length-1:r}},{key:"nextAutoLevel",get:function(){var t=this;return Math.min(Math.max(t.abrController.nextAutoLevel,t.minAutoLevel),t.maxAutoLevel)},set:function(t){var e=this;e.abrController.nextAutoLevel=Math.max(e.minAutoLevel,t)}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"liveSyncPosition",get:function(){return this.streamController.liveSyncPosition}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}}]),t}();e.default=Lr},function(t,e,r){function i(t){function e(i){if(r[i])return r[i].exports;var a=r[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,e),a.l=!0,a.exports}var r={};e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,i){e.o(t,r)||Object.defineProperty(t,r,{
configurable:!1,enumerable:!0,get:i})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e.oe=function(t){throw console.error(t),t};var i=e(e.s=ENTRY_MODULE);return i.default||i}function a(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function n(t){var e=[],r=t.toString(),i=r.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!i)return e;for(var n,o=i[1],s=new RegExp("(\\\\n|\\W)"+a(o)+"\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\w|/|@]+).*?\\)","g");n=s.exec(r);)e.push(n[3]);return e}function o(t,e){for(var r=[e],i=[],a={};r.length;){var o=r.pop();if(!a[o]&&t[o]){a[o]=!0,i.push(o);var s=n(t[o]);r=r.concat(s)}}return i}t.exports=function(t,e){e=e||{};var a=r.m,n=e.all?Object.keys(a):o(a,t),s="("+i.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+n.map(function(t){return""+JSON.stringify(t)+": "+a[t].toString()}).join(",")+"})(self);",l=new window.Blob([s],{type:"text/javascript"});if(e.bare)return l;var u=window.URL||window.webkitURL||window.mozURL||window.msURL,d=u.createObjectURL(l),c=new window.Worker(d);return c.objectURL=d,c}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=r(6),a=r(1),n=r(0),o=r(4),s=r.n(o),l=function(t){var e=new s.a;e.trigger=function(t){for(var r=arguments.length,i=Array(r>1?r-1:0),a=1;a1?r-1:0),a=1;a57343)a.push(n);else if(56320<=n&&n<=57343)a.push(65533);else if(55296<=n&&n<=56319)if(i===r-1)a.push(65533);else{var o=e.charCodeAt(i+1);if(56320<=o&&o<=57343){var s=1023&n,l=1023&o;a.push(65536+(s<<10)+l),i+=1}else a.push(65533)}i+=1}return a}function o(t){for(var e="",r=0;r>10)+55296,(1023&i)+56320))}return e}function s(t){return 0<=t&&t<=127}function l(t){this.tokens=[].slice.call(t),this.tokens.reverse()}function u(t,e){if(t)throw TypeError("Decoder error");return e||65533}function d(t){throw TypeError("The code point "+t+" could not be encoded.")}function c(){}function f(){}function h(t){return t=String(t).trim().toLowerCase(),Object.prototype.hasOwnProperty.call(X,t)?X[t]:null}function p(t,e){return e?e[t]||null:null}function g(t,e){var r=e.indexOf(t);return r===-1?null:r}function v(t){if(!("encoding-indexes"in e))throw Error("Indexes missing. Did you forget to include encoding-indexes.js first?");return e["encoding-indexes"][t]}function m(t){if(t>39419&&t<189e3||t>1237575)return null;if(7457===t)return 59335;var e,r=0,i=0,a=v("gb18030-ranges");for(e=0;e>6*i)+a];i>0;){var o=e>>6*(i-1);n.push(128|63&o),i-=1}return n}}function w(t,e){var r=e.fatal;this.handler=function(e,i){if(i===q)return Y;if(s(i))return i;var a=t[i-128];return null===a?u(r):a}}function _(t,e){e.fatal;this.handler=function(e,r){if(r===q)return Y;if(V(r))return r;var i=g(r,t);return null===i&&d(r),i+128}}function L(t){var e=t.fatal,i=0,a=0,n=0;this.handler=function(t,o){if(o===q&&0===i&&0===a&&0===n)return Y;o!==q||0===i&&0===a&&0===n||(i=0,a=0,n=0,u(e));var l;if(0!==n){l=null,r(o,48,57)&&(l=m(10*(126*(10*(i-129)+a-48)+n-129)+o-48));var d=[a,n,o];return i=0,a=0,n=0,null===l?(t.prepend(d),u(e)):l}if(0!==a)return r(o,129,254)?(n=o,null):(t.prepend([a,o]),i=0,a=0,u(e));if(0!==i){if(r(o,48,57))return a=o,null;var c=i,f=null;i=0;var h=o<127?64:65;return(r(o,64,126)||r(o,128,254))&&(f=190*(c-129)+(o-h)),l=null===f?null:p(f,v("gb18030")),null===l&&s(o)&&t.prepend(o),null===l?u(e):l}return s(o)?o:128===o?8364:r(o,129,254)?(i=o,null):u(e)}}function k(t,e){t.fatal;this.handler=function(t,r){if(r===q)return Y;if(V(r))return r;if(58853===r)return d(r);if(e&&8364===r)return 128;var i=g(r,v("gb18030"));if(null!==i){var a=W(i/190)+129,n=i%190,o=n<63?64:65;return[a,n+o]}if(e)return d(r);i=y(r);var s=W(i/10/126/10);i-=10*s*126*10;var l=W(i/10/126);i-=10*l*126;var u=W(i/10),c=i-10*u;return[s+129,l+48,u+129,c+48]}}function D(t){var e=t.fatal,i=0;this.handler=function(t,a){if(a===q&&0!==i)return i=0,u(e);if(a===q&&0===i)return Y;if(0!==i){var n=i,o=null;i=0;var l=a<127?64:98;switch((r(a,64,126)||r(a,161,254))&&(o=157*(n-129)+(a-l)),o){case 1133:return[202,772];case 1135:return[202,780];case 1164:return[234,772];case 1166:return[234,780]}var d=null===o?null:p(o,v("big5"));return null===d&&s(a)&&t.prepend(a),null===d?u(e):d}return s(a)?a:r(a,129,254)?(i=a,null):u(e)}}function I(t){t.fatal;this.handler=function(t,e){if(e===q)return Y;if(V(e))return e;var r=E(e);if(null===r)return d(e);var i=W(r/157)+129;if(i<161)return d(e);var a=r%157,n=a<63?64:98;return[i,a+n]}}function O(t){var e=t.fatal,i=!1,a=0;this.handler=function(t,n){if(n===q&&0!==a)return a=0,u(e);if(n===q&&0===a)return Y;if(142===a&&r(n,161,223))return a=0,65216+n;if(143===a&&r(n,161,254))return i=!0,a=n,null;if(0!==a){var o=a;a=0;var l=null;return r(o,161,254)&&r(n,161,254)&&(l=p(94*(o-161)+(n-161),v(i?"jis0212":"jis0208"))),i=!1,r(n,161,254)||t.prepend(n),null===l?u(e):l}return s(n)?n:142===n||143===n||r(n,161,254)?(a=n,null):u(e)}}function C(t){t.fatal;this.handler=function(t,e){if(e===q)return Y;if(V(e))return e;if(165===e)return 92;if(8254===e)return 126;if(r(e,65377,65439))return[142,e-65377+161];8722===e&&(e=65293);var i=g(e,v("jis0208"));if(null===i)return d(e);var a=W(i/94)+161,n=i%94+161;return[a,n]}}function x(t){var e=t.fatal,i={ASCII:0,Roman:1,Katakana:2,LeadByte:3,TrailByte:4,EscapeStart:5,Escape:6},a=i.ASCII,n=i.ASCII,o=0,s=!1;this.handler=function(t,l){switch(a){default:case i.ASCII:return 27===l?(a=i.EscapeStart,null):r(l,0,127)&&14!==l&&15!==l&&27!==l?(s=!1,l):l===q?Y:(s=!1,u(e));case i.Roman:return 27===l?(a=i.EscapeStart,null):92===l?(s=!1,165):126===l?(s=!1,8254):r(l,0,127)&&14!==l&&15!==l&&27!==l&&92!==l&&126!==l?(s=!1,l):l===q?Y:(s=!1,u(e));case i.Katakana:return 27===l?(a=i.EscapeStart,null):r(l,33,95)?(s=!1,65344+l):l===q?Y:(s=!1,u(e));case i.LeadByte:return 27===l?(a=i.EscapeStart,null):r(l,33,126)?(s=!1,o=l,a=i.TrailByte,null):l===q?Y:(s=!1,u(e));case i.TrailByte:if(27===l)return a=i.EscapeStart,u(e);if(r(l,33,126)){a=i.LeadByte;var d=94*(o-33)+l-33,c=p(d,v("jis0208"));return null===c?u(e):c}return l===q?(a=i.LeadByte,t.prepend(l),u(e)):(a=i.LeadByte,u(e));case i.EscapeStart:return 36===l||40===l?(o=l,a=i.Escape,null):(t.prepend(l),s=!1,a=n,u(e));case i.Escape:var f=o;o=0;var h=null;if(40===f&&66===l&&(h=i.ASCII),40===f&&74===l&&(h=i.Roman),40===f&&73===l&&(h=i.Katakana),36!==f||64!==l&&66!==l||(h=i.LeadByte),null!==h){a=a=h;var g=s;return s=!0,g?u(e):null}return t.prepend([f,l]),s=!1,a=n,u(e)}}}function P(t){var e=(t.fatal,{ASCII:0,Roman:1,jis0208:2}),r=e.ASCII;this.handler=function(t,i){if(i===q&&r!==e.ASCII)return t.prepend(i),r=e.ASCII,[27,40,66];if(i===q&&r===e.ASCII)return Y;if(!(r!==e.ASCII&&r!==e.Roman||14!==i&&15!==i&&27!==i))return d(65533);if(r===e.ASCII&&V(i))return i;if(r===e.Roman&&(V(i)&&92!==i&&126!==i||165==i||8254==i)){if(V(i))return i;if(165===i)return 92;if(8254===i)return 126}if(V(i)&&r!==e.ASCII)return t.prepend(i),r=e.ASCII,[27,40,66];if((165===i||8254===i)&&r!==e.Roman)return t.prepend(i),r=e.Roman,[27,40,74];8722===i&&(i=65293);var a=g(i,v("jis0208"));if(null===a)return d(i);if(r!==e.jis0208)return t.prepend(i),r=e.jis0208,[27,36,66];var n=W(a/94)+33,o=a%94+33;return[n,o]}}function F(t){var e=t.fatal,i=0;this.handler=function(t,a){if(a===q&&0!==i)return i=0,u(e);if(a===q&&0===i)return Y;if(0!==i){var n=i,o=null;i=0;var l=a<127?64:65,d=n<160?129:193;if((r(a,64,126)||r(a,128,252))&&(o=188*(n-d)+a-l),r(o,8836,10715))return 48508+o;var c=null===o?null:p(o,v("jis0208"));return null===c&&s(a)&&t.prepend(a),null===c?u(e):c}return s(a)||128===a?a:r(a,161,223)?65216+a:r(a,129,159)||r(a,224,252)?(i=a,null):u(e)}}function N(t){t.fatal;this.handler=function(t,e){if(e===q)return Y;if(V(e)||128===e)return e;if(165===e)return 92;if(8254===e)return 126;if(r(e,65377,65439))return e-65377+161;8722===e&&(e=65293);var i=b(e);if(null===i)return d(e);var a=W(i/188),n=a<31?129:193,o=i%188,s=o<63?64:65;return[a+n,o+s]}}function M(t){var e=t.fatal,i=0;this.handler=function(t,a){if(a===q&&0!==i)return i=0,u(e);if(a===q&&0===i)return Y;if(0!==i){var n=i,o=null;i=0,r(a,65,254)&&(o=190*(n-129)+(a-65));var l=null===o?null:p(o,v("euc-kr"));return null===o&&s(a)&&t.prepend(a),null===l?u(e):l}return s(a)?a:r(a,129,254)?(i=a,null):u(e)}}function U(t){t.fatal;this.handler=function(t,e){if(e===q)return Y;if(V(e))return e;var r=g(e,v("euc-kr"));if(null===r)return d(e);var i=W(r/190)+129,a=r%190+65;return[i,a]}}function B(t,e){var r=t>>8,i=255&t;return e?[r,i]:[i,r]}function G(t,e){var i=e.fatal,a=null,n=null;this.handler=function(e,o){if(o===q&&(null!==a||null!==n))return u(i);if(o===q&&null===a&&null===n)return Y;if(null===a)return a=o,null;var s;if(s=t?(a<<8)+o:(o<<8)+a,a=null,null!==n){var l=n;return n=null,r(s,56320,57343)?65536+1024*(l-55296)+(s-56320):(e.prepend(B(s,t)),u(i))}return r(s,55296,56319)?(n=s,null):r(s,56320,57343)?u(i):s}}function j(t,e){e.fatal;this.handler=function(e,i){if(i===q)return Y;if(r(i,0,65535))return B(i,t);var a=B((i-65536>>10)+55296,t),n=B((i-65536&1023)+56320,t);return a.concat(n)}}function K(t){t.fatal;this.handler=function(t,e){return e===q?Y:s(e)?e:63360+e-128}}function H(t){t.fatal;this.handler=function(t,e){return e===q?Y:V(e)?e:r(e,63360,63487)?e-63360+128:d(e)}}var W=Math.floor,V=s,q=-1;l.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.pop():q},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.pop());else this.tokens.push(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.shift());else this.tokens.unshift(t)}};var Y=-1;c.prototype={handler:function(t,e){}},f.prototype={handler:function(t,e){}};var z=[{encodings:[{labels:["unicode-1-1-utf-8","utf-8","utf8"],name:"UTF-8"}],heading:"The Encoding"},{encodings:[{labels:["866","cp866","csibm866","ibm866"],name:"IBM866"},{labels:["csisolatin2","iso-8859-2","iso-ir-101","iso8859-2","iso88592","iso_8859-2","iso_8859-2:1987","l2","latin2"],name:"ISO-8859-2"},{labels:["csisolatin3","iso-8859-3","iso-ir-109","iso8859-3","iso88593","iso_8859-3","iso_8859-3:1988","l3","latin3"],name:"ISO-8859-3"},{labels:["csisolatin4","iso-8859-4","iso-ir-110","iso8859-4","iso88594","iso_8859-4","iso_8859-4:1988","l4","latin4"],name:"ISO-8859-4"},{labels:["csisolatincyrillic","cyrillic","iso-8859-5","iso-ir-144","iso8859-5","iso88595","iso_8859-5","iso_8859-5:1988"],name:"ISO-8859-5"},{labels:["arabic","asmo-708","csiso88596e","csiso88596i","csisolatinarabic","ecma-114","iso-8859-6","iso-8859-6-e","iso-8859-6-i","iso-ir-127","iso8859-6","iso88596","iso_8859-6","iso_8859-6:1987"],name:"ISO-8859-6"},{labels:["csisolatingreek","ecma-118","elot_928","greek","greek8","iso-8859-7","iso-ir-126","iso8859-7","iso88597","iso_8859-7","iso_8859-7:1987","sun_eu_greek"],name:"ISO-8859-7"},{labels:["csiso88598e","csisolatinhebrew","hebrew","iso-8859-8","iso-8859-8-e","iso-ir-138","iso8859-8","iso88598","iso_8859-8","iso_8859-8:1988","visual"],name:"ISO-8859-8"},{labels:["csiso88598i","iso-8859-8-i","logical"],name:"ISO-8859-8-I"},{labels:["csisolatin6","iso-8859-10","iso-ir-157","iso8859-10","iso885910","l6","latin6"],name:"ISO-8859-10"},{labels:["iso-8859-13","iso8859-13","iso885913"],name:"ISO-8859-13"},{labels:["iso-8859-14","iso8859-14","iso885914"],name:"ISO-8859-14"},{labels:["csisolatin9","iso-8859-15","iso8859-15","iso885915","iso_8859-15","l9"],name:"ISO-8859-15"},{labels:["iso-8859-16"],name:"ISO-8859-16"},{labels:["cskoi8r","koi","koi8","koi8-r","koi8_r"],name:"KOI8-R"},{labels:["koi8-ru","koi8-u"],name:"KOI8-U"},{labels:["csmacintosh","mac","macintosh","x-mac-roman"],name:"macintosh"},{labels:["dos-874","iso-8859-11","iso8859-11","iso885911","tis-620","windows-874"],name:"windows-874"},{labels:["cp1250","windows-1250","x-cp1250"],name:"windows-1250"},{labels:["cp1251","windows-1251","x-cp1251"],name:"windows-1251"},{labels:["ansi_x3.4-1968","ascii","cp1252","cp819","csisolatin1","ibm819","iso-8859-1","iso-ir-100","iso8859-1","iso88591","iso_8859-1","iso_8859-1:1987","l1","latin1","us-ascii","windows-1252","x-cp1252"],name:"windows-1252"},{labels:["cp1253","windows-1253","x-cp1253"],name:"windows-1253"},{labels:["cp1254","csisolatin5","iso-8859-9","iso-ir-148","iso8859-9","iso88599","iso_8859-9","iso_8859-9:1989","l5","latin5","windows-1254","x-cp1254"],name:"windows-1254"},{labels:["cp1255","windows-1255","x-cp1255"],name:"windows-1255"},{labels:["cp1256","windows-1256","x-cp1256"],name:"windows-1256"},{labels:["cp1257","windows-1257","x-cp1257"],name:"windows-1257"},{labels:["cp1258","windows-1258","x-cp1258"],name:"windows-1258"},{labels:["x-mac-cyrillic","x-mac-ukrainian"],name:"x-mac-cyrillic"}],heading:"Legacy single-byte encodings"},{encodings:[{labels:["chinese","csgb2312","csiso58gb231280","gb2312","gb_2312","gb_2312-80","gbk","iso-ir-58","x-gbk"],name:"GBK"},{labels:["gb18030"],name:"gb18030"}],heading:"Legacy multi-byte Chinese (simplified) encodings"},{encodings:[{labels:["big5","big5-hkscs","cn-big5","csbig5","x-x-big5"],name:"Big5"}],heading:"Legacy multi-byte Chinese (traditional) encodings"},{encodings:[{labels:["cseucpkdfmtjapanese","euc-jp","x-euc-jp"],name:"EUC-JP"},{labels:["csiso2022jp","iso-2022-jp"],name:"ISO-2022-JP"},{labels:["csshiftjis","ms932","ms_kanji","shift-jis","shift_jis","sjis","windows-31j","x-sjis"],name:"Shift_JIS"}],heading:"Legacy multi-byte Japanese encodings"},{encodings:[{labels:["cseuckr","csksc56011987","euc-kr","iso-ir-149","korean","ks_c_5601-1987","ks_c_5601-1989","ksc5601","ksc_5601","windows-949"],name:"EUC-KR"}],heading:"Legacy multi-byte Korean encodings"},{encodings:[{labels:["csiso2022kr","hz-gb-2312","iso-2022-cn","iso-2022-cn-ext","iso-2022-kr"],name:"replacement"},{labels:["utf-16be"],name:"UTF-16BE"},{labels:["utf-16","utf-16le"],name:"UTF-16LE"},{labels:["x-user-defined"],name:"x-user-defined"}],heading:"Legacy miscellaneous encodings"}],X={};z.forEach(function(t){t.encodings.forEach(function(t){t.labels.forEach(function(e){X[e]=t})})});var Q,J,$={},Z={},tt="utf-8";Object.defineProperty&&(Object.defineProperty(T.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),Object.defineProperty(T.prototype,"fatal",{get:function(){return"fatal"===this._error_mode}}),Object.defineProperty(T.prototype,"ignoreBOM",{get:function(){return this._ignoreBOM}})),T.prototype.decode=function(t,e){function r(t){return!i(["UTF-8","UTF-16LE","UTF-16BE"],this._encoding.name)||this._ignoreBOM||this._BOMseen||(t.length>0&&65279===t[0]?(this._BOMseen=!0,t.shift()):t.length>0&&(this._BOMseen=!0)),o(t)}var n;n="object"==typeof t&&t instanceof ArrayBuffer?new Uint8Array(t):"object"==typeof t&&"buffer"in t&&t.buffer instanceof ArrayBuffer?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(0),e=a(e),this._do_not_flush||(this._decoder=Z[this._encoding.name]({fatal:"fatal"===this._error_mode}),this._BOMseen=!1),this._do_not_flush=Boolean(e.stream);for(var s,u=new l(n),d=[];;){var c=u.read();if(c===q)break;if(s=this._decoder.handler(u,c),s===Y)break;null!==s&&(Array.isArray(s)?d.push.apply(d,s):d.push(s))}if(!this._do_not_flush){do{if(s=this._decoder.handler(u,u.read()),s===Y)break;null!==s&&(Array.isArray(s)?d.push.apply(d,s):d.push(s))}while(!u.endOfStream());this._decoder=null}return r.call(this,d)},Object.defineProperty&&Object.defineProperty(R.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),R.prototype.encode=function(t,e){t=void 0===t?"":String(t),e=a(e),this._do_not_flush||(this._encoder=$[this._encoding.name]({fatal:"fatal"===this._fatal})),this._do_not_flush=Boolean(e.stream);for(var r,i=new l(n(t)),o=[];;){var s=i.read();if(s===q)break;if(r=this._encoder.handler(i,s),r===Y)break;Array.isArray(r)?o.push.apply(o,r):o.push(r)}if(!this._do_not_flush){for(;;){if(r=this._encoder.handler(i,i.read()),r===Y)break;Array.isArray(r)?o.push.apply(o,r):o.push(r)}this._encoder=null}return new Uint8Array(o)},$["UTF-8"]=function(t){return new A(t)},Z["UTF-8"]=function(t){return new S(t)},function(){"encoding-indexes"in e&&z.forEach(function(t){"Legacy single-byte encodings"===t.heading&&t.encodings.forEach(function(t){var e=t.name,r=v(e.toLowerCase());Z[e]=function(t){return new w(r,t)},$[e]=function(t){return new _(r,t)}})})}(),Z.GBK=function(t){return new L(t)},$.GBK=function(t){return new k(t,!0)},$.gb18030=function(t){return new k(t)},Z.gb18030=function(t){return new L(t)},$.Big5=function(t){return new I(t)},Z.Big5=function(t){return new D(t)},$["EUC-JP"]=function(t){return new C(t)},Z["EUC-JP"]=function(t){return new O(t)},$["ISO-2022-JP"]=function(t){return new P(t)},Z["ISO-2022-JP"]=function(t){return new x(t)},$.Shift_JIS=function(t){return new N(t)},Z.Shift_JIS=function(t){return new F(t)},$["EUC-KR"]=function(t){return new U(t)},Z["EUC-KR"]=function(t){return new M(t)},$["UTF-16BE"]=function(t){return new j(!0,t)},Z["UTF-16BE"]=function(t){return new G(!0,t)},$["UTF-16LE"]=function(t){return new j(!1,t)},Z["UTF-16LE"]=function(t){return new G(!1,t)},$["x-user-defined"]=function(t){return new H(t)},Z["x-user-defined"]=function(t){return new K(t)},e.TextEncoder||(e.TextEncoder=R),e.TextDecoder||(e.TextDecoder=T),"undefined"!=typeof t&&t.exports&&(t.exports={TextEncoder:e.TextEncoder,TextDecoder:e.TextDecoder,EncodingIndexes:e["encoding-indexes"]})}(this||{})},function(t,e,r){var i=r(1);i(flowplayer)}]);
/*@
@end
@*/