diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
deleted file mode 100644
index 03d9549..0000000
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/jsLinters/eslint.xml b/.idea/jsLinters/eslint.xml
deleted file mode 100644
index 541945b..0000000
--- a/.idea/jsLinters/eslint.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/public/build/bundle.js b/public/build/bundle.js
index cd52367..9fa66e0 100644
--- a/public/build/bundle.js
+++ b/public/build/bundle.js
@@ -18,4 +18,4 @@ function Je(){return(Je=Object.assign||function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:{};jl(this,t);var r=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),s=n.withCredentials,a=void 0!==s&&s,o=n.handleManifestRedirects,u=void 0!==o&&o;r.srcUrl=e,r.hls_=i,r.withCredentials=a,r.handleManifestRedirects=u;var l=i.options_;if(r.customTagParsers=l&&l.customTagParsers||[],r.customTagMappers=l&&l.customTagMappers||[],!r.srcUrl)throw new Error("A non-empty playlist URL is required");return r.state="HAVE_NOTHING",r.on("mediaupdatetimeout",(function(){"HAVE_METADATA"===r.state&&(r.state="HAVE_CURRENT_METADATA",r.request=r.hls_.xhr({uri:Ml(r.master.uri,r.media().uri),withCredentials:r.withCredentials},(function(e,t){if(r.request)return e?r.playlistRequestError(r.request,r.media(),"HAVE_METADATA"):void r.haveMetadata(r.request,r.media().uri,r.media().id)})))})),r}return Vl(t,e),Fl(t,[{key:"playlistRequestError",value:function(e,t,i){var n=t.uri,r=t.id;this.request=null,i&&(this.state=i),this.error={playlist:this.master.playlists[r],status:e.status,message:"HLS playlist request error at URL: "+n+".",responseText:e.responseText,code:e.status>=500?4:2},this.trigger("error")}},{key:"haveMetadata",value:function(e,t,i){var n=this;this.request=null,this.state="HAVE_METADATA";var r=new st;this.customTagParsers.forEach((function(e){return r.addParser(e)})),this.customTagMappers.forEach((function(e){return r.addTagMapper(e)})),r.push(e.responseText),r.end(),r.manifest.uri=t,r.manifest.id=i,r.manifest.attributes=r.manifest.attributes||{};var s=Xl(this.master,r.manifest);this.targetDuration=r.manifest.targetDuration,s?(this.master=s,this.media_=this.master.playlists[i]):this.trigger("playlistunchanged"),this.media().endList||(ee.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=ee.setTimeout((function(){n.trigger("mediaupdatetimeout")}),Jl(this.media(),!!s))),this.trigger("loadedplaylist")}},{key:"dispose",value:function(){this.trigger("dispose"),this.stopRequest(),ee.clearTimeout(this.mediaUpdateTimeout),ee.clearTimeout(this.finalRenditionTimeout),this.off()}},{key:"stopRequest",value:function(){if(this.request){var e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}},{key:"media",value:function(e,t){var i=this;if(!e)return this.media_;if("HAVE_NOTHING"===this.state)throw new Error("Cannot switch media playlist from "+this.state);if("string"==typeof e){if(!this.master.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.master.playlists[e]}if(ee.clearTimeout(this.finalRenditionTimeout),t){var n=e.targetDuration/2*1e3||5e3;this.finalRenditionTimeout=ee.setTimeout(this.media.bind(this,e,!1),n)}else{var r=this.state,s=!this.media_||e.id!==this.media_.id;if(this.master.playlists[e.id].endList)return this.request&&(this.request.onreadystatechange=null,this.request.abort(),this.request=null),this.state="HAVE_METADATA",this.media_=e,void(s&&(this.trigger("mediachanging"),this.trigger("mediachange")));if(s){if(this.state="SWITCHING_MEDIA",this.request){if(e.resolvedUri===this.request.url)return;this.request.onreadystatechange=null,this.request.abort(),this.request=null}this.media_&&this.trigger("mediachanging"),this.request=this.hls_.xhr({uri:e.resolvedUri,withCredentials:this.withCredentials},(function(t,n){if(i.request){if(e.resolvedUri=Bl(i.handleManifestRedirects,e.resolvedUri,n),t)return i.playlistRequestError(i.request,e,r);i.haveMetadata(n,e.uri,e.id),"HAVE_MASTER"===r?i.trigger("loadedmetadata"):i.trigger("mediachange")}}))}}}},{key:"pause",value:function(){this.stopRequest(),ee.clearTimeout(this.mediaUpdateTimeout),"HAVE_NOTHING"===this.state&&(this.started=!1),"SWITCHING_MEDIA"===this.state?this.media_?this.state="HAVE_METADATA":this.state="HAVE_MASTER":"HAVE_CURRENT_METADATA"===this.state&&(this.state="HAVE_METADATA")}},{key:"load",value:function(e){var t=this;ee.clearTimeout(this.mediaUpdateTimeout);var i=this.media();if(e){var n=i?i.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=ee.setTimeout((function(){return t.load()}),n)}else this.started?i&&!i.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist"):this.start()}},{key:"start",value:function(){var e=this;this.started=!0,this.request=this.hls_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},(function(t,i){if(e.request){if(e.request=null,t)return e.error={status:i.status,message:"HLS playlist request error at URL: "+e.srcUrl+".",responseText:i.responseText,code:2},"HAVE_NOTHING"===e.state&&(e.started=!1),e.trigger("error");var n=new st;if(e.customTagParsers.forEach((function(e){return n.addParser(e)})),e.customTagMappers.forEach((function(e){return n.addTagMapper(e)})),n.push(i.responseText),n.end(),e.state="HAVE_MASTER",e.srcUrl=Bl(e.handleManifestRedirects,e.srcUrl,i),n.manifest.uri=e.srcUrl,n.manifest.playlists)return e.master=n.manifest,Yl(e.master),Ql(e.master),e.trigger("loadedplaylist"),void(e.request||e.media(n.manifest.playlists[0]));var r=Kl(0,e.srcUrl);return e.master={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:ee.location.href,playlists:[{uri:e.srcUrl,id:r,resolvedUri:e.srcUrl,attributes:{}}]},e.master.playlists[r]=e.master.playlists[0],e.master.playlists[e.srcUrl]=e.master.playlists[0],e.haveMetadata(i,e.srcUrl,r),e.trigger("loadedmetadata")}}))}}]),t}(zl),ec=Nl.createTimeRange,tc=function(e,t,i){var n,r;return void 0===t&&(t=e.mediaSequence+e.segments.length),ti){var r=[i,t];t=r[0],i=r[1]}if(t<0){for(var s=t;s=r););return Math.max(0,i)},sc=function(e,t,i,n){if(!e||!e.segments)return null;if(e.endList)return ic(e);if(null===t)return null;t=t||0;var r=i?rc(e,n):e.segments.length;return tc(e,e.mediaSequence+r,t)},ac=function(e){return e-Math.floor(e)==0},oc=function(e,t){if(ac(t))return t+.1*e;for(var i=t.toString().split(".")[1].length,n=1;n<=i;n++){var r=Math.pow(10,n),s=t*r;if(ac(s)||n===i)return(s+e)/r}},uc=oc.bind(null,1),lc=oc.bind(null,-1),cc=function(e){return e.excludeUntil&&e.excludeUntil>Date.now()},hc=function(e){return e.excludeUntil&&e.excludeUntil===1/0},dc=function(e){var t=cc(e);return!e.disabled&&!t},pc=function(e,t){return t.attributes&&t.attributes[e]},fc=function(e,t){if(1===e.playlists.length)return!0;var i=t.attributes.BANDWIDTH||Number.MAX_VALUE;return 0===e.playlists.filter((function(e){return!!dc(e)&&(e.attributes.BANDWIDTH||0)0)for(r=i-1;r>=0;r--)if(s=e.segments[r],(o+=lc(s.duration))>0)return{mediaIndex:r,startTime:n-nc(e,i,r)};return{mediaIndex:0,startTime:t}}if(i<0){for(r=i;r<0;r++)if((o-=e.targetDuration)<0)return{mediaIndex:0,startTime:t};i=0}for(r=i;r3&&void 0!==arguments[3]?arguments[3]:0;if(!pc("BANDWIDTH",i))return NaN;var r=e*i.attributes.BANDWIDTH;return(r-8*n)/t},isLowestEnabledRendition:fc},gc=Nl.xhr,vc=Nl.mergeOptions,yc=function(){return function e(t,i){t=vc({timeout:45e3},t);var n=e.beforeRequest||Nl.Hls.xhr.beforeRequest;if(n&&"function"==typeof n){var r=n(t);r&&(t=r)}var s=gc(t,(function(e,t){var n=s.response;!e&&n&&(s.responseTime=Date.now(),s.roundTripTime=s.responseTime-s.requestTime,s.bytesReceived=n.byteLength||n.length,s.bandwidth||(s.bandwidth=Math.floor(s.bytesReceived/s.roundTripTime*8*1e3))),t.headers&&(s.responseHeaders=t.headers),e&&"ETIMEDOUT"===e.code&&(s.timedout=!0),e||s.aborted||200===t.statusCode||206===t.statusCode||0===t.statusCode||(e=new Error("XHR Failed with a response of: "+(s&&(n||s.responseText)))),i(e,s)})),a=s.abort;return s.abort=function(){return s.aborted=!0,a.apply(s,arguments)},s.uri=t.uri,s.requestTime=Date.now(),s}},_c=function(e){var t,i,n={};return e.byterange&&(n.Range=(t=e.byterange,i=t.offset+t.length-1,"bytes="+t.offset+"-"+i)),n},bc=function(e,t){return e.start(t)+"-"+e.end(t)},Tc=function(e,t){var i=e.toString(16);return"00".substring(0,2-i.length)+i+(t%2?" ":"")},Sc=function(e){return e>=32&&e<126?String.fromCharCode(e):"."},kc=function(e){var t={};return Object.keys(e).forEach((function(i){var n=e[i];ArrayBuffer.isView(n)?t[i]={bytes:n.buffer,byteOffset:n.byteOffset,byteLength:n.byteLength}:t[i]=n})),t},Cc=function(e){var t=e.byterange||{length:1/0,offset:0};return[t.length,t.offset,e.resolvedUri].join(",")},wc=function(e){return e.resolvedUri},Ec=function(e){for(var t=Array.prototype.slice.call(e),i="",n=0;ni){if(e>i+.25*s.duration)return null;n=s}return{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:i-n.duration,type:n.videoTimingInfo?"accurate":"estimate"}}(n,t);if(!s)return r({message:"valid programTime was not found"});if("estimate"===s.type)return r({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:s.estimatedStart});var a={mediaSeconds:n},o=function(e,t){if(!t.dateTimeObject)return null;var i=t.videoTimingInfo.transmuxerPrependedSeconds,n=e-(t.videoTimingInfo.transmuxedPresentationStart+i);return new Date(t.dateTimeObject.getTime()+1e3*n)}(n,s.segment);return o&&(a.programDateTime=o.toISOString()),r(null,a)},Ic=function e(t){var i=t.programTime,n=t.playlist,r=t.retryCount,s=void 0===r?2:r,a=t.seekTo,o=t.pauseAfterSeek,u=void 0===o||o,l=t.tech,c=t.callback;if(!c)throw new Error("seekToProgramTime: callback must be provided");if(void 0===i||!n||!a)return c({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!n.endList&&!l.hasStarted_)return c({message:"player must be playing a live stream to start buffering"});if(!function(e){if(!e.segments||0===e.segments.length)return!1;for(var t=0;tnew Date(o.getTime()+1e3*u)?null:(i>o&&(n=a),{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:mc.duration(t,t.mediaSequence+t.segments.indexOf(n)),type:n.videoTimingInfo?"accurate":"estimate"})}(i,n);if(!h)return c({message:i+" was not found in the stream"});var d=h.segment,p=function(e,t){var i=void 0,n=void 0;try{i=new Date(e),n=new Date(t)}catch(e){}var r=i.getTime();return(n.getTime()-r)/1e3}(d.dateTimeObject,i);if("estimate"===h.type)return 0===s?c({message:i+" is not buffered yet. Try again"}):(a(h.estimatedStart+p),void l.one("seeked",(function(){e({programTime:i,playlist:n,retryCount:s-1,seekTo:a,pauseAfterSeek:u,tech:l,callback:c})})));var f=d.start+p;l.one("seeked",(function(){return c(null,l.currentTime())})),u&&l.pause(),a(f)},Pc=function(e,t){var i=[],n=void 0;if(e&&e.length)for(n=0;n=t}))},Oc=function(e,t){return Pc(e,(function(e){return e-1/30>=t}))},Dc=function(e){var t=[];if(!e||!e.length)return"";for(var i=0;i "+e.end(i));return t.join(", ")},Nc=function(e){for(var t=[],i=0;i=e&&i.removeCue(r)},Uc=function(e){return isNaN(e)||Math.abs(e)===1/0?Number.MAX_VALUE:e},Mc=function(e,t,i){var n=ee.WebKitDataCue||ee.VTTCue;if(t&&t.forEach((function(e){var t=e.stream;this.inbandTextTracks_[t].addCue(new n(e.startTime+this.timestampOffset,e.endTime+this.timestampOffset,e.text))}),e),i){var r=Uc(e.mediaSource_.duration);if(i.forEach((function(e){var t=e.cueTime+this.timestampOffset;!("number"!=typeof t||ee.isNaN(t)||t<0)&&t<1/0&&e.frames.forEach((function(e){var i=new n(t,t,e.value||e.url||e.data||"");i.frame=e,i.value=e,function(e){Object.defineProperties(e.frame,{id:{get:function(){return Nl.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),e.value.key}},value:{get:function(){return Nl.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),e.value.data}},privateData:{get:function(){return Nl.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),e.value.data}}})}(i),this.metadataTrack_.addCue(i)}),this)}),e),e.metadataTrack_&&e.metadataTrack_.cues&&e.metadataTrack_.cues.length){for(var s=e.metadataTrack_.cues,a=[],o=0;o-1)},this.trigger=function(t){var i,n,r,s;if(i=e[t])if(2===arguments.length)for(r=i.length,n=0;n>>1,e.samplingfrequencyindex<<7|e.channelcount<<3,6,1,2]))},g=function(e){return t(k.hdlr,I[e])},m=function(e){var i=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,e.duration>>>24&255,e.duration>>>16&255,e.duration>>>8&255,255&e.duration,85,196,0,0]);return e.samplerate&&(i[12]=e.samplerate>>>24&255,i[13]=e.samplerate>>>16&255,i[14]=e.samplerate>>>8&255,i[15]=255&e.samplerate),t(k.mdhd,i)},f=function(e){return t(k.mdia,m(e),g(e.type),o(e))},a=function(e){return t(k.mfhd,new Uint8Array([0,0,0,0,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e]))},o=function(e){return t(k.minf,"video"===e.type?t(k.vmhd,P):t(k.smhd,L),n(),y(e))},u=function(e,i){for(var n=[],r=i.length;r--;)n[r]=b(i[r]);return t.apply(null,[k.moof,a(e)].concat(n))},l=function(e){for(var i=e.length,n=[];i--;)n[i]=d(e[i]);return t.apply(null,[k.moov,h(4294967295)].concat(n).concat(c(e)))},c=function(e){for(var i=e.length,n=[];i--;)n[i]=T(e[i]);return t.apply(null,[k.mvex].concat(n))},h=function(e){var i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return t(k.mvhd,i)},v=function(e){var i,n,r=e.samples||[],s=new Uint8Array(4+r.length);for(n=0;n>>8),a.push(255&r[i].byteLength),a=a.concat(Array.prototype.slice.call(r[i]));for(i=0;i>>8),o.push(255&s[i].byteLength),o=o.concat(Array.prototype.slice.call(s[i]));if(n=[k.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(65280&e.width)>>8,255&e.width,(65280&e.height)>>8,255&e.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),t(k.avcC,new Uint8Array([1,e.profileIdc,e.profileCompatibility,e.levelIdc,255].concat([r.length],a,[s.length],o))),t(k.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],e.sarRatio){var u=e.sarRatio[0],l=e.sarRatio[1];n.push(t(k.pasp,new Uint8Array([(4278190080&u)>>24,(16711680&u)>>16,(65280&u)>>8,255&u,(4278190080&l)>>24,(16711680&l)>>16,(65280&l)>>8,255&l])))}return t.apply(null,n)},B=function(e){return t(k.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(65280&e.channelcount)>>8,255&e.channelcount,(65280&e.samplesize)>>8,255&e.samplesize,0,0,0,0,(65280&e.samplerate)>>8,255&e.samplerate,0,0]),r(e))},p=function(e){var i=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,0,(4278190080&e.duration)>>24,(16711680&e.duration)>>16,(65280&e.duration)>>8,255&e.duration,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,(65280&e.width)>>8,255&e.width,0,0,(65280&e.height)>>8,255&e.height,0,0]);return t(k.tkhd,i)},b=function(e){var i,n,r,s,a,o;return i=t(k.tfhd,new Uint8Array([0,0,0,58,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),a=Math.floor(e.baseMediaDecodeTime/(q+1)),o=Math.floor(e.baseMediaDecodeTime%(q+1)),n=t(k.tfdt,new Uint8Array([1,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,255&a,o>>>24&255,o>>>16&255,o>>>8&255,255&o])),92,"audio"===e.type?(r=S(e,92),t(k.traf,i,n,r)):(s=v(e),r=S(e,s.length+92),t(k.traf,i,n,r,s))},d=function(e){return e.duration=e.duration||4294967295,t(k.trak,p(e),f(e))},T=function(e){var i=new Uint8Array([0,0,0,0,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return"video"!==e.type&&(i[i.length-1]=0),t(k.trex,i)},V=function(e,t){var i=0,n=0,r=0,s=0;return e.length&&(void 0!==e[0].duration&&(i=1),void 0!==e[0].size&&(n=2),void 0!==e[0].flags&&(r=4),void 0!==e[0].compositionTimeOffset&&(s=8)),[0,0,i|n|r|s,1,(4278190080&e.length)>>>24,(16711680&e.length)>>>16,(65280&e.length)>>>8,255&e.length,(4278190080&t)>>>24,(16711680&t)>>>16,(65280&t)>>>8,255&t]},F=function(e,i){var n,r,s,a;for(i+=20+16*(r=e.samples||[]).length,n=V(r,i),a=0;a>>24,(16711680&s.duration)>>>16,(65280&s.duration)>>>8,255&s.duration,(4278190080&s.size)>>>24,(16711680&s.size)>>>16,(65280&s.size)>>>8,255&s.size,s.flags.isLeading<<2|s.flags.dependsOn,s.flags.isDependedOn<<6|s.flags.hasRedundancy<<4|s.flags.paddingValue<<1|s.flags.isNonSyncSample,61440&s.flags.degradationPriority,15&s.flags.degradationPriority,(4278190080&s.compositionTimeOffset)>>>24,(16711680&s.compositionTimeOffset)>>>16,(65280&s.compositionTimeOffset)>>>8,255&s.compositionTimeOffset]);return t(k.trun,new Uint8Array(n))},j=function(e,i){var n,r,s,a;for(i+=20+8*(r=e.samples||[]).length,n=V(r,i),a=0;a>>24,(16711680&s.duration)>>>16,(65280&s.duration)>>>8,255&s.duration,(4278190080&s.size)>>>24,(16711680&s.size)>>>16,(65280&s.size)>>>8,255&s.size]);return t(k.trun,new Uint8Array(n))},S=function(e,t){return"audio"===e.type?j(e,t):F(e,t)};s=function(){return t(k.ftyp,C,w,C,E)};var W,z,$,G,X,K,Y,Q,J=function(e){return t(k.mdat,e)},Z=u,ee=function(e){var t,i=s(),n=l(e);return(t=new Uint8Array(i.byteLength+n.byteLength)).set(i),t.set(n,i.byteLength),t},te=function(e,t){var i={size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}};return i.dataOffset=t,i.compositionTimeOffset=e.pts-e.dts,i.duration=e.duration,i.size=4*e.length,i.size+=e.byteLength,e.keyFrame&&(i.flags.dependsOn=2,i.flags.isNonSyncSample=0),i},ie=function(e){var t,i,n=[],r=[];for(r.byteLength=0,r.nalCount=0,r.duration=0,n.byteLength=0,t=0;t1&&(t=e.shift(),e.byteLength-=t.byteLength,e.nalCount-=t.nalCount,e[0][0].dts=t.dts,e[0][0].pts=t.pts,e[0][0].duration+=t.duration),e},se=function(e,t){var i,n,r,s,a,o=t||0,u=[];for(i=0;ide/2))){for((a=he[e.samplerate])||(a=t[0].data),o=0;o=i?e:(t.minSegmentDts=1/0,e.filter((function(e){return e.dts>=i&&(t.minSegmentDts=Math.min(t.minSegmentDts,e.dts),t.minSegmentPts=t.minSegmentDts,!0)})))},ye=function(e){var t,i,n=[];for(t=0;t>>8,r=255&t,t!==this.PADDING_)if(t===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(t===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(e.pts),this.flushDisplayed(e.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,this.startPts_=e.pts;else if(t===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(e.pts);else if(t===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(e.pts);else if(t===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(e.pts);else if(t===this.CARRIAGE_RETURN_)this.clearFormatting(e.pts),this.flushDisplayed(e.pts),this.shiftRowsUp_(),this.startPts_=e.pts;else if(t===this.BACKSPACE_)"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1);else if(t===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(e.pts),this.displayed_=Oe();else if(t===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Oe();else if(t===this.RESUME_DIRECT_CAPTIONING_)"paintOn"!==this.mode_&&(this.flushDisplayed(e.pts),this.displayed_=Oe()),this.mode_="paintOn",this.startPts_=e.pts;else if(this.isSpecialCharacter(n,r))s=Pe((n=(3&n)<<8)|r),this[this.mode_](e.pts,s),this.column_++;else if(this.isExtCharacter(n,r))"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),s=Pe((n=(3&n)<<8)|r),this[this.mode_](e.pts,s),this.column_++;else if(this.isMidRowCode(n,r))this.clearFormatting(e.pts),this[this.mode_](e.pts," "),this.column_++,14==(14&r)&&this.addFormatting(e.pts,["i"]),1==(1&r)&&this.addFormatting(e.pts,["u"]);else if(this.isOffsetControlCode(n,r))this.column_+=3&r;else if(this.isPAC(n,r)){var a=Le.indexOf(7968&t);"rollUp"===this.mode_&&(a-this.rollUpRows_+1<0&&(a=this.rollUpRows_-1),this.setRollUp(e.pts,a)),a!==this.row_&&(this.clearFormatting(e.pts),this.row_=a),1&r&&-1===this.formatting_.indexOf("u")&&this.addFormatting(e.pts,["u"]),16==(16&t)&&(this.column_=4*((14&t)>>1)),this.isColorPAC(r)&&14==(14&r)&&this.addFormatting(e.pts,["i"])}else this.isNormalChar(n)&&(0===r&&(r=null),s=Pe(n),s+=Pe(r),this[this.mode_](e.pts,s),this.column_+=s.length)}else this.lastControlCode_=null}};De.prototype=new H,De.prototype.flushDisplayed=function(e){var t=this.displayed_.map((function(e){try{return e.trim()}catch(e){return console.error("Skipping malformed caption."),""}})).join("\n").replace(/^\n+|\n+$/g,"");t.length&&this.trigger("data",{startPts:this.startPts_,endPts:e,text:t,stream:this.name_})},De.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=Oe(),this.nonDisplayed_=Oe(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.rollUpRows_=2,this.formatting_=[]},De.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_},De.prototype.isSpecialCharacter=function(e,t){return e===this.EXT_&&t>=48&&t<=63},De.prototype.isExtCharacter=function(e,t){return(e===this.EXT_+1||e===this.EXT_+2)&&t>=32&&t<=63},De.prototype.isMidRowCode=function(e,t){return e===this.EXT_&&t>=32&&t<=47},De.prototype.isOffsetControlCode=function(e,t){return e===this.OFFSET_&&t>=33&&t<=35},De.prototype.isPAC=function(e,t){return e>=this.BASE_&&e=64&&t<=127},De.prototype.isColorPAC=function(e){return e>=64&&e<=79||e>=96&&e<=127},De.prototype.isNormalChar=function(e){return e>=32&&e<=127},De.prototype.setRollUp=function(e,t){if("rollUp"!==this.mode_&&(this.row_=14,this.mode_="rollUp",this.flushDisplayed(e),this.nonDisplayed_=Oe(),this.displayed_=Oe()),void 0!==t&&t!==this.row_)for(var i=0;i"}),"");this[this.mode_](e,i)},De.prototype.clearFormatting=function(e){if(this.formatting_.length){var t=this.formatting_.reverse().reduce((function(e,t){return e+""+t+">"}),"");this.formatting_=[],this[this.mode_](e,t)}},De.prototype.popOn=function(e,t){var i=this.nonDisplayed_[this.row_];i+=t,this.nonDisplayed_[this.row_]=i},De.prototype.rollUp=function(e,t){var i=this.displayed_[this.row_];i+=t,this.displayed_[this.row_]=i},De.prototype.shiftRowsUp_=function(){var e;for(e=0;et&&(i=-1);Math.abs(t-e)>4294967296;)e+=8589934592*i;return e},Me=function e(t){var i,n;e.prototype.init.call(this),this.type_=t||"shared",this.push=function(e){"shared"!==this.type_&&e.type!==this.type_||(void 0===n&&(n=e.dts),e.dts=Ue(e.dts,n),e.pts=Ue(e.pts,n),i=e.dts,this.trigger("data",e))},this.flush=function(){n=i,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){n=void 0,i=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};Me.prototype=new H;var Be,je=Me,Fe=function(e,t,i){var n,r="";for(n=t;n>>2;h*=4,h+=3&c[7],u.timeStamp=h,void 0===t.pts&&void 0===t.dts&&(t.pts=u.timeStamp,t.dts=u.timeStamp),this.trigger("timestamp",u)}t.frames.push(u),a+=10,a+=o}while(a>>4>1&&(n+=t[n]+1),0===i.pid)i.type="pat",e(t.subarray(n),i),this.trigger("data",i);else if(i.pid===this.pmtPid)for(i.type="pmt",e(t.subarray(n),i),this.trigger("data",i);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else void 0===this.programMapTable?this.packetsWaitingForPmt.push([t,n,i]):this.processPes_(t,n,i)},this.processPes_=function(e,t,i){i.pid===this.programMapTable.video?i.streamType=Re.H264_STREAM_TYPE:i.pid===this.programMapTable.audio?i.streamType=Re.ADTS_STREAM_TYPE:i.streamType=this.programMapTable["timed-metadata"][i.pid],i.type="pes",i.data=e.subarray(t),this.trigger("data",i)}}).prototype=new H,ze.STREAM_TYPES={h264:27,adts:15},($e=function(){var e,t=this,i={data:[],size:0},n={data:[],size:0},r={data:[],size:0},s=function(e,i,n){var r,s,a=new Uint8Array(e.size),o={type:i},u=0,l=0;if(e.data.length&&!(e.size<9)){for(o.trackId=e.data[0].pid,u=0;u>>3,h.pts*=4,h.pts+=(6&c[13])>>>1,h.dts=h.pts,64&d&&(h.dts=(14&c[14])<<27|(255&c[15])<<20|(254&c[16])<<12|(255&c[17])<<5|(254&c[18])>>>3,h.dts*=4,h.dts+=(6&c[18])>>>1)),h.data=c.subarray(9+c[8]),r="video"===i||o.packetLength<=e.size,(n||r)&&(e.size=0,e.data.length=0),r&&t.trigger("data",o)}};$e.prototype.init.call(this),this.push=function(a){({pat:function(){},pes:function(){var e,t;switch(a.streamType){case Re.H264_STREAM_TYPE:case Re.H264_STREAM_TYPE:e=i,t="video";break;case Re.ADTS_STREAM_TYPE:e=n,t="audio";break;case Re.METADATA_STREAM_TYPE:e=r,t="timed-metadata";break;default:return}a.payloadUnitStartIndicator&&s(e,t,!0),e.data.push(a),e.size+=a.data.byteLength},pmt:function(){var i={type:"metadata",tracks:[]};null!==(e=a.programMapTable).video&&i.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+e.video,codec:"avc",type:"video"}),null!==e.audio&&i.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+e.audio,codec:"adts",type:"audio"}),t.trigger("data",i)}})[a.type]()},this.reset=function(){i.size=0,i.data.length=0,n.size=0,n.data.length=0,this.trigger("reset")},this.flushStreams_=function(){s(i,"video"),s(n,"audio"),s(r,"timed-metadata")},this.flush=function(){this.flushStreams_(),this.trigger("done")}}).prototype=new H;var Ke={PAT_PID:0,MP2T_PACKET_LENGTH:188,TransportPacketStream:We,TransportParseStream:ze,ElementaryStream:$e,TimestampRolloverStream:Xe,CaptionStream:Ne.CaptionStream,Cea608Stream:Ne.Cea608Stream,MetadataStream:Ge};for(var Ye in Re)Re.hasOwnProperty(Ye)&&(Ke[Ye]=Re[Ye]);var Qe,Je=Ke,Ze=de,et=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];(Qe=function(e){var t,i=0;Qe.prototype.init.call(this),this.push=function(n){var r,s,a,o,u,l,c=0;if(e||(i=0),"audio"===n.type)for(t?(o=t,(t=new Uint8Array(o.byteLength+n.data.byteLength)).set(o),t.set(n.data,o.byteLength)):t=n.data;c+5>5,l=(u=1024*(1+(3&t[c+6])))*Ze/et[(60&t[c+2])>>>2],a=c+r,t.byteLength>>6&3),channelcount:(1&t[c+2])<<2|(192&t[c+3])>>>6,samplerate:et[(60&t[c+2])>>>2],samplingfrequencyindex:(60&t[c+2])>>>2,samplesize:16,data:t.subarray(c+7+s,a)}),i++,t.byteLength===a)return void(t=void 0);t=t.subarray(a)}else c++},this.flush=function(){i=0,this.trigger("done")},this.reset=function(){t=void 0,this.trigger("reset")},this.endTimeline=function(){t=void 0,this.trigger("endedtimeline")}}).prototype=new H;var tt,it,nt,rt=Qe,st=function(e){var t=e.byteLength,i=0,n=0;this.length=function(){return 8*t},this.bitsAvailable=function(){return 8*t+n},this.loadWord=function(){var r=e.byteLength-t,s=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");s.set(e.subarray(r,r+a)),i=new DataView(s.buffer).getUint32(0),n=8*a,t-=a},this.skipBits=function(e){var r;n>e?(i<<=e,n-=e):(e-=n,e-=8*(r=Math.floor(e/8)),t-=r,this.loadWord(),i<<=e,n-=e)},this.readBits=function(e){var r=Math.min(n,e),s=i>>>32-r;return(n-=r)>0?i<<=r:t>0&&this.loadWord(),(r=e-r)>0?s<>>e))return i<<=e,n-=e,e;return this.loadWord(),e+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var e=this.skipLeadingZeros();return this.readBits(e+1)-1},this.readExpGolomb=function(){var e=this.readUnsignedExpGolomb();return 1&e?1+e>>>1:-1*(e>>>1)},this.readBoolean=function(){return 1===this.readBits(1)},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};(it=function(){var e,t,i=0;it.prototype.init.call(this),this.push=function(n){var r;t?((r=new Uint8Array(t.byteLength+n.data.byteLength)).set(t),r.set(n.data,t.byteLength),t=r):t=n.data;for(var s=t.byteLength;i3&&this.trigger("data",t.subarray(i+3)),t=null,i=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}}).prototype=new H,nt={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},(tt=function(){var e,t,i,n,r,s,a,o=new it;tt.prototype.init.call(this),e=this,this.push=function(e){"video"===e.type&&(t=e.trackId,i=e.pts,n=e.dts,o.push(e))},o.on("data",(function(a){var o={trackId:t,pts:i,dts:n,data:a};switch(31&a[0]){case 5:o.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:o.nalUnitType="sei_rbsp",o.escapedRBSP=r(a.subarray(1));break;case 7:o.nalUnitType="seq_parameter_set_rbsp",o.escapedRBSP=r(a.subarray(1)),o.config=s(o.escapedRBSP);break;case 8:o.nalUnitType="pic_parameter_set_rbsp";break;case 9:o.nalUnitType="access_unit_delimiter_rbsp"}e.trigger("data",o)})),o.on("done",(function(){e.trigger("done")})),o.on("partialdone",(function(){e.trigger("partialdone")})),o.on("reset",(function(){e.trigger("reset")})),o.on("endedtimeline",(function(){e.trigger("endedtimeline")})),this.flush=function(){o.flush()},this.partialFlush=function(){o.partialFlush()},this.reset=function(){o.reset()},this.endTimeline=function(){o.endTimeline()},a=function(e,t){var i,n=8,r=8;for(i=0;i>4?i+20:i+10},ct=function(e,t){var i=(224&e[t+5])>>5,n=e[t+4]<<3;return 6144&e[t+3]|n|i};(at=function(){var e=new Uint8Array,t=0;at.prototype.init.call(this),this.setTimestamp=function(e){t=e},this.push=function(i){var n,r,s,a,o=0,u=0;for(e.length?(a=e.length,(e=new Uint8Array(i.byteLength+a)).set(e.subarray(0,a)),e.set(i,a)):e=i;e.length-u>=3;)if(e[u]!=="I".charCodeAt(0)||e[u+1]!=="D".charCodeAt(0)||e[u+2]!=="3".charCodeAt(0))if(255!=(255&e[u])||240!=(240&e[u+1]))u++;else{if(e.length-u<7)break;if(u+(o=ct(e,u))>e.length)break;s={type:"audio",data:e.subarray(u,u+o),pts:t,dts:t},this.trigger("data",s),u+=o}else{if(e.length-u<10)break;if(u+(o=lt(e,u))>e.length)break;r={type:"timed-metadata",data:e.subarray(u,u+o)},this.trigger("data",r),u+=o}n=e.length-u,e=n>0?e.subarray(u):new Uint8Array},this.reset=function(){e=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){e=new Uint8Array,this.trigger("endedtimeline")}}).prototype=new H;var ht,dt,pt,ft,mt=at,gt=ot.H264Stream,vt=ut,yt=de,_t=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],bt=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],Tt=function(e,t){var i;if(e.length!==t.length)return!1;for(i=0;i=-1e4&&i<=45e3&&(!n||o>i)&&(n=s,o=i));return n?n.gop:null},this.alignGopsAtStart_=function(e){var t,i,n,r,s,o,u,l;for(s=e.byteLength,o=e.nalCount,u=e.duration,t=i=0;tn.pts?t++:(i++,s-=r.byteLength,o-=r.nalCount,u-=r.duration);return 0===i?e:i===e.length?null:((l=e.slice(i)).byteLength=s,l.duration=u,l.nalCount=o,l.pts=l[0].pts,l.dts=l[0].dts,l)},this.alignGopsAtEnd_=function(e){var t,i,n,r,s,o,u;for(t=a.length-1,i=e.length-1,s=null,o=!1;t>=0&&i>=0;){if(n=a[t],r=e[i],n.pts===r.pts){o=!0;break}n.pts>r.pts?t--:(t===a.length-1&&(s=i),i--)}if(!o&&null===s)return null;if(0===(u=o?i:s))return e;var l=e.slice(u),c=l.reduce((function(e,t){return e.byteLength+=t.byteLength,e.duration+=t.duration,e.nalCount+=t.nalCount,e}),{byteLength:0,duration:0,nalCount:0});return l.byteLength=c.byteLength,l.duration=c.duration,l.nalCount=c.nalCount,l.pts=l[0].pts,l.dts=l[0].dts,l},this.alignGopsWith=function(e){a=e}}).prototype=new H,(ft=function(e,t){this.numberOfTracks=0,this.metadataStream=t,void 0!==(e=e||{}).remux?this.remuxTracks=!!e.remux:this.remuxTracks=!0,"boolean"==typeof e.keepOriginalTimestamps?this.keepOriginalTimestamps=e.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,ft.prototype.init.call(this),this.push=function(e){return e.text?this.pendingCaptions.push(e):e.frames?this.pendingMetadata.push(e):(this.pendingTracks.push(e.track),this.pendingBytes+=e.boxes.byteLength,"video"===e.track.type&&(this.videoTrack=e.track,this.pendingBoxes.push(e.boxes)),void("audio"===e.track.type&&(this.audioTrack=e.track,this.pendingBoxes.unshift(e.boxes))))}}).prototype=new H,ft.prototype.flush=function(e){var t,i,n,r,s=0,a={captions:[],captionStreams:{},metadata:[],info:{}},o=0;if(this.pendingTracks.length=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0))}if(this.videoTrack?(o=this.videoTrack.timelineStartInfo.pts,bt.forEach((function(e){a.info[e]=this.videoTrack[e]}),this)):this.audioTrack&&(o=this.audioTrack.timelineStartInfo.pts,_t.forEach((function(e){a.info[e]=this.audioTrack[e]}),this)),this.videoTrack||this.audioTrack){for(1===this.pendingTracks.length?a.type=this.pendingTracks[0].type:a.type="combined",this.emittedTracks+=this.pendingTracks.length,n=ee(this.pendingTracks),a.initSegment=new Uint8Array(n.byteLength),a.initSegment.set(n),a.data=new Uint8Array(this.pendingBytes),r=0;r=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},ft.prototype.setRemux=function(e){this.remuxTracks=e},(pt=function(e){var t,i,n=this,r=!0;pt.prototype.init.call(this),e=e||{},this.baseMediaDecodeTime=e.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var r={};this.transmuxPipeline_=r,r.type="aac",r.metadataStream=new Je.MetadataStream,r.aacStream=new mt,r.audioTimestampRolloverStream=new Je.TimestampRolloverStream("audio"),r.timedMetadataTimestampRolloverStream=new Je.TimestampRolloverStream("timed-metadata"),r.adtsStream=new rt,r.coalesceStream=new ft(e,r.metadataStream),r.headOfPipeline=r.aacStream,r.aacStream.pipe(r.audioTimestampRolloverStream).pipe(r.adtsStream),r.aacStream.pipe(r.timedMetadataTimestampRolloverStream).pipe(r.metadataStream).pipe(r.coalesceStream),r.metadataStream.on("timestamp",(function(e){r.aacStream.setTimestamp(e.timeStamp)})),r.aacStream.on("data",(function(s){"timed-metadata"!==s.type||r.audioSegmentStream||(i=i||{timelineStartInfo:{baseMediaDecodeTime:n.baseMediaDecodeTime},codec:"adts",type:"audio"},r.coalesceStream.numberOfTracks++,r.audioSegmentStream=new dt(i,e),r.audioSegmentStream.on("timingInfo",n.trigger.bind(n,"audioTimingInfo")),r.adtsStream.pipe(r.audioSegmentStream).pipe(r.coalesceStream)),n.trigger("trackinfo",{hasAudio:!!i,hasVideo:!!t})})),r.coalesceStream.on("data",this.trigger.bind(this,"data")),r.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setupTsPipeline=function(){var r={};this.transmuxPipeline_=r,r.type="ts",r.metadataStream=new Je.MetadataStream,r.packetStream=new Je.TransportPacketStream,r.parseStream=new Je.TransportParseStream,r.elementaryStream=new Je.ElementaryStream,r.timestampRolloverStream=new Je.TimestampRolloverStream,r.adtsStream=new rt,r.h264Stream=new gt,r.captionStream=new Je.CaptionStream,r.coalesceStream=new ft(e,r.metadataStream),r.headOfPipeline=r.packetStream,r.packetStream.pipe(r.parseStream).pipe(r.elementaryStream).pipe(r.timestampRolloverStream),r.timestampRolloverStream.pipe(r.h264Stream),r.timestampRolloverStream.pipe(r.adtsStream),r.timestampRolloverStream.pipe(r.metadataStream).pipe(r.coalesceStream),r.h264Stream.pipe(r.captionStream).pipe(r.coalesceStream),r.elementaryStream.on("data",(function(s){var a;if("metadata"===s.type){for(a=s.tracks.length;a--;)t||"video"!==s.tracks[a].type?i||"audio"!==s.tracks[a].type||((i=s.tracks[a]).timelineStartInfo.baseMediaDecodeTime=n.baseMediaDecodeTime):(t=s.tracks[a]).timelineStartInfo.baseMediaDecodeTime=n.baseMediaDecodeTime;t&&!r.videoSegmentStream&&(r.coalesceStream.numberOfTracks++,r.videoSegmentStream=new ht(t,e),r.videoSegmentStream.on("timelineStartInfo",(function(e){i&&(i.timelineStartInfo=e,r.audioSegmentStream.setEarliestDts(e.dts))})),r.videoSegmentStream.on("processedGopsInfo",n.trigger.bind(n,"gopInfo")),r.videoSegmentStream.on("segmentTimingInfo",n.trigger.bind(n,"videoSegmentTimingInfo")),r.videoSegmentStream.on("baseMediaDecodeTime",(function(e){i&&r.audioSegmentStream.setVideoBaseMediaDecodeTime(e)})),r.videoSegmentStream.on("timingInfo",n.trigger.bind(n,"videoTimingInfo")),r.h264Stream.pipe(r.videoSegmentStream).pipe(r.coalesceStream)),i&&!r.audioSegmentStream&&(r.coalesceStream.numberOfTracks++,r.audioSegmentStream=new dt(i,e),r.audioSegmentStream.on("timingInfo",n.trigger.bind(n,"audioTimingInfo")),r.adtsStream.pipe(r.audioSegmentStream).pipe(r.coalesceStream)),n.trigger("trackinfo",{hasAudio:!!i,hasVideo:!!t})}})),r.coalesceStream.on("data",this.trigger.bind(this,"data")),r.coalesceStream.on("id3Frame",(function(e){e.dispatchType=r.metadataStream.dispatchType,n.trigger("id3Frame",e)})),r.coalesceStream.on("caption",this.trigger.bind(this,"caption")),r.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setBaseMediaDecodeTime=function(n){var r=this.transmuxPipeline_;e.keepOriginalTimestamps||(this.baseMediaDecodeTime=n),i&&(i.timelineStartInfo.dts=void 0,i.timelineStartInfo.pts=void 0,Te(i),e.keepOriginalTimestamps||(i.timelineStartInfo.baseMediaDecodeTime=n),r.audioTimestampRolloverStream&&r.audioTimestampRolloverStream.discontinuity()),t&&(r.videoSegmentStream&&(r.videoSegmentStream.gopCache_=[]),t.timelineStartInfo.dts=void 0,t.timelineStartInfo.pts=void 0,Te(t),r.captionStream.reset(),e.keepOriginalTimestamps||(t.timelineStartInfo.baseMediaDecodeTime=n)),r.timestampRolloverStream&&r.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(e){i&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(e)},this.setRemux=function(t){var i=this.transmuxPipeline_;e.remux=t,i&&i.coalesceStream&&i.coalesceStream.setRemux(t)},this.alignGopsWith=function(e){t&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(e)},this.push=function(e){if(r){var t=vt(e);t&&"aac"!==this.transmuxPipeline_.type?this.setupAacPipeline():t||"ts"===this.transmuxPipeline_.type||this.setupTsPipeline(),r=!1}this.transmuxPipeline_.headOfPipeline.push(e)},this.flush=function(){r=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}}).prototype=new H;var kt={Transmuxer:pt,VideoSegmentStream:ht,AudioSegmentStream:dt,AUDIO_PROPERTIES:_t,VIDEO_PROPERTIES:bt,generateVideoSegmentTimingInfo:St},Ct=function(){function e(e,t){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:"",t={codecCount:0},i=void 0;return t.codecCount=e.split(",").length,t.codecCount=t.codecCount||2,(i=/(^|\s|,)+(avc[13])([^ ,]*)/i.exec(e))&&(t.videoCodec=i[2],t.videoObjectTypeIndicator=i[3]),t.audioProfile=/(^|\s|,)+mp4a.[0-9A-Fa-f]+\.([0-9A-Fa-f]+)/i.exec(e),t.audioProfile=t.audioProfile&&t.audioProfile[2],t},Jc=function(e,t,i){return e+"/"+t+'; codecs="'+i.filter((function(e){return!!e})).join(", ")+'"'},Zc=function(e,t){var i=function(e){return e.segments&&e.segments.length&&e.segments[0].map?"mp4":"mp2t"}(t),n=function(e){var t=e.attributes||{};return t.CODECS?Qc(t.CODECS):Kc}(t),r=t.attributes||{},s=!0,a=!1;if(!t)return[];if(e.mediaGroups.AUDIO&&r.AUDIO){var o=e.mediaGroups.AUDIO[r.AUDIO];if(o)for(var u in a=!0,s=!1,o)if(!o[u].uri&&!o[u].playlists){s=!0;break}}a&&!n.audioProfile&&(s||(n.audioProfile=function(e,t){if(!e.mediaGroups.AUDIO||!t)return null;var i=e.mediaGroups.AUDIO[t];if(!i)return null;for(var n in i){var r=i[n];if(r.default&&r.playlists)return Qc(r.playlists[0].attributes.CODECS).audioProfile}return null}(e,r.AUDIO)),n.audioProfile||(Nl.log.warn("Multiple audio tracks present but no audio codec string is specified. Attempting to use the default audio codec (mp4a.40.2)"),n.audioProfile=Kc.audioProfile));var l={};n.videoCodec&&(l.video=""+n.videoCodec+n.videoObjectTypeIndicator),n.audioProfile&&(l.audio="mp4a.40."+n.audioProfile);var c=Jc("audio",i,[l.audio]),h=Jc("video",i,[l.video]),d=Jc("video",i,[l.video,l.audio]);return a?!s&&l.video?[h,c]:s||l.video?[d,c]:[c,c]:l.video?[d]:[c]},eh=function(e){var t={type:"",parameters:{}},i=e.trim().split(";");return t.type=i.shift().trim(),i.forEach((function(e){var i=e.trim().split("=");if(i.length>1){var n=i[0].replace(/"/g,"").trim(),r=i[1].replace(/"/g,"").trim();t.parameters[n]=r}})),t},th=function(e){return/mp4a\.\d+.\d+/i.test(e)},ih=function(e){return/avc1\.[\da-f]+/i.test(e)},nh=function(e,t,i){if(null==t||!e.length)return[];var n=Math.ceil(9e4*(t-i+3)),r=void 0;for(r=0;rn);r++);return e.slice(r)},rh=function(e){function t(e,i){jl(this,t);var n=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,Nl.EventTarget));n.timestampOffset_=0,n.pendingBuffers_=[],n.bufferUpdating_=!1,n.mediaSource_=e,n.codecs_=i,n.audioCodec_=null,n.videoCodec_=null,n.audioDisabled_=!1,n.appendAudioInitSegment_=!0,n.gopBuffer_=[],n.timeMapping_=0,n.safeAppend_=Nl.browser.IE_VERSION>=11;var r={remux:!1,alignGopsAtEnd:n.safeAppend_};return n.codecs_.forEach((function(e){th(e)?n.audioCodec_=e:ih(e)&&(n.videoCodec_=e)})),n.transmuxer_=new Xc,n.transmuxer_.postMessage({action:"init",options:r}),n.transmuxer_.onmessage=function(e){return"data"===e.data.action?n.data_(e):"done"===e.data.action?n.done_(e):"gopInfo"===e.data.action?n.appendGopInfo_(e):"videoSegmentTimingInfo"===e.data.action?n.videoSegmentTimingInfo_(e.data.videoSegmentTimingInfo):void 0},Object.defineProperty(n,"timestampOffset",{get:function(){return this.timestampOffset_},set:function(e){"number"==typeof e&&e>=0&&(this.timestampOffset_=e,this.appendAudioInitSegment_=!0,this.gopBuffer_.length=0,this.timeMapping_=0,this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:e}))}}),Object.defineProperty(n,"appendWindowStart",{get:function(){return(this.videoBuffer_||this.audioBuffer_).appendWindowStart},set:function(e){this.videoBuffer_&&(this.videoBuffer_.appendWindowStart=e),this.audioBuffer_&&(this.audioBuffer_.appendWindowStart=e)}}),Object.defineProperty(n,"updating",{get:function(){return!!(this.bufferUpdating_||!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.updating||this.videoBuffer_&&this.videoBuffer_.updating)}}),Object.defineProperty(n,"buffered",{get:function(){return function(e,t,i){var n=null,r=null,s=0,a=[],o=[];if(!e&&!t)return Nl.createTimeRange();if(!e)return t.buffered;if(!t)return e.buffered;if(i)return e.buffered;if(0===e.buffered.length&&0===t.buffered.length)return Nl.createTimeRange();for(var u=e.buffered,l=t.buffered,c=u.length;c--;)a.push({time:u.start(c),type:"start"}),a.push({time:u.end(c),type:"end"});for(c=l.length;c--;)a.push({time:l.start(c),type:"start"}),a.push({time:l.end(c),type:"end"});for(a.sort((function(e,t){return e.time-t.time})),c=0;c=n);r++);return e.slice(0,r).concat(t)}(this.gopBuffer_,e.data.gopInfo,this.safeAppend_)}},{key:"remove",value:function(e,t){if(this.videoBuffer_&&(this.videoBuffer_.updating=!0,this.videoBuffer_.remove(e,t),this.gopBuffer_=function(e,t,i,n){for(var r=Math.ceil(9e4*(t-n)),s=Math.ceil(9e4*(i-n)),a=e.slice(),o=e.length;o--&&!(e[o].pts<=s););if(-1===o)return a;for(var u=o+1;u--&&!(e[u].pts<=r););return u=Math.max(u,0),a.splice(u,o-u+1),a}(this.gopBuffer_,e,t,this.timeMapping_)),!this.audioDisabled_&&this.audioBuffer_&&(this.audioBuffer_.updating=!0,this.audioBuffer_.remove(e,t)),Rc(e,t,this.metadataTrack_),this.inbandTextTracks_)for(var i in this.inbandTextTracks_)Rc(e,t,this.inbandTextTracks_[i])}},{key:"processPendingSegments_",value:function(){var e={video:{segments:[],bytes:0},audio:{segments:[],bytes:0},captions:[],metadata:[]};if(!this.pendingBuffers_.length)return this.trigger("updateend"),void(this.bufferUpdating_=!1);e=this.pendingBuffers_.reduce((function(e,t){var i=t.type,n=t.data,r=t.initSegment;return e[i].segments.push(n),e[i].bytes+=n.byteLength,e[i].initSegment=r,t.captions&&(e.captions=e.captions.concat(t.captions)),t.info&&(e[i].info=t.info),t.metadata&&(e.metadata=e.metadata.concat(t.metadata)),e}),e),this.videoBuffer_||this.audioBuffer_||(0===e.video.bytes&&(this.videoCodec_=null),0===e.audio.bytes&&(this.audioCodec_=null),this.createRealSourceBuffers_()),e.audio.info&&this.mediaSource_.trigger({type:"audioinfo",info:e.audio.info}),e.video.info&&this.mediaSource_.trigger({type:"videoinfo",info:e.video.info}),this.appendAudioInitSegment_&&(!this.audioDisabled_&&this.audioBuffer_&&(e.audio.segments.unshift(e.audio.initSegment),e.audio.bytes+=e.audio.initSegment.byteLength),this.appendAudioInitSegment_=!1);var t=!1;this.videoBuffer_&&e.video.bytes?(e.video.segments.unshift(e.video.initSegment),e.video.bytes+=e.video.initSegment.byteLength,this.concatAndAppendSegments_(e.video,this.videoBuffer_)):!this.videoBuffer_||!this.audioDisabled_&&this.audioBuffer_||(t=!0),Mc(this,e.captions,e.metadata),!this.audioDisabled_&&this.audioBuffer_&&this.concatAndAppendSegments_(e.audio,this.audioBuffer_),this.pendingBuffers_.length=0,t&&this.trigger("updateend"),this.bufferUpdating_=!1}},{key:"concatAndAppendSegments_",value:function(e,t){var i=0,n=void 0;if(e.bytes){n=new Uint8Array(e.bytes),e.segments.forEach((function(e){n.set(e,i),i+=e.byteLength}));try{t.updating=!0,t.appendBuffer(n)}catch(e){this.mediaSource_.player_&&this.mediaSource_.player_.error({code:-3,type:"APPEND_BUFFER_ERR",message:e.message,originalError:e})}}}},{key:"abort",value:function(){this.videoBuffer_&&this.videoBuffer_.abort(),!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:"reset"}),this.pendingBuffers_.length=0,this.bufferUpdating_=!1}},{key:"dispose",value:function(){this.transmuxer_&&this.transmuxer_.terminate(),this.trigger("dispose"),this.off()}}]),t}(Nl.EventTarget),sh=function(e){function t(){jl(this,t);var e=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),i=void 0;for(i in e.nativeMediaSource_=new ee.MediaSource,e.nativeMediaSource_)i in t.prototype||"function"!=typeof e.nativeMediaSource_[i]||(e[i]=e.nativeMediaSource_[i].bind(e.nativeMediaSource_));return e.duration_=NaN,Object.defineProperty(e,"duration",{get:function(){return this.duration_===1/0?this.duration_:this.nativeMediaSource_.duration},set:function(e){this.duration_=e,e===1/0||(this.nativeMediaSource_.duration=e)}}),Object.defineProperty(e,"seekable",{get:function(){return this.duration_===1/0?Nl.createTimeRanges([[0,this.nativeMediaSource_.duration]]):this.nativeMediaSource_.seekable}}),Object.defineProperty(e,"readyState",{get:function(){return this.nativeMediaSource_.readyState}}),Object.defineProperty(e,"activeSourceBuffers",{get:function(){return this.activeSourceBuffers_}}),e.sourceBuffers=[],e.activeSourceBuffers_=[],e.updateActiveSourceBuffers_=function(){if(e.activeSourceBuffers_.length=0,1===e.sourceBuffers.length){var t=e.sourceBuffers[0];return t.appendAudioInitSegment_=!0,t.audioDisabled_=!t.audioCodec_,void e.activeSourceBuffers_.push(t)}for(var i=!1,n=!0,r=0;rthis.nativeMediaSource_.duration||isNaN(this.nativeMediaSource_.duration))&&(this.nativeMediaSource_.duration=t)}},{key:"addSourceBuffer",value:function(e){var t=void 0,i=eh(e);if(/^(video|audio)\/mp2t$/i.test(i.type)){var n=[];i.parameters&&i.parameters.codecs&&(n=i.parameters.codecs.split(","),n=(n=Yc(n)).filter((function(e){return th(e)||ih(e)}))),0===n.length&&(n=["avc1.4d400d","mp4a.40.2"]),t=new rh(this,n),0!==this.sourceBuffers.length&&(this.sourceBuffers[0].createRealSourceBuffers_(),t.createRealSourceBuffers_(),this.sourceBuffers[0].audioDisabled_=!0)}else t=this.nativeMediaSource_.addSourceBuffer(e);return this.sourceBuffers.push(t),t}},{key:"dispose",value:function(){this.trigger("dispose"),this.off(),this.sourceBuffers.forEach((function(e){e.dispose&&e.dispose()})),this.sourceBuffers.length=0}}]),t}(Nl.EventTarget),ah=0;Nl.mediaSources={};var oh=function(e,t){var i=Nl.mediaSources[e];if(!i)throw new Error("Media Source not found (Video.js)");i.trigger({type:"sourceopen",swfId:t})},uh=function(){return!!ee.MediaSource&&!!ee.MediaSource.isTypeSupported&&ee.MediaSource.isTypeSupported('video/mp4;codecs="avc1.4d400d,mp4a.40.2"')},lh=function(){if(this.MediaSource={open:oh,supportsNativeMediaSources:uh},uh())return new sh;throw new Error("Cannot use create a virtual MediaSource for this video")};lh.open=oh,lh.supportsNativeMediaSources=uh;var ch={createObjectURL:function(e){var t=void 0;return e instanceof sh?(t=ee.URL.createObjectURL(e.nativeMediaSource_),e.url_=t,t):e instanceof sh?(t="blob:vjs-media-source/"+ah,ah++,Nl.mediaSources[t]=e,t):(t=ee.URL.createObjectURL(e),e.url_=t,t)}};Nl.MediaSource=lh,Nl.URL=ch;var hh=Nl.EventTarget,dh=Nl.mergeOptions,ph=function(e,t){for(var i=void 0,n=dh(e,{duration:t.duration,minimumUpdatePeriod:t.minimumUpdatePeriod}),r=0;r2&&void 0!==arguments[2]?arguments[2]:{},r=arguments[3];jl(this,t);var s=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),a=n.withCredentials,o=void 0!==a&&a,u=n.handleManifestRedirects,l=void 0!==u&&u;if(s.hls_=i,s.withCredentials=o,s.handleManifestRedirects=l,!e)throw new Error("A non-empty playlist URL or playlist is required");return s.on("minimumUpdatePeriod",(function(){s.refreshXml_()})),s.on("mediaupdatetimeout",(function(){s.refreshMedia_(s.media().id)})),s.state="HAVE_NOTHING",s.loadedPlaylists_={},"string"==typeof e?(s.srcUrl=e,s.sidxMapping_={},Hl(s)):(s.setupChildLoader(r,e),s)}return Vl(t,e),Fl(t,[{key:"setupChildLoader",value:function(e,t){this.masterPlaylistLoader_=e,this.childPlaylist_=t}},{key:"dispose",value:function(){this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},ee.clearTimeout(this.minimumUpdatePeriodTimeout_),ee.clearTimeout(this.mediaRequest_),ee.clearTimeout(this.mediaUpdateTimeout),this.off()}},{key:"hasPendingRequest",value:function(){return this.request||this.mediaRequest_}},{key:"stopRequest",value:function(){if(this.request){var e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}},{key:"sidxRequestFinished_",value:function(e,t,i,n){var r=this;return function(s,a){if(r.request){if(r.request=null,s)return r.error={status:a.status,message:"DASH playlist request error at URL: "+e.uri,response:a.response,code:2},i&&(r.state=i),r.trigger("error"),n(t,null);var o=new Uint8Array(a.response),u=Nn.parseSidx(o.subarray(8));return n(t,u)}}}},{key:"media",value:function(e){var t=this;if(!e)return this.media_;if("HAVE_NOTHING"===this.state)throw new Error("Cannot switch media playlist from "+this.state);var i=this.state;if("string"==typeof e){if(!this.master.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.master.playlists[e]}var n=!this.media_||e.id!==this.media_.id;if(n&&this.loadedPlaylists_[e.id]&&this.loadedPlaylists_[e.id].endList)return this.state="HAVE_METADATA",this.media_=e,void(n&&(this.trigger("mediachanging"),this.trigger("mediachange")));if(n)if(this.media_&&this.trigger("mediachanging"),e.sidx){var r=void 0,s=void 0;this.masterPlaylistLoader_?(r=this.masterPlaylistLoader_.master,s=this.masterPlaylistLoader_.sidxMapping_):(r=this.master,s=this.sidxMapping_);var a=fh(e.sidx);s[a]={sidxInfo:e.sidx},this.request=gh(e.sidx,e,this.hls_.xhr,{handleManifestRedirects:this.handleManifestRedirects},this.sidxRequestFinished_(e,r,i,(function(n,r){if(!n||!r)throw new Error("failed to request sidx");s[a].sidx=r,t.haveMetadata({startingState:i,playlist:n.playlists[e.id]})})))}else this.mediaRequest_=ee.setTimeout(this.haveMetadata.bind(this,{startingState:i,playlist:e}),0)}},{key:"haveMetadata",value:function(e){var t=e.startingState,i=e.playlist;this.state="HAVE_METADATA",this.loadedPlaylists_[i.id]=i,this.mediaRequest_=null,this.refreshMedia_(i.id),"HAVE_MASTER"===t?this.trigger("loadedmetadata"):this.trigger("mediachange")}},{key:"pause",value:function(){this.stopRequest(),ee.clearTimeout(this.mediaUpdateTimeout),ee.clearTimeout(this.minimumUpdatePeriodTimeout_),"HAVE_NOTHING"===this.state&&(this.started=!1)}},{key:"load",value:function(e){var t=this;ee.clearTimeout(this.mediaUpdateTimeout),ee.clearTimeout(this.minimumUpdatePeriodTimeout_);var i=this.media();if(e){var n=i?i.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=ee.setTimeout((function(){return t.load()}),n)}else this.started?i&&!i.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist"):this.start()}},{key:"parseMasterXml",value:function(){var e=kn(this.masterXml_,{manifestUri:this.srcUrl,clientOffset:this.clientOffset_,sidxMapping:this.sidxMapping_});e.uri=this.srcUrl;for(var t=0;t"):function(){}};function _h(){}var bh=function(){function e(t,i,n,r){jl(this,e),this.callbacks_=[],this.pendingCallback_=null,this.timestampOffset_=0,this.mediaSource=t,this.processedAppend_=!1,this.type_=n,this.mimeType_=i,this.logger_=yh("SourceUpdater["+n+"]["+i+"]"),"closed"===t.readyState?t.addEventListener("sourceopen",this.createSourceBuffer_.bind(this,i,r)):this.createSourceBuffer_(i,r)}return Fl(e,[{key:"createSourceBuffer_",value:function(e,t){var i=this;this.sourceBuffer_=this.mediaSource.addSourceBuffer(e),this.logger_("created SourceBuffer"),t&&(t.trigger("sourcebufferadded"),this.mediaSource.sourceBuffers.length<2)?t.on("sourcebufferadded",(function(){i.start_()})):this.start_()}},{key:"start_",value:function(){var e=this;this.started_=!0,this.onUpdateendCallback_=function(){var t=e.pendingCallback_;e.pendingCallback_=null,e.sourceBuffer_.removing=!1,e.logger_("buffered ["+Dc(e.buffered())+"]"),t&&t(),e.runCallback_()},this.sourceBuffer_.addEventListener("updateend",this.onUpdateendCallback_),this.runCallback_()}},{key:"abort",value:function(e){var t=this;this.processedAppend_&&this.queueCallback_((function(){t.sourceBuffer_.abort()}),e)}},{key:"appendBuffer",value:function(e,t){var i=this;this.processedAppend_=!0,this.queueCallback_((function(){e.videoSegmentTimingInfoCallback&&i.sourceBuffer_.addEventListener("videoSegmentTimingInfo",e.videoSegmentTimingInfoCallback),i.sourceBuffer_.appendBuffer(e.bytes)}),(function(){e.videoSegmentTimingInfoCallback&&i.sourceBuffer_.removeEventListener("videoSegmentTimingInfo",e.videoSegmentTimingInfoCallback),t()}))}},{key:"buffered",value:function(){return this.sourceBuffer_?this.sourceBuffer_.buffered:Nl.createTimeRanges()}},{key:"remove",value:function(e,t){var i=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:_h;this.processedAppend_&&this.queueCallback_((function(){i.logger_("remove ["+e+" => "+t+"]"),i.sourceBuffer_.removing=!0,i.sourceBuffer_.remove(e,t)}),n)}},{key:"updating",value:function(){return!this.sourceBuffer_||this.sourceBuffer_.updating||!!this.pendingCallback_&&this.pendingCallback_!==_h}},{key:"timestampOffset",value:function(e){var t=this;return void 0!==e&&(this.queueCallback_((function(){t.sourceBuffer_.timestampOffset=e,t.runCallback_()})),this.timestampOffset_=e),this.timestampOffset_}},{key:"queueCallback_",value:function(e,t){this.callbacks_.push([e.bind(this),t]),this.runCallback_()}},{key:"runCallback_",value:function(){var e=void 0;!this.updating()&&this.callbacks_.length&&this.started_&&(e=this.callbacks_.shift(),this.pendingCallback_=e[1],e[0]())}},{key:"dispose",value:function(){var e=this,t=function t(){e.sourceBuffer_&&"open"===e.mediaSource.readyState&&e.sourceBuffer_.abort(),e.sourceBuffer_.removeEventListener("updateend",t)};this.sourceBuffer_.removeEventListener("updateend",this.onUpdateendCallback_),this.sourceBuffer_.removing?this.sourceBuffer_.addEventListener("updateend",t):t()}}]),e}(),Th={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,BUFFER_LOW_WATER_LINE_RATE:1},Sh=2,kh=-101,Ch=-102,wh=function(e){e.forEach((function(e){e.abort()}))},Eh=function(e,t){return t.timedout?{status:t.status,message:"HLS request timed-out at URL: "+t.uri,code:kh,xhr:t}:t.aborted?{status:t.status,message:"HLS request aborted at URL: "+t.uri,code:Ch,xhr:t}:e?{status:t.status,message:"HLS request errored at URL: "+t.uri,code:Sh,xhr:t}:null},xh=function(e,t,i){var n=0,r=!1;return function(s,a){if(!r)return s?(r=!0,wh(e),i(s,a)):(n+=1)===e.length?(a.endOfAllRequests=Date.now(),a.encryptedBytes?function(e,t,i){e.addEventListener("message",(function n(r){if(r.data.source===t.requestId){e.removeEventListener("message",n);var s=r.data.decrypted;return t.bytes=new Uint8Array(s.bytes,s.byteOffset,s.byteLength),i(null,t)}}));var n=void 0;n=t.key.bytes.slice?t.key.bytes.slice():new Uint32Array(Array.prototype.slice.call(t.key.bytes)),e.postMessage(kc({source:t.requestId,encrypted:t.encryptedBytes,key:n,iv:t.key.iv}),[t.encryptedBytes.buffer,n.buffer])}(t,a,i):i(null,a)):void 0}},Ah=function(e,t){return function(i){var n,r,s;return e.stats=Nl.mergeOptions(e.stats,(r=(n=i).target,(s={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-r.requestTime||0}).bytesReceived=n.loaded,s.bandwidth=Math.floor(s.bytesReceived/s.roundTripTime*8*1e3),s)),!e.stats.firstBytesReceivedAt&&e.stats.bytesReceived&&(e.stats.firstBytesReceivedAt=Date.now()),t(i,e)}},Ih=function(e,t,i,n,r,s,a){var o=[],u=xh(o,i,a);if(r.key&&!r.key.bytes){var l=e(Nl.mergeOptions(t,{uri:r.key.resolvedUri,responseType:"arraybuffer"}),function(e,t){return function(i,n){var r=n.response,s=Eh(i,n);if(s)return t(s,e);if(16!==r.byteLength)return t({status:n.status,message:"Invalid HLS key at URL: "+n.uri,code:Sh,xhr:n},e);var a=new DataView(r);return e.key.bytes=new Uint32Array([a.getUint32(0),a.getUint32(4),a.getUint32(8),a.getUint32(12)]),t(null,e)}}(r,u));o.push(l)}if(r.map&&!r.map.bytes){var c=e(Nl.mergeOptions(t,{uri:r.map.resolvedUri,responseType:"arraybuffer",headers:_c(r.map)}),function(e,t,i){return function(n,r){var s=r.response,a=Eh(n,r);return a?i(a,e):0===s.byteLength?i({status:r.status,message:"Empty HLS segment content at URL: "+r.uri,code:Sh,xhr:r},e):(e.map.bytes=new Uint8Array(r.response),t&&!t.isInitialized()&&t.init(),e.map.timescales=Mn.timescale(e.map.bytes),e.map.videoTrackIds=Mn.videoTrackIds(e.map.bytes),i(null,e))}}(r,n,u));o.push(c)}var h=e(Nl.mergeOptions(t,{uri:r.resolvedUri,responseType:"arraybuffer",headers:_c(r)}),function(e,t,i){return function(n,r){var s=r.response,a=Eh(n,r),o=void 0;return a?i(a,e):0===s.byteLength?i({status:r.status,message:"Empty HLS segment content at URL: "+r.uri,code:Sh,xhr:r},e):(e.stats=function(e){return{bandwidth:e.bandwidth,bytesReceived:e.bytesReceived||0,roundTripTime:e.roundTripTime||0}}(r),e.key?e.encryptedBytes=new Uint8Array(r.response):e.bytes=new Uint8Array(r.response),t&&e.map&&e.map.bytes&&(t.isInitialized()||t.init(),(o=t.parse(e.bytes,e.map.videoTrackIds,e.map.timescales))&&o.captions&&(e.captionStreams=o.captionStreams,e.fmp4Captions=o.captions)),i(null,e))}}(r,n,u));return h.addEventListener("progress",Ah(r,s)),o.push(h),function(){return wh(o)}},Ph=function(e,t){var i;return e&&(i=ee.getComputedStyle(e))?i[t]:""},Lh=function(e,t){var i=e.slice();e.sort((function(e,n){var r=t(e,n);return 0===r?i.indexOf(e)-i.indexOf(n):r}))},Oh=function(e,t){var i=void 0,n=void 0;return e.attributes.BANDWIDTH&&(i=e.attributes.BANDWIDTH),i=i||ee.Number.MAX_VALUE,t.attributes.BANDWIDTH&&(n=t.attributes.BANDWIDTH),i-(n=n||ee.Number.MAX_VALUE)},Dh=function(e,t,i){if(!e||!t)return!1;var n=i===e.segments.length;return e.endList&&"open"===t.readyState&&n},Nh=function(e){return"number"==typeof e&&isFinite(e)},Rh=function(e){function t(e){jl(this,t);var i=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));if(!e)throw new TypeError("Initialization settings are required");if("function"!=typeof e.currentTime)throw new TypeError("No currentTime getter specified");if(!e.mediaSource)throw new TypeError("No MediaSource specified");return i.bandwidth=e.bandwidth,i.throughput={rate:0,count:0},i.roundTrip=NaN,i.resetStats_(),i.mediaIndex=null,i.hasPlayed_=e.hasPlayed,i.currentTime_=e.currentTime,i.seekable_=e.seekable,i.seeking_=e.seeking,i.duration_=e.duration,i.mediaSource_=e.mediaSource,i.hls_=e.hls,i.loaderType_=e.loaderType,i.startingMedia_=void 0,i.segmentMetadataTrack_=e.segmentMetadataTrack,i.goalBufferLength_=e.goalBufferLength,i.sourceType_=e.sourceType,i.inbandTextTracks_=e.inbandTextTracks,i.state_="INIT",i.checkBufferTimeout_=null,i.error_=void 0,i.currentTimeline_=-1,i.pendingSegment_=null,i.mimeType_=null,i.sourceUpdater_=null,i.xhrOptions_=null,i.activeInitSegmentId_=null,i.initSegments_={},i.cacheEncryptionKeys_=e.cacheEncryptionKeys,i.keyCache_={},"main"===i.loaderType_?i.captionParser_=new tr:i.captionParser_=null,i.decrypter_=e.decrypter,i.syncController_=e.syncController,i.syncPoint_={segmentIndex:0,time:0},i.triggerSyncInfoUpdate_=function(){return i.trigger("syncinfoupdate")},i.syncController_.on("syncinfoupdate",i.triggerSyncInfoUpdate_),i.mediaSource_.addEventListener("sourceopen",(function(){return i.ended_=!1})),i.fetchAtBuffer_=!1,i.logger_=yh("SegmentLoader["+i.loaderType_+"]"),Object.defineProperty(i,"state",{get:function(){return this.state_},set:function(e){e!==this.state_&&(this.logger_(this.state_+" -> "+e),this.state_=e)}}),i}return Vl(t,e),Fl(t,[{key:"resetStats_",value:function(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0}},{key:"dispose",value:function(){this.trigger("dispose"),this.state="DISPOSED",this.pause(),this.abort_(),this.sourceUpdater_&&this.sourceUpdater_.dispose(),this.resetStats_(),this.captionParser_&&this.captionParser_.reset(),this.checkBufferTimeout_&&ee.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_),this.off()}},{key:"abort",value:function(){"WAITING"===this.state?(this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()):this.pendingSegment_&&(this.pendingSegment_=null)}},{key:"abort_",value:function(){this.pendingSegment_&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null}},{key:"error",value:function(e){return void 0!==e&&(this.error_=e),this.pendingSegment_=null,this.error_}},{key:"endOfStream",value:function(){this.ended_=!0,this.pause(),this.trigger("ended")}},{key:"buffered_",value:function(){return this.sourceUpdater_?this.sourceUpdater_.buffered():Nl.createTimeRanges()}},{key:"initSegment",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e)return null;var i=Cc(e),n=this.initSegments_[i];return t&&!n&&e.bytes&&(this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,timescales:e.timescales,videoTrackIds:e.videoTrackIds}),n||e}},{key:"segmentKey",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e)return null;var i=wc(e),n=this.keyCache_[i];this.cacheEncryptionKeys_&&t&&!n&&e.bytes&&(this.keyCache_[i]=n={resolvedUri:e.resolvedUri,bytes:e.bytes});var r={resolvedUri:(n||e).resolvedUri};return n&&(r.bytes=n.bytes),r}},{key:"couldBeginLoading_",value:function(){return this.playlist_&&(this.sourceUpdater_||this.mimeType_&&"INIT"===this.state)&&!this.paused()}},{key:"load",value:function(){if(this.monitorBuffer_(),this.playlist_){if(this.syncController_.setDateTimeMapping(this.playlist_),"INIT"===this.state&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||"READY"!==this.state&&"INIT"!==this.state||(this.state="READY")}}},{key:"init_",value:function(){return this.state="READY",this.sourceUpdater_=new bh(this.mediaSource_,this.mimeType_,this.loaderType_,this.sourceBufferEmitter_),this.resetEverything(),this.monitorBuffer_()}},{key:"playlist",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e){var i=this.playlist_,n=this.pendingSegment_;this.playlist_=e,this.xhrOptions_=t,"INIT"===this.state&&(e.syncInfo={mediaSequence:e.mediaSequence,time:0});var r=null;if(i&&(i.id?r=i.id:i.uri&&(r=i.uri)),this.logger_("playlist update ["+r+" => "+(e.id||e.uri)+"]"),this.trigger("syncinfoupdate"),"INIT"===this.state&&this.couldBeginLoading_())return this.init_();if(i&&i.uri===e.uri){var s=e.mediaSequence-i.mediaSequence;this.logger_("live window shift ["+s+"]"),null!==this.mediaIndex&&(this.mediaIndex-=s),n&&(n.mediaIndex-=s,n.mediaIndex>=0&&(n.segment=e.segments[n.mediaIndex])),this.syncController_.saveExpiredSegmentInfo(i,e)}else null!==this.mediaIndex&&this.resyncLoader()}}},{key:"pause",value:function(){this.checkBufferTimeout_&&(ee.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}},{key:"paused",value:function(){return null===this.checkBufferTimeout_}},{key:"mimeType",value:function(e,t){this.mimeType_||(this.mimeType_=e,this.sourceBufferEmitter_=t,"INIT"===this.state&&this.couldBeginLoading_()&&this.init_())}},{key:"resetEverything",value:function(e){this.ended_=!1,this.resetLoader(),this.remove(0,1/0,e),this.captionParser_&&this.captionParser_.clearAllCaptions(),this.trigger("reseteverything")}},{key:"resetLoader",value:function(){this.fetchAtBuffer_=!1,this.resyncLoader()}},{key:"resyncLoader",value:function(){this.mediaIndex=null,this.syncPoint_=null,this.abort()}},{key:"remove",value:function(e,t,i){if(t===1/0&&(t=this.duration_()),this.sourceUpdater_&&this.sourceUpdater_.remove(e,t,i),Rc(e,t,this.segmentMetadataTrack_),this.inbandTextTracks_)for(var n in this.inbandTextTracks_)Rc(e,t,this.inbandTextTracks_[n])}},{key:"monitorBuffer_",value:function(){this.checkBufferTimeout_&&ee.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=ee.setTimeout(this.monitorBufferTick_.bind(this),1)}},{key:"monitorBufferTick_",value:function(){"READY"===this.state&&this.fillBuffer_(),this.checkBufferTimeout_&&ee.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=ee.setTimeout(this.monitorBufferTick_.bind(this),500)}},{key:"fillBuffer_",value:function(){if(!this.sourceUpdater_.updating()){this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var e=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);e&&(this.isEndOfStream_(e.mediaIndex)?this.endOfStream():(e.mediaIndex!==this.playlist_.segments.length-1||"ended"!==this.mediaSource_.readyState||this.seeking_())&&(e.timeline!==this.currentTimeline_&&(this.syncController_.reset(),e.timestampOffset=e.startOfSegment,this.captionParser_&&this.captionParser_.clearAllCaptions()),this.loadSegment_(e)))}}},{key:"isEndOfStream_",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.playlist_;return Dh(t,this.mediaSource_,e)&&!this.sourceUpdater_.updating()}},{key:"checkBuffer_",value:function(e,t,i,n,r,s){var a=0,o=void 0;e.length&&(a=e.end(e.length-1));var u=Math.max(0,a-r);if(!t.segments.length)return null;if(u>=this.goalBufferLength_())return null;if(!n&&u>=1)return null;if(null===s)return i=this.getSyncSegmentCandidate_(t),this.generateSegmentInfo_(t,i,null,!0);if(null!==i){t.segments[i];return o=a,this.generateSegmentInfo_(t,i+1,o,!1)}if(this.fetchAtBuffer_){var l=mc.getMediaInfoForTime(t,a,s.segmentIndex,s.time);i=l.mediaIndex,o=l.startTime}else{var c=mc.getMediaInfoForTime(t,r,s.segmentIndex,s.time);i=c.mediaIndex,o=c.startTime}return this.generateSegmentInfo_(t,i,o,!1)}},{key:"getSyncSegmentCandidate_",value:function(e){var t=this;if(-1===this.currentTimeline_)return 0;var i=e.segments.map((function(e,t){return{timeline:e.timeline,segmentIndex:t}})).filter((function(e){return e.timeline===t.currentTimeline_}));return i.length?i[Math.min(i.length-1,1)].segmentIndex:Math.max(e.segments.length-1,0)}},{key:"generateSegmentInfo_",value:function(e,t,i,n){if(t<0||t>=e.segments.length)return null;var r=e.segments[t];return{requestId:"segment-loader-"+Math.random(),uri:r.resolvedUri,mediaIndex:t,isSyncRequest:n,startOfSegment:i,playlist:e,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:r.timeline,duration:r.duration,segment:r}}},{key:"abortRequestEarly_",value:function(e){if(this.hls_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH)return!1;if(Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)return!1;var t=this.currentTime_(),i=e.bandwidth,n=this.pendingSegment_.duration,r=mc.estimateSegmentRequestTime(n,i,this.playlist_,e.bytesReceived),s=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=e.length?e.end(e.length-1):0;return(n-t)/i}(this.buffered_(),t,this.hls_.tech_.playbackRate())-1;if(r<=s)return!1;var a=function(e){var t=e.master,i=e.currentTime,n=e.bandwidth,r=e.duration,s=e.segmentDuration,a=e.timeUntilRebuffer,o=e.currentTimeline,u=e.syncController,l=t.playlists.filter((function(e){return!mc.isIncompatible(e)})),c=l.filter(mc.isEnabled);c.length||(c=l.filter((function(e){return!mc.isDisabled(e)})));var h=c.filter(mc.hasAttribute.bind(null,"BANDWIDTH")).map((function(e){var t=u.getSyncPoint(e,r,o,i)?1:2;return{playlist:e,rebufferingImpact:mc.estimateSegmentRequestTime(s,n,e)*t-a}})),d=h.filter((function(e){return e.rebufferingImpact<=0}));return Lh(d,(function(e,t){return Oh(t.playlist,e.playlist)})),d.length?d[0]:(Lh(h,(function(e,t){return e.rebufferingImpact-t.rebufferingImpact})),h[0]||null)}({master:this.hls_.playlists.master,currentTime:t,bandwidth:i,duration:this.duration_(),segmentDuration:n,timeUntilRebuffer:s,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(a){var o=r-s-a.rebufferingImpact,u=.5;return s<=1/30&&(u=1),!a.playlist||a.playlist.uri===this.playlist_.uri||o0&&this.remove(0,t)}},{key:"createSimplifiedSegmentObj_",value:function(e){var t=e.segment,i={resolvedUri:t.resolvedUri,byterange:t.byterange,requestId:e.requestId};if(t.key){var n=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);i.key=this.segmentKey(t.key),i.key.iv=n}return t.map&&(i.map=this.initSegment(t.map)),i}},{key:"segmentRequestFinished_",value:function(e,t){if(this.mediaRequests+=1,t.stats&&(this.mediaBytesTransferred+=t.stats.bytesReceived,this.mediaTransferDuration+=t.stats.roundTripTime),this.pendingSegment_){if(t.requestId===this.pendingSegment_.requestId){if(e)return this.pendingSegment_=null,this.state="READY",e.code===Ch?void(this.mediaRequestsAborted+=1):(this.pause(),e.code===kh?(this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,void this.trigger("bandwidthupdate")):(this.mediaRequestsErrored+=1,this.error(e),void this.trigger("error")));this.bandwidth=t.stats.bandwidth,this.roundTrip=t.stats.roundTripTime,t.map&&(t.map=this.initSegment(t.map,!0)),t.key&&this.segmentKey(t.key,!0),this.processSegmentResponse_(t)}}else this.mediaRequestsAborted+=1}},{key:"processSegmentResponse_",value:function(e){var t=this.pendingSegment_;t.bytes=e.bytes,e.map&&(t.segment.map.bytes=e.map.bytes),t.endOfAllRequests=e.endOfAllRequests,e.fmp4Captions&&(!function(e,t,i){for(var n in i)if(!e[n]){t.trigger({type:"usage",name:"hls-608"});var r=t.textTracks().getTrackById(n);e[n]=r||t.addRemoteTextTrack({kind:"captions",id:n,label:n},!1).track}}(this.inbandTextTracks_,this.hls_.tech_,e.captionStreams),function(e){var t=e.inbandTextTracks,i=e.captionArray,n=e.timestampOffset;if(i){var r=window.WebKitDataCue||window.VTTCue;i.forEach((function(e){var i=e.stream,s=e.startTime,a=e.endTime;t[i]&&(s+=n,a+=n,t[i].addCue(new r(s,a,e.text)))}))}}({inbandTextTracks:this.inbandTextTracks_,captionArray:e.fmp4Captions,timestampOffset:0}),this.captionParser_&&this.captionParser_.clearParsedCaptions()),this.handleSegment_()}},{key:"handleSegment_",value:function(){var e=this;if(this.pendingSegment_){var t=this.pendingSegment_,i=t.segment,n=this.syncController_.probeSegmentInfo(t);void 0===this.startingMedia_&&n&&(n.containsAudio||n.containsVideo)&&(this.startingMedia_={containsAudio:n.containsAudio,containsVideo:n.containsVideo});var r,s,a,o=(r=this.loaderType_,s=this.startingMedia_,a=n,"main"===r&&s&&a?a.containsAudio||a.containsVideo?s.containsVideo&&!a.containsVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!s.containsVideo&&a.containsVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null:"Neither audio nor video found in segment.":null);if(o)return this.error({message:o,blacklistDuration:1/0}),void this.trigger("error");if(t.isSyncRequest)return this.trigger("syncinfoupdate"),this.pendingSegment_=null,void(this.state="READY");if(null!==t.timestampOffset&&t.timestampOffset!==this.sourceUpdater_.timestampOffset()){if(n&&n.segmentTimestampInfo){var u=n.segmentTimestampInfo[0].ptsTime,l=n.segmentTimestampInfo[0].dtsTime;t.timestampOffset-=u-l}this.sourceUpdater_.timestampOffset(t.timestampOffset),this.trigger("timestampoffset")}var c=this.syncController_.mappingForTimeline(t.timeline);if(null!==c&&this.trigger({type:"segmenttimemapping",mapping:c}),this.state="APPENDING",i.map){var h=Cc(i.map);if(!this.activeInitSegmentId_||this.activeInitSegmentId_!==h){var d=this.initSegment(i.map);this.sourceUpdater_.appendBuffer({bytes:d.bytes},(function(){e.activeInitSegmentId_=h}))}}t.byteLength=t.bytes.byteLength,"number"==typeof i.start&&"number"==typeof i.end?this.mediaSecondsLoaded+=i.end-i.start:this.mediaSecondsLoaded+=i.duration,this.logger_(function(e){var t=e.segment,i=t.start,n=t.end,r=e.playlist,s=r.mediaSequence,a=r.id,o=r.segments,u=void 0===o?[]:o,l=e.mediaIndex,c=e.timeline;return["appending ["+l+"] of ["+s+", "+(s+u.length)+"] from playlist ["+a+"]","["+i+" => "+n+"] in timeline ["+c+"]"].join(" ")}(t)),this.sourceUpdater_.appendBuffer({bytes:t.bytes,videoSegmentTimingInfoCallback:this.handleVideoSegmentTimingInfo_.bind(this,t.requestId)},this.handleUpdateEnd_.bind(this))}else this.state="READY"}},{key:"handleVideoSegmentTimingInfo_",value:function(e,t){if(this.pendingSegment_&&e===this.pendingSegment_.requestId){var i=this.pendingSegment_.segment;i.videoTimingInfo||(i.videoTimingInfo={}),i.videoTimingInfo.transmuxerPrependedSeconds=t.videoSegmentTimingInfo.prependedContentDuration||0,i.videoTimingInfo.transmuxedPresentationStart=t.videoSegmentTimingInfo.start.presentation,i.videoTimingInfo.transmuxedPresentationEnd=t.videoSegmentTimingInfo.end.presentation,i.videoTimingInfo.baseMediaDecodeTime=t.videoSegmentTimingInfo.baseMediaDecodeTime}}},{key:"handleUpdateEnd_",value:function(){if(!this.pendingSegment_)return this.state="READY",void(this.paused()||this.monitorBuffer_());var e=this.pendingSegment_,t=e.segment,i=null!==this.mediaIndex;this.pendingSegment_=null,this.recordThroughput_(e),this.addSegmentMetadataCue_(e),this.state="READY",this.mediaIndex=e.mediaIndex,this.fetchAtBuffer_=!0,this.currentTimeline_=e.timeline,this.trigger("syncinfoupdate"),t.end&&this.currentTime_()-t.end>3*e.playlist.targetDuration?this.resetEverything():(i&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.isEndOfStream_(e.mediaIndex+1,e.playlist)&&this.endOfStream(),this.paused()||this.monitorBuffer_())}},{key:"recordThroughput_",value:function(e){var t=this.throughput.rate,i=Date.now()-e.endOfAllRequests+1,n=Math.floor(e.byteLength/i*8*1e3);this.throughput.rate+=(n-t)/++this.throughput.count}},{key:"addSegmentMetadataCue_",value:function(e){if(this.segmentMetadataTrack_){var t=e.segment,i=t.start,n=t.end;if(Nh(i)&&Nh(n)){Rc(i,n,this.segmentMetadataTrack_);var r=ee.WebKitDataCue||ee.VTTCue,s={custom:t.custom,dateTimeObject:t.dateTimeObject,dateTimeString:t.dateTimeString,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:i,end:n},a=new r(i,n,JSON.stringify(s));a.value=s,this.segmentMetadataTrack_.addCue(a)}}}}]),t}(Nl.EventTarget),Uh=function(e){return decodeURIComponent(escape(String.fromCharCode.apply(null,e)))},Mh=new Uint8Array("\n\n".split("").map((function(e){return e.charCodeAt(0)}))),Bh=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};jl(this,t);var n=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i));return n.mediaSource_=null,n.subtitlesTrack_=null,n.featuresNativeTextTracks_=e.featuresNativeTextTracks,n}return Vl(t,e),Fl(t,[{key:"buffered_",value:function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return Nl.createTimeRanges();var e=this.subtitlesTrack_.cues,t=e[0].startTime,i=e[e.length-1].startTime;return Nl.createTimeRanges([[t,i]])}},{key:"initSegment",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e)return null;var i=Cc(e),n=this.initSegments_[i];if(t&&!n&&e.bytes){var r=Mh.byteLength+e.bytes.byteLength,s=new Uint8Array(r);s.set(e.bytes),s.set(Mh,e.bytes.byteLength),this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:s}}return n||e}},{key:"couldBeginLoading_",value:function(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}},{key:"init_",value:function(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}},{key:"track",value:function(e){return void 0===e||(this.subtitlesTrack_=e,"INIT"===this.state&&this.couldBeginLoading_()&&this.init_()),this.subtitlesTrack_}},{key:"remove",value:function(e,t){Rc(e,t,this.subtitlesTrack_)}},{key:"fillBuffer_",value:function(){var e=this;this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var t=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(t=this.skipEmptySegments_(t)){if(null===this.syncController_.timestampOffsetForTimeline(t.timeline)){return this.syncController_.one("timestampoffset",(function(){e.state="READY",e.paused()||e.monitorBuffer_()})),void(this.state="WAITING_ON_TIMELINE")}this.loadSegment_(t)}}},{key:"skipEmptySegments_",value:function(e){for(;e&&e.segment.empty;)e=this.generateSegmentInfo_(e.playlist,e.mediaIndex+1,e.startOfSegment+e.duration,e.isSyncRequest);return e}},{key:"handleSegment_",value:function(){var e=this;if(this.pendingSegment_&&this.subtitlesTrack_){this.state="APPENDING";var t=this.pendingSegment_,i=t.segment;if("function"!=typeof ee.WebVTT&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var n=void 0,r=function(){e.subtitlesTrack_.tech_.off("vttjsloaded",n),e.error({message:"Error loading vtt.js"}),e.state="READY",e.pause(),e.trigger("error")};return n=function(){e.subtitlesTrack_.tech_.off("vttjserror",r),e.handleSegment_()},this.state="WAITING_ON_VTTJS",this.subtitlesTrack_.tech_.one("vttjsloaded",n),void this.subtitlesTrack_.tech_.one("vttjserror",r)}i.requested=!0;try{this.parseVTTCues_(t)}catch(e){return this.error({message:e.message}),this.state="READY",this.pause(),this.trigger("error")}if(this.updateTimeMapping_(t,this.syncController_.timelines[t.timeline],this.playlist_),t.isSyncRequest)return this.trigger("syncinfoupdate"),this.pendingSegment_=null,void(this.state="READY");t.byteLength=t.bytes.byteLength,this.mediaSecondsLoaded+=i.duration,t.cues.length&&this.remove(t.cues[0].endTime,t.cues[t.cues.length-1].endTime),t.cues.forEach((function(t){e.subtitlesTrack_.addCue(e.featuresNativeTextTracks_?new ee.VTTCue(t.startTime,t.endTime,t.text):t)})),this.handleUpdateEnd_()}else this.state="READY"}},{key:"parseVTTCues_",value:function(e){var t=void 0,i=!1;"function"==typeof ee.TextDecoder?t=new ee.TextDecoder("utf8"):(t=ee.WebVTT.StringDecoder(),i=!0);var n=new ee.WebVTT.Parser(ee,ee.vttjs,t);if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},n.oncue=e.cues.push.bind(e.cues),n.ontimestampmap=function(t){return e.timestampmap=t},n.onparsingerror=function(e){Nl.log.warn("Error encountered when parsing cues: "+e.message)},e.segment.map){var r=e.segment.map.bytes;i&&(r=Uh(r)),n.parse(r)}var s=e.bytes;i&&(s=Uh(s)),n.parse(s),n.flush()}},{key:"updateTimeMapping_",value:function(e,t,i){var n=e.segment;if(t)if(e.cues.length){var r=e.timestampmap,s=r.MPEGTS/9e4-r.LOCAL+t.mapping;if(e.cues.forEach((function(e){e.startTime+=s,e.endTime+=s})),!i.syncInfo){var a=e.cues[0].startTime,o=e.cues[e.cues.length-1].startTime;i.syncInfo={mediaSequence:i.mediaSequence+e.mediaIndex,time:Math.min(a,o-n.duration)}}}else n.empty=!0}}]),t}(Rh),jh=function(e,t){for(var i=e.cues,n=0;n=r.adStartTime&&t<=r.adEndTime)return r}return null},Fh=Er,Vh=[{name:"VOD",run:function(e,t,i,n,r){if(i!==1/0){return{time:0,segmentIndex:0}}return null}},{name:"ProgramDateTime",run:function(e,t,i,n,r){if(!e.datetimeToDisplayTime)return null;var s=t.segments||[],a=null,o=null;r=r||0;for(var u=0;u=c)&&(o=c,a={time:l.start,segmentIndex:u})}}return a}},{name:"Discontinuity",run:function(e,t,i,n,r){var s=null;if(r=r||0,t.discontinuityStarts&&t.discontinuityStarts.length)for(var a=null,o=0;o=h)&&(a=h,s={time:c.time,segmentIndex:u})}}return s}},{name:"Playlist",run:function(e,t,i,n,r){return t.syncInfo?{time:t.syncInfo.time,segmentIndex:t.syncInfo.mediaSequence-t.mediaSequence}:null}}],Hh=function(e){function t(){jl(this,t);var e=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.inspectCache_=void 0,e.timelines=[],e.discontinuities=[],e.datetimeToDisplayTime=null,e.logger_=yh("SyncController"),e}return Vl(t,e),Fl(t,[{key:"getSyncPoint",value:function(e,t,i,n){var r=this.runStrategies_(e,t,i,n);return r.length?this.selectSyncPoint_(r,{key:"time",value:n}):null}},{key:"getExpiredTime",value:function(e,t){if(!e||!e.segments)return null;var i=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!i.length)return null;var n=this.selectSyncPoint_(i,{key:"segmentIndex",value:0});return n.segmentIndex>0&&(n.time*=-1),Math.abs(n.time+nc(e,n.segmentIndex,0))}},{key:"runStrategies_",value:function(e,t,i,n){for(var r=[],s=0;s=0;i--){var n=e.segments[i];if(n&&void 0!==n.start){t.syncInfo={mediaSequence:e.mediaSequence+i,time:n.start},this.logger_("playlist refresh sync: [time:"+t.syncInfo.time+", mediaSequence: "+t.syncInfo.mediaSequence+"]"),this.trigger("syncinfoupdate");break}}}},{key:"setDateTimeMapping",value:function(e){if(!this.datetimeToDisplayTime&&e.segments&&e.segments.length&&e.segments[0].dateTimeObject){var t=e.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-t}}},{key:"reset",value:function(){this.inspectCache_=void 0}},{key:"probeSegmentInfo",value:function(e){var t=e.segment,i=e.playlist,n=void 0;return(n=t.map?this.probeMp4Segment_(e):this.probeTsSegment_(e))&&this.calculateSegmentTimeMapping_(e,n)&&(this.saveDiscontinuitySyncInfo_(e),i.syncInfo||(i.syncInfo={mediaSequence:i.mediaSequence+e.mediaIndex,time:t.start})),n}},{key:"probeMp4Segment_",value:function(e){var t=e.segment,i=Mn.timescale(t.map.bytes),n=Mn.compositionStartTime(i,e.bytes);return null!==e.timestampOffset&&(e.timestampOffset-=n),{start:n,end:n+t.duration}}},{key:"probeTsSegment_",value:function(e){var t=Fh(e.bytes,this.inspectCache_),i=void 0,n=void 0,r=void 0;return t?(t.video&&2===t.video.length?(this.inspectCache_=t.video[1].dts,i=t.video[0].dtsTime,n=t.video[1].dtsTime,r=t.video):t.audio&&2===t.audio.length&&(this.inspectCache_=t.audio[1].dts,i=t.audio[0].dtsTime,n=t.audio[1].dtsTime,r=t.audio),{segmentTimestampInfo:r,start:i,end:n,containsVideo:t.video&&2===t.video.length,containsAudio:t.audio&&2===t.audio.length}):null}},{key:"timestampOffsetForTimeline",value:function(e){return void 0===this.timelines[e]?null:this.timelines[e].time}},{key:"mappingForTimeline",value:function(e){return void 0===this.timelines[e]?null:this.timelines[e].mapping}},{key:"calculateSegmentTimeMapping_",value:function(e,t){var i=e.segment,n=this.timelines[e.timeline];if(null!==e.timestampOffset)n={time:e.startOfSegment,mapping:e.startOfSegment-t.start},this.timelines[e.timeline]=n,this.trigger("timestampoffset"),this.logger_("time mapping for timeline "+e.timeline+": [time: "+n.time+"] [mapping: "+n.mapping+"]"),i.start=e.startOfSegment,i.end=t.end+n.mapping;else{if(!n)return!1;i.start=t.start+n.mapping,i.end=t.end+n.mapping}return!0}},{key:"saveDiscontinuitySyncInfo_",value:function(e){var t=e.playlist,i=e.segment;if(i.discontinuity)this.discontinuities[i.timeline]={time:i.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(var n=0;no){var u=void 0;u=a<0?i.start-nc(t,e.mediaIndex,r):i.end+nc(t,e.mediaIndex+1,r),this.discontinuities[s]={time:u,accuracy:o}}}}},{key:"dispose",value:function(){this.trigger("dispose"),this.off()}}]),t}(Nl.EventTarget),qh=new qc("./decrypter-worker.worker.js",(function(e,t){var i=this;!function(){var e=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},t=function(){function e(e,t){for(var i=0;i>7))^s]=s;for(a=o=0;!n[a];a^=c||1,o=l[o]||1)for(d=(d=o^o<<1^o<<2^o<<3^o<<4)>>8^255&d^99,n[a]=d,r[d]=a,f=16843009*u[h=u[c=u[a]]]^65537*h^257*c^16843008*a,p=257*u[d]^16843008*d,s=0;s<4;s++)t[s][a]=p=p<<24^p>>>8,i[s][d]=f=f<<24^f>>>8;for(s=0;s<5;s++)t[s]=t[s].slice(0),i[s]=i[s].slice(0);return e}()),this._tables=[[n[0][0].slice(),n[0][1].slice(),n[0][2].slice(),n[0][3].slice(),n[0][4].slice()],[n[1][0].slice(),n[1][1].slice(),n[1][2].slice(),n[1][3].slice(),n[1][4].slice()]];var r=void 0,s=void 0,a=void 0,o=void 0,u=void 0,l=this._tables[0][4],c=this._tables[1],h=i.length,d=1;if(4!==h&&6!==h&&8!==h)throw new Error("Invalid aes key size");for(o=i.slice(0),u=[],this._key=[o,u],r=h;r<4*h+28;r++)a=o[r-1],(r%h==0||8===h&&r%h==4)&&(a=l[a>>>24]<<24^l[a>>16&255]<<16^l[a>>8&255]<<8^l[255&a],r%h==0&&(a=a<<8^a>>>24^d<<24,d=d<<1^283*(d>>7))),o[r]=o[r-h]^a;for(s=0;r;s++,r--)a=o[3&s?r:r-4],u[s]=r<=4||s<4?a:c[0][l[a>>>24]]^c[1][l[a>>16&255]]^c[2][l[a>>8&255]]^c[3][l[255&a]]}return t.prototype.decrypt=function(e,t,i,n,r,s){var a=this._key[1],o=e^a[0],u=n^a[1],l=i^a[2],c=t^a[3],h=void 0,d=void 0,p=void 0,f=a.length/4-2,m=void 0,g=4,v=this._tables[1],y=v[0],_=v[1],b=v[2],T=v[3],S=v[4];for(m=0;m>>24]^_[u>>16&255]^b[l>>8&255]^T[255&c]^a[g],d=y[u>>>24]^_[l>>16&255]^b[c>>8&255]^T[255&o]^a[g+1],p=y[l>>>24]^_[c>>16&255]^b[o>>8&255]^T[255&u]^a[g+2],c=y[c>>>24]^_[o>>16&255]^b[u>>8&255]^T[255&l]^a[g+3],g+=4,o=h,u=d,l=p;for(m=0;m<4;m++)r[(3&-m)+s]=S[o>>>24]<<24^S[u>>16&255]<<16^S[l>>8&255]<<8^S[255&c]^a[g++],h=o,o=u,u=l,l=c,c=h},t}(),s=function(){function t(){e(this,t),this.listeners={}}return t.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},t.prototype.off=function(e,t){if(!this.listeners[e])return!1;var i=this.listeners[e].indexOf(t);return this.listeners[e].splice(i,1),i>-1},t.prototype.trigger=function(e){var t=this.listeners[e];if(t)if(2===arguments.length)for(var i=t.length,n=0;n>8|e>>>24},u=function(){function i(t,n,r,s){e(this,i);var u=i.STEP,l=new Int32Array(t.buffer),c=new Uint8Array(t.byteLength),h=0;for(this.asyncStream_=new a,this.asyncStream_.push(this.decryptChunk_(l.subarray(h,h+u),n,r,c)),h=u;h>2),s=new r(Array.prototype.slice.call(t)),a=new Uint8Array(e.byteLength),u=new Int32Array(a.buffer),l=void 0,c=void 0,h=void 0,d=void 0,p=void 0,f=void 0,m=void 0,g=void 0,v=void 0;for(l=i[0],c=i[1],h=i[2],d=i[3],v=0;v=0&&(t="main-desc"),t},zh=function(e,t){e.abort(),e.pause(),t&&t.activePlaylistLoader&&(t.activePlaylistLoader.pause(),t.activePlaylistLoader=null)},$h=function(e,t){t.activePlaylistLoader=e,e.load()},Gh={AUDIO:function(e,t){return function(){var i=t.segmentLoaders[e],n=t.mediaTypes[e],r=t.blacklistCurrentPlaylist;zh(i,n);var s=n.activeTrack(),a=n.activeGroup(),o=(a.filter((function(e){return e.default}))[0]||a[0]).id,u=n.tracks[o];if(s!==u){for(var l in Nl.log.warn("Problem encountered loading the alternate audio track.Switching back to default."),n.tracks)n.tracks[l].enabled=n.tracks[l]===u;n.onTrackChanged()}else r({message:"Problem encountered loading the default audio track."})}},SUBTITLES:function(e,t){return function(){var i=t.segmentLoaders[e],n=t.mediaTypes[e];Nl.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),zh(i,n);var r=n.activeTrack();r&&(r.mode="disabled"),n.onTrackChanged()}}},Xh={AUDIO:function(e,t,i){if(t){var n=i.tech,r=i.requestOptions,s=i.segmentLoaders[e];t.on("loadedmetadata",(function(){var e=t.media();s.playlist(e,r),(!n.paused()||e.endList&&"none"!==n.preload())&&s.load()})),t.on("loadedplaylist",(function(){s.playlist(t.media(),r),n.paused()||s.load()})),t.on("error",Gh[e](e,i))}},SUBTITLES:function(e,t,i){var n=i.tech,r=i.requestOptions,s=i.segmentLoaders[e],a=i.mediaTypes[e];t.on("loadedmetadata",(function(){var e=t.media();s.playlist(e,r),s.track(a.activeTrack()),(!n.paused()||e.endList&&"none"!==n.preload())&&s.load()})),t.on("loadedplaylist",(function(){s.playlist(t.media(),r),n.paused()||s.load()})),t.on("error",Gh[e](e,i))}},Kh={AUDIO:function(e,t){var i=t.hls,n=t.sourceType,r=t.segmentLoaders[e],s=t.requestOptions,a=t.master.mediaGroups,o=t.mediaTypes[e],u=o.groups,l=o.tracks,c=t.masterPlaylistLoader;for(var h in a[e]&&0!==Object.keys(a[e]).length||(a[e]={main:{default:{default:!0}}}),a[e])for(var d in u[h]||(u[h]=[]),a[e][h]){var p=a[e][h][d],f=void 0;if(f=p.resolvedUri?new Zl(p.resolvedUri,i,s):p.playlists&&"dash"===n?new vh(p.playlists[0],i,s,c):null,p=Nl.mergeOptions({id:d,playlistLoader:f},p),Xh[e](e,p.playlistLoader,t),u[h].push(p),void 0===l[d]){var m=new Nl.AudioTrack({id:d,kind:Wh(p),enabled:!1,language:p.language,default:p.default,label:d});l[d]=m}}r.on("error",Gh[e](e,t))},SUBTITLES:function(e,t){var i=t.tech,n=t.hls,r=t.sourceType,s=t.segmentLoaders[e],a=t.requestOptions,o=t.master.mediaGroups,u=t.mediaTypes[e],l=u.groups,c=u.tracks,h=t.masterPlaylistLoader;for(var d in o[e])for(var p in l[d]||(l[d]=[]),o[e][d])if(!o[e][d][p].forced){var f=o[e][d][p],m=void 0;if("hls"===r?m=new Zl(f.resolvedUri,n,a):"dash"===r&&(m=new vh(f.playlists[0],n,a,h)),f=Nl.mergeOptions({id:p,playlistLoader:m},f),Xh[e](e,f.playlistLoader,t),l[d].push(f),void 0===c[p]){var g=i.addRemoteTextTrack({id:p,kind:"subtitles",default:f.default&&f.autoselect,language:f.language,label:p},!1).track;c[p]=g}}s.on("error",Gh[e](e,t))},"CLOSED-CAPTIONS":function(e,t){var i=t.tech,n=t.master.mediaGroups,r=t.mediaTypes[e],s=r.groups,a=r.tracks;for(var o in n[e])for(var u in s[o]||(s[o]=[]),n[e][o]){var l=n[e][o][u];if(l.instreamId.match(/CC\d/)&&(s[o].push(Nl.mergeOptions({id:u},l)),void 0===a[u])){var c=i.addRemoteTextTrack({id:l.instreamId,kind:"captions",default:l.default&&l.autoselect,language:l.language,label:u},!1).track;a[u]=c}}}},Yh={AUDIO:function(e,t){return function(){var i=t.mediaTypes[e].tracks;for(var n in i)if(i[n].enabled)return i[n];return null}},SUBTITLES:function(e,t){return function(){var i=t.mediaTypes[e].tracks;for(var n in i)if("showing"===i[n].mode||"hidden"===i[n].mode)return i[n];return null}}},Qh=function(e){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((function(t){Kh[t](t,e)}));var t=e.mediaTypes,i=e.masterPlaylistLoader,n=e.tech,r=e.hls;["AUDIO","SUBTITLES"].forEach((function(i){t[i].activeGroup=function(e,t){return function(i){var n=t.masterPlaylistLoader,r=t.mediaTypes[e].groups,s=n.media();if(!s)return null;var a=null;return s.attributes[e]&&(a=r[s.attributes[e]]),a=a||r.main,void 0===i?a:null===i?null:a.filter((function(e){return e.id===i.id}))[0]||null}}(i,e),t[i].activeTrack=Yh[i](i,e),t[i].onGroupChanged=function(e,t){return function(){var i=t.segmentLoaders,n=i[e],r=i.main,s=t.mediaTypes[e],a=s.activeTrack(),o=s.activeGroup(a),u=s.activePlaylistLoader;zh(n,s),o&&(o.playlistLoader?(n.resyncLoader(),$h(o.playlistLoader,s)):u&&r.resetEverything())}}(i,e),t[i].onTrackChanged=function(e,t){return function(){var i=t.segmentLoaders,n=i[e],r=i.main,s=t.mediaTypes[e],a=s.activeTrack(),o=s.activeGroup(a),u=s.activePlaylistLoader;zh(n,s),o&&(o.playlistLoader?u!==o.playlistLoader?(n.track&&n.track(a),n.resetEverything(),$h(o.playlistLoader,s)):$h(o.playlistLoader,s):r.resetEverything())}}(i,e)}));var s=t.AUDIO.activeGroup(),a=(s.filter((function(e){return e.default}))[0]||s[0]).id;t.AUDIO.tracks[a].enabled=!0,t.AUDIO.onTrackChanged(),i.on("mediachange",(function(){["AUDIO","SUBTITLES"].forEach((function(e){return t[e].onGroupChanged()}))}));var o=function(){t.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"hls-audio-change"})};for(var u in n.audioTracks().addEventListener("change",o),n.remoteTextTracks().addEventListener("change",t.SUBTITLES.onTrackChanged),r.on("dispose",(function(){n.audioTracks().removeEventListener("change",o),n.remoteTextTracks().removeEventListener("change",t.SUBTITLES.onTrackChanged)})),n.clearTracks("audio"),t.AUDIO.tracks)n.audioTracks().addTrack(t.AUDIO.tracks[u])},Jh=void 0,Zh=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],ed=function(e){return this.audioSegmentLoader_[e]+this.mainSegmentLoader_[e]},td=function(e){function t(e){jl(this,t);var i,n=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),r=e.url,s=e.handleManifestRedirects,a=e.withCredentials,o=e.tech,u=e.bandwidth,l=e.externHls,c=e.useCueTags,h=e.blacklistDuration,d=e.enableLowInitialPlaylist,p=e.cacheEncryptionKeys,f=e.sourceType;if(!r)throw new Error("A non-empty playlist URL is required");Jh=l,n.withCredentials=a,n.tech_=o,n.hls_=o.hls,n.sourceType_=f,n.useCueTags_=c,n.blacklistDuration=h,n.enableLowInitialPlaylist=d,n.useCueTags_&&(n.cueTagsTrack_=n.tech_.addTextTrack("metadata","ad-cues"),n.cueTagsTrack_.inBandMetadataTrackDispatchType=""),n.requestOptions_={withCredentials:a,handleManifestRedirects:s,timeout:null},n.mediaTypes_=(i={},["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((function(e){i[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:_h,activeTrack:_h,onGroupChanged:_h,onTrackChanged:_h}})),i),n.mediaSource=new Nl.MediaSource,n.mediaSource.addEventListener("sourceopen",n.handleSourceOpen_.bind(n)),n.seekable_=Nl.createTimeRanges(),n.hasPlayed_=!1,n.syncController_=new Hh(e),n.segmentMetadataTrack_=o.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,n.decrypter_=new qh,n.inbandTextTracks_={};var m={hls:n.hls_,mediaSource:n.mediaSource,currentTime:n.tech_.currentTime.bind(n.tech_),seekable:function(){return n.seekable()},seeking:function(){return n.tech_.seeking()},duration:function(){return n.mediaSource.duration},hasPlayed:function(){return n.hasPlayed_},goalBufferLength:function(){return n.goalBufferLength()},bandwidth:u,syncController:n.syncController_,decrypter:n.decrypter_,sourceType:n.sourceType_,inbandTextTracks:n.inbandTextTracks_,cacheEncryptionKeys:p};return n.masterPlaylistLoader_="dash"===n.sourceType_?new vh(r,n.hls_,n.requestOptions_):new Zl(r,n.hls_,n.requestOptions_),n.setupMasterPlaylistLoaderListeners_(),n.mainSegmentLoader_=new Rh(Nl.mergeOptions(m,{segmentMetadataTrack:n.segmentMetadataTrack_,loaderType:"main"}),e),n.audioSegmentLoader_=new Rh(Nl.mergeOptions(m,{loaderType:"audio"}),e),n.subtitleSegmentLoader_=new Bh(Nl.mergeOptions(m,{loaderType:"vtt",featuresNativeTextTracks:n.tech_.featuresNativeTextTracks}),e),n.setupSegmentLoaderListeners_(),Zh.forEach((function(e){n[e+"_"]=ed.bind(n,e)})),n.logger_=yh("MPC"),n.masterPlaylistLoader_.load(),n}return Vl(t,e),Fl(t,[{key:"setupMasterPlaylistLoaderListeners_",value:function(){var e=this;this.masterPlaylistLoader_.on("loadedmetadata",(function(){var t=e.masterPlaylistLoader_.media(),i=1.5*t.targetDuration*1e3;fc(e.masterPlaylistLoader_.master,e.masterPlaylistLoader_.media())?e.requestOptions_.timeout=0:e.requestOptions_.timeout=i,t.endList&&"none"!==e.tech_.preload()&&(e.mainSegmentLoader_.playlist(t,e.requestOptions_),e.mainSegmentLoader_.load()),Qh({sourceType:e.sourceType_,segmentLoaders:{AUDIO:e.audioSegmentLoader_,SUBTITLES:e.subtitleSegmentLoader_,main:e.mainSegmentLoader_},tech:e.tech_,requestOptions:e.requestOptions_,masterPlaylistLoader:e.masterPlaylistLoader_,hls:e.hls_,master:e.master(),mediaTypes:e.mediaTypes_,blacklistCurrentPlaylist:e.blacklistCurrentPlaylist.bind(e)}),e.triggerPresenceUsage_(e.master(),t);try{e.setupSourceBuffers_()}catch(t){return Nl.log.warn("Failed to create SourceBuffers",t),e.mediaSource.endOfStream("decode")}e.setupFirstPlay(),!e.mediaTypes_.AUDIO.activePlaylistLoader||e.mediaTypes_.AUDIO.activePlaylistLoader.media()?e.trigger("selectedinitialmedia"):e.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",(function(){e.trigger("selectedinitialmedia")}))})),this.masterPlaylistLoader_.on("loadedplaylist",(function(){var t=e.masterPlaylistLoader_.media();if(!t){e.excludeUnsupportedVariants_();var i=void 0;return e.enableLowInitialPlaylist&&(i=e.selectInitialPlaylist()),i||(i=e.selectPlaylist()),e.initialMedia_=i,void e.masterPlaylistLoader_.media(e.initialMedia_)}if(e.useCueTags_&&e.updateAdCues_(t),e.mainSegmentLoader_.playlist(t,e.requestOptions_),e.updateDuration(),e.tech_.paused()||(e.mainSegmentLoader_.load(),e.audioSegmentLoader_&&e.audioSegmentLoader_.load()),!t.endList){var n=function(){var t=e.seekable();0!==t.length&&e.mediaSource.addSeekableRange_(t.start(0),t.end(0))};if(e.duration()!==1/0){e.tech_.one("durationchange",(function t(){e.duration()===1/0?n():e.tech_.one("durationchange",t)}))}else n()}})),this.masterPlaylistLoader_.on("error",(function(){e.blacklistCurrentPlaylist(e.masterPlaylistLoader_.error)})),this.masterPlaylistLoader_.on("mediachanging",(function(){e.mainSegmentLoader_.abort(),e.mainSegmentLoader_.pause()})),this.masterPlaylistLoader_.on("mediachange",(function(){var t=e.masterPlaylistLoader_.media(),i=1.5*t.targetDuration*1e3;fc(e.masterPlaylistLoader_.master,e.masterPlaylistLoader_.media())?e.requestOptions_.timeout=0:e.requestOptions_.timeout=i,e.mainSegmentLoader_.playlist(t,e.requestOptions_),e.mainSegmentLoader_.load(),e.tech_.trigger({type:"mediachange",bubbles:!0})})),this.masterPlaylistLoader_.on("playlistunchanged",(function(){var t=e.masterPlaylistLoader_.media();e.stuckAtPlaylistEnd_(t)&&(e.blacklistCurrentPlaylist({message:"Playlist no longer updating."}),e.tech_.trigger("playliststuck"))})),this.masterPlaylistLoader_.on("renditiondisabled",(function(){e.tech_.trigger({type:"usage",name:"hls-rendition-disabled"})})),this.masterPlaylistLoader_.on("renditionenabled",(function(){e.tech_.trigger({type:"usage",name:"hls-rendition-enabled"})}))}},{key:"triggerPresenceUsage_",value:function(e,t){var i=e.mediaGroups||{},n=!0,r=Object.keys(i.AUDIO);for(var s in i.AUDIO)for(var a in i.AUDIO[s]){i.AUDIO[s][a].uri||(n=!1)}n&&this.tech_.trigger({type:"usage",name:"hls-demuxed"}),Object.keys(i.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"hls-webvtt"}),Jh.Playlist.isAes(t)&&this.tech_.trigger({type:"usage",name:"hls-aes"}),Jh.Playlist.isFmp4(t)&&this.tech_.trigger({type:"usage",name:"hls-fmp4"}),r.length&&Object.keys(i.AUDIO[r[0]]).length>1&&this.tech_.trigger({type:"usage",name:"hls-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"hls-playlist-cue-tags"})}},{key:"setupSegmentLoaderListeners_",value:function(){var e=this;this.mainSegmentLoader_.on("bandwidthupdate",(function(){var t=e.selectPlaylist(),i=e.masterPlaylistLoader_.media(),n=e.tech_.buffered();(function(e){var t=e.currentPlaylist,i=e.nextPlaylist,n=e.forwardBuffer,r=e.bufferLowWaterLine,s=e.duration;e.log;return i?!t.endList||(s=r)):(Nl.log.warn("We received no playlist to switch to. Please check your stream."),!1)})({currentPlaylist:i,nextPlaylist:t,forwardBuffer:n.length?n.end(n.length-1)-e.tech_.currentTime():0,bufferLowWaterLine:e.bufferLowWaterLine(),duration:e.duration(),log:e.logger_})&&e.masterPlaylistLoader_.media(t),e.tech_.trigger("bandwidthupdate")})),this.mainSegmentLoader_.on("progress",(function(){e.trigger("progress")})),this.mainSegmentLoader_.on("error",(function(){e.blacklistCurrentPlaylist(e.mainSegmentLoader_.error())})),this.mainSegmentLoader_.on("syncinfoupdate",(function(){e.onSyncInfoUpdate_()})),this.mainSegmentLoader_.on("timestampoffset",(function(){e.tech_.trigger({type:"usage",name:"hls-timestamp-offset"})})),this.audioSegmentLoader_.on("syncinfoupdate",(function(){e.onSyncInfoUpdate_()})),this.mainSegmentLoader_.on("ended",(function(){e.onEndOfStream()})),this.mainSegmentLoader_.on("earlyabort",(function(){e.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},120)})),this.mainSegmentLoader_.on("reseteverything",(function(){e.tech_.trigger("hls-reset")})),this.mainSegmentLoader_.on("segmenttimemapping",(function(t){e.tech_.trigger({type:"hls-segment-time-mapping",mapping:t.mapping})})),this.audioSegmentLoader_.on("ended",(function(){e.onEndOfStream()}))}},{key:"mediaSecondsLoaded_",value:function(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}},{key:"load",value:function(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}},{key:"smoothQualityChange_",value:function(){var e=this.selectPlaylist();e!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(e),this.mainSegmentLoader_.resetLoader())}},{key:"fastQualityChange_",value:function(){var e=this,t=this.selectPlaylist();t!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(t),this.mainSegmentLoader_.resetEverything((function(){Nl.browser.IE_VERSION||Nl.browser.IS_EDGE?e.tech_.setCurrentTime(e.tech_.currentTime()+.04):e.tech_.setCurrentTime(e.tech_.currentTime())})))}},{key:"play",value:function(){if(!this.setupFirstPlay()){this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();var e=this.tech_.seekable();return this.tech_.duration()===1/0&&this.tech_.currentTime()0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1],i=void 0,n=void 0;if(i=e.playlist||this.masterPlaylistLoader_.media(),t=t||e.blacklistDuration||this.blacklistDuration,!i){this.error=e;try{return this.mediaSource.endOfStream("network")}catch(e){return this.trigger("error")}}var r=1===this.masterPlaylistLoader_.master.playlists.filter(dc).length,s=this.masterPlaylistLoader_.master.playlists;return 1===s.length?(Nl.log.warn("Problem encountered with the current HLS playlist. Trying again since it is the only playlist."),this.tech_.trigger("retryplaylist"),this.masterPlaylistLoader_.load(r)):(r&&(Nl.log.warn("Removing all playlists from the blacklist because the last rendition is about to be blacklisted."),s.forEach((function(e){e.excludeUntil!==1/0&&delete e.excludeUntil})),this.tech_.trigger("retryplaylist")),i.excludeUntil=Date.now()+1e3*t,this.tech_.trigger("blacklistplaylist"),this.tech_.trigger({type:"usage",name:"hls-rendition-blacklisted"}),n=this.selectPlaylist(),Nl.log.warn("Problem encountered with the current HLS playlist."+(e.message?" "+e.message:"")+" Switching to another playlist."),this.masterPlaylistLoader_.media(n,r))}},{key:"pauseLoading",value:function(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}},{key:"setCurrentTime",value:function(e){var t=Lc(this.tech_.buffered(),e);return this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media()&&this.masterPlaylistLoader_.media().segments?t&&t.length?e:(this.mainSegmentLoader_.resetEverything(),this.mainSegmentLoader_.abort(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.resetEverything(),this.audioSegmentLoader_.abort()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.resetEverything(),this.subtitleSegmentLoader_.abort()),void this.load()):0}},{key:"duration",value:function(){return this.masterPlaylistLoader_?this.mediaSource?this.mediaSource.duration:Jh.Playlist.duration(this.masterPlaylistLoader_.media()):0}},{key:"seekable",value:function(){return this.seekable_}},{key:"onSyncInfoUpdate_",value:function(){var e=void 0;if(this.masterPlaylistLoader_){var t=this.masterPlaylistLoader_.media();if(t){var i=this.syncController_.getExpiredTime(t,this.mediaSource.duration);if(null!==i){var n=this.masterPlaylistLoader_.master.suggestedPresentationDelay,r=Jh.Playlist.seekable(t,i,n);if(0!==r.length){if(this.mediaTypes_.AUDIO.activePlaylistLoader){if(t=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),null===(i=this.syncController_.getExpiredTime(t,this.mediaSource.duration)))return;if(0===(e=Jh.Playlist.seekable(t,i,n)).length)return}var s=void 0,a=void 0;this.seekable_&&this.seekable_.length&&(s=this.seekable_.end(0),a=this.seekable_.start(0)),e?e.start(0)>r.end(0)||r.start(0)>e.end(0)?this.seekable_=r:this.seekable_=Nl.createTimeRanges([[e.start(0)>r.start(0)?e.start(0):r.start(0),e.end(0) "+i);try{e.mediaSource.duration=i}catch(e){Nl.log.warn("Failed to set media source duration",e)}e.tech_.trigger("durationchange"),e.mediaSource.removeEventListener("sourceopen",t)};n.length>0&&(i=Math.max(i,n.end(n.length-1))),t!==i&&("open"!==this.mediaSource.readyState?this.mediaSource.addEventListener("sourceopen",r):r())}},{key:"dispose",value:function(){var e=this;this.trigger("dispose"),this.decrypter_&&this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),["AUDIO","SUBTITLES"].forEach((function(t){var i=e.mediaTypes_[t].groups;for(var n in i)i[n].forEach((function(e){e.playlistLoader&&e.playlistLoader.dispose()}))})),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.off(),this.mediaSource.dispose&&this.mediaSource.dispose()}},{key:"master",value:function(){return this.masterPlaylistLoader_.master}},{key:"media",value:function(){return this.masterPlaylistLoader_.media()||this.initialMedia_}},{key:"setupSourceBuffers_",value:function(){var e,t=this.masterPlaylistLoader_.media();if(t&&"open"===this.mediaSource.readyState){if((e=Zc(this.masterPlaylistLoader_.master,t)).length<1)return this.error="No compatible SourceBuffer configuration for the variant stream:"+t.resolvedUri,this.mediaSource.endOfStream("decode");this.configureLoaderMimeTypes_(e),this.excludeIncompatibleVariants_(t)}}},{key:"configureLoaderMimeTypes_",value:function(e){var t=e.length>1&&-1===e[0].indexOf(",")&&e[0]!==e[1]?new Nl.EventTarget:null;this.mainSegmentLoader_.mimeType(e[0],t),e[1]&&this.audioSegmentLoader_.mimeType(e[1],t)}},{key:"excludeUnsupportedVariants_",value:function(){this.master().playlists.forEach((function(e){var t;e.attributes.CODECS&&ee.MediaSource&&ee.MediaSource.isTypeSupported&&!ee.MediaSource.isTypeSupported('video/mp4; codecs="'+(t=e.attributes.CODECS,t.replace(/avc1\.(\d+)\.(\d+)/i,(function(e){return Yc([e])[0]}))+'"'))&&(e.excludeUntil=1/0)}))}},{key:"excludeIncompatibleVariants_",value:function(e){var t=2,i=null,n=void 0;e.attributes.CODECS&&(n=Qc(e.attributes.CODECS),i=n.videoCodec,t=n.codecCount),this.master().playlists.forEach((function(e){var n={codecCount:2,videoCodec:null};e.attributes.CODECS&&(n=Qc(e.attributes.CODECS)),n.codecCount!==t&&(e.excludeUntil=1/0),n.videoCodec!==i&&(e.excludeUntil=1/0)}))}},{key:"updateAdCues_",value:function(e){var t=0,i=this.seekable();i.length&&(t=i.start(0)),function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(e.segments)for(var n=i,r=void 0,s=0;s=t.end(t.length-1)))return this.techWaiting_();this.consecutiveUpdates>=5&&e===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):e===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=e)}}},{key:"cancelTimer_",value:function(){this.consecutiveUpdates=0,this.timer_&&(this.logger_("cancelTimer_"),clearTimeout(this.timer_)),this.timer_=null}},{key:"fixesBadSeeks_",value:function(){if(!this.tech_.seeking())return!1;var e=this.seekable(),t=this.tech_.currentTime(),i=void 0;this.afterSeekableWindow_(e,t,this.media(),this.allowSeeksWithinUnsafeLiveWindow)&&(i=e.end(e.length-1));this.beforeSeekableWindow_(e,t)&&(i=e.start(0)+.1);return void 0!==i&&(this.logger_("Trying to seek outside of seekable at time "+t+" with seekable range "+Dc(e)+". Seeking to "+i+"."),this.tech_.setCurrentTime(i),!0)}},{key:"waiting_",value:function(){if(!this.techWaiting_()){var e=this.tech_.currentTime(),t=this.tech_.buffered(),i=Lc(t,e);return i.length&&e+3<=i.end(0)?(this.cancelTimer_(),this.tech_.setCurrentTime(e),this.logger_("Stopped at "+e+" while inside a buffered region ["+i.start(0)+" -> "+i.end(0)+"]. Attempting to resume playback by seeking to the current time."),void this.tech_.trigger({type:"usage",name:"hls-unknown-waiting"})):void 0}}},{key:"techWaiting_",value:function(){var e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_())return!0;if(this.tech_.seeking()||null!==this.timer_)return!0;if(this.beforeSeekableWindow_(e,t)){var i=e.end(e.length-1);return this.logger_("Fell out of live window at time "+t+". Seeking to live point (seekable end) "+i),this.cancelTimer_(),this.tech_.setCurrentTime(i),this.tech_.trigger({type:"usage",name:"hls-live-resync"}),!0}var n=this.tech_.buffered(),r=Oc(n,t);if(this.videoUnderflow_(r,n,t))return this.cancelTimer_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"hls-video-underflow"}),!0;if(r.length>0){var s=r.start(0)-t;return this.logger_("Stopped at "+t+", setting timer for "+s+", seeking to "+r.start(0)),this.timer_=setTimeout(this.skipTheGap_.bind(this),1e3*s,t),!0}return!1}},{key:"afterSeekableWindow_",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!e.length)return!1;var r=e.end(e.length-1)+.1,s=!i.endList;return s&&n&&(r=e.end(e.length-1)+3*i.targetDuration),t>r}},{key:"beforeSeekableWindow_",value:function(e,t){return!!(e.length&&e.start(0)>0&&t2)return{start:r,end:s}}return null}}]),e}(),sd={errorInterval:30,getSource:function(e){return e(this.tech({IWillNotUseThisInPlugins:!0}).currentSource_)}},ad=function(e){!function e(t,i){var n=0,r=0,s=Nl.mergeOptions(sd,i);t.ready((function(){t.trigger({type:"usage",name:"hls-error-reload-initialized"})}));var a=function(){r&&t.currentTime(r)},o=function(e){null!=e&&(r=t.duration()!==1/0&&t.currentTime()||0,t.one("loadedmetadata",a),t.src(e),t.trigger({type:"usage",name:"hls-error-reload"}),t.play())},u=function(){if(Date.now()-n<1e3*s.errorInterval)t.trigger({type:"usage",name:"hls-error-reload-canceled"});else{if(s.getSource&&"function"==typeof s.getSource)return n=Date.now(),s.getSource.call(t,o);Nl.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!")}},l=function e(){t.off("loadedmetadata",a),t.off("error",u),t.off("dispose",e)};t.on("error",u),t.on("dispose",l),t.reloadSourceOnError=function(i){l(),e(t,i)}}(this,e)},od={PlaylistLoader:Zl,Playlist:mc,Decrypter:Rr,AsyncStream:Or,decrypt:Nr,utils:xc,STANDARD_PLAYLIST_SELECTOR:function(){var e=this.useDevicePixelRatio&&ee.devicePixelRatio||1;return function(e,t,i,n,r){var s=e.playlists.map((function(e){var t,i;return t=e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width,i=e.attributes.RESOLUTION&&e.attributes.RESOLUTION.height,{bandwidth:e.attributes.BANDWIDTH||ee.Number.MAX_VALUE,width:t,height:i,playlist:e}}));Lh(s,(function(e,t){return e.bandwidth-t.bandwidth}));var a=(s=s.filter((function(e){return!mc.isIncompatible(e.playlist)}))).filter((function(e){return mc.isEnabled(e.playlist)}));a.length||(a=s.filter((function(e){return!mc.isDisabled(e.playlist)})));var o=a.filter((function(e){return e.bandwidth*Th.BANDWIDTH_VARIANCEi||e.height>n}))).filter((function(e){return e.width===f[0].width&&e.height===f[0].height})),u=m[m.length-1],g=m.filter((function(e){return e.bandwidth===u.bandwidth}))[0]);var v=g||p||l||a[0]||s[0];return v?v.playlist:null}(this.playlists.master,this.systemBandwidth,parseInt(Ph(this.tech_.el(),"width"),10)*e,parseInt(Ph(this.tech_.el(),"height"),10)*e,this.limitRenditionByPlayerDimensions)},INITIAL_PLAYLIST_SELECTOR:function(){var e=this.playlists.master.playlists.filter(mc.isEnabled);return Lh(e,(function(e,t){return Oh(e,t)})),e.filter((function(e){return Qc(e.attributes.CODECS).videoCodec}))[0]||null},comparePlaylistBandwidth:Oh,comparePlaylistResolution:function(e,t){var i=void 0,n=void 0;return e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(i=e.attributes.RESOLUTION.width),i=i||ee.Number.MAX_VALUE,t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width&&(n=t.attributes.RESOLUTION.width),i===(n=n||ee.Number.MAX_VALUE)&&e.attributes.BANDWIDTH&&t.attributes.BANDWIDTH?e.attributes.BANDWIDTH-t.attributes.BANDWIDTH:i-n},xhr:yc()};["GOAL_BUFFER_LENGTH","MAX_GOAL_BUFFER_LENGTH","GOAL_BUFFER_LENGTH_RATE","BUFFER_LOW_WATER_LINE","MAX_BUFFER_LOW_WATER_LINE","BUFFER_LOW_WATER_LINE_RATE","BANDWIDTH_VARIANCE"].forEach((function(e){Object.defineProperty(od,e,{get:function(){return Nl.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),Th[e]},set:function(t){Nl.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),"number"!=typeof t||t<0?Nl.log.warn("value of Hls."+e+" must be greater than or equal to 0"):Th[e]=t}})}));var ud=function(e){if(/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i.test(e))return"hls";return/^application\/dash\+xml/i.test(e)?"dash":null},ld=function(e,t){for(var i=t.media(),n=-1,r=0;r0?1/this.throughput:0,Math.floor(1/(e+t))},set:function(){Nl.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:function(){return i.bandwidth||0},enumerable:!0},mediaRequests:{get:function(){return i.masterPlaylistController_.mediaRequests_()||0},enumerable:!0},mediaRequestsAborted:{get:function(){return i.masterPlaylistController_.mediaRequestsAborted_()||0},enumerable:!0},mediaRequestsTimedout:{get:function(){return i.masterPlaylistController_.mediaRequestsTimedout_()||0},enumerable:!0},mediaRequestsErrored:{get:function(){return i.masterPlaylistController_.mediaRequestsErrored_()||0},enumerable:!0},mediaTransferDuration:{get:function(){return i.masterPlaylistController_.mediaTransferDuration_()||0},enumerable:!0},mediaBytesTransferred:{get:function(){return i.masterPlaylistController_.mediaBytesTransferred_()||0},enumerable:!0},mediaSecondsLoaded:{get:function(){return i.masterPlaylistController_.mediaSecondsLoaded_()||0},enumerable:!0},buffered:{get:function(){return Nc(i.tech_.buffered())},enumerable:!0},currentTime:{get:function(){return i.tech_.currentTime()},enumerable:!0},currentSource:{get:function(){return i.tech_.currentSource_},enumerable:!0},currentTech:{get:function(){return i.tech_.name_},enumerable:!0},duration:{get:function(){return i.tech_.duration()},enumerable:!0},master:{get:function(){return i.playlists.master},enumerable:!0},playerDimensions:{get:function(){return i.tech_.currentDimensions()},enumerable:!0},seekable:{get:function(){return Nc(i.tech_.seekable())},enumerable:!0},timestamp:{get:function(){return Date.now()},enumerable:!0},videoPlaybackQuality:{get:function(){return i.tech_.getVideoPlaybackQuality()},enumerable:!0}}),this.tech_.one("canplay",this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_)),this.tech_.on("bandwidthupdate",(function(){i.options_.useBandwidthFromLocalStorage&&function(e){if(!window.localStorage)return!1;var t=hd();t=t?Nl.mergeOptions(t,e):e;try{window.localStorage.setItem("videojs-vhs",JSON.stringify(t))}catch(e){return!1}}({bandwidth:i.bandwidth,throughput:Math.round(i.throughput)})})),this.masterPlaylistController_.on("selectedinitialmedia",(function(){var e,t;t=(e=i).playlists,e.representations=function(){return t&&t.master&&t.master.playlists?t.master.playlists.filter((function(e){return!hc(e)})).map((function(t,i){return new id(e,t,t.id)})):[]},cd(i)})),this.on(this.masterPlaylistController_,"progress",(function(){this.tech_.trigger("progress")})),this.on(this.masterPlaylistController_,"firstplay",(function(){this.ignoreNextSeekingEvent_=!0})),this.setupQualityLevels_(),this.tech_.el()&&this.tech_.src(Nl.URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var e=this,t=Nl.players[this.tech_.options_.playerId];t&&t.qualityLevels&&!this.qualityLevels_&&(this.qualityLevels_=t.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",(function(){var t,i;t=e.qualityLevels_,(i=e).representations().forEach((function(e){t.addQualityLevel(e)})),ld(t,i.playlists)})),this.playlists.on("mediachange",(function(){ld(e.qualityLevels_,e.playlists)})))}},{key:"play",value:function(){this.masterPlaylistController_.play()}},{key:"setCurrentTime",value:function(e){this.masterPlaylistController_.setCurrentTime(e)}},{key:"duration",value:function(){return this.masterPlaylistController_.duration()}},{key:"seekable",value:function(){return this.masterPlaylistController_.seekable()}},{key:"dispose",value:function(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.masterPlaylistController_&&this.masterPlaylistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.player_&&(delete this.player_.vhs,delete this.player_.dash,delete this.player_.hls),this.tech_&&this.tech_.hls&&delete this.tech_.hls,function e(t,i,n){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,i);if(void 0===r){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,i,n)}if("value"in r)return r.value;var a=r.get;return void 0!==a?a.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"dispose",this).call(this)}},{key:"convertToProgramTime",value:function(e,t){return Ac({playlist:this.masterPlaylistController_.media(),time:e,callback:t})}},{key:"seekToProgramTime",value:function(e,t){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2;return Ic({programTime:e,playlist:this.masterPlaylistController_.media(),retryCount:n,pauseAfterSeek:i,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}}]),t}(Nl.getComponent("Component")),pd={name:"videojs-http-streaming",VERSION:"1.13.2",canHandleSource:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=Nl.mergeOptions(Nl.options,t);return pd.canPlayType(e.type,i)},handleSource:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=Nl.mergeOptions(Nl.options,i);return t.hls=new dd(e,t,n),t.hls.xhr=yc(),t.hls.src(e.src,e.type),t.hls},canPlayType:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=Nl.mergeOptions(Nl.options,t),n=i.hls.overrideNative,r=ud(e),s=r&&(!od.supportsTypeNatively(r)||n);return s?"maybe":""}};function fd(t){let i,n,r,s,a,b,T,S,k,C,w,E,x,A,I;return{c(){i=c("div"),n=c("div"),r=c("div"),s=c("div"),a=d(),b=c("div"),T=h(t[1]),S=d(),k=c("video"),C=c("source"),this.h()},l(e){i=g(e,"DIV",{class:!0});var o=m(i);n=g(o,"DIV",{class:!0});var u=m(n);r=g(u,"DIV",{class:!0});var c=m(r);s=g(c,"DIV",{class:!0}),m(s).forEach(l),a=y(c),b=g(c,"DIV",{class:!0});var h=m(b);T=v(h,t[1]),h.forEach(l),S=y(c),k=g(c,"VIDEO",{id:!0,class:!0,autoplay:!0,muted:!0,preload:!0,"data-setup":!0});var d=m(k);C=g(d,"SOURCE",{src:!0,type:!0}),d.forEach(l),c.forEach(l),u.forEach(l),o.forEach(l),this.h()},h(){f(s,"class","overlay"),f(b,"class","title"),C.src!==(w=t[0])&&f(C,"src",w),f(C,"type","application/x-mpegURL"),f(k,"id",t[2]),f(k,"class","video-js vjs-16-9"),k.autoplay=!0,k.muted=!0,f(k,"preload","auto"),f(k,"data-setup",E=JSON.stringify(t[4])),f(r,"class",x="stream live "+t[3]),f(n,"class","wrapper"),f(i,"class","quarter")},m(e,l){u(e,i,l),o(i,n),o(n,r),o(r,s),o(r,a),o(r,b),o(b,T),o(r,S),o(r,k),o(k,C),A||(I=p(i,"click",t[5]),A=!0)},p(e,[t]){2&t&&_(T,e[1]),1&t&&C.src!==(w=e[0])&&f(C,"src",w),4&t&&f(k,"id",e[2]),8&t&&x!==(x="stream live "+e[3])&&f(r,"class",x)},i:e,o:e,d(e){e&&l(i),A=!1,I()}}}function md(e,t,i){let{id:n}=t,{src:r}=t,{title:s}=t,a="",o="";let u;return S(()=>{try{u=Nl(a)}catch(e){console.log(e)}z.subscribe(e=>{i(3,o=""!==a&&e===a?"active":""),u&&(console.log(a+" - mute"),u.muted(!0),o&&(console.log(a+" - unmute"),u.muted(!1)))}),console.log(`mounted ${a} player`)}),e.$set=e=>{"id"in e&&i(6,n=e.id),"src"in e&&i(0,r=e.src),"title"in e&&i(1,s=e.title)},e.$$.update=()=>{64&e.$$.dirty&&i(2,a=n+"-live")},[r,s,a,o,{youtube:{ytControls:0}},function(){$.setPlaying(a)},n]}void 0!==Nl.MediaSource&&void 0!==Nl.URL||(Nl.MediaSource=lh,Nl.URL=ch),lh.supportsNativeMediaSources()&&Nl.getTech("Html5").registerSourceHandler(pd,0),Nl.HlsHandler=dd,Nl.HlsSourceHandler=pd,Nl.Hls=od,Nl.use||Nl.registerComponent("Hls",od),Nl.options.hls=Nl.options.hls||{},Nl.registerPlugin?Nl.registerPlugin("reloadSourceOnError",ad):Nl.plugin("reloadSourceOnError",ad);class gd extends q{constructor(e){super(),H(this,e,md,fd,s,{id:6,src:0,title:1})}}function vd(t){let i,n,r,s,a,b,T,S,k,C;return{c(){i=c("div"),n=c("div"),r=c("div"),s=c("div"),a=d(),b=c("div"),T=h(t[0]),this.h()},l(e){i=g(e,"DIV",{class:!0});var o=m(i);n=g(o,"DIV",{class:!0});var u=m(n);r=g(u,"DIV",{class:!0,"data-video-id":!0,id:!0});var c=m(r);s=g(c,"DIV",{class:!0}),m(s).forEach(l),a=y(c),b=g(c,"DIV",{class:!0});var h=m(b);T=v(h,t[0]),h.forEach(l),c.forEach(l),u.forEach(l),o.forEach(l),this.h()},h(){f(s,"class","overlay"),f(b,"class","title"),f(r,"class",S="stream live twitch "+t[2]),f(r,"data-video-id","4"),f(r,"id",t[1]),f(n,"class","wrapper"),f(i,"class","quarter")},m(e,l){u(e,i,l),o(i,n),o(n,r),o(r,s),o(r,a),o(r,b),o(b,T),k||(C=p(i,"click",t[3]),k=!0)},p(e,[t]){1&t&&_(T,e[0]),4&t&&S!==(S="stream live twitch "+e[2])&&f(r,"class",S),2&t&&f(r,"id",e[1])},i:e,o:e,d(e){e&&l(i),k=!1,C()}}}function yd(e,t,i){let n,{id:r}=t,{channel:s}=t,{title:a}=t,o="",u="";return S(()=>{try{n=new Twitch.Player(o,{channel:s,muted:!0,width:"100%",height:"100%"})}catch(e){console.log(e)}z.subscribe(e=>{i(2,u=""!==o&&e===o?"active":""),n&&(console.log(o+" - mute"),n.setMuted(!0),u&&(console.log(o+" - unmute"),n.setMuted(!1)))}),console.log(`mounted ${o} player`)}),e.$set=e=>{"id"in e&&i(4,r=e.id),"channel"in e&&i(5,s=e.channel),"title"in e&&i(0,a=e.title)},e.$$.update=()=>{16&e.$$.dirty&&i(1,o=r+"-twitch")},[a,o,u,function(){console.log("click "+o),$.setPlaying(o)},r,s]}class _d extends q{constructor(e){super(),H(this,e,yd,vd,s,{id:4,channel:5,title:0})}}function bd(e){let t,i,n,r,s,a,p,b,T,S,k,C,w;const E=new gd({props:{title:"Sky News",id:"skynews",src:"http://skydvn-sn-mobile-prod.skydvn.com/skynews/1404/latest.m3u8#"+e[0]}}),x=new gd({props:{title:"BBC News",id:"bbcnews24",src:"https://1636691764.rsc.cdn77.org/mhpoAXyltANt8TpRJoAoAg==,1617977604/LS-ATL-54548-11/tracks-v1a1/mono.m3u8#"+e[0]}}),A=new K({props:{title:"EuroNews",id:"euronews",src:"https://www.youtube.com/embed/sPgqEHsONK8?enablejsapi=1&autoplay=1&mute=1&controls=0&fs=0&modestbranding=1&cc_load_policy=1"}}),I=new gd({props:{title:"BBC Parliament",id:"bbcparliament",src:"https://a.files.bbci.co.uk/media/live/manifesto/audio_video/simulcast/hls/uk/abr_tv/ak/bbc_parliament.m3u8#"+e[0]}}),P=new gd({props:{title:"Bloomberg",id:"bloomberg",src:"https://liveprodeuwest.akamaized.net/eu1/Channel-EUTVqvs-AWS-ireland-1/Source-EUTVqvs-1000-1_live.m3u8#"+e[0]}}),L=new _d({props:{title:"twitch.tv/rukpolitics",id:"rukpolitics",channel:"rukpolitics"}}),O=new _d({props:{title:"twitch.tv/ukcommons",id:"ukcommons",channel:"ukcommons"}}),D=new _d({props:{title:"twitch.tv/democracylive",id:"democracylive",channel:"democracylive"}});return{c(){t=c("div"),i=h("Playing:"),n=h(e[1]),r=d(),s=c("div"),M(E.$$.fragment),a=d(),M(x.$$.fragment),p=d(),M(A.$$.fragment),b=d(),M(I.$$.fragment),T=d(),M(P.$$.fragment),S=d(),M(L.$$.fragment),k=d(),M(O.$$.fragment),C=d(),M(D.$$.fragment),this.h()},l(o){t=g(o,"DIV",{});var u=m(t);i=v(u,"Playing:"),n=v(u,e[1]),u.forEach(l),r=y(o),s=g(o,"DIV",{id:!0});var c=m(s);B(E.$$.fragment,c),a=y(c),B(x.$$.fragment,c),p=y(c),B(A.$$.fragment,c),b=y(c),B(I.$$.fragment,c),T=y(c),B(P.$$.fragment,c),S=y(c),B(L.$$.fragment,c),k=y(c),B(O.$$.fragment,c),C=y(c),B(D.$$.fragment,c),c.forEach(l),this.h()},h(){f(s,"id","container")},m(e,l){u(e,t,l),o(t,i),o(t,n),u(e,r,l),u(e,s,l),j(E,s,null),o(s,a),j(x,s,null),o(s,p),j(A,s,null),o(s,b),j(I,s,null),o(s,T),j(P,s,null),o(s,S),j(L,s,null),o(s,k),j(O,s,null),o(s,C),j(D,s,null),w=!0},p(e,[t]){(!w||2&t)&&_(n,e[1]);const i={};1&t&&(i.src="http://skydvn-sn-mobile-prod.skydvn.com/skynews/1404/latest.m3u8#"+e[0]),E.$set(i);const r={};1&t&&(r.src="https://1636691764.rsc.cdn77.org/mhpoAXyltANt8TpRJoAoAg==,1617977604/LS-ATL-54548-11/tracks-v1a1/mono.m3u8#"+e[0]),x.$set(r);const s={};1&t&&(s.src="https://a.files.bbci.co.uk/media/live/manifesto/audio_video/simulcast/hls/uk/abr_tv/ak/bbc_parliament.m3u8#"+e[0]),I.$set(s);const a={};1&t&&(a.src="https://liveprodeuwest.akamaized.net/eu1/Channel-EUTVqvs-AWS-ireland-1/Source-EUTVqvs-1000-1_live.m3u8#"+e[0]),P.$set(a)},i(e){w||(R(E.$$.fragment,e),R(x.$$.fragment,e),R(A.$$.fragment,e),R(I.$$.fragment,e),R(P.$$.fragment,e),R(L.$$.fragment,e),R(O.$$.fragment,e),R(D.$$.fragment,e),w=!0)},o(e){U(E.$$.fragment,e),U(x.$$.fragment,e),U(A.$$.fragment,e),U(I.$$.fragment,e),U(P.$$.fragment,e),U(L.$$.fragment,e),U(O.$$.fragment,e),U(D.$$.fragment,e),w=!1},d(e){e&&l(t),e&&l(r),e&&l(s),F(E),F(x),F(A),F(I),F(P),F(L),F(O),F(D)}}}function Td(e,t,i){let n;a(e,z,e=>i(1,n=e));let r=0;return i(0,r=(new Date).getTime.toString(36)),[r,n]}return new class extends q{constructor(e){super(),H(this,e,Td,bd,s,{})}}({target:document.body,props:{}})}();
+var Ml=function(e,t){return/^[a-z]+:/i.test(t)?t:(/\/\//i.test(e)||(e=Qe.buildAbsoluteURL(ee.location.href,e)),Qe.buildAbsoluteURL(e,t))},Bl=function(e,t,i){return e&&i.responseURL&&t!==i.responseURL?i.responseURL:t},jl=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},Fl=function(){function e(e,t){for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:{};jl(this,t);var r=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),s=n.withCredentials,a=void 0!==s&&s,o=n.handleManifestRedirects,u=void 0!==o&&o;r.srcUrl=e,r.hls_=i,r.withCredentials=a,r.handleManifestRedirects=u;var l=i.options_;if(r.customTagParsers=l&&l.customTagParsers||[],r.customTagMappers=l&&l.customTagMappers||[],!r.srcUrl)throw new Error("A non-empty playlist URL is required");return r.state="HAVE_NOTHING",r.on("mediaupdatetimeout",(function(){"HAVE_METADATA"===r.state&&(r.state="HAVE_CURRENT_METADATA",r.request=r.hls_.xhr({uri:Ml(r.master.uri,r.media().uri),withCredentials:r.withCredentials},(function(e,t){if(r.request)return e?r.playlistRequestError(r.request,r.media(),"HAVE_METADATA"):void r.haveMetadata(r.request,r.media().uri,r.media().id)})))})),r}return Vl(t,e),Fl(t,[{key:"playlistRequestError",value:function(e,t,i){var n=t.uri,r=t.id;this.request=null,i&&(this.state=i),this.error={playlist:this.master.playlists[r],status:e.status,message:"HLS playlist request error at URL: "+n+".",responseText:e.responseText,code:e.status>=500?4:2},this.trigger("error")}},{key:"haveMetadata",value:function(e,t,i){var n=this;this.request=null,this.state="HAVE_METADATA";var r=new st;this.customTagParsers.forEach((function(e){return r.addParser(e)})),this.customTagMappers.forEach((function(e){return r.addTagMapper(e)})),r.push(e.responseText),r.end(),r.manifest.uri=t,r.manifest.id=i,r.manifest.attributes=r.manifest.attributes||{};var s=Xl(this.master,r.manifest);this.targetDuration=r.manifest.targetDuration,s?(this.master=s,this.media_=this.master.playlists[i]):this.trigger("playlistunchanged"),this.media().endList||(ee.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=ee.setTimeout((function(){n.trigger("mediaupdatetimeout")}),Jl(this.media(),!!s))),this.trigger("loadedplaylist")}},{key:"dispose",value:function(){this.trigger("dispose"),this.stopRequest(),ee.clearTimeout(this.mediaUpdateTimeout),ee.clearTimeout(this.finalRenditionTimeout),this.off()}},{key:"stopRequest",value:function(){if(this.request){var e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}},{key:"media",value:function(e,t){var i=this;if(!e)return this.media_;if("HAVE_NOTHING"===this.state)throw new Error("Cannot switch media playlist from "+this.state);if("string"==typeof e){if(!this.master.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.master.playlists[e]}if(ee.clearTimeout(this.finalRenditionTimeout),t){var n=e.targetDuration/2*1e3||5e3;this.finalRenditionTimeout=ee.setTimeout(this.media.bind(this,e,!1),n)}else{var r=this.state,s=!this.media_||e.id!==this.media_.id;if(this.master.playlists[e.id].endList)return this.request&&(this.request.onreadystatechange=null,this.request.abort(),this.request=null),this.state="HAVE_METADATA",this.media_=e,void(s&&(this.trigger("mediachanging"),this.trigger("mediachange")));if(s){if(this.state="SWITCHING_MEDIA",this.request){if(e.resolvedUri===this.request.url)return;this.request.onreadystatechange=null,this.request.abort(),this.request=null}this.media_&&this.trigger("mediachanging"),this.request=this.hls_.xhr({uri:e.resolvedUri,withCredentials:this.withCredentials},(function(t,n){if(i.request){if(e.resolvedUri=Bl(i.handleManifestRedirects,e.resolvedUri,n),t)return i.playlistRequestError(i.request,e,r);i.haveMetadata(n,e.uri,e.id),"HAVE_MASTER"===r?i.trigger("loadedmetadata"):i.trigger("mediachange")}}))}}}},{key:"pause",value:function(){this.stopRequest(),ee.clearTimeout(this.mediaUpdateTimeout),"HAVE_NOTHING"===this.state&&(this.started=!1),"SWITCHING_MEDIA"===this.state?this.media_?this.state="HAVE_METADATA":this.state="HAVE_MASTER":"HAVE_CURRENT_METADATA"===this.state&&(this.state="HAVE_METADATA")}},{key:"load",value:function(e){var t=this;ee.clearTimeout(this.mediaUpdateTimeout);var i=this.media();if(e){var n=i?i.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=ee.setTimeout((function(){return t.load()}),n)}else this.started?i&&!i.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist"):this.start()}},{key:"start",value:function(){var e=this;this.started=!0,this.request=this.hls_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},(function(t,i){if(e.request){if(e.request=null,t)return e.error={status:i.status,message:"HLS playlist request error at URL: "+e.srcUrl+".",responseText:i.responseText,code:2},"HAVE_NOTHING"===e.state&&(e.started=!1),e.trigger("error");var n=new st;if(e.customTagParsers.forEach((function(e){return n.addParser(e)})),e.customTagMappers.forEach((function(e){return n.addTagMapper(e)})),n.push(i.responseText),n.end(),e.state="HAVE_MASTER",e.srcUrl=Bl(e.handleManifestRedirects,e.srcUrl,i),n.manifest.uri=e.srcUrl,n.manifest.playlists)return e.master=n.manifest,Yl(e.master),Ql(e.master),e.trigger("loadedplaylist"),void(e.request||e.media(n.manifest.playlists[0]));var r=Kl(0,e.srcUrl);return e.master={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:ee.location.href,playlists:[{uri:e.srcUrl,id:r,resolvedUri:e.srcUrl,attributes:{}}]},e.master.playlists[r]=e.master.playlists[0],e.master.playlists[e.srcUrl]=e.master.playlists[0],e.haveMetadata(i,e.srcUrl,r),e.trigger("loadedmetadata")}}))}}]),t}(zl),ec=Nl.createTimeRange,tc=function(e,t,i){var n,r;return void 0===t&&(t=e.mediaSequence+e.segments.length),ti){var r=[i,t];t=r[0],i=r[1]}if(t<0){for(var s=t;s=r););return Math.max(0,i)},sc=function(e,t,i,n){if(!e||!e.segments)return null;if(e.endList)return ic(e);if(null===t)return null;t=t||0;var r=i?rc(e,n):e.segments.length;return tc(e,e.mediaSequence+r,t)},ac=function(e){return e-Math.floor(e)==0},oc=function(e,t){if(ac(t))return t+.1*e;for(var i=t.toString().split(".")[1].length,n=1;n<=i;n++){var r=Math.pow(10,n),s=t*r;if(ac(s)||n===i)return(s+e)/r}},uc=oc.bind(null,1),lc=oc.bind(null,-1),cc=function(e){return e.excludeUntil&&e.excludeUntil>Date.now()},hc=function(e){return e.excludeUntil&&e.excludeUntil===1/0},dc=function(e){var t=cc(e);return!e.disabled&&!t},pc=function(e,t){return t.attributes&&t.attributes[e]},fc=function(e,t){if(1===e.playlists.length)return!0;var i=t.attributes.BANDWIDTH||Number.MAX_VALUE;return 0===e.playlists.filter((function(e){return!!dc(e)&&(e.attributes.BANDWIDTH||0)0)for(r=i-1;r>=0;r--)if(s=e.segments[r],(o+=lc(s.duration))>0)return{mediaIndex:r,startTime:n-nc(e,i,r)};return{mediaIndex:0,startTime:t}}if(i<0){for(r=i;r<0;r++)if((o-=e.targetDuration)<0)return{mediaIndex:0,startTime:t};i=0}for(r=i;r3&&void 0!==arguments[3]?arguments[3]:0;if(!pc("BANDWIDTH",i))return NaN;var r=e*i.attributes.BANDWIDTH;return(r-8*n)/t},isLowestEnabledRendition:fc},gc=Nl.xhr,vc=Nl.mergeOptions,yc=function(){return function e(t,i){t=vc({timeout:45e3},t);var n=e.beforeRequest||Nl.Hls.xhr.beforeRequest;if(n&&"function"==typeof n){var r=n(t);r&&(t=r)}var s=gc(t,(function(e,t){var n=s.response;!e&&n&&(s.responseTime=Date.now(),s.roundTripTime=s.responseTime-s.requestTime,s.bytesReceived=n.byteLength||n.length,s.bandwidth||(s.bandwidth=Math.floor(s.bytesReceived/s.roundTripTime*8*1e3))),t.headers&&(s.responseHeaders=t.headers),e&&"ETIMEDOUT"===e.code&&(s.timedout=!0),e||s.aborted||200===t.statusCode||206===t.statusCode||0===t.statusCode||(e=new Error("XHR Failed with a response of: "+(s&&(n||s.responseText)))),i(e,s)})),a=s.abort;return s.abort=function(){return s.aborted=!0,a.apply(s,arguments)},s.uri=t.uri,s.requestTime=Date.now(),s}},_c=function(e){var t,i,n={};return e.byterange&&(n.Range=(t=e.byterange,i=t.offset+t.length-1,"bytes="+t.offset+"-"+i)),n},bc=function(e,t){return e.start(t)+"-"+e.end(t)},Tc=function(e,t){var i=e.toString(16);return"00".substring(0,2-i.length)+i+(t%2?" ":"")},Sc=function(e){return e>=32&&e<126?String.fromCharCode(e):"."},kc=function(e){var t={};return Object.keys(e).forEach((function(i){var n=e[i];ArrayBuffer.isView(n)?t[i]={bytes:n.buffer,byteOffset:n.byteOffset,byteLength:n.byteLength}:t[i]=n})),t},Cc=function(e){var t=e.byterange||{length:1/0,offset:0};return[t.length,t.offset,e.resolvedUri].join(",")},wc=function(e){return e.resolvedUri},Ec=function(e){for(var t=Array.prototype.slice.call(e),i="",n=0;ni){if(e>i+.25*s.duration)return null;n=s}return{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:i-n.duration,type:n.videoTimingInfo?"accurate":"estimate"}}(n,t);if(!s)return r({message:"valid programTime was not found"});if("estimate"===s.type)return r({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:s.estimatedStart});var a={mediaSeconds:n},o=function(e,t){if(!t.dateTimeObject)return null;var i=t.videoTimingInfo.transmuxerPrependedSeconds,n=e-(t.videoTimingInfo.transmuxedPresentationStart+i);return new Date(t.dateTimeObject.getTime()+1e3*n)}(n,s.segment);return o&&(a.programDateTime=o.toISOString()),r(null,a)},Ic=function e(t){var i=t.programTime,n=t.playlist,r=t.retryCount,s=void 0===r?2:r,a=t.seekTo,o=t.pauseAfterSeek,u=void 0===o||o,l=t.tech,c=t.callback;if(!c)throw new Error("seekToProgramTime: callback must be provided");if(void 0===i||!n||!a)return c({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!n.endList&&!l.hasStarted_)return c({message:"player must be playing a live stream to start buffering"});if(!function(e){if(!e.segments||0===e.segments.length)return!1;for(var t=0;tnew Date(o.getTime()+1e3*u)?null:(i>o&&(n=a),{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:mc.duration(t,t.mediaSequence+t.segments.indexOf(n)),type:n.videoTimingInfo?"accurate":"estimate"})}(i,n);if(!h)return c({message:i+" was not found in the stream"});var d=h.segment,p=function(e,t){var i=void 0,n=void 0;try{i=new Date(e),n=new Date(t)}catch(e){}var r=i.getTime();return(n.getTime()-r)/1e3}(d.dateTimeObject,i);if("estimate"===h.type)return 0===s?c({message:i+" is not buffered yet. Try again"}):(a(h.estimatedStart+p),void l.one("seeked",(function(){e({programTime:i,playlist:n,retryCount:s-1,seekTo:a,pauseAfterSeek:u,tech:l,callback:c})})));var f=d.start+p;l.one("seeked",(function(){return c(null,l.currentTime())})),u&&l.pause(),a(f)},Pc=function(e,t){var i=[],n=void 0;if(e&&e.length)for(n=0;n=t}))},Oc=function(e,t){return Pc(e,(function(e){return e-1/30>=t}))},Dc=function(e){var t=[];if(!e||!e.length)return"";for(var i=0;i "+e.end(i));return t.join(", ")},Nc=function(e){for(var t=[],i=0;i=e&&i.removeCue(r)},Uc=function(e){return isNaN(e)||Math.abs(e)===1/0?Number.MAX_VALUE:e},Mc=function(e,t,i){var n=ee.WebKitDataCue||ee.VTTCue;if(t&&t.forEach((function(e){var t=e.stream;this.inbandTextTracks_[t].addCue(new n(e.startTime+this.timestampOffset,e.endTime+this.timestampOffset,e.text))}),e),i){var r=Uc(e.mediaSource_.duration);if(i.forEach((function(e){var t=e.cueTime+this.timestampOffset;!("number"!=typeof t||ee.isNaN(t)||t<0)&&t<1/0&&e.frames.forEach((function(e){var i=new n(t,t,e.value||e.url||e.data||"");i.frame=e,i.value=e,function(e){Object.defineProperties(e.frame,{id:{get:function(){return Nl.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),e.value.key}},value:{get:function(){return Nl.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),e.value.data}},privateData:{get:function(){return Nl.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),e.value.data}}})}(i),this.metadataTrack_.addCue(i)}),this)}),e),e.metadataTrack_&&e.metadataTrack_.cues&&e.metadataTrack_.cues.length){for(var s=e.metadataTrack_.cues,a=[],o=0;o-1)},this.trigger=function(t){var i,n,r,s;if(i=e[t])if(2===arguments.length)for(r=i.length,n=0;n>>1,e.samplingfrequencyindex<<7|e.channelcount<<3,6,1,2]))},g=function(e){return t(k.hdlr,I[e])},m=function(e){var i=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,e.duration>>>24&255,e.duration>>>16&255,e.duration>>>8&255,255&e.duration,85,196,0,0]);return e.samplerate&&(i[12]=e.samplerate>>>24&255,i[13]=e.samplerate>>>16&255,i[14]=e.samplerate>>>8&255,i[15]=255&e.samplerate),t(k.mdhd,i)},f=function(e){return t(k.mdia,m(e),g(e.type),o(e))},a=function(e){return t(k.mfhd,new Uint8Array([0,0,0,0,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e]))},o=function(e){return t(k.minf,"video"===e.type?t(k.vmhd,P):t(k.smhd,L),n(),y(e))},u=function(e,i){for(var n=[],r=i.length;r--;)n[r]=b(i[r]);return t.apply(null,[k.moof,a(e)].concat(n))},l=function(e){for(var i=e.length,n=[];i--;)n[i]=d(e[i]);return t.apply(null,[k.moov,h(4294967295)].concat(n).concat(c(e)))},c=function(e){for(var i=e.length,n=[];i--;)n[i]=T(e[i]);return t.apply(null,[k.mvex].concat(n))},h=function(e){var i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return t(k.mvhd,i)},v=function(e){var i,n,r=e.samples||[],s=new Uint8Array(4+r.length);for(n=0;n>>8),a.push(255&r[i].byteLength),a=a.concat(Array.prototype.slice.call(r[i]));for(i=0;i>>8),o.push(255&s[i].byteLength),o=o.concat(Array.prototype.slice.call(s[i]));if(n=[k.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(65280&e.width)>>8,255&e.width,(65280&e.height)>>8,255&e.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),t(k.avcC,new Uint8Array([1,e.profileIdc,e.profileCompatibility,e.levelIdc,255].concat([r.length],a,[s.length],o))),t(k.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],e.sarRatio){var u=e.sarRatio[0],l=e.sarRatio[1];n.push(t(k.pasp,new Uint8Array([(4278190080&u)>>24,(16711680&u)>>16,(65280&u)>>8,255&u,(4278190080&l)>>24,(16711680&l)>>16,(65280&l)>>8,255&l])))}return t.apply(null,n)},B=function(e){return t(k.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(65280&e.channelcount)>>8,255&e.channelcount,(65280&e.samplesize)>>8,255&e.samplesize,0,0,0,0,(65280&e.samplerate)>>8,255&e.samplerate,0,0]),r(e))},p=function(e){var i=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,0,(4278190080&e.duration)>>24,(16711680&e.duration)>>16,(65280&e.duration)>>8,255&e.duration,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,(65280&e.width)>>8,255&e.width,0,0,(65280&e.height)>>8,255&e.height,0,0]);return t(k.tkhd,i)},b=function(e){var i,n,r,s,a,o;return i=t(k.tfhd,new Uint8Array([0,0,0,58,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),a=Math.floor(e.baseMediaDecodeTime/(q+1)),o=Math.floor(e.baseMediaDecodeTime%(q+1)),n=t(k.tfdt,new Uint8Array([1,0,0,0,a>>>24&255,a>>>16&255,a>>>8&255,255&a,o>>>24&255,o>>>16&255,o>>>8&255,255&o])),92,"audio"===e.type?(r=S(e,92),t(k.traf,i,n,r)):(s=v(e),r=S(e,s.length+92),t(k.traf,i,n,r,s))},d=function(e){return e.duration=e.duration||4294967295,t(k.trak,p(e),f(e))},T=function(e){var i=new Uint8Array([0,0,0,0,(4278190080&e.id)>>24,(16711680&e.id)>>16,(65280&e.id)>>8,255&e.id,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return"video"!==e.type&&(i[i.length-1]=0),t(k.trex,i)},V=function(e,t){var i=0,n=0,r=0,s=0;return e.length&&(void 0!==e[0].duration&&(i=1),void 0!==e[0].size&&(n=2),void 0!==e[0].flags&&(r=4),void 0!==e[0].compositionTimeOffset&&(s=8)),[0,0,i|n|r|s,1,(4278190080&e.length)>>>24,(16711680&e.length)>>>16,(65280&e.length)>>>8,255&e.length,(4278190080&t)>>>24,(16711680&t)>>>16,(65280&t)>>>8,255&t]},F=function(e,i){var n,r,s,a;for(i+=20+16*(r=e.samples||[]).length,n=V(r,i),a=0;a>>24,(16711680&s.duration)>>>16,(65280&s.duration)>>>8,255&s.duration,(4278190080&s.size)>>>24,(16711680&s.size)>>>16,(65280&s.size)>>>8,255&s.size,s.flags.isLeading<<2|s.flags.dependsOn,s.flags.isDependedOn<<6|s.flags.hasRedundancy<<4|s.flags.paddingValue<<1|s.flags.isNonSyncSample,61440&s.flags.degradationPriority,15&s.flags.degradationPriority,(4278190080&s.compositionTimeOffset)>>>24,(16711680&s.compositionTimeOffset)>>>16,(65280&s.compositionTimeOffset)>>>8,255&s.compositionTimeOffset]);return t(k.trun,new Uint8Array(n))},j=function(e,i){var n,r,s,a;for(i+=20+8*(r=e.samples||[]).length,n=V(r,i),a=0;a>>24,(16711680&s.duration)>>>16,(65280&s.duration)>>>8,255&s.duration,(4278190080&s.size)>>>24,(16711680&s.size)>>>16,(65280&s.size)>>>8,255&s.size]);return t(k.trun,new Uint8Array(n))},S=function(e,t){return"audio"===e.type?j(e,t):F(e,t)};s=function(){return t(k.ftyp,C,w,C,E)};var W,z,$,G,X,K,Y,Q,J=function(e){return t(k.mdat,e)},Z=u,ee=function(e){var t,i=s(),n=l(e);return(t=new Uint8Array(i.byteLength+n.byteLength)).set(i),t.set(n,i.byteLength),t},te=function(e,t){var i={size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}};return i.dataOffset=t,i.compositionTimeOffset=e.pts-e.dts,i.duration=e.duration,i.size=4*e.length,i.size+=e.byteLength,e.keyFrame&&(i.flags.dependsOn=2,i.flags.isNonSyncSample=0),i},ie=function(e){var t,i,n=[],r=[];for(r.byteLength=0,r.nalCount=0,r.duration=0,n.byteLength=0,t=0;t1&&(t=e.shift(),e.byteLength-=t.byteLength,e.nalCount-=t.nalCount,e[0][0].dts=t.dts,e[0][0].pts=t.pts,e[0][0].duration+=t.duration),e},se=function(e,t){var i,n,r,s,a,o=t||0,u=[];for(i=0;ide/2))){for((a=he[e.samplerate])||(a=t[0].data),o=0;o=i?e:(t.minSegmentDts=1/0,e.filter((function(e){return e.dts>=i&&(t.minSegmentDts=Math.min(t.minSegmentDts,e.dts),t.minSegmentPts=t.minSegmentDts,!0)})))},ye=function(e){var t,i,n=[];for(t=0;t>>8,r=255&t,t!==this.PADDING_)if(t===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(t===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(e.pts),this.flushDisplayed(e.pts),i=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=i,this.startPts_=e.pts;else if(t===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(e.pts);else if(t===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(e.pts);else if(t===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(e.pts);else if(t===this.CARRIAGE_RETURN_)this.clearFormatting(e.pts),this.flushDisplayed(e.pts),this.shiftRowsUp_(),this.startPts_=e.pts;else if(t===this.BACKSPACE_)"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1);else if(t===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(e.pts),this.displayed_=Oe();else if(t===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Oe();else if(t===this.RESUME_DIRECT_CAPTIONING_)"paintOn"!==this.mode_&&(this.flushDisplayed(e.pts),this.displayed_=Oe()),this.mode_="paintOn",this.startPts_=e.pts;else if(this.isSpecialCharacter(n,r))s=Pe((n=(3&n)<<8)|r),this[this.mode_](e.pts,s),this.column_++;else if(this.isExtCharacter(n,r))"popOn"===this.mode_?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),s=Pe((n=(3&n)<<8)|r),this[this.mode_](e.pts,s),this.column_++;else if(this.isMidRowCode(n,r))this.clearFormatting(e.pts),this[this.mode_](e.pts," "),this.column_++,14==(14&r)&&this.addFormatting(e.pts,["i"]),1==(1&r)&&this.addFormatting(e.pts,["u"]);else if(this.isOffsetControlCode(n,r))this.column_+=3&r;else if(this.isPAC(n,r)){var a=Le.indexOf(7968&t);"rollUp"===this.mode_&&(a-this.rollUpRows_+1<0&&(a=this.rollUpRows_-1),this.setRollUp(e.pts,a)),a!==this.row_&&(this.clearFormatting(e.pts),this.row_=a),1&r&&-1===this.formatting_.indexOf("u")&&this.addFormatting(e.pts,["u"]),16==(16&t)&&(this.column_=4*((14&t)>>1)),this.isColorPAC(r)&&14==(14&r)&&this.addFormatting(e.pts,["i"])}else this.isNormalChar(n)&&(0===r&&(r=null),s=Pe(n),s+=Pe(r),this[this.mode_](e.pts,s),this.column_+=s.length)}else this.lastControlCode_=null}};De.prototype=new H,De.prototype.flushDisplayed=function(e){var t=this.displayed_.map((function(e){try{return e.trim()}catch(e){return console.error("Skipping malformed caption."),""}})).join("\n").replace(/^\n+|\n+$/g,"");t.length&&this.trigger("data",{startPts:this.startPts_,endPts:e,text:t,stream:this.name_})},De.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=Oe(),this.nonDisplayed_=Oe(),this.lastControlCode_=null,this.column_=0,this.row_=14,this.rollUpRows_=2,this.formatting_=[]},De.prototype.setConstants=function(){0===this.dataChannel_?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):1===this.dataChannel_&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=32|this.CONTROL_,this.END_OF_CAPTION_=47|this.CONTROL_,this.ROLL_UP_2_ROWS_=37|this.CONTROL_,this.ROLL_UP_3_ROWS_=38|this.CONTROL_,this.ROLL_UP_4_ROWS_=39|this.CONTROL_,this.CARRIAGE_RETURN_=45|this.CONTROL_,this.RESUME_DIRECT_CAPTIONING_=41|this.CONTROL_,this.BACKSPACE_=33|this.CONTROL_,this.ERASE_DISPLAYED_MEMORY_=44|this.CONTROL_,this.ERASE_NON_DISPLAYED_MEMORY_=46|this.CONTROL_},De.prototype.isSpecialCharacter=function(e,t){return e===this.EXT_&&t>=48&&t<=63},De.prototype.isExtCharacter=function(e,t){return(e===this.EXT_+1||e===this.EXT_+2)&&t>=32&&t<=63},De.prototype.isMidRowCode=function(e,t){return e===this.EXT_&&t>=32&&t<=47},De.prototype.isOffsetControlCode=function(e,t){return e===this.OFFSET_&&t>=33&&t<=35},De.prototype.isPAC=function(e,t){return e>=this.BASE_&&e=64&&t<=127},De.prototype.isColorPAC=function(e){return e>=64&&e<=79||e>=96&&e<=127},De.prototype.isNormalChar=function(e){return e>=32&&e<=127},De.prototype.setRollUp=function(e,t){if("rollUp"!==this.mode_&&(this.row_=14,this.mode_="rollUp",this.flushDisplayed(e),this.nonDisplayed_=Oe(),this.displayed_=Oe()),void 0!==t&&t!==this.row_)for(var i=0;i"}),"");this[this.mode_](e,i)},De.prototype.clearFormatting=function(e){if(this.formatting_.length){var t=this.formatting_.reverse().reduce((function(e,t){return e+""+t+">"}),"");this.formatting_=[],this[this.mode_](e,t)}},De.prototype.popOn=function(e,t){var i=this.nonDisplayed_[this.row_];i+=t,this.nonDisplayed_[this.row_]=i},De.prototype.rollUp=function(e,t){var i=this.displayed_[this.row_];i+=t,this.displayed_[this.row_]=i},De.prototype.shiftRowsUp_=function(){var e;for(e=0;et&&(i=-1);Math.abs(t-e)>4294967296;)e+=8589934592*i;return e},Me=function e(t){var i,n;e.prototype.init.call(this),this.type_=t||"shared",this.push=function(e){"shared"!==this.type_&&e.type!==this.type_||(void 0===n&&(n=e.dts),e.dts=Ue(e.dts,n),e.pts=Ue(e.pts,n),i=e.dts,this.trigger("data",e))},this.flush=function(){n=i,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){n=void 0,i=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};Me.prototype=new H;var Be,je=Me,Fe=function(e,t,i){var n,r="";for(n=t;n>>2;h*=4,h+=3&c[7],u.timeStamp=h,void 0===t.pts&&void 0===t.dts&&(t.pts=u.timeStamp,t.dts=u.timeStamp),this.trigger("timestamp",u)}t.frames.push(u),a+=10,a+=o}while(a>>4>1&&(n+=t[n]+1),0===i.pid)i.type="pat",e(t.subarray(n),i),this.trigger("data",i);else if(i.pid===this.pmtPid)for(i.type="pmt",e(t.subarray(n),i),this.trigger("data",i);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else void 0===this.programMapTable?this.packetsWaitingForPmt.push([t,n,i]):this.processPes_(t,n,i)},this.processPes_=function(e,t,i){i.pid===this.programMapTable.video?i.streamType=Re.H264_STREAM_TYPE:i.pid===this.programMapTable.audio?i.streamType=Re.ADTS_STREAM_TYPE:i.streamType=this.programMapTable["timed-metadata"][i.pid],i.type="pes",i.data=e.subarray(t),this.trigger("data",i)}}).prototype=new H,ze.STREAM_TYPES={h264:27,adts:15},($e=function(){var e,t=this,i={data:[],size:0},n={data:[],size:0},r={data:[],size:0},s=function(e,i,n){var r,s,a=new Uint8Array(e.size),o={type:i},u=0,l=0;if(e.data.length&&!(e.size<9)){for(o.trackId=e.data[0].pid,u=0;u>>3,h.pts*=4,h.pts+=(6&c[13])>>>1,h.dts=h.pts,64&d&&(h.dts=(14&c[14])<<27|(255&c[15])<<20|(254&c[16])<<12|(255&c[17])<<5|(254&c[18])>>>3,h.dts*=4,h.dts+=(6&c[18])>>>1)),h.data=c.subarray(9+c[8]),r="video"===i||o.packetLength<=e.size,(n||r)&&(e.size=0,e.data.length=0),r&&t.trigger("data",o)}};$e.prototype.init.call(this),this.push=function(a){({pat:function(){},pes:function(){var e,t;switch(a.streamType){case Re.H264_STREAM_TYPE:case Re.H264_STREAM_TYPE:e=i,t="video";break;case Re.ADTS_STREAM_TYPE:e=n,t="audio";break;case Re.METADATA_STREAM_TYPE:e=r,t="timed-metadata";break;default:return}a.payloadUnitStartIndicator&&s(e,t,!0),e.data.push(a),e.size+=a.data.byteLength},pmt:function(){var i={type:"metadata",tracks:[]};null!==(e=a.programMapTable).video&&i.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+e.video,codec:"avc",type:"video"}),null!==e.audio&&i.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+e.audio,codec:"adts",type:"audio"}),t.trigger("data",i)}})[a.type]()},this.reset=function(){i.size=0,i.data.length=0,n.size=0,n.data.length=0,this.trigger("reset")},this.flushStreams_=function(){s(i,"video"),s(n,"audio"),s(r,"timed-metadata")},this.flush=function(){this.flushStreams_(),this.trigger("done")}}).prototype=new H;var Ke={PAT_PID:0,MP2T_PACKET_LENGTH:188,TransportPacketStream:We,TransportParseStream:ze,ElementaryStream:$e,TimestampRolloverStream:Xe,CaptionStream:Ne.CaptionStream,Cea608Stream:Ne.Cea608Stream,MetadataStream:Ge};for(var Ye in Re)Re.hasOwnProperty(Ye)&&(Ke[Ye]=Re[Ye]);var Qe,Je=Ke,Ze=de,et=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];(Qe=function(e){var t,i=0;Qe.prototype.init.call(this),this.push=function(n){var r,s,a,o,u,l,c=0;if(e||(i=0),"audio"===n.type)for(t?(o=t,(t=new Uint8Array(o.byteLength+n.data.byteLength)).set(o),t.set(n.data,o.byteLength)):t=n.data;c+5>5,l=(u=1024*(1+(3&t[c+6])))*Ze/et[(60&t[c+2])>>>2],a=c+r,t.byteLength>>6&3),channelcount:(1&t[c+2])<<2|(192&t[c+3])>>>6,samplerate:et[(60&t[c+2])>>>2],samplingfrequencyindex:(60&t[c+2])>>>2,samplesize:16,data:t.subarray(c+7+s,a)}),i++,t.byteLength===a)return void(t=void 0);t=t.subarray(a)}else c++},this.flush=function(){i=0,this.trigger("done")},this.reset=function(){t=void 0,this.trigger("reset")},this.endTimeline=function(){t=void 0,this.trigger("endedtimeline")}}).prototype=new H;var tt,it,nt,rt=Qe,st=function(e){var t=e.byteLength,i=0,n=0;this.length=function(){return 8*t},this.bitsAvailable=function(){return 8*t+n},this.loadWord=function(){var r=e.byteLength-t,s=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");s.set(e.subarray(r,r+a)),i=new DataView(s.buffer).getUint32(0),n=8*a,t-=a},this.skipBits=function(e){var r;n>e?(i<<=e,n-=e):(e-=n,e-=8*(r=Math.floor(e/8)),t-=r,this.loadWord(),i<<=e,n-=e)},this.readBits=function(e){var r=Math.min(n,e),s=i>>>32-r;return(n-=r)>0?i<<=r:t>0&&this.loadWord(),(r=e-r)>0?s<>>e))return i<<=e,n-=e,e;return this.loadWord(),e+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var e=this.skipLeadingZeros();return this.readBits(e+1)-1},this.readExpGolomb=function(){var e=this.readUnsignedExpGolomb();return 1&e?1+e>>>1:-1*(e>>>1)},this.readBoolean=function(){return 1===this.readBits(1)},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};(it=function(){var e,t,i=0;it.prototype.init.call(this),this.push=function(n){var r;t?((r=new Uint8Array(t.byteLength+n.data.byteLength)).set(t),r.set(n.data,t.byteLength),t=r):t=n.data;for(var s=t.byteLength;i3&&this.trigger("data",t.subarray(i+3)),t=null,i=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}}).prototype=new H,nt={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},(tt=function(){var e,t,i,n,r,s,a,o=new it;tt.prototype.init.call(this),e=this,this.push=function(e){"video"===e.type&&(t=e.trackId,i=e.pts,n=e.dts,o.push(e))},o.on("data",(function(a){var o={trackId:t,pts:i,dts:n,data:a};switch(31&a[0]){case 5:o.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:o.nalUnitType="sei_rbsp",o.escapedRBSP=r(a.subarray(1));break;case 7:o.nalUnitType="seq_parameter_set_rbsp",o.escapedRBSP=r(a.subarray(1)),o.config=s(o.escapedRBSP);break;case 8:o.nalUnitType="pic_parameter_set_rbsp";break;case 9:o.nalUnitType="access_unit_delimiter_rbsp"}e.trigger("data",o)})),o.on("done",(function(){e.trigger("done")})),o.on("partialdone",(function(){e.trigger("partialdone")})),o.on("reset",(function(){e.trigger("reset")})),o.on("endedtimeline",(function(){e.trigger("endedtimeline")})),this.flush=function(){o.flush()},this.partialFlush=function(){o.partialFlush()},this.reset=function(){o.reset()},this.endTimeline=function(){o.endTimeline()},a=function(e,t){var i,n=8,r=8;for(i=0;i>4?i+20:i+10},ct=function(e,t){var i=(224&e[t+5])>>5,n=e[t+4]<<3;return 6144&e[t+3]|n|i};(at=function(){var e=new Uint8Array,t=0;at.prototype.init.call(this),this.setTimestamp=function(e){t=e},this.push=function(i){var n,r,s,a,o=0,u=0;for(e.length?(a=e.length,(e=new Uint8Array(i.byteLength+a)).set(e.subarray(0,a)),e.set(i,a)):e=i;e.length-u>=3;)if(e[u]!=="I".charCodeAt(0)||e[u+1]!=="D".charCodeAt(0)||e[u+2]!=="3".charCodeAt(0))if(255!=(255&e[u])||240!=(240&e[u+1]))u++;else{if(e.length-u<7)break;if(u+(o=ct(e,u))>e.length)break;s={type:"audio",data:e.subarray(u,u+o),pts:t,dts:t},this.trigger("data",s),u+=o}else{if(e.length-u<10)break;if(u+(o=lt(e,u))>e.length)break;r={type:"timed-metadata",data:e.subarray(u,u+o)},this.trigger("data",r),u+=o}n=e.length-u,e=n>0?e.subarray(u):new Uint8Array},this.reset=function(){e=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){e=new Uint8Array,this.trigger("endedtimeline")}}).prototype=new H;var ht,dt,pt,ft,mt=at,gt=ot.H264Stream,vt=ut,yt=de,_t=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],bt=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],Tt=function(e,t){var i;if(e.length!==t.length)return!1;for(i=0;i=-1e4&&i<=45e3&&(!n||o>i)&&(n=s,o=i));return n?n.gop:null},this.alignGopsAtStart_=function(e){var t,i,n,r,s,o,u,l;for(s=e.byteLength,o=e.nalCount,u=e.duration,t=i=0;tn.pts?t++:(i++,s-=r.byteLength,o-=r.nalCount,u-=r.duration);return 0===i?e:i===e.length?null:((l=e.slice(i)).byteLength=s,l.duration=u,l.nalCount=o,l.pts=l[0].pts,l.dts=l[0].dts,l)},this.alignGopsAtEnd_=function(e){var t,i,n,r,s,o,u;for(t=a.length-1,i=e.length-1,s=null,o=!1;t>=0&&i>=0;){if(n=a[t],r=e[i],n.pts===r.pts){o=!0;break}n.pts>r.pts?t--:(t===a.length-1&&(s=i),i--)}if(!o&&null===s)return null;if(0===(u=o?i:s))return e;var l=e.slice(u),c=l.reduce((function(e,t){return e.byteLength+=t.byteLength,e.duration+=t.duration,e.nalCount+=t.nalCount,e}),{byteLength:0,duration:0,nalCount:0});return l.byteLength=c.byteLength,l.duration=c.duration,l.nalCount=c.nalCount,l.pts=l[0].pts,l.dts=l[0].dts,l},this.alignGopsWith=function(e){a=e}}).prototype=new H,(ft=function(e,t){this.numberOfTracks=0,this.metadataStream=t,void 0!==(e=e||{}).remux?this.remuxTracks=!!e.remux:this.remuxTracks=!0,"boolean"==typeof e.keepOriginalTimestamps?this.keepOriginalTimestamps=e.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,ft.prototype.init.call(this),this.push=function(e){return e.text?this.pendingCaptions.push(e):e.frames?this.pendingMetadata.push(e):(this.pendingTracks.push(e.track),this.pendingBytes+=e.boxes.byteLength,"video"===e.track.type&&(this.videoTrack=e.track,this.pendingBoxes.push(e.boxes)),void("audio"===e.track.type&&(this.audioTrack=e.track,this.pendingBoxes.unshift(e.boxes))))}}).prototype=new H,ft.prototype.flush=function(e){var t,i,n,r,s=0,a={captions:[],captionStreams:{},metadata:[],info:{}},o=0;if(this.pendingTracks.length=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0))}if(this.videoTrack?(o=this.videoTrack.timelineStartInfo.pts,bt.forEach((function(e){a.info[e]=this.videoTrack[e]}),this)):this.audioTrack&&(o=this.audioTrack.timelineStartInfo.pts,_t.forEach((function(e){a.info[e]=this.audioTrack[e]}),this)),this.videoTrack||this.audioTrack){for(1===this.pendingTracks.length?a.type=this.pendingTracks[0].type:a.type="combined",this.emittedTracks+=this.pendingTracks.length,n=ee(this.pendingTracks),a.initSegment=new Uint8Array(n.byteLength),a.initSegment.set(n),a.data=new Uint8Array(this.pendingBytes),r=0;r=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},ft.prototype.setRemux=function(e){this.remuxTracks=e},(pt=function(e){var t,i,n=this,r=!0;pt.prototype.init.call(this),e=e||{},this.baseMediaDecodeTime=e.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var r={};this.transmuxPipeline_=r,r.type="aac",r.metadataStream=new Je.MetadataStream,r.aacStream=new mt,r.audioTimestampRolloverStream=new Je.TimestampRolloverStream("audio"),r.timedMetadataTimestampRolloverStream=new Je.TimestampRolloverStream("timed-metadata"),r.adtsStream=new rt,r.coalesceStream=new ft(e,r.metadataStream),r.headOfPipeline=r.aacStream,r.aacStream.pipe(r.audioTimestampRolloverStream).pipe(r.adtsStream),r.aacStream.pipe(r.timedMetadataTimestampRolloverStream).pipe(r.metadataStream).pipe(r.coalesceStream),r.metadataStream.on("timestamp",(function(e){r.aacStream.setTimestamp(e.timeStamp)})),r.aacStream.on("data",(function(s){"timed-metadata"!==s.type||r.audioSegmentStream||(i=i||{timelineStartInfo:{baseMediaDecodeTime:n.baseMediaDecodeTime},codec:"adts",type:"audio"},r.coalesceStream.numberOfTracks++,r.audioSegmentStream=new dt(i,e),r.audioSegmentStream.on("timingInfo",n.trigger.bind(n,"audioTimingInfo")),r.adtsStream.pipe(r.audioSegmentStream).pipe(r.coalesceStream)),n.trigger("trackinfo",{hasAudio:!!i,hasVideo:!!t})})),r.coalesceStream.on("data",this.trigger.bind(this,"data")),r.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setupTsPipeline=function(){var r={};this.transmuxPipeline_=r,r.type="ts",r.metadataStream=new Je.MetadataStream,r.packetStream=new Je.TransportPacketStream,r.parseStream=new Je.TransportParseStream,r.elementaryStream=new Je.ElementaryStream,r.timestampRolloverStream=new Je.TimestampRolloverStream,r.adtsStream=new rt,r.h264Stream=new gt,r.captionStream=new Je.CaptionStream,r.coalesceStream=new ft(e,r.metadataStream),r.headOfPipeline=r.packetStream,r.packetStream.pipe(r.parseStream).pipe(r.elementaryStream).pipe(r.timestampRolloverStream),r.timestampRolloverStream.pipe(r.h264Stream),r.timestampRolloverStream.pipe(r.adtsStream),r.timestampRolloverStream.pipe(r.metadataStream).pipe(r.coalesceStream),r.h264Stream.pipe(r.captionStream).pipe(r.coalesceStream),r.elementaryStream.on("data",(function(s){var a;if("metadata"===s.type){for(a=s.tracks.length;a--;)t||"video"!==s.tracks[a].type?i||"audio"!==s.tracks[a].type||((i=s.tracks[a]).timelineStartInfo.baseMediaDecodeTime=n.baseMediaDecodeTime):(t=s.tracks[a]).timelineStartInfo.baseMediaDecodeTime=n.baseMediaDecodeTime;t&&!r.videoSegmentStream&&(r.coalesceStream.numberOfTracks++,r.videoSegmentStream=new ht(t,e),r.videoSegmentStream.on("timelineStartInfo",(function(e){i&&(i.timelineStartInfo=e,r.audioSegmentStream.setEarliestDts(e.dts))})),r.videoSegmentStream.on("processedGopsInfo",n.trigger.bind(n,"gopInfo")),r.videoSegmentStream.on("segmentTimingInfo",n.trigger.bind(n,"videoSegmentTimingInfo")),r.videoSegmentStream.on("baseMediaDecodeTime",(function(e){i&&r.audioSegmentStream.setVideoBaseMediaDecodeTime(e)})),r.videoSegmentStream.on("timingInfo",n.trigger.bind(n,"videoTimingInfo")),r.h264Stream.pipe(r.videoSegmentStream).pipe(r.coalesceStream)),i&&!r.audioSegmentStream&&(r.coalesceStream.numberOfTracks++,r.audioSegmentStream=new dt(i,e),r.audioSegmentStream.on("timingInfo",n.trigger.bind(n,"audioTimingInfo")),r.adtsStream.pipe(r.audioSegmentStream).pipe(r.coalesceStream)),n.trigger("trackinfo",{hasAudio:!!i,hasVideo:!!t})}})),r.coalesceStream.on("data",this.trigger.bind(this,"data")),r.coalesceStream.on("id3Frame",(function(e){e.dispatchType=r.metadataStream.dispatchType,n.trigger("id3Frame",e)})),r.coalesceStream.on("caption",this.trigger.bind(this,"caption")),r.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setBaseMediaDecodeTime=function(n){var r=this.transmuxPipeline_;e.keepOriginalTimestamps||(this.baseMediaDecodeTime=n),i&&(i.timelineStartInfo.dts=void 0,i.timelineStartInfo.pts=void 0,Te(i),e.keepOriginalTimestamps||(i.timelineStartInfo.baseMediaDecodeTime=n),r.audioTimestampRolloverStream&&r.audioTimestampRolloverStream.discontinuity()),t&&(r.videoSegmentStream&&(r.videoSegmentStream.gopCache_=[]),t.timelineStartInfo.dts=void 0,t.timelineStartInfo.pts=void 0,Te(t),r.captionStream.reset(),e.keepOriginalTimestamps||(t.timelineStartInfo.baseMediaDecodeTime=n)),r.timestampRolloverStream&&r.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(e){i&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(e)},this.setRemux=function(t){var i=this.transmuxPipeline_;e.remux=t,i&&i.coalesceStream&&i.coalesceStream.setRemux(t)},this.alignGopsWith=function(e){t&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(e)},this.push=function(e){if(r){var t=vt(e);t&&"aac"!==this.transmuxPipeline_.type?this.setupAacPipeline():t||"ts"===this.transmuxPipeline_.type||this.setupTsPipeline(),r=!1}this.transmuxPipeline_.headOfPipeline.push(e)},this.flush=function(){r=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}}).prototype=new H;var kt={Transmuxer:pt,VideoSegmentStream:ht,AudioSegmentStream:dt,AUDIO_PROPERTIES:_t,VIDEO_PROPERTIES:bt,generateVideoSegmentTimingInfo:St},Ct=function(){function e(e,t){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:"",t={codecCount:0},i=void 0;return t.codecCount=e.split(",").length,t.codecCount=t.codecCount||2,(i=/(^|\s|,)+(avc[13])([^ ,]*)/i.exec(e))&&(t.videoCodec=i[2],t.videoObjectTypeIndicator=i[3]),t.audioProfile=/(^|\s|,)+mp4a.[0-9A-Fa-f]+\.([0-9A-Fa-f]+)/i.exec(e),t.audioProfile=t.audioProfile&&t.audioProfile[2],t},Jc=function(e,t,i){return e+"/"+t+'; codecs="'+i.filter((function(e){return!!e})).join(", ")+'"'},Zc=function(e,t){var i=function(e){return e.segments&&e.segments.length&&e.segments[0].map?"mp4":"mp2t"}(t),n=function(e){var t=e.attributes||{};return t.CODECS?Qc(t.CODECS):Kc}(t),r=t.attributes||{},s=!0,a=!1;if(!t)return[];if(e.mediaGroups.AUDIO&&r.AUDIO){var o=e.mediaGroups.AUDIO[r.AUDIO];if(o)for(var u in a=!0,s=!1,o)if(!o[u].uri&&!o[u].playlists){s=!0;break}}a&&!n.audioProfile&&(s||(n.audioProfile=function(e,t){if(!e.mediaGroups.AUDIO||!t)return null;var i=e.mediaGroups.AUDIO[t];if(!i)return null;for(var n in i){var r=i[n];if(r.default&&r.playlists)return Qc(r.playlists[0].attributes.CODECS).audioProfile}return null}(e,r.AUDIO)),n.audioProfile||(Nl.log.warn("Multiple audio tracks present but no audio codec string is specified. Attempting to use the default audio codec (mp4a.40.2)"),n.audioProfile=Kc.audioProfile));var l={};n.videoCodec&&(l.video=""+n.videoCodec+n.videoObjectTypeIndicator),n.audioProfile&&(l.audio="mp4a.40."+n.audioProfile);var c=Jc("audio",i,[l.audio]),h=Jc("video",i,[l.video]),d=Jc("video",i,[l.video,l.audio]);return a?!s&&l.video?[h,c]:s||l.video?[d,c]:[c,c]:l.video?[d]:[c]},eh=function(e){var t={type:"",parameters:{}},i=e.trim().split(";");return t.type=i.shift().trim(),i.forEach((function(e){var i=e.trim().split("=");if(i.length>1){var n=i[0].replace(/"/g,"").trim(),r=i[1].replace(/"/g,"").trim();t.parameters[n]=r}})),t},th=function(e){return/mp4a\.\d+.\d+/i.test(e)},ih=function(e){return/avc1\.[\da-f]+/i.test(e)},nh=function(e,t,i){if(null==t||!e.length)return[];var n=Math.ceil(9e4*(t-i+3)),r=void 0;for(r=0;rn);r++);return e.slice(r)},rh=function(e){function t(e,i){jl(this,t);var n=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,Nl.EventTarget));n.timestampOffset_=0,n.pendingBuffers_=[],n.bufferUpdating_=!1,n.mediaSource_=e,n.codecs_=i,n.audioCodec_=null,n.videoCodec_=null,n.audioDisabled_=!1,n.appendAudioInitSegment_=!0,n.gopBuffer_=[],n.timeMapping_=0,n.safeAppend_=Nl.browser.IE_VERSION>=11;var r={remux:!1,alignGopsAtEnd:n.safeAppend_};return n.codecs_.forEach((function(e){th(e)?n.audioCodec_=e:ih(e)&&(n.videoCodec_=e)})),n.transmuxer_=new Xc,n.transmuxer_.postMessage({action:"init",options:r}),n.transmuxer_.onmessage=function(e){return"data"===e.data.action?n.data_(e):"done"===e.data.action?n.done_(e):"gopInfo"===e.data.action?n.appendGopInfo_(e):"videoSegmentTimingInfo"===e.data.action?n.videoSegmentTimingInfo_(e.data.videoSegmentTimingInfo):void 0},Object.defineProperty(n,"timestampOffset",{get:function(){return this.timestampOffset_},set:function(e){"number"==typeof e&&e>=0&&(this.timestampOffset_=e,this.appendAudioInitSegment_=!0,this.gopBuffer_.length=0,this.timeMapping_=0,this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:e}))}}),Object.defineProperty(n,"appendWindowStart",{get:function(){return(this.videoBuffer_||this.audioBuffer_).appendWindowStart},set:function(e){this.videoBuffer_&&(this.videoBuffer_.appendWindowStart=e),this.audioBuffer_&&(this.audioBuffer_.appendWindowStart=e)}}),Object.defineProperty(n,"updating",{get:function(){return!!(this.bufferUpdating_||!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.updating||this.videoBuffer_&&this.videoBuffer_.updating)}}),Object.defineProperty(n,"buffered",{get:function(){return function(e,t,i){var n=null,r=null,s=0,a=[],o=[];if(!e&&!t)return Nl.createTimeRange();if(!e)return t.buffered;if(!t)return e.buffered;if(i)return e.buffered;if(0===e.buffered.length&&0===t.buffered.length)return Nl.createTimeRange();for(var u=e.buffered,l=t.buffered,c=u.length;c--;)a.push({time:u.start(c),type:"start"}),a.push({time:u.end(c),type:"end"});for(c=l.length;c--;)a.push({time:l.start(c),type:"start"}),a.push({time:l.end(c),type:"end"});for(a.sort((function(e,t){return e.time-t.time})),c=0;c=n);r++);return e.slice(0,r).concat(t)}(this.gopBuffer_,e.data.gopInfo,this.safeAppend_)}},{key:"remove",value:function(e,t){if(this.videoBuffer_&&(this.videoBuffer_.updating=!0,this.videoBuffer_.remove(e,t),this.gopBuffer_=function(e,t,i,n){for(var r=Math.ceil(9e4*(t-n)),s=Math.ceil(9e4*(i-n)),a=e.slice(),o=e.length;o--&&!(e[o].pts<=s););if(-1===o)return a;for(var u=o+1;u--&&!(e[u].pts<=r););return u=Math.max(u,0),a.splice(u,o-u+1),a}(this.gopBuffer_,e,t,this.timeMapping_)),!this.audioDisabled_&&this.audioBuffer_&&(this.audioBuffer_.updating=!0,this.audioBuffer_.remove(e,t)),Rc(e,t,this.metadataTrack_),this.inbandTextTracks_)for(var i in this.inbandTextTracks_)Rc(e,t,this.inbandTextTracks_[i])}},{key:"processPendingSegments_",value:function(){var e={video:{segments:[],bytes:0},audio:{segments:[],bytes:0},captions:[],metadata:[]};if(!this.pendingBuffers_.length)return this.trigger("updateend"),void(this.bufferUpdating_=!1);e=this.pendingBuffers_.reduce((function(e,t){var i=t.type,n=t.data,r=t.initSegment;return e[i].segments.push(n),e[i].bytes+=n.byteLength,e[i].initSegment=r,t.captions&&(e.captions=e.captions.concat(t.captions)),t.info&&(e[i].info=t.info),t.metadata&&(e.metadata=e.metadata.concat(t.metadata)),e}),e),this.videoBuffer_||this.audioBuffer_||(0===e.video.bytes&&(this.videoCodec_=null),0===e.audio.bytes&&(this.audioCodec_=null),this.createRealSourceBuffers_()),e.audio.info&&this.mediaSource_.trigger({type:"audioinfo",info:e.audio.info}),e.video.info&&this.mediaSource_.trigger({type:"videoinfo",info:e.video.info}),this.appendAudioInitSegment_&&(!this.audioDisabled_&&this.audioBuffer_&&(e.audio.segments.unshift(e.audio.initSegment),e.audio.bytes+=e.audio.initSegment.byteLength),this.appendAudioInitSegment_=!1);var t=!1;this.videoBuffer_&&e.video.bytes?(e.video.segments.unshift(e.video.initSegment),e.video.bytes+=e.video.initSegment.byteLength,this.concatAndAppendSegments_(e.video,this.videoBuffer_)):!this.videoBuffer_||!this.audioDisabled_&&this.audioBuffer_||(t=!0),Mc(this,e.captions,e.metadata),!this.audioDisabled_&&this.audioBuffer_&&this.concatAndAppendSegments_(e.audio,this.audioBuffer_),this.pendingBuffers_.length=0,t&&this.trigger("updateend"),this.bufferUpdating_=!1}},{key:"concatAndAppendSegments_",value:function(e,t){var i=0,n=void 0;if(e.bytes){n=new Uint8Array(e.bytes),e.segments.forEach((function(e){n.set(e,i),i+=e.byteLength}));try{t.updating=!0,t.appendBuffer(n)}catch(e){this.mediaSource_.player_&&this.mediaSource_.player_.error({code:-3,type:"APPEND_BUFFER_ERR",message:e.message,originalError:e})}}}},{key:"abort",value:function(){this.videoBuffer_&&this.videoBuffer_.abort(),!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:"reset"}),this.pendingBuffers_.length=0,this.bufferUpdating_=!1}},{key:"dispose",value:function(){this.transmuxer_&&this.transmuxer_.terminate(),this.trigger("dispose"),this.off()}}]),t}(Nl.EventTarget),sh=function(e){function t(){jl(this,t);var e=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),i=void 0;for(i in e.nativeMediaSource_=new ee.MediaSource,e.nativeMediaSource_)i in t.prototype||"function"!=typeof e.nativeMediaSource_[i]||(e[i]=e.nativeMediaSource_[i].bind(e.nativeMediaSource_));return e.duration_=NaN,Object.defineProperty(e,"duration",{get:function(){return this.duration_===1/0?this.duration_:this.nativeMediaSource_.duration},set:function(e){this.duration_=e,e===1/0||(this.nativeMediaSource_.duration=e)}}),Object.defineProperty(e,"seekable",{get:function(){return this.duration_===1/0?Nl.createTimeRanges([[0,this.nativeMediaSource_.duration]]):this.nativeMediaSource_.seekable}}),Object.defineProperty(e,"readyState",{get:function(){return this.nativeMediaSource_.readyState}}),Object.defineProperty(e,"activeSourceBuffers",{get:function(){return this.activeSourceBuffers_}}),e.sourceBuffers=[],e.activeSourceBuffers_=[],e.updateActiveSourceBuffers_=function(){if(e.activeSourceBuffers_.length=0,1===e.sourceBuffers.length){var t=e.sourceBuffers[0];return t.appendAudioInitSegment_=!0,t.audioDisabled_=!t.audioCodec_,void e.activeSourceBuffers_.push(t)}for(var i=!1,n=!0,r=0;rthis.nativeMediaSource_.duration||isNaN(this.nativeMediaSource_.duration))&&(this.nativeMediaSource_.duration=t)}},{key:"addSourceBuffer",value:function(e){var t=void 0,i=eh(e);if(/^(video|audio)\/mp2t$/i.test(i.type)){var n=[];i.parameters&&i.parameters.codecs&&(n=i.parameters.codecs.split(","),n=(n=Yc(n)).filter((function(e){return th(e)||ih(e)}))),0===n.length&&(n=["avc1.4d400d","mp4a.40.2"]),t=new rh(this,n),0!==this.sourceBuffers.length&&(this.sourceBuffers[0].createRealSourceBuffers_(),t.createRealSourceBuffers_(),this.sourceBuffers[0].audioDisabled_=!0)}else t=this.nativeMediaSource_.addSourceBuffer(e);return this.sourceBuffers.push(t),t}},{key:"dispose",value:function(){this.trigger("dispose"),this.off(),this.sourceBuffers.forEach((function(e){e.dispose&&e.dispose()})),this.sourceBuffers.length=0}}]),t}(Nl.EventTarget),ah=0;Nl.mediaSources={};var oh=function(e,t){var i=Nl.mediaSources[e];if(!i)throw new Error("Media Source not found (Video.js)");i.trigger({type:"sourceopen",swfId:t})},uh=function(){return!!ee.MediaSource&&!!ee.MediaSource.isTypeSupported&&ee.MediaSource.isTypeSupported('video/mp4;codecs="avc1.4d400d,mp4a.40.2"')},lh=function(){if(this.MediaSource={open:oh,supportsNativeMediaSources:uh},uh())return new sh;throw new Error("Cannot use create a virtual MediaSource for this video")};lh.open=oh,lh.supportsNativeMediaSources=uh;var ch={createObjectURL:function(e){var t=void 0;return e instanceof sh?(t=ee.URL.createObjectURL(e.nativeMediaSource_),e.url_=t,t):e instanceof sh?(t="blob:vjs-media-source/"+ah,ah++,Nl.mediaSources[t]=e,t):(t=ee.URL.createObjectURL(e),e.url_=t,t)}};Nl.MediaSource=lh,Nl.URL=ch;var hh=Nl.EventTarget,dh=Nl.mergeOptions,ph=function(e,t){for(var i=void 0,n=dh(e,{duration:t.duration,minimumUpdatePeriod:t.minimumUpdatePeriod}),r=0;r2&&void 0!==arguments[2]?arguments[2]:{},r=arguments[3];jl(this,t);var s=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),a=n.withCredentials,o=void 0!==a&&a,u=n.handleManifestRedirects,l=void 0!==u&&u;if(s.hls_=i,s.withCredentials=o,s.handleManifestRedirects=l,!e)throw new Error("A non-empty playlist URL or playlist is required");return s.on("minimumUpdatePeriod",(function(){s.refreshXml_()})),s.on("mediaupdatetimeout",(function(){s.refreshMedia_(s.media().id)})),s.state="HAVE_NOTHING",s.loadedPlaylists_={},"string"==typeof e?(s.srcUrl=e,s.sidxMapping_={},Hl(s)):(s.setupChildLoader(r,e),s)}return Vl(t,e),Fl(t,[{key:"setupChildLoader",value:function(e,t){this.masterPlaylistLoader_=e,this.childPlaylist_=t}},{key:"dispose",value:function(){this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},ee.clearTimeout(this.minimumUpdatePeriodTimeout_),ee.clearTimeout(this.mediaRequest_),ee.clearTimeout(this.mediaUpdateTimeout),this.off()}},{key:"hasPendingRequest",value:function(){return this.request||this.mediaRequest_}},{key:"stopRequest",value:function(){if(this.request){var e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}},{key:"sidxRequestFinished_",value:function(e,t,i,n){var r=this;return function(s,a){if(r.request){if(r.request=null,s)return r.error={status:a.status,message:"DASH playlist request error at URL: "+e.uri,response:a.response,code:2},i&&(r.state=i),r.trigger("error"),n(t,null);var o=new Uint8Array(a.response),u=Nn.parseSidx(o.subarray(8));return n(t,u)}}}},{key:"media",value:function(e){var t=this;if(!e)return this.media_;if("HAVE_NOTHING"===this.state)throw new Error("Cannot switch media playlist from "+this.state);var i=this.state;if("string"==typeof e){if(!this.master.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.master.playlists[e]}var n=!this.media_||e.id!==this.media_.id;if(n&&this.loadedPlaylists_[e.id]&&this.loadedPlaylists_[e.id].endList)return this.state="HAVE_METADATA",this.media_=e,void(n&&(this.trigger("mediachanging"),this.trigger("mediachange")));if(n)if(this.media_&&this.trigger("mediachanging"),e.sidx){var r=void 0,s=void 0;this.masterPlaylistLoader_?(r=this.masterPlaylistLoader_.master,s=this.masterPlaylistLoader_.sidxMapping_):(r=this.master,s=this.sidxMapping_);var a=fh(e.sidx);s[a]={sidxInfo:e.sidx},this.request=gh(e.sidx,e,this.hls_.xhr,{handleManifestRedirects:this.handleManifestRedirects},this.sidxRequestFinished_(e,r,i,(function(n,r){if(!n||!r)throw new Error("failed to request sidx");s[a].sidx=r,t.haveMetadata({startingState:i,playlist:n.playlists[e.id]})})))}else this.mediaRequest_=ee.setTimeout(this.haveMetadata.bind(this,{startingState:i,playlist:e}),0)}},{key:"haveMetadata",value:function(e){var t=e.startingState,i=e.playlist;this.state="HAVE_METADATA",this.loadedPlaylists_[i.id]=i,this.mediaRequest_=null,this.refreshMedia_(i.id),"HAVE_MASTER"===t?this.trigger("loadedmetadata"):this.trigger("mediachange")}},{key:"pause",value:function(){this.stopRequest(),ee.clearTimeout(this.mediaUpdateTimeout),ee.clearTimeout(this.minimumUpdatePeriodTimeout_),"HAVE_NOTHING"===this.state&&(this.started=!1)}},{key:"load",value:function(e){var t=this;ee.clearTimeout(this.mediaUpdateTimeout),ee.clearTimeout(this.minimumUpdatePeriodTimeout_);var i=this.media();if(e){var n=i?i.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=ee.setTimeout((function(){return t.load()}),n)}else this.started?i&&!i.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist"):this.start()}},{key:"parseMasterXml",value:function(){var e=kn(this.masterXml_,{manifestUri:this.srcUrl,clientOffset:this.clientOffset_,sidxMapping:this.sidxMapping_});e.uri=this.srcUrl;for(var t=0;t"):function(){}};function _h(){}var bh=function(){function e(t,i,n,r){jl(this,e),this.callbacks_=[],this.pendingCallback_=null,this.timestampOffset_=0,this.mediaSource=t,this.processedAppend_=!1,this.type_=n,this.mimeType_=i,this.logger_=yh("SourceUpdater["+n+"]["+i+"]"),"closed"===t.readyState?t.addEventListener("sourceopen",this.createSourceBuffer_.bind(this,i,r)):this.createSourceBuffer_(i,r)}return Fl(e,[{key:"createSourceBuffer_",value:function(e,t){var i=this;this.sourceBuffer_=this.mediaSource.addSourceBuffer(e),this.logger_("created SourceBuffer"),t&&(t.trigger("sourcebufferadded"),this.mediaSource.sourceBuffers.length<2)?t.on("sourcebufferadded",(function(){i.start_()})):this.start_()}},{key:"start_",value:function(){var e=this;this.started_=!0,this.onUpdateendCallback_=function(){var t=e.pendingCallback_;e.pendingCallback_=null,e.sourceBuffer_.removing=!1,e.logger_("buffered ["+Dc(e.buffered())+"]"),t&&t(),e.runCallback_()},this.sourceBuffer_.addEventListener("updateend",this.onUpdateendCallback_),this.runCallback_()}},{key:"abort",value:function(e){var t=this;this.processedAppend_&&this.queueCallback_((function(){t.sourceBuffer_.abort()}),e)}},{key:"appendBuffer",value:function(e,t){var i=this;this.processedAppend_=!0,this.queueCallback_((function(){e.videoSegmentTimingInfoCallback&&i.sourceBuffer_.addEventListener("videoSegmentTimingInfo",e.videoSegmentTimingInfoCallback),i.sourceBuffer_.appendBuffer(e.bytes)}),(function(){e.videoSegmentTimingInfoCallback&&i.sourceBuffer_.removeEventListener("videoSegmentTimingInfo",e.videoSegmentTimingInfoCallback),t()}))}},{key:"buffered",value:function(){return this.sourceBuffer_?this.sourceBuffer_.buffered:Nl.createTimeRanges()}},{key:"remove",value:function(e,t){var i=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:_h;this.processedAppend_&&this.queueCallback_((function(){i.logger_("remove ["+e+" => "+t+"]"),i.sourceBuffer_.removing=!0,i.sourceBuffer_.remove(e,t)}),n)}},{key:"updating",value:function(){return!this.sourceBuffer_||this.sourceBuffer_.updating||!!this.pendingCallback_&&this.pendingCallback_!==_h}},{key:"timestampOffset",value:function(e){var t=this;return void 0!==e&&(this.queueCallback_((function(){t.sourceBuffer_.timestampOffset=e,t.runCallback_()})),this.timestampOffset_=e),this.timestampOffset_}},{key:"queueCallback_",value:function(e,t){this.callbacks_.push([e.bind(this),t]),this.runCallback_()}},{key:"runCallback_",value:function(){var e=void 0;!this.updating()&&this.callbacks_.length&&this.started_&&(e=this.callbacks_.shift(),this.pendingCallback_=e[1],e[0]())}},{key:"dispose",value:function(){var e=this,t=function t(){e.sourceBuffer_&&"open"===e.mediaSource.readyState&&e.sourceBuffer_.abort(),e.sourceBuffer_.removeEventListener("updateend",t)};this.sourceBuffer_.removeEventListener("updateend",this.onUpdateendCallback_),this.sourceBuffer_.removing?this.sourceBuffer_.addEventListener("updateend",t):t()}}]),e}(),Th={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,BUFFER_LOW_WATER_LINE_RATE:1},Sh=2,kh=-101,Ch=-102,wh=function(e){e.forEach((function(e){e.abort()}))},Eh=function(e,t){return t.timedout?{status:t.status,message:"HLS request timed-out at URL: "+t.uri,code:kh,xhr:t}:t.aborted?{status:t.status,message:"HLS request aborted at URL: "+t.uri,code:Ch,xhr:t}:e?{status:t.status,message:"HLS request errored at URL: "+t.uri,code:Sh,xhr:t}:null},xh=function(e,t,i){var n=0,r=!1;return function(s,a){if(!r)return s?(r=!0,wh(e),i(s,a)):(n+=1)===e.length?(a.endOfAllRequests=Date.now(),a.encryptedBytes?function(e,t,i){e.addEventListener("message",(function n(r){if(r.data.source===t.requestId){e.removeEventListener("message",n);var s=r.data.decrypted;return t.bytes=new Uint8Array(s.bytes,s.byteOffset,s.byteLength),i(null,t)}}));var n=void 0;n=t.key.bytes.slice?t.key.bytes.slice():new Uint32Array(Array.prototype.slice.call(t.key.bytes)),e.postMessage(kc({source:t.requestId,encrypted:t.encryptedBytes,key:n,iv:t.key.iv}),[t.encryptedBytes.buffer,n.buffer])}(t,a,i):i(null,a)):void 0}},Ah=function(e,t){return function(i){var n,r,s;return e.stats=Nl.mergeOptions(e.stats,(r=(n=i).target,(s={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-r.requestTime||0}).bytesReceived=n.loaded,s.bandwidth=Math.floor(s.bytesReceived/s.roundTripTime*8*1e3),s)),!e.stats.firstBytesReceivedAt&&e.stats.bytesReceived&&(e.stats.firstBytesReceivedAt=Date.now()),t(i,e)}},Ih=function(e,t,i,n,r,s,a){var o=[],u=xh(o,i,a);if(r.key&&!r.key.bytes){var l=e(Nl.mergeOptions(t,{uri:r.key.resolvedUri,responseType:"arraybuffer"}),function(e,t){return function(i,n){var r=n.response,s=Eh(i,n);if(s)return t(s,e);if(16!==r.byteLength)return t({status:n.status,message:"Invalid HLS key at URL: "+n.uri,code:Sh,xhr:n},e);var a=new DataView(r);return e.key.bytes=new Uint32Array([a.getUint32(0),a.getUint32(4),a.getUint32(8),a.getUint32(12)]),t(null,e)}}(r,u));o.push(l)}if(r.map&&!r.map.bytes){var c=e(Nl.mergeOptions(t,{uri:r.map.resolvedUri,responseType:"arraybuffer",headers:_c(r.map)}),function(e,t,i){return function(n,r){var s=r.response,a=Eh(n,r);return a?i(a,e):0===s.byteLength?i({status:r.status,message:"Empty HLS segment content at URL: "+r.uri,code:Sh,xhr:r},e):(e.map.bytes=new Uint8Array(r.response),t&&!t.isInitialized()&&t.init(),e.map.timescales=Mn.timescale(e.map.bytes),e.map.videoTrackIds=Mn.videoTrackIds(e.map.bytes),i(null,e))}}(r,n,u));o.push(c)}var h=e(Nl.mergeOptions(t,{uri:r.resolvedUri,responseType:"arraybuffer",headers:_c(r)}),function(e,t,i){return function(n,r){var s=r.response,a=Eh(n,r),o=void 0;return a?i(a,e):0===s.byteLength?i({status:r.status,message:"Empty HLS segment content at URL: "+r.uri,code:Sh,xhr:r},e):(e.stats=function(e){return{bandwidth:e.bandwidth,bytesReceived:e.bytesReceived||0,roundTripTime:e.roundTripTime||0}}(r),e.key?e.encryptedBytes=new Uint8Array(r.response):e.bytes=new Uint8Array(r.response),t&&e.map&&e.map.bytes&&(t.isInitialized()||t.init(),(o=t.parse(e.bytes,e.map.videoTrackIds,e.map.timescales))&&o.captions&&(e.captionStreams=o.captionStreams,e.fmp4Captions=o.captions)),i(null,e))}}(r,n,u));return h.addEventListener("progress",Ah(r,s)),o.push(h),function(){return wh(o)}},Ph=function(e,t){var i;return e&&(i=ee.getComputedStyle(e))?i[t]:""},Lh=function(e,t){var i=e.slice();e.sort((function(e,n){var r=t(e,n);return 0===r?i.indexOf(e)-i.indexOf(n):r}))},Oh=function(e,t){var i=void 0,n=void 0;return e.attributes.BANDWIDTH&&(i=e.attributes.BANDWIDTH),i=i||ee.Number.MAX_VALUE,t.attributes.BANDWIDTH&&(n=t.attributes.BANDWIDTH),i-(n=n||ee.Number.MAX_VALUE)},Dh=function(e,t,i){if(!e||!t)return!1;var n=i===e.segments.length;return e.endList&&"open"===t.readyState&&n},Nh=function(e){return"number"==typeof e&&isFinite(e)},Rh=function(e){function t(e){jl(this,t);var i=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));if(!e)throw new TypeError("Initialization settings are required");if("function"!=typeof e.currentTime)throw new TypeError("No currentTime getter specified");if(!e.mediaSource)throw new TypeError("No MediaSource specified");return i.bandwidth=e.bandwidth,i.throughput={rate:0,count:0},i.roundTrip=NaN,i.resetStats_(),i.mediaIndex=null,i.hasPlayed_=e.hasPlayed,i.currentTime_=e.currentTime,i.seekable_=e.seekable,i.seeking_=e.seeking,i.duration_=e.duration,i.mediaSource_=e.mediaSource,i.hls_=e.hls,i.loaderType_=e.loaderType,i.startingMedia_=void 0,i.segmentMetadataTrack_=e.segmentMetadataTrack,i.goalBufferLength_=e.goalBufferLength,i.sourceType_=e.sourceType,i.inbandTextTracks_=e.inbandTextTracks,i.state_="INIT",i.checkBufferTimeout_=null,i.error_=void 0,i.currentTimeline_=-1,i.pendingSegment_=null,i.mimeType_=null,i.sourceUpdater_=null,i.xhrOptions_=null,i.activeInitSegmentId_=null,i.initSegments_={},i.cacheEncryptionKeys_=e.cacheEncryptionKeys,i.keyCache_={},"main"===i.loaderType_?i.captionParser_=new tr:i.captionParser_=null,i.decrypter_=e.decrypter,i.syncController_=e.syncController,i.syncPoint_={segmentIndex:0,time:0},i.triggerSyncInfoUpdate_=function(){return i.trigger("syncinfoupdate")},i.syncController_.on("syncinfoupdate",i.triggerSyncInfoUpdate_),i.mediaSource_.addEventListener("sourceopen",(function(){return i.ended_=!1})),i.fetchAtBuffer_=!1,i.logger_=yh("SegmentLoader["+i.loaderType_+"]"),Object.defineProperty(i,"state",{get:function(){return this.state_},set:function(e){e!==this.state_&&(this.logger_(this.state_+" -> "+e),this.state_=e)}}),i}return Vl(t,e),Fl(t,[{key:"resetStats_",value:function(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0}},{key:"dispose",value:function(){this.trigger("dispose"),this.state="DISPOSED",this.pause(),this.abort_(),this.sourceUpdater_&&this.sourceUpdater_.dispose(),this.resetStats_(),this.captionParser_&&this.captionParser_.reset(),this.checkBufferTimeout_&&ee.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_),this.off()}},{key:"abort",value:function(){"WAITING"===this.state?(this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()):this.pendingSegment_&&(this.pendingSegment_=null)}},{key:"abort_",value:function(){this.pendingSegment_&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null}},{key:"error",value:function(e){return void 0!==e&&(this.error_=e),this.pendingSegment_=null,this.error_}},{key:"endOfStream",value:function(){this.ended_=!0,this.pause(),this.trigger("ended")}},{key:"buffered_",value:function(){return this.sourceUpdater_?this.sourceUpdater_.buffered():Nl.createTimeRanges()}},{key:"initSegment",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e)return null;var i=Cc(e),n=this.initSegments_[i];return t&&!n&&e.bytes&&(this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,timescales:e.timescales,videoTrackIds:e.videoTrackIds}),n||e}},{key:"segmentKey",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e)return null;var i=wc(e),n=this.keyCache_[i];this.cacheEncryptionKeys_&&t&&!n&&e.bytes&&(this.keyCache_[i]=n={resolvedUri:e.resolvedUri,bytes:e.bytes});var r={resolvedUri:(n||e).resolvedUri};return n&&(r.bytes=n.bytes),r}},{key:"couldBeginLoading_",value:function(){return this.playlist_&&(this.sourceUpdater_||this.mimeType_&&"INIT"===this.state)&&!this.paused()}},{key:"load",value:function(){if(this.monitorBuffer_(),this.playlist_){if(this.syncController_.setDateTimeMapping(this.playlist_),"INIT"===this.state&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||"READY"!==this.state&&"INIT"!==this.state||(this.state="READY")}}},{key:"init_",value:function(){return this.state="READY",this.sourceUpdater_=new bh(this.mediaSource_,this.mimeType_,this.loaderType_,this.sourceBufferEmitter_),this.resetEverything(),this.monitorBuffer_()}},{key:"playlist",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e){var i=this.playlist_,n=this.pendingSegment_;this.playlist_=e,this.xhrOptions_=t,"INIT"===this.state&&(e.syncInfo={mediaSequence:e.mediaSequence,time:0});var r=null;if(i&&(i.id?r=i.id:i.uri&&(r=i.uri)),this.logger_("playlist update ["+r+" => "+(e.id||e.uri)+"]"),this.trigger("syncinfoupdate"),"INIT"===this.state&&this.couldBeginLoading_())return this.init_();if(i&&i.uri===e.uri){var s=e.mediaSequence-i.mediaSequence;this.logger_("live window shift ["+s+"]"),null!==this.mediaIndex&&(this.mediaIndex-=s),n&&(n.mediaIndex-=s,n.mediaIndex>=0&&(n.segment=e.segments[n.mediaIndex])),this.syncController_.saveExpiredSegmentInfo(i,e)}else null!==this.mediaIndex&&this.resyncLoader()}}},{key:"pause",value:function(){this.checkBufferTimeout_&&(ee.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}},{key:"paused",value:function(){return null===this.checkBufferTimeout_}},{key:"mimeType",value:function(e,t){this.mimeType_||(this.mimeType_=e,this.sourceBufferEmitter_=t,"INIT"===this.state&&this.couldBeginLoading_()&&this.init_())}},{key:"resetEverything",value:function(e){this.ended_=!1,this.resetLoader(),this.remove(0,1/0,e),this.captionParser_&&this.captionParser_.clearAllCaptions(),this.trigger("reseteverything")}},{key:"resetLoader",value:function(){this.fetchAtBuffer_=!1,this.resyncLoader()}},{key:"resyncLoader",value:function(){this.mediaIndex=null,this.syncPoint_=null,this.abort()}},{key:"remove",value:function(e,t,i){if(t===1/0&&(t=this.duration_()),this.sourceUpdater_&&this.sourceUpdater_.remove(e,t,i),Rc(e,t,this.segmentMetadataTrack_),this.inbandTextTracks_)for(var n in this.inbandTextTracks_)Rc(e,t,this.inbandTextTracks_[n])}},{key:"monitorBuffer_",value:function(){this.checkBufferTimeout_&&ee.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=ee.setTimeout(this.monitorBufferTick_.bind(this),1)}},{key:"monitorBufferTick_",value:function(){"READY"===this.state&&this.fillBuffer_(),this.checkBufferTimeout_&&ee.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=ee.setTimeout(this.monitorBufferTick_.bind(this),500)}},{key:"fillBuffer_",value:function(){if(!this.sourceUpdater_.updating()){this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var e=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);e&&(this.isEndOfStream_(e.mediaIndex)?this.endOfStream():(e.mediaIndex!==this.playlist_.segments.length-1||"ended"!==this.mediaSource_.readyState||this.seeking_())&&(e.timeline!==this.currentTimeline_&&(this.syncController_.reset(),e.timestampOffset=e.startOfSegment,this.captionParser_&&this.captionParser_.clearAllCaptions()),this.loadSegment_(e)))}}},{key:"isEndOfStream_",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.playlist_;return Dh(t,this.mediaSource_,e)&&!this.sourceUpdater_.updating()}},{key:"checkBuffer_",value:function(e,t,i,n,r,s){var a=0,o=void 0;e.length&&(a=e.end(e.length-1));var u=Math.max(0,a-r);if(!t.segments.length)return null;if(u>=this.goalBufferLength_())return null;if(!n&&u>=1)return null;if(null===s)return i=this.getSyncSegmentCandidate_(t),this.generateSegmentInfo_(t,i,null,!0);if(null!==i){t.segments[i];return o=a,this.generateSegmentInfo_(t,i+1,o,!1)}if(this.fetchAtBuffer_){var l=mc.getMediaInfoForTime(t,a,s.segmentIndex,s.time);i=l.mediaIndex,o=l.startTime}else{var c=mc.getMediaInfoForTime(t,r,s.segmentIndex,s.time);i=c.mediaIndex,o=c.startTime}return this.generateSegmentInfo_(t,i,o,!1)}},{key:"getSyncSegmentCandidate_",value:function(e){var t=this;if(-1===this.currentTimeline_)return 0;var i=e.segments.map((function(e,t){return{timeline:e.timeline,segmentIndex:t}})).filter((function(e){return e.timeline===t.currentTimeline_}));return i.length?i[Math.min(i.length-1,1)].segmentIndex:Math.max(e.segments.length-1,0)}},{key:"generateSegmentInfo_",value:function(e,t,i,n){if(t<0||t>=e.segments.length)return null;var r=e.segments[t];return{requestId:"segment-loader-"+Math.random(),uri:r.resolvedUri,mediaIndex:t,isSyncRequest:n,startOfSegment:i,playlist:e,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:r.timeline,duration:r.duration,segment:r}}},{key:"abortRequestEarly_",value:function(e){if(this.hls_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH)return!1;if(Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)return!1;var t=this.currentTime_(),i=e.bandwidth,n=this.pendingSegment_.duration,r=mc.estimateSegmentRequestTime(n,i,this.playlist_,e.bytesReceived),s=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=e.length?e.end(e.length-1):0;return(n-t)/i}(this.buffered_(),t,this.hls_.tech_.playbackRate())-1;if(r<=s)return!1;var a=function(e){var t=e.master,i=e.currentTime,n=e.bandwidth,r=e.duration,s=e.segmentDuration,a=e.timeUntilRebuffer,o=e.currentTimeline,u=e.syncController,l=t.playlists.filter((function(e){return!mc.isIncompatible(e)})),c=l.filter(mc.isEnabled);c.length||(c=l.filter((function(e){return!mc.isDisabled(e)})));var h=c.filter(mc.hasAttribute.bind(null,"BANDWIDTH")).map((function(e){var t=u.getSyncPoint(e,r,o,i)?1:2;return{playlist:e,rebufferingImpact:mc.estimateSegmentRequestTime(s,n,e)*t-a}})),d=h.filter((function(e){return e.rebufferingImpact<=0}));return Lh(d,(function(e,t){return Oh(t.playlist,e.playlist)})),d.length?d[0]:(Lh(h,(function(e,t){return e.rebufferingImpact-t.rebufferingImpact})),h[0]||null)}({master:this.hls_.playlists.master,currentTime:t,bandwidth:i,duration:this.duration_(),segmentDuration:n,timeUntilRebuffer:s,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(a){var o=r-s-a.rebufferingImpact,u=.5;return s<=1/30&&(u=1),!a.playlist||a.playlist.uri===this.playlist_.uri||o0&&this.remove(0,t)}},{key:"createSimplifiedSegmentObj_",value:function(e){var t=e.segment,i={resolvedUri:t.resolvedUri,byterange:t.byterange,requestId:e.requestId};if(t.key){var n=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);i.key=this.segmentKey(t.key),i.key.iv=n}return t.map&&(i.map=this.initSegment(t.map)),i}},{key:"segmentRequestFinished_",value:function(e,t){if(this.mediaRequests+=1,t.stats&&(this.mediaBytesTransferred+=t.stats.bytesReceived,this.mediaTransferDuration+=t.stats.roundTripTime),this.pendingSegment_){if(t.requestId===this.pendingSegment_.requestId){if(e)return this.pendingSegment_=null,this.state="READY",e.code===Ch?void(this.mediaRequestsAborted+=1):(this.pause(),e.code===kh?(this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,void this.trigger("bandwidthupdate")):(this.mediaRequestsErrored+=1,this.error(e),void this.trigger("error")));this.bandwidth=t.stats.bandwidth,this.roundTrip=t.stats.roundTripTime,t.map&&(t.map=this.initSegment(t.map,!0)),t.key&&this.segmentKey(t.key,!0),this.processSegmentResponse_(t)}}else this.mediaRequestsAborted+=1}},{key:"processSegmentResponse_",value:function(e){var t=this.pendingSegment_;t.bytes=e.bytes,e.map&&(t.segment.map.bytes=e.map.bytes),t.endOfAllRequests=e.endOfAllRequests,e.fmp4Captions&&(!function(e,t,i){for(var n in i)if(!e[n]){t.trigger({type:"usage",name:"hls-608"});var r=t.textTracks().getTrackById(n);e[n]=r||t.addRemoteTextTrack({kind:"captions",id:n,label:n},!1).track}}(this.inbandTextTracks_,this.hls_.tech_,e.captionStreams),function(e){var t=e.inbandTextTracks,i=e.captionArray,n=e.timestampOffset;if(i){var r=window.WebKitDataCue||window.VTTCue;i.forEach((function(e){var i=e.stream,s=e.startTime,a=e.endTime;t[i]&&(s+=n,a+=n,t[i].addCue(new r(s,a,e.text)))}))}}({inbandTextTracks:this.inbandTextTracks_,captionArray:e.fmp4Captions,timestampOffset:0}),this.captionParser_&&this.captionParser_.clearParsedCaptions()),this.handleSegment_()}},{key:"handleSegment_",value:function(){var e=this;if(this.pendingSegment_){var t=this.pendingSegment_,i=t.segment,n=this.syncController_.probeSegmentInfo(t);void 0===this.startingMedia_&&n&&(n.containsAudio||n.containsVideo)&&(this.startingMedia_={containsAudio:n.containsAudio,containsVideo:n.containsVideo});var r,s,a,o=(r=this.loaderType_,s=this.startingMedia_,a=n,"main"===r&&s&&a?a.containsAudio||a.containsVideo?s.containsVideo&&!a.containsVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!s.containsVideo&&a.containsVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null:"Neither audio nor video found in segment.":null);if(o)return this.error({message:o,blacklistDuration:1/0}),void this.trigger("error");if(t.isSyncRequest)return this.trigger("syncinfoupdate"),this.pendingSegment_=null,void(this.state="READY");if(null!==t.timestampOffset&&t.timestampOffset!==this.sourceUpdater_.timestampOffset()){if(n&&n.segmentTimestampInfo){var u=n.segmentTimestampInfo[0].ptsTime,l=n.segmentTimestampInfo[0].dtsTime;t.timestampOffset-=u-l}this.sourceUpdater_.timestampOffset(t.timestampOffset),this.trigger("timestampoffset")}var c=this.syncController_.mappingForTimeline(t.timeline);if(null!==c&&this.trigger({type:"segmenttimemapping",mapping:c}),this.state="APPENDING",i.map){var h=Cc(i.map);if(!this.activeInitSegmentId_||this.activeInitSegmentId_!==h){var d=this.initSegment(i.map);this.sourceUpdater_.appendBuffer({bytes:d.bytes},(function(){e.activeInitSegmentId_=h}))}}t.byteLength=t.bytes.byteLength,"number"==typeof i.start&&"number"==typeof i.end?this.mediaSecondsLoaded+=i.end-i.start:this.mediaSecondsLoaded+=i.duration,this.logger_(function(e){var t=e.segment,i=t.start,n=t.end,r=e.playlist,s=r.mediaSequence,a=r.id,o=r.segments,u=void 0===o?[]:o,l=e.mediaIndex,c=e.timeline;return["appending ["+l+"] of ["+s+", "+(s+u.length)+"] from playlist ["+a+"]","["+i+" => "+n+"] in timeline ["+c+"]"].join(" ")}(t)),this.sourceUpdater_.appendBuffer({bytes:t.bytes,videoSegmentTimingInfoCallback:this.handleVideoSegmentTimingInfo_.bind(this,t.requestId)},this.handleUpdateEnd_.bind(this))}else this.state="READY"}},{key:"handleVideoSegmentTimingInfo_",value:function(e,t){if(this.pendingSegment_&&e===this.pendingSegment_.requestId){var i=this.pendingSegment_.segment;i.videoTimingInfo||(i.videoTimingInfo={}),i.videoTimingInfo.transmuxerPrependedSeconds=t.videoSegmentTimingInfo.prependedContentDuration||0,i.videoTimingInfo.transmuxedPresentationStart=t.videoSegmentTimingInfo.start.presentation,i.videoTimingInfo.transmuxedPresentationEnd=t.videoSegmentTimingInfo.end.presentation,i.videoTimingInfo.baseMediaDecodeTime=t.videoSegmentTimingInfo.baseMediaDecodeTime}}},{key:"handleUpdateEnd_",value:function(){if(!this.pendingSegment_)return this.state="READY",void(this.paused()||this.monitorBuffer_());var e=this.pendingSegment_,t=e.segment,i=null!==this.mediaIndex;this.pendingSegment_=null,this.recordThroughput_(e),this.addSegmentMetadataCue_(e),this.state="READY",this.mediaIndex=e.mediaIndex,this.fetchAtBuffer_=!0,this.currentTimeline_=e.timeline,this.trigger("syncinfoupdate"),t.end&&this.currentTime_()-t.end>3*e.playlist.targetDuration?this.resetEverything():(i&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.isEndOfStream_(e.mediaIndex+1,e.playlist)&&this.endOfStream(),this.paused()||this.monitorBuffer_())}},{key:"recordThroughput_",value:function(e){var t=this.throughput.rate,i=Date.now()-e.endOfAllRequests+1,n=Math.floor(e.byteLength/i*8*1e3);this.throughput.rate+=(n-t)/++this.throughput.count}},{key:"addSegmentMetadataCue_",value:function(e){if(this.segmentMetadataTrack_){var t=e.segment,i=t.start,n=t.end;if(Nh(i)&&Nh(n)){Rc(i,n,this.segmentMetadataTrack_);var r=ee.WebKitDataCue||ee.VTTCue,s={custom:t.custom,dateTimeObject:t.dateTimeObject,dateTimeString:t.dateTimeString,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:i,end:n},a=new r(i,n,JSON.stringify(s));a.value=s,this.segmentMetadataTrack_.addCue(a)}}}}]),t}(Nl.EventTarget),Uh=function(e){return decodeURIComponent(escape(String.fromCharCode.apply(null,e)))},Mh=new Uint8Array("\n\n".split("").map((function(e){return e.charCodeAt(0)}))),Bh=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};jl(this,t);var n=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i));return n.mediaSource_=null,n.subtitlesTrack_=null,n.featuresNativeTextTracks_=e.featuresNativeTextTracks,n}return Vl(t,e),Fl(t,[{key:"buffered_",value:function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return Nl.createTimeRanges();var e=this.subtitlesTrack_.cues,t=e[0].startTime,i=e[e.length-1].startTime;return Nl.createTimeRanges([[t,i]])}},{key:"initSegment",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e)return null;var i=Cc(e),n=this.initSegments_[i];if(t&&!n&&e.bytes){var r=Mh.byteLength+e.bytes.byteLength,s=new Uint8Array(r);s.set(e.bytes),s.set(Mh,e.bytes.byteLength),this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:s}}return n||e}},{key:"couldBeginLoading_",value:function(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}},{key:"init_",value:function(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}},{key:"track",value:function(e){return void 0===e||(this.subtitlesTrack_=e,"INIT"===this.state&&this.couldBeginLoading_()&&this.init_()),this.subtitlesTrack_}},{key:"remove",value:function(e,t){Rc(e,t,this.subtitlesTrack_)}},{key:"fillBuffer_",value:function(){var e=this;this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var t=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(t=this.skipEmptySegments_(t)){if(null===this.syncController_.timestampOffsetForTimeline(t.timeline)){return this.syncController_.one("timestampoffset",(function(){e.state="READY",e.paused()||e.monitorBuffer_()})),void(this.state="WAITING_ON_TIMELINE")}this.loadSegment_(t)}}},{key:"skipEmptySegments_",value:function(e){for(;e&&e.segment.empty;)e=this.generateSegmentInfo_(e.playlist,e.mediaIndex+1,e.startOfSegment+e.duration,e.isSyncRequest);return e}},{key:"handleSegment_",value:function(){var e=this;if(this.pendingSegment_&&this.subtitlesTrack_){this.state="APPENDING";var t=this.pendingSegment_,i=t.segment;if("function"!=typeof ee.WebVTT&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var n=void 0,r=function(){e.subtitlesTrack_.tech_.off("vttjsloaded",n),e.error({message:"Error loading vtt.js"}),e.state="READY",e.pause(),e.trigger("error")};return n=function(){e.subtitlesTrack_.tech_.off("vttjserror",r),e.handleSegment_()},this.state="WAITING_ON_VTTJS",this.subtitlesTrack_.tech_.one("vttjsloaded",n),void this.subtitlesTrack_.tech_.one("vttjserror",r)}i.requested=!0;try{this.parseVTTCues_(t)}catch(e){return this.error({message:e.message}),this.state="READY",this.pause(),this.trigger("error")}if(this.updateTimeMapping_(t,this.syncController_.timelines[t.timeline],this.playlist_),t.isSyncRequest)return this.trigger("syncinfoupdate"),this.pendingSegment_=null,void(this.state="READY");t.byteLength=t.bytes.byteLength,this.mediaSecondsLoaded+=i.duration,t.cues.length&&this.remove(t.cues[0].endTime,t.cues[t.cues.length-1].endTime),t.cues.forEach((function(t){e.subtitlesTrack_.addCue(e.featuresNativeTextTracks_?new ee.VTTCue(t.startTime,t.endTime,t.text):t)})),this.handleUpdateEnd_()}else this.state="READY"}},{key:"parseVTTCues_",value:function(e){var t=void 0,i=!1;"function"==typeof ee.TextDecoder?t=new ee.TextDecoder("utf8"):(t=ee.WebVTT.StringDecoder(),i=!0);var n=new ee.WebVTT.Parser(ee,ee.vttjs,t);if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},n.oncue=e.cues.push.bind(e.cues),n.ontimestampmap=function(t){return e.timestampmap=t},n.onparsingerror=function(e){Nl.log.warn("Error encountered when parsing cues: "+e.message)},e.segment.map){var r=e.segment.map.bytes;i&&(r=Uh(r)),n.parse(r)}var s=e.bytes;i&&(s=Uh(s)),n.parse(s),n.flush()}},{key:"updateTimeMapping_",value:function(e,t,i){var n=e.segment;if(t)if(e.cues.length){var r=e.timestampmap,s=r.MPEGTS/9e4-r.LOCAL+t.mapping;if(e.cues.forEach((function(e){e.startTime+=s,e.endTime+=s})),!i.syncInfo){var a=e.cues[0].startTime,o=e.cues[e.cues.length-1].startTime;i.syncInfo={mediaSequence:i.mediaSequence+e.mediaIndex,time:Math.min(a,o-n.duration)}}}else n.empty=!0}}]),t}(Rh),jh=function(e,t){for(var i=e.cues,n=0;n=r.adStartTime&&t<=r.adEndTime)return r}return null},Fh=Er,Vh=[{name:"VOD",run:function(e,t,i,n,r){if(i!==1/0){return{time:0,segmentIndex:0}}return null}},{name:"ProgramDateTime",run:function(e,t,i,n,r){if(!e.datetimeToDisplayTime)return null;var s=t.segments||[],a=null,o=null;r=r||0;for(var u=0;u=c)&&(o=c,a={time:l.start,segmentIndex:u})}}return a}},{name:"Discontinuity",run:function(e,t,i,n,r){var s=null;if(r=r||0,t.discontinuityStarts&&t.discontinuityStarts.length)for(var a=null,o=0;o=h)&&(a=h,s={time:c.time,segmentIndex:u})}}return s}},{name:"Playlist",run:function(e,t,i,n,r){return t.syncInfo?{time:t.syncInfo.time,segmentIndex:t.syncInfo.mediaSequence-t.mediaSequence}:null}}],Hh=function(e){function t(){jl(this,t);var e=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.inspectCache_=void 0,e.timelines=[],e.discontinuities=[],e.datetimeToDisplayTime=null,e.logger_=yh("SyncController"),e}return Vl(t,e),Fl(t,[{key:"getSyncPoint",value:function(e,t,i,n){var r=this.runStrategies_(e,t,i,n);return r.length?this.selectSyncPoint_(r,{key:"time",value:n}):null}},{key:"getExpiredTime",value:function(e,t){if(!e||!e.segments)return null;var i=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!i.length)return null;var n=this.selectSyncPoint_(i,{key:"segmentIndex",value:0});return n.segmentIndex>0&&(n.time*=-1),Math.abs(n.time+nc(e,n.segmentIndex,0))}},{key:"runStrategies_",value:function(e,t,i,n){for(var r=[],s=0;s=0;i--){var n=e.segments[i];if(n&&void 0!==n.start){t.syncInfo={mediaSequence:e.mediaSequence+i,time:n.start},this.logger_("playlist refresh sync: [time:"+t.syncInfo.time+", mediaSequence: "+t.syncInfo.mediaSequence+"]"),this.trigger("syncinfoupdate");break}}}},{key:"setDateTimeMapping",value:function(e){if(!this.datetimeToDisplayTime&&e.segments&&e.segments.length&&e.segments[0].dateTimeObject){var t=e.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-t}}},{key:"reset",value:function(){this.inspectCache_=void 0}},{key:"probeSegmentInfo",value:function(e){var t=e.segment,i=e.playlist,n=void 0;return(n=t.map?this.probeMp4Segment_(e):this.probeTsSegment_(e))&&this.calculateSegmentTimeMapping_(e,n)&&(this.saveDiscontinuitySyncInfo_(e),i.syncInfo||(i.syncInfo={mediaSequence:i.mediaSequence+e.mediaIndex,time:t.start})),n}},{key:"probeMp4Segment_",value:function(e){var t=e.segment,i=Mn.timescale(t.map.bytes),n=Mn.compositionStartTime(i,e.bytes);return null!==e.timestampOffset&&(e.timestampOffset-=n),{start:n,end:n+t.duration}}},{key:"probeTsSegment_",value:function(e){var t=Fh(e.bytes,this.inspectCache_),i=void 0,n=void 0,r=void 0;return t?(t.video&&2===t.video.length?(this.inspectCache_=t.video[1].dts,i=t.video[0].dtsTime,n=t.video[1].dtsTime,r=t.video):t.audio&&2===t.audio.length&&(this.inspectCache_=t.audio[1].dts,i=t.audio[0].dtsTime,n=t.audio[1].dtsTime,r=t.audio),{segmentTimestampInfo:r,start:i,end:n,containsVideo:t.video&&2===t.video.length,containsAudio:t.audio&&2===t.audio.length}):null}},{key:"timestampOffsetForTimeline",value:function(e){return void 0===this.timelines[e]?null:this.timelines[e].time}},{key:"mappingForTimeline",value:function(e){return void 0===this.timelines[e]?null:this.timelines[e].mapping}},{key:"calculateSegmentTimeMapping_",value:function(e,t){var i=e.segment,n=this.timelines[e.timeline];if(null!==e.timestampOffset)n={time:e.startOfSegment,mapping:e.startOfSegment-t.start},this.timelines[e.timeline]=n,this.trigger("timestampoffset"),this.logger_("time mapping for timeline "+e.timeline+": [time: "+n.time+"] [mapping: "+n.mapping+"]"),i.start=e.startOfSegment,i.end=t.end+n.mapping;else{if(!n)return!1;i.start=t.start+n.mapping,i.end=t.end+n.mapping}return!0}},{key:"saveDiscontinuitySyncInfo_",value:function(e){var t=e.playlist,i=e.segment;if(i.discontinuity)this.discontinuities[i.timeline]={time:i.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(var n=0;no){var u=void 0;u=a<0?i.start-nc(t,e.mediaIndex,r):i.end+nc(t,e.mediaIndex+1,r),this.discontinuities[s]={time:u,accuracy:o}}}}},{key:"dispose",value:function(){this.trigger("dispose"),this.off()}}]),t}(Nl.EventTarget),qh=new qc("./decrypter-worker.worker.js",(function(e,t){var i=this;!function(){var e=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},t=function(){function e(e,t){for(var i=0;i>7))^s]=s;for(a=o=0;!n[a];a^=c||1,o=l[o]||1)for(d=(d=o^o<<1^o<<2^o<<3^o<<4)>>8^255&d^99,n[a]=d,r[d]=a,f=16843009*u[h=u[c=u[a]]]^65537*h^257*c^16843008*a,p=257*u[d]^16843008*d,s=0;s<4;s++)t[s][a]=p=p<<24^p>>>8,i[s][d]=f=f<<24^f>>>8;for(s=0;s<5;s++)t[s]=t[s].slice(0),i[s]=i[s].slice(0);return e}()),this._tables=[[n[0][0].slice(),n[0][1].slice(),n[0][2].slice(),n[0][3].slice(),n[0][4].slice()],[n[1][0].slice(),n[1][1].slice(),n[1][2].slice(),n[1][3].slice(),n[1][4].slice()]];var r=void 0,s=void 0,a=void 0,o=void 0,u=void 0,l=this._tables[0][4],c=this._tables[1],h=i.length,d=1;if(4!==h&&6!==h&&8!==h)throw new Error("Invalid aes key size");for(o=i.slice(0),u=[],this._key=[o,u],r=h;r<4*h+28;r++)a=o[r-1],(r%h==0||8===h&&r%h==4)&&(a=l[a>>>24]<<24^l[a>>16&255]<<16^l[a>>8&255]<<8^l[255&a],r%h==0&&(a=a<<8^a>>>24^d<<24,d=d<<1^283*(d>>7))),o[r]=o[r-h]^a;for(s=0;r;s++,r--)a=o[3&s?r:r-4],u[s]=r<=4||s<4?a:c[0][l[a>>>24]]^c[1][l[a>>16&255]]^c[2][l[a>>8&255]]^c[3][l[255&a]]}return t.prototype.decrypt=function(e,t,i,n,r,s){var a=this._key[1],o=e^a[0],u=n^a[1],l=i^a[2],c=t^a[3],h=void 0,d=void 0,p=void 0,f=a.length/4-2,m=void 0,g=4,v=this._tables[1],y=v[0],_=v[1],b=v[2],T=v[3],S=v[4];for(m=0;m>>24]^_[u>>16&255]^b[l>>8&255]^T[255&c]^a[g],d=y[u>>>24]^_[l>>16&255]^b[c>>8&255]^T[255&o]^a[g+1],p=y[l>>>24]^_[c>>16&255]^b[o>>8&255]^T[255&u]^a[g+2],c=y[c>>>24]^_[o>>16&255]^b[u>>8&255]^T[255&l]^a[g+3],g+=4,o=h,u=d,l=p;for(m=0;m<4;m++)r[(3&-m)+s]=S[o>>>24]<<24^S[u>>16&255]<<16^S[l>>8&255]<<8^S[255&c]^a[g++],h=o,o=u,u=l,l=c,c=h},t}(),s=function(){function t(){e(this,t),this.listeners={}}return t.prototype.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},t.prototype.off=function(e,t){if(!this.listeners[e])return!1;var i=this.listeners[e].indexOf(t);return this.listeners[e].splice(i,1),i>-1},t.prototype.trigger=function(e){var t=this.listeners[e];if(t)if(2===arguments.length)for(var i=t.length,n=0;n>8|e>>>24},u=function(){function i(t,n,r,s){e(this,i);var u=i.STEP,l=new Int32Array(t.buffer),c=new Uint8Array(t.byteLength),h=0;for(this.asyncStream_=new a,this.asyncStream_.push(this.decryptChunk_(l.subarray(h,h+u),n,r,c)),h=u;h>2),s=new r(Array.prototype.slice.call(t)),a=new Uint8Array(e.byteLength),u=new Int32Array(a.buffer),l=void 0,c=void 0,h=void 0,d=void 0,p=void 0,f=void 0,m=void 0,g=void 0,v=void 0;for(l=i[0],c=i[1],h=i[2],d=i[3],v=0;v=0&&(t="main-desc"),t},zh=function(e,t){e.abort(),e.pause(),t&&t.activePlaylistLoader&&(t.activePlaylistLoader.pause(),t.activePlaylistLoader=null)},$h=function(e,t){t.activePlaylistLoader=e,e.load()},Gh={AUDIO:function(e,t){return function(){var i=t.segmentLoaders[e],n=t.mediaTypes[e],r=t.blacklistCurrentPlaylist;zh(i,n);var s=n.activeTrack(),a=n.activeGroup(),o=(a.filter((function(e){return e.default}))[0]||a[0]).id,u=n.tracks[o];if(s!==u){for(var l in Nl.log.warn("Problem encountered loading the alternate audio track.Switching back to default."),n.tracks)n.tracks[l].enabled=n.tracks[l]===u;n.onTrackChanged()}else r({message:"Problem encountered loading the default audio track."})}},SUBTITLES:function(e,t){return function(){var i=t.segmentLoaders[e],n=t.mediaTypes[e];Nl.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),zh(i,n);var r=n.activeTrack();r&&(r.mode="disabled"),n.onTrackChanged()}}},Xh={AUDIO:function(e,t,i){if(t){var n=i.tech,r=i.requestOptions,s=i.segmentLoaders[e];t.on("loadedmetadata",(function(){var e=t.media();s.playlist(e,r),(!n.paused()||e.endList&&"none"!==n.preload())&&s.load()})),t.on("loadedplaylist",(function(){s.playlist(t.media(),r),n.paused()||s.load()})),t.on("error",Gh[e](e,i))}},SUBTITLES:function(e,t,i){var n=i.tech,r=i.requestOptions,s=i.segmentLoaders[e],a=i.mediaTypes[e];t.on("loadedmetadata",(function(){var e=t.media();s.playlist(e,r),s.track(a.activeTrack()),(!n.paused()||e.endList&&"none"!==n.preload())&&s.load()})),t.on("loadedplaylist",(function(){s.playlist(t.media(),r),n.paused()||s.load()})),t.on("error",Gh[e](e,i))}},Kh={AUDIO:function(e,t){var i=t.hls,n=t.sourceType,r=t.segmentLoaders[e],s=t.requestOptions,a=t.master.mediaGroups,o=t.mediaTypes[e],u=o.groups,l=o.tracks,c=t.masterPlaylistLoader;for(var h in a[e]&&0!==Object.keys(a[e]).length||(a[e]={main:{default:{default:!0}}}),a[e])for(var d in u[h]||(u[h]=[]),a[e][h]){var p=a[e][h][d],f=void 0;if(f=p.resolvedUri?new Zl(p.resolvedUri,i,s):p.playlists&&"dash"===n?new vh(p.playlists[0],i,s,c):null,p=Nl.mergeOptions({id:d,playlistLoader:f},p),Xh[e](e,p.playlistLoader,t),u[h].push(p),void 0===l[d]){var m=new Nl.AudioTrack({id:d,kind:Wh(p),enabled:!1,language:p.language,default:p.default,label:d});l[d]=m}}r.on("error",Gh[e](e,t))},SUBTITLES:function(e,t){var i=t.tech,n=t.hls,r=t.sourceType,s=t.segmentLoaders[e],a=t.requestOptions,o=t.master.mediaGroups,u=t.mediaTypes[e],l=u.groups,c=u.tracks,h=t.masterPlaylistLoader;for(var d in o[e])for(var p in l[d]||(l[d]=[]),o[e][d])if(!o[e][d][p].forced){var f=o[e][d][p],m=void 0;if("hls"===r?m=new Zl(f.resolvedUri,n,a):"dash"===r&&(m=new vh(f.playlists[0],n,a,h)),f=Nl.mergeOptions({id:p,playlistLoader:m},f),Xh[e](e,f.playlistLoader,t),l[d].push(f),void 0===c[p]){var g=i.addRemoteTextTrack({id:p,kind:"subtitles",default:f.default&&f.autoselect,language:f.language,label:p},!1).track;c[p]=g}}s.on("error",Gh[e](e,t))},"CLOSED-CAPTIONS":function(e,t){var i=t.tech,n=t.master.mediaGroups,r=t.mediaTypes[e],s=r.groups,a=r.tracks;for(var o in n[e])for(var u in s[o]||(s[o]=[]),n[e][o]){var l=n[e][o][u];if(l.instreamId.match(/CC\d/)&&(s[o].push(Nl.mergeOptions({id:u},l)),void 0===a[u])){var c=i.addRemoteTextTrack({id:l.instreamId,kind:"captions",default:l.default&&l.autoselect,language:l.language,label:u},!1).track;a[u]=c}}}},Yh={AUDIO:function(e,t){return function(){var i=t.mediaTypes[e].tracks;for(var n in i)if(i[n].enabled)return i[n];return null}},SUBTITLES:function(e,t){return function(){var i=t.mediaTypes[e].tracks;for(var n in i)if("showing"===i[n].mode||"hidden"===i[n].mode)return i[n];return null}}},Qh=function(e){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((function(t){Kh[t](t,e)}));var t=e.mediaTypes,i=e.masterPlaylistLoader,n=e.tech,r=e.hls;["AUDIO","SUBTITLES"].forEach((function(i){t[i].activeGroup=function(e,t){return function(i){var n=t.masterPlaylistLoader,r=t.mediaTypes[e].groups,s=n.media();if(!s)return null;var a=null;return s.attributes[e]&&(a=r[s.attributes[e]]),a=a||r.main,void 0===i?a:null===i?null:a.filter((function(e){return e.id===i.id}))[0]||null}}(i,e),t[i].activeTrack=Yh[i](i,e),t[i].onGroupChanged=function(e,t){return function(){var i=t.segmentLoaders,n=i[e],r=i.main,s=t.mediaTypes[e],a=s.activeTrack(),o=s.activeGroup(a),u=s.activePlaylistLoader;zh(n,s),o&&(o.playlistLoader?(n.resyncLoader(),$h(o.playlistLoader,s)):u&&r.resetEverything())}}(i,e),t[i].onTrackChanged=function(e,t){return function(){var i=t.segmentLoaders,n=i[e],r=i.main,s=t.mediaTypes[e],a=s.activeTrack(),o=s.activeGroup(a),u=s.activePlaylistLoader;zh(n,s),o&&(o.playlistLoader?u!==o.playlistLoader?(n.track&&n.track(a),n.resetEverything(),$h(o.playlistLoader,s)):$h(o.playlistLoader,s):r.resetEverything())}}(i,e)}));var s=t.AUDIO.activeGroup(),a=(s.filter((function(e){return e.default}))[0]||s[0]).id;t.AUDIO.tracks[a].enabled=!0,t.AUDIO.onTrackChanged(),i.on("mediachange",(function(){["AUDIO","SUBTITLES"].forEach((function(e){return t[e].onGroupChanged()}))}));var o=function(){t.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"hls-audio-change"})};for(var u in n.audioTracks().addEventListener("change",o),n.remoteTextTracks().addEventListener("change",t.SUBTITLES.onTrackChanged),r.on("dispose",(function(){n.audioTracks().removeEventListener("change",o),n.remoteTextTracks().removeEventListener("change",t.SUBTITLES.onTrackChanged)})),n.clearTracks("audio"),t.AUDIO.tracks)n.audioTracks().addTrack(t.AUDIO.tracks[u])},Jh=void 0,Zh=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],ed=function(e){return this.audioSegmentLoader_[e]+this.mainSegmentLoader_[e]},td=function(e){function t(e){jl(this,t);var i,n=Hl(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),r=e.url,s=e.handleManifestRedirects,a=e.withCredentials,o=e.tech,u=e.bandwidth,l=e.externHls,c=e.useCueTags,h=e.blacklistDuration,d=e.enableLowInitialPlaylist,p=e.cacheEncryptionKeys,f=e.sourceType;if(!r)throw new Error("A non-empty playlist URL is required");Jh=l,n.withCredentials=a,n.tech_=o,n.hls_=o.hls,n.sourceType_=f,n.useCueTags_=c,n.blacklistDuration=h,n.enableLowInitialPlaylist=d,n.useCueTags_&&(n.cueTagsTrack_=n.tech_.addTextTrack("metadata","ad-cues"),n.cueTagsTrack_.inBandMetadataTrackDispatchType=""),n.requestOptions_={withCredentials:a,handleManifestRedirects:s,timeout:null},n.mediaTypes_=(i={},["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach((function(e){i[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:_h,activeTrack:_h,onGroupChanged:_h,onTrackChanged:_h}})),i),n.mediaSource=new Nl.MediaSource,n.mediaSource.addEventListener("sourceopen",n.handleSourceOpen_.bind(n)),n.seekable_=Nl.createTimeRanges(),n.hasPlayed_=!1,n.syncController_=new Hh(e),n.segmentMetadataTrack_=o.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,n.decrypter_=new qh,n.inbandTextTracks_={};var m={hls:n.hls_,mediaSource:n.mediaSource,currentTime:n.tech_.currentTime.bind(n.tech_),seekable:function(){return n.seekable()},seeking:function(){return n.tech_.seeking()},duration:function(){return n.mediaSource.duration},hasPlayed:function(){return n.hasPlayed_},goalBufferLength:function(){return n.goalBufferLength()},bandwidth:u,syncController:n.syncController_,decrypter:n.decrypter_,sourceType:n.sourceType_,inbandTextTracks:n.inbandTextTracks_,cacheEncryptionKeys:p};return n.masterPlaylistLoader_="dash"===n.sourceType_?new vh(r,n.hls_,n.requestOptions_):new Zl(r,n.hls_,n.requestOptions_),n.setupMasterPlaylistLoaderListeners_(),n.mainSegmentLoader_=new Rh(Nl.mergeOptions(m,{segmentMetadataTrack:n.segmentMetadataTrack_,loaderType:"main"}),e),n.audioSegmentLoader_=new Rh(Nl.mergeOptions(m,{loaderType:"audio"}),e),n.subtitleSegmentLoader_=new Bh(Nl.mergeOptions(m,{loaderType:"vtt",featuresNativeTextTracks:n.tech_.featuresNativeTextTracks}),e),n.setupSegmentLoaderListeners_(),Zh.forEach((function(e){n[e+"_"]=ed.bind(n,e)})),n.logger_=yh("MPC"),n.masterPlaylistLoader_.load(),n}return Vl(t,e),Fl(t,[{key:"setupMasterPlaylistLoaderListeners_",value:function(){var e=this;this.masterPlaylistLoader_.on("loadedmetadata",(function(){var t=e.masterPlaylistLoader_.media(),i=1.5*t.targetDuration*1e3;fc(e.masterPlaylistLoader_.master,e.masterPlaylistLoader_.media())?e.requestOptions_.timeout=0:e.requestOptions_.timeout=i,t.endList&&"none"!==e.tech_.preload()&&(e.mainSegmentLoader_.playlist(t,e.requestOptions_),e.mainSegmentLoader_.load()),Qh({sourceType:e.sourceType_,segmentLoaders:{AUDIO:e.audioSegmentLoader_,SUBTITLES:e.subtitleSegmentLoader_,main:e.mainSegmentLoader_},tech:e.tech_,requestOptions:e.requestOptions_,masterPlaylistLoader:e.masterPlaylistLoader_,hls:e.hls_,master:e.master(),mediaTypes:e.mediaTypes_,blacklistCurrentPlaylist:e.blacklistCurrentPlaylist.bind(e)}),e.triggerPresenceUsage_(e.master(),t);try{e.setupSourceBuffers_()}catch(t){return Nl.log.warn("Failed to create SourceBuffers",t),e.mediaSource.endOfStream("decode")}e.setupFirstPlay(),!e.mediaTypes_.AUDIO.activePlaylistLoader||e.mediaTypes_.AUDIO.activePlaylistLoader.media()?e.trigger("selectedinitialmedia"):e.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",(function(){e.trigger("selectedinitialmedia")}))})),this.masterPlaylistLoader_.on("loadedplaylist",(function(){var t=e.masterPlaylistLoader_.media();if(!t){e.excludeUnsupportedVariants_();var i=void 0;return e.enableLowInitialPlaylist&&(i=e.selectInitialPlaylist()),i||(i=e.selectPlaylist()),e.initialMedia_=i,void e.masterPlaylistLoader_.media(e.initialMedia_)}if(e.useCueTags_&&e.updateAdCues_(t),e.mainSegmentLoader_.playlist(t,e.requestOptions_),e.updateDuration(),e.tech_.paused()||(e.mainSegmentLoader_.load(),e.audioSegmentLoader_&&e.audioSegmentLoader_.load()),!t.endList){var n=function(){var t=e.seekable();0!==t.length&&e.mediaSource.addSeekableRange_(t.start(0),t.end(0))};if(e.duration()!==1/0){e.tech_.one("durationchange",(function t(){e.duration()===1/0?n():e.tech_.one("durationchange",t)}))}else n()}})),this.masterPlaylistLoader_.on("error",(function(){e.blacklistCurrentPlaylist(e.masterPlaylistLoader_.error)})),this.masterPlaylistLoader_.on("mediachanging",(function(){e.mainSegmentLoader_.abort(),e.mainSegmentLoader_.pause()})),this.masterPlaylistLoader_.on("mediachange",(function(){var t=e.masterPlaylistLoader_.media(),i=1.5*t.targetDuration*1e3;fc(e.masterPlaylistLoader_.master,e.masterPlaylistLoader_.media())?e.requestOptions_.timeout=0:e.requestOptions_.timeout=i,e.mainSegmentLoader_.playlist(t,e.requestOptions_),e.mainSegmentLoader_.load(),e.tech_.trigger({type:"mediachange",bubbles:!0})})),this.masterPlaylistLoader_.on("playlistunchanged",(function(){var t=e.masterPlaylistLoader_.media();e.stuckAtPlaylistEnd_(t)&&(e.blacklistCurrentPlaylist({message:"Playlist no longer updating."}),e.tech_.trigger("playliststuck"))})),this.masterPlaylistLoader_.on("renditiondisabled",(function(){e.tech_.trigger({type:"usage",name:"hls-rendition-disabled"})})),this.masterPlaylistLoader_.on("renditionenabled",(function(){e.tech_.trigger({type:"usage",name:"hls-rendition-enabled"})}))}},{key:"triggerPresenceUsage_",value:function(e,t){var i=e.mediaGroups||{},n=!0,r=Object.keys(i.AUDIO);for(var s in i.AUDIO)for(var a in i.AUDIO[s]){i.AUDIO[s][a].uri||(n=!1)}n&&this.tech_.trigger({type:"usage",name:"hls-demuxed"}),Object.keys(i.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"hls-webvtt"}),Jh.Playlist.isAes(t)&&this.tech_.trigger({type:"usage",name:"hls-aes"}),Jh.Playlist.isFmp4(t)&&this.tech_.trigger({type:"usage",name:"hls-fmp4"}),r.length&&Object.keys(i.AUDIO[r[0]]).length>1&&this.tech_.trigger({type:"usage",name:"hls-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"hls-playlist-cue-tags"})}},{key:"setupSegmentLoaderListeners_",value:function(){var e=this;this.mainSegmentLoader_.on("bandwidthupdate",(function(){var t=e.selectPlaylist(),i=e.masterPlaylistLoader_.media(),n=e.tech_.buffered();(function(e){var t=e.currentPlaylist,i=e.nextPlaylist,n=e.forwardBuffer,r=e.bufferLowWaterLine,s=e.duration;e.log;return i?!t.endList||(s=r)):(Nl.log.warn("We received no playlist to switch to. Please check your stream."),!1)})({currentPlaylist:i,nextPlaylist:t,forwardBuffer:n.length?n.end(n.length-1)-e.tech_.currentTime():0,bufferLowWaterLine:e.bufferLowWaterLine(),duration:e.duration(),log:e.logger_})&&e.masterPlaylistLoader_.media(t),e.tech_.trigger("bandwidthupdate")})),this.mainSegmentLoader_.on("progress",(function(){e.trigger("progress")})),this.mainSegmentLoader_.on("error",(function(){e.blacklistCurrentPlaylist(e.mainSegmentLoader_.error())})),this.mainSegmentLoader_.on("syncinfoupdate",(function(){e.onSyncInfoUpdate_()})),this.mainSegmentLoader_.on("timestampoffset",(function(){e.tech_.trigger({type:"usage",name:"hls-timestamp-offset"})})),this.audioSegmentLoader_.on("syncinfoupdate",(function(){e.onSyncInfoUpdate_()})),this.mainSegmentLoader_.on("ended",(function(){e.onEndOfStream()})),this.mainSegmentLoader_.on("earlyabort",(function(){e.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},120)})),this.mainSegmentLoader_.on("reseteverything",(function(){e.tech_.trigger("hls-reset")})),this.mainSegmentLoader_.on("segmenttimemapping",(function(t){e.tech_.trigger({type:"hls-segment-time-mapping",mapping:t.mapping})})),this.audioSegmentLoader_.on("ended",(function(){e.onEndOfStream()}))}},{key:"mediaSecondsLoaded_",value:function(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}},{key:"load",value:function(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}},{key:"smoothQualityChange_",value:function(){var e=this.selectPlaylist();e!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(e),this.mainSegmentLoader_.resetLoader())}},{key:"fastQualityChange_",value:function(){var e=this,t=this.selectPlaylist();t!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(t),this.mainSegmentLoader_.resetEverything((function(){Nl.browser.IE_VERSION||Nl.browser.IS_EDGE?e.tech_.setCurrentTime(e.tech_.currentTime()+.04):e.tech_.setCurrentTime(e.tech_.currentTime())})))}},{key:"play",value:function(){if(!this.setupFirstPlay()){this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();var e=this.tech_.seekable();return this.tech_.duration()===1/0&&this.tech_.currentTime()0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1],i=void 0,n=void 0;if(i=e.playlist||this.masterPlaylistLoader_.media(),t=t||e.blacklistDuration||this.blacklistDuration,!i){this.error=e;try{return this.mediaSource.endOfStream("network")}catch(e){return this.trigger("error")}}var r=1===this.masterPlaylistLoader_.master.playlists.filter(dc).length,s=this.masterPlaylistLoader_.master.playlists;return 1===s.length?(Nl.log.warn("Problem encountered with the current HLS playlist. Trying again since it is the only playlist."),this.tech_.trigger("retryplaylist"),this.masterPlaylistLoader_.load(r)):(r&&(Nl.log.warn("Removing all playlists from the blacklist because the last rendition is about to be blacklisted."),s.forEach((function(e){e.excludeUntil!==1/0&&delete e.excludeUntil})),this.tech_.trigger("retryplaylist")),i.excludeUntil=Date.now()+1e3*t,this.tech_.trigger("blacklistplaylist"),this.tech_.trigger({type:"usage",name:"hls-rendition-blacklisted"}),n=this.selectPlaylist(),Nl.log.warn("Problem encountered with the current HLS playlist."+(e.message?" "+e.message:"")+" Switching to another playlist."),this.masterPlaylistLoader_.media(n,r))}},{key:"pauseLoading",value:function(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}},{key:"setCurrentTime",value:function(e){var t=Lc(this.tech_.buffered(),e);return this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media()&&this.masterPlaylistLoader_.media().segments?t&&t.length?e:(this.mainSegmentLoader_.resetEverything(),this.mainSegmentLoader_.abort(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.resetEverything(),this.audioSegmentLoader_.abort()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.resetEverything(),this.subtitleSegmentLoader_.abort()),void this.load()):0}},{key:"duration",value:function(){return this.masterPlaylistLoader_?this.mediaSource?this.mediaSource.duration:Jh.Playlist.duration(this.masterPlaylistLoader_.media()):0}},{key:"seekable",value:function(){return this.seekable_}},{key:"onSyncInfoUpdate_",value:function(){var e=void 0;if(this.masterPlaylistLoader_){var t=this.masterPlaylistLoader_.media();if(t){var i=this.syncController_.getExpiredTime(t,this.mediaSource.duration);if(null!==i){var n=this.masterPlaylistLoader_.master.suggestedPresentationDelay,r=Jh.Playlist.seekable(t,i,n);if(0!==r.length){if(this.mediaTypes_.AUDIO.activePlaylistLoader){if(t=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),null===(i=this.syncController_.getExpiredTime(t,this.mediaSource.duration)))return;if(0===(e=Jh.Playlist.seekable(t,i,n)).length)return}var s=void 0,a=void 0;this.seekable_&&this.seekable_.length&&(s=this.seekable_.end(0),a=this.seekable_.start(0)),e?e.start(0)>r.end(0)||r.start(0)>e.end(0)?this.seekable_=r:this.seekable_=Nl.createTimeRanges([[e.start(0)>r.start(0)?e.start(0):r.start(0),e.end(0) "+i);try{e.mediaSource.duration=i}catch(e){Nl.log.warn("Failed to set media source duration",e)}e.tech_.trigger("durationchange"),e.mediaSource.removeEventListener("sourceopen",t)};n.length>0&&(i=Math.max(i,n.end(n.length-1))),t!==i&&("open"!==this.mediaSource.readyState?this.mediaSource.addEventListener("sourceopen",r):r())}},{key:"dispose",value:function(){var e=this;this.trigger("dispose"),this.decrypter_&&this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),["AUDIO","SUBTITLES"].forEach((function(t){var i=e.mediaTypes_[t].groups;for(var n in i)i[n].forEach((function(e){e.playlistLoader&&e.playlistLoader.dispose()}))})),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.off(),this.mediaSource.dispose&&this.mediaSource.dispose()}},{key:"master",value:function(){return this.masterPlaylistLoader_.master}},{key:"media",value:function(){return this.masterPlaylistLoader_.media()||this.initialMedia_}},{key:"setupSourceBuffers_",value:function(){var e,t=this.masterPlaylistLoader_.media();if(t&&"open"===this.mediaSource.readyState){if((e=Zc(this.masterPlaylistLoader_.master,t)).length<1)return this.error="No compatible SourceBuffer configuration for the variant stream:"+t.resolvedUri,this.mediaSource.endOfStream("decode");this.configureLoaderMimeTypes_(e),this.excludeIncompatibleVariants_(t)}}},{key:"configureLoaderMimeTypes_",value:function(e){var t=e.length>1&&-1===e[0].indexOf(",")&&e[0]!==e[1]?new Nl.EventTarget:null;this.mainSegmentLoader_.mimeType(e[0],t),e[1]&&this.audioSegmentLoader_.mimeType(e[1],t)}},{key:"excludeUnsupportedVariants_",value:function(){this.master().playlists.forEach((function(e){var t;e.attributes.CODECS&&ee.MediaSource&&ee.MediaSource.isTypeSupported&&!ee.MediaSource.isTypeSupported('video/mp4; codecs="'+(t=e.attributes.CODECS,t.replace(/avc1\.(\d+)\.(\d+)/i,(function(e){return Yc([e])[0]}))+'"'))&&(e.excludeUntil=1/0)}))}},{key:"excludeIncompatibleVariants_",value:function(e){var t=2,i=null,n=void 0;e.attributes.CODECS&&(n=Qc(e.attributes.CODECS),i=n.videoCodec,t=n.codecCount),this.master().playlists.forEach((function(e){var n={codecCount:2,videoCodec:null};e.attributes.CODECS&&(n=Qc(e.attributes.CODECS)),n.codecCount!==t&&(e.excludeUntil=1/0),n.videoCodec!==i&&(e.excludeUntil=1/0)}))}},{key:"updateAdCues_",value:function(e){var t=0,i=this.seekable();i.length&&(t=i.start(0)),function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(e.segments)for(var n=i,r=void 0,s=0;s=t.end(t.length-1)))return this.techWaiting_();this.consecutiveUpdates>=5&&e===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):e===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=e)}}},{key:"cancelTimer_",value:function(){this.consecutiveUpdates=0,this.timer_&&(this.logger_("cancelTimer_"),clearTimeout(this.timer_)),this.timer_=null}},{key:"fixesBadSeeks_",value:function(){if(!this.tech_.seeking())return!1;var e=this.seekable(),t=this.tech_.currentTime(),i=void 0;this.afterSeekableWindow_(e,t,this.media(),this.allowSeeksWithinUnsafeLiveWindow)&&(i=e.end(e.length-1));this.beforeSeekableWindow_(e,t)&&(i=e.start(0)+.1);return void 0!==i&&(this.logger_("Trying to seek outside of seekable at time "+t+" with seekable range "+Dc(e)+". Seeking to "+i+"."),this.tech_.setCurrentTime(i),!0)}},{key:"waiting_",value:function(){if(!this.techWaiting_()){var e=this.tech_.currentTime(),t=this.tech_.buffered(),i=Lc(t,e);return i.length&&e+3<=i.end(0)?(this.cancelTimer_(),this.tech_.setCurrentTime(e),this.logger_("Stopped at "+e+" while inside a buffered region ["+i.start(0)+" -> "+i.end(0)+"]. Attempting to resume playback by seeking to the current time."),void this.tech_.trigger({type:"usage",name:"hls-unknown-waiting"})):void 0}}},{key:"techWaiting_",value:function(){var e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_())return!0;if(this.tech_.seeking()||null!==this.timer_)return!0;if(this.beforeSeekableWindow_(e,t)){var i=e.end(e.length-1);return this.logger_("Fell out of live window at time "+t+". Seeking to live point (seekable end) "+i),this.cancelTimer_(),this.tech_.setCurrentTime(i),this.tech_.trigger({type:"usage",name:"hls-live-resync"}),!0}var n=this.tech_.buffered(),r=Oc(n,t);if(this.videoUnderflow_(r,n,t))return this.cancelTimer_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"hls-video-underflow"}),!0;if(r.length>0){var s=r.start(0)-t;return this.logger_("Stopped at "+t+", setting timer for "+s+", seeking to "+r.start(0)),this.timer_=setTimeout(this.skipTheGap_.bind(this),1e3*s,t),!0}return!1}},{key:"afterSeekableWindow_",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!e.length)return!1;var r=e.end(e.length-1)+.1,s=!i.endList;return s&&n&&(r=e.end(e.length-1)+3*i.targetDuration),t>r}},{key:"beforeSeekableWindow_",value:function(e,t){return!!(e.length&&e.start(0)>0&&t2)return{start:r,end:s}}return null}}]),e}(),sd={errorInterval:30,getSource:function(e){return e(this.tech({IWillNotUseThisInPlugins:!0}).currentSource_)}},ad=function(e){!function e(t,i){var n=0,r=0,s=Nl.mergeOptions(sd,i);t.ready((function(){t.trigger({type:"usage",name:"hls-error-reload-initialized"})}));var a=function(){r&&t.currentTime(r)},o=function(e){null!=e&&(r=t.duration()!==1/0&&t.currentTime()||0,t.one("loadedmetadata",a),t.src(e),t.trigger({type:"usage",name:"hls-error-reload"}),t.play())},u=function(){if(Date.now()-n<1e3*s.errorInterval)t.trigger({type:"usage",name:"hls-error-reload-canceled"});else{if(s.getSource&&"function"==typeof s.getSource)return n=Date.now(),s.getSource.call(t,o);Nl.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!")}},l=function e(){t.off("loadedmetadata",a),t.off("error",u),t.off("dispose",e)};t.on("error",u),t.on("dispose",l),t.reloadSourceOnError=function(i){l(),e(t,i)}}(this,e)},od={PlaylistLoader:Zl,Playlist:mc,Decrypter:Rr,AsyncStream:Or,decrypt:Nr,utils:xc,STANDARD_PLAYLIST_SELECTOR:function(){var e=this.useDevicePixelRatio&&ee.devicePixelRatio||1;return function(e,t,i,n,r){var s=e.playlists.map((function(e){var t,i;return t=e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width,i=e.attributes.RESOLUTION&&e.attributes.RESOLUTION.height,{bandwidth:e.attributes.BANDWIDTH||ee.Number.MAX_VALUE,width:t,height:i,playlist:e}}));Lh(s,(function(e,t){return e.bandwidth-t.bandwidth}));var a=(s=s.filter((function(e){return!mc.isIncompatible(e.playlist)}))).filter((function(e){return mc.isEnabled(e.playlist)}));a.length||(a=s.filter((function(e){return!mc.isDisabled(e.playlist)})));var o=a.filter((function(e){return e.bandwidth*Th.BANDWIDTH_VARIANCEi||e.height>n}))).filter((function(e){return e.width===f[0].width&&e.height===f[0].height})),u=m[m.length-1],g=m.filter((function(e){return e.bandwidth===u.bandwidth}))[0]);var v=g||p||l||a[0]||s[0];return v?v.playlist:null}(this.playlists.master,this.systemBandwidth,parseInt(Ph(this.tech_.el(),"width"),10)*e,parseInt(Ph(this.tech_.el(),"height"),10)*e,this.limitRenditionByPlayerDimensions)},INITIAL_PLAYLIST_SELECTOR:function(){var e=this.playlists.master.playlists.filter(mc.isEnabled);return Lh(e,(function(e,t){return Oh(e,t)})),e.filter((function(e){return Qc(e.attributes.CODECS).videoCodec}))[0]||null},comparePlaylistBandwidth:Oh,comparePlaylistResolution:function(e,t){var i=void 0,n=void 0;return e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(i=e.attributes.RESOLUTION.width),i=i||ee.Number.MAX_VALUE,t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width&&(n=t.attributes.RESOLUTION.width),i===(n=n||ee.Number.MAX_VALUE)&&e.attributes.BANDWIDTH&&t.attributes.BANDWIDTH?e.attributes.BANDWIDTH-t.attributes.BANDWIDTH:i-n},xhr:yc()};["GOAL_BUFFER_LENGTH","MAX_GOAL_BUFFER_LENGTH","GOAL_BUFFER_LENGTH_RATE","BUFFER_LOW_WATER_LINE","MAX_BUFFER_LOW_WATER_LINE","BUFFER_LOW_WATER_LINE_RATE","BANDWIDTH_VARIANCE"].forEach((function(e){Object.defineProperty(od,e,{get:function(){return Nl.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),Th[e]},set:function(t){Nl.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),"number"!=typeof t||t<0?Nl.log.warn("value of Hls."+e+" must be greater than or equal to 0"):Th[e]=t}})}));var ud=function(e){if(/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i.test(e))return"hls";return/^application\/dash\+xml/i.test(e)?"dash":null},ld=function(e,t){for(var i=t.media(),n=-1,r=0;r0?1/this.throughput:0,Math.floor(1/(e+t))},set:function(){Nl.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:function(){return i.bandwidth||0},enumerable:!0},mediaRequests:{get:function(){return i.masterPlaylistController_.mediaRequests_()||0},enumerable:!0},mediaRequestsAborted:{get:function(){return i.masterPlaylistController_.mediaRequestsAborted_()||0},enumerable:!0},mediaRequestsTimedout:{get:function(){return i.masterPlaylistController_.mediaRequestsTimedout_()||0},enumerable:!0},mediaRequestsErrored:{get:function(){return i.masterPlaylistController_.mediaRequestsErrored_()||0},enumerable:!0},mediaTransferDuration:{get:function(){return i.masterPlaylistController_.mediaTransferDuration_()||0},enumerable:!0},mediaBytesTransferred:{get:function(){return i.masterPlaylistController_.mediaBytesTransferred_()||0},enumerable:!0},mediaSecondsLoaded:{get:function(){return i.masterPlaylistController_.mediaSecondsLoaded_()||0},enumerable:!0},buffered:{get:function(){return Nc(i.tech_.buffered())},enumerable:!0},currentTime:{get:function(){return i.tech_.currentTime()},enumerable:!0},currentSource:{get:function(){return i.tech_.currentSource_},enumerable:!0},currentTech:{get:function(){return i.tech_.name_},enumerable:!0},duration:{get:function(){return i.tech_.duration()},enumerable:!0},master:{get:function(){return i.playlists.master},enumerable:!0},playerDimensions:{get:function(){return i.tech_.currentDimensions()},enumerable:!0},seekable:{get:function(){return Nc(i.tech_.seekable())},enumerable:!0},timestamp:{get:function(){return Date.now()},enumerable:!0},videoPlaybackQuality:{get:function(){return i.tech_.getVideoPlaybackQuality()},enumerable:!0}}),this.tech_.one("canplay",this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_)),this.tech_.on("bandwidthupdate",(function(){i.options_.useBandwidthFromLocalStorage&&function(e){if(!window.localStorage)return!1;var t=hd();t=t?Nl.mergeOptions(t,e):e;try{window.localStorage.setItem("videojs-vhs",JSON.stringify(t))}catch(e){return!1}}({bandwidth:i.bandwidth,throughput:Math.round(i.throughput)})})),this.masterPlaylistController_.on("selectedinitialmedia",(function(){var e,t;t=(e=i).playlists,e.representations=function(){return t&&t.master&&t.master.playlists?t.master.playlists.filter((function(e){return!hc(e)})).map((function(t,i){return new id(e,t,t.id)})):[]},cd(i)})),this.on(this.masterPlaylistController_,"progress",(function(){this.tech_.trigger("progress")})),this.on(this.masterPlaylistController_,"firstplay",(function(){this.ignoreNextSeekingEvent_=!0})),this.setupQualityLevels_(),this.tech_.el()&&this.tech_.src(Nl.URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var e=this,t=Nl.players[this.tech_.options_.playerId];t&&t.qualityLevels&&!this.qualityLevels_&&(this.qualityLevels_=t.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",(function(){var t,i;t=e.qualityLevels_,(i=e).representations().forEach((function(e){t.addQualityLevel(e)})),ld(t,i.playlists)})),this.playlists.on("mediachange",(function(){ld(e.qualityLevels_,e.playlists)})))}},{key:"play",value:function(){this.masterPlaylistController_.play()}},{key:"setCurrentTime",value:function(e){this.masterPlaylistController_.setCurrentTime(e)}},{key:"duration",value:function(){return this.masterPlaylistController_.duration()}},{key:"seekable",value:function(){return this.masterPlaylistController_.seekable()}},{key:"dispose",value:function(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.masterPlaylistController_&&this.masterPlaylistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.player_&&(delete this.player_.vhs,delete this.player_.dash,delete this.player_.hls),this.tech_&&this.tech_.hls&&delete this.tech_.hls,function e(t,i,n){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,i);if(void 0===r){var s=Object.getPrototypeOf(t);return null===s?void 0:e(s,i,n)}if("value"in r)return r.value;var a=r.get;return void 0!==a?a.call(n):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"dispose",this).call(this)}},{key:"convertToProgramTime",value:function(e,t){return Ac({playlist:this.masterPlaylistController_.media(),time:e,callback:t})}},{key:"seekToProgramTime",value:function(e,t){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2;return Ic({programTime:e,playlist:this.masterPlaylistController_.media(),retryCount:n,pauseAfterSeek:i,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}}]),t}(Nl.getComponent("Component")),pd={name:"videojs-http-streaming",VERSION:"1.13.2",canHandleSource:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=Nl.mergeOptions(Nl.options,t);return pd.canPlayType(e.type,i)},handleSource:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=Nl.mergeOptions(Nl.options,i);return t.hls=new dd(e,t,n),t.hls.xhr=yc(),t.hls.src(e.src,e.type),t.hls},canPlayType:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=Nl.mergeOptions(Nl.options,t),n=i.hls.overrideNative,r=ud(e),s=r&&(!od.supportsTypeNatively(r)||n);return s?"maybe":""}};function fd(t){let i,n,r,s,a,b,T,S,k,C,w,E,x,A,I;return{c(){i=c("div"),n=c("div"),r=c("div"),s=c("div"),a=d(),b=c("div"),T=h(t[1]),S=d(),k=c("video"),C=c("source"),this.h()},l(e){i=g(e,"DIV",{class:!0});var o=m(i);n=g(o,"DIV",{class:!0});var u=m(n);r=g(u,"DIV",{class:!0});var c=m(r);s=g(c,"DIV",{class:!0}),m(s).forEach(l),a=y(c),b=g(c,"DIV",{class:!0});var h=m(b);T=v(h,t[1]),h.forEach(l),S=y(c),k=g(c,"VIDEO",{id:!0,class:!0,autoplay:!0,muted:!0,preload:!0,"data-setup":!0});var d=m(k);C=g(d,"SOURCE",{src:!0,type:!0}),d.forEach(l),c.forEach(l),u.forEach(l),o.forEach(l),this.h()},h(){f(s,"class","overlay"),f(b,"class","title"),C.src!==(w=t[0])&&f(C,"src",w),f(C,"type","application/x-mpegURL"),f(k,"id",t[2]),f(k,"class","video-js vjs-16-9"),k.autoplay=!0,k.muted=!0,f(k,"preload","auto"),f(k,"data-setup",E=JSON.stringify(t[4])),f(r,"class",x="stream live "+t[3]),f(n,"class","wrapper"),f(i,"class","quarter")},m(e,l){u(e,i,l),o(i,n),o(n,r),o(r,s),o(r,a),o(r,b),o(b,T),o(r,S),o(r,k),o(k,C),A||(I=p(i,"click",t[5]),A=!0)},p(e,[t]){2&t&&_(T,e[1]),1&t&&C.src!==(w=e[0])&&f(C,"src",w),4&t&&f(k,"id",e[2]),8&t&&x!==(x="stream live "+e[3])&&f(r,"class",x)},i:e,o:e,d(e){e&&l(i),A=!1,I()}}}function md(e,t,i){let{id:n}=t,{src:r}=t,{title:s}=t,a="",o="";let u;return S(()=>{try{u=Nl(a)}catch(e){console.log(e)}z.subscribe(e=>{i(3,o=""!==a&&e===a?"active":""),u&&(console.log(a+" - mute"),u.muted(!0),o&&(console.log(a+" - unmute"),u.muted(!1)))}),console.log(`mounted ${a} player`)}),e.$set=e=>{"id"in e&&i(6,n=e.id),"src"in e&&i(0,r=e.src),"title"in e&&i(1,s=e.title)},e.$$.update=()=>{64&e.$$.dirty&&i(2,a=n+"-live")},[r,s,a,o,{youtube:{ytControls:0}},function(){$.setPlaying(a)},n]}void 0!==Nl.MediaSource&&void 0!==Nl.URL||(Nl.MediaSource=lh,Nl.URL=ch),lh.supportsNativeMediaSources()&&Nl.getTech("Html5").registerSourceHandler(pd,0),Nl.HlsHandler=dd,Nl.HlsSourceHandler=pd,Nl.Hls=od,Nl.use||Nl.registerComponent("Hls",od),Nl.options.hls=Nl.options.hls||{},Nl.registerPlugin?Nl.registerPlugin("reloadSourceOnError",ad):Nl.plugin("reloadSourceOnError",ad);class gd extends q{constructor(e){super(),H(this,e,md,fd,s,{id:6,src:0,title:1})}}function vd(t){let i,n,r,s,a,b,T,S,k,C;return{c(){i=c("div"),n=c("div"),r=c("div"),s=c("div"),a=d(),b=c("div"),T=h(t[0]),this.h()},l(e){i=g(e,"DIV",{class:!0});var o=m(i);n=g(o,"DIV",{class:!0});var u=m(n);r=g(u,"DIV",{class:!0,"data-video-id":!0,id:!0});var c=m(r);s=g(c,"DIV",{class:!0}),m(s).forEach(l),a=y(c),b=g(c,"DIV",{class:!0});var h=m(b);T=v(h,t[0]),h.forEach(l),c.forEach(l),u.forEach(l),o.forEach(l),this.h()},h(){f(s,"class","overlay"),f(b,"class","title"),f(r,"class",S="stream live twitch "+t[2]),f(r,"data-video-id","4"),f(r,"id",t[1]),f(n,"class","wrapper"),f(i,"class","quarter")},m(e,l){u(e,i,l),o(i,n),o(n,r),o(r,s),o(r,a),o(r,b),o(b,T),k||(C=p(i,"click",t[3]),k=!0)},p(e,[t]){1&t&&_(T,e[0]),4&t&&S!==(S="stream live twitch "+e[2])&&f(r,"class",S),2&t&&f(r,"id",e[1])},i:e,o:e,d(e){e&&l(i),k=!1,C()}}}function yd(e,t,i){let n,{id:r}=t,{channel:s}=t,{title:a}=t,o="",u="";return S(()=>{try{n=new Twitch.Player(o,{channel:s,muted:!0,width:"100%",height:"100%"})}catch(e){console.log(e)}z.subscribe(e=>{i(2,u=""!==o&&e===o?"active":""),n&&(console.log(o+" - mute"),n.setMuted(!0),u&&(console.log(o+" - unmute"),n.setMuted(!1)))}),console.log(`mounted ${o} player`)}),e.$set=e=>{"id"in e&&i(4,r=e.id),"channel"in e&&i(5,s=e.channel),"title"in e&&i(0,a=e.title)},e.$$.update=()=>{16&e.$$.dirty&&i(1,o=r+"-twitch")},[a,o,u,function(){console.log("click "+o),$.setPlaying(o)},r,s]}class _d extends q{constructor(e){super(),H(this,e,yd,vd,s,{id:4,channel:5,title:0})}}function bd(e){let t,i,n,r,s,a,p,b,T,S,k,C,w,E;const x=new gd({props:{title:"Sky News",id:"skynews",src:"http://skydvn-sn-mobile-prod.skydvn.com/skynews/1404/latest.m3u8#"+e[0]}}),A=new gd({props:{title:"BBC News",id:"bbcnews24",src:"http://vs-hls-push-uk.live.cf.md.bbci.co.uk/manifest/x=3/i=urn:bbc:pips:service:bbc_news_channel_hd/mobile_wifi_main_sd_abr_v2_http.m3u8#"+e[0]}}),I=new K({props:{title:"EuroNews",id:"euronews",src:"https://www.youtube.com/embed/sPgqEHsONK8?enablejsapi=1&autoplay=1&mute=1&controls=0&fs=0&modestbranding=1&cc_load_policy=1"}}),P=new gd({props:{title:"BBC Parliament",id:"bbcparliament",src:"http://vs-hls-pushb-uk-live.akamaized.net/manifest/x=3/i=urn:bbc:pips:service:bbc_parliament/mobile_wifi_main_sd_abr_v2_akamai_hls_live_http.m3u8#"+e[0]}}),L=new gd({props:{title:"Bloomberg",id:"bloomberg",src:"https://liveprodeuwest.akamaized.net/eu1/Channel-EUTVqvs-AWS-ireland-1/Source-EUTVqvs-1000-1_live.m3u8#"+e[0]}}),O=new gd({props:{title:"BBC Scotland",id:"bbcscotland",src:"https://vs-hls-pushb-uk-live.akamaized.net/content/x=3/v=pv14/b=5070016/t=3840/i=urn:bbc:pips:service:bbc_scotland_hd/main.m3u8#"+e[0]}}),D=new _d({props:{title:"twitch.tv/rukpolitics",id:"rukpolitics",channel:"rukpolitics"}}),N=new _d({props:{title:"twitch.tv/ukcommons",id:"ukcommons",channel:"ukcommons"}}),V=new _d({props:{title:"twitch.tv/democracylive",id:"democracylive",channel:"democracylive"}});return{c(){t=c("div"),i=h("Playing:"),n=h(e[1]),r=d(),s=c("div"),M(x.$$.fragment),a=d(),M(A.$$.fragment),p=d(),M(I.$$.fragment),b=d(),M(P.$$.fragment),T=d(),M(L.$$.fragment),S=d(),M(O.$$.fragment),k=d(),M(D.$$.fragment),C=d(),M(N.$$.fragment),w=d(),M(V.$$.fragment),this.h()},l(o){t=g(o,"DIV",{});var u=m(t);i=v(u,"Playing:"),n=v(u,e[1]),u.forEach(l),r=y(o),s=g(o,"DIV",{id:!0});var c=m(s);B(x.$$.fragment,c),a=y(c),B(A.$$.fragment,c),p=y(c),B(I.$$.fragment,c),b=y(c),B(P.$$.fragment,c),T=y(c),B(L.$$.fragment,c),S=y(c),B(O.$$.fragment,c),k=y(c),B(D.$$.fragment,c),C=y(c),B(N.$$.fragment,c),w=y(c),B(V.$$.fragment,c),c.forEach(l),this.h()},h(){f(s,"id","container")},m(e,l){u(e,t,l),o(t,i),o(t,n),u(e,r,l),u(e,s,l),j(x,s,null),o(s,a),j(A,s,null),o(s,p),j(I,s,null),o(s,b),j(P,s,null),o(s,T),j(L,s,null),o(s,S),j(O,s,null),o(s,k),j(D,s,null),o(s,C),j(N,s,null),o(s,w),j(V,s,null),E=!0},p(e,[t]){(!E||2&t)&&_(n,e[1]);const i={};1&t&&(i.src="http://skydvn-sn-mobile-prod.skydvn.com/skynews/1404/latest.m3u8#"+e[0]),x.$set(i);const r={};1&t&&(r.src="http://vs-hls-push-uk.live.cf.md.bbci.co.uk/manifest/x=3/i=urn:bbc:pips:service:bbc_news_channel_hd/mobile_wifi_main_sd_abr_v2_http.m3u8#"+e[0]),A.$set(r);const s={};1&t&&(s.src="http://vs-hls-pushb-uk-live.akamaized.net/manifest/x=3/i=urn:bbc:pips:service:bbc_parliament/mobile_wifi_main_sd_abr_v2_akamai_hls_live_http.m3u8#"+e[0]),P.$set(s);const a={};1&t&&(a.src="https://liveprodeuwest.akamaized.net/eu1/Channel-EUTVqvs-AWS-ireland-1/Source-EUTVqvs-1000-1_live.m3u8#"+e[0]),L.$set(a);const o={};1&t&&(o.src="https://vs-hls-pushb-uk-live.akamaized.net/content/x=3/v=pv14/b=5070016/t=3840/i=urn:bbc:pips:service:bbc_scotland_hd/main.m3u8#"+e[0]),O.$set(o)},i(e){E||(R(x.$$.fragment,e),R(A.$$.fragment,e),R(I.$$.fragment,e),R(P.$$.fragment,e),R(L.$$.fragment,e),R(O.$$.fragment,e),R(D.$$.fragment,e),R(N.$$.fragment,e),R(V.$$.fragment,e),E=!0)},o(e){U(x.$$.fragment,e),U(A.$$.fragment,e),U(I.$$.fragment,e),U(P.$$.fragment,e),U(L.$$.fragment,e),U(O.$$.fragment,e),U(D.$$.fragment,e),U(N.$$.fragment,e),U(V.$$.fragment,e),E=!1},d(e){e&&l(t),e&&l(r),e&&l(s),F(x),F(A),F(I),F(P),F(L),F(O),F(D),F(N),F(V)}}}function Td(e,t,i){let n;a(e,z,e=>i(1,n=e));let r=0;return i(0,r=(new Date).getTime.toString(36)),[r,n]}return new class extends q{constructor(e){super(),H(this,e,Td,bd,s,{})}}({target:document.body,props:{}})}();
diff --git a/src/App.svelte b/src/App.svelte
index 33622fa..4e8dc21 100644
--- a/src/App.svelte
+++ b/src/App.svelte
@@ -24,12 +24,15 @@
-
+
-
+
+
+
+