stream-engine-player 0.0.24 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -101,7 +101,7 @@ See https://github.com/videojs/video.js/issues/2617 for more info.
|
|
101
101
|
`;return e},w2=function(r){var i=r.bytes;return _x(i)},k2=function(r){var i="",t=void 0;for(t=0;t<r.length;t++)i+=x2(r,t)+" ";return i},D2=Object.freeze({createTransferableMessage:mx,initSegmentId:mp,segmentKeyId:yx,hexDump:_x,tagDump:w2,textRanges:k2}),Tx=.25,P2=function(r,i){if(!i.dateTimeObject)return null;var t=i.videoTimingInfo.transmuxerPrependedSeconds,e=i.videoTimingInfo.transmuxedPresentationStart,a=e+t,s=r-a;return new Date(i.dateTimeObject.getTime()+s*1e3)},R2=function(r){return r.transmuxedPresentationEnd-r.transmuxedPresentationStart-r.transmuxerPrependedSeconds},I2=function(r,i){var t=void 0;try{t=new Date(r)}catch{return null}if(!i||!i.segments||i.segments.length===0)return null;var e=i.segments[0];if(t<e.dateTimeObject)return null;for(var a=0;a<i.segments.length-1;a++){e=i.segments[a];var s=i.segments[a+1].dateTimeObject;if(t<s)break}var o=i.segments[i.segments.length-1],u=o.dateTimeObject,l=o.videoTimingInfo?R2(o.videoTimingInfo):o.duration+o.duration*Tx,d=new Date(u.getTime()+l*1e3);return t>d?null:(t>u&&(e=o),{segment:e,estimatedStart:e.videoTimingInfo?e.videoTimingInfo.transmuxedPresentationStart:ns.duration(i,i.mediaSequence+i.segments.indexOf(e)),type:e.videoTimingInfo?"accurate":"estimate"})},O2=function(r,i){if(!i||!i.segments||i.segments.length===0)return null;for(var t=0,e=void 0,a=0;a<i.segments.length&&(e=i.segments[a],t=e.videoTimingInfo?e.videoTimingInfo.transmuxedPresentationEnd:t+e.duration,!(r<=t));a++);var s=i.segments[i.segments.length-1];if(s.videoTimingInfo&&s.videoTimingInfo.transmuxedPresentationEnd<r)return null;if(r>t){if(r>t+s.duration*Tx)return null;e=s}return{segment:e,estimatedStart:e.videoTimingInfo?e.videoTimingInfo.transmuxedPresentationStart:t-e.duration,type:e.videoTimingInfo?"accurate":"estimate"}},L2=function(r,i){var t=void 0,e=void 0;try{t=new Date(r),e=new Date(i)}catch{}var a=t.getTime(),s=e.getTime();return(s-a)/1e3},M2=function(r){if(!r.segments||r.segments.length===0)return!1;for(var i=0;i<r.segments.length;i++){var t=r.segments[i];if(!t.dateTimeObject)return!1}return!0},F2=function(r){var i=r.playlist,t=r.time,e=t===void 0?void 0:t,a=r.callback;if(!a)throw new Error("getProgramTime: callback must be provided");if(!i||e===void 0)return a({message:"getProgramTime: playlist and time must be provided"});var s=O2(e,i);if(!s)return a({message:"valid programTime was not found"});if(s.type==="estimate")return a({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:s.estimatedStart});var o={mediaSeconds:e},u=P2(e,s.segment);return u&&(o.programDateTime=u.toISOString()),a(null,o)},N2=function n(r){var i=r.programTime,t=r.playlist,e=r.retryCount,a=e===void 0?2:e,s=r.seekTo,o=r.pauseAfterSeek,u=o===void 0?!0:o,l=r.tech,d=r.callback;if(!d)throw new Error("seekToProgramTime: callback must be provided");if(typeof i>"u"||!t||!s)return d({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!t.endList&&!l.hasStarted_)return d({message:"player must be playing a live stream to start buffering"});if(!M2(t))return d({message:"programDateTime tags must be provided in the manifest "+t.resolvedUri});var c=I2(i,t);if(!c)return d({message:i+" was not found in the stream"});var f=c.segment,h=L2(f.dateTimeObject,i);if(c.type==="estimate"){if(a===0)return d({message:i+" is not buffered yet. Try again"});s(c.estimatedStart+h),l.one("seeked",function(){n({programTime:i,playlist:t,retryCount:a-1,seekTo:s,pauseAfterSeek:u,tech:l,callback:d})});return}var g=f.start+h,p=function(){return d(null,l.currentTime())};l.one("seeked",p),u&&l.pause(),s(g)},yp=1/30,uu=yp*3,bx=function(r,i){var t=[],e=void 0;if(r&&r.length)for(e=0;e<r.length;e++)i(r.start(e),r.end(e))&&t.push([r.start(e),r.end(e)]);return be.createTimeRanges(t)},Sx=function(r,i){return bx(r,function(t,e){return t-uu<=i&&e+uu>=i})},Ex=function(r,i){return bx(r,function(t){return t-yp>=i})},B2=function(r){if(r.length<2)return be.createTimeRanges();for(var i=[],t=1;t<r.length;t++){var e=r.end(t-1),a=r.start(t);i.push([e,a])}return be.createTimeRanges(i)},l0=function(r){var i=[];if(!r||!r.length)return"";for(var t=0;t<r.length;t++)i.push(r.start(t)+" => "+r.end(t));return i.join(", ")},U2=function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,e=r.length?r.end(r.length-1):0;return(e-i)/t},xx=function(r){for(var i=[],t=0;t<r.length;t++)i.push({start:r.start(t),end:r.end(t)});return i},j2=function(r,i,t){var e=i.player_;if(t.captions&&t.captions.length){r.inbandTextTracks_||(r.inbandTextTracks_={});for(var a in t.captionStreams)if(!r.inbandTextTracks_[a]){e.tech_.trigger({type:"usage",name:"hls-608"});var s=e.textTracks().getTrackById(a);s?r.inbandTextTracks_[a]=s:r.inbandTextTracks_[a]=e.addRemoteTextTrack({kind:"captions",id:a,label:a},!1).track}}t.metadata&&t.metadata.length&&!r.metadataTrack_&&(r.metadataTrack_=e.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,r.metadataTrack_.inBandMetadataTrackDispatchType=t.metadata.dispatchType)},Uc=function(r,i,t){var e=void 0,a=void 0;if(!!t&&!!t.cues)for(e=t.cues.length;e--;)a=t.cues[e],a.startTime<=i&&a.endTime>=r&&t.removeCue(a)},$2=function(r){Object.defineProperties(r.frame,{id:{get:function(){return be.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),r.value.key}},value:{get:function(){return be.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),r.value.data}},privateData:{get:function(){return be.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),r.value.data}}})},Ax=function(r){var i=void 0;return isNaN(r)||Math.abs(r)===1/0?i=Number.MAX_VALUE:i=r,i},H2=function(r,i,t){var e=tt.WebKitDataCue||tt.VTTCue;if(i&&i.forEach(function(c){var f=c.stream;this.inbandTextTracks_[f].addCue(new e(c.startTime+this.timestampOffset,c.endTime+this.timestampOffset,c.text))},r),t){var a=Ax(r.mediaSource_.duration);if(t.forEach(function(c){var f=c.cueTime+this.timestampOffset;typeof f!="number"||tt.isNaN(f)||f<0||!(f<1/0)||c.frames.forEach(function(h){var g=new e(f,f,h.value||h.url||h.data||"");g.frame=h,g.value=h,$2(g),this.metadataTrack_.addCue(g)},this)},r),r.metadataTrack_&&r.metadataTrack_.cues&&r.metadataTrack_.cues.length){for(var s=r.metadataTrack_.cues,o=[],u=0;u<s.length;u++)s[u]&&o.push(s[u]);var l=o.reduce(function(c,f){var h=c[f.startTime]||[];return h.push(f),c[f.startTime]=h,c},{}),d=Object.keys(l).sort(function(c,f){return Number(c)-Number(f)});d.forEach(function(c,f){var h=l[c],g=Number(d[f+1])||a;h.forEach(function(p){p.endTime=g})})}}},Cl=typeof window<"u"?window:{},c0=typeof Symbol>"u"?"__target":Symbol(),V2="application/javascript",G2=Cl.BlobBuilder||Cl.WebKitBlobBuilder||Cl.MozBlobBuilder||Cl.MSBlobBuilder,jc=Cl.URL||Cl.webkitURL||jc&&jc.msURL,$c=Cl.Worker;function Cx(n,r){return function(t){var e=this;if(r)if($c&&!t){var a=r.toString().replace(/^function.+?{/,"").slice(0,-1),s=Dx(a);return this[c0]=new $c(s),q2(this[c0],s),this[c0]}else{var o={postMessage:function(l){e.onmessage&&setTimeout(function(){e.onmessage({data:l,target:o})})}};r.call(o),this.postMessage=function(u){setTimeout(function(){o.onmessage({data:u,target:e})})},this.isThisThread=!0}else return new $c(n)}}if($c){var _p,wx=Dx("self.onmessage = function () {}"),kx=new Uint8Array(1);try{_p=new $c(wx),_p.postMessage(kx,[kx.buffer])}catch{$c=null}finally{jc.revokeObjectURL(wx),_p&&_p.terminate()}}function Dx(n){try{return jc.createObjectURL(new Blob([n],{type:V2}))}catch{var r=new G2;return r.append(n),jc.createObjectURL(r.getBlob(type))}}function q2(n,r){if(!(!n||!r)){var i=n.terminate;n.objURL=r,n.terminate=function(){n.objURL&&jc.revokeObjectURL(n.objURL),i.call(n)}}}var W2=new Cx("./transmuxer-worker.worker.js",function(n,r){var i=this;(function(){var t=function(){this.init=function(){var X={};this.on=function(ee,de){X[ee]||(X[ee]=[]),X[ee]=X[ee].concat(de)},this.off=function(ee,de){var fe;return X[ee]?(fe=X[ee].indexOf(de),X[ee]=X[ee].slice(),X[ee].splice(fe,1),fe>-1):!1},this.trigger=function(ee){var de,fe,Ee,Ae;if(de=X[ee],!!de)if(arguments.length===2)for(Ee=de.length,fe=0;fe<Ee;++fe)de[fe].call(this,arguments[1]);else{for(Ae=[],fe=arguments.length,fe=1;fe<arguments.length;++fe)Ae.push(arguments[fe]);for(Ee=de.length,fe=0;fe<Ee;++fe)de[fe].apply(this,Ae)}},this.dispose=function(){X={}}}};t.prototype.pipe=function(Ne){return this.on("data",function(X){Ne.push(X)}),this.on("done",function(X){Ne.flush(X)}),this.on("partialdone",function(X){Ne.partialFlush(X)}),this.on("endedtimeline",function(X){Ne.endTimeline(X)}),this.on("reset",function(X){Ne.reset(X)}),Ne},t.prototype.push=function(Ne){this.trigger("data",Ne)},t.prototype.flush=function(Ne){this.trigger("done",Ne)},t.prototype.partialFlush=function(Ne){this.trigger("partialdone",Ne)},t.prototype.endTimeline=function(Ne){this.trigger("endedtimeline",Ne)},t.prototype.reset=function(Ne){this.trigger("reset",Ne)};var e=t,a=Math.pow(2,32)-1,s,o,u,l,d,c,f,h,g,p,v,y,m,T,b,E,C,x,S,w,k,P,R,N,G,I,M,B,q,Z,re,oe,ae,ne,ye,Pe;(function(){var Ne;if(R={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},!(typeof Uint8Array>"u")){for(Ne in R)R.hasOwnProperty(Ne)&&(R[Ne]=[Ne.charCodeAt(0),Ne.charCodeAt(1),Ne.charCodeAt(2),Ne.charCodeAt(3)]);N=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]),I=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]),G=new Uint8Array([0,0,0,1]),M=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),B=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),q={video:M,audio:B},oe=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),re=new Uint8Array([0,0,0,0,0,0,0,0]),ae=new Uint8Array([0,0,0,0,0,0,0,0]),ne=ae,ye=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Pe=ae,Z=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}})(),s=function(X){var ee=[],de=0,fe,Ee,Ae;for(fe=1;fe<arguments.length;fe++)ee.push(arguments[fe]);for(fe=ee.length;fe--;)de+=ee[fe].byteLength;for(Ee=new Uint8Array(de+8),Ae=new DataView(Ee.buffer,Ee.byteOffset,Ee.byteLength),Ae.setUint32(0,Ee.byteLength),Ee.set(X,4),fe=0,de=8;fe<ee.length;fe++)Ee.set(ee[fe],de),de+=ee[fe].byteLength;return Ee},o=function(){return s(R.dinf,s(R.dref,oe))},u=function(X){return s(R.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,X.audioobjecttype<<3|X.samplingfrequencyindex>>>1,X.samplingfrequencyindex<<7|X.channelcount<<3,6,1,2]))},l=function(){return s(R.ftyp,N,G,N,I)},E=function(X){return s(R.hdlr,q[X])},d=function(X){return s(R.mdat,X)},b=function(X){var ee=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,X.duration>>>24&255,X.duration>>>16&255,X.duration>>>8&255,X.duration&255,85,196,0,0]);return X.samplerate&&(ee[12]=X.samplerate>>>24&255,ee[13]=X.samplerate>>>16&255,ee[14]=X.samplerate>>>8&255,ee[15]=X.samplerate&255),s(R.mdhd,ee)},T=function(X){return s(R.mdia,b(X),E(X.type),f(X))},c=function(X){return s(R.mfhd,new Uint8Array([0,0,0,0,(X&4278190080)>>24,(X&16711680)>>16,(X&65280)>>8,X&255]))},f=function(X){return s(R.minf,X.type==="video"?s(R.vmhd,Z):s(R.smhd,re),o(),x(X))},h=function(X,ee){for(var de=[],fe=ee.length;fe--;)de[fe]=w(ee[fe]);return s.apply(null,[R.moof,c(X)].concat(de))},g=function(X){for(var ee=X.length,de=[];ee--;)de[ee]=y(X[ee]);return s.apply(null,[R.moov,v(4294967295)].concat(de).concat(p(X)))},p=function(X){for(var ee=X.length,de=[];ee--;)de[ee]=k(X[ee]);return s.apply(null,[R.mvex].concat(de))},v=function(X){var ee=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(X&4278190080)>>24,(X&16711680)>>16,(X&65280)>>8,X&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return s(R.mvhd,ee)},C=function(X){var ee=X.samples||[],de=new Uint8Array(4+ee.length),fe,Ee;for(Ee=0;Ee<ee.length;Ee++)fe=ee[Ee].flags,de[Ee+4]=fe.dependsOn<<4|fe.isDependedOn<<2|fe.hasRedundancy;return s(R.sdtp,de)},x=function(X){return s(R.stbl,S(X),s(R.stts,Pe),s(R.stsc,ne),s(R.stsz,ye),s(R.stco,ae))},function(){var Ne,X;S=function(de){return s(R.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),de.type==="video"?Ne(de):X(de))},Ne=function(de){var fe=de.sps||[],Ee=de.pps||[],Ae=[],Ue=[],He,it;for(He=0;He<fe.length;He++)Ae.push((fe[He].byteLength&65280)>>>8),Ae.push(fe[He].byteLength&255),Ae=Ae.concat(Array.prototype.slice.call(fe[He]));for(He=0;He<Ee.length;He++)Ue.push((Ee[He].byteLength&65280)>>>8),Ue.push(Ee[He].byteLength&255),Ue=Ue.concat(Array.prototype.slice.call(Ee[He]));if(it=[R.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,(de.width&65280)>>8,de.width&255,(de.height&65280)>>8,de.height&255,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]),s(R.avcC,new Uint8Array([1,de.profileIdc,de.profileCompatibility,de.levelIdc,255].concat([fe.length],Ae,[Ee.length],Ue))),s(R.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],de.sarRatio){var St=de.sarRatio[0],or=de.sarRatio[1];it.push(s(R.pasp,new Uint8Array([(St&4278190080)>>24,(St&16711680)>>16,(St&65280)>>8,St&255,(or&4278190080)>>24,(or&16711680)>>16,(or&65280)>>8,or&255])))}return s.apply(null,it)},X=function(de){return s(R.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(de.channelcount&65280)>>8,de.channelcount&255,(de.samplesize&65280)>>8,de.samplesize&255,0,0,0,0,(de.samplerate&65280)>>8,de.samplerate&255,0,0]),u(de))}}(),m=function(X){var ee=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(X.id&4278190080)>>24,(X.id&16711680)>>16,(X.id&65280)>>8,X.id&255,0,0,0,0,(X.duration&4278190080)>>24,(X.duration&16711680)>>16,(X.duration&65280)>>8,X.duration&255,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,(X.width&65280)>>8,X.width&255,0,0,(X.height&65280)>>8,X.height&255,0,0]);return s(R.tkhd,ee)},w=function(X){var ee,de,fe,Ee,Ae,Ue,He;return ee=s(R.tfhd,new Uint8Array([0,0,0,58,(X.id&4278190080)>>24,(X.id&16711680)>>16,(X.id&65280)>>8,X.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),Ue=Math.floor(X.baseMediaDecodeTime/(a+1)),He=Math.floor(X.baseMediaDecodeTime%(a+1)),de=s(R.tfdt,new Uint8Array([1,0,0,0,Ue>>>24&255,Ue>>>16&255,Ue>>>8&255,Ue&255,He>>>24&255,He>>>16&255,He>>>8&255,He&255])),Ae=32+20+8+16+8+8,X.type==="audio"?(fe=P(X,Ae),s(R.traf,ee,de,fe)):(Ee=C(X),fe=P(X,Ee.length+Ae),s(R.traf,ee,de,fe,Ee))},y=function(X){return X.duration=X.duration||4294967295,s(R.trak,m(X),T(X))},k=function(X){var ee=new Uint8Array([0,0,0,0,(X.id&4278190080)>>24,(X.id&16711680)>>16,(X.id&65280)>>8,X.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return X.type!=="video"&&(ee[ee.length-1]=0),s(R.trex,ee)},function(){var Ne,X,ee;ee=function(fe,Ee){var Ae=0,Ue=0,He=0,it=0;return fe.length&&(fe[0].duration!==void 0&&(Ae=1),fe[0].size!==void 0&&(Ue=2),fe[0].flags!==void 0&&(He=4),fe[0].compositionTimeOffset!==void 0&&(it=8)),[0,0,Ae|Ue|He|it,1,(fe.length&4278190080)>>>24,(fe.length&16711680)>>>16,(fe.length&65280)>>>8,fe.length&255,(Ee&4278190080)>>>24,(Ee&16711680)>>>16,(Ee&65280)>>>8,Ee&255]},X=function(fe,Ee){var Ae,Ue,He,it;for(Ue=fe.samples||[],Ee+=8+12+16*Ue.length,Ae=ee(Ue,Ee),it=0;it<Ue.length;it++)He=Ue[it],Ae=Ae.concat([(He.duration&4278190080)>>>24,(He.duration&16711680)>>>16,(He.duration&65280)>>>8,He.duration&255,(He.size&4278190080)>>>24,(He.size&16711680)>>>16,(He.size&65280)>>>8,He.size&255,He.flags.isLeading<<2|He.flags.dependsOn,He.flags.isDependedOn<<6|He.flags.hasRedundancy<<4|He.flags.paddingValue<<1|He.flags.isNonSyncSample,He.flags.degradationPriority&240<<8,He.flags.degradationPriority&15,(He.compositionTimeOffset&4278190080)>>>24,(He.compositionTimeOffset&16711680)>>>16,(He.compositionTimeOffset&65280)>>>8,He.compositionTimeOffset&255]);return s(R.trun,new Uint8Array(Ae))},Ne=function(fe,Ee){var Ae,Ue,He,it;for(Ue=fe.samples||[],Ee+=8+12+8*Ue.length,Ae=ee(Ue,Ee),it=0;it<Ue.length;it++)He=Ue[it],Ae=Ae.concat([(He.duration&4278190080)>>>24,(He.duration&16711680)>>>16,(He.duration&65280)>>>8,He.duration&255,(He.size&4278190080)>>>24,(He.size&16711680)>>>16,(He.size&65280)>>>8,He.size&255]);return s(R.trun,new Uint8Array(Ae))},P=function(fe,Ee){return fe.type==="audio"?Ne(fe,Ee):X(fe,Ee)}}();var $e={ftyp:l,mdat:d,moof:h,moov:g,initSegment:function(X){var ee=l(),de=g(X),fe;return fe=new Uint8Array(ee.byteLength+de.byteLength),fe.set(ee),fe.set(de,ee.byteLength),fe}},ft=function(X){var ee,de,fe=[],Ee=[];for(Ee.byteLength=0,Ee.nalCount=0,Ee.duration=0,fe.byteLength=0,ee=0;ee<X.length;ee++)de=X[ee],de.nalUnitType==="access_unit_delimiter_rbsp"?(fe.length&&(fe.duration=de.dts-fe.dts,Ee.byteLength+=fe.byteLength,Ee.nalCount+=fe.length,Ee.duration+=fe.duration,Ee.push(fe)),fe=[de],fe.byteLength=de.data.byteLength,fe.pts=de.pts,fe.dts=de.dts):(de.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"&&(fe.keyFrame=!0),fe.duration=de.dts-fe.dts,fe.byteLength+=de.data.byteLength,fe.push(de));return Ee.length&&(!fe.duration||fe.duration<=0)&&(fe.duration=Ee[Ee.length-1].duration),Ee.byteLength+=fe.byteLength,Ee.nalCount+=fe.length,Ee.duration+=fe.duration,Ee.push(fe),Ee},at=function(X){var ee,de,fe=[],Ee=[];for(fe.byteLength=0,fe.nalCount=0,fe.duration=0,fe.pts=X[0].pts,fe.dts=X[0].dts,Ee.byteLength=0,Ee.nalCount=0,Ee.duration=0,Ee.pts=X[0].pts,Ee.dts=X[0].dts,ee=0;ee<X.length;ee++)de=X[ee],de.keyFrame?(fe.length&&(Ee.push(fe),Ee.byteLength+=fe.byteLength,Ee.nalCount+=fe.nalCount,Ee.duration+=fe.duration),fe=[de],fe.nalCount=de.length,fe.byteLength=de.byteLength,fe.pts=de.pts,fe.dts=de.dts,fe.duration=de.duration):(fe.duration+=de.duration,fe.nalCount+=de.length,fe.byteLength+=de.byteLength,fe.push(de));return Ee.length&&fe.duration<=0&&(fe.duration=Ee[Ee.length-1].duration),Ee.byteLength+=fe.byteLength,Ee.nalCount+=fe.nalCount,Ee.duration+=fe.duration,Ee.push(fe),Ee},Ye=function(X){var ee;return!X[0][0].keyFrame&&X.length>1&&(ee=X.shift(),X.byteLength-=ee.byteLength,X.nalCount-=ee.nalCount,X[0][0].dts=ee.dts,X[0][0].pts=ee.pts,X[0][0].duration+=ee.duration),X},gt=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},ur=function(X,ee){var de=gt();return de.dataOffset=ee,de.compositionTimeOffset=X.pts-X.dts,de.duration=X.duration,de.size=4*X.length,de.size+=X.byteLength,X.keyFrame&&(de.flags.dependsOn=2,de.flags.isNonSyncSample=0),de},pr=function(X,ee){var de,fe,Ee,Ae,Ue,He=ee||0,it=[];for(de=0;de<X.length;de++)for(Ae=X[de],fe=0;fe<Ae.length;fe++)Ue=Ae[fe],Ee=ur(Ue,He),He+=Ee.size,it.push(Ee);return it},Cr=function(X){var ee,de,fe,Ee,Ae,Ue,He=0,it=X.byteLength,St=X.nalCount,or=it+4*St,Wt=new Uint8Array(or),wr=new DataView(Wt.buffer);for(ee=0;ee<X.length;ee++)for(Ee=X[ee],de=0;de<Ee.length;de++)for(Ae=Ee[de],fe=0;fe<Ae.length;fe++)Ue=Ae[fe],wr.setUint32(He,Ue.data.byteLength),He+=4,Wt.set(Ue.data,He),He+=Ue.data.byteLength;return Wt},ut=function(X,ee){var de,fe=ee||0,Ee=[];return de=ur(X,fe),Ee.push(de),Ee},It=function(X){var ee,de,fe=0,Ee=X.byteLength,Ae=X.length,Ue=Ee+4*Ae,He=new Uint8Array(Ue),it=new DataView(He.buffer);for(ee=0;ee<X.length;ee++)de=X[ee],it.setUint32(fe,de.data.byteLength),fe+=4,He.set(de.data,fe),fe+=de.data.byteLength;return He},Nt={groupNalsIntoFrames:ft,groupFramesIntoGops:at,extendFirstKeyFrame:Ye,generateSampleTable:pr,concatenateNalData:Cr,generateSampleTableForFrame:ut,concatenateNalDataForFrame:It},Ut=[33,16,5,32,164,27],qt=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],ot=function(X){for(var ee=[];X--;)ee.push(0);return ee},Zt=function(X){return Object.keys(X).reduce(function(ee,de){return ee[de]=new Uint8Array(X[de].reduce(function(fe,Ee){return fe.concat(Ee)},[])),ee},{})},zt={96e3:[Ut,[227,64],ot(154),[56]],88200:[Ut,[231],ot(170),[56]],64e3:[Ut,[248,192],ot(240),[56]],48e3:[Ut,[255,192],ot(268),[55,148,128],ot(54),[112]],44100:[Ut,[255,192],ot(268),[55,163,128],ot(84),[112]],32e3:[Ut,[255,192],ot(268),[55,234],ot(226),[112]],24e3:[Ut,[255,192],ot(268),[55,255,128],ot(268),[111,112],ot(126),[224]],16e3:[Ut,[255,192],ot(268),[55,255,128],ot(268),[111,255],ot(269),[223,108],ot(195),[1,192]],12e3:[qt,ot(268),[3,127,248],ot(268),[6,255,240],ot(268),[13,255,224],ot(268),[27,253,128],ot(259),[56]],11025:[qt,ot(268),[3,127,248],ot(268),[6,255,240],ot(268),[13,255,224],ot(268),[27,255,192],ot(268),[55,175,128],ot(108),[112]],8e3:[qt,ot(268),[3,121,16],ot(47),[7]]},Dr=Zt(zt),xt=9e4,mi,pi,Hr,Pi,ui,Ci,wi;mi=function(X){return X*xt},pi=function(X,ee){return X*ee},Hr=function(X){return X/xt},Pi=function(X,ee){return X/ee},ui=function(X,ee){return mi(Pi(X,ee))},Ci=function(X,ee){return pi(Hr(X),ee)},wi=function(X,ee,de){return Hr(de?X:X-ee)};var Er={ONE_SECOND_IN_TS:xt,secondsToVideoTs:mi,secondsToAudioTs:pi,videoTsToSeconds:Hr,audioTsToSeconds:Pi,audioTsToVideoTs:ui,videoTsToAudioTs:Ci,metadataTsToSeconds:wi},yi=function(X){var ee,de,fe=0;for(ee=0;ee<X.length;ee++)de=X[ee],fe+=de.data.byteLength;return fe},In=function(X,ee,de,fe){var Ee,Ae=0,Ue=0,He=0,it=0,St,or,Wt;if(!!ee.length&&(Ee=Er.audioTsToVideoTs(X.baseMediaDecodeTime,X.samplerate),Ae=Math.ceil(Er.ONE_SECOND_IN_TS/(X.samplerate/1024)),de&&fe&&(Ue=Ee-Math.max(de,fe),He=Math.floor(Ue/Ae),it=He*Ae),!(He<1||it>Er.ONE_SECOND_IN_TS/2))){for(St=Dr[X.samplerate],St||(St=ee[0].data),or=0;or<He;or++)Wt=ee[0],ee.splice(0,0,{data:St,dts:Wt.dts-Ae,pts:Wt.pts-Ae});X.baseMediaDecodeTime-=Math.floor(Er.videoTsToAudioTs(it,X.samplerate))}},us=function(X,ee,de){return ee.minSegmentDts>=de?X:(ee.minSegmentDts=1/0,X.filter(function(fe){return fe.dts>=de?(ee.minSegmentDts=Math.min(ee.minSegmentDts,fe.dts),ee.minSegmentPts=ee.minSegmentDts,!0):!1}))},yo=function(X){var ee,de,fe=[];for(ee=0;ee<X.length;ee++)de=X[ee],fe.push({size:de.data.byteLength,duration:1024});return fe},As=function(X){var ee,de,fe=0,Ee=new Uint8Array(yi(X));for(ee=0;ee<X.length;ee++)de=X[ee],Ee.set(de.data,fe),fe+=de.data.byteLength;return Ee},Cn={prefixWithSilence:In,trimAdtsFramesByEarliestDts:us,generateSampleTable:yo,concatenateFrameData:As},Cs=Er.ONE_SECOND_IN_TS,_o=function(X,ee){typeof ee.pts=="number"&&(X.timelineStartInfo.pts===void 0&&(X.timelineStartInfo.pts=ee.pts),X.minSegmentPts===void 0?X.minSegmentPts=ee.pts:X.minSegmentPts=Math.min(X.minSegmentPts,ee.pts),X.maxSegmentPts===void 0?X.maxSegmentPts=ee.pts:X.maxSegmentPts=Math.max(X.maxSegmentPts,ee.pts)),typeof ee.dts=="number"&&(X.timelineStartInfo.dts===void 0&&(X.timelineStartInfo.dts=ee.dts),X.minSegmentDts===void 0?X.minSegmentDts=ee.dts:X.minSegmentDts=Math.min(X.minSegmentDts,ee.dts),X.maxSegmentDts===void 0?X.maxSegmentDts=ee.dts:X.maxSegmentDts=Math.max(X.maxSegmentDts,ee.dts))},On=function(X){delete X.minSegmentDts,delete X.maxSegmentDts,delete X.minSegmentPts,delete X.maxSegmentPts},Ga=function(X,ee){var de,fe,Ee=X.minSegmentDts;return ee||(Ee-=X.timelineStartInfo.dts),de=X.timelineStartInfo.baseMediaDecodeTime,de+=Ee,de=Math.max(0,de),X.type==="audio"&&(fe=X.samplerate/Cs,de*=fe,de=Math.floor(de)),de},li={clearDtsInfo:On,calculateTrackBaseMediaDecodeTime:Ga,collectDtsInfo:_o},ws=4,Ho=128,To=function(X){for(var ee=0,de={payloadType:-1,payloadSize:0},fe=0,Ee=0;ee<X.byteLength&&X[ee]!==Ho;){for(;X[ee]===255;)fe+=255,ee++;for(fe+=X[ee++];X[ee]===255;)Ee+=255,ee++;if(Ee+=X[ee++],!de.payload&&fe===ws){de.payloadType=fe,de.payloadSize=Ee,de.payload=X.subarray(ee,ee+Ee);break}ee+=Ee,fe=0,Ee=0}return de},ks=function(X){return X.payload[0]!==181||(X.payload[1]<<8|X.payload[2])!==49||String.fromCharCode(X.payload[3],X.payload[4],X.payload[5],X.payload[6])!=="GA94"||X.payload[7]!==3?null:X.payload.subarray(8,X.payload.length-1)},Ln=function(X,ee){var de=[],fe,Ee,Ae,Ue;if(!(ee[0]&64))return de;for(Ee=ee[0]&31,fe=0;fe<Ee;fe++)Ae=fe*3,Ue={type:ee[Ae+2]&3,pts:X},ee[Ae+2]&4&&(Ue.ccData=ee[Ae+3]<<8|ee[Ae+4],de.push(Ue));return de},ls=function(X){for(var ee=X.byteLength,de=[],fe=1,Ee,Ae;fe<ee-2;)X[fe]===0&&X[fe+1]===0&&X[fe+2]===3?(de.push(fe+2),fe+=2):fe++;if(de.length===0)return X;Ee=ee-de.length,Ae=new Uint8Array(Ee);var Ue=0;for(fe=0;fe<Ee;Ue++,fe++)Ue===de[0]&&(Ue++,de.shift()),Ae[fe]=X[Ue];return Ae},zn={parseSei:To,parseUserData:ks,parseCaptionPackets:Ln,discardEmulationPreventionBytes:ls,USER_DATA_REGISTERED_ITU_T_T35:ws},ki=function Ne(){Ne.prototype.init.call(this),this.captionPackets_=[],this.ccStreams_=[new Pr(0,0),new Pr(0,1),new Pr(1,0),new Pr(1,1)],this.reset(),this.ccStreams_.forEach(function(X){X.on("data",this.trigger.bind(this,"data")),X.on("partialdone",this.trigger.bind(this,"partialdone")),X.on("done",this.trigger.bind(this,"done"))},this)};ki.prototype=new e,ki.prototype.push=function(Ne){var X,ee,de;if(Ne.nalUnitType==="sei_rbsp"&&(X=zn.parseSei(Ne.escapedRBSP),X.payloadType===zn.USER_DATA_REGISTERED_ITU_T_T35&&(ee=zn.parseUserData(X),!!ee))){if(Ne.dts<this.latestDts_){this.ignoreNextEqualDts_=!0;return}else if(Ne.dts===this.latestDts_&&this.ignoreNextEqualDts_){this.numSameDts_--,this.numSameDts_||(this.ignoreNextEqualDts_=!1);return}de=zn.parseCaptionPackets(Ne.pts,ee),this.captionPackets_=this.captionPackets_.concat(de),this.latestDts_!==Ne.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=Ne.dts}},ki.prototype.flushCCStreams=function(Ne){this.ccStreams_.forEach(function(X){return Ne==="flush"?X.flush():X.partialFlush()},this)},ki.prototype.flushStream=function(Ne){if(!this.captionPackets_.length){this.flushCCStreams(Ne);return}this.captionPackets_.forEach(function(X,ee){X.presortIndex=ee}),this.captionPackets_.sort(function(X,ee){return X.pts===ee.pts?X.presortIndex-ee.presortIndex:X.pts-ee.pts}),this.captionPackets_.forEach(function(X){X.type<2&&this.dispatchCea608Packet(X)},this),this.captionPackets_.length=0,this.flushCCStreams(Ne)},ki.prototype.flush=function(){return this.flushStream("flush")},ki.prototype.partialFlush=function(){return this.flushStream("partialFlush")},ki.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(Ne){Ne.reset()})},ki.prototype.dispatchCea608Packet=function(Ne){this.setsTextOrXDSActive(Ne)?this.activeCea608Channel_[Ne.type]=null:this.setsChannel1Active(Ne)?this.activeCea608Channel_[Ne.type]=0:this.setsChannel2Active(Ne)&&(this.activeCea608Channel_[Ne.type]=1),this.activeCea608Channel_[Ne.type]!==null&&this.ccStreams_[(Ne.type<<1)+this.activeCea608Channel_[Ne.type]].push(Ne)},ki.prototype.setsChannel1Active=function(Ne){return(Ne.ccData&30720)===4096},ki.prototype.setsChannel2Active=function(Ne){return(Ne.ccData&30720)===6144},ki.prototype.setsTextOrXDSActive=function(Ne){return(Ne.ccData&28928)===256||(Ne.ccData&30974)===4138||(Ne.ccData&30974)===6186};var Vo={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},zs=function(X){return X===null?"":(X=Vo[X]||X,String.fromCharCode(X))},qa=14,Xn=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],wn=function(){for(var X=[],ee=qa+1;ee--;)X.push("");return X},Pr=function Ne(X,ee){Ne.prototype.init.call(this),this.field_=X||0,this.dataChannel_=ee||0,this.name_="CC"+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(de){var fe,Ee,Ae,Ue,He;if(fe=de.ccData&32639,fe===this.lastControlCode_){this.lastControlCode_=null;return}if((fe&61440)===4096?this.lastControlCode_=fe:fe!==this.PADDING_&&(this.lastControlCode_=null),Ae=fe>>>8,Ue=fe&255,fe!==this.PADDING_)if(fe===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(fe===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(de.pts),this.flushDisplayed(de.pts),Ee=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=Ee,this.startPts_=de.pts;else if(fe===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(de.pts);else if(fe===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(de.pts);else if(fe===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(de.pts);else if(fe===this.CARRIAGE_RETURN_)this.clearFormatting(de.pts),this.flushDisplayed(de.pts),this.shiftRowsUp_(),this.startPts_=de.pts;else if(fe===this.BACKSPACE_)this.mode_==="popOn"?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1);else if(fe===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(de.pts),this.displayed_=wn();else if(fe===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=wn();else if(fe===this.RESUME_DIRECT_CAPTIONING_)this.mode_!=="paintOn"&&(this.flushDisplayed(de.pts),this.displayed_=wn()),this.mode_="paintOn",this.startPts_=de.pts;else if(this.isSpecialCharacter(Ae,Ue))Ae=(Ae&3)<<8,He=zs(Ae|Ue),this[this.mode_](de.pts,He),this.column_++;else if(this.isExtCharacter(Ae,Ue))this.mode_==="popOn"?this.nonDisplayed_[this.row_]=this.nonDisplayed_[this.row_].slice(0,-1):this.displayed_[this.row_]=this.displayed_[this.row_].slice(0,-1),Ae=(Ae&3)<<8,He=zs(Ae|Ue),this[this.mode_](de.pts,He),this.column_++;else if(this.isMidRowCode(Ae,Ue))this.clearFormatting(de.pts),this[this.mode_](de.pts," "),this.column_++,(Ue&14)===14&&this.addFormatting(de.pts,["i"]),(Ue&1)===1&&this.addFormatting(de.pts,["u"]);else if(this.isOffsetControlCode(Ae,Ue))this.column_+=Ue&3;else if(this.isPAC(Ae,Ue)){var it=Xn.indexOf(fe&7968);this.mode_==="rollUp"&&(it-this.rollUpRows_+1<0&&(it=this.rollUpRows_-1),this.setRollUp(de.pts,it)),it!==this.row_&&(this.clearFormatting(de.pts),this.row_=it),Ue&1&&this.formatting_.indexOf("u")===-1&&this.addFormatting(de.pts,["u"]),(fe&16)===16&&(this.column_=((fe&14)>>1)*4),this.isColorPAC(Ue)&&(Ue&14)===14&&this.addFormatting(de.pts,["i"])}else this.isNormalChar(Ae)&&(Ue===0&&(Ue=null),He=zs(Ae),He+=zs(Ue),this[this.mode_](de.pts,He),this.column_+=He.length)}};Pr.prototype=new e,Pr.prototype.flushDisplayed=function(Ne){var X=this.displayed_.map(function(ee){try{return ee.trim()}catch{return console.error("Skipping malformed caption."),""}}).join(`
|
102
102
|
`).replace(/^\n+|\n+$/g,"");X.length&&this.trigger("data",{startPts:this.startPts_,endPts:Ne,text:X,stream:this.name_})},Pr.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=wn(),this.nonDisplayed_=wn(),this.lastControlCode_=null,this.column_=0,this.row_=qa,this.rollUpRows_=2,this.formatting_=[]},Pr.prototype.setConstants=function(){this.dataChannel_===0?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):this.dataChannel_===1&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=this.CONTROL_|32,this.END_OF_CAPTION_=this.CONTROL_|47,this.ROLL_UP_2_ROWS_=this.CONTROL_|37,this.ROLL_UP_3_ROWS_=this.CONTROL_|38,this.ROLL_UP_4_ROWS_=this.CONTROL_|39,this.CARRIAGE_RETURN_=this.CONTROL_|45,this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41,this.BACKSPACE_=this.CONTROL_|33,this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44,this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46},Pr.prototype.isSpecialCharacter=function(Ne,X){return Ne===this.EXT_&&X>=48&&X<=63},Pr.prototype.isExtCharacter=function(Ne,X){return(Ne===this.EXT_+1||Ne===this.EXT_+2)&&X>=32&&X<=63},Pr.prototype.isMidRowCode=function(Ne,X){return Ne===this.EXT_&&X>=32&&X<=47},Pr.prototype.isOffsetControlCode=function(Ne,X){return Ne===this.OFFSET_&&X>=33&&X<=35},Pr.prototype.isPAC=function(Ne,X){return Ne>=this.BASE_&&Ne<this.BASE_+8&&X>=64&&X<=127},Pr.prototype.isColorPAC=function(Ne){return Ne>=64&&Ne<=79||Ne>=96&&Ne<=127},Pr.prototype.isNormalChar=function(Ne){return Ne>=32&&Ne<=127},Pr.prototype.setRollUp=function(Ne,X){if(this.mode_!=="rollUp"&&(this.row_=qa,this.mode_="rollUp",this.flushDisplayed(Ne),this.nonDisplayed_=wn(),this.displayed_=wn()),X!==void 0&&X!==this.row_)for(var ee=0;ee<this.rollUpRows_;ee++)this.displayed_[X-ee]=this.displayed_[this.row_-ee],this.displayed_[this.row_-ee]="";X===void 0&&(X=this.row_),this.topRow_=X-this.rollUpRows_+1},Pr.prototype.addFormatting=function(Ne,X){this.formatting_=this.formatting_.concat(X);var ee=X.reduce(function(de,fe){return de+"<"+fe+">"},"");this[this.mode_](Ne,ee)},Pr.prototype.clearFormatting=function(Ne){if(!!this.formatting_.length){var X=this.formatting_.reverse().reduce(function(ee,de){return ee+"</"+de+">"},"");this.formatting_=[],this[this.mode_](Ne,X)}},Pr.prototype.popOn=function(Ne,X){var ee=this.nonDisplayed_[this.row_];ee+=X,this.nonDisplayed_[this.row_]=ee},Pr.prototype.rollUp=function(Ne,X){var ee=this.displayed_[this.row_];ee+=X,this.displayed_[this.row_]=ee},Pr.prototype.shiftRowsUp_=function(){var Ne;for(Ne=0;Ne<this.topRow_;Ne++)this.displayed_[Ne]="";for(Ne=this.row_+1;Ne<qa+1;Ne++)this.displayed_[Ne]="";for(Ne=this.topRow_;Ne<this.row_;Ne++)this.displayed_[Ne]=this.displayed_[Ne+1];this.displayed_[this.row_]=""},Pr.prototype.paintOn=function(Ne,X){var ee=this.displayed_[this.row_];ee+=X,this.displayed_[this.row_]=ee};var Xs={CaptionStream:ki,Cea608Stream:Pr},rn={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},Wa=8589934592,cs=4294967296,yn="shared",_i=function(X,ee){var de=1;for(X>ee&&(de=-1);Math.abs(ee-X)>cs;)X+=de*Wa;return X},_a=function Ne(X){var ee,de;Ne.prototype.init.call(this),this.type_=X||yn,this.push=function(fe){this.type_!==yn&&fe.type!==this.type_||(de===void 0&&(de=fe.dts),fe.dts=_i(fe.dts,de),fe.pts=_i(fe.pts,de),ee=fe.dts,this.trigger("data",fe))},this.flush=function(){de=ee,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){de=void 0,ee=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};_a.prototype=new e;var Wr={TimestampRolloverStream:_a,handleRollover:_i},Mn=function(X,ee,de){var fe,Ee="";for(fe=ee;fe<de;fe++)Ee+="%"+("00"+X[fe].toString(16)).slice(-2);return Ee},Ys=function(X,ee,de){return decodeURIComponent(Mn(X,ee,de))},Ka=function(X,ee,de){return unescape(Mn(X,ee,de))},kn=function(X){return X[0]<<21|X[1]<<14|X[2]<<7|X[3]},Ds={TXXX:function(X){var ee;if(X.data[0]===3){for(ee=1;ee<X.data.length;ee++)if(X.data[ee]===0){X.description=Ys(X.data,1,ee),X.value=Ys(X.data,ee+1,X.data.length).replace(/\0*$/,"");break}X.data=X.value}},WXXX:function(X){var ee;if(X.data[0]===3){for(ee=1;ee<X.data.length;ee++)if(X.data[ee]===0){X.description=Ys(X.data,1,ee),X.url=Ys(X.data,ee+1,X.data.length);break}}},PRIV:function(X){var ee;for(ee=0;ee<X.data.length;ee++)if(X.data[ee]===0){X.owner=Ka(X.data,0,ee);break}X.privateData=X.data.subarray(ee+1),X.data=X.privateData}},aa;aa=function(X){var ee={debug:!!(X&&X.debug),descriptor:X&&X.descriptor},de=0,fe=[],Ee=0,Ae;if(aa.prototype.init.call(this),this.dispatchType=rn.METADATA_STREAM_TYPE.toString(16),ee.descriptor)for(Ae=0;Ae<ee.descriptor.length;Ae++)this.dispatchType+=("00"+ee.descriptor[Ae].toString(16)).slice(-2);this.push=function(Ue){var He,it,St,or,Wt,wr;if(Ue.type==="timed-metadata"){if(Ue.dataAlignmentIndicator&&(Ee=0,fe.length=0),fe.length===0&&(Ue.data.length<10||Ue.data[0]!=="I".charCodeAt(0)||Ue.data[1]!=="D".charCodeAt(0)||Ue.data[2]!=="3".charCodeAt(0))){ee.debug&&console.log("Skipping unrecognized metadata packet");return}if(fe.push(Ue),Ee+=Ue.data.byteLength,fe.length===1&&(de=kn(Ue.data.subarray(6,10)),de+=10),!(Ee<de)){for(He={data:new Uint8Array(de),frames:[],pts:fe[0].pts,dts:fe[0].dts},Wt=0;Wt<de;)He.data.set(fe[0].data.subarray(0,de-Wt),Wt),Wt+=fe[0].data.byteLength,Ee-=fe[0].data.byteLength,fe.shift();it=10,He.data[5]&64&&(it+=4,it+=kn(He.data.subarray(10,14)),de-=kn(He.data.subarray(16,20)));do{if(St=kn(He.data.subarray(it+4,it+8)),St<1)return console.log("Malformed ID3 frame encountered. Skipping metadata parsing.");if(wr=String.fromCharCode(He.data[it],He.data[it+1],He.data[it+2],He.data[it+3]),or={id:wr,data:He.data.subarray(it+10,it+St+10)},or.key=or.id,Ds[or.id]&&(Ds[or.id](or),or.owner==="com.apple.streaming.transportStreamTimestamp")){var Vr=or.data,Jr=(Vr[3]&1)<<30|Vr[4]<<22|Vr[5]<<14|Vr[6]<<6|Vr[7]>>>2;Jr*=4,Jr+=Vr[7]&3,or.timeStamp=Jr,He.pts===void 0&&He.dts===void 0&&(He.pts=or.timeStamp,He.dts=or.timeStamp),this.trigger("timestamp",or)}He.frames.push(or),it+=10,it+=St}while(it<de);this.trigger("data",He)}}}},aa.prototype=new e;var za=aa,ds=Wr.TimestampRolloverStream,Fn,Ta,ba,un=188,Qs=71;Fn=function(){var X=new Uint8Array(un),ee=0;Fn.prototype.init.call(this),this.push=function(de){var fe=0,Ee=un,Ae;for(ee?(Ae=new Uint8Array(de.byteLength+ee),Ae.set(X.subarray(0,ee)),Ae.set(de,ee),ee=0):Ae=de;Ee<Ae.byteLength;){if(Ae[fe]===Qs&&Ae[Ee]===Qs){this.trigger("data",Ae.subarray(fe,Ee)),fe+=un,Ee+=un;continue}fe++,Ee++}fe<Ae.byteLength&&(X.set(Ae.subarray(fe),0),ee=Ae.byteLength-fe)},this.flush=function(){ee===un&&X[0]===Qs&&(this.trigger("data",X),ee=0),this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){ee=0,this.trigger("reset")}},Fn.prototype=new e,Ta=function(){var X,ee,de,fe;Ta.prototype.init.call(this),fe=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,X=function(Ae,Ue){var He=0;Ue.payloadUnitStartIndicator&&(He+=Ae[He]+1),Ue.type==="pat"?ee(Ae.subarray(He),Ue):de(Ae.subarray(He),Ue)},ee=function(Ae,Ue){Ue.section_number=Ae[7],Ue.last_section_number=Ae[8],fe.pmtPid=(Ae[10]&31)<<8|Ae[11],Ue.pmtPid=fe.pmtPid},de=function(Ae,Ue){var He,it,St,or;if(!!(Ae[5]&1)){for(fe.programMapTable={video:null,audio:null,"timed-metadata":{}},He=(Ae[1]&15)<<8|Ae[2],it=3+He-4,St=(Ae[10]&15)<<8|Ae[11],or=12+St;or<it;){var Wt=Ae[or],wr=(Ae[or+1]&31)<<8|Ae[or+2];Wt===rn.H264_STREAM_TYPE&&fe.programMapTable.video===null?fe.programMapTable.video=wr:Wt===rn.ADTS_STREAM_TYPE&&fe.programMapTable.audio===null?fe.programMapTable.audio=wr:Wt===rn.METADATA_STREAM_TYPE&&(fe.programMapTable["timed-metadata"][wr]=Wt),or+=((Ae[or+3]&15)<<8|Ae[or+4])+5}Ue.programMapTable=fe.programMapTable}},this.push=function(Ee){var Ae={},Ue=4;if(Ae.payloadUnitStartIndicator=!!(Ee[1]&64),Ae.pid=Ee[1]&31,Ae.pid<<=8,Ae.pid|=Ee[2],(Ee[3]&48)>>>4>1&&(Ue+=Ee[Ue]+1),Ae.pid===0)Ae.type="pat",X(Ee.subarray(Ue),Ae),this.trigger("data",Ae);else if(Ae.pid===this.pmtPid)for(Ae.type="pmt",X(Ee.subarray(Ue),Ae),this.trigger("data",Ae);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([Ee,Ue,Ae]):this.processPes_(Ee,Ue,Ae)},this.processPes_=function(Ee,Ae,Ue){Ue.pid===this.programMapTable.video?Ue.streamType=rn.H264_STREAM_TYPE:Ue.pid===this.programMapTable.audio?Ue.streamType=rn.ADTS_STREAM_TYPE:Ue.streamType=this.programMapTable["timed-metadata"][Ue.pid],Ue.type="pes",Ue.data=Ee.subarray(Ae),this.trigger("data",Ue)}},Ta.prototype=new e,Ta.STREAM_TYPES={h264:27,adts:15},ba=function(){var X=this,ee={data:[],size:0},de={data:[],size:0},fe={data:[],size:0},Ee,Ae=function(it,St){var or;St.packetLength=6+(it[4]<<8|it[5]),St.dataAlignmentIndicator=(it[6]&4)!==0,or=it[7],or&192&&(St.pts=(it[9]&14)<<27|(it[10]&255)<<20|(it[11]&254)<<12|(it[12]&255)<<5|(it[13]&254)>>>3,St.pts*=4,St.pts+=(it[13]&6)>>>1,St.dts=St.pts,or&64&&(St.dts=(it[14]&14)<<27|(it[15]&255)<<20|(it[16]&254)<<12|(it[17]&255)<<5|(it[18]&254)>>>3,St.dts*=4,St.dts+=(it[18]&6)>>>1)),St.data=it.subarray(9+it[8])},Ue=function(it,St,or){var Wt=new Uint8Array(it.size),wr={type:St},Vr=0,Jr=0,Kt=!1,zi;if(!(!it.data.length||it.size<9)){for(wr.trackId=it.data[0].pid,Vr=0;Vr<it.data.length;Vr++)zi=it.data[Vr],Wt.set(zi.data,Jr),Jr+=zi.data.byteLength;Ae(Wt,wr),Kt=St==="video"||wr.packetLength<=it.size,(or||Kt)&&(it.size=0,it.data.length=0),Kt&&X.trigger("data",wr)}};ba.prototype.init.call(this),this.push=function(He){({pat:function(){},pes:function(){var St,or;switch(He.streamType){case rn.H264_STREAM_TYPE:case rn.H264_STREAM_TYPE:St=ee,or="video";break;case rn.ADTS_STREAM_TYPE:St=de,or="audio";break;case rn.METADATA_STREAM_TYPE:St=fe,or="timed-metadata";break;default:return}He.payloadUnitStartIndicator&&Ue(St,or,!0),St.data.push(He),St.size+=He.data.byteLength},pmt:function(){var St={type:"metadata",tracks:[]};Ee=He.programMapTable,Ee.video!==null&&St.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+Ee.video,codec:"avc",type:"video"}),Ee.audio!==null&&St.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+Ee.audio,codec:"adts",type:"audio"}),X.trigger("data",St)}})[He.type]()},this.reset=function(){ee.size=0,ee.data.length=0,de.size=0,de.data.length=0,this.trigger("reset")},this.flushStreams_=function(){Ue(ee,"video"),Ue(de,"audio"),Ue(fe,"timed-metadata")},this.flush=function(){this.flushStreams_(),this.trigger("done")}},ba.prototype=new e;var fs={PAT_PID:0,MP2T_PACKET_LENGTH:un,TransportPacketStream:Fn,TransportParseStream:Ta,ElementaryStream:ba,TimestampRolloverStream:ds,CaptionStream:Xs.CaptionStream,Cea608Stream:Xs.Cea608Stream,MetadataStream:za};for(var Dn in rn)rn.hasOwnProperty(Dn)&&(fs[Dn]=rn[Dn]);var _n=fs,Ps=Er.ONE_SECOND_IN_TS,me,Fe=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];me=function(X){var ee,de=0;me.prototype.init.call(this),this.push=function(fe){var Ee=0,Ae,Ue,He,it,St,or;if(X||(de=0),fe.type==="audio")for(ee?(it=ee,ee=new Uint8Array(it.byteLength+fe.data.byteLength),ee.set(it),ee.set(fe.data,it.byteLength)):ee=fe.data;Ee+5<ee.length;){if(ee[Ee]!==255||(ee[Ee+1]&246)!==240){Ee++;continue}if(Ue=(~ee[Ee+1]&1)*2,Ae=(ee[Ee+3]&3)<<11|ee[Ee+4]<<3|(ee[Ee+5]&224)>>5,St=((ee[Ee+6]&3)+1)*1024,or=St*Ps/Fe[(ee[Ee+2]&60)>>>2],He=Ee+Ae,ee.byteLength<He)return;if(this.trigger("data",{pts:fe.pts+de*or,dts:fe.dts+de*or,sampleCount:St,audioobjecttype:(ee[Ee+2]>>>6&3)+1,channelcount:(ee[Ee+2]&1)<<2|(ee[Ee+3]&192)>>>6,samplerate:Fe[(ee[Ee+2]&60)>>>2],samplingfrequencyindex:(ee[Ee+2]&60)>>>2,samplesize:16,data:ee.subarray(Ee+7+Ue,He)}),de++,ee.byteLength===He){ee=void 0;return}ee=ee.subarray(He)}},this.flush=function(){de=0,this.trigger("done")},this.reset=function(){ee=void 0,this.trigger("reset")},this.endTimeline=function(){ee=void 0,this.trigger("endedtimeline")}},me.prototype=new e;var xe=me,ze;ze=function(X){var ee=X.byteLength,de=0,fe=0;this.length=function(){return 8*ee},this.bitsAvailable=function(){return 8*ee+fe},this.loadWord=function(){var Ee=X.byteLength-ee,Ae=new Uint8Array(4),Ue=Math.min(4,ee);if(Ue===0)throw new Error("no bytes available");Ae.set(X.subarray(Ee,Ee+Ue)),de=new DataView(Ae.buffer).getUint32(0),fe=Ue*8,ee-=Ue},this.skipBits=function(Ee){var Ae;fe>Ee?(de<<=Ee,fe-=Ee):(Ee-=fe,Ae=Math.floor(Ee/8),Ee-=Ae*8,ee-=Ae,this.loadWord(),de<<=Ee,fe-=Ee)},this.readBits=function(Ee){var Ae=Math.min(fe,Ee),Ue=de>>>32-Ae;return fe-=Ae,fe>0?de<<=Ae:ee>0&&this.loadWord(),Ae=Ee-Ae,Ae>0?Ue<<Ae|this.readBits(Ae):Ue},this.skipLeadingZeros=function(){var Ee;for(Ee=0;Ee<fe;++Ee)if((de&2147483648>>>Ee)!==0)return de<<=Ee,fe-=Ee,Ee;return this.loadWord(),Ee+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var Ee=this.skipLeadingZeros();return this.readBits(Ee+1)-1},this.readExpGolomb=function(){var Ee=this.readUnsignedExpGolomb();return 1&Ee?1+Ee>>>1:-1*(Ee>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};var et=ze,Ke,pt,Ot;pt=function(){var X=0,ee,de;pt.prototype.init.call(this),this.push=function(fe){var Ee;de?(Ee=new Uint8Array(de.byteLength+fe.data.byteLength),Ee.set(de),Ee.set(fe.data,de.byteLength),de=Ee):de=fe.data;for(var Ae=de.byteLength;X<Ae-3;X++)if(de[X+2]===1){ee=X+5;break}for(;ee<Ae;)switch(de[ee]){case 0:if(de[ee-1]!==0){ee+=2;break}else if(de[ee-2]!==0){ee++;break}X+3!==ee-2&&this.trigger("data",de.subarray(X+3,ee-2));do ee++;while(de[ee]!==1&&ee<Ae);X=ee-2,ee+=3;break;case 1:if(de[ee-1]!==0||de[ee-2]!==0){ee+=3;break}this.trigger("data",de.subarray(X+3,ee-2)),X=ee-2,ee+=3;break;default:ee+=3;break}de=de.subarray(X),ee-=X,X=0},this.reset=function(){de=null,X=0,this.trigger("reset")},this.flush=function(){de&&de.byteLength>3&&this.trigger("data",de.subarray(X+3)),de=null,X=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}},pt.prototype=new e,Ot={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},Ke=function(){var X=new pt,ee,de,fe,Ee,Ae,Ue,He;Ke.prototype.init.call(this),ee=this,this.push=function(it){it.type==="video"&&(de=it.trackId,fe=it.pts,Ee=it.dts,X.push(it))},X.on("data",function(it){var St={trackId:de,pts:fe,dts:Ee,data:it};switch(it[0]&31){case 5:St.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:St.nalUnitType="sei_rbsp",St.escapedRBSP=Ae(it.subarray(1));break;case 7:St.nalUnitType="seq_parameter_set_rbsp",St.escapedRBSP=Ae(it.subarray(1)),St.config=Ue(St.escapedRBSP);break;case 8:St.nalUnitType="pic_parameter_set_rbsp";break;case 9:St.nalUnitType="access_unit_delimiter_rbsp";break}ee.trigger("data",St)}),X.on("done",function(){ee.trigger("done")}),X.on("partialdone",function(){ee.trigger("partialdone")}),X.on("reset",function(){ee.trigger("reset")}),X.on("endedtimeline",function(){ee.trigger("endedtimeline")}),this.flush=function(){X.flush()},this.partialFlush=function(){X.partialFlush()},this.reset=function(){X.reset()},this.endTimeline=function(){X.endTimeline()},He=function(St,or){var Wt=8,wr=8,Vr,Jr;for(Vr=0;Vr<St;Vr++)wr!==0&&(Jr=or.readExpGolomb(),wr=(Wt+Jr+256)%256),Wt=wr===0?Wt:wr},Ae=function(St){for(var or=St.byteLength,Wt=[],wr=1,Vr,Jr;wr<or-2;)St[wr]===0&&St[wr+1]===0&&St[wr+2]===3?(Wt.push(wr+2),wr+=2):wr++;if(Wt.length===0)return St;Vr=or-Wt.length,Jr=new Uint8Array(Vr);var Kt=0;for(wr=0;wr<Vr;Kt++,wr++)Kt===Wt[0]&&(Kt++,Wt.shift()),Jr[wr]=St[Kt];return Jr},Ue=function(St){var or=0,Wt=0,wr=0,Vr=0,Jr=1,Kt,zi,Qn,eo,xa,Ko,zo,gs,Os,vs,Tn,$i,Du,Ls;if(Kt=new et(St),zi=Kt.readUnsignedByte(),eo=Kt.readUnsignedByte(),Qn=Kt.readUnsignedByte(),Kt.skipUnsignedExpGolomb(),Ot[zi]&&(xa=Kt.readUnsignedExpGolomb(),xa===3&&Kt.skipBits(1),Kt.skipUnsignedExpGolomb(),Kt.skipUnsignedExpGolomb(),Kt.skipBits(1),Kt.readBoolean()))for(Tn=xa!==3?8:12,Ls=0;Ls<Tn;Ls++)Kt.readBoolean()&&(Ls<6?He(16,Kt):He(64,Kt));if(Kt.skipUnsignedExpGolomb(),Ko=Kt.readUnsignedExpGolomb(),Ko===0)Kt.readUnsignedExpGolomb();else if(Ko===1)for(Kt.skipBits(1),Kt.skipExpGolomb(),Kt.skipExpGolomb(),zo=Kt.readUnsignedExpGolomb(),Ls=0;Ls<zo;Ls++)Kt.skipExpGolomb();if(Kt.skipUnsignedExpGolomb(),Kt.skipBits(1),gs=Kt.readUnsignedExpGolomb(),Os=Kt.readUnsignedExpGolomb(),vs=Kt.readBits(1),vs===0&&Kt.skipBits(1),Kt.skipBits(1),Kt.readBoolean()&&(or=Kt.readUnsignedExpGolomb(),Wt=Kt.readUnsignedExpGolomb(),wr=Kt.readUnsignedExpGolomb(),Vr=Kt.readUnsignedExpGolomb()),Kt.readBoolean()&&Kt.readBoolean()){switch(Du=Kt.readUnsignedByte(),Du){case 1:$i=[1,1];break;case 2:$i=[12,11];break;case 3:$i=[10,11];break;case 4:$i=[16,11];break;case 5:$i=[40,33];break;case 6:$i=[24,11];break;case 7:$i=[20,11];break;case 8:$i=[32,11];break;case 9:$i=[80,33];break;case 10:$i=[18,11];break;case 11:$i=[15,11];break;case 12:$i=[64,33];break;case 13:$i=[160,99];break;case 14:$i=[4,3];break;case 15:$i=[3,2];break;case 16:$i=[2,1];break;case 255:{$i=[Kt.readUnsignedByte()<<8|Kt.readUnsignedByte(),Kt.readUnsignedByte()<<8|Kt.readUnsignedByte()];break}}$i&&(Jr=$i[0]/$i[1])}return{profileIdc:zi,levelIdc:Qn,profileCompatibility:eo,width:Math.ceil(((gs+1)*16-or*2-Wt*2)*Jr),height:(2-vs)*(Os+1)*16-wr*2-Vr*2,sarRatio:$i}}},Ke.prototype=new e;var Rt={H264Stream:Ke,NalByteStream:pt},jt=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],Xt=function(X){return X[0]==="I".charCodeAt(0)&&X[1]==="D".charCodeAt(0)&&X[2]==="3".charCodeAt(0)},gr=function(X){return X[0]<<21|X[1]<<14|X[2]<<7|X[3]},Br=function(X,ee,de){var fe,Ee="";for(fe=ee;fe<de;fe++)Ee+="%"+("00"+X[fe].toString(16)).slice(-2);return Ee},ii=function(X,ee,de){return unescape(Br(X,ee,de))},ci=function(X,ee){var de=X[ee+6]<<21|X[ee+7]<<14|X[ee+8]<<7|X[ee+9],fe=X[ee+5],Ee=(fe&16)>>4;return Ee?de+20:de+10},ji=function(X,ee){var de=(X[ee+5]&224)>>5,fe=X[ee+4]<<3,Ee=X[ee+3]&3<<11;return Ee|fe|de},jr=function(X,ee){return X[ee]==="I".charCodeAt(0)&&X[ee+1]==="D".charCodeAt(0)&&X[ee+2]==="3".charCodeAt(0)?"timed-metadata":X[ee]&!0&&(X[ee+1]&240)===240?"audio":null},cn=function(X){for(var ee=0;ee+5<X.length;){if(X[ee]!==255||(X[ee+1]&246)!==240){ee++;continue}return jt[(X[ee+2]&60)>>>2]}return null},Sa=function(X){var ee,de,fe,Ee;ee=10,X[5]&64&&(ee+=4,ee+=gr(X.subarray(10,14)));do{if(de=gr(X.subarray(ee+4,ee+8)),de<1)return null;if(Ee=String.fromCharCode(X[ee],X[ee+1],X[ee+2],X[ee+3]),Ee==="PRIV"){fe=X.subarray(ee+10,ee+de+10);for(var Ae=0;Ae<fe.byteLength;Ae++)if(fe[Ae]===0){var Ue=ii(fe,0,Ae);if(Ue==="com.apple.streaming.transportStreamTimestamp"){var He=fe.subarray(Ae+1),it=(He[3]&1)<<30|He[4]<<22|He[5]<<14|He[6]<<6|He[7]>>>2;return it*=4,it+=He[7]&3,it}break}}ee+=10,ee+=de}while(ee<X.byteLength);return null},Xa={isLikelyAacData:Xt,parseId3TagSize:ci,parseAdtsSize:ji,parseType:jr,parseSampleRate:cn,parseAacTimestamp:Sa},Nn;Nn=function(){var X=new Uint8Array,ee=0;Nn.prototype.init.call(this),this.setTimestamp=function(de){ee=de},this.push=function(de){var fe=0,Ee=0,Ae,Ue,He,it;for(X.length?(it=X.length,X=new Uint8Array(de.byteLength+it),X.set(X.subarray(0,it)),X.set(de,it)):X=de;X.length-Ee>=3;){if(X[Ee]==="I".charCodeAt(0)&&X[Ee+1]==="D".charCodeAt(0)&&X[Ee+2]==="3".charCodeAt(0)){if(X.length-Ee<10||(fe=Xa.parseId3TagSize(X,Ee),Ee+fe>X.length))break;Ue={type:"timed-metadata",data:X.subarray(Ee,Ee+fe)},this.trigger("data",Ue),Ee+=fe;continue}else if((X[Ee]&255)===255&&(X[Ee+1]&240)===240){if(X.length-Ee<7||(fe=Xa.parseAdtsSize(X,Ee),Ee+fe>X.length))break;He={type:"audio",data:X.subarray(Ee,Ee+fe),pts:ee,dts:ee},this.trigger("data",He),Ee+=fe;continue}Ee++}Ae=X.length-Ee,Ae>0?X=X.subarray(Ee):X=new Uint8Array},this.reset=function(){X=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){X=new Uint8Array,this.trigger("endedtimeline")}},Nn.prototype=new e;var hs=Nn,Go=Rt.H264Stream,sa=Xa.isLikelyAacData,Ea=Er.ONE_SECOND_IN_TS,Ya=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],ps=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],Qa,Ja,bo,oa,ll=function(X,ee){var de;if(X.length!==ee.length)return!1;for(de=0;de<X.length;de++)if(X[de]!==ee[de])return!1;return!0},Yn=function(X,ee,de,fe,Ee,Ae){var Ue=de-ee,He=fe-ee,it=Ee-de;return{start:{dts:X,pts:X+Ue},end:{dts:X+He,pts:X+it},prependedContentDuration:Ae,baseMediaDecodeTime:X}};Ja=function(X,ee){var de=[],fe=0,Ee=0,Ae=0,Ue=1/0;ee=ee||{},Ja.prototype.init.call(this),this.push=function(He){li.collectDtsInfo(X,He),X&&Ya.forEach(function(it){X[it]=He[it]}),de.push(He)},this.setEarliestDts=function(He){Ee=He-X.timelineStartInfo.baseMediaDecodeTime},this.setVideoBaseMediaDecodeTime=function(He){Ue=He},this.setAudioAppendStart=function(He){Ae=He},this.flush=function(){var He,it,St,or,Wt;if(de.length===0){this.trigger("done","AudioSegmentStream");return}He=Cn.trimAdtsFramesByEarliestDts(de,X,Ee),X.baseMediaDecodeTime=li.calculateTrackBaseMediaDecodeTime(X,ee.keepOriginalTimestamps),Cn.prefixWithSilence(X,He,Ae,Ue),X.samples=Cn.generateSampleTable(He),St=$e.mdat(Cn.concatenateFrameData(He)),de=[],it=$e.moof(fe,[X]),or=new Uint8Array(it.byteLength+St.byteLength),fe++,or.set(it),or.set(St,it.byteLength),li.clearDtsInfo(X),Wt=Math.ceil(Ea*1024/X.samplerate),He.length&&this.trigger("timingInfo",{start:He[0].dts,end:He[0].dts+He.length*Wt}),this.trigger("data",{track:X,boxes:or}),this.trigger("done","AudioSegmentStream")},this.reset=function(){li.clearDtsInfo(X),de=[],this.trigger("reset")}},Ja.prototype=new e,Qa=function(X,ee){var de=0,fe=[],Ee=[],Ae,Ue;ee=ee||{},Qa.prototype.init.call(this),delete X.minPTS,this.gopCache_=[],this.push=function(He){li.collectDtsInfo(X,He),He.nalUnitType==="seq_parameter_set_rbsp"&&!Ae&&(Ae=He.config,X.sps=[He.data],ps.forEach(function(it){X[it]=Ae[it]},this)),He.nalUnitType==="pic_parameter_set_rbsp"&&!Ue&&(Ue=He.data,X.pps=[He.data]),fe.push(He)},this.flush=function(){for(var He,it,St,or,Wt,wr,Vr=0,Jr,Kt;fe.length&&fe[0].nalUnitType!=="access_unit_delimiter_rbsp";)fe.shift();if(fe.length===0){this.resetStream_(),this.trigger("done","VideoSegmentStream");return}if(He=Nt.groupNalsIntoFrames(fe),St=Nt.groupFramesIntoGops(He),St[0][0].keyFrame||(it=this.getGopForFusion_(fe[0],X),it?(Vr=it.duration,St.unshift(it),St.byteLength+=it.byteLength,St.nalCount+=it.nalCount,St.pts=it.pts,St.dts=it.dts,St.duration+=it.duration):St=Nt.extendFirstKeyFrame(St)),Ee.length){var zi;if(ee.alignGopsAtEnd?zi=this.alignGopsAtEnd_(St):zi=this.alignGopsAtStart_(St),!zi){this.gopCache_.unshift({gop:St.pop(),pps:X.pps,sps:X.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),fe=[],this.resetStream_(),this.trigger("done","VideoSegmentStream");return}li.clearDtsInfo(X),St=zi}li.collectDtsInfo(X,St),X.samples=Nt.generateSampleTable(St),Wt=$e.mdat(Nt.concatenateNalData(St)),X.baseMediaDecodeTime=li.calculateTrackBaseMediaDecodeTime(X,ee.keepOriginalTimestamps),this.trigger("processedGopsInfo",St.map(function(Qn){return{pts:Qn.pts,dts:Qn.dts,byteLength:Qn.byteLength}})),Jr=St[0],Kt=St[St.length-1],this.trigger("segmentTimingInfo",Yn(X.baseMediaDecodeTime,Jr.dts,Jr.pts,Kt.dts+Kt.duration,Kt.pts+Kt.duration,Vr)),this.trigger("timingInfo",{start:St[0].dts,end:St[St.length-1].dts+St[St.length-1].duration}),this.gopCache_.unshift({gop:St.pop(),pps:X.pps,sps:X.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),fe=[],this.trigger("baseMediaDecodeTime",X.baseMediaDecodeTime),this.trigger("timelineStartInfo",X.timelineStartInfo),or=$e.moof(de,[X]),wr=new Uint8Array(or.byteLength+Wt.byteLength),de++,wr.set(or),wr.set(Wt,or.byteLength),this.trigger("data",{track:X,boxes:wr}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),fe=[],this.gopCache_.length=0,Ee.length=0,this.trigger("reset")},this.resetStream_=function(){li.clearDtsInfo(X),Ae=void 0,Ue=void 0},this.getGopForFusion_=function(He){var it=45e3,St=1e4,or=1/0,Wt,wr,Vr,Jr,Kt;for(Kt=0;Kt<this.gopCache_.length;Kt++)Jr=this.gopCache_[Kt],Vr=Jr.gop,!(!(X.pps&&ll(X.pps[0],Jr.pps[0]))||!(X.sps&&ll(X.sps[0],Jr.sps[0])))&&(Vr.dts<X.timelineStartInfo.dts||(Wt=He.dts-Vr.dts-Vr.duration,Wt>=-St&&Wt<=it&&(!wr||or>Wt)&&(wr=Jr,or=Wt)));return wr?wr.gop:null},this.alignGopsAtStart_=function(He){var it,St,or,Wt,wr,Vr,Jr,Kt;for(wr=He.byteLength,Vr=He.nalCount,Jr=He.duration,it=St=0;it<Ee.length&&St<He.length&&(or=Ee[it],Wt=He[St],or.pts!==Wt.pts);){if(Wt.pts>or.pts){it++;continue}St++,wr-=Wt.byteLength,Vr-=Wt.nalCount,Jr-=Wt.duration}return St===0?He:St===He.length?null:(Kt=He.slice(St),Kt.byteLength=wr,Kt.duration=Jr,Kt.nalCount=Vr,Kt.pts=Kt[0].pts,Kt.dts=Kt[0].dts,Kt)},this.alignGopsAtEnd_=function(He){var it,St,or,Wt,wr,Vr;for(it=Ee.length-1,St=He.length-1,wr=null,Vr=!1;it>=0&&St>=0;){if(or=Ee[it],Wt=He[St],or.pts===Wt.pts){Vr=!0;break}if(or.pts>Wt.pts){it--;continue}it===Ee.length-1&&(wr=St),St--}if(!Vr&&wr===null)return null;var Jr;if(Vr?Jr=St:Jr=wr,Jr===0)return He;var Kt=He.slice(Jr),zi=Kt.reduce(function(Qn,eo){return Qn.byteLength+=eo.byteLength,Qn.duration+=eo.duration,Qn.nalCount+=eo.nalCount,Qn},{byteLength:0,duration:0,nalCount:0});return Kt.byteLength=zi.byteLength,Kt.duration=zi.duration,Kt.nalCount=zi.nalCount,Kt.pts=Kt[0].pts,Kt.dts=Kt[0].dts,Kt},this.alignGopsWith=function(He){Ee=He}},Qa.prototype=new e,oa=function(X,ee){this.numberOfTracks=0,this.metadataStream=ee,X=X||{},typeof X.remux<"u"?this.remuxTracks=!!X.remux:this.remuxTracks=!0,typeof X.keepOriginalTimestamps=="boolean"?this.keepOriginalTimestamps=X.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,oa.prototype.init.call(this),this.push=function(de){if(de.text)return this.pendingCaptions.push(de);if(de.frames)return this.pendingMetadata.push(de);this.pendingTracks.push(de.track),this.pendingBytes+=de.boxes.byteLength,de.track.type==="video"&&(this.videoTrack=de.track,this.pendingBoxes.push(de.boxes)),de.track.type==="audio"&&(this.audioTrack=de.track,this.pendingBoxes.unshift(de.boxes))}},oa.prototype=new e,oa.prototype.flush=function(Ne){var X=0,ee={captions:[],captionStreams:{},metadata:[],info:{}},de,fe,Ee,Ae=0,Ue;if(this.pendingTracks.length<this.numberOfTracks){if(Ne!=="VideoSegmentStream"&&Ne!=="AudioSegmentStream")return;if(this.remuxTracks)return;if(this.pendingTracks.length===0){this.emittedTracks++,this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0);return}}if(this.videoTrack?(Ae=this.videoTrack.timelineStartInfo.pts,ps.forEach(function(He){ee.info[He]=this.videoTrack[He]},this)):this.audioTrack&&(Ae=this.audioTrack.timelineStartInfo.pts,Ya.forEach(function(He){ee.info[He]=this.audioTrack[He]},this)),this.videoTrack||this.audioTrack){for(this.pendingTracks.length===1?ee.type=this.pendingTracks[0].type:ee.type="combined",this.emittedTracks+=this.pendingTracks.length,Ee=$e.initSegment(this.pendingTracks),ee.initSegment=new Uint8Array(Ee.byteLength),ee.initSegment.set(Ee),ee.data=new Uint8Array(this.pendingBytes),Ue=0;Ue<this.pendingBoxes.length;Ue++)ee.data.set(this.pendingBoxes[Ue],X),X+=this.pendingBoxes[Ue].byteLength;for(Ue=0;Ue<this.pendingCaptions.length;Ue++)de=this.pendingCaptions[Ue],de.startTime=Er.metadataTsToSeconds(de.startPts,Ae,this.keepOriginalTimestamps),de.endTime=Er.metadataTsToSeconds(de.endPts,Ae,this.keepOriginalTimestamps),ee.captionStreams[de.stream]=!0,ee.captions.push(de);for(Ue=0;Ue<this.pendingMetadata.length;Ue++)fe=this.pendingMetadata[Ue],fe.cueTime=Er.metadataTsToSeconds(fe.pts,Ae,this.keepOriginalTimestamps),ee.metadata.push(fe);for(ee.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger("data",ee),Ue=0;Ue<ee.captions.length;Ue++)de=ee.captions[Ue],this.trigger("caption",de);for(Ue=0;Ue<ee.metadata.length;Ue++)fe=ee.metadata[Ue],this.trigger("id3Frame",fe)}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},oa.prototype.setRemux=function(Ne){this.remuxTracks=Ne},bo=function(X){var ee=this,de=!0,fe,Ee;bo.prototype.init.call(this),X=X||{},this.baseMediaDecodeTime=X.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var Ae={};this.transmuxPipeline_=Ae,Ae.type="aac",Ae.metadataStream=new _n.MetadataStream,Ae.aacStream=new hs,Ae.audioTimestampRolloverStream=new _n.TimestampRolloverStream("audio"),Ae.timedMetadataTimestampRolloverStream=new _n.TimestampRolloverStream("timed-metadata"),Ae.adtsStream=new xe,Ae.coalesceStream=new oa(X,Ae.metadataStream),Ae.headOfPipeline=Ae.aacStream,Ae.aacStream.pipe(Ae.audioTimestampRolloverStream).pipe(Ae.adtsStream),Ae.aacStream.pipe(Ae.timedMetadataTimestampRolloverStream).pipe(Ae.metadataStream).pipe(Ae.coalesceStream),Ae.metadataStream.on("timestamp",function(Ue){Ae.aacStream.setTimestamp(Ue.timeStamp)}),Ae.aacStream.on("data",function(Ue){Ue.type==="timed-metadata"&&!Ae.audioSegmentStream&&(Ee=Ee||{timelineStartInfo:{baseMediaDecodeTime:ee.baseMediaDecodeTime},codec:"adts",type:"audio"},Ae.coalesceStream.numberOfTracks++,Ae.audioSegmentStream=new Ja(Ee,X),Ae.audioSegmentStream.on("timingInfo",ee.trigger.bind(ee,"audioTimingInfo")),Ae.adtsStream.pipe(Ae.audioSegmentStream).pipe(Ae.coalesceStream)),ee.trigger("trackinfo",{hasAudio:!!Ee,hasVideo:!!fe})}),Ae.coalesceStream.on("data",this.trigger.bind(this,"data")),Ae.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setupTsPipeline=function(){var Ae={};this.transmuxPipeline_=Ae,Ae.type="ts",Ae.metadataStream=new _n.MetadataStream,Ae.packetStream=new _n.TransportPacketStream,Ae.parseStream=new _n.TransportParseStream,Ae.elementaryStream=new _n.ElementaryStream,Ae.timestampRolloverStream=new _n.TimestampRolloverStream,Ae.adtsStream=new xe,Ae.h264Stream=new Go,Ae.captionStream=new _n.CaptionStream,Ae.coalesceStream=new oa(X,Ae.metadataStream),Ae.headOfPipeline=Ae.packetStream,Ae.packetStream.pipe(Ae.parseStream).pipe(Ae.elementaryStream).pipe(Ae.timestampRolloverStream),Ae.timestampRolloverStream.pipe(Ae.h264Stream),Ae.timestampRolloverStream.pipe(Ae.adtsStream),Ae.timestampRolloverStream.pipe(Ae.metadataStream).pipe(Ae.coalesceStream),Ae.h264Stream.pipe(Ae.captionStream).pipe(Ae.coalesceStream),Ae.elementaryStream.on("data",function(Ue){var He;if(Ue.type==="metadata"){for(He=Ue.tracks.length;He--;)!fe&&Ue.tracks[He].type==="video"?(fe=Ue.tracks[He],fe.timelineStartInfo.baseMediaDecodeTime=ee.baseMediaDecodeTime):!Ee&&Ue.tracks[He].type==="audio"&&(Ee=Ue.tracks[He],Ee.timelineStartInfo.baseMediaDecodeTime=ee.baseMediaDecodeTime);fe&&!Ae.videoSegmentStream&&(Ae.coalesceStream.numberOfTracks++,Ae.videoSegmentStream=new Qa(fe,X),Ae.videoSegmentStream.on("timelineStartInfo",function(it){Ee&&(Ee.timelineStartInfo=it,Ae.audioSegmentStream.setEarliestDts(it.dts))}),Ae.videoSegmentStream.on("processedGopsInfo",ee.trigger.bind(ee,"gopInfo")),Ae.videoSegmentStream.on("segmentTimingInfo",ee.trigger.bind(ee,"videoSegmentTimingInfo")),Ae.videoSegmentStream.on("baseMediaDecodeTime",function(it){Ee&&Ae.audioSegmentStream.setVideoBaseMediaDecodeTime(it)}),Ae.videoSegmentStream.on("timingInfo",ee.trigger.bind(ee,"videoTimingInfo")),Ae.h264Stream.pipe(Ae.videoSegmentStream).pipe(Ae.coalesceStream)),Ee&&!Ae.audioSegmentStream&&(Ae.coalesceStream.numberOfTracks++,Ae.audioSegmentStream=new Ja(Ee,X),Ae.audioSegmentStream.on("timingInfo",ee.trigger.bind(ee,"audioTimingInfo")),Ae.adtsStream.pipe(Ae.audioSegmentStream).pipe(Ae.coalesceStream)),ee.trigger("trackinfo",{hasAudio:!!Ee,hasVideo:!!fe})}}),Ae.coalesceStream.on("data",this.trigger.bind(this,"data")),Ae.coalesceStream.on("id3Frame",function(Ue){Ue.dispatchType=Ae.metadataStream.dispatchType,ee.trigger("id3Frame",Ue)}),Ae.coalesceStream.on("caption",this.trigger.bind(this,"caption")),Ae.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setBaseMediaDecodeTime=function(Ae){var Ue=this.transmuxPipeline_;X.keepOriginalTimestamps||(this.baseMediaDecodeTime=Ae),Ee&&(Ee.timelineStartInfo.dts=void 0,Ee.timelineStartInfo.pts=void 0,li.clearDtsInfo(Ee),X.keepOriginalTimestamps||(Ee.timelineStartInfo.baseMediaDecodeTime=Ae),Ue.audioTimestampRolloverStream&&Ue.audioTimestampRolloverStream.discontinuity()),fe&&(Ue.videoSegmentStream&&(Ue.videoSegmentStream.gopCache_=[]),fe.timelineStartInfo.dts=void 0,fe.timelineStartInfo.pts=void 0,li.clearDtsInfo(fe),Ue.captionStream.reset(),X.keepOriginalTimestamps||(fe.timelineStartInfo.baseMediaDecodeTime=Ae)),Ue.timestampRolloverStream&&Ue.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(Ae){Ee&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(Ae)},this.setRemux=function(Ae){var Ue=this.transmuxPipeline_;X.remux=Ae,Ue&&Ue.coalesceStream&&Ue.coalesceStream.setRemux(Ae)},this.alignGopsWith=function(Ae){fe&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(Ae)},this.push=function(Ae){if(de){var Ue=sa(Ae);Ue&&this.transmuxPipeline_.type!=="aac"?this.setupAacPipeline():!Ue&&this.transmuxPipeline_.type!=="ts"&&this.setupTsPipeline(),de=!1}this.transmuxPipeline_.headOfPipeline.push(Ae)},this.flush=function(){de=!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()}},bo.prototype=new e;var Js={Transmuxer:bo,VideoSegmentStream:Qa,AudioSegmentStream:Ja,AUDIO_PROPERTIES:Ya,VIDEO_PROPERTIES:ps,generateVideoSegmentTimingInfo:Yn},ku=function(X,ee){if(!(X instanceof ee))throw new TypeError("Cannot call a class as a function")},qo=function(){function Ne(X,ee){for(var de=0;de<ee.length;de++){var fe=ee[de];fe.enumerable=fe.enumerable||!1,fe.configurable=!0,"value"in fe&&(fe.writable=!0),Object.defineProperty(X,fe.key,fe)}}return function(X,ee,de){return ee&&Ne(X.prototype,ee),de&&Ne(X,de),X}}(),Zs=function(X,ee){ee.on("data",function(de){var fe=de.initSegment;de.initSegment={data:fe.buffer,byteOffset:fe.byteOffset,byteLength:fe.byteLength};var Ee=de.data;de.data=Ee.buffer,X.postMessage({action:"data",segment:de,byteOffset:Ee.byteOffset,byteLength:Ee.byteLength},[de.data])}),ee.captionStream&&ee.captionStream.on("data",function(de){X.postMessage({action:"caption",data:de})}),ee.on("done",function(de){X.postMessage({action:"done"})}),ee.on("gopInfo",function(de){X.postMessage({action:"gopInfo",gopInfo:de})}),ee.on("videoSegmentTimingInfo",function(de){X.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:de})})},Rs=function(){function Ne(X,ee){ku(this,Ne),this.options=ee||{},this.self=X,this.init()}return qo(Ne,[{key:"init",value:function(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new Js.Transmuxer(this.options),Zs(this.self,this.transmuxer)}},{key:"push",value:function(ee){var de=new Uint8Array(ee.data,ee.byteOffset,ee.byteLength);this.transmuxer.push(de)}},{key:"reset",value:function(){this.init()}},{key:"setTimestampOffset",value:function(ee){var de=ee.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(de*9e4))}},{key:"setAudioAppendStart",value:function(ee){this.transmuxer.setAudioAppendStart(Math.ceil(ee.appendStart*9e4))}},{key:"flush",value:function(ee){this.transmuxer.flush()}},{key:"resetCaptions",value:function(){this.transmuxer.resetCaptions()}},{key:"alignGopsWith",value:function(ee){this.transmuxer.alignGopsWith(ee.gopsToAlignWith.slice())}}]),Ne}(),Wo=function(X){X.onmessage=function(ee){if(ee.data.action==="init"&&ee.data.options){this.messageHandlers=new Rs(X,ee.data.options);return}this.messageHandlers||(this.messageHandlers=new Rs(X)),ee.data&&ee.data.action&&ee.data.action!=="init"&&this.messageHandlers[ee.data.action]&&this.messageHandlers[ee.data.action](ee.data)}},Is=new Wo(i);return Is})()}),Px={videoCodec:"avc1",videoObjectTypeIndicator:".4d400d",audioProfile:"2"},Rx=function(r){return r.map(function(i){return i.replace(/avc1\.(\d+)\.(\d+)/i,function(t,e,a){var s=("00"+Number(e).toString(16)).slice(-2),o=("00"+Number(a).toString(16)).slice(-2);return"avc1."+s+"00"+o})})},yf=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",i={codecCount:0},t=void 0;return i.codecCount=r.split(",").length,i.codecCount=i.codecCount||2,t=/(^|\s|,)+(avc[13])([^ ,]*)/i.exec(r),t&&(i.videoCodec=t[2],i.videoObjectTypeIndicator=t[3]),i.audioProfile=/(^|\s|,)+mp4a.[0-9A-Fa-f]+\.([0-9A-Fa-f]+)/i.exec(r),i.audioProfile=i.audioProfile&&i.audioProfile[2],i},K2=function(r){return r.replace(/avc1\.(\d+)\.(\d+)/i,function(i){return Rx([i])[0]})},d0=function(r,i,t){return r+"/"+i+'; codecs="'+t.filter(function(e){return!!e}).join(", ")+'"'},z2=function(r){return r.segments&&r.segments.length&&r.segments[0].map?"mp4":"mp2t"},X2=function(r){var i=r.attributes||{};return i.CODECS?yf(i.CODECS):Px},Y2=function(r,i){if(!r.mediaGroups.AUDIO||!i)return null;var t=r.mediaGroups.AUDIO[i];if(!t)return null;for(var e in t){var a=t[e];if(a.default&&a.playlists)return yf(a.playlists[0].attributes.CODECS).audioProfile}return null},Q2=function(r,i){var t=z2(i),e=X2(i),a=i.attributes||{},s=!0,o=!1;if(!i)return[];if(r.mediaGroups.AUDIO&&a.AUDIO){var u=r.mediaGroups.AUDIO[a.AUDIO];if(u){o=!0,s=!1;for(var l in u)if(!u[l].uri&&!u[l].playlists){s=!0;break}}}o&&!e.audioProfile&&(s||(e.audioProfile=Y2(r,a.AUDIO)),e.audioProfile||(be.log.warn("Multiple audio tracks present but no audio codec string is specified. Attempting to use the default audio codec (mp4a.40.2)"),e.audioProfile=Px.audioProfile));var d={};e.videoCodec&&(d.video=""+e.videoCodec+e.videoObjectTypeIndicator),e.audioProfile&&(d.audio="mp4a.40."+e.audioProfile);var c=d0("audio",t,[d.audio]),f=d0("video",t,[d.video]),h=d0("video",t,[d.video,d.audio]);return o?!s&&d.video?[f,c]:!s&&!d.video?[c,c]:[h,c]:d.video?[h]:[c]},J2=function(r){var i={type:"",parameters:{}},t=r.trim().split(";");return i.type=t.shift().trim(),t.forEach(function(e){var a=e.trim().split("=");if(a.length>1){var s=a[0].replace(/"/g,"").trim(),o=a[1].replace(/"/g,"").trim();i.parameters[s]=o}}),i},Ix=function(r){return/mp4a\.\d+.\d+/i.test(r)},Ox=function(r){return/avc1\.[\da-f]+/i.test(r)},Z2=function(r,i,t){if(typeof i>"u"||i===null||!r.length)return[];var e=Math.ceil((i-t+3)*9e4),a=void 0;for(a=0;a<r.length&&!(r[a].pts>e);a++);return r.slice(a)},eM=function(r,i,t){if(!i.length)return r;if(t)return i.slice();var e=i[0].pts,a=0;for(a;a<r.length&&!(r[a].pts>=e);a++);return r.slice(0,a).concat(i)},tM=function(r,i,t,e){for(var a=Math.ceil((i-e)*9e4),s=Math.ceil((t-e)*9e4),o=r.slice(),u=r.length;u--&&!(r[u].pts<=s););if(u===-1)return o;for(var l=u+1;l--&&!(r[l].pts<=a););return l=Math.max(l,0),o.splice(l,u-l+1),o},rM=function(r,i,t){var e=null,a=null,s=0,o=[],u=[];if(!r&&!i)return be.createTimeRange();if(!r)return i.buffered;if(!i||t)return r.buffered;if(r.buffered.length===0&&i.buffered.length===0)return be.createTimeRange();for(var l=r.buffered,d=i.buffered,c=l.length;c--;)o.push({time:l.start(c),type:"start"}),o.push({time:l.end(c),type:"end"});for(c=d.length;c--;)o.push({time:d.start(c),type:"start"}),o.push({time:d.end(c),type:"end"});for(o.sort(function(f,h){return f.time-h.time}),c=0;c<o.length;c++)o[c].type==="start"?(s++,s===2&&(e=o[c].time)):o[c].type==="end"&&(s--,s===1&&(a=o[c].time)),e!==null&&a!==null&&(u.push([e,a]),e=null,a=null);return be.createTimeRanges(u)},Hc=9e4,iM=function(r,i){var t=r.addSourceBuffer(i),e=Object.create(null);e.updating=!1,e.realBuffer_=t;var a=function(u){typeof t[u]=="function"?e[u]=function(){return t[u].apply(t,arguments)}:typeof e[u]>"u"&&Object.defineProperty(e,u,{get:function(){return t[u]},set:function(d){return t[u]=d}})};for(var s in t)a(s);return e},nM=function(n){ou(r,n);function r(i,t){Gs(this,r);var e=ko(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,be.EventTarget));e.timestampOffset_=0,e.pendingBuffers_=[],e.bufferUpdating_=!1,e.mediaSource_=i,e.codecs_=t,e.audioCodec_=null,e.videoCodec_=null,e.audioDisabled_=!1,e.appendAudioInitSegment_=!0,e.gopBuffer_=[],e.timeMapping_=0,e.safeAppend_=be.browser.IE_VERSION>=11;var a={remux:!1,alignGopsAtEnd:e.safeAppend_};return e.codecs_.forEach(function(s){Ix(s)?e.audioCodec_=s:Ox(s)&&(e.videoCodec_=s)}),e.transmuxer_=new W2,e.transmuxer_.postMessage({action:"init",options:a}),e.transmuxer_.onmessage=function(s){if(s.data.action==="data")return e.data_(s);if(s.data.action==="done")return e.done_(s);if(s.data.action==="gopInfo")return e.appendGopInfo_(s);if(s.data.action==="videoSegmentTimingInfo")return e.videoSegmentTimingInfo_(s.data.videoSegmentTimingInfo)},Object.defineProperty(e,"timestampOffset",{get:function(){return this.timestampOffset_},set:function(o){typeof o=="number"&&o>=0&&(this.timestampOffset_=o,this.appendAudioInitSegment_=!0,this.gopBuffer_.length=0,this.timeMapping_=0,this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:o}))}}),Object.defineProperty(e,"appendWindowStart",{get:function(){return(this.videoBuffer_||this.audioBuffer_).appendWindowStart},set:function(o){this.videoBuffer_&&(this.videoBuffer_.appendWindowStart=o),this.audioBuffer_&&(this.audioBuffer_.appendWindowStart=o)}}),Object.defineProperty(e,"updating",{get:function(){return!!(this.bufferUpdating_||!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.updating||this.videoBuffer_&&this.videoBuffer_.updating)}}),Object.defineProperty(e,"buffered",{get:function(){return rM(this.videoBuffer_,this.audioBuffer_,this.audioDisabled_)}}),e}return so(r,[{key:"data_",value:function(t){var e=t.data.segment;e.data=new Uint8Array(e.data,t.data.byteOffset,t.data.byteLength),e.initSegment=new Uint8Array(e.initSegment.data,e.initSegment.byteOffset,e.initSegment.byteLength),j2(this,this.mediaSource_,e),this.pendingBuffers_.push(e)}},{key:"done_",value:function(t){if(this.mediaSource_.readyState==="closed"){this.pendingBuffers_.length=0;return}this.processPendingSegments_()}},{key:"videoSegmentTimingInfo_",value:function(t){var e={start:{decode:t.start.dts/Hc,presentation:t.start.pts/Hc},end:{decode:t.end.dts/Hc,presentation:t.end.pts/Hc},baseMediaDecodeTime:t.baseMediaDecodeTime/Hc};t.prependedContentDuration&&(e.prependedContentDuration=t.prependedContentDuration/Hc),this.trigger({type:"videoSegmentTimingInfo",videoSegmentTimingInfo:e})}},{key:"createRealSourceBuffers_",value:function(){var t=this,e=["audio","video"];e.forEach(function(a){if(!!t[a+"Codec_"]&&!t[a+"Buffer_"]){var s=null;if(t.mediaSource_[a+"Buffer_"])s=t.mediaSource_[a+"Buffer_"],s.updating=!1;else{var o=a+"Codec_",u=a+'/mp4;codecs="'+t[o]+'"';s=iM(t.mediaSource_.nativeMediaSource_,u),t.mediaSource_[a+"Buffer_"]=s}t[a+"Buffer_"]=s,["update","updatestart","updateend"].forEach(function(l){s.addEventListener(l,function(){if(!(a==="audio"&&t.audioDisabled_)){l==="updateend"&&(t[a+"Buffer_"].updating=!1);var d=e.every(function(c){return c==="audio"&&t.audioDisabled_?!0:!(a!==c&&t[c+"Buffer_"]&&t[c+"Buffer_"].updating)});if(d)return t.trigger(l)}})})}})}},{key:"appendBuffer",value:function(t){if(this.bufferUpdating_=!0,this.audioBuffer_&&this.audioBuffer_.buffered.length){var e=this.audioBuffer_.buffered;this.transmuxer_.postMessage({action:"setAudioAppendStart",appendStart:e.end(e.length-1)})}this.videoBuffer_&&this.transmuxer_.postMessage({action:"alignGopsWith",gopsToAlignWith:Z2(this.gopBuffer_,this.mediaSource_.player_?this.mediaSource_.player_.currentTime():null,this.timeMapping_)}),this.transmuxer_.postMessage({action:"push",data:t.buffer,byteOffset:t.byteOffset,byteLength:t.byteLength},[t.buffer]),this.transmuxer_.postMessage({action:"flush"})}},{key:"appendGopInfo_",value:function(t){this.gopBuffer_=eM(this.gopBuffer_,t.data.gopInfo,this.safeAppend_)}},{key:"remove",value:function(t,e){if(this.videoBuffer_&&(this.videoBuffer_.updating=!0,this.videoBuffer_.remove(t,e),this.gopBuffer_=tM(this.gopBuffer_,t,e,this.timeMapping_)),!this.audioDisabled_&&this.audioBuffer_&&(this.audioBuffer_.updating=!0,this.audioBuffer_.remove(t,e)),Uc(t,e,this.metadataTrack_),this.inbandTextTracks_)for(var a in this.inbandTextTracks_)Uc(t,e,this.inbandTextTracks_[a])}},{key:"processPendingSegments_",value:function(){var t={video:{segments:[],bytes:0},audio:{segments:[],bytes:0},captions:[],metadata:[]};if(!this.pendingBuffers_.length){this.trigger("updateend"),this.bufferUpdating_=!1;return}t=this.pendingBuffers_.reduce(function(a,s){var o=s.type,u=s.data,l=s.initSegment;return a[o].segments.push(u),a[o].bytes+=u.byteLength,a[o].initSegment=l,s.captions&&(a.captions=a.captions.concat(s.captions)),s.info&&(a[o].info=s.info),s.metadata&&(a.metadata=a.metadata.concat(s.metadata)),a},t),!this.videoBuffer_&&!this.audioBuffer_&&(t.video.bytes===0&&(this.videoCodec_=null),t.audio.bytes===0&&(this.audioCodec_=null),this.createRealSourceBuffers_()),t.audio.info&&this.mediaSource_.trigger({type:"audioinfo",info:t.audio.info}),t.video.info&&this.mediaSource_.trigger({type:"videoinfo",info:t.video.info}),this.appendAudioInitSegment_&&(!this.audioDisabled_&&this.audioBuffer_&&(t.audio.segments.unshift(t.audio.initSegment),t.audio.bytes+=t.audio.initSegment.byteLength),this.appendAudioInitSegment_=!1);var e=!1;this.videoBuffer_&&t.video.bytes?(t.video.segments.unshift(t.video.initSegment),t.video.bytes+=t.video.initSegment.byteLength,this.concatAndAppendSegments_(t.video,this.videoBuffer_)):this.videoBuffer_&&(this.audioDisabled_||!this.audioBuffer_)&&(e=!0),H2(this,t.captions,t.metadata),!this.audioDisabled_&&this.audioBuffer_&&this.concatAndAppendSegments_(t.audio,this.audioBuffer_),this.pendingBuffers_.length=0,e&&this.trigger("updateend"),this.bufferUpdating_=!1}},{key:"concatAndAppendSegments_",value:function(t,e){var a=0,s=void 0;if(t.bytes){s=new Uint8Array(t.bytes),t.segments.forEach(function(o){s.set(o,a),a+=o.byteLength});try{e.updating=!0,e.appendBuffer(s)}catch(o){this.mediaSource_.player_&&this.mediaSource_.player_.error({code:-3,type:"APPEND_BUFFER_ERR",message:o.message,originalError:o})}}}},{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}}]),r}(be.EventTarget),f0=function(n){ou(r,n);function r(){Gs(this,r);var i=ko(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),t=void 0;i.nativeMediaSource_=new tt.MediaSource;for(t in i.nativeMediaSource_)!(t in r.prototype)&&typeof i.nativeMediaSource_[t]=="function"&&(i[t]=i.nativeMediaSource_[t].bind(i.nativeMediaSource_));return i.duration_=NaN,Object.defineProperty(i,"duration",{get:function(){return this.duration_===1/0?this.duration_:this.nativeMediaSource_.duration},set:function(a){if(this.duration_=a,a!==1/0){this.nativeMediaSource_.duration=a;return}}}),Object.defineProperty(i,"seekable",{get:function(){return this.duration_===1/0?be.createTimeRanges([[0,this.nativeMediaSource_.duration]]):this.nativeMediaSource_.seekable}}),Object.defineProperty(i,"readyState",{get:function(){return this.nativeMediaSource_.readyState}}),Object.defineProperty(i,"activeSourceBuffers",{get:function(){return this.activeSourceBuffers_}}),i.sourceBuffers=[],i.activeSourceBuffers_=[],i.updateActiveSourceBuffers_=function(){if(i.activeSourceBuffers_.length=0,i.sourceBuffers.length===1){var e=i.sourceBuffers[0];e.appendAudioInitSegment_=!0,e.audioDisabled_=!e.audioCodec_,i.activeSourceBuffers_.push(e);return}for(var a=!1,s=!0,o=0;o<i.player_.audioTracks().length;o++){var u=i.player_.audioTracks()[o];if(u.enabled&&u.kind!=="main"){a=!0,s=!1;break}}i.sourceBuffers.forEach(function(l,d){if(l.appendAudioInitSegment_=!0,l.videoCodec_&&l.audioCodec_)l.audioDisabled_=a;else if(l.videoCodec_&&!l.audioCodec_)l.audioDisabled_=!0,s=!1;else if(!l.videoCodec_&&l.audioCodec_&&(l.audioDisabled_=d?s:!s,l.audioDisabled_))return;i.activeSourceBuffers_.push(l)})},i.onPlayerMediachange_=function(){i.sourceBuffers.forEach(function(e){e.appendAudioInitSegment_=!0})},i.onHlsReset_=function(){i.sourceBuffers.forEach(function(e){e.transmuxer_&&e.transmuxer_.postMessage({action:"resetCaptions"})})},i.onHlsSegmentTimeMapping_=function(e){i.sourceBuffers.forEach(function(a){return a.timeMapping_=e.mapping})},["sourceopen","sourceclose","sourceended"].forEach(function(e){this.nativeMediaSource_.addEventListener(e,this.trigger.bind(this))},i),i.on("sourceopen",function(e){var a=sr.querySelector('[src="'+i.url_+'"]');!a||(i.player_=be(a.parentNode),i.player_&&(i.player_.tech_.on("hls-reset",i.onHlsReset_),i.player_.tech_.on("hls-segment-time-mapping",i.onHlsSegmentTimeMapping_),i.player_.audioTracks&&i.player_.audioTracks()&&(i.player_.audioTracks().on("change",i.updateActiveSourceBuffers_),i.player_.audioTracks().on("addtrack",i.updateActiveSourceBuffers_),i.player_.audioTracks().on("removetrack",i.updateActiveSourceBuffers_)),i.player_.on("mediachange",i.onPlayerMediachange_)))}),i.on("sourceended",function(e){for(var a=Ax(i.duration),s=0;s<i.sourceBuffers.length;s++){var o=i.sourceBuffers[s],u=o.metadataTrack_&&o.metadataTrack_.cues;u&&u.length&&(u[u.length-1].endTime=a)}}),i.on("sourceclose",function(e){this.sourceBuffers.forEach(function(a){a.transmuxer_&&a.transmuxer_.terminate()}),this.sourceBuffers.length=0,this.player_&&(this.player_.audioTracks&&this.player_.audioTracks()&&(this.player_.audioTracks().off("change",this.updateActiveSourceBuffers_),this.player_.audioTracks().off("addtrack",this.updateActiveSourceBuffers_),this.player_.audioTracks().off("removetrack",this.updateActiveSourceBuffers_)),this.player_.el_&&this.player_.off("mediachange",this.onPlayerMediachange_),this.player_.tech_&&this.player_.tech_.el_&&(this.player_.tech_.off("hls-reset",this.onHlsReset_),this.player_.tech_.off("hls-segment-time-mapping",this.onHlsSegmentTimeMapping_)))}),i}return so(r,[{key:"addSeekableRange_",value:function(t,e){var a=void 0;if(this.duration!==1/0)throw a=new Error("MediaSource.addSeekableRange() can only be invoked when the duration is Infinity"),a.name="InvalidStateError",a.code=11,a;(e>this.nativeMediaSource_.duration||isNaN(this.nativeMediaSource_.duration))&&(this.nativeMediaSource_.duration=e)}},{key:"addSourceBuffer",value:function(t){var e=void 0,a=J2(t);if(/^(video|audio)\/mp2t$/i.test(a.type)){var s=[];a.parameters&&a.parameters.codecs&&(s=a.parameters.codecs.split(","),s=Rx(s),s=s.filter(function(o){return Ix(o)||Ox(o)})),s.length===0&&(s=["avc1.4d400d","mp4a.40.2"]),e=new nM(this,s),this.sourceBuffers.length!==0&&(this.sourceBuffers[0].createRealSourceBuffers_(),e.createRealSourceBuffers_(),this.sourceBuffers[0].audioDisabled_=!0)}else e=this.nativeMediaSource_.addSourceBuffer(t);return this.sourceBuffers.push(e),e}}]),r}(be.EventTarget),Lx=0;be.mediaSources={};var Mx=function(r,i){var t=be.mediaSources[r];if(t)t.trigger({type:"sourceopen",swfId:i});else throw new Error("Media Source not found (Video.js)")},h0=function(){return!!tt.MediaSource&&!!tt.MediaSource.isTypeSupported&&tt.MediaSource.isTypeSupported('video/mp4;codecs="avc1.4d400d,mp4a.40.2"')},_f=function(){if(this.MediaSource={open:Mx,supportsNativeMediaSources:h0},h0())return new f0;throw new Error("Cannot use create a virtual MediaSource for this video")};_f.open=Mx,_f.supportsNativeMediaSources=h0;var Fx={createObjectURL:function(r){var i="blob:vjs-media-source/",t=void 0;return r instanceof f0?(t=tt.URL.createObjectURL(r.nativeMediaSource_),r.url_=t,t):r instanceof f0?(t=i+Lx,Lx++,be.mediaSources[t]=r,t):(t=tt.URL.createObjectURL(r),r.url_=t,t)}};be.MediaSource=_f,be.URL=Fx;var aM=be.EventTarget,Nx=be.mergeOptions,Bx=function(r,i){for(var t=void 0,e=Nx(r,{duration:i.duration,minimumUpdatePeriod:i.minimumUpdatePeriod}),a=0;a<i.playlists.length;a++){var s=a0(e,i.playlists[a]);s?e=s:t=!0}return pp(i,function(o,u,l,d){if(o.playlists&&o.playlists.length){var c=o.playlists[0].uri,f=a0(e,o.playlists[0]);f&&(e=f,e.mediaGroups[u][l][d].playlists[0]=e.playlists[c],t=!1)}}),t?null:e},p0=function(r){var i=r.byterange.offset+r.byterange.length-1;return r.uri+"-"+r.byterange.offset+"-"+i},sM=function(r,i){var t=Boolean(!r.map&&!i.map),e=t||Boolean(r.map&&i.map&&r.map.byterange.offset===i.map.byterange.offset&&r.map.byterange.length===i.map.byterange.length);return e&&r.uri===i.uri&&r.byterange.offset===i.byterange.offset&&r.byterange.length===i.byterange.length},Ux=function(r,i){var t={};for(var e in r){var a=r[e],s=a.sidx;if(s){var o=p0(s);if(!i[o])break;var u=i[o].sidxInfo;sM(u,s)&&(t[o]=i[o])}}return t},oM=function(r,i,t,e){var a=Nv(r,{manifestUri:i,clientOffset:t}),s=Ux(a.playlists,e),o=s;return pp(a,function(u,l,d,c){if(u.playlists&&u.playlists.length){var f=u.playlists;o=Nx(o,Ux(f,e))}}),o},jx=function(r,i,t,e,a){var s={uri:hp(e.handleManifestRedirects,r.resolvedUri),byterange:r.byterange,playlist:i},o=be.mergeOptions(s,{responseType:"arraybuffer",headers:u0(s)});return t(o,a)},g0=function(n){ou(r,n);function r(i,t){var e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=arguments[3];Gs(this,r);var s=ko(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),o=e.withCredentials,u=o===void 0?!1:o,l=e.handleManifestRedirects,d=l===void 0?!1:l;if(s.hls_=t,s.withCredentials=u,s.handleManifestRedirects=d,!i)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().uri)}),s.state="HAVE_NOTHING",s.loadedPlaylists_={},typeof i=="string"?(s.srcUrl=i,s.sidxMapping_={},ko(s)):(s.setupChildLoader(a,i),s)}return so(r,[{key:"setupChildLoader",value:function(t,e){this.masterPlaylistLoader_=t,this.childPlaylist_=e}},{key:"dispose",value:function(){this.stopRequest(),this.loadedPlaylists_={},tt.clearTimeout(this.minimumUpdatePeriodTimeout_),tt.clearTimeout(this.mediaRequest_),tt.clearTimeout(this.mediaUpdateTimeout)}},{key:"hasPendingRequest",value:function(){return this.request||this.mediaRequest_}},{key:"stopRequest",value:function(){if(this.request){var t=this.request;this.request=null,t.onreadystatechange=null,t.abort()}}},{key:"sidxRequestFinished_",value:function(t,e,a,s){var o=this;return function(u,l){if(!!o.request){if(o.request=null,u)return o.error={status:l.status,message:"DASH playlist request error at URL: "+t.uri,response:l.response,code:2},a&&(o.state=a),o.trigger("error"),s(e,null);var d=new Uint8Array(l.response),c=wI.parseSidx(d.subarray(8));return s(e,c)}}}},{key:"media",value:function(t){var e=this;if(!t)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);var a=this.state;if(typeof t=="string"){if(!this.master.playlists[t])throw new Error("Unknown playlist URI: "+t);t=this.master.playlists[t]}var s=!this.media_||t.uri!==this.media_.uri;if(s&&this.loadedPlaylists_[t.uri]&&this.loadedPlaylists_[t.uri].endList){this.state="HAVE_METADATA",this.media_=t,s&&(this.trigger("mediachanging"),this.trigger("mediachange"));return}if(!!s){if(this.media_&&this.trigger("mediachanging"),!t.sidx){this.mediaRequest_=tt.setTimeout(this.haveMetadata.bind(this,{startingState:a,playlist:t}),0);return}var o=void 0,u=void 0;this.masterPlaylistLoader_?(o=this.masterPlaylistLoader_.master,u=this.masterPlaylistLoader_.sidxMapping_):(o=this.master,u=this.sidxMapping_);var l=p0(t.sidx);u[l]={sidxInfo:t.sidx},this.request=jx(t.sidx,t,this.hls_.xhr,{handleManifestRedirects:this.handleManifestRedirects},this.sidxRequestFinished_(t,o,a,function(d,c){if(!d||!c)throw new Error("failed to request sidx");u[l].sidx=c,e.haveMetadata({startingState:a,playlist:d.playlists[t.uri]})}))}}},{key:"haveMetadata",value:function(t){var e=t.startingState,a=t.playlist;this.state="HAVE_METADATA",this.loadedPlaylists_[a.uri]=a,this.mediaRequest_=null,this.refreshMedia_(a.uri),e==="HAVE_MASTER"?this.trigger("loadedmetadata"):this.trigger("mediachange")}},{key:"pause",value:function(){this.stopRequest(),tt.clearTimeout(this.mediaUpdateTimeout),tt.clearTimeout(this.minimumUpdatePeriodTimeout_),this.state==="HAVE_NOTHING"&&(this.started=!1)}},{key:"load",value:function(t){var e=this;tt.clearTimeout(this.mediaUpdateTimeout),tt.clearTimeout(this.minimumUpdatePeriodTimeout_);var a=this.media();if(t){var s=a?a.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=tt.setTimeout(function(){return e.load()},s);return}if(!this.started){this.start();return}this.trigger("loadedplaylist")}},{key:"parseMasterXml",value:function(){var t=Nv(this.masterXml_,{manifestUri:this.srcUrl,clientOffset:this.clientOffset_,sidxMapping:this.sidxMapping_});t.uri=this.srcUrl;for(var e=0;e<t.playlists.length;e++){var a="placeholder-uri-"+e;t.playlists[e].uri=a,t.playlists[a]=t.playlists[e]}return pp(t,function(s,o,u,l){if(s.playlists&&s.playlists.length){var d="placeholder-uri-"+o+"-"+u+"-"+l;s.playlists[0].uri=d,t.playlists[d]=s.playlists[0]}}),nx(t),ax(t),t}},{key:"start",value:function(){var t=this;if(this.started=!0,this.masterPlaylistLoader_){this.mediaRequest_=tt.setTimeout(this.haveMaster_.bind(this),0);return}this.request=this.hls_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},function(e,a){if(!!t.request){if(t.request=null,e)return t.error={status:a.status,message:"DASH playlist request error at URL: "+t.srcUrl,responseText:a.responseText,code:2},t.state==="HAVE_NOTHING"&&(t.started=!1),t.trigger("error");t.masterXml_=a.responseText,a.responseHeaders&&a.responseHeaders.date?t.masterLoaded_=Date.parse(a.responseHeaders.date):t.masterLoaded_=Date.now(),t.srcUrl=hp(t.handleManifestRedirects,t.srcUrl,a),t.syncClientServerClock_(t.onClientServerClockSync_.bind(t))}})}},{key:"syncClientServerClock_",value:function(t){var e=this,a=Gb(this.masterXml_);if(a===null)return this.clientOffset_=this.masterLoaded_-Date.now(),t();if(a.method==="DIRECT")return this.clientOffset_=a.value-Date.now(),t();this.request=this.hls_.xhr({uri:Al(this.srcUrl,a.value),method:a.method,withCredentials:this.withCredentials},function(s,o){if(!!e.request){if(s)return e.clientOffset_=e.masterLoaded_-Date.now(),t();var u=void 0;a.method==="HEAD"?!o.responseHeaders||!o.responseHeaders.date?u=e.masterLoaded_:u=Date.parse(o.responseHeaders.date):u=Date.parse(o.responseText),e.clientOffset_=u-Date.now(),t()}})}},{key:"haveMaster_",value:function(){this.state="HAVE_MASTER",this.mediaRequest_=null,this.masterPlaylistLoader_?this.media_||this.media(this.childPlaylist_):(this.master=this.parseMasterXml(),this.trigger("loadedplaylist"))}},{key:"onClientServerClockSync_",value:function(){var t=this;this.haveMaster_(),!this.hasPendingRequest()&&!this.media_&&this.media(this.master.playlists[0]),this.master&&this.master.minimumUpdatePeriod&&(this.minimumUpdatePeriodTimeout_=tt.setTimeout(function(){t.trigger("minimumUpdatePeriod")},this.master.minimumUpdatePeriod))}},{key:"refreshXml_",value:function(){var t=this;this.request=this.hls_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},function(e,a){if(!!t.request){if(t.request=null,e)return t.error={status:a.status,message:"DASH playlist request error at URL: "+t.srcUrl,responseText:a.responseText,code:2},t.state==="HAVE_NOTHING"&&(t.started=!1),t.trigger("error");t.masterXml_=a.responseText,t.sidxMapping_=oM(t.masterXml_,t.srcUrl,t.clientOffset_,t.sidxMapping_);var s=t.parseMasterXml(),o=Bx(t.master,s),u=t.media().sidx;if(o)if(u){var l=p0(u);if(!t.sidxMapping_[l]){var d=t.media();t.request=jx(d.sidx,d,t.hls_.xhr,{handleManifestRedirects:t.handleManifestRedirects},t.sidxRequestFinished_(d,s,t.state,function(c,f){if(!c||!f)throw new Error("failed to request sidx on minimumUpdatePeriod");t.sidxMapping_[l].sidx=f,t.minimumUpdatePeriodTimeout_=tt.setTimeout(function(){t.trigger("minimumUpdatePeriod")},t.master.minimumUpdatePeriod),t.refreshMedia_(t.media().uri)}))}}else t.master=o;t.minimumUpdatePeriodTimeout_=tt.setTimeout(function(){t.trigger("minimumUpdatePeriod")},t.master.minimumUpdatePeriod)}})}},{key:"refreshMedia_",value:function(t){var e=this;if(!t)throw new Error("refreshMedia_ must take a media uri");var a=void 0,s=void 0;this.masterPlaylistLoader_?(a=this.masterPlaylistLoader_.master,s=this.masterPlaylistLoader_.parseMasterXml()):(a=this.master,s=this.parseMasterXml());var o=Bx(a,s);o?(this.masterPlaylistLoader_?this.masterPlaylistLoader_.master=o:this.master=o,this.media_=o.playlists[t]):(this.media_=s.playlists[t],this.trigger("playlistunchanged")),this.media().endList||(this.mediaUpdateTimeout=tt.setTimeout(function(){e.trigger("mediaupdatetimeout")},sx(this.media(),!!o))),this.trigger("loadedplaylist")}}]),r}(aM),Tf=function(r){return be.log.debug?be.log.debug.bind(be,"VHS:",r+" >"):function(){}};function Vc(){}var uM=function(){function n(r,i,t,e){Gs(this,n),this.callbacks_=[],this.pendingCallback_=null,this.timestampOffset_=0,this.mediaSource=r,this.processedAppend_=!1,this.type_=t,this.mimeType_=i,this.logger_=Tf("SourceUpdater["+t+"]["+i+"]"),r.readyState==="closed"?r.addEventListener("sourceopen",this.createSourceBuffer_.bind(this,i,e)):this.createSourceBuffer_(i,e)}return so(n,[{key:"createSourceBuffer_",value:function(i,t){var e=this;if(this.sourceBuffer_=this.mediaSource.addSourceBuffer(i),this.logger_("created SourceBuffer"),t&&(t.trigger("sourcebufferadded"),this.mediaSource.sourceBuffers.length<2)){t.on("sourcebufferadded",function(){e.start_()});return}this.start_()}},{key:"start_",value:function(){var i=this;this.started_=!0,this.onUpdateendCallback_=function(){var t=i.pendingCallback_;i.pendingCallback_=null,i.sourceBuffer_.removing=!1,i.logger_("buffered ["+l0(i.buffered())+"]"),t&&t(),i.runCallback_()},this.sourceBuffer_.addEventListener("updateend",this.onUpdateendCallback_),this.runCallback_()}},{key:"abort",value:function(i){var t=this;this.processedAppend_&&this.queueCallback_(function(){t.sourceBuffer_.abort()},i)}},{key:"appendBuffer",value:function(i,t){var e=this;this.processedAppend_=!0,this.queueCallback_(function(){i.videoSegmentTimingInfoCallback&&e.sourceBuffer_.addEventListener("videoSegmentTimingInfo",i.videoSegmentTimingInfoCallback),e.sourceBuffer_.appendBuffer(i.bytes)},function(){i.videoSegmentTimingInfoCallback&&e.sourceBuffer_.removeEventListener("videoSegmentTimingInfo",i.videoSegmentTimingInfoCallback),t()})}},{key:"buffered",value:function(){return this.sourceBuffer_?this.sourceBuffer_.buffered:be.createTimeRanges()}},{key:"remove",value:function(i,t){var e=this,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Vc;this.processedAppend_&&this.queueCallback_(function(){e.logger_("remove ["+i+" => "+t+"]"),e.sourceBuffer_.removing=!0,e.sourceBuffer_.remove(i,t)},a)}},{key:"updating",value:function(){return!this.sourceBuffer_||this.sourceBuffer_.updating||!!this.pendingCallback_&&this.pendingCallback_!==Vc}},{key:"timestampOffset",value:function(i){var t=this;return typeof i<"u"&&(this.queueCallback_(function(){t.sourceBuffer_.timestampOffset=i,t.runCallback_()}),this.timestampOffset_=i),this.timestampOffset_}},{key:"queueCallback_",value:function(i,t){this.callbacks_.push([i.bind(this),t]),this.runCallback_()}},{key:"runCallback_",value:function(){var i=void 0;!this.updating()&&this.callbacks_.length&&this.started_&&(i=this.callbacks_.shift(),this.pendingCallback_=i[1],i[0]())}},{key:"dispose",value:function(){var i=this,t=function e(){i.sourceBuffer_&&i.mediaSource.readyState==="open"&&i.sourceBuffer_.abort(),i.sourceBuffer_.removeEventListener("updateend",e)};this.sourceBuffer_.removeEventListener("updateend",this.onUpdateendCallback_),this.sourceBuffer_.removing?this.sourceBuffer_.addEventListener("updateend",t):t()}}]),n}(),Ts={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},zu={FAILURE:2,TIMEOUT:-101,ABORTED:-102},$x=function(r){r.forEach(function(i){i.abort()})},lM=function(r){return{bandwidth:r.bandwidth,bytesReceived:r.bytesReceived||0,roundTripTime:r.roundTripTime||0}},cM=function(r){var i=r.target,t=Date.now()-i.requestTime,e={bandwidth:1/0,bytesReceived:0,roundTripTime:t||0};return e.bytesReceived=r.loaded,e.bandwidth=Math.floor(e.bytesReceived/e.roundTripTime*8*1e3),e},v0=function(r,i){return i.timedout?{status:i.status,message:"HLS request timed-out at URL: "+i.uri,code:zu.TIMEOUT,xhr:i}:i.aborted?{status:i.status,message:"HLS request aborted at URL: "+i.uri,code:zu.ABORTED,xhr:i}:r?{status:i.status,message:"HLS request errored at URL: "+i.uri,code:zu.FAILURE,xhr:i}:null},dM=function(r,i){return function(t,e){var a=e.response,s=v0(t,e);if(s)return i(s,r);if(a.byteLength!==16)return i({status:e.status,message:"Invalid HLS key at URL: "+e.uri,code:zu.FAILURE,xhr:e},r);var o=new DataView(a);return r.key.bytes=new Uint32Array([o.getUint32(0),o.getUint32(4),o.getUint32(8),o.getUint32(12)]),i(null,r)}},fM=function(r,i,t){return function(e,a){var s=a.response,o=v0(e,a);return o?t(o,r):s.byteLength===0?t({status:a.status,message:"Empty HLS segment content at URL: "+a.uri,code:zu.FAILURE,xhr:a},r):(r.map.bytes=new Uint8Array(a.response),i&&!i.isInitialized()&&i.init(),r.map.timescales=Fh.timescale(r.map.bytes),r.map.videoTrackIds=Fh.videoTrackIds(r.map.bytes),t(null,r))}},hM=function(r,i,t){return function(e,a){var s=a.response,o=v0(e,a),u=void 0;return o?t(o,r):s.byteLength===0?t({status:a.status,message:"Empty HLS segment content at URL: "+a.uri,code:zu.FAILURE,xhr:a},r):(r.stats=lM(a),r.key?r.encryptedBytes=new Uint8Array(a.response):r.bytes=new Uint8Array(a.response),i&&r.map&&r.map.bytes&&(i.isInitialized()||i.init(),u=i.parse(r.bytes,r.map.videoTrackIds,r.map.timescales),u&&u.captions&&(r.captionStreams=u.captionStreams,r.fmp4Captions=u.captions)),t(null,r))}},pM=function(r,i,t){var e=function s(o){if(o.data.source===i.requestId){r.removeEventListener("message",s);var u=o.data.decrypted;return i.bytes=new Uint8Array(u.bytes,u.byteOffset,u.byteLength),t(null,i)}};r.addEventListener("message",e);var a=void 0;i.key.bytes.slice?a=i.key.bytes.slice():a=new Uint32Array(Array.prototype.slice.call(i.key.bytes)),r.postMessage(mx({source:i.requestId,encrypted:i.encryptedBytes,key:a,iv:i.key.iv}),[i.encryptedBytes.buffer,a.buffer])},gM=function(r,i,t){var e=0,a=!1;return function(s,o){if(!a){if(s)return a=!0,$x(r),t(s,o);if(e+=1,e===r.length)return o.endOfAllRequests=Date.now(),o.encryptedBytes?pM(i,o,t):t(null,o)}}},vM=function(r,i){return function(t){return r.stats=be.mergeOptions(r.stats,cM(t)),!r.stats.firstBytesReceivedAt&&r.stats.bytesReceived&&(r.stats.firstBytesReceivedAt=Date.now()),i(t,r)}},mM=function(r,i,t,e,a,s,o){var u=[],l=gM(u,t,o);if(a.key&&!a.key.bytes){var d=be.mergeOptions(i,{uri:a.key.resolvedUri,responseType:"arraybuffer"}),c=dM(a,l),f=r(d,c);u.push(f)}if(a.map&&!a.map.bytes){var h=be.mergeOptions(i,{uri:a.map.resolvedUri,responseType:"arraybuffer",headers:u0(a.map)}),g=fM(a,e,l),p=r(h,g);u.push(p)}var v=be.mergeOptions(i,{uri:a.resolvedUri,responseType:"arraybuffer",headers:u0(a)}),y=hM(a,e,l),m=r(v,y);return m.addEventListener("progress",vM(a,s)),u.push(m),function(){return $x(u)}},Hx=function(r,i){var t=void 0;return!r||(t=tt.getComputedStyle(r),!t)?"":t[i]},bf=function(r,i){var t=r.slice();r.sort(function(e,a){var s=i(e,a);return s===0?t.indexOf(e)-t.indexOf(a):s})},m0=function(r,i){var t=void 0,e=void 0;return r.attributes.BANDWIDTH&&(t=r.attributes.BANDWIDTH),t=t||tt.Number.MAX_VALUE,i.attributes.BANDWIDTH&&(e=i.attributes.BANDWIDTH),e=e||tt.Number.MAX_VALUE,t-e},yM=function(r,i){var t=void 0,e=void 0;return r.attributes.RESOLUTION&&r.attributes.RESOLUTION.width&&(t=r.attributes.RESOLUTION.width),t=t||tt.Number.MAX_VALUE,i.attributes.RESOLUTION&&i.attributes.RESOLUTION.width&&(e=i.attributes.RESOLUTION.width),e=e||tt.Number.MAX_VALUE,t===e&&r.attributes.BANDWIDTH&&i.attributes.BANDWIDTH?r.attributes.BANDWIDTH-i.attributes.BANDWIDTH:t-e},_M=function(r,i,t,e,a){var s=r.playlists.map(function(T){var b=void 0,E=void 0,C=void 0;return b=T.attributes.RESOLUTION&&T.attributes.RESOLUTION.width,E=T.attributes.RESOLUTION&&T.attributes.RESOLUTION.height,C=T.attributes.BANDWIDTH,C=C||tt.Number.MAX_VALUE,{bandwidth:C,width:b,height:E,playlist:T}});bf(s,function(T,b){return T.bandwidth-b.bandwidth}),s=s.filter(function(T){return!ns.isIncompatible(T.playlist)});var o=s.filter(function(T){return ns.isEnabled(T.playlist)});o.length||(o=s.filter(function(T){return!ns.isDisabled(T.playlist)}));var u=o.filter(function(T){return T.bandwidth*Ts.BANDWIDTH_VARIANCE<i}),l=u[u.length-1],d=u.filter(function(T){return T.bandwidth===l.bandwidth})[0];if(a===!1){var c=d||o[0]||s[0];return c?c.playlist:null}var f=u.filter(function(T){return T.width&&T.height});bf(f,function(T,b){return T.width-b.width});var h=f.filter(function(T){return T.width===t&&T.height===e});l=h[h.length-1];var g=h.filter(function(T){return T.bandwidth===l.bandwidth})[0],p=void 0,v=void 0,y=void 0;g||(p=f.filter(function(T){return T.width>t||T.height>e}),v=p.filter(function(T){return T.width===p[0].width&&T.height===p[0].height}),l=v[v.length-1],y=v.filter(function(T){return T.bandwidth===l.bandwidth})[0]);var m=y||g||d||o[0]||s[0];return m?m.playlist:null},TM=function(){return _M(this.playlists.master,this.systemBandwidth,parseInt(Hx(this.tech_.el(),"width"),10),parseInt(Hx(this.tech_.el(),"height"),10),this.limitRenditionByPlayerDimensions)},bM=function(r){var i=r.master,t=r.currentTime,e=r.bandwidth,a=r.duration,s=r.segmentDuration,o=r.timeUntilRebuffer,u=r.currentTimeline,l=r.syncController,d=i.playlists.filter(function(p){return!ns.isIncompatible(p)}),c=d.filter(ns.isEnabled);c.length||(c=d.filter(function(p){return!ns.isDisabled(p)}));var f=c.filter(ns.hasAttribute.bind(null,"BANDWIDTH")),h=f.map(function(p){var v=l.getSyncPoint(p,a,u,t),y=v?1:2,m=ns.estimateSegmentRequestTime(s,e,p),T=m*y-o;return{playlist:p,rebufferingImpact:T}}),g=h.filter(function(p){return p.rebufferingImpact<=0});return bf(g,function(p,v){return m0(v.playlist,p.playlist)}),g.length?g[0]:(bf(h,function(p,v){return p.rebufferingImpact-v.rebufferingImpact}),h[0]||null)},SM=function(){var r=this.playlists.master.playlists.filter(ns.isEnabled);bf(r,function(t,e){return m0(t,e)});var i=r.filter(function(t){return yf(t.attributes.CODECS).videoCodec});return i[0]||null},EM=function(r,i,t){for(var e in t)if(!r[e]){i.trigger({type:"usage",name:"hls-608"});var a=i.textTracks().getTrackById(e);a?r[e]=a:r[e]=i.addRemoteTextTrack({kind:"captions",id:e,label:e},!1).track}},xM=function(r){var i=r.inbandTextTracks,t=r.captionArray,e=r.timestampOffset;if(!!t){var a=window.WebKitDataCue||window.VTTCue;t.forEach(function(s){var o=s.stream,u=s.startTime,l=s.endTime;!i[o]||(u+=e,l+=e,i[o].addCue(new a(u,l,s.text)))})}},AM=500,CM=function(r,i,t){if(!r||!i)return!1;var e=r.segments,a=t===e.length;return r.endList&&i.readyState==="open"&&a},Vx=function(r){return typeof r=="number"&&isFinite(r)},wM=function(r,i,t){return r!=="main"||!i||!t?null:!t.containsAudio&&!t.containsVideo?"Neither audio nor video found in segment.":i.containsVideo&&!t.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.":!i.containsVideo&&t.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},kM=function(r,i,t){var e=void 0;return r.length&&r.start(0)>0&&r.start(0)<i?e=r.start(0):e=i-30,Math.min(e,i-t)},DM=function(r){var i=r.segment,t=i.start,e=i.end,a=r.playlist,s=a.mediaSequence,o=a.id,u=a.segments,l=u===void 0?[]:u,d=r.mediaIndex,c=r.timeline;return["appending ["+d+"] of ["+s+", "+(s+l.length)+"] from playlist ["+o+"]","["+t+" => "+e+"] in timeline ["+c+"]"].join(" ")},y0=function(n){ou(r,n);function r(i){Gs(this,r);var t=ko(this,(r.__proto__||Object.getPrototypeOf(r)).call(this));if(!i)throw new TypeError("Initialization settings are required");if(typeof i.currentTime!="function")throw new TypeError("No currentTime getter specified");if(!i.mediaSource)throw new TypeError("No MediaSource specified");return t.bandwidth=i.bandwidth,t.throughput={rate:0,count:0},t.roundTrip=NaN,t.resetStats_(),t.mediaIndex=null,t.hasPlayed_=i.hasPlayed,t.currentTime_=i.currentTime,t.seekable_=i.seekable,t.seeking_=i.seeking,t.duration_=i.duration,t.mediaSource_=i.mediaSource,t.hls_=i.hls,t.loaderType_=i.loaderType,t.startingMedia_=void 0,t.segmentMetadataTrack_=i.segmentMetadataTrack,t.goalBufferLength_=i.goalBufferLength,t.sourceType_=i.sourceType,t.inbandTextTracks_=i.inbandTextTracks,t.state_="INIT",t.checkBufferTimeout_=null,t.error_=void 0,t.currentTimeline_=-1,t.pendingSegment_=null,t.mimeType_=null,t.sourceUpdater_=null,t.xhrOptions_=null,t.activeInitSegmentId_=null,t.initSegments_={},t.cacheEncryptionKeys_=i.cacheEncryptionKeys,t.keyCache_={},t.loaderType_==="main"?t.captionParser_=new ZI:t.captionParser_=null,t.decrypter_=i.decrypter,t.syncController_=i.syncController,t.syncPoint_={segmentIndex:0,time:0},t.syncController_.on("syncinfoupdate",function(){return t.trigger("syncinfoupdate")}),t.mediaSource_.addEventListener("sourceopen",function(){return t.ended_=!1}),t.fetchAtBuffer_=!1,t.logger_=Tf("SegmentLoader["+t.loaderType_+"]"),Object.defineProperty(t,"state",{get:function(){return this.state_},set:function(a){a!==this.state_&&(this.logger_(this.state_+" -> "+a),this.state_=a)}}),t}return so(r,[{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.state="DISPOSED",this.pause(),this.abort_(),this.sourceUpdater_&&this.sourceUpdater_.dispose(),this.resetStats_(),this.captionParser_&&this.captionParser_.reset()}},{key:"abort",value:function(){if(this.state!=="WAITING"){this.pendingSegment_&&(this.pendingSegment_=null);return}this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()}},{key:"abort_",value:function(){this.pendingSegment_&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null}},{key:"error",value:function(t){return typeof t<"u"&&(this.error_=t),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():be.createTimeRanges()}},{key:"initSegment",value:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=mp(t),s=this.initSegments_[a];return e&&!s&&t.bytes&&(this.initSegments_[a]=s={resolvedUri:t.resolvedUri,byterange:t.byterange,bytes:t.bytes,timescales:t.timescales,videoTrackIds:t.videoTrackIds}),s||t}},{key:"segmentKey",value:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=yx(t),s=this.keyCache_[a];this.cacheEncryptionKeys_&&e&&!s&&t.bytes&&(this.keyCache_[a]=s={resolvedUri:t.resolvedUri,bytes:t.bytes});var o={resolvedUri:(s||t).resolvedUri};return s&&(o.bytes=s.bytes),o}},{key:"couldBeginLoading_",value:function(){return this.playlist_&&(this.sourceUpdater_||this.mimeType_&&this.state==="INIT")&&!this.paused()}},{key:"load",value:function(){if(this.monitorBuffer_(),!!this.playlist_){if(this.syncController_.setDateTimeMapping(this.playlist_),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||this.state!=="READY"&&this.state!=="INIT"||(this.state="READY")}}},{key:"init_",value:function(){return this.state="READY",this.sourceUpdater_=new uM(this.mediaSource_,this.mimeType_,this.loaderType_,this.sourceBufferEmitter_),this.resetEverything(),this.monitorBuffer_()}},{key:"playlist",value:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!!t){var a=this.playlist_,s=this.pendingSegment_;this.playlist_=t,this.xhrOptions_=e,this.hasPlayed_()||(t.syncInfo={mediaSequence:t.mediaSequence,time:0});var o=null;if(a&&(a.id?o=a.id:a.uri&&(o=a.uri)),this.logger_("playlist update ["+o+" => "+(t.id||t.uri)+"]"),this.trigger("syncinfoupdate"),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();if(!a||a.uri!==t.uri){this.mediaIndex!==null&&this.resyncLoader();return}var u=t.mediaSequence-a.mediaSequence;this.logger_("live window shift ["+u+"]"),this.mediaIndex!==null&&(this.mediaIndex-=u),s&&(s.mediaIndex-=u,s.mediaIndex>=0&&(s.segment=t.segments[s.mediaIndex])),this.syncController_.saveExpiredSegmentInfo(a,t)}}},{key:"pause",value:function(){this.checkBufferTimeout_&&(tt.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}},{key:"paused",value:function(){return this.checkBufferTimeout_===null}},{key:"mimeType",value:function(t,e){this.mimeType_||(this.mimeType_=t,this.sourceBufferEmitter_=e,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_())}},{key:"resetEverything",value:function(t){this.ended_=!1,this.resetLoader(),this.remove(0,this.duration_(),t),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(t,e,a){if(this.sourceUpdater_&&this.sourceUpdater_.remove(t,e,a),Uc(t,e,this.segmentMetadataTrack_),this.inbandTextTracks_)for(var s in this.inbandTextTracks_)Uc(t,e,this.inbandTextTracks_[s])}},{key:"monitorBuffer_",value:function(){this.checkBufferTimeout_&&tt.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=tt.setTimeout(this.monitorBufferTick_.bind(this),1)}},{key:"monitorBufferTick_",value:function(){this.state==="READY"&&this.fillBuffer_(),this.checkBufferTimeout_&&tt.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=tt.setTimeout(this.monitorBufferTick_.bind(this),AM)}},{key:"fillBuffer_",value:function(){if(!this.sourceUpdater_.updating()){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){if(this.isEndOfStream_(t.mediaIndex)){this.endOfStream();return}t.mediaIndex===this.playlist_.segments.length-1&&this.mediaSource_.readyState==="ended"&&!this.seeking_()||(t.timeline!==this.currentTimeline_&&(this.syncController_.reset(),t.timestampOffset=t.startOfSegment,this.captionParser_&&this.captionParser_.clearAllCaptions()),this.loadSegment_(t))}}}},{key:"isEndOfStream_",value:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.playlist_;return CM(e,this.mediaSource_,t)&&!this.sourceUpdater_.updating()}},{key:"checkBuffer_",value:function(t,e,a,s,o,u){var l=0,d=void 0;t.length&&(l=t.end(t.length-1));var c=Math.max(0,l-o);if(!e.segments.length||c>=this.goalBufferLength_()||!s&&c>=1)return null;if(u===null)return a=this.getSyncSegmentCandidate_(e),this.generateSegmentInfo_(e,a,null,!0);if(a!==null)return e.segments[a],d=l,this.generateSegmentInfo_(e,a+1,d,!1);if(this.fetchAtBuffer_){var f=ns.getMediaInfoForTime(e,l,u.segmentIndex,u.time);a=f.mediaIndex,d=f.startTime}else{var h=ns.getMediaInfoForTime(e,o,u.segmentIndex,u.time);a=h.mediaIndex,d=h.startTime}return this.generateSegmentInfo_(e,a,d,!1)}},{key:"getSyncSegmentCandidate_",value:function(t){var e=this;if(this.currentTimeline_===-1)return 0;var a=t.segments.map(function(s,o){return{timeline:s.timeline,segmentIndex:o}}).filter(function(s){return s.timeline===e.currentTimeline_});return a.length?a[Math.min(a.length-1,1)].segmentIndex:Math.max(t.segments.length-1,0)}},{key:"generateSegmentInfo_",value:function(t,e,a,s){if(e<0||e>=t.segments.length)return null;var o=t.segments[e];return{requestId:"segment-loader-"+Math.random(),uri:o.resolvedUri,mediaIndex:e,isSyncRequest:s,startOfSegment:a,playlist:t,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:o.timeline,duration:o.duration,segment:o}}},{key:"abortRequestEarly_",value:function(t){if(this.hls_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH||Date.now()-(t.firstBytesReceivedAt||Date.now())<1e3)return!1;var e=this.currentTime_(),a=t.bandwidth,s=this.pendingSegment_.duration,o=ns.estimateSegmentRequestTime(s,a,this.playlist_,t.bytesReceived),u=U2(this.buffered_(),e,this.hls_.tech_.playbackRate())-1;if(o<=u)return!1;var l=bM({master:this.hls_.playlists.master,currentTime:e,bandwidth:a,duration:this.duration_(),segmentDuration:s,timeUntilRebuffer:u,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!!l){var d=o-u,c=d-l.rebufferingImpact,f=.5;return u<=yp&&(f=1),!l.playlist||l.playlist.uri===this.playlist_.uri||c<f?!1:(this.bandwidth=l.playlist.attributes.BANDWIDTH*Ts.BANDWIDTH_VARIANCE+1,this.abort(),this.trigger("earlyabort"),!0)}}},{key:"handleProgress_",value:function(t,e){!this.pendingSegment_||e.requestId!==this.pendingSegment_.requestId||this.abortRequestEarly_(e.stats)||this.trigger("progress")}},{key:"loadSegment_",value:function(t){this.state="WAITING",this.pendingSegment_=t,this.trimBackBuffer_(t),t.abortRequests=mM(this.hls_.xhr,this.xhrOptions_,this.decrypter_,this.captionParser_,this.createSimplifiedSegmentObj_(t),this.handleProgress_.bind(this),this.segmentRequestFinished_.bind(this))}},{key:"trimBackBuffer_",value:function(t){var e=kM(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);e>0&&this.remove(0,e)}},{key:"createSimplifiedSegmentObj_",value:function(t){var e=t.segment,a={resolvedUri:e.resolvedUri,byterange:e.byterange,requestId:t.requestId};if(e.key){var s=e.key.iv||new Uint32Array([0,0,0,t.mediaIndex+t.playlist.mediaSequence]);a.key=this.segmentKey(e.key),a.key.iv=s}return e.map&&(a.map=this.initSegment(e.map)),a}},{key:"segmentRequestFinished_",value:function(t,e){if(this.mediaRequests+=1,e.stats&&(this.mediaBytesTransferred+=e.stats.bytesReceived,this.mediaTransferDuration+=e.stats.roundTripTime),!this.pendingSegment_){this.mediaRequestsAborted+=1;return}if(e.requestId===this.pendingSegment_.requestId){if(t){if(this.pendingSegment_=null,this.state="READY",t.code===zu.ABORTED){this.mediaRequestsAborted+=1;return}if(this.pause(),t.code===zu.TIMEOUT){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger("bandwidthupdate");return}this.mediaRequestsErrored+=1,this.error(t),this.trigger("error");return}this.bandwidth=e.stats.bandwidth,this.roundTrip=e.stats.roundTripTime,e.map&&(e.map=this.initSegment(e.map,!0)),e.key&&this.segmentKey(e.key,!0),this.processSegmentResponse_(e)}}},{key:"processSegmentResponse_",value:function(t){var e=this.pendingSegment_;e.bytes=t.bytes,t.map&&(e.segment.map.bytes=t.map.bytes),e.endOfAllRequests=t.endOfAllRequests,t.fmp4Captions&&(EM(this.inbandTextTracks_,this.hls_.tech_,t.captionStreams),xM({inbandTextTracks:this.inbandTextTracks_,captionArray:t.fmp4Captions,timestampOffset:0}),this.captionParser_&&this.captionParser_.clearParsedCaptions()),this.handleSegment_()}},{key:"handleSegment_",value:function(){var t=this;if(!this.pendingSegment_){this.state="READY";return}var e=this.pendingSegment_,a=e.segment,s=this.syncController_.probeSegmentInfo(e);typeof this.startingMedia_>"u"&&s&&(s.containsAudio||s.containsVideo)&&(this.startingMedia_={containsAudio:s.containsAudio,containsVideo:s.containsVideo});var o=wM(this.loaderType_,this.startingMedia_,s);if(o){this.error({message:o,blacklistDuration:1/0}),this.trigger("error");return}if(e.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}if(e.timestampOffset!==null&&e.timestampOffset!==this.sourceUpdater_.timestampOffset()){if(s&&s.segmentTimestampInfo){var u=s.segmentTimestampInfo[0].ptsTime,l=s.segmentTimestampInfo[0].dtsTime;e.timestampOffset-=u-l}this.sourceUpdater_.timestampOffset(e.timestampOffset),this.trigger("timestampoffset")}var d=this.syncController_.mappingForTimeline(e.timeline);if(d!==null&&this.trigger({type:"segmenttimemapping",mapping:d}),this.state="APPENDING",a.map){var c=mp(a.map);if(!this.activeInitSegmentId_||this.activeInitSegmentId_!==c){var f=this.initSegment(a.map);this.sourceUpdater_.appendBuffer({bytes:f.bytes},function(){t.activeInitSegmentId_=c})}}e.byteLength=e.bytes.byteLength,typeof a.start=="number"&&typeof a.end=="number"?this.mediaSecondsLoaded+=a.end-a.start:this.mediaSecondsLoaded+=a.duration,this.logger_(DM(e)),this.sourceUpdater_.appendBuffer({bytes:e.bytes,videoSegmentTimingInfoCallback:this.handleVideoSegmentTimingInfo_.bind(this,e.requestId)},this.handleUpdateEnd_.bind(this))}},{key:"handleVideoSegmentTimingInfo_",value:function(t,e){if(!(!this.pendingSegment_||t!==this.pendingSegment_.requestId)){var a=this.pendingSegment_.segment;a.videoTimingInfo||(a.videoTimingInfo={}),a.videoTimingInfo.transmuxerPrependedSeconds=e.videoSegmentTimingInfo.prependedContentDuration||0,a.videoTimingInfo.transmuxedPresentationStart=e.videoSegmentTimingInfo.start.presentation,a.videoTimingInfo.transmuxedPresentationEnd=e.videoSegmentTimingInfo.end.presentation,a.videoTimingInfo.baseMediaDecodeTime=e.videoSegmentTimingInfo.baseMediaDecodeTime}}},{key:"handleUpdateEnd_",value:function(){if(!this.pendingSegment_){this.state="READY",this.paused()||this.monitorBuffer_();return}var t=this.pendingSegment_,e=t.segment,a=this.mediaIndex!==null;if(this.pendingSegment_=null,this.recordThroughput_(t),this.addSegmentMetadataCue_(t),this.state="READY",this.mediaIndex=t.mediaIndex,this.fetchAtBuffer_=!0,this.currentTimeline_=t.timeline,this.trigger("syncinfoupdate"),e.end&&this.currentTime_()-e.end>t.playlist.targetDuration*3){this.resetEverything();return}a&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.isEndOfStream_(t.mediaIndex+1,t.playlist)&&this.endOfStream(),this.paused()||this.monitorBuffer_()}},{key:"recordThroughput_",value:function(t){var e=this.throughput.rate,a=Date.now()-t.endOfAllRequests+1,s=Math.floor(t.byteLength/a*8*1e3);this.throughput.rate+=(s-e)/++this.throughput.count}},{key:"addSegmentMetadataCue_",value:function(t){if(!!this.segmentMetadataTrack_){var e=t.segment,a=e.start,s=e.end;if(!(!Vx(a)||!Vx(s))){Uc(a,s,this.segmentMetadataTrack_);var o=tt.WebKitDataCue||tt.VTTCue,u={custom:e.custom,dateTimeObject:e.dateTimeObject,dateTimeString:e.dateTimeString,bandwidth:t.playlist.attributes.BANDWIDTH,resolution:t.playlist.attributes.RESOLUTION,codecs:t.playlist.attributes.CODECS,byteLength:t.byteLength,uri:t.uri,timeline:t.timeline,playlist:t.playlist.uri,start:a,end:s},l=JSON.stringify(u),d=new o(a,s,l);d.value=u,this.segmentMetadataTrack_.addCue(d)}}}}]),r}(be.EventTarget),Gx=function(r){return decodeURIComponent(escape(String.fromCharCode.apply(null,r)))},qx=new Uint8Array(`
|
103
103
|
|
104
|
-
`.split("").map(function(n){return n.charCodeAt(0)})),PM=function(n){ou(r,n);function r(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Gs(this,r);var e=ko(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,i,t));return e.mediaSource_=null,e.subtitlesTrack_=null,e}return so(r,[{key:"buffered_",value:function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return be.createTimeRanges();var t=this.subtitlesTrack_.cues,e=t[0].startTime,a=t[t.length-1].startTime;return be.createTimeRanges([[e,a]])}},{key:"initSegment",value:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=mp(t),s=this.initSegments_[a];if(e&&!s&&t.bytes){var o=qx.byteLength+t.bytes.byteLength,u=new Uint8Array(o);u.set(t.bytes),u.set(qx,t.bytes.byteLength),this.initSegments_[a]=s={resolvedUri:t.resolvedUri,byterange:t.byterange,bytes:u}}return s||t}},{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(t){return typeof t>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=t,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}},{key:"remove",value:function(t,e){Uc(t,e,this.subtitlesTrack_)}},{key:"fillBuffer_",value:function(){var t=this;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_);if(e=this.skipEmptySegments_(e),!!e){if(this.syncController_.timestampOffsetForTimeline(e.timeline)===null){var a=function(){t.state="READY",t.paused()||t.monitorBuffer_()};this.syncController_.one("timestampoffset",a),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(e)}}},{key:"skipEmptySegments_",value:function(t){for(;t&&t.segment.empty;)t=this.generateSegmentInfo_(t.playlist,t.mediaIndex+1,t.startOfSegment+t.duration,t.isSyncRequest);return t}},{key:"handleSegment_",value:function(){var t=this;if(!this.pendingSegment_||!this.subtitlesTrack_){this.state="READY";return}this.state="APPENDING";var e=this.pendingSegment_,a=e.segment;if(typeof tt.WebVTT!="function"&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var s=void 0,o=function(){t.subtitlesTrack_.tech_.off("vttjsloaded",s),t.error({message:"Error loading vtt.js"}),t.state="READY",t.pause(),t.trigger("error")};s=function(){t.subtitlesTrack_.tech_.off("vttjserror",o),t.handleSegment_()},this.state="WAITING_ON_VTTJS",this.subtitlesTrack_.tech_.one("vttjsloaded",s),this.subtitlesTrack_.tech_.one("vttjserror",o);return}a.requested=!0;try{this.parseVTTCues_(e)}catch(u){return this.error({message:u.message}),this.state="READY",this.pause(),this.trigger("error")}if(this.updateTimeMapping_(e,this.syncController_.timelines[e.timeline],this.playlist_),e.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}e.byteLength=e.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,e.cues.length&&this.remove(e.cues[0].endTime,e.cues[e.cues.length-1].endTime),e.cues.forEach(function(u){t.subtitlesTrack_.addCue(u)}),this.handleUpdateEnd_()}},{key:"parseVTTCues_",value:function(t){var e=void 0,a=!1;typeof tt.TextDecoder=="function"?e=new tt.TextDecoder("utf8"):(e=tt.WebVTT.StringDecoder(),a=!0);var s=new tt.WebVTT.Parser(tt,tt.vttjs,e);if(t.cues=[],t.timestampmap={MPEGTS:0,LOCAL:0},s.oncue=t.cues.push.bind(t.cues),s.ontimestampmap=function(l){return t.timestampmap=l},s.onparsingerror=function(l){be.log.warn("Error encountered when parsing cues: "+l.message)},t.segment.map){var o=t.segment.map.bytes;a&&(o=Gx(o)),s.parse(o)}var u=t.bytes;a&&(u=Gx(u)),s.parse(u),s.flush()}},{key:"updateTimeMapping_",value:function(t,e,a){var s=t.segment;if(!!e){if(!t.cues.length){s.empty=!0;return}var o=t.timestampmap,u=o.MPEGTS/9e4-o.LOCAL+e.mapping;if(t.cues.forEach(function(c){c.startTime+=u,c.endTime+=u}),!a.syncInfo){var l=t.cues[0].startTime,d=t.cues[t.cues.length-1].startTime;a.syncInfo={mediaSequence:a.mediaSequence+t.mediaIndex,time:Math.min(l,d-s.duration)}}}}}]),r}(y0),RM=function(r,i){for(var t=r.cues,e=0;e<t.length;e++){var a=t[e];if(i>=a.adStartTime&&i<=a.adEndTime)return a}return null},IM=function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!!r.segments)for(var e=t,a=void 0,s=0;s<r.segments.length;s++){var o=r.segments[s];if(a||(a=RM(i,e+o.duration/2)),a){if("cueIn"in o){a.endTime=e,a.adEndTime=e,e+=o.duration,a=null;continue}if(e<a.endTime){e+=o.duration;continue}a.endTime+=o.duration}else if("cueOut"in o&&(a=new tt.VTTCue(e,e+o.duration,o.cueOut),a.adStartTime=e,a.adEndTime=e+parseFloat(o.cueOut),i.addCue(a)),"cueOutCont"in o){var u=void 0,l=void 0,d=o.cueOutCont.split("/").map(parseFloat),c=s2(d,2);u=c[0],l=c[1],a=new tt.VTTCue(e,e+o.duration,""),a.adStartTime=e-u,a.adEndTime=a.adStartTime+l,i.addCue(a)}e+=o.duration}},OM=CO.inspect,Wx=[{name:"VOD",run:function(r,i,t,e,a){if(t!==1/0){var s={time:0,segmentIndex:0};return s}return null}},{name:"ProgramDateTime",run:function(r,i,t,e,a){if(!r.datetimeToDisplayTime)return null;var s=i.segments||[],o=null,u=null;a=a||0;for(var l=0;l<s.length;l++){var d=s[l];if(d.dateTimeObject){var c=d.dateTimeObject.getTime()/1e3,f=c+r.datetimeToDisplayTime,h=Math.abs(a-f);if(u!==null&&(h===0||u<h))break;u=h,o={time:f,segmentIndex:l}}}return o}},{name:"Segment",run:function(r,i,t,e,a){var s=i.segments||[],o=null,u=null;a=a||0;for(var l=0;l<s.length;l++){var d=s[l];if(d.timeline===e&&typeof d.start<"u"){var c=Math.abs(a-d.start);if(u!==null&&u<c)break;(!o||u===null||u>=c)&&(u=c,o={time:d.start,segmentIndex:l})}}return o}},{name:"Discontinuity",run:function(r,i,t,e,a){var s=null;if(a=a||0,i.discontinuityStarts&&i.discontinuityStarts.length)for(var o=null,u=0;u<i.discontinuityStarts.length;u++){var l=i.discontinuityStarts[u],d=i.discontinuitySequence+u+1,c=r.discontinuities[d];if(c){var f=Math.abs(a-c.time);if(o!==null&&o<f)break;(!s||o===null||o>=f)&&(o=f,s={time:c.time,segmentIndex:l})}}return s}},{name:"Playlist",run:function(r,i,t,e,a){if(i.syncInfo){var s={time:i.syncInfo.time,segmentIndex:i.syncInfo.mediaSequence-i.mediaSequence};return s}return null}}],LM=function(n){ou(r,n);function r(){Gs(this,r);var i=ko(this,(r.__proto__||Object.getPrototypeOf(r)).call(this));return i.inspectCache_=void 0,i.timelines=[],i.discontinuities=[],i.datetimeToDisplayTime=null,i.logger_=Tf("SyncController"),i}return so(r,[{key:"getSyncPoint",value:function(t,e,a,s){var o=this.runStrategies_(t,e,a,s);return o.length?this.selectSyncPoint_(o,{key:"time",value:s}):null}},{key:"getExpiredTime",value:function(t,e){if(!t||!t.segments)return null;var a=this.runStrategies_(t,e,t.discontinuitySequence,0);if(!a.length)return null;var s=this.selectSyncPoint_(a,{key:"segmentIndex",value:0});return s.segmentIndex>0&&(s.time*=-1),Math.abs(s.time+mf(t,s.segmentIndex,0))}},{key:"runStrategies_",value:function(t,e,a,s){for(var o=[],u=0;u<Wx.length;u++){var l=Wx[u],d=l.run(this,t,e,a,s);d&&(d.strategy=l.name,o.push({strategy:l.name,syncPoint:d}))}return o}},{key:"selectSyncPoint_",value:function(t,e){for(var a=t[0].syncPoint,s=Math.abs(t[0].syncPoint[e.key]-e.value),o=t[0].strategy,u=1;u<t.length;u++){var l=Math.abs(t[u].syncPoint[e.key]-e.value);l<s&&(s=l,a=t[u].syncPoint,o=t[u].strategy)}return this.logger_("syncPoint for ["+e.key+": "+e.value+"] chosen with strategy"+(" ["+o+"]: [time:"+a.time+",")+(" segmentIndex:"+a.segmentIndex+"]")),a}},{key:"saveExpiredSegmentInfo",value:function(t,e){for(var a=e.mediaSequence-t.mediaSequence,s=a-1;s>=0;s--){var o=t.segments[s];if(o&&typeof o.start<"u"){e.syncInfo={mediaSequence:t.mediaSequence+s,time:o.start},this.logger_("playlist refresh sync: [time:"+e.syncInfo.time+","+(" mediaSequence: "+e.syncInfo.mediaSequence+"]")),this.trigger("syncinfoupdate");break}}}},{key:"setDateTimeMapping",value:function(t){if(!this.datetimeToDisplayTime&&t.segments&&t.segments.length&&t.segments[0].dateTimeObject){var e=t.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-e}}},{key:"reset",value:function(){this.inspectCache_=void 0}},{key:"probeSegmentInfo",value:function(t){var e=t.segment,a=t.playlist,s=void 0;return e.map?s=this.probeMp4Segment_(t):s=this.probeTsSegment_(t),s&&this.calculateSegmentTimeMapping_(t,s)&&(this.saveDiscontinuitySyncInfo_(t),a.syncInfo||(a.syncInfo={mediaSequence:a.mediaSequence+t.mediaIndex,time:e.start})),s}},{key:"probeMp4Segment_",value:function(t){var e=t.segment,a=Fh.timescale(e.map.bytes),s=Fh.startTime(a,t.bytes);return t.timestampOffset!==null&&(t.timestampOffset-=s),{start:s,end:s+e.duration}}},{key:"probeTsSegment_",value:function(t){var e=OM(t.bytes,this.inspectCache_),a=void 0,s=void 0,o=void 0;if(!e)return null;e.video&&e.video.length===2?(this.inspectCache_=e.video[1].dts,a=e.video[0].dtsTime,s=e.video[1].dtsTime,o=e.video):e.audio&&e.audio.length===2&&(this.inspectCache_=e.audio[1].dts,a=e.audio[0].dtsTime,s=e.audio[1].dtsTime,o=e.audio);var u={segmentTimestampInfo:o,start:a,end:s,containsVideo:e.video&&e.video.length===2,containsAudio:e.audio&&e.audio.length===2};return u}},{key:"timestampOffsetForTimeline",value:function(t){return typeof this.timelines[t]>"u"?null:this.timelines[t].time}},{key:"mappingForTimeline",value:function(t){return typeof this.timelines[t]>"u"?null:this.timelines[t].mapping}},{key:"calculateSegmentTimeMapping_",value:function(t,e){var a=t.segment,s=this.timelines[t.timeline];if(t.timestampOffset!==null)s={time:t.startOfSegment,mapping:t.startOfSegment-e.start},this.timelines[t.timeline]=s,this.trigger("timestampoffset"),this.logger_("time mapping for timeline "+t.timeline+": "+("[time: "+s.time+"] [mapping: "+s.mapping+"]")),a.start=t.startOfSegment,a.end=e.end+s.mapping;else if(s)a.start=e.start+s.mapping,a.end=e.end+s.mapping;else return!1;return!0}},{key:"saveDiscontinuitySyncInfo_",value:function(t){var e=t.playlist,a=t.segment;if(a.discontinuity)this.discontinuities[a.timeline]={time:a.start,accuracy:0};else if(e.discontinuityStarts&&e.discontinuityStarts.length)for(var s=0;s<e.discontinuityStarts.length;s++){var o=e.discontinuityStarts[s],u=e.discontinuitySequence+s+1,l=o-t.mediaIndex,d=Math.abs(l);if(!this.discontinuities[u]||this.discontinuities[u].accuracy>d){var c=void 0;l<0?c=a.start-mf(e,t.mediaIndex,o):c=a.end+mf(e,t.mediaIndex+1,o),this.discontinuities[u]={time:c,accuracy:d}}}}}]),r}(be.EventTarget),MM=new Cx("./decrypter-worker.worker.js",function(n,r){var i=this;(function(){function t(T){return T.subarray(0,T.byteLength-T[T.byteLength-1])}var e=function(b,E){if(!(b instanceof E))throw new TypeError("Cannot call a class as a function")},a=function(){function T(b,E){for(var C=0;C<E.length;C++){var x=E[C];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(b,x.key,x)}}return function(b,E,C){return E&&T(b.prototype,E),C&&T(b,C),b}}(),s=function(b,E){if(typeof E!="function"&&E!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof E);b.prototype=Object.create(E&&E.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),E&&(Object.setPrototypeOf?Object.setPrototypeOf(b,E):b.__proto__=E)},o=function(b,E){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return E&&(typeof E=="object"||typeof E=="function")?E:b},u=function(){var b=[[[],[],[],[],[]],[[],[],[],[],[]]],E=b[0],C=b[1],x=E[4],S=C[4],w=void 0,k=void 0,P=void 0,R=[],N=[],G=void 0,I=void 0,M=void 0,B=void 0,q=void 0,Z=void 0;for(w=0;w<256;w++)N[(R[w]=w<<1^(w>>7)*283)^w]=w;for(k=P=0;!x[k];k^=G||1,P=N[P]||1)for(B=P^P<<1^P<<2^P<<3^P<<4,B=B>>8^B&255^99,x[k]=B,S[B]=k,M=R[I=R[G=R[k]]],Z=M*16843009^I*65537^G*257^k*16843008,q=R[B]*257^B*16843008,w=0;w<4;w++)E[w][k]=q=q<<24^q>>>8,C[w][B]=Z=Z<<24^Z>>>8;for(w=0;w<5;w++)E[w]=E[w].slice(0),C[w]=C[w].slice(0);return b},l=null,d=function(){function T(b){e(this,T),l||(l=u()),this._tables=[[l[0][0].slice(),l[0][1].slice(),l[0][2].slice(),l[0][3].slice(),l[0][4].slice()],[l[1][0].slice(),l[1][1].slice(),l[1][2].slice(),l[1][3].slice(),l[1][4].slice()]];var E=void 0,C=void 0,x=void 0,S=void 0,w=void 0,k=this._tables[0][4],P=this._tables[1],R=b.length,N=1;if(R!==4&&R!==6&&R!==8)throw new Error("Invalid aes key size");for(S=b.slice(0),w=[],this._key=[S,w],E=R;E<4*R+28;E++)x=S[E-1],(E%R===0||R===8&&E%R===4)&&(x=k[x>>>24]<<24^k[x>>16&255]<<16^k[x>>8&255]<<8^k[x&255],E%R===0&&(x=x<<8^x>>>24^N<<24,N=N<<1^(N>>7)*283)),S[E]=S[E-R]^x;for(C=0;E;C++,E--)x=S[C&3?E:E-4],E<=4||C<4?w[C]=x:w[C]=P[0][k[x>>>24]]^P[1][k[x>>16&255]]^P[2][k[x>>8&255]]^P[3][k[x&255]]}return T.prototype.decrypt=function(E,C,x,S,w,k){var P=this._key[1],R=E^P[0],N=S^P[1],G=x^P[2],I=C^P[3],M=void 0,B=void 0,q=void 0,Z=P.length/4-2,re=void 0,oe=4,ae=this._tables[1],ne=ae[0],ye=ae[1],Pe=ae[2],$e=ae[3],ft=ae[4];for(re=0;re<Z;re++)M=ne[R>>>24]^ye[N>>16&255]^Pe[G>>8&255]^$e[I&255]^P[oe],B=ne[N>>>24]^ye[G>>16&255]^Pe[I>>8&255]^$e[R&255]^P[oe+1],q=ne[G>>>24]^ye[I>>16&255]^Pe[R>>8&255]^$e[N&255]^P[oe+2],I=ne[I>>>24]^ye[R>>16&255]^Pe[N>>8&255]^$e[G&255]^P[oe+3],oe+=4,R=M,N=B,G=q;for(re=0;re<4;re++)w[(3&-re)+k]=ft[R>>>24]<<24^ft[N>>16&255]<<16^ft[G>>8&255]<<8^ft[I&255]^P[oe++],M=R,R=N,N=G,G=I,I=M},T}(),c=function(){function T(){e(this,T),this.listeners={}}return T.prototype.on=function(E,C){this.listeners[E]||(this.listeners[E]=[]),this.listeners[E].push(C)},T.prototype.off=function(E,C){if(!this.listeners[E])return!1;var x=this.listeners[E].indexOf(C);return this.listeners[E].splice(x,1),x>-1},T.prototype.trigger=function(E){var C=this.listeners[E];if(!!C)if(arguments.length===2)for(var x=C.length,S=0;S<x;++S)C[S].call(this,arguments[1]);else for(var w=Array.prototype.slice.call(arguments,1),k=C.length,P=0;P<k;++P)C[P].apply(this,w)},T.prototype.dispose=function(){this.listeners={}},T.prototype.pipe=function(E){this.on("data",function(C){E.push(C)})},T}(),f=function(T){s(b,T);function b(){e(this,b);var E=o(this,T.call(this,c));return E.jobs=[],E.delay=1,E.timeout_=null,E}return b.prototype.processJob_=function(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null},b.prototype.push=function(C){this.jobs.push(C),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))},b}(c),h=function(b){return b<<24|(b&65280)<<8|(b&16711680)>>8|b>>>24},g=function(b,E,C){var x=new Int32Array(b.buffer,b.byteOffset,b.byteLength>>2),S=new d(Array.prototype.slice.call(E)),w=new Uint8Array(b.byteLength),k=new Int32Array(w.buffer),P=void 0,R=void 0,N=void 0,G=void 0,I=void 0,M=void 0,B=void 0,q=void 0,Z=void 0;for(P=C[0],R=C[1],N=C[2],G=C[3],Z=0;Z<x.length;Z+=4)I=h(x[Z]),M=h(x[Z+1]),B=h(x[Z+2]),q=h(x[Z+3]),S.decrypt(I,M,B,q,k,Z),k[Z]=h(k[Z]^P),k[Z+1]=h(k[Z+1]^R),k[Z+2]=h(k[Z+2]^N),k[Z+3]=h(k[Z+3]^G),P=I,R=M,N=B,G=q;return w},p=function(){function T(b,E,C,x){e(this,T);var S=T.STEP,w=new Int32Array(b.buffer),k=new Uint8Array(b.byteLength),P=0;for(this.asyncStream_=new f,this.asyncStream_.push(this.decryptChunk_(w.subarray(P,P+S),E,C,k)),P=S;P<w.length;P+=S)C=new Uint32Array([h(w[P-4]),h(w[P-3]),h(w[P-2]),h(w[P-1])]),this.asyncStream_.push(this.decryptChunk_(w.subarray(P,P+S),E,C,k));this.asyncStream_.push(function(){x(null,t(k))})}return T.prototype.decryptChunk_=function(E,C,x,S){return function(){var w=g(E,C,x);S.set(w,E.byteOffset)}},a(T,null,[{key:"STEP",get:function(){return 32e3}}]),T}(),v=function(b){var E={};return Object.keys(b).forEach(function(C){var x=b[C];ArrayBuffer.isView(x)?E[C]={bytes:x.buffer,byteOffset:x.byteOffset,byteLength:x.byteLength}:E[C]=x}),E},y=function(b){b.onmessage=function(E){var C=E.data,x=new Uint8Array(C.encrypted.bytes,C.encrypted.byteOffset,C.encrypted.byteLength),S=new Uint32Array(C.key.bytes,C.key.byteOffset,C.key.byteLength/4),w=new Uint32Array(C.iv.bytes,C.iv.byteOffset,C.iv.byteLength/4);new p(x,S,w,function(k,P){b.postMessage(v({source:C.source,decrypted:P}),[P.buffer])})}},m=new y(i);return m})()}),FM=function(r){var i=r.default?"main":"alternative";return r.characteristics&&r.characteristics.indexOf("public.accessibility.describes-video")>=0&&(i="main-desc"),i},Tp=function(r,i){r.abort(),r.pause(),i&&i.activePlaylistLoader&&(i.activePlaylistLoader.pause(),i.activePlaylistLoader=null)},_0=function(r,i){i.activePlaylistLoader=r,r.load()},NM=function(r,i){return function(){var t=i.segmentLoaders,e=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),u=s.activeGroup(o),l=s.activePlaylistLoader;if(Tp(e,s),!!u){if(!u.playlistLoader){l&&a.resetEverything();return}e.resyncLoader(),_0(u.playlistLoader,s)}}},BM=function(r,i){return function(){var t=i.segmentLoaders,e=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),u=s.activeGroup(o),l=s.activePlaylistLoader;if(Tp(e,s),!!u){if(!u.playlistLoader){a.resetEverything();return}if(l===u.playlistLoader){_0(u.playlistLoader,s);return}e.track&&e.track(o),e.resetEverything(),_0(u.playlistLoader,s)}}},bp={AUDIO:function(r,i){return function(){var t=i.segmentLoaders[r],e=i.mediaTypes[r],a=i.blacklistCurrentPlaylist;Tp(t,e);var s=e.activeTrack(),o=e.activeGroup(),u=(o.filter(function(c){return c.default})[0]||o[0]).id,l=e.tracks[u];if(s===l){a({message:"Problem encountered loading the default audio track."});return}be.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(var d in e.tracks)e.tracks[d].enabled=e.tracks[d]===l;e.onTrackChanged()}},SUBTITLES:function(r,i){return function(){var t=i.segmentLoaders[r],e=i.mediaTypes[r];be.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),Tp(t,e);var a=e.activeTrack();a&&(a.mode="disabled"),e.onTrackChanged()}}},Kx={AUDIO:function(r,i,t){if(!!i){var e=t.tech,a=t.requestOptions,s=t.segmentLoaders[r];i.on("loadedmetadata",function(){var o=i.media();s.playlist(o,a),(!e.paused()||o.endList&&e.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),e.paused()||s.load()}),i.on("error",bp[r](r,t))}},SUBTITLES:function(r,i,t){var e=t.tech,a=t.requestOptions,s=t.segmentLoaders[r],o=t.mediaTypes[r];i.on("loadedmetadata",function(){var u=i.media();s.playlist(u,a),s.track(o.activeTrack()),(!e.paused()||u.endList&&e.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),e.paused()||s.load()}),i.on("error",bp[r](r,t))}},UM={AUDIO:function(r,i){var t=i.hls,e=i.sourceType,a=i.segmentLoaders[r],s=i.requestOptions,o=i.master.mediaGroups,u=i.mediaTypes[r],l=u.groups,d=u.tracks,c=i.masterPlaylistLoader;(!o[r]||Object.keys(o[r]).length===0)&&(o[r]={main:{default:{default:!0}}});for(var f in o[r]){l[f]||(l[f]=[]);for(var h in o[r][f]){var g=o[r][f][h],p=void 0;if(g.resolvedUri?p=new gp(g.resolvedUri,t,s):g.playlists&&e==="dash"?p=new g0(g.playlists[0],t,s,c):p=null,g=be.mergeOptions({id:h,playlistLoader:p},g),Kx[r](r,g.playlistLoader,i),l[f].push(g),typeof d[h]>"u"){var v=new be.AudioTrack({id:h,kind:FM(g),enabled:!1,language:g.language,default:g.default,label:h});d[h]=v}}}a.on("error",bp[r](r,i))},SUBTITLES:function(r,i){var t=i.tech,e=i.hls,a=i.sourceType,s=i.segmentLoaders[r],o=i.requestOptions,u=i.master.mediaGroups,l=i.mediaTypes[r],d=l.groups,c=l.tracks,f=i.masterPlaylistLoader;for(var h in u[r]){d[h]||(d[h]=[]);for(var g in u[r][h])if(!u[r][h][g].forced){var p=u[r][h][g],v=void 0;if(a==="hls"?v=new gp(p.resolvedUri,e,o):a==="dash"&&(v=new g0(p.playlists[0],e,o,f)),p=be.mergeOptions({id:g,playlistLoader:v},p),Kx[r](r,p.playlistLoader,i),d[h].push(p),typeof c[g]>"u"){var y=t.addRemoteTextTrack({id:g,kind:"subtitles",default:p.default&&p.autoselect,language:p.language,label:g},!1).track;c[g]=y}}}s.on("error",bp[r](r,i))},"CLOSED-CAPTIONS":function(r,i){var t=i.tech,e=i.master.mediaGroups,a=i.mediaTypes[r],s=a.groups,o=a.tracks;for(var u in e[r]){s[u]||(s[u]=[]);for(var l in e[r][u]){var d=e[r][u][l];if(!!d.instreamId.match(/CC\d/)&&(s[u].push(be.mergeOptions({id:l},d)),typeof o[l]>"u")){var c=t.addRemoteTextTrack({id:d.instreamId,kind:"captions",default:d.default&&d.autoselect,language:d.language,label:l},!1).track;o[l]=c}}}}},jM=function(r,i){return function(t){var e=i.masterPlaylistLoader,a=i.mediaTypes[r].groups,s=e.media();if(!s)return null;var o=null;return s.attributes[r]&&(o=a[s.attributes[r]]),o=o||a.main,typeof t>"u"?o:t===null?null:o.filter(function(u){return u.id===t.id})[0]||null}},$M={AUDIO:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var e in t)if(t[e].enabled)return t[e];return null}},SUBTITLES:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var e in t)if(t[e].mode==="showing")return t[e];return null}}},HM=function(r){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(d){UM[d](d,r)});var i=r.mediaTypes,t=r.masterPlaylistLoader,e=r.tech,a=r.hls;["AUDIO","SUBTITLES"].forEach(function(d){i[d].activeGroup=jM(d,r),i[d].activeTrack=$M[d](d,r),i[d].onGroupChanged=NM(d,r),i[d].onTrackChanged=BM(d,r)});var s=i.AUDIO.activeGroup(),o=(s.filter(function(d){return d.default})[0]||s[0]).id;i.AUDIO.tracks[o].enabled=!0,i.AUDIO.onTrackChanged(),t.on("mediachange",function(){["AUDIO","SUBTITLES"].forEach(function(d){return i[d].onGroupChanged()})});var u=function(){i.AUDIO.onTrackChanged(),e.trigger({type:"usage",name:"hls-audio-change"})};e.audioTracks().addEventListener("change",u),e.remoteTextTracks().addEventListener("change",i.SUBTITLES.onTrackChanged),a.on("dispose",function(){e.audioTracks().removeEventListener("change",u),e.remoteTextTracks().removeEventListener("change",i.SUBTITLES.onTrackChanged)}),e.clearTracks("audio");for(var l in i.AUDIO.tracks)e.audioTracks().addTrack(i.AUDIO.tracks[l])},VM=function(){var r={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(i){r[i]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Vc,activeTrack:Vc,onGroupChanged:Vc,onTrackChanged:Vc}}),r},GM=60*2,Xu=void 0,qM=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],WM=function(r){return this.audioSegmentLoader_[r]+this.mainSegmentLoader_[r]},KM=function(n){ou(r,n);function r(i){Gs(this,r);var t=ko(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),e=i.url,a=i.handleManifestRedirects,s=i.withCredentials,o=i.tech,u=i.bandwidth,l=i.externHls,d=i.useCueTags,c=i.blacklistDuration,f=i.enableLowInitialPlaylist,h=i.sourceType,g=i.seekTo,p=i.cacheEncryptionKeys;if(!e)throw new Error("A non-empty playlist URL is required");Xu=l,t.withCredentials=s,t.tech_=o,t.hls_=o.hls,t.seekTo_=g,t.sourceType_=h,t.useCueTags_=d,t.blacklistDuration=c,t.enableLowInitialPlaylist=f,t.useCueTags_&&(t.cueTagsTrack_=t.tech_.addTextTrack("metadata","ad-cues"),t.cueTagsTrack_.inBandMetadataTrackDispatchType=""),t.requestOptions_={withCredentials:s,handleManifestRedirects:a,timeout:null},t.mediaTypes_=VM(),t.mediaSource=new be.MediaSource,t.mediaSource.addEventListener("sourceopen",t.handleSourceOpen_.bind(t)),t.seekable_=be.createTimeRanges(),t.hasPlayed_=function(){return!1},t.syncController_=new LM(i),t.segmentMetadataTrack_=o.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,t.decrypter_=new MM,t.inbandTextTracks_={};var v={hls:t.hls_,mediaSource:t.mediaSource,currentTime:t.tech_.currentTime.bind(t.tech_),seekable:function(){return t.seekable()},seeking:function(){return t.tech_.seeking()},duration:function(){return t.mediaSource.duration},hasPlayed:function(){return t.hasPlayed_()},goalBufferLength:function(){return t.goalBufferLength()},bandwidth:u,syncController:t.syncController_,decrypter:t.decrypter_,sourceType:t.sourceType_,inbandTextTracks:t.inbandTextTracks_,cacheEncryptionKeys:p};return t.masterPlaylistLoader_=t.sourceType_==="dash"?new g0(e,t.hls_,t.requestOptions_):new gp(e,t.hls_,t.requestOptions_),t.setupMasterPlaylistLoaderListeners_(),t.mainSegmentLoader_=new y0(be.mergeOptions(v,{segmentMetadataTrack:t.segmentMetadataTrack_,loaderType:"main"}),i),t.audioSegmentLoader_=new y0(be.mergeOptions(v,{loaderType:"audio"}),i),t.subtitleSegmentLoader_=new PM(be.mergeOptions(v,{loaderType:"vtt"}),i),t.setupSegmentLoaderListeners_(),qM.forEach(function(y){t[y+"_"]=WM.bind(t,y)}),t.logger_=Tf("MPC"),t.masterPlaylistLoader_.load(),t}return so(r,[{key:"setupMasterPlaylistLoaderListeners_",value:function(){var t=this;this.masterPlaylistLoader_.on("loadedmetadata",function(){var e=t.masterPlaylistLoader_.media(),a=e.targetDuration*1.5*1e3;o0(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,e.endList&&t.tech_.preload()!=="none"&&(t.mainSegmentLoader_.playlist(e,t.requestOptions_),t.mainSegmentLoader_.load()),HM({sourceType:t.sourceType_,segmentLoaders:{AUDIO:t.audioSegmentLoader_,SUBTITLES:t.subtitleSegmentLoader_,main:t.mainSegmentLoader_},tech:t.tech_,requestOptions:t.requestOptions_,masterPlaylistLoader:t.masterPlaylistLoader_,hls:t.hls_,master:t.master(),mediaTypes:t.mediaTypes_,blacklistCurrentPlaylist:t.blacklistCurrentPlaylist.bind(t)}),t.triggerPresenceUsage_(t.master(),e);try{t.setupSourceBuffers_()}catch(s){return be.log.warn("Failed to create SourceBuffers",s),t.mediaSource.endOfStream("decode")}t.setupFirstPlay(),!t.mediaTypes_.AUDIO.activePlaylistLoader||t.mediaTypes_.AUDIO.activePlaylistLoader.media()?t.trigger("selectedinitialmedia"):t.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",function(){t.trigger("selectedinitialmedia")})}),this.masterPlaylistLoader_.on("loadedplaylist",function(){var e=t.masterPlaylistLoader_.media();if(!e){t.excludeUnsupportedVariants_();var a=void 0;t.enableLowInitialPlaylist&&(a=t.selectInitialPlaylist()),a||(a=t.selectPlaylist()),t.initialMedia_=a,t.masterPlaylistLoader_.media(t.initialMedia_);return}if(t.useCueTags_&&t.updateAdCues_(e),t.mainSegmentLoader_.playlist(e,t.requestOptions_),t.updateDuration(),t.tech_.paused()||(t.mainSegmentLoader_.load(),t.audioSegmentLoader_&&t.audioSegmentLoader_.load()),!e.endList){var s=function(){var l=t.seekable();l.length!==0&&t.mediaSource.addSeekableRange_(l.start(0),l.end(0))};if(t.duration()!==1/0){var o=function u(){t.duration()===1/0?s():t.tech_.one("durationchange",u)};t.tech_.one("durationchange",o)}else s()}}),this.masterPlaylistLoader_.on("error",function(){t.blacklistCurrentPlaylist(t.masterPlaylistLoader_.error)}),this.masterPlaylistLoader_.on("mediachanging",function(){t.mainSegmentLoader_.abort(),t.mainSegmentLoader_.pause()}),this.masterPlaylistLoader_.on("mediachange",function(){var e=t.masterPlaylistLoader_.media(),a=e.targetDuration*1.5*1e3;o0(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,t.mainSegmentLoader_.playlist(e,t.requestOptions_),t.mainSegmentLoader_.load(),t.tech_.trigger({type:"mediachange",bubbles:!0})}),this.masterPlaylistLoader_.on("playlistunchanged",function(){var e=t.masterPlaylistLoader_.media(),a=t.stuckAtPlaylistEnd_(e);a&&(t.blacklistCurrentPlaylist({message:"Playlist no longer updating."}),t.tech_.trigger("playliststuck"))}),this.masterPlaylistLoader_.on("renditiondisabled",function(){t.tech_.trigger({type:"usage",name:"hls-rendition-disabled"})}),this.masterPlaylistLoader_.on("renditionenabled",function(){t.tech_.trigger({type:"usage",name:"hls-rendition-enabled"})})}},{key:"triggerPresenceUsage_",value:function(t,e){var a=t.mediaGroups||{},s=!0,o=Object.keys(a.AUDIO);for(var u in a.AUDIO)for(var l in a.AUDIO[u]){var d=a.AUDIO[u][l];d.uri||(s=!1)}s&&this.tech_.trigger({type:"usage",name:"hls-demuxed"}),Object.keys(a.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"hls-webvtt"}),Xu.Playlist.isAes(e)&&this.tech_.trigger({type:"usage",name:"hls-aes"}),Xu.Playlist.isFmp4(e)&&this.tech_.trigger({type:"usage",name:"hls-fmp4"}),o.length&&Object.keys(a.AUDIO[o[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 t=this;this.mainSegmentLoader_.on("bandwidthupdate",function(){var e=t.selectPlaylist(),a=t.masterPlaylistLoader_.media(),s=t.tech_.buffered(),o=s.length?s.end(s.length-1)-t.tech_.currentTime():0,u=t.bufferLowWaterLine();(!a.endList||t.duration()<Ts.MAX_BUFFER_LOW_WATER_LINE||e.attributes.BANDWIDTH<a.attributes.BANDWIDTH||o>=u)&&t.masterPlaylistLoader_.media(e),t.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("progress",function(){t.trigger("progress")}),this.mainSegmentLoader_.on("error",function(){t.blacklistCurrentPlaylist(t.mainSegmentLoader_.error())}),this.mainSegmentLoader_.on("syncinfoupdate",function(){t.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",function(){t.tech_.trigger({type:"usage",name:"hls-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",function(){t.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("ended",function(){t.onEndOfStream()}),this.mainSegmentLoader_.on("earlyabort",function(){t.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},GM)}),this.mainSegmentLoader_.on("reseteverything",function(){t.tech_.trigger("hls-reset")}),this.mainSegmentLoader_.on("segmenttimemapping",function(e){t.tech_.trigger({type:"hls-segment-time-mapping",mapping:e.mapping})}),this.audioSegmentLoader_.on("ended",function(){t.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 t=this.selectPlaylist();t!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(t),this.mainSegmentLoader_.resetLoader())}},{key:"fastQualityChange_",value:function(){var t=this,e=this.selectPlaylist();e!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(e),this.mainSegmentLoader_.resetEverything(function(){be.browser.IE_VERSION||be.browser.IS_EDGE?t.tech_.setCurrentTime(t.tech_.currentTime()+.04):t.tech_.setCurrentTime(t.tech_.currentTime())}))}},{key:"play",value:function(){if(!this.setupFirstPlay()){this.tech_.ended()&&this.seekTo_(0),this.hasPlayed_()&&this.load();var t=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<t.start(0))return this.seekTo_(t.end(t.length-1))}}},{key:"setupFirstPlay",value:function(){var t=this,e=this.masterPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_())return!1;if(!e.endList){var a=this.seekable();if(!a.length)return!1;if(be.browser.IE_VERSION&&this.tech_.readyState()===0)return this.tech_.one("loadedmetadata",function(){t.trigger("firstplay"),t.seekTo_(a.end(0)),t.hasPlayed_=function(){return!0}}),!1;this.trigger("firstplay"),this.seekTo_(a.end(0))}return this.hasPlayed_=function(){return!0},this.load(),!0}},{key:"handleSourceOpen_",value:function(){try{this.setupSourceBuffers_()}catch(e){return be.log.warn("Failed to create Source Buffers",e),this.mediaSource.endOfStream("decode")}if(this.tech_.autoplay()){var t=this.tech_.play();typeof t<"u"&&typeof t.then=="function"&&t.then(null,function(e){})}this.trigger("sourceopen")}},{key:"onEndOfStream",value:function(){var t=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(!this.mainSegmentLoader_.startingMedia_||this.mainSegmentLoader_.startingMedia_.containsVideo?t=t&&this.audioSegmentLoader_.ended_:t=this.audioSegmentLoader_.ended_),!!t){this.logger_("calling mediaSource.endOfStream()");try{this.mediaSource.endOfStream()}catch(e){be.log.warn("Failed to call media source endOfStream",e)}}}},{key:"stuckAtPlaylistEnd_",value:function(t){var e=this.seekable();if(!e.length)return!1;var a=this.syncController_.getExpiredTime(t,this.mediaSource.duration);if(a===null)return!1;var s=Xu.Playlist.playlistEnd(t,a),o=this.tech_.currentTime(),u=this.tech_.buffered();if(!u.length)return s-o<=uu;var l=u.end(u.length-1);return l-o<=uu&&s-l<=uu}},{key:"blacklistCurrentPlaylist",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments[1],a=void 0,s=void 0;if(a=t.playlist||this.masterPlaylistLoader_.media(),e=e||t.blacklistDuration||this.blacklistDuration,!a){this.error=t;try{return this.mediaSource.endOfStream("network")}catch{return this.trigger("error")}}var o=this.masterPlaylistLoader_.master.playlists.filter(vp).length===1,u=this.masterPlaylistLoader_.master.playlists;return u.length===1?(be.log.warn("Problem encountered with the current HLS playlist. Trying again since it is the only playlist."),this.tech_.trigger("retryplaylist"),this.masterPlaylistLoader_.load(o)):(o&&(be.log.warn("Removing all playlists from the blacklist because the last rendition is about to be blacklisted."),u.forEach(function(l){l.excludeUntil!==1/0&&delete l.excludeUntil}),this.tech_.trigger("retryplaylist")),a.excludeUntil=Date.now()+e*1e3,this.tech_.trigger("blacklistplaylist"),this.tech_.trigger({type:"usage",name:"hls-rendition-blacklisted"}),s=this.selectPlaylist(),be.log.warn("Problem encountered with the current HLS playlist."+(t.message?" "+t.message:"")+" Switching to another playlist."),this.masterPlaylistLoader_.media(s,o))}},{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(t){var e=Sx(this.tech_.buffered(),t);if(!(this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media())||!this.masterPlaylistLoader_.media().segments)return 0;if(e&&e.length)return t;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()),this.load()}},{key:"duration",value:function(){return this.masterPlaylistLoader_?this.mediaSource?this.mediaSource.duration:Xu.Playlist.duration(this.masterPlaylistLoader_.media()):0}},{key:"seekable",value:function(){return this.seekable_}},{key:"onSyncInfoUpdate_",value:function(){var t=void 0,e=void 0;if(!!this.masterPlaylistLoader_){var a=this.masterPlaylistLoader_.media();if(!!a){var s=this.syncController_.getExpiredTime(a,this.mediaSource.duration);if(s!==null&&(t=Xu.Playlist.seekable(a,s),t.length!==0&&!(this.mediaTypes_.AUDIO.activePlaylistLoader&&(a=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),s=this.syncController_.getExpiredTime(a,this.mediaSource.duration),s===null||(e=Xu.Playlist.seekable(a,s),e.length===0))))){var o=void 0,u=void 0;this.seekable_&&this.seekable_.length&&(o=this.seekable_.end(0),u=this.seekable_.start(0)),e?e.start(0)>t.end(0)||t.start(0)>e.end(0)?this.seekable_=t:this.seekable_=be.createTimeRanges([[e.start(0)>t.start(0)?e.start(0):t.start(0),e.end(0)<t.end(0)?e.end(0):t.end(0)]]):this.seekable_=t,!(this.seekable_&&this.seekable_.length&&this.seekable_.end(0)===o&&this.seekable_.start(0)===u)&&(this.logger_("seekable updated ["+l0(this.seekable_)+"]"),this.tech_.trigger("seekablechanged"))}}}}},{key:"updateDuration",value:function(){var t=this,e=this.mediaSource.duration,a=Xu.Playlist.duration(this.masterPlaylistLoader_.media()),s=this.tech_.buffered(),o=function u(){t.logger_("Setting duration from "+t.mediaSource.duration+" => "+a);try{t.mediaSource.duration=a}catch(l){be.log.warn("Failed to set media source duration",l)}t.tech_.trigger("durationchange"),t.mediaSource.removeEventListener("sourceopen",u)};s.length>0&&(a=Math.max(a,s.end(s.length-1))),e!==a&&(this.mediaSource.readyState!=="open"?this.mediaSource.addEventListener("sourceopen",o):o())}},{key:"dispose",value:function(){var t=this;this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),["AUDIO","SUBTITLES"].forEach(function(e){var a=t.mediaTypes_[e].groups;for(var s in a)a[s].forEach(function(o){o.playlistLoader&&o.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose()}},{key:"master",value:function(){return this.masterPlaylistLoader_.master}},{key:"media",value:function(){return this.masterPlaylistLoader_.media()||this.initialMedia_}},{key:"setupSourceBuffers_",value:function(){var t=this.masterPlaylistLoader_.media(),e=void 0;if(!(!t||this.mediaSource.readyState!=="open")){if(e=Q2(this.masterPlaylistLoader_.master,t),e.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(t){var e=t.length>1&&t[0].indexOf(",")===-1&&t[0]!==t[1]?new be.EventTarget:null;this.mainSegmentLoader_.mimeType(t[0],e),t[1]&&this.audioSegmentLoader_.mimeType(t[1],e)}},{key:"excludeUnsupportedVariants_",value:function(){this.master().playlists.forEach(function(t){t.attributes.CODECS&&tt.MediaSource&&tt.MediaSource.isTypeSupported&&!tt.MediaSource.isTypeSupported('video/mp4; codecs="'+K2(t.attributes.CODECS)+'"')&&(t.excludeUntil=1/0)})}},{key:"excludeIncompatibleVariants_",value:function(t){var e=2,a=null,s=void 0;t.attributes.CODECS&&(s=yf(t.attributes.CODECS),a=s.videoCodec,e=s.codecCount),this.master().playlists.forEach(function(o){var u={codecCount:2,videoCodec:null};o.attributes.CODECS&&(u=yf(o.attributes.CODECS)),u.codecCount!==e&&(o.excludeUntil=1/0),u.videoCodec!==a&&(o.excludeUntil=1/0)})}},{key:"updateAdCues_",value:function(t){var e=0,a=this.seekable();a.length&&(e=a.start(0)),IM(t,this.cueTagsTrack_,e)}},{key:"goalBufferLength",value:function(){var t=this.tech_.currentTime(),e=Ts.GOAL_BUFFER_LENGTH,a=Ts.GOAL_BUFFER_LENGTH_RATE,s=Math.max(e,Ts.MAX_GOAL_BUFFER_LENGTH);return Math.min(e+t*a,s)}},{key:"bufferLowWaterLine",value:function(){var t=this.tech_.currentTime(),e=Ts.BUFFER_LOW_WATER_LINE,a=Ts.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(e,Ts.MAX_BUFFER_LOW_WATER_LINE);return Math.min(e+t*a,s)}}]),r}(be.EventTarget),zM=function(r,i,t){return function(e){var a=r.master.playlists[i],s=s0(a),o=vp(a);return typeof e>"u"?o:(e?delete a.disabled:a.disabled=!0,e!==o&&!s&&(t(),e?r.trigger("renditionenabled"):r.trigger("renditiondisabled")),e)}},XM=function n(r,i,t){Gs(this,n);var e=r.masterPlaylistController_,a=r.options_.smoothQualityChange,s=a?"smooth":"fast",o=e[s+"QualityChange_"].bind(e);if(i.attributes.RESOLUTION){var u=i.attributes.RESOLUTION;this.width=u.width,this.height=u.height}this.bandwidth=i.attributes.BANDWIDTH,this.id=t,this.enabled=zM(r.playlists,i.uri,o)},YM=function(r){var i=r.playlists;r.representations=function(){return i.master.playlists.filter(function(t){return!s0(t)}).map(function(t,e){return new XM(r,t,t.uri)})}},zx=["seeking","seeked","pause","playing","error"],QM=function(){function n(r){var i=this;Gs(this,n),this.tech_=r.tech,this.seekable=r.seekable,this.seekTo=r.seekTo,this.allowSeeksWithinUnsafeLiveWindow=r.allowSeeksWithinUnsafeLiveWindow,this.media=r.media,this.consecutiveUpdates=0,this.lastRecordedTime=null,this.timer_=null,this.checkCurrentTimeTimeout_=null,this.logger_=Tf("PlaybackWatcher"),this.logger_("initialize");var t=function(){return i.monitorCurrentTime_()},e=function(){return i.techWaiting_()},a=function(){return i.cancelTimer_()},s=function(){return i.fixesBadSeeks_()};this.tech_.on("seekablechanged",s),this.tech_.on("waiting",e),this.tech_.on(zx,a),this.tech_.on("canplay",t),this.dispose=function(){i.logger_("dispose"),i.tech_.off("seekablechanged",s),i.tech_.off("waiting",e),i.tech_.off(zx,a),i.tech_.off("canplay",t),i.checkCurrentTimeTimeout_&&tt.clearTimeout(i.checkCurrentTimeTimeout_),i.cancelTimer_()}}return so(n,[{key:"monitorCurrentTime_",value:function(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&tt.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=tt.setTimeout(this.monitorCurrentTime_.bind(this),250)}},{key:"checkCurrentTime_",value:function(){if(this.tech_.seeking()&&this.fixesBadSeeks_()){this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime();return}if(!(this.tech_.paused()||this.tech_.seeking())){var i=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===i&&(!t.length||i+uu>=t.end(t.length-1)))return this.techWaiting_();this.consecutiveUpdates>=5&&i===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):i===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=i)}}},{key:"cancelTimer_",value:function(){this.consecutiveUpdates=0,this.timer_&&(this.logger_("cancelTimer_"),clearTimeout(this.timer_)),this.timer_=null}},{key:"fixesBadSeeks_",value:function(){var i=this.tech_.seeking();if(!i)return!1;var t=this.seekable(),e=this.tech_.currentTime(),a=this.afterSeekableWindow_(t,e,this.media(),this.allowSeeksWithinUnsafeLiveWindow),s=void 0;if(a){var o=t.end(t.length-1);s=o}if(this.beforeSeekableWindow_(t,e)){var u=t.start(0);s=u+uu}return typeof s<"u"?(this.logger_("Trying to seek outside of seekable at time "+e+" with "+("seekable range "+l0(t)+". Seeking to ")+(s+".")),this.seekTo(s),!0):!1}},{key:"waiting_",value:function(){if(!this.techWaiting_()){var i=this.tech_.currentTime(),t=this.tech_.buffered(),e=Sx(t,i);if(e.length&&i+3<=e.end(0)){this.cancelTimer_(),this.seekTo(i),this.logger_("Stopped at "+i+" while inside a buffered region "+("["+e.start(0)+" -> "+e.end(0)+"]. Attempting to resume ")+"playback by seeking to the current time."),this.tech_.trigger({type:"usage",name:"hls-unknown-waiting"});return}}}},{key:"techWaiting_",value:function(){var i=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_()||this.tech_.seeking()||this.timer_!==null)return!0;if(this.beforeSeekableWindow_(i,t)){var e=i.end(i.length-1);return this.logger_("Fell out of live window at time "+t+". Seeking to "+("live point (seekable end) "+e)),this.cancelTimer_(),this.seekTo(e),this.tech_.trigger({type:"usage",name:"hls-live-resync"}),!0}var a=this.tech_.buffered(),s=Ex(a,t);if(this.videoUnderflow_(s,a,t))return this.cancelTimer_(),this.seekTo(t),this.tech_.trigger({type:"usage",name:"hls-video-underflow"}),!0;if(s.length>0){var o=s.start(0)-t;return this.logger_("Stopped at "+t+", setting timer for "+o+", seeking "+("to "+s.start(0))),this.timer_=setTimeout(this.skipTheGap_.bind(this),o*1e3,t),!0}return!1}},{key:"afterSeekableWindow_",value:function(i,t,e){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!i.length)return!1;var s=i.end(i.length-1)+uu,o=!e.endList;return o&&a&&(s=i.end(i.length-1)+e.targetDuration*3),t>s}},{key:"beforeSeekableWindow_",value:function(i,t){return!!(i.length&&i.start(0)>0&&t<i.start(0)-uu)}},{key:"videoUnderflow_",value:function(i,t,e){if(i.length===0){var a=this.gapFromVideoUnderflow_(t,e);if(a)return this.logger_("Encountered a gap in video from "+a.start+" to "+a.end+". "+("Seeking to current time "+e)),!0}return!1}},{key:"skipTheGap_",value:function(i){var t=this.tech_.buffered(),e=this.tech_.currentTime(),a=Ex(t,e);this.cancelTimer_(),!(a.length===0||e!==i)&&(this.logger_("skipTheGap_:","currentTime:",e,"scheduled currentTime:",i,"nextRange start:",a.start(0)),this.seekTo(a.start(0)+yp),this.tech_.trigger({type:"usage",name:"hls-gap-skip"}))}},{key:"gapFromVideoUnderflow_",value:function(i,t){for(var e=B2(i),a=0;a<e.length;a++){var s=e.start(a),o=e.end(a);if(t-s<4&&t-s>2)return{start:s,end:o}}return null}}]),n}(),JM={errorInterval:30,getSource:function(r){var i=this.tech({IWillNotUseThisInPlugins:!0}),t=i.currentSource_;return r(t)}},ZM=function n(r,i){var t=0,e=0,a=be.mergeOptions(JM,i);r.ready(function(){r.trigger({type:"usage",name:"hls-error-reload-initialized"})});var s=function(){e&&r.currentTime(e)},o=function(f){f!=null&&(e=r.duration()!==1/0&&r.currentTime()||0,r.one("loadedmetadata",s),r.src(f),r.trigger({type:"usage",name:"hls-error-reload"}),r.play())},u=function(){if(Date.now()-t<a.errorInterval*1e3){r.trigger({type:"usage",name:"hls-error-reload-canceled"});return}if(!a.getSource||typeof a.getSource!="function"){be.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),a.getSource.call(r,o)},l=function c(){r.off("loadedmetadata",s),r.off("error",u),r.off("dispose",c)},d=function(f){l(),n(r,f)};r.on("error",u),r.on("dispose",l),r.reloadSourceOnError=d},Xx=function(r){ZM(this,r)},eF="1.10.6";be.use("*",function(n){return{setSource:function(i,t){t(null,i)},setCurrentTime:function(i){return n.vhs&&n.currentSource().src===n.vhs.source_.src&&n.vhs.setCurrentTime(i),i},play:function(){n.vhs&&n.currentSource().src===n.vhs.source_.src&&n.vhs.setCurrentTime(n.tech_.currentTime())}}});var as={PlaylistLoader:gp,Playlist:ns,Decrypter:OO,AsyncStream:yS,decrypt:_S,utils:D2,STANDARD_PLAYLIST_SELECTOR:TM,INITIAL_PLAYLIST_SELECTOR:SM,comparePlaylistBandwidth:m0,comparePlaylistResolution:yM,xhr:vx()};["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(n){Object.defineProperty(as,n,{get:function(){return be.log.warn("using Hls."+n+" is UNSAFE be sure you know what you are doing"),Ts[n]},set:function(i){if(be.log.warn("using Hls."+n+" is UNSAFE be sure you know what you are doing"),typeof i!="number"||i<0){be.log.warn("value of Hls."+n+" must be greater than or equal to 0");return}Ts[n]=i}})});var Yx="videojs-vhs",Qx=function(r){var i=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;if(i.test(r))return"hls";var t=/^application\/dash\+xml/i;return t.test(r)?"dash":null},Jx=function(r,i){for(var t=i.media(),e=-1,a=0;a<r.length;a++)if(r[a].id===t.uri){e=a;break}r.selectedIndex_=e,r.trigger({selectedIndex:e,type:"change"})},tF=function(r,i){i.representations().forEach(function(t){r.addQualityLevel(t)}),Jx(r,i.playlists)};as.canPlaySource=function(){return be.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var rF=function(r,i,t){if(!r)return r;var e={};for(var a in r)e[a]={audioContentType:'audio/mp4; codecs="'+t.attributes.CODECS+'"',videoContentType:'video/mp4; codecs="'+i.attributes.CODECS+'"'},i.contentProtection&&i.contentProtection[a]&&i.contentProtection[a].pssh&&(e[a].pssh=i.contentProtection[a].pssh),typeof r[a]=="string"&&(e[a].url=r[a]);return be.mergeOptions(r,e)},iF=function(r){if(r.options_.sourceType==="dash"){var i=be.players[r.tech_.options_.playerId];if(i.eme){var t=rF(r.source_.keySystems,r.playlists.media(),r.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader.media());t&&(i.currentSource().keySystems=t,i.eme.initializeMediaKeys&&i.eme.initializeMediaKeys())}}},Zx=function(){if(!window.localStorage)return null;var r=window.localStorage.getItem(Yx);if(!r)return null;try{return JSON.parse(r)}catch{return null}},nF=function(r){if(!window.localStorage)return!1;var i=Zx();i=i?be.mergeOptions(i,r):r;try{window.localStorage.setItem(Yx,JSON.stringify(i))}catch{return!1}return i};as.supportsNativeHls=function(){var n=sr.createElement("video");if(!be.getTech("Html5").isSupported())return!1;var r=["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"];return r.some(function(i){return/maybe|probably/i.test(n.canPlayType(i))})}(),as.supportsNativeDash=function(){return be.getTech("Html5").isSupported()?/maybe|probably/i.test(sr.createElement("video").canPlayType("application/dash+xml")):!1}(),as.supportsTypeNatively=function(n){return n==="hls"?as.supportsNativeHls:n==="dash"?as.supportsNativeDash:!1},as.isSupported=function(){return be.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var aF=be.getComponent("Component"),eA=function(n){ou(r,n);function r(i,t,e){Gs(this,r);var a=ko(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t,e.hls));if(t.options_&&t.options_.playerId){var s=be(t.options_.playerId);s.hasOwnProperty("hls")||Object.defineProperty(s,"hls",{get:function(){return be.log.warn("player.hls is deprecated. Use player.tech().hls instead."),t.trigger({type:"usage",name:"hls-player-access"}),a},configurable:!0}),s.vhs=a,s.dash=a,a.player_=s}if(a.tech_=t,a.source_=i,a.stats={},a.setOptions_(),a.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(a.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native HLS requires emulated tracks. See https://git.io/vMpjB");return a.on(sr,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],function(o){var u=sr.fullscreenElement||sr.webkitFullscreenElement||sr.mozFullScreenElement||sr.msFullscreenElement;u&&u.contains(a.tech_.el())&&a.masterPlaylistController_.smoothQualityChange_()}),a.on(a.tech_,"seeking",function(){this.tech_.currentTime()===0&&this.tech_.player_.loop()&&this.setCurrentTime(0)}),a.on(a.tech_,"error",function(){this.masterPlaylistController_&&this.masterPlaylistController_.pauseLoading()}),a.on(a.tech_,"play",a.play),a}return so(r,[{key:"setOptions_",value:function(){var t=this;if(this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.handleManifestRedirects=this.options_.handleManifestRedirects||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.smoothQualityChange=this.options_.smoothQualityChange||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,typeof this.options_.blacklistDuration!="number"&&(this.options_.blacklistDuration=5*60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){var e=Zx();e&&e.bandwidth&&(this.options_.bandwidth=e.bandwidth,this.tech_.trigger({type:"usage",name:"hls-bandwidth-from-local-storage"})),e&&e.throughput&&(this.options_.throughput=e.throughput,this.tech_.trigger({type:"usage",name:"hls-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=Ts.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===Ts.INITIAL_BANDWIDTH,["withCredentials","limitRenditionByPlayerDimensions","bandwidth","smoothQualityChange","customTagParsers","customTagMappers","handleManifestRedirects","cacheEncryptionKeys"].forEach(function(a){typeof t.source_[a]<"u"&&(t.options_[a]=t.source_[a])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions}},{key:"src",value:function(t,e){var a=this;!t||(this.setOptions_(),this.options_.url=this.source_.src,this.options_.tech=this.tech_,this.options_.externHls=as,this.options_.sourceType=Qx(e),this.options_.seekTo=function(s){a.tech_.setCurrentTime(s),a.setCurrentTime(s)},this.masterPlaylistController_=new KM(this.options_),this.playbackWatcher_=new QM(be.mergeOptions(this.options_,{seekable:function(){return a.seekable()},media:function(){return a.masterPlaylistController_.media()}})),this.masterPlaylistController_.on("error",function(){var s=be.players[a.tech_.options_.playerId];s.error(a.masterPlaylistController_.error)}),this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):as.STANDARD_PLAYLIST_SELECTOR.bind(this),this.masterPlaylistController_.selectInitialPlaylist=as.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.masterPlaylistController_.masterPlaylistLoader_,this.mediaSource=this.masterPlaylistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get:function(){return this.masterPlaylistController_.selectPlaylist},set:function(o){this.masterPlaylistController_.selectPlaylist=o.bind(this)}},throughput:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.throughput.rate},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.throughput.rate=o,this.masterPlaylistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.bandwidth},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.bandwidth=o,this.masterPlaylistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get:function(){var o=1/(this.bandwidth||1),u=void 0;this.throughput>0?u=1/this.throughput:u=0;var l=Math.floor(1/(o+u));return l},set:function(){be.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 a.bandwidth||0},enumerable:!0},mediaRequests:{get:function(){return a.masterPlaylistController_.mediaRequests_()||0},enumerable:!0},mediaRequestsAborted:{get:function(){return a.masterPlaylistController_.mediaRequestsAborted_()||0},enumerable:!0},mediaRequestsTimedout:{get:function(){return a.masterPlaylistController_.mediaRequestsTimedout_()||0},enumerable:!0},mediaRequestsErrored:{get:function(){return a.masterPlaylistController_.mediaRequestsErrored_()||0},enumerable:!0},mediaTransferDuration:{get:function(){return a.masterPlaylistController_.mediaTransferDuration_()||0},enumerable:!0},mediaBytesTransferred:{get:function(){return a.masterPlaylistController_.mediaBytesTransferred_()||0},enumerable:!0},mediaSecondsLoaded:{get:function(){return a.masterPlaylistController_.mediaSecondsLoaded_()||0},enumerable:!0},buffered:{get:function(){return xx(a.tech_.buffered())},enumerable:!0},currentTime:{get:function(){return a.tech_.currentTime()},enumerable:!0},currentSource:{get:function(){return a.tech_.currentSource_},enumerable:!0},currentTech:{get:function(){return a.tech_.name_},enumerable:!0},duration:{get:function(){return a.tech_.duration()},enumerable:!0},master:{get:function(){return a.playlists.master},enumerable:!0},playerDimensions:{get:function(){return a.tech_.currentDimensions()},enumerable:!0},seekable:{get:function(){return xx(a.tech_.seekable())},enumerable:!0},timestamp:{get:function(){return Date.now()},enumerable:!0},videoPlaybackQuality:{get:function(){return a.tech_.getVideoPlaybackQuality()},enumerable:!0}}),this.tech_.one("canplay",this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_)),this.tech_.on("bandwidthupdate",function(){a.options_.useBandwidthFromLocalStorage&&nF({bandwidth:a.bandwidth,throughput:Math.round(a.throughput)})}),this.masterPlaylistController_.on("selectedinitialmedia",function(){YM(a),iF(a)}),this.on(this.masterPlaylistController_,"progress",function(){this.tech_.trigger("progress")}),this.tech_.ready(function(){return a.setupQualityLevels_()}),this.tech_.el()&&this.tech_.src(be.URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var t=this,e=be.players[this.tech_.options_.playerId];e&&e.qualityLevels&&(this.qualityLevels_=e.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",function(){tF(t.qualityLevels_,t)}),this.playlists.on("mediachange",function(){Jx(t.qualityLevels_,t.playlists)}))}},{key:"play",value:function(){this.masterPlaylistController_.play()}},{key:"setCurrentTime",value:function(t){this.masterPlaylistController_.setCurrentTime(t)}},{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,a2(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"dispose",this).call(this)}},{key:"convertToProgramTime",value:function(t,e){return F2({playlist:this.masterPlaylistController_.media(),time:t,callback:e})}},{key:"seekToProgramTime",value:function(t,e){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:2;return N2({programTime:t,playlist:this.masterPlaylistController_.media(),retryCount:s,pauseAfterSeek:a,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:e})}}]),r}(aF),T0={name:"videojs-http-streaming",VERSION:eF,canHandleSource:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=be.mergeOptions(be.options,i);return T0.canPlayType(r.type,t)},handleSource:function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},e=be.mergeOptions(be.options,t);return i.hls=new eA(r,i,e),i.hls.xhr=vx(),i.hls.src(r.src,r.type),i.hls},canPlayType:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=be.mergeOptions(be.options,i),e=t.hls.overrideNative,a=Qx(r),s=a&&(!as.supportsTypeNatively(a)||e);return s?"maybe":""}};(typeof be.MediaSource>"u"||typeof be.URL>"u")&&(be.MediaSource=_f,be.URL=Fx),_f.supportsNativeMediaSources()&&be.getTech("Html5").registerSourceHandler(T0,0),be.HlsHandler=eA,be.HlsSourceHandler=T0,be.Hls=as,be.use||be.registerComponent("Hls",as),be.options.hls=be.options.hls||{},be.registerPlugin?be.registerPlugin("reloadSourceOnError",Xx):be.plugin("reloadSourceOnError",Xx);const sF=Object.freeze(Object.defineProperty({__proto__:null,default:be},Symbol.toStringTag,{value:"Module"})),oF={name:"stream-engine-player",version:"0.0.24",description:"Stream engine player",type:"module",files:["dist","src","index.js","README.md","LICENSE","package.json","vite.config.js"],exports:{".":{import:"./dist/stream-engine-player.mjs",require:"./dist/stream-engine-player.js"},"./style":{import:"./dist/style.css",require:"./dist/style.css"},"./bundle":{import:"./dist/stream-engine-player-bundle.mjs",require:"./dist/stream-engine-player-bundle.js"}},main:"dist/stream-engine-player.js",author:"Dok Umansky",scripts:{dev:"vite serve",build:'concurrently "vite build --mode bundle" "vite build"',serve:"vite preview",start:"npm run dev",prebuild:"rm -rf dist","version:patch":"npm version patch",lint:"./node_modules/.bin/eslint src",format:'prettier "src/**/*.{ts,js,json,scss,css}" --write',watch:'concurrently "vite build --watch" "vite serve"',"build:watch":"vite build --watch"},dependencies:{angular:"~1.4.8","angular-cookies":"~1.4.8","font-awesome":"^4.7.0","hls.js":"^0.12.4","include-media":"^2.0.0",localforage:"^1.10.0","m3u8-parser":"^7.1.0","mixpanel-browser":"2.52.0","video.js":"7.6.6","videojs-youtube":"^2.6.1","videojs-ima":"1.7.5","videojs-contrib-ads":"6.6.5","videojs-mux":"4.19.0","infront-logger":"1.1.11"},devDependencies:{concurrently:"^8.2.1",eslint:"^8.24.0","eslint-config-prettier":"^8.5.0","eslint-plugin-angular":"^4.1.0","eslint-plugin-prettier":"^4.2.1",husky:"^8.0.1",hygen:"^6.2.11","lint-staged":"^13.0.3",prettier:"^2.7.1",sass:"^1.55.0",vite:"^3.2.7"},husky:{hooks:{"pre-commit":"lint-staged"}},"lint-staged":{"*.{ts,js,json,scss,css}":["prettier --write","git add"]}},gG="";/**
|
104
|
+
`.split("").map(function(n){return n.charCodeAt(0)})),PM=function(n){ou(r,n);function r(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Gs(this,r);var e=ko(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,i,t));return e.mediaSource_=null,e.subtitlesTrack_=null,e}return so(r,[{key:"buffered_",value:function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return be.createTimeRanges();var t=this.subtitlesTrack_.cues,e=t[0].startTime,a=t[t.length-1].startTime;return be.createTimeRanges([[e,a]])}},{key:"initSegment",value:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=mp(t),s=this.initSegments_[a];if(e&&!s&&t.bytes){var o=qx.byteLength+t.bytes.byteLength,u=new Uint8Array(o);u.set(t.bytes),u.set(qx,t.bytes.byteLength),this.initSegments_[a]=s={resolvedUri:t.resolvedUri,byterange:t.byterange,bytes:u}}return s||t}},{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(t){return typeof t>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=t,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}},{key:"remove",value:function(t,e){Uc(t,e,this.subtitlesTrack_)}},{key:"fillBuffer_",value:function(){var t=this;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_);if(e=this.skipEmptySegments_(e),!!e){if(this.syncController_.timestampOffsetForTimeline(e.timeline)===null){var a=function(){t.state="READY",t.paused()||t.monitorBuffer_()};this.syncController_.one("timestampoffset",a),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(e)}}},{key:"skipEmptySegments_",value:function(t){for(;t&&t.segment.empty;)t=this.generateSegmentInfo_(t.playlist,t.mediaIndex+1,t.startOfSegment+t.duration,t.isSyncRequest);return t}},{key:"handleSegment_",value:function(){var t=this;if(!this.pendingSegment_||!this.subtitlesTrack_){this.state="READY";return}this.state="APPENDING";var e=this.pendingSegment_,a=e.segment;if(typeof tt.WebVTT!="function"&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var s=void 0,o=function(){t.subtitlesTrack_.tech_.off("vttjsloaded",s),t.error({message:"Error loading vtt.js"}),t.state="READY",t.pause(),t.trigger("error")};s=function(){t.subtitlesTrack_.tech_.off("vttjserror",o),t.handleSegment_()},this.state="WAITING_ON_VTTJS",this.subtitlesTrack_.tech_.one("vttjsloaded",s),this.subtitlesTrack_.tech_.one("vttjserror",o);return}a.requested=!0;try{this.parseVTTCues_(e)}catch(u){return this.error({message:u.message}),this.state="READY",this.pause(),this.trigger("error")}if(this.updateTimeMapping_(e,this.syncController_.timelines[e.timeline],this.playlist_),e.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}e.byteLength=e.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,e.cues.length&&this.remove(e.cues[0].endTime,e.cues[e.cues.length-1].endTime),e.cues.forEach(function(u){t.subtitlesTrack_.addCue(u)}),this.handleUpdateEnd_()}},{key:"parseVTTCues_",value:function(t){var e=void 0,a=!1;typeof tt.TextDecoder=="function"?e=new tt.TextDecoder("utf8"):(e=tt.WebVTT.StringDecoder(),a=!0);var s=new tt.WebVTT.Parser(tt,tt.vttjs,e);if(t.cues=[],t.timestampmap={MPEGTS:0,LOCAL:0},s.oncue=t.cues.push.bind(t.cues),s.ontimestampmap=function(l){return t.timestampmap=l},s.onparsingerror=function(l){be.log.warn("Error encountered when parsing cues: "+l.message)},t.segment.map){var o=t.segment.map.bytes;a&&(o=Gx(o)),s.parse(o)}var u=t.bytes;a&&(u=Gx(u)),s.parse(u),s.flush()}},{key:"updateTimeMapping_",value:function(t,e,a){var s=t.segment;if(!!e){if(!t.cues.length){s.empty=!0;return}var o=t.timestampmap,u=o.MPEGTS/9e4-o.LOCAL+e.mapping;if(t.cues.forEach(function(c){c.startTime+=u,c.endTime+=u}),!a.syncInfo){var l=t.cues[0].startTime,d=t.cues[t.cues.length-1].startTime;a.syncInfo={mediaSequence:a.mediaSequence+t.mediaIndex,time:Math.min(l,d-s.duration)}}}}}]),r}(y0),RM=function(r,i){for(var t=r.cues,e=0;e<t.length;e++){var a=t[e];if(i>=a.adStartTime&&i<=a.adEndTime)return a}return null},IM=function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!!r.segments)for(var e=t,a=void 0,s=0;s<r.segments.length;s++){var o=r.segments[s];if(a||(a=RM(i,e+o.duration/2)),a){if("cueIn"in o){a.endTime=e,a.adEndTime=e,e+=o.duration,a=null;continue}if(e<a.endTime){e+=o.duration;continue}a.endTime+=o.duration}else if("cueOut"in o&&(a=new tt.VTTCue(e,e+o.duration,o.cueOut),a.adStartTime=e,a.adEndTime=e+parseFloat(o.cueOut),i.addCue(a)),"cueOutCont"in o){var u=void 0,l=void 0,d=o.cueOutCont.split("/").map(parseFloat),c=s2(d,2);u=c[0],l=c[1],a=new tt.VTTCue(e,e+o.duration,""),a.adStartTime=e-u,a.adEndTime=a.adStartTime+l,i.addCue(a)}e+=o.duration}},OM=CO.inspect,Wx=[{name:"VOD",run:function(r,i,t,e,a){if(t!==1/0){var s={time:0,segmentIndex:0};return s}return null}},{name:"ProgramDateTime",run:function(r,i,t,e,a){if(!r.datetimeToDisplayTime)return null;var s=i.segments||[],o=null,u=null;a=a||0;for(var l=0;l<s.length;l++){var d=s[l];if(d.dateTimeObject){var c=d.dateTimeObject.getTime()/1e3,f=c+r.datetimeToDisplayTime,h=Math.abs(a-f);if(u!==null&&(h===0||u<h))break;u=h,o={time:f,segmentIndex:l}}}return o}},{name:"Segment",run:function(r,i,t,e,a){var s=i.segments||[],o=null,u=null;a=a||0;for(var l=0;l<s.length;l++){var d=s[l];if(d.timeline===e&&typeof d.start<"u"){var c=Math.abs(a-d.start);if(u!==null&&u<c)break;(!o||u===null||u>=c)&&(u=c,o={time:d.start,segmentIndex:l})}}return o}},{name:"Discontinuity",run:function(r,i,t,e,a){var s=null;if(a=a||0,i.discontinuityStarts&&i.discontinuityStarts.length)for(var o=null,u=0;u<i.discontinuityStarts.length;u++){var l=i.discontinuityStarts[u],d=i.discontinuitySequence+u+1,c=r.discontinuities[d];if(c){var f=Math.abs(a-c.time);if(o!==null&&o<f)break;(!s||o===null||o>=f)&&(o=f,s={time:c.time,segmentIndex:l})}}return s}},{name:"Playlist",run:function(r,i,t,e,a){if(i.syncInfo){var s={time:i.syncInfo.time,segmentIndex:i.syncInfo.mediaSequence-i.mediaSequence};return s}return null}}],LM=function(n){ou(r,n);function r(){Gs(this,r);var i=ko(this,(r.__proto__||Object.getPrototypeOf(r)).call(this));return i.inspectCache_=void 0,i.timelines=[],i.discontinuities=[],i.datetimeToDisplayTime=null,i.logger_=Tf("SyncController"),i}return so(r,[{key:"getSyncPoint",value:function(t,e,a,s){var o=this.runStrategies_(t,e,a,s);return o.length?this.selectSyncPoint_(o,{key:"time",value:s}):null}},{key:"getExpiredTime",value:function(t,e){if(!t||!t.segments)return null;var a=this.runStrategies_(t,e,t.discontinuitySequence,0);if(!a.length)return null;var s=this.selectSyncPoint_(a,{key:"segmentIndex",value:0});return s.segmentIndex>0&&(s.time*=-1),Math.abs(s.time+mf(t,s.segmentIndex,0))}},{key:"runStrategies_",value:function(t,e,a,s){for(var o=[],u=0;u<Wx.length;u++){var l=Wx[u],d=l.run(this,t,e,a,s);d&&(d.strategy=l.name,o.push({strategy:l.name,syncPoint:d}))}return o}},{key:"selectSyncPoint_",value:function(t,e){for(var a=t[0].syncPoint,s=Math.abs(t[0].syncPoint[e.key]-e.value),o=t[0].strategy,u=1;u<t.length;u++){var l=Math.abs(t[u].syncPoint[e.key]-e.value);l<s&&(s=l,a=t[u].syncPoint,o=t[u].strategy)}return this.logger_("syncPoint for ["+e.key+": "+e.value+"] chosen with strategy"+(" ["+o+"]: [time:"+a.time+",")+(" segmentIndex:"+a.segmentIndex+"]")),a}},{key:"saveExpiredSegmentInfo",value:function(t,e){for(var a=e.mediaSequence-t.mediaSequence,s=a-1;s>=0;s--){var o=t.segments[s];if(o&&typeof o.start<"u"){e.syncInfo={mediaSequence:t.mediaSequence+s,time:o.start},this.logger_("playlist refresh sync: [time:"+e.syncInfo.time+","+(" mediaSequence: "+e.syncInfo.mediaSequence+"]")),this.trigger("syncinfoupdate");break}}}},{key:"setDateTimeMapping",value:function(t){if(!this.datetimeToDisplayTime&&t.segments&&t.segments.length&&t.segments[0].dateTimeObject){var e=t.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-e}}},{key:"reset",value:function(){this.inspectCache_=void 0}},{key:"probeSegmentInfo",value:function(t){var e=t.segment,a=t.playlist,s=void 0;return e.map?s=this.probeMp4Segment_(t):s=this.probeTsSegment_(t),s&&this.calculateSegmentTimeMapping_(t,s)&&(this.saveDiscontinuitySyncInfo_(t),a.syncInfo||(a.syncInfo={mediaSequence:a.mediaSequence+t.mediaIndex,time:e.start})),s}},{key:"probeMp4Segment_",value:function(t){var e=t.segment,a=Fh.timescale(e.map.bytes),s=Fh.startTime(a,t.bytes);return t.timestampOffset!==null&&(t.timestampOffset-=s),{start:s,end:s+e.duration}}},{key:"probeTsSegment_",value:function(t){var e=OM(t.bytes,this.inspectCache_),a=void 0,s=void 0,o=void 0;if(!e)return null;e.video&&e.video.length===2?(this.inspectCache_=e.video[1].dts,a=e.video[0].dtsTime,s=e.video[1].dtsTime,o=e.video):e.audio&&e.audio.length===2&&(this.inspectCache_=e.audio[1].dts,a=e.audio[0].dtsTime,s=e.audio[1].dtsTime,o=e.audio);var u={segmentTimestampInfo:o,start:a,end:s,containsVideo:e.video&&e.video.length===2,containsAudio:e.audio&&e.audio.length===2};return u}},{key:"timestampOffsetForTimeline",value:function(t){return typeof this.timelines[t]>"u"?null:this.timelines[t].time}},{key:"mappingForTimeline",value:function(t){return typeof this.timelines[t]>"u"?null:this.timelines[t].mapping}},{key:"calculateSegmentTimeMapping_",value:function(t,e){var a=t.segment,s=this.timelines[t.timeline];if(t.timestampOffset!==null)s={time:t.startOfSegment,mapping:t.startOfSegment-e.start},this.timelines[t.timeline]=s,this.trigger("timestampoffset"),this.logger_("time mapping for timeline "+t.timeline+": "+("[time: "+s.time+"] [mapping: "+s.mapping+"]")),a.start=t.startOfSegment,a.end=e.end+s.mapping;else if(s)a.start=e.start+s.mapping,a.end=e.end+s.mapping;else return!1;return!0}},{key:"saveDiscontinuitySyncInfo_",value:function(t){var e=t.playlist,a=t.segment;if(a.discontinuity)this.discontinuities[a.timeline]={time:a.start,accuracy:0};else if(e.discontinuityStarts&&e.discontinuityStarts.length)for(var s=0;s<e.discontinuityStarts.length;s++){var o=e.discontinuityStarts[s],u=e.discontinuitySequence+s+1,l=o-t.mediaIndex,d=Math.abs(l);if(!this.discontinuities[u]||this.discontinuities[u].accuracy>d){var c=void 0;l<0?c=a.start-mf(e,t.mediaIndex,o):c=a.end+mf(e,t.mediaIndex+1,o),this.discontinuities[u]={time:c,accuracy:d}}}}}]),r}(be.EventTarget),MM=new Cx("./decrypter-worker.worker.js",function(n,r){var i=this;(function(){function t(T){return T.subarray(0,T.byteLength-T[T.byteLength-1])}var e=function(b,E){if(!(b instanceof E))throw new TypeError("Cannot call a class as a function")},a=function(){function T(b,E){for(var C=0;C<E.length;C++){var x=E[C];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(b,x.key,x)}}return function(b,E,C){return E&&T(b.prototype,E),C&&T(b,C),b}}(),s=function(b,E){if(typeof E!="function"&&E!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof E);b.prototype=Object.create(E&&E.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),E&&(Object.setPrototypeOf?Object.setPrototypeOf(b,E):b.__proto__=E)},o=function(b,E){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return E&&(typeof E=="object"||typeof E=="function")?E:b},u=function(){var b=[[[],[],[],[],[]],[[],[],[],[],[]]],E=b[0],C=b[1],x=E[4],S=C[4],w=void 0,k=void 0,P=void 0,R=[],N=[],G=void 0,I=void 0,M=void 0,B=void 0,q=void 0,Z=void 0;for(w=0;w<256;w++)N[(R[w]=w<<1^(w>>7)*283)^w]=w;for(k=P=0;!x[k];k^=G||1,P=N[P]||1)for(B=P^P<<1^P<<2^P<<3^P<<4,B=B>>8^B&255^99,x[k]=B,S[B]=k,M=R[I=R[G=R[k]]],Z=M*16843009^I*65537^G*257^k*16843008,q=R[B]*257^B*16843008,w=0;w<4;w++)E[w][k]=q=q<<24^q>>>8,C[w][B]=Z=Z<<24^Z>>>8;for(w=0;w<5;w++)E[w]=E[w].slice(0),C[w]=C[w].slice(0);return b},l=null,d=function(){function T(b){e(this,T),l||(l=u()),this._tables=[[l[0][0].slice(),l[0][1].slice(),l[0][2].slice(),l[0][3].slice(),l[0][4].slice()],[l[1][0].slice(),l[1][1].slice(),l[1][2].slice(),l[1][3].slice(),l[1][4].slice()]];var E=void 0,C=void 0,x=void 0,S=void 0,w=void 0,k=this._tables[0][4],P=this._tables[1],R=b.length,N=1;if(R!==4&&R!==6&&R!==8)throw new Error("Invalid aes key size");for(S=b.slice(0),w=[],this._key=[S,w],E=R;E<4*R+28;E++)x=S[E-1],(E%R===0||R===8&&E%R===4)&&(x=k[x>>>24]<<24^k[x>>16&255]<<16^k[x>>8&255]<<8^k[x&255],E%R===0&&(x=x<<8^x>>>24^N<<24,N=N<<1^(N>>7)*283)),S[E]=S[E-R]^x;for(C=0;E;C++,E--)x=S[C&3?E:E-4],E<=4||C<4?w[C]=x:w[C]=P[0][k[x>>>24]]^P[1][k[x>>16&255]]^P[2][k[x>>8&255]]^P[3][k[x&255]]}return T.prototype.decrypt=function(E,C,x,S,w,k){var P=this._key[1],R=E^P[0],N=S^P[1],G=x^P[2],I=C^P[3],M=void 0,B=void 0,q=void 0,Z=P.length/4-2,re=void 0,oe=4,ae=this._tables[1],ne=ae[0],ye=ae[1],Pe=ae[2],$e=ae[3],ft=ae[4];for(re=0;re<Z;re++)M=ne[R>>>24]^ye[N>>16&255]^Pe[G>>8&255]^$e[I&255]^P[oe],B=ne[N>>>24]^ye[G>>16&255]^Pe[I>>8&255]^$e[R&255]^P[oe+1],q=ne[G>>>24]^ye[I>>16&255]^Pe[R>>8&255]^$e[N&255]^P[oe+2],I=ne[I>>>24]^ye[R>>16&255]^Pe[N>>8&255]^$e[G&255]^P[oe+3],oe+=4,R=M,N=B,G=q;for(re=0;re<4;re++)w[(3&-re)+k]=ft[R>>>24]<<24^ft[N>>16&255]<<16^ft[G>>8&255]<<8^ft[I&255]^P[oe++],M=R,R=N,N=G,G=I,I=M},T}(),c=function(){function T(){e(this,T),this.listeners={}}return T.prototype.on=function(E,C){this.listeners[E]||(this.listeners[E]=[]),this.listeners[E].push(C)},T.prototype.off=function(E,C){if(!this.listeners[E])return!1;var x=this.listeners[E].indexOf(C);return this.listeners[E].splice(x,1),x>-1},T.prototype.trigger=function(E){var C=this.listeners[E];if(!!C)if(arguments.length===2)for(var x=C.length,S=0;S<x;++S)C[S].call(this,arguments[1]);else for(var w=Array.prototype.slice.call(arguments,1),k=C.length,P=0;P<k;++P)C[P].apply(this,w)},T.prototype.dispose=function(){this.listeners={}},T.prototype.pipe=function(E){this.on("data",function(C){E.push(C)})},T}(),f=function(T){s(b,T);function b(){e(this,b);var E=o(this,T.call(this,c));return E.jobs=[],E.delay=1,E.timeout_=null,E}return b.prototype.processJob_=function(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null},b.prototype.push=function(C){this.jobs.push(C),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))},b}(c),h=function(b){return b<<24|(b&65280)<<8|(b&16711680)>>8|b>>>24},g=function(b,E,C){var x=new Int32Array(b.buffer,b.byteOffset,b.byteLength>>2),S=new d(Array.prototype.slice.call(E)),w=new Uint8Array(b.byteLength),k=new Int32Array(w.buffer),P=void 0,R=void 0,N=void 0,G=void 0,I=void 0,M=void 0,B=void 0,q=void 0,Z=void 0;for(P=C[0],R=C[1],N=C[2],G=C[3],Z=0;Z<x.length;Z+=4)I=h(x[Z]),M=h(x[Z+1]),B=h(x[Z+2]),q=h(x[Z+3]),S.decrypt(I,M,B,q,k,Z),k[Z]=h(k[Z]^P),k[Z+1]=h(k[Z+1]^R),k[Z+2]=h(k[Z+2]^N),k[Z+3]=h(k[Z+3]^G),P=I,R=M,N=B,G=q;return w},p=function(){function T(b,E,C,x){e(this,T);var S=T.STEP,w=new Int32Array(b.buffer),k=new Uint8Array(b.byteLength),P=0;for(this.asyncStream_=new f,this.asyncStream_.push(this.decryptChunk_(w.subarray(P,P+S),E,C,k)),P=S;P<w.length;P+=S)C=new Uint32Array([h(w[P-4]),h(w[P-3]),h(w[P-2]),h(w[P-1])]),this.asyncStream_.push(this.decryptChunk_(w.subarray(P,P+S),E,C,k));this.asyncStream_.push(function(){x(null,t(k))})}return T.prototype.decryptChunk_=function(E,C,x,S){return function(){var w=g(E,C,x);S.set(w,E.byteOffset)}},a(T,null,[{key:"STEP",get:function(){return 32e3}}]),T}(),v=function(b){var E={};return Object.keys(b).forEach(function(C){var x=b[C];ArrayBuffer.isView(x)?E[C]={bytes:x.buffer,byteOffset:x.byteOffset,byteLength:x.byteLength}:E[C]=x}),E},y=function(b){b.onmessage=function(E){var C=E.data,x=new Uint8Array(C.encrypted.bytes,C.encrypted.byteOffset,C.encrypted.byteLength),S=new Uint32Array(C.key.bytes,C.key.byteOffset,C.key.byteLength/4),w=new Uint32Array(C.iv.bytes,C.iv.byteOffset,C.iv.byteLength/4);new p(x,S,w,function(k,P){b.postMessage(v({source:C.source,decrypted:P}),[P.buffer])})}},m=new y(i);return m})()}),FM=function(r){var i=r.default?"main":"alternative";return r.characteristics&&r.characteristics.indexOf("public.accessibility.describes-video")>=0&&(i="main-desc"),i},Tp=function(r,i){r.abort(),r.pause(),i&&i.activePlaylistLoader&&(i.activePlaylistLoader.pause(),i.activePlaylistLoader=null)},_0=function(r,i){i.activePlaylistLoader=r,r.load()},NM=function(r,i){return function(){var t=i.segmentLoaders,e=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),u=s.activeGroup(o),l=s.activePlaylistLoader;if(Tp(e,s),!!u){if(!u.playlistLoader){l&&a.resetEverything();return}e.resyncLoader(),_0(u.playlistLoader,s)}}},BM=function(r,i){return function(){var t=i.segmentLoaders,e=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),u=s.activeGroup(o),l=s.activePlaylistLoader;if(Tp(e,s),!!u){if(!u.playlistLoader){a.resetEverything();return}if(l===u.playlistLoader){_0(u.playlistLoader,s);return}e.track&&e.track(o),e.resetEverything(),_0(u.playlistLoader,s)}}},bp={AUDIO:function(r,i){return function(){var t=i.segmentLoaders[r],e=i.mediaTypes[r],a=i.blacklistCurrentPlaylist;Tp(t,e);var s=e.activeTrack(),o=e.activeGroup(),u=(o.filter(function(c){return c.default})[0]||o[0]).id,l=e.tracks[u];if(s===l){a({message:"Problem encountered loading the default audio track."});return}be.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(var d in e.tracks)e.tracks[d].enabled=e.tracks[d]===l;e.onTrackChanged()}},SUBTITLES:function(r,i){return function(){var t=i.segmentLoaders[r],e=i.mediaTypes[r];be.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),Tp(t,e);var a=e.activeTrack();a&&(a.mode="disabled"),e.onTrackChanged()}}},Kx={AUDIO:function(r,i,t){if(!!i){var e=t.tech,a=t.requestOptions,s=t.segmentLoaders[r];i.on("loadedmetadata",function(){var o=i.media();s.playlist(o,a),(!e.paused()||o.endList&&e.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),e.paused()||s.load()}),i.on("error",bp[r](r,t))}},SUBTITLES:function(r,i,t){var e=t.tech,a=t.requestOptions,s=t.segmentLoaders[r],o=t.mediaTypes[r];i.on("loadedmetadata",function(){var u=i.media();s.playlist(u,a),s.track(o.activeTrack()),(!e.paused()||u.endList&&e.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),e.paused()||s.load()}),i.on("error",bp[r](r,t))}},UM={AUDIO:function(r,i){var t=i.hls,e=i.sourceType,a=i.segmentLoaders[r],s=i.requestOptions,o=i.master.mediaGroups,u=i.mediaTypes[r],l=u.groups,d=u.tracks,c=i.masterPlaylistLoader;(!o[r]||Object.keys(o[r]).length===0)&&(o[r]={main:{default:{default:!0}}});for(var f in o[r]){l[f]||(l[f]=[]);for(var h in o[r][f]){var g=o[r][f][h],p=void 0;if(g.resolvedUri?p=new gp(g.resolvedUri,t,s):g.playlists&&e==="dash"?p=new g0(g.playlists[0],t,s,c):p=null,g=be.mergeOptions({id:h,playlistLoader:p},g),Kx[r](r,g.playlistLoader,i),l[f].push(g),typeof d[h]>"u"){var v=new be.AudioTrack({id:h,kind:FM(g),enabled:!1,language:g.language,default:g.default,label:h});d[h]=v}}}a.on("error",bp[r](r,i))},SUBTITLES:function(r,i){var t=i.tech,e=i.hls,a=i.sourceType,s=i.segmentLoaders[r],o=i.requestOptions,u=i.master.mediaGroups,l=i.mediaTypes[r],d=l.groups,c=l.tracks,f=i.masterPlaylistLoader;for(var h in u[r]){d[h]||(d[h]=[]);for(var g in u[r][h])if(!u[r][h][g].forced){var p=u[r][h][g],v=void 0;if(a==="hls"?v=new gp(p.resolvedUri,e,o):a==="dash"&&(v=new g0(p.playlists[0],e,o,f)),p=be.mergeOptions({id:g,playlistLoader:v},p),Kx[r](r,p.playlistLoader,i),d[h].push(p),typeof c[g]>"u"){var y=t.addRemoteTextTrack({id:g,kind:"subtitles",default:p.default&&p.autoselect,language:p.language,label:g},!1).track;c[g]=y}}}s.on("error",bp[r](r,i))},"CLOSED-CAPTIONS":function(r,i){var t=i.tech,e=i.master.mediaGroups,a=i.mediaTypes[r],s=a.groups,o=a.tracks;for(var u in e[r]){s[u]||(s[u]=[]);for(var l in e[r][u]){var d=e[r][u][l];if(!!d.instreamId.match(/CC\d/)&&(s[u].push(be.mergeOptions({id:l},d)),typeof o[l]>"u")){var c=t.addRemoteTextTrack({id:d.instreamId,kind:"captions",default:d.default&&d.autoselect,language:d.language,label:l},!1).track;o[l]=c}}}}},jM=function(r,i){return function(t){var e=i.masterPlaylistLoader,a=i.mediaTypes[r].groups,s=e.media();if(!s)return null;var o=null;return s.attributes[r]&&(o=a[s.attributes[r]]),o=o||a.main,typeof t>"u"?o:t===null?null:o.filter(function(u){return u.id===t.id})[0]||null}},$M={AUDIO:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var e in t)if(t[e].enabled)return t[e];return null}},SUBTITLES:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var e in t)if(t[e].mode==="showing")return t[e];return null}}},HM=function(r){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(d){UM[d](d,r)});var i=r.mediaTypes,t=r.masterPlaylistLoader,e=r.tech,a=r.hls;["AUDIO","SUBTITLES"].forEach(function(d){i[d].activeGroup=jM(d,r),i[d].activeTrack=$M[d](d,r),i[d].onGroupChanged=NM(d,r),i[d].onTrackChanged=BM(d,r)});var s=i.AUDIO.activeGroup(),o=(s.filter(function(d){return d.default})[0]||s[0]).id;i.AUDIO.tracks[o].enabled=!0,i.AUDIO.onTrackChanged(),t.on("mediachange",function(){["AUDIO","SUBTITLES"].forEach(function(d){return i[d].onGroupChanged()})});var u=function(){i.AUDIO.onTrackChanged(),e.trigger({type:"usage",name:"hls-audio-change"})};e.audioTracks().addEventListener("change",u),e.remoteTextTracks().addEventListener("change",i.SUBTITLES.onTrackChanged),a.on("dispose",function(){e.audioTracks().removeEventListener("change",u),e.remoteTextTracks().removeEventListener("change",i.SUBTITLES.onTrackChanged)}),e.clearTracks("audio");for(var l in i.AUDIO.tracks)e.audioTracks().addTrack(i.AUDIO.tracks[l])},VM=function(){var r={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(i){r[i]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Vc,activeTrack:Vc,onGroupChanged:Vc,onTrackChanged:Vc}}),r},GM=60*2,Xu=void 0,qM=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],WM=function(r){return this.audioSegmentLoader_[r]+this.mainSegmentLoader_[r]},KM=function(n){ou(r,n);function r(i){Gs(this,r);var t=ko(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),e=i.url,a=i.handleManifestRedirects,s=i.withCredentials,o=i.tech,u=i.bandwidth,l=i.externHls,d=i.useCueTags,c=i.blacklistDuration,f=i.enableLowInitialPlaylist,h=i.sourceType,g=i.seekTo,p=i.cacheEncryptionKeys;if(!e)throw new Error("A non-empty playlist URL is required");Xu=l,t.withCredentials=s,t.tech_=o,t.hls_=o.hls,t.seekTo_=g,t.sourceType_=h,t.useCueTags_=d,t.blacklistDuration=c,t.enableLowInitialPlaylist=f,t.useCueTags_&&(t.cueTagsTrack_=t.tech_.addTextTrack("metadata","ad-cues"),t.cueTagsTrack_.inBandMetadataTrackDispatchType=""),t.requestOptions_={withCredentials:s,handleManifestRedirects:a,timeout:null},t.mediaTypes_=VM(),t.mediaSource=new be.MediaSource,t.mediaSource.addEventListener("sourceopen",t.handleSourceOpen_.bind(t)),t.seekable_=be.createTimeRanges(),t.hasPlayed_=function(){return!1},t.syncController_=new LM(i),t.segmentMetadataTrack_=o.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,t.decrypter_=new MM,t.inbandTextTracks_={};var v={hls:t.hls_,mediaSource:t.mediaSource,currentTime:t.tech_.currentTime.bind(t.tech_),seekable:function(){return t.seekable()},seeking:function(){return t.tech_.seeking()},duration:function(){return t.mediaSource.duration},hasPlayed:function(){return t.hasPlayed_()},goalBufferLength:function(){return t.goalBufferLength()},bandwidth:u,syncController:t.syncController_,decrypter:t.decrypter_,sourceType:t.sourceType_,inbandTextTracks:t.inbandTextTracks_,cacheEncryptionKeys:p};return t.masterPlaylistLoader_=t.sourceType_==="dash"?new g0(e,t.hls_,t.requestOptions_):new gp(e,t.hls_,t.requestOptions_),t.setupMasterPlaylistLoaderListeners_(),t.mainSegmentLoader_=new y0(be.mergeOptions(v,{segmentMetadataTrack:t.segmentMetadataTrack_,loaderType:"main"}),i),t.audioSegmentLoader_=new y0(be.mergeOptions(v,{loaderType:"audio"}),i),t.subtitleSegmentLoader_=new PM(be.mergeOptions(v,{loaderType:"vtt"}),i),t.setupSegmentLoaderListeners_(),qM.forEach(function(y){t[y+"_"]=WM.bind(t,y)}),t.logger_=Tf("MPC"),t.masterPlaylistLoader_.load(),t}return so(r,[{key:"setupMasterPlaylistLoaderListeners_",value:function(){var t=this;this.masterPlaylistLoader_.on("loadedmetadata",function(){var e=t.masterPlaylistLoader_.media(),a=e.targetDuration*1.5*1e3;o0(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,e.endList&&t.tech_.preload()!=="none"&&(t.mainSegmentLoader_.playlist(e,t.requestOptions_),t.mainSegmentLoader_.load()),HM({sourceType:t.sourceType_,segmentLoaders:{AUDIO:t.audioSegmentLoader_,SUBTITLES:t.subtitleSegmentLoader_,main:t.mainSegmentLoader_},tech:t.tech_,requestOptions:t.requestOptions_,masterPlaylistLoader:t.masterPlaylistLoader_,hls:t.hls_,master:t.master(),mediaTypes:t.mediaTypes_,blacklistCurrentPlaylist:t.blacklistCurrentPlaylist.bind(t)}),t.triggerPresenceUsage_(t.master(),e);try{t.setupSourceBuffers_()}catch(s){return be.log.warn("Failed to create SourceBuffers",s),t.mediaSource.endOfStream("decode")}t.setupFirstPlay(),!t.mediaTypes_.AUDIO.activePlaylistLoader||t.mediaTypes_.AUDIO.activePlaylistLoader.media()?t.trigger("selectedinitialmedia"):t.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",function(){t.trigger("selectedinitialmedia")})}),this.masterPlaylistLoader_.on("loadedplaylist",function(){var e=t.masterPlaylistLoader_.media();if(!e){t.excludeUnsupportedVariants_();var a=void 0;t.enableLowInitialPlaylist&&(a=t.selectInitialPlaylist()),a||(a=t.selectPlaylist()),t.initialMedia_=a,t.masterPlaylistLoader_.media(t.initialMedia_);return}if(t.useCueTags_&&t.updateAdCues_(e),t.mainSegmentLoader_.playlist(e,t.requestOptions_),t.updateDuration(),t.tech_.paused()||(t.mainSegmentLoader_.load(),t.audioSegmentLoader_&&t.audioSegmentLoader_.load()),!e.endList){var s=function(){var l=t.seekable();l.length!==0&&t.mediaSource.addSeekableRange_(l.start(0),l.end(0))};if(t.duration()!==1/0){var o=function u(){t.duration()===1/0?s():t.tech_.one("durationchange",u)};t.tech_.one("durationchange",o)}else s()}}),this.masterPlaylistLoader_.on("error",function(){t.blacklistCurrentPlaylist(t.masterPlaylistLoader_.error)}),this.masterPlaylistLoader_.on("mediachanging",function(){t.mainSegmentLoader_.abort(),t.mainSegmentLoader_.pause()}),this.masterPlaylistLoader_.on("mediachange",function(){var e=t.masterPlaylistLoader_.media(),a=e.targetDuration*1.5*1e3;o0(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,t.mainSegmentLoader_.playlist(e,t.requestOptions_),t.mainSegmentLoader_.load(),t.tech_.trigger({type:"mediachange",bubbles:!0})}),this.masterPlaylistLoader_.on("playlistunchanged",function(){var e=t.masterPlaylistLoader_.media(),a=t.stuckAtPlaylistEnd_(e);a&&(t.blacklistCurrentPlaylist({message:"Playlist no longer updating."}),t.tech_.trigger("playliststuck"))}),this.masterPlaylistLoader_.on("renditiondisabled",function(){t.tech_.trigger({type:"usage",name:"hls-rendition-disabled"})}),this.masterPlaylistLoader_.on("renditionenabled",function(){t.tech_.trigger({type:"usage",name:"hls-rendition-enabled"})})}},{key:"triggerPresenceUsage_",value:function(t,e){var a=t.mediaGroups||{},s=!0,o=Object.keys(a.AUDIO);for(var u in a.AUDIO)for(var l in a.AUDIO[u]){var d=a.AUDIO[u][l];d.uri||(s=!1)}s&&this.tech_.trigger({type:"usage",name:"hls-demuxed"}),Object.keys(a.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"hls-webvtt"}),Xu.Playlist.isAes(e)&&this.tech_.trigger({type:"usage",name:"hls-aes"}),Xu.Playlist.isFmp4(e)&&this.tech_.trigger({type:"usage",name:"hls-fmp4"}),o.length&&Object.keys(a.AUDIO[o[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 t=this;this.mainSegmentLoader_.on("bandwidthupdate",function(){var e=t.selectPlaylist(),a=t.masterPlaylistLoader_.media(),s=t.tech_.buffered(),o=s.length?s.end(s.length-1)-t.tech_.currentTime():0,u=t.bufferLowWaterLine();(!a.endList||t.duration()<Ts.MAX_BUFFER_LOW_WATER_LINE||e.attributes.BANDWIDTH<a.attributes.BANDWIDTH||o>=u)&&t.masterPlaylistLoader_.media(e),t.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("progress",function(){t.trigger("progress")}),this.mainSegmentLoader_.on("error",function(){t.blacklistCurrentPlaylist(t.mainSegmentLoader_.error())}),this.mainSegmentLoader_.on("syncinfoupdate",function(){t.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",function(){t.tech_.trigger({type:"usage",name:"hls-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",function(){t.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("ended",function(){t.onEndOfStream()}),this.mainSegmentLoader_.on("earlyabort",function(){t.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},GM)}),this.mainSegmentLoader_.on("reseteverything",function(){t.tech_.trigger("hls-reset")}),this.mainSegmentLoader_.on("segmenttimemapping",function(e){t.tech_.trigger({type:"hls-segment-time-mapping",mapping:e.mapping})}),this.audioSegmentLoader_.on("ended",function(){t.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 t=this.selectPlaylist();t!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(t),this.mainSegmentLoader_.resetLoader())}},{key:"fastQualityChange_",value:function(){var t=this,e=this.selectPlaylist();e!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(e),this.mainSegmentLoader_.resetEverything(function(){be.browser.IE_VERSION||be.browser.IS_EDGE?t.tech_.setCurrentTime(t.tech_.currentTime()+.04):t.tech_.setCurrentTime(t.tech_.currentTime())}))}},{key:"play",value:function(){if(!this.setupFirstPlay()){this.tech_.ended()&&this.seekTo_(0),this.hasPlayed_()&&this.load();var t=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<t.start(0))return this.seekTo_(t.end(t.length-1))}}},{key:"setupFirstPlay",value:function(){var t=this,e=this.masterPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_())return!1;if(!e.endList){var a=this.seekable();if(!a.length)return!1;if(be.browser.IE_VERSION&&this.tech_.readyState()===0)return this.tech_.one("loadedmetadata",function(){t.trigger("firstplay"),t.seekTo_(a.end(0)),t.hasPlayed_=function(){return!0}}),!1;this.trigger("firstplay"),this.seekTo_(a.end(0))}return this.hasPlayed_=function(){return!0},this.load(),!0}},{key:"handleSourceOpen_",value:function(){try{this.setupSourceBuffers_()}catch(e){return be.log.warn("Failed to create Source Buffers",e),this.mediaSource.endOfStream("decode")}if(this.tech_.autoplay()){var t=this.tech_.play();typeof t<"u"&&typeof t.then=="function"&&t.then(null,function(e){})}this.trigger("sourceopen")}},{key:"onEndOfStream",value:function(){var t=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(!this.mainSegmentLoader_.startingMedia_||this.mainSegmentLoader_.startingMedia_.containsVideo?t=t&&this.audioSegmentLoader_.ended_:t=this.audioSegmentLoader_.ended_),!!t){this.logger_("calling mediaSource.endOfStream()");try{this.mediaSource.endOfStream()}catch(e){be.log.warn("Failed to call media source endOfStream",e)}}}},{key:"stuckAtPlaylistEnd_",value:function(t){var e=this.seekable();if(!e.length)return!1;var a=this.syncController_.getExpiredTime(t,this.mediaSource.duration);if(a===null)return!1;var s=Xu.Playlist.playlistEnd(t,a),o=this.tech_.currentTime(),u=this.tech_.buffered();if(!u.length)return s-o<=uu;var l=u.end(u.length-1);return l-o<=uu&&s-l<=uu}},{key:"blacklistCurrentPlaylist",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments[1],a=void 0,s=void 0;if(a=t.playlist||this.masterPlaylistLoader_.media(),e=e||t.blacklistDuration||this.blacklistDuration,!a){this.error=t;try{return this.mediaSource.endOfStream("network")}catch{return this.trigger("error")}}var o=this.masterPlaylistLoader_.master.playlists.filter(vp).length===1,u=this.masterPlaylistLoader_.master.playlists;return u.length===1?(be.log.warn("Problem encountered with the current HLS playlist. Trying again since it is the only playlist."),this.tech_.trigger("retryplaylist"),this.masterPlaylistLoader_.load(o)):(o&&(be.log.warn("Removing all playlists from the blacklist because the last rendition is about to be blacklisted."),u.forEach(function(l){l.excludeUntil!==1/0&&delete l.excludeUntil}),this.tech_.trigger("retryplaylist")),a.excludeUntil=Date.now()+e*1e3,this.tech_.trigger("blacklistplaylist"),this.tech_.trigger({type:"usage",name:"hls-rendition-blacklisted"}),s=this.selectPlaylist(),be.log.warn("Problem encountered with the current HLS playlist."+(t.message?" "+t.message:"")+" Switching to another playlist."),this.masterPlaylistLoader_.media(s,o))}},{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(t){var e=Sx(this.tech_.buffered(),t);if(!(this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media())||!this.masterPlaylistLoader_.media().segments)return 0;if(e&&e.length)return t;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()),this.load()}},{key:"duration",value:function(){return this.masterPlaylistLoader_?this.mediaSource?this.mediaSource.duration:Xu.Playlist.duration(this.masterPlaylistLoader_.media()):0}},{key:"seekable",value:function(){return this.seekable_}},{key:"onSyncInfoUpdate_",value:function(){var t=void 0,e=void 0;if(!!this.masterPlaylistLoader_){var a=this.masterPlaylistLoader_.media();if(!!a){var s=this.syncController_.getExpiredTime(a,this.mediaSource.duration);if(s!==null&&(t=Xu.Playlist.seekable(a,s),t.length!==0&&!(this.mediaTypes_.AUDIO.activePlaylistLoader&&(a=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),s=this.syncController_.getExpiredTime(a,this.mediaSource.duration),s===null||(e=Xu.Playlist.seekable(a,s),e.length===0))))){var o=void 0,u=void 0;this.seekable_&&this.seekable_.length&&(o=this.seekable_.end(0),u=this.seekable_.start(0)),e?e.start(0)>t.end(0)||t.start(0)>e.end(0)?this.seekable_=t:this.seekable_=be.createTimeRanges([[e.start(0)>t.start(0)?e.start(0):t.start(0),e.end(0)<t.end(0)?e.end(0):t.end(0)]]):this.seekable_=t,!(this.seekable_&&this.seekable_.length&&this.seekable_.end(0)===o&&this.seekable_.start(0)===u)&&(this.logger_("seekable updated ["+l0(this.seekable_)+"]"),this.tech_.trigger("seekablechanged"))}}}}},{key:"updateDuration",value:function(){var t=this,e=this.mediaSource.duration,a=Xu.Playlist.duration(this.masterPlaylistLoader_.media()),s=this.tech_.buffered(),o=function u(){t.logger_("Setting duration from "+t.mediaSource.duration+" => "+a);try{t.mediaSource.duration=a}catch(l){be.log.warn("Failed to set media source duration",l)}t.tech_.trigger("durationchange"),t.mediaSource.removeEventListener("sourceopen",u)};s.length>0&&(a=Math.max(a,s.end(s.length-1))),e!==a&&(this.mediaSource.readyState!=="open"?this.mediaSource.addEventListener("sourceopen",o):o())}},{key:"dispose",value:function(){var t=this;this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),["AUDIO","SUBTITLES"].forEach(function(e){var a=t.mediaTypes_[e].groups;for(var s in a)a[s].forEach(function(o){o.playlistLoader&&o.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose()}},{key:"master",value:function(){return this.masterPlaylistLoader_.master}},{key:"media",value:function(){return this.masterPlaylistLoader_.media()||this.initialMedia_}},{key:"setupSourceBuffers_",value:function(){var t=this.masterPlaylistLoader_.media(),e=void 0;if(!(!t||this.mediaSource.readyState!=="open")){if(e=Q2(this.masterPlaylistLoader_.master,t),e.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(t){var e=t.length>1&&t[0].indexOf(",")===-1&&t[0]!==t[1]?new be.EventTarget:null;this.mainSegmentLoader_.mimeType(t[0],e),t[1]&&this.audioSegmentLoader_.mimeType(t[1],e)}},{key:"excludeUnsupportedVariants_",value:function(){this.master().playlists.forEach(function(t){t.attributes.CODECS&&tt.MediaSource&&tt.MediaSource.isTypeSupported&&!tt.MediaSource.isTypeSupported('video/mp4; codecs="'+K2(t.attributes.CODECS)+'"')&&(t.excludeUntil=1/0)})}},{key:"excludeIncompatibleVariants_",value:function(t){var e=2,a=null,s=void 0;t.attributes.CODECS&&(s=yf(t.attributes.CODECS),a=s.videoCodec,e=s.codecCount),this.master().playlists.forEach(function(o){var u={codecCount:2,videoCodec:null};o.attributes.CODECS&&(u=yf(o.attributes.CODECS)),u.codecCount!==e&&(o.excludeUntil=1/0),u.videoCodec!==a&&(o.excludeUntil=1/0)})}},{key:"updateAdCues_",value:function(t){var e=0,a=this.seekable();a.length&&(e=a.start(0)),IM(t,this.cueTagsTrack_,e)}},{key:"goalBufferLength",value:function(){var t=this.tech_.currentTime(),e=Ts.GOAL_BUFFER_LENGTH,a=Ts.GOAL_BUFFER_LENGTH_RATE,s=Math.max(e,Ts.MAX_GOAL_BUFFER_LENGTH);return Math.min(e+t*a,s)}},{key:"bufferLowWaterLine",value:function(){var t=this.tech_.currentTime(),e=Ts.BUFFER_LOW_WATER_LINE,a=Ts.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(e,Ts.MAX_BUFFER_LOW_WATER_LINE);return Math.min(e+t*a,s)}}]),r}(be.EventTarget),zM=function(r,i,t){return function(e){var a=r.master.playlists[i],s=s0(a),o=vp(a);return typeof e>"u"?o:(e?delete a.disabled:a.disabled=!0,e!==o&&!s&&(t(),e?r.trigger("renditionenabled"):r.trigger("renditiondisabled")),e)}},XM=function n(r,i,t){Gs(this,n);var e=r.masterPlaylistController_,a=r.options_.smoothQualityChange,s=a?"smooth":"fast",o=e[s+"QualityChange_"].bind(e);if(i.attributes.RESOLUTION){var u=i.attributes.RESOLUTION;this.width=u.width,this.height=u.height}this.bandwidth=i.attributes.BANDWIDTH,this.id=t,this.enabled=zM(r.playlists,i.uri,o)},YM=function(r){var i=r.playlists;r.representations=function(){return i.master.playlists.filter(function(t){return!s0(t)}).map(function(t,e){return new XM(r,t,t.uri)})}},zx=["seeking","seeked","pause","playing","error"],QM=function(){function n(r){var i=this;Gs(this,n),this.tech_=r.tech,this.seekable=r.seekable,this.seekTo=r.seekTo,this.allowSeeksWithinUnsafeLiveWindow=r.allowSeeksWithinUnsafeLiveWindow,this.media=r.media,this.consecutiveUpdates=0,this.lastRecordedTime=null,this.timer_=null,this.checkCurrentTimeTimeout_=null,this.logger_=Tf("PlaybackWatcher"),this.logger_("initialize");var t=function(){return i.monitorCurrentTime_()},e=function(){return i.techWaiting_()},a=function(){return i.cancelTimer_()},s=function(){return i.fixesBadSeeks_()};this.tech_.on("seekablechanged",s),this.tech_.on("waiting",e),this.tech_.on(zx,a),this.tech_.on("canplay",t),this.dispose=function(){i.logger_("dispose"),i.tech_.off("seekablechanged",s),i.tech_.off("waiting",e),i.tech_.off(zx,a),i.tech_.off("canplay",t),i.checkCurrentTimeTimeout_&&tt.clearTimeout(i.checkCurrentTimeTimeout_),i.cancelTimer_()}}return so(n,[{key:"monitorCurrentTime_",value:function(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&tt.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=tt.setTimeout(this.monitorCurrentTime_.bind(this),250)}},{key:"checkCurrentTime_",value:function(){if(this.tech_.seeking()&&this.fixesBadSeeks_()){this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime();return}if(!(this.tech_.paused()||this.tech_.seeking())){var i=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===i&&(!t.length||i+uu>=t.end(t.length-1)))return this.techWaiting_();this.consecutiveUpdates>=5&&i===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):i===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=i)}}},{key:"cancelTimer_",value:function(){this.consecutiveUpdates=0,this.timer_&&(this.logger_("cancelTimer_"),clearTimeout(this.timer_)),this.timer_=null}},{key:"fixesBadSeeks_",value:function(){var i=this.tech_.seeking();if(!i)return!1;var t=this.seekable(),e=this.tech_.currentTime(),a=this.afterSeekableWindow_(t,e,this.media(),this.allowSeeksWithinUnsafeLiveWindow),s=void 0;if(a){var o=t.end(t.length-1);s=o}if(this.beforeSeekableWindow_(t,e)){var u=t.start(0);s=u+uu}return typeof s<"u"?(this.logger_("Trying to seek outside of seekable at time "+e+" with "+("seekable range "+l0(t)+". Seeking to ")+(s+".")),this.seekTo(s),!0):!1}},{key:"waiting_",value:function(){if(!this.techWaiting_()){var i=this.tech_.currentTime(),t=this.tech_.buffered(),e=Sx(t,i);if(e.length&&i+3<=e.end(0)){this.cancelTimer_(),this.seekTo(i),this.logger_("Stopped at "+i+" while inside a buffered region "+("["+e.start(0)+" -> "+e.end(0)+"]. Attempting to resume ")+"playback by seeking to the current time."),this.tech_.trigger({type:"usage",name:"hls-unknown-waiting"});return}}}},{key:"techWaiting_",value:function(){var i=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_()||this.tech_.seeking()||this.timer_!==null)return!0;if(this.beforeSeekableWindow_(i,t)){var e=i.end(i.length-1);return this.logger_("Fell out of live window at time "+t+". Seeking to "+("live point (seekable end) "+e)),this.cancelTimer_(),this.seekTo(e),this.tech_.trigger({type:"usage",name:"hls-live-resync"}),!0}var a=this.tech_.buffered(),s=Ex(a,t);if(this.videoUnderflow_(s,a,t))return this.cancelTimer_(),this.seekTo(t),this.tech_.trigger({type:"usage",name:"hls-video-underflow"}),!0;if(s.length>0){var o=s.start(0)-t;return this.logger_("Stopped at "+t+", setting timer for "+o+", seeking "+("to "+s.start(0))),this.timer_=setTimeout(this.skipTheGap_.bind(this),o*1e3,t),!0}return!1}},{key:"afterSeekableWindow_",value:function(i,t,e){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!i.length)return!1;var s=i.end(i.length-1)+uu,o=!e.endList;return o&&a&&(s=i.end(i.length-1)+e.targetDuration*3),t>s}},{key:"beforeSeekableWindow_",value:function(i,t){return!!(i.length&&i.start(0)>0&&t<i.start(0)-uu)}},{key:"videoUnderflow_",value:function(i,t,e){if(i.length===0){var a=this.gapFromVideoUnderflow_(t,e);if(a)return this.logger_("Encountered a gap in video from "+a.start+" to "+a.end+". "+("Seeking to current time "+e)),!0}return!1}},{key:"skipTheGap_",value:function(i){var t=this.tech_.buffered(),e=this.tech_.currentTime(),a=Ex(t,e);this.cancelTimer_(),!(a.length===0||e!==i)&&(this.logger_("skipTheGap_:","currentTime:",e,"scheduled currentTime:",i,"nextRange start:",a.start(0)),this.seekTo(a.start(0)+yp),this.tech_.trigger({type:"usage",name:"hls-gap-skip"}))}},{key:"gapFromVideoUnderflow_",value:function(i,t){for(var e=B2(i),a=0;a<e.length;a++){var s=e.start(a),o=e.end(a);if(t-s<4&&t-s>2)return{start:s,end:o}}return null}}]),n}(),JM={errorInterval:30,getSource:function(r){var i=this.tech({IWillNotUseThisInPlugins:!0}),t=i.currentSource_;return r(t)}},ZM=function n(r,i){var t=0,e=0,a=be.mergeOptions(JM,i);r.ready(function(){r.trigger({type:"usage",name:"hls-error-reload-initialized"})});var s=function(){e&&r.currentTime(e)},o=function(f){f!=null&&(e=r.duration()!==1/0&&r.currentTime()||0,r.one("loadedmetadata",s),r.src(f),r.trigger({type:"usage",name:"hls-error-reload"}),r.play())},u=function(){if(Date.now()-t<a.errorInterval*1e3){r.trigger({type:"usage",name:"hls-error-reload-canceled"});return}if(!a.getSource||typeof a.getSource!="function"){be.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),a.getSource.call(r,o)},l=function c(){r.off("loadedmetadata",s),r.off("error",u),r.off("dispose",c)},d=function(f){l(),n(r,f)};r.on("error",u),r.on("dispose",l),r.reloadSourceOnError=d},Xx=function(r){ZM(this,r)},eF="1.10.6";be.use("*",function(n){return{setSource:function(i,t){t(null,i)},setCurrentTime:function(i){return n.vhs&&n.currentSource().src===n.vhs.source_.src&&n.vhs.setCurrentTime(i),i},play:function(){n.vhs&&n.currentSource().src===n.vhs.source_.src&&n.vhs.setCurrentTime(n.tech_.currentTime())}}});var as={PlaylistLoader:gp,Playlist:ns,Decrypter:OO,AsyncStream:yS,decrypt:_S,utils:D2,STANDARD_PLAYLIST_SELECTOR:TM,INITIAL_PLAYLIST_SELECTOR:SM,comparePlaylistBandwidth:m0,comparePlaylistResolution:yM,xhr:vx()};["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(n){Object.defineProperty(as,n,{get:function(){return be.log.warn("using Hls."+n+" is UNSAFE be sure you know what you are doing"),Ts[n]},set:function(i){if(be.log.warn("using Hls."+n+" is UNSAFE be sure you know what you are doing"),typeof i!="number"||i<0){be.log.warn("value of Hls."+n+" must be greater than or equal to 0");return}Ts[n]=i}})});var Yx="videojs-vhs",Qx=function(r){var i=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;if(i.test(r))return"hls";var t=/^application\/dash\+xml/i;return t.test(r)?"dash":null},Jx=function(r,i){for(var t=i.media(),e=-1,a=0;a<r.length;a++)if(r[a].id===t.uri){e=a;break}r.selectedIndex_=e,r.trigger({selectedIndex:e,type:"change"})},tF=function(r,i){i.representations().forEach(function(t){r.addQualityLevel(t)}),Jx(r,i.playlists)};as.canPlaySource=function(){return be.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var rF=function(r,i,t){if(!r)return r;var e={};for(var a in r)e[a]={audioContentType:'audio/mp4; codecs="'+t.attributes.CODECS+'"',videoContentType:'video/mp4; codecs="'+i.attributes.CODECS+'"'},i.contentProtection&&i.contentProtection[a]&&i.contentProtection[a].pssh&&(e[a].pssh=i.contentProtection[a].pssh),typeof r[a]=="string"&&(e[a].url=r[a]);return be.mergeOptions(r,e)},iF=function(r){if(r.options_.sourceType==="dash"){var i=be.players[r.tech_.options_.playerId];if(i.eme){var t=rF(r.source_.keySystems,r.playlists.media(),r.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader.media());t&&(i.currentSource().keySystems=t,i.eme.initializeMediaKeys&&i.eme.initializeMediaKeys())}}},Zx=function(){if(!window.localStorage)return null;var r=window.localStorage.getItem(Yx);if(!r)return null;try{return JSON.parse(r)}catch{return null}},nF=function(r){if(!window.localStorage)return!1;var i=Zx();i=i?be.mergeOptions(i,r):r;try{window.localStorage.setItem(Yx,JSON.stringify(i))}catch{return!1}return i};as.supportsNativeHls=function(){var n=sr.createElement("video");if(!be.getTech("Html5").isSupported())return!1;var r=["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"];return r.some(function(i){return/maybe|probably/i.test(n.canPlayType(i))})}(),as.supportsNativeDash=function(){return be.getTech("Html5").isSupported()?/maybe|probably/i.test(sr.createElement("video").canPlayType("application/dash+xml")):!1}(),as.supportsTypeNatively=function(n){return n==="hls"?as.supportsNativeHls:n==="dash"?as.supportsNativeDash:!1},as.isSupported=function(){return be.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var aF=be.getComponent("Component"),eA=function(n){ou(r,n);function r(i,t,e){Gs(this,r);var a=ko(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t,e.hls));if(t.options_&&t.options_.playerId){var s=be(t.options_.playerId);s.hasOwnProperty("hls")||Object.defineProperty(s,"hls",{get:function(){return be.log.warn("player.hls is deprecated. Use player.tech().hls instead."),t.trigger({type:"usage",name:"hls-player-access"}),a},configurable:!0}),s.vhs=a,s.dash=a,a.player_=s}if(a.tech_=t,a.source_=i,a.stats={},a.setOptions_(),a.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(a.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native HLS requires emulated tracks. See https://git.io/vMpjB");return a.on(sr,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],function(o){var u=sr.fullscreenElement||sr.webkitFullscreenElement||sr.mozFullScreenElement||sr.msFullscreenElement;u&&u.contains(a.tech_.el())&&a.masterPlaylistController_.smoothQualityChange_()}),a.on(a.tech_,"seeking",function(){this.tech_.currentTime()===0&&this.tech_.player_.loop()&&this.setCurrentTime(0)}),a.on(a.tech_,"error",function(){this.masterPlaylistController_&&this.masterPlaylistController_.pauseLoading()}),a.on(a.tech_,"play",a.play),a}return so(r,[{key:"setOptions_",value:function(){var t=this;if(this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.handleManifestRedirects=this.options_.handleManifestRedirects||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.smoothQualityChange=this.options_.smoothQualityChange||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,typeof this.options_.blacklistDuration!="number"&&(this.options_.blacklistDuration=5*60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){var e=Zx();e&&e.bandwidth&&(this.options_.bandwidth=e.bandwidth,this.tech_.trigger({type:"usage",name:"hls-bandwidth-from-local-storage"})),e&&e.throughput&&(this.options_.throughput=e.throughput,this.tech_.trigger({type:"usage",name:"hls-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=Ts.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===Ts.INITIAL_BANDWIDTH,["withCredentials","limitRenditionByPlayerDimensions","bandwidth","smoothQualityChange","customTagParsers","customTagMappers","handleManifestRedirects","cacheEncryptionKeys"].forEach(function(a){typeof t.source_[a]<"u"&&(t.options_[a]=t.source_[a])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions}},{key:"src",value:function(t,e){var a=this;!t||(this.setOptions_(),this.options_.url=this.source_.src,this.options_.tech=this.tech_,this.options_.externHls=as,this.options_.sourceType=Qx(e),this.options_.seekTo=function(s){a.tech_.setCurrentTime(s),a.setCurrentTime(s)},this.masterPlaylistController_=new KM(this.options_),this.playbackWatcher_=new QM(be.mergeOptions(this.options_,{seekable:function(){return a.seekable()},media:function(){return a.masterPlaylistController_.media()}})),this.masterPlaylistController_.on("error",function(){var s=be.players[a.tech_.options_.playerId];s.error(a.masterPlaylistController_.error)}),this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):as.STANDARD_PLAYLIST_SELECTOR.bind(this),this.masterPlaylistController_.selectInitialPlaylist=as.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.masterPlaylistController_.masterPlaylistLoader_,this.mediaSource=this.masterPlaylistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get:function(){return this.masterPlaylistController_.selectPlaylist},set:function(o){this.masterPlaylistController_.selectPlaylist=o.bind(this)}},throughput:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.throughput.rate},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.throughput.rate=o,this.masterPlaylistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.bandwidth},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.bandwidth=o,this.masterPlaylistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get:function(){var o=1/(this.bandwidth||1),u=void 0;this.throughput>0?u=1/this.throughput:u=0;var l=Math.floor(1/(o+u));return l},set:function(){be.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 a.bandwidth||0},enumerable:!0},mediaRequests:{get:function(){return a.masterPlaylistController_.mediaRequests_()||0},enumerable:!0},mediaRequestsAborted:{get:function(){return a.masterPlaylistController_.mediaRequestsAborted_()||0},enumerable:!0},mediaRequestsTimedout:{get:function(){return a.masterPlaylistController_.mediaRequestsTimedout_()||0},enumerable:!0},mediaRequestsErrored:{get:function(){return a.masterPlaylistController_.mediaRequestsErrored_()||0},enumerable:!0},mediaTransferDuration:{get:function(){return a.masterPlaylistController_.mediaTransferDuration_()||0},enumerable:!0},mediaBytesTransferred:{get:function(){return a.masterPlaylistController_.mediaBytesTransferred_()||0},enumerable:!0},mediaSecondsLoaded:{get:function(){return a.masterPlaylistController_.mediaSecondsLoaded_()||0},enumerable:!0},buffered:{get:function(){return xx(a.tech_.buffered())},enumerable:!0},currentTime:{get:function(){return a.tech_.currentTime()},enumerable:!0},currentSource:{get:function(){return a.tech_.currentSource_},enumerable:!0},currentTech:{get:function(){return a.tech_.name_},enumerable:!0},duration:{get:function(){return a.tech_.duration()},enumerable:!0},master:{get:function(){return a.playlists.master},enumerable:!0},playerDimensions:{get:function(){return a.tech_.currentDimensions()},enumerable:!0},seekable:{get:function(){return xx(a.tech_.seekable())},enumerable:!0},timestamp:{get:function(){return Date.now()},enumerable:!0},videoPlaybackQuality:{get:function(){return a.tech_.getVideoPlaybackQuality()},enumerable:!0}}),this.tech_.one("canplay",this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_)),this.tech_.on("bandwidthupdate",function(){a.options_.useBandwidthFromLocalStorage&&nF({bandwidth:a.bandwidth,throughput:Math.round(a.throughput)})}),this.masterPlaylistController_.on("selectedinitialmedia",function(){YM(a),iF(a)}),this.on(this.masterPlaylistController_,"progress",function(){this.tech_.trigger("progress")}),this.tech_.ready(function(){return a.setupQualityLevels_()}),this.tech_.el()&&this.tech_.src(be.URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var t=this,e=be.players[this.tech_.options_.playerId];e&&e.qualityLevels&&(this.qualityLevels_=e.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",function(){tF(t.qualityLevels_,t)}),this.playlists.on("mediachange",function(){Jx(t.qualityLevels_,t.playlists)}))}},{key:"play",value:function(){this.masterPlaylistController_.play()}},{key:"setCurrentTime",value:function(t){this.masterPlaylistController_.setCurrentTime(t)}},{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,a2(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"dispose",this).call(this)}},{key:"convertToProgramTime",value:function(t,e){return F2({playlist:this.masterPlaylistController_.media(),time:t,callback:e})}},{key:"seekToProgramTime",value:function(t,e){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:2;return N2({programTime:t,playlist:this.masterPlaylistController_.media(),retryCount:s,pauseAfterSeek:a,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:e})}}]),r}(aF),T0={name:"videojs-http-streaming",VERSION:eF,canHandleSource:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=be.mergeOptions(be.options,i);return T0.canPlayType(r.type,t)},handleSource:function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},e=be.mergeOptions(be.options,t);return i.hls=new eA(r,i,e),i.hls.xhr=vx(),i.hls.src(r.src,r.type),i.hls},canPlayType:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=be.mergeOptions(be.options,i),e=t.hls.overrideNative,a=Qx(r),s=a&&(!as.supportsTypeNatively(a)||e);return s?"maybe":""}};(typeof be.MediaSource>"u"||typeof be.URL>"u")&&(be.MediaSource=_f,be.URL=Fx),_f.supportsNativeMediaSources()&&be.getTech("Html5").registerSourceHandler(T0,0),be.HlsHandler=eA,be.HlsSourceHandler=T0,be.Hls=as,be.use||be.registerComponent("Hls",as),be.options.hls=be.options.hls||{},be.registerPlugin?be.registerPlugin("reloadSourceOnError",Xx):be.plugin("reloadSourceOnError",Xx);const sF=Object.freeze(Object.defineProperty({__proto__:null,default:be},Symbol.toStringTag,{value:"Module"})),oF={name:"stream-engine-player",version:"0.0.25",description:"Stream engine player",type:"module",files:["dist","src","index.js","README.md","LICENSE","package.json","vite.config.js"],exports:{".":{import:"./dist/stream-engine-player.mjs",require:"./dist/stream-engine-player.js"},"./style":{import:"./dist/style.css",require:"./dist/style.css"},"./bundle":{import:"./dist/stream-engine-player-bundle.mjs",require:"./dist/stream-engine-player-bundle.js"}},main:"dist/stream-engine-player.js",author:"Dok Umansky",scripts:{dev:"vite serve",build:'concurrently "vite build --mode bundle" "vite build"',serve:"vite preview",start:"npm run dev",prebuild:"rm -rf dist","version:patch":"npm version patch",lint:"./node_modules/.bin/eslint src",format:'prettier "src/**/*.{ts,js,json,scss,css}" --write',watch:'concurrently "vite build --watch" "vite serve"',"build:watch":"vite build --watch --minify=false"},dependencies:{angular:"~1.4.8","angular-cookies":"~1.4.8","font-awesome":"^4.7.0","hls.js":"^0.12.4","include-media":"^2.0.0",localforage:"^1.10.0","m3u8-parser":"^7.1.0","mixpanel-browser":"2.52.0","video.js":"7.6.6","videojs-youtube":"^2.6.1","videojs-ima":"1.7.5","videojs-contrib-ads":"6.6.5","videojs-mux":"4.19.0","infront-logger":"1.1.11"},devDependencies:{concurrently:"^8.2.1",eslint:"^8.24.0","eslint-config-prettier":"^8.5.0","eslint-plugin-angular":"^4.1.0","eslint-plugin-prettier":"^4.2.1",husky:"^8.0.1",hygen:"^6.2.11","lint-staged":"^13.0.3",prettier:"^2.7.1",sass:"^1.55.0",vite:"^3.2.7"},husky:{hooks:{"pre-commit":"lint-staged"}},"lint-staged":{"*.{ts,js,json,scss,css}":["prettier --write","git add"]}},gG="";/**
|
105
105
|
* @license AngularJS v1.4.14
|
106
106
|
* (c) 2010-2015 Google, Inc. http://angularjs.org
|
107
107
|
* License: MIT
|