stream-engine-player 0.0.45 → 0.0.46

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.
@@ -78,7 +78,7 @@ See https://github.com/videojs/video.js/issues/2617 for more info.
78
78
  `;return n},Ux=function(r){var i=r.bytes;return Cm(i)},Bx=function(r){var i="",t=void 0;for(t=0;t<r.length;t++)i+=Mx(r,t)+" ";return i},jx=Object.freeze({createTransferableMessage:Am,initSegmentId:Nu,segmentKeyId:km,hexDump:Cm,tagDump:Ux,textRanges:Bx}),Rm=.25,Hx=function(r,i){if(!i.dateTimeObject)return null;var t=i.videoTimingInfo.transmuxerPrependedSeconds,n=i.videoTimingInfo.transmuxedPresentationStart,a=n+t,s=r-a;return new Date(i.dateTimeObject.getTime()+s*1e3)},Gx=function(r){return r.transmuxedPresentationEnd-r.transmuxedPresentationStart-r.transmuxerPrependedSeconds},Vx=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 n=i.segments[0];if(t<n.dateTimeObject)return null;for(var a=0;a<i.segments.length-1;a++){n=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?Gx(o.videoTimingInfo):o.duration+o.duration*Rm,h=new Date(u.getTime()+l*1e3);return t>h?null:(t>u&&(n=o),{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:ti.duration(i,i.mediaSequence+i.segments.indexOf(n)),type:n.videoTimingInfo?"accurate":"estimate"})},Wx=function(r,i){if(!i||!i.segments||i.segments.length===0)return null;for(var t=0,n=void 0,a=0;a<i.segments.length&&(n=i.segments[a],t=n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationEnd:t+n.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*Rm)return null;n=s}return{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:t-n.duration,type:n.videoTimingInfo?"accurate":"estimate"}},qx=function(r,i){var t=void 0,n=void 0;try{t=new Date(r),n=new Date(i)}catch{}var a=t.getTime(),s=n.getTime();return(s-a)/1e3},Yx=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},Kx=function(r){var i=r.playlist,t=r.time,n=t===void 0?void 0:t,a=r.callback;if(!a)throw new Error("getProgramTime: callback must be provided");if(!i||n===void 0)return a({message:"getProgramTime: playlist and time must be provided"});var s=Wx(n,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:n},u=Hx(n,s.segment);return u&&(o.programDateTime=u.toISOString()),a(null,o)},$x=function e(r){var i=r.programTime,t=r.playlist,n=r.retryCount,a=n===void 0?2:n,s=r.seekTo,o=r.pauseAfterSeek,u=o===void 0?!0:o,l=r.tech,h=r.callback;if(!h)throw new Error("seekToProgramTime: callback must be provided");if(typeof i>"u"||!t||!s)return h({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!t.endList&&!l.hasStarted_)return h({message:"player must be playing a live stream to start buffering"});if(!Yx(t))return h({message:"programDateTime tags must be provided in the manifest "+t.resolvedUri});var d=Vx(i,t);if(!d)return h({message:i+" was not found in the stream"});var g=d.segment,c=qx(g.dateTimeObject,i);if(d.type==="estimate"){if(a===0)return h({message:i+" is not buffered yet. Try again"});s(d.estimatedStart+c),l.one("seeked",function(){e({programTime:i,playlist:t,retryCount:a-1,seekTo:s,pauseAfterSeek:u,tech:l,callback:h})});return}var b=g.start+c,f=function(){return h(null,l.currentTime())};l.one("seeked",f),u&&l.pause(),s(b)},Fu=1/30,_n=Fu*3,Dm=function(r,i){var t=[],n=void 0;if(r&&r.length)for(n=0;n<r.length;n++)i(r.start(n),r.end(n))&&t.push([r.start(n),r.end(n)]);return W.createTimeRanges(t)},Pm=function(r,i){return Dm(r,function(t,n){return t-_n<=i&&n+_n>=i})},Lm=function(r,i){return Dm(r,function(t){return t-Fu>=i})},zx=function(r){if(r.length<2)return W.createTimeRanges();for(var i=[],t=1;t<r.length;t++){var n=r.end(t-1),a=r.start(t);i.push([n,a])}return W.createTimeRanges(i)},kf=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(", ")},Xx=function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,n=r.length?r.end(r.length-1):0;return(n-i)/t},Om=function(r){for(var i=[],t=0;t<r.length;t++)i.push({start:r.start(t),end:r.end(t)});return i},Jx=function(r,i,t){var n=i.player_;if(t.captions&&t.captions.length){r.inbandTextTracks_||(r.inbandTextTracks_={});for(var a in t.captionStreams)if(!r.inbandTextTracks_[a]){n.tech_.trigger({type:"usage",name:"hls-608"});var s=n.textTracks().getTrackById(a);s?r.inbandTextTracks_[a]=s:r.inbandTextTracks_[a]=n.addRemoteTextTrack({kind:"captions",id:a,label:a},!1).track}}t.metadata&&t.metadata.length&&!r.metadataTrack_&&(r.metadataTrack_=n.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,r.metadataTrack_.inBandMetadataTrackDispatchType=t.metadata.dispatchType)},Gs=function(r,i,t){var n=void 0,a=void 0;if(!!t&&!!t.cues)for(n=t.cues.length;n--;)a=t.cues[n],a.startTime<=i&&a.endTime>=r&&t.removeCue(a)},Qx=function(r){Object.defineProperties(r.frame,{id:{get:function(){return W.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),r.value.key}},value:{get:function(){return W.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),r.value.data}},privateData:{get:function(){return W.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),r.value.data}}})},Im=function(r){var i=void 0;return isNaN(r)||Math.abs(r)===1/0?i=Number.MAX_VALUE:i=r,i},Zx=function(r,i,t){var n=ge.WebKitDataCue||ge.VTTCue;if(i&&i.forEach(function(d){var g=d.stream;this.inbandTextTracks_[g].addCue(new n(d.startTime+this.timestampOffset,d.endTime+this.timestampOffset,d.text))},r),t){var a=Im(r.mediaSource_.duration);if(t.forEach(function(d){var g=d.cueTime+this.timestampOffset;typeof g!="number"||ge.isNaN(g)||g<0||!(g<1/0)||d.frames.forEach(function(c){var b=new n(g,g,c.value||c.url||c.data||"");b.frame=c,b.value=c,Qx(b),this.metadataTrack_.addCue(b)},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(d,g){var c=d[g.startTime]||[];return c.push(g),d[g.startTime]=c,d},{}),h=Object.keys(l).sort(function(d,g){return Number(d)-Number(g)});h.forEach(function(d,g){var c=l[d],b=Number(h[g+1])||a;c.forEach(function(f){f.endTime=b})})}}},qa=typeof window<"u"?window:{},Cf=typeof Symbol>"u"?"__target":Symbol(),ew="application/javascript",tw=qa.BlobBuilder||qa.WebKitBlobBuilder||qa.MozBlobBuilder||qa.MSBlobBuilder,Vs=qa.URL||qa.webkitURL||Vs&&Vs.msURL,Ws=qa.Worker;function Mm(e,r){return function(t){var n=this;if(r)if(Ws&&!t){var a=r.toString().replace(/^function.+?{/,"").slice(0,-1),s=Um(a);return this[Cf]=new Ws(s),rw(this[Cf],s),this[Cf]}else{var o={postMessage:function(l){n.onmessage&&setTimeout(function(){n.onmessage({data:l,target:o})})}};r.call(o),this.postMessage=function(u){setTimeout(function(){o.onmessage({data:u,target:n})})},this.isThisThread=!0}else return new Ws(e)}}if(Ws){var Uu,Nm=Um("self.onmessage = function () {}"),Fm=new Uint8Array(1);try{Uu=new Ws(Nm),Uu.postMessage(Fm,[Fm.buffer])}catch{Ws=null}finally{Vs.revokeObjectURL(Nm),Uu&&Uu.terminate()}}function Um(e){try{return Vs.createObjectURL(new Blob([e],{type:ew}))}catch{var r=new tw;return r.append(e),Vs.createObjectURL(r.getBlob(type))}}function rw(e,r){if(!(!e||!r)){var i=e.terminate;e.objURL=r,e.terminate=function(){e.objURL&&Vs.revokeObjectURL(e.objURL),i.call(e)}}}var iw=new Mm("./transmuxer-worker.worker.js",function(e,r){var i=this;(function(){var t=function(){this.init=function(){var F={};this.on=function(j,K){F[j]||(F[j]=[]),F[j]=F[j].concat(K)},this.off=function(j,K){var q;return F[j]?(q=F[j].indexOf(K),F[j]=F[j].slice(),F[j].splice(q,1),q>-1):!1},this.trigger=function(j){var K,q,ee,re;if(K=F[j],!!K)if(arguments.length===2)for(ee=K.length,q=0;q<ee;++q)K[q].call(this,arguments[1]);else{for(re=[],q=arguments.length,q=1;q<arguments.length;++q)re.push(arguments[q]);for(ee=K.length,q=0;q<ee;++q)K[q].apply(this,re)}},this.dispose=function(){F={}}}};t.prototype.pipe=function(se){return this.on("data",function(F){se.push(F)}),this.on("done",function(F){se.flush(F)}),this.on("partialdone",function(F){se.partialFlush(F)}),this.on("endedtimeline",function(F){se.endTimeline(F)}),this.on("reset",function(F){se.reset(F)}),se},t.prototype.push=function(se){this.trigger("data",se)},t.prototype.flush=function(se){this.trigger("done",se)},t.prototype.partialFlush=function(se){this.trigger("partialdone",se)},t.prototype.endTimeline=function(se){this.trigger("endedtimeline",se)},t.prototype.reset=function(se){this.trigger("reset",se)};var n=t,a=Math.pow(2,32)-1,s,o,u,l,h,d,g,c,b,f,m,y,v,p,S,E,w,x,T,A,k,C,R,P,I,D,L,O,N,B,H,J,ie,Q,ne,ue;(function(){var se;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(se in R)R.hasOwnProperty(se)&&(R[se]=[se.charCodeAt(0),se.charCodeAt(1),se.charCodeAt(2),se.charCodeAt(3)]);P=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]),D=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]),I=new Uint8Array([0,0,0,1]),L=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]),O=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]),N={video:L,audio:O},J=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),H=new Uint8Array([0,0,0,0,0,0,0,0]),ie=new Uint8Array([0,0,0,0,0,0,0,0]),Q=ie,ne=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),ue=ie,B=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}})(),s=function(F){var j=[],K=0,q,ee,re;for(q=1;q<arguments.length;q++)j.push(arguments[q]);for(q=j.length;q--;)K+=j[q].byteLength;for(ee=new Uint8Array(K+8),re=new DataView(ee.buffer,ee.byteOffset,ee.byteLength),re.setUint32(0,ee.byteLength),ee.set(F,4),q=0,K=8;q<j.length;q++)ee.set(j[q],K),K+=j[q].byteLength;return ee},o=function(){return s(R.dinf,s(R.dref,J))},u=function(F){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,F.audioobjecttype<<3|F.samplingfrequencyindex>>>1,F.samplingfrequencyindex<<7|F.channelcount<<3,6,1,2]))},l=function(){return s(R.ftyp,P,I,P,D)},E=function(F){return s(R.hdlr,N[F])},h=function(F){return s(R.mdat,F)},S=function(F){var j=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,F.duration>>>24&255,F.duration>>>16&255,F.duration>>>8&255,F.duration&255,85,196,0,0]);return F.samplerate&&(j[12]=F.samplerate>>>24&255,j[13]=F.samplerate>>>16&255,j[14]=F.samplerate>>>8&255,j[15]=F.samplerate&255),s(R.mdhd,j)},p=function(F){return s(R.mdia,S(F),E(F.type),g(F))},d=function(F){return s(R.mfhd,new Uint8Array([0,0,0,0,(F&4278190080)>>24,(F&16711680)>>16,(F&65280)>>8,F&255]))},g=function(F){return s(R.minf,F.type==="video"?s(R.vmhd,B):s(R.smhd,H),o(),x(F))},c=function(F,j){for(var K=[],q=j.length;q--;)K[q]=A(j[q]);return s.apply(null,[R.moof,d(F)].concat(K))},b=function(F){for(var j=F.length,K=[];j--;)K[j]=y(F[j]);return s.apply(null,[R.moov,m(4294967295)].concat(K).concat(f(F)))},f=function(F){for(var j=F.length,K=[];j--;)K[j]=k(F[j]);return s.apply(null,[R.mvex].concat(K))},m=function(F){var j=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(F&4278190080)>>24,(F&16711680)>>16,(F&65280)>>8,F&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,j)},w=function(F){var j=F.samples||[],K=new Uint8Array(4+j.length),q,ee;for(ee=0;ee<j.length;ee++)q=j[ee].flags,K[ee+4]=q.dependsOn<<4|q.isDependedOn<<2|q.hasRedundancy;return s(R.sdtp,K)},x=function(F){return s(R.stbl,T(F),s(R.stts,ue),s(R.stsc,Q),s(R.stsz,ne),s(R.stco,ie))},function(){var se,F;T=function(K){return s(R.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),K.type==="video"?se(K):F(K))},se=function(K){var q=K.sps||[],ee=K.pps||[],re=[],oe=[],de,ye;for(de=0;de<q.length;de++)re.push((q[de].byteLength&65280)>>>8),re.push(q[de].byteLength&255),re=re.concat(Array.prototype.slice.call(q[de]));for(de=0;de<ee.length;de++)oe.push((ee[de].byteLength&65280)>>>8),oe.push(ee[de].byteLength&255),oe=oe.concat(Array.prototype.slice.call(ee[de]));if(ye=[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,(K.width&65280)>>8,K.width&255,(K.height&65280)>>8,K.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,K.profileIdc,K.profileCompatibility,K.levelIdc,255].concat([q.length],re,[ee.length],oe))),s(R.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],K.sarRatio){var Ae=K.sarRatio[0],Je=K.sarRatio[1];ye.push(s(R.pasp,new Uint8Array([(Ae&4278190080)>>24,(Ae&16711680)>>16,(Ae&65280)>>8,Ae&255,(Je&4278190080)>>24,(Je&16711680)>>16,(Je&65280)>>8,Je&255])))}return s.apply(null,ye)},F=function(K){return s(R.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(K.channelcount&65280)>>8,K.channelcount&255,(K.samplesize&65280)>>8,K.samplesize&255,0,0,0,0,(K.samplerate&65280)>>8,K.samplerate&255,0,0]),u(K))}}(),v=function(F){var j=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(F.id&4278190080)>>24,(F.id&16711680)>>16,(F.id&65280)>>8,F.id&255,0,0,0,0,(F.duration&4278190080)>>24,(F.duration&16711680)>>16,(F.duration&65280)>>8,F.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,(F.width&65280)>>8,F.width&255,0,0,(F.height&65280)>>8,F.height&255,0,0]);return s(R.tkhd,j)},A=function(F){var j,K,q,ee,re,oe,de;return j=s(R.tfhd,new Uint8Array([0,0,0,58,(F.id&4278190080)>>24,(F.id&16711680)>>16,(F.id&65280)>>8,F.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),oe=Math.floor(F.baseMediaDecodeTime/(a+1)),de=Math.floor(F.baseMediaDecodeTime%(a+1)),K=s(R.tfdt,new Uint8Array([1,0,0,0,oe>>>24&255,oe>>>16&255,oe>>>8&255,oe&255,de>>>24&255,de>>>16&255,de>>>8&255,de&255])),re=32+20+8+16+8+8,F.type==="audio"?(q=C(F,re),s(R.traf,j,K,q)):(ee=w(F),q=C(F,ee.length+re),s(R.traf,j,K,q,ee))},y=function(F){return F.duration=F.duration||4294967295,s(R.trak,v(F),p(F))},k=function(F){var j=new Uint8Array([0,0,0,0,(F.id&4278190080)>>24,(F.id&16711680)>>16,(F.id&65280)>>8,F.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return F.type!=="video"&&(j[j.length-1]=0),s(R.trex,j)},function(){var se,F,j;j=function(q,ee){var re=0,oe=0,de=0,ye=0;return q.length&&(q[0].duration!==void 0&&(re=1),q[0].size!==void 0&&(oe=2),q[0].flags!==void 0&&(de=4),q[0].compositionTimeOffset!==void 0&&(ye=8)),[0,0,re|oe|de|ye,1,(q.length&4278190080)>>>24,(q.length&16711680)>>>16,(q.length&65280)>>>8,q.length&255,(ee&4278190080)>>>24,(ee&16711680)>>>16,(ee&65280)>>>8,ee&255]},F=function(q,ee){var re,oe,de,ye;for(oe=q.samples||[],ee+=8+12+16*oe.length,re=j(oe,ee),ye=0;ye<oe.length;ye++)de=oe[ye],re=re.concat([(de.duration&4278190080)>>>24,(de.duration&16711680)>>>16,(de.duration&65280)>>>8,de.duration&255,(de.size&4278190080)>>>24,(de.size&16711680)>>>16,(de.size&65280)>>>8,de.size&255,de.flags.isLeading<<2|de.flags.dependsOn,de.flags.isDependedOn<<6|de.flags.hasRedundancy<<4|de.flags.paddingValue<<1|de.flags.isNonSyncSample,de.flags.degradationPriority&240<<8,de.flags.degradationPriority&15,(de.compositionTimeOffset&4278190080)>>>24,(de.compositionTimeOffset&16711680)>>>16,(de.compositionTimeOffset&65280)>>>8,de.compositionTimeOffset&255]);return s(R.trun,new Uint8Array(re))},se=function(q,ee){var re,oe,de,ye;for(oe=q.samples||[],ee+=8+12+8*oe.length,re=j(oe,ee),ye=0;ye<oe.length;ye++)de=oe[ye],re=re.concat([(de.duration&4278190080)>>>24,(de.duration&16711680)>>>16,(de.duration&65280)>>>8,de.duration&255,(de.size&4278190080)>>>24,(de.size&16711680)>>>16,(de.size&65280)>>>8,de.size&255]);return s(R.trun,new Uint8Array(re))},C=function(q,ee){return q.type==="audio"?se(q,ee):F(q,ee)}}();var Te={ftyp:l,mdat:h,moof:c,moov:b,initSegment:function(F){var j=l(),K=b(F),q;return q=new Uint8Array(j.byteLength+K.byteLength),q.set(j),q.set(K,j.byteLength),q}},Me=function(F){var j,K,q=[],ee=[];for(ee.byteLength=0,ee.nalCount=0,ee.duration=0,q.byteLength=0,j=0;j<F.length;j++)K=F[j],K.nalUnitType==="access_unit_delimiter_rbsp"?(q.length&&(q.duration=K.dts-q.dts,ee.byteLength+=q.byteLength,ee.nalCount+=q.length,ee.duration+=q.duration,ee.push(q)),q=[K],q.byteLength=K.data.byteLength,q.pts=K.pts,q.dts=K.dts):(K.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"&&(q.keyFrame=!0),q.duration=K.dts-q.dts,q.byteLength+=K.data.byteLength,q.push(K));return ee.length&&(!q.duration||q.duration<=0)&&(q.duration=ee[ee.length-1].duration),ee.byteLength+=q.byteLength,ee.nalCount+=q.length,ee.duration+=q.duration,ee.push(q),ee},Se=function(F){var j,K,q=[],ee=[];for(q.byteLength=0,q.nalCount=0,q.duration=0,q.pts=F[0].pts,q.dts=F[0].dts,ee.byteLength=0,ee.nalCount=0,ee.duration=0,ee.pts=F[0].pts,ee.dts=F[0].dts,j=0;j<F.length;j++)K=F[j],K.keyFrame?(q.length&&(ee.push(q),ee.byteLength+=q.byteLength,ee.nalCount+=q.nalCount,ee.duration+=q.duration),q=[K],q.nalCount=K.length,q.byteLength=K.byteLength,q.pts=K.pts,q.dts=K.dts,q.duration=K.duration):(q.duration+=K.duration,q.nalCount+=K.length,q.byteLength+=K.byteLength,q.push(K));return ee.length&&q.duration<=0&&(q.duration=ee[ee.length-1].duration),ee.byteLength+=q.byteLength,ee.nalCount+=q.nalCount,ee.duration+=q.duration,ee.push(q),ee},be=function(F){var j;return!F[0][0].keyFrame&&F.length>1&&(j=F.shift(),F.byteLength-=j.byteLength,F.nalCount-=j.nalCount,F[0][0].dts=j.dts,F[0][0].pts=j.pts,F[0][0].duration+=j.duration),F},Ge=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},rt=function(F,j){var K=Ge();return K.dataOffset=j,K.compositionTimeOffset=F.pts-F.dts,K.duration=F.duration,K.size=4*F.length,K.size+=F.byteLength,F.keyFrame&&(K.flags.dependsOn=2,K.flags.isNonSyncSample=0),K},ot=function(F,j){var K,q,ee,re,oe,de=j||0,ye=[];for(K=0;K<F.length;K++)for(re=F[K],q=0;q<re.length;q++)oe=re[q],ee=rt(oe,de),de+=ee.size,ye.push(ee);return ye},yt=function(F){var j,K,q,ee,re,oe,de=0,ye=F.byteLength,Ae=F.nalCount,Je=ye+4*Ae,dt=new Uint8Array(Je),ht=new DataView(dt.buffer);for(j=0;j<F.length;j++)for(ee=F[j],K=0;K<ee.length;K++)for(re=ee[K],q=0;q<re.length;q++)oe=re[q],ht.setUint32(de,oe.data.byteLength),de+=4,dt.set(oe.data,de),de+=oe.data.byteLength;return dt},_e=function(F,j){var K,q=j||0,ee=[];return K=rt(F,q),ee.push(K),ee},Oe=function(F){var j,K,q=0,ee=F.byteLength,re=F.length,oe=ee+4*re,de=new Uint8Array(oe),ye=new DataView(de.buffer);for(j=0;j<F.length;j++)K=F[j],ye.setUint32(q,K.data.byteLength),q+=4,de.set(K.data,q),q+=K.data.byteLength;return de},Be={groupNalsIntoFrames:Me,groupFramesIntoGops:Se,extendFirstKeyFrame:be,generateSampleTable:ot,concatenateNalData:yt,generateSampleTableForFrame:_e,concatenateNalDataForFrame:Oe},Ke=[33,16,5,32,164,27],ze=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],we=function(F){for(var j=[];F--;)j.push(0);return j},Ye=function(F){return Object.keys(F).reduce(function(j,K){return j[K]=new Uint8Array(F[K].reduce(function(q,ee){return q.concat(ee)},[])),j},{})},ut={96e3:[Ke,[227,64],we(154),[56]],88200:[Ke,[231],we(170),[56]],64e3:[Ke,[248,192],we(240),[56]],48e3:[Ke,[255,192],we(268),[55,148,128],we(54),[112]],44100:[Ke,[255,192],we(268),[55,163,128],we(84),[112]],32e3:[Ke,[255,192],we(268),[55,234],we(226),[112]],24e3:[Ke,[255,192],we(268),[55,255,128],we(268),[111,112],we(126),[224]],16e3:[Ke,[255,192],we(268),[55,255,128],we(268),[111,255],we(269),[223,108],we(195),[1,192]],12e3:[ze,we(268),[3,127,248],we(268),[6,255,240],we(268),[13,255,224],we(268),[27,253,128],we(259),[56]],11025:[ze,we(268),[3,127,248],we(268),[6,255,240],we(268),[13,255,224],we(268),[27,255,192],we(268),[55,175,128],we(108),[112]],8e3:[ze,we(268),[3,121,16],we(47),[7]]},vt=Ye(ut),Ce=9e4,Qt,_r,Ut,xr,gr,Gr,br;Qt=function(F){return F*Ce},_r=function(F,j){return F*j},Ut=function(F){return F/Ce},xr=function(F,j){return F/j},gr=function(F,j){return Qt(xr(F,j))},Gr=function(F,j){return _r(Ut(F),j)},br=function(F,j,K){return Ut(K?F:F-j)};var or={ONE_SECOND_IN_TS:Ce,secondsToVideoTs:Qt,secondsToAudioTs:_r,videoTsToSeconds:Ut,audioTsToSeconds:xr,audioTsToVideoTs:gr,videoTsToAudioTs:Gr,metadataTsToSeconds:br},tr=function(F){var j,K,q=0;for(j=0;j<F.length;j++)K=F[j],q+=K.data.byteLength;return q},Wi=function(F,j,K,q){var ee,re=0,oe=0,de=0,ye=0,Ae,Je,dt;if(!!j.length&&(ee=or.audioTsToVideoTs(F.baseMediaDecodeTime,F.samplerate),re=Math.ceil(or.ONE_SECOND_IN_TS/(F.samplerate/1024)),K&&q&&(oe=ee-Math.max(K,q),de=Math.floor(oe/re),ye=de*re),!(de<1||ye>or.ONE_SECOND_IN_TS/2))){for(Ae=vt[F.samplerate],Ae||(Ae=j[0].data),Je=0;Je<de;Je++)dt=j[0],j.splice(0,0,{data:Ae,dts:dt.dts-re,pts:dt.pts-re});F.baseMediaDecodeTime-=Math.floor(or.videoTsToAudioTs(ye,F.samplerate))}},Fn=function(F,j,K){return j.minSegmentDts>=K?F:(j.minSegmentDts=1/0,F.filter(function(q){return q.dts>=K?(j.minSegmentDts=Math.min(j.minSegmentDts,q.dts),j.minSegmentPts=j.minSegmentDts,!0):!1}))},_o=function(F){var j,K,q=[];for(j=0;j<F.length;j++)K=F[j],q.push({size:K.data.byteLength,duration:1024});return q},Ll=function(F){var j,K,q=0,ee=new Uint8Array(tr(F));for(j=0;j<F.length;j++)K=F[j],ee.set(K.data,q),q+=K.data.byteLength;return ee},ki={prefixWithSilence:Wi,trimAdtsFramesByEarliestDts:Fn,generateSampleTable:_o,concatenateFrameData:Ll},Un=or.ONE_SECOND_IN_TS,bo=function(F,j){typeof j.pts=="number"&&(F.timelineStartInfo.pts===void 0&&(F.timelineStartInfo.pts=j.pts),F.minSegmentPts===void 0?F.minSegmentPts=j.pts:F.minSegmentPts=Math.min(F.minSegmentPts,j.pts),F.maxSegmentPts===void 0?F.maxSegmentPts=j.pts:F.maxSegmentPts=Math.max(F.maxSegmentPts,j.pts)),typeof j.dts=="number"&&(F.timelineStartInfo.dts===void 0&&(F.timelineStartInfo.dts=j.dts),F.minSegmentDts===void 0?F.minSegmentDts=j.dts:F.minSegmentDts=Math.min(F.minSegmentDts,j.dts),F.maxSegmentDts===void 0?F.maxSegmentDts=j.dts:F.maxSegmentDts=Math.max(F.maxSegmentDts,j.dts))},ei=function(F){delete F.minSegmentDts,delete F.maxSegmentDts,delete F.minSegmentPts,delete F.maxSegmentPts},Bn=function(F,j){var K,q,ee=F.minSegmentDts;return j||(ee-=F.timelineStartInfo.dts),K=F.timelineStartInfo.baseMediaDecodeTime,K+=ee,K=Math.max(0,K),F.type==="audio"&&(q=F.samplerate/Un,K*=q,K=Math.floor(K)),K},Vr={clearDtsInfo:ei,calculateTrackBaseMediaDecodeTime:Bn,collectDtsInfo:bo},ps=4,Ol=128,Il=function(F){for(var j=0,K={payloadType:-1,payloadSize:0},q=0,ee=0;j<F.byteLength&&F[j]!==Ol;){for(;F[j]===255;)q+=255,j++;for(q+=F[j++];F[j]===255;)ee+=255,j++;if(ee+=F[j++],!K.payload&&q===ps){K.payloadType=q,K.payloadSize=ee,K.payload=F.subarray(j,j+ee);break}j+=ee,q=0,ee=0}return K},To=function(F){return F.payload[0]!==181||(F.payload[1]<<8|F.payload[2])!==49||String.fromCharCode(F.payload[3],F.payload[4],F.payload[5],F.payload[6])!=="GA94"||F.payload[7]!==3?null:F.payload.subarray(8,F.payload.length-1)},Ml=function(F,j){var K=[],q,ee,re,oe;if(!(j[0]&64))return K;for(ee=j[0]&31,q=0;q<ee;q++)re=q*3,oe={type:j[re+2]&3,pts:F},j[re+2]&4&&(oe.ccData=j[re+3]<<8|j[re+4],K.push(oe));return K},Nl=function(F){for(var j=F.byteLength,K=[],q=1,ee,re;q<j-2;)F[q]===0&&F[q+1]===0&&F[q+2]===3?(K.push(q+2),q+=2):q++;if(K.length===0)return F;ee=j-K.length,re=new Uint8Array(ee);var oe=0;for(q=0;q<ee;oe++,q++)oe===K[0]&&(oe++,K.shift()),re[q]=F[oe];return re},ln={parseSei:Il,parseUserData:To,parseCaptionPackets:Ml,discardEmulationPreventionBytes:Nl,USER_DATA_REGISTERED_ITU_T_T35:ps},Wr=function se(){se.prototype.init.call(this),this.captionPackets_=[],this.ccStreams_=[new rr(0,0),new rr(0,1),new rr(1,0),new rr(1,1)],this.reset(),this.ccStreams_.forEach(function(F){F.on("data",this.trigger.bind(this,"data")),F.on("partialdone",this.trigger.bind(this,"partialdone")),F.on("done",this.trigger.bind(this,"done"))},this)};Wr.prototype=new n,Wr.prototype.push=function(se){var F,j,K;if(se.nalUnitType==="sei_rbsp"&&(F=ln.parseSei(se.escapedRBSP),F.payloadType===ln.USER_DATA_REGISTERED_ITU_T_T35&&(j=ln.parseUserData(F),!!j))){if(se.dts<this.latestDts_){this.ignoreNextEqualDts_=!0;return}else if(se.dts===this.latestDts_&&this.ignoreNextEqualDts_){this.numSameDts_--,this.numSameDts_||(this.ignoreNextEqualDts_=!1);return}K=ln.parseCaptionPackets(se.pts,j),this.captionPackets_=this.captionPackets_.concat(K),this.latestDts_!==se.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=se.dts}},Wr.prototype.flushCCStreams=function(se){this.ccStreams_.forEach(function(F){return se==="flush"?F.flush():F.partialFlush()},this)},Wr.prototype.flushStream=function(se){if(!this.captionPackets_.length){this.flushCCStreams(se);return}this.captionPackets_.forEach(function(F,j){F.presortIndex=j}),this.captionPackets_.sort(function(F,j){return F.pts===j.pts?F.presortIndex-j.presortIndex:F.pts-j.pts}),this.captionPackets_.forEach(function(F){F.type<2&&this.dispatchCea608Packet(F)},this),this.captionPackets_.length=0,this.flushCCStreams(se)},Wr.prototype.flush=function(){return this.flushStream("flush")},Wr.prototype.partialFlush=function(){return this.flushStream("partialFlush")},Wr.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(se){se.reset()})},Wr.prototype.dispatchCea608Packet=function(se){this.setsTextOrXDSActive(se)?this.activeCea608Channel_[se.type]=null:this.setsChannel1Active(se)?this.activeCea608Channel_[se.type]=0:this.setsChannel2Active(se)&&(this.activeCea608Channel_[se.type]=1),this.activeCea608Channel_[se.type]!==null&&this.ccStreams_[(se.type<<1)+this.activeCea608Channel_[se.type]].push(se)},Wr.prototype.setsChannel1Active=function(se){return(se.ccData&30720)===4096},Wr.prototype.setsChannel2Active=function(se){return(se.ccData&30720)===6144},Wr.prototype.setsTextOrXDSActive=function(se){return(se.ccData&28928)===256||(se.ccData&30974)===4138||(se.ccData&30974)===6186};var Fl={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},Ta=function(F){return F===null?"":(F=Fl[F]||F,String.fromCharCode(F))},Sa=14,So=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],Ci=function(){for(var F=[],j=Sa+1;j--;)F.push("");return F},rr=function se(F,j){se.prototype.init.call(this),this.field_=F||0,this.dataChannel_=j||0,this.name_="CC"+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(K){var q,ee,re,oe,de;if(q=K.ccData&32639,q===this.lastControlCode_){this.lastControlCode_=null;return}if((q&61440)===4096?this.lastControlCode_=q:q!==this.PADDING_&&(this.lastControlCode_=null),re=q>>>8,oe=q&255,q!==this.PADDING_)if(q===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(q===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(K.pts),this.flushDisplayed(K.pts),ee=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=ee,this.startPts_=K.pts;else if(q===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(K.pts);else if(q===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(K.pts);else if(q===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(K.pts);else if(q===this.CARRIAGE_RETURN_)this.clearFormatting(K.pts),this.flushDisplayed(K.pts),this.shiftRowsUp_(),this.startPts_=K.pts;else if(q===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(q===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(K.pts),this.displayed_=Ci();else if(q===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Ci();else if(q===this.RESUME_DIRECT_CAPTIONING_)this.mode_!=="paintOn"&&(this.flushDisplayed(K.pts),this.displayed_=Ci()),this.mode_="paintOn",this.startPts_=K.pts;else if(this.isSpecialCharacter(re,oe))re=(re&3)<<8,de=Ta(re|oe),this[this.mode_](K.pts,de),this.column_++;else if(this.isExtCharacter(re,oe))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),re=(re&3)<<8,de=Ta(re|oe),this[this.mode_](K.pts,de),this.column_++;else if(this.isMidRowCode(re,oe))this.clearFormatting(K.pts),this[this.mode_](K.pts," "),this.column_++,(oe&14)===14&&this.addFormatting(K.pts,["i"]),(oe&1)===1&&this.addFormatting(K.pts,["u"]);else if(this.isOffsetControlCode(re,oe))this.column_+=oe&3;else if(this.isPAC(re,oe)){var ye=So.indexOf(q&7968);this.mode_==="rollUp"&&(ye-this.rollUpRows_+1<0&&(ye=this.rollUpRows_-1),this.setRollUp(K.pts,ye)),ye!==this.row_&&(this.clearFormatting(K.pts),this.row_=ye),oe&1&&this.formatting_.indexOf("u")===-1&&this.addFormatting(K.pts,["u"]),(q&16)===16&&(this.column_=((q&14)>>1)*4),this.isColorPAC(oe)&&(oe&14)===14&&this.addFormatting(K.pts,["i"])}else this.isNormalChar(re)&&(oe===0&&(oe=null),de=Ta(re),de+=Ta(oe),this[this.mode_](K.pts,de),this.column_+=de.length)}};rr.prototype=new n,rr.prototype.flushDisplayed=function(se){var F=this.displayed_.map(function(j){try{return j.trim()}catch{return console.error("Skipping malformed caption."),""}}).join(`
79
79
  `).replace(/^\n+|\n+$/g,"");F.length&&this.trigger("data",{startPts:this.startPts_,endPts:se,text:F,stream:this.name_})},rr.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=Ci(),this.nonDisplayed_=Ci(),this.lastControlCode_=null,this.column_=0,this.row_=Sa,this.rollUpRows_=2,this.formatting_=[]},rr.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},rr.prototype.isSpecialCharacter=function(se,F){return se===this.EXT_&&F>=48&&F<=63},rr.prototype.isExtCharacter=function(se,F){return(se===this.EXT_+1||se===this.EXT_+2)&&F>=32&&F<=63},rr.prototype.isMidRowCode=function(se,F){return se===this.EXT_&&F>=32&&F<=47},rr.prototype.isOffsetControlCode=function(se,F){return se===this.OFFSET_&&F>=33&&F<=35},rr.prototype.isPAC=function(se,F){return se>=this.BASE_&&se<this.BASE_+8&&F>=64&&F<=127},rr.prototype.isColorPAC=function(se){return se>=64&&se<=79||se>=96&&se<=127},rr.prototype.isNormalChar=function(se){return se>=32&&se<=127},rr.prototype.setRollUp=function(se,F){if(this.mode_!=="rollUp"&&(this.row_=Sa,this.mode_="rollUp",this.flushDisplayed(se),this.nonDisplayed_=Ci(),this.displayed_=Ci()),F!==void 0&&F!==this.row_)for(var j=0;j<this.rollUpRows_;j++)this.displayed_[F-j]=this.displayed_[this.row_-j],this.displayed_[this.row_-j]="";F===void 0&&(F=this.row_),this.topRow_=F-this.rollUpRows_+1},rr.prototype.addFormatting=function(se,F){this.formatting_=this.formatting_.concat(F);var j=F.reduce(function(K,q){return K+"<"+q+">"},"");this[this.mode_](se,j)},rr.prototype.clearFormatting=function(se){if(!!this.formatting_.length){var F=this.formatting_.reverse().reduce(function(j,K){return j+"</"+K+">"},"");this.formatting_=[],this[this.mode_](se,F)}},rr.prototype.popOn=function(se,F){var j=this.nonDisplayed_[this.row_];j+=F,this.nonDisplayed_[this.row_]=j},rr.prototype.rollUp=function(se,F){var j=this.displayed_[this.row_];j+=F,this.displayed_[this.row_]=j},rr.prototype.shiftRowsUp_=function(){var se;for(se=0;se<this.topRow_;se++)this.displayed_[se]="";for(se=this.row_+1;se<Sa+1;se++)this.displayed_[se]="";for(se=this.topRow_;se<this.row_;se++)this.displayed_[se]=this.displayed_[se+1];this.displayed_[this.row_]=""},rr.prototype.paintOn=function(se,F){var j=this.displayed_[this.row_];j+=F,this.displayed_[this.row_]=j};var Eo={CaptionStream:Wr,Cea608Stream:rr},Fr={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},Ul=8589934592,Bl=4294967296,xo="shared",Ea=function(F,j){var K=1;for(F>j&&(K=-1);Math.abs(j-F)>Bl;)F+=K*Ul;return F},wo=function se(F){var j,K;se.prototype.init.call(this),this.type_=F||xo,this.push=function(q){this.type_!==xo&&q.type!==this.type_||(K===void 0&&(K=q.dts),q.dts=Ea(q.dts,K),q.pts=Ea(q.pts,K),j=q.dts,this.trigger("data",q))},this.flush=function(){K=j,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){K=void 0,j=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};wo.prototype=new n;var jl={TimestampRolloverStream:wo,handleRollover:Ea},gs=function(F,j,K){var q,ee="";for(q=j;q<K;q++)ee+="%"+("00"+F[q].toString(16)).slice(-2);return ee},xa=function(F,j,K){return decodeURIComponent(gs(F,j,K))},Hl=function(F,j,K){return unescape(gs(F,j,K))},un=function(F){return F[0]<<21|F[1]<<14|F[2]<<7|F[3]},vs={TXXX:function(F){var j;if(F.data[0]===3){for(j=1;j<F.data.length;j++)if(F.data[j]===0){F.description=xa(F.data,1,j),F.value=xa(F.data,j+1,F.data.length).replace(/\0*$/,"");break}F.data=F.value}},WXXX:function(F){var j;if(F.data[0]===3){for(j=1;j<F.data.length;j++)if(F.data[j]===0){F.description=xa(F.data,1,j),F.url=xa(F.data,j+1,F.data.length);break}}},PRIV:function(F){var j;for(j=0;j<F.data.length;j++)if(F.data[j]===0){F.owner=Hl(F.data,0,j);break}F.privateData=F.data.subarray(j+1),F.data=F.privateData}},dn;dn=function(F){var j={debug:!!(F&&F.debug),descriptor:F&&F.descriptor},K=0,q=[],ee=0,re;if(dn.prototype.init.call(this),this.dispatchType=Fr.METADATA_STREAM_TYPE.toString(16),j.descriptor)for(re=0;re<j.descriptor.length;re++)this.dispatchType+=("00"+j.descriptor[re].toString(16)).slice(-2);this.push=function(oe){var de,ye,Ae,Je,dt,ht;if(oe.type==="timed-metadata"){if(oe.dataAlignmentIndicator&&(ee=0,q.length=0),q.length===0&&(oe.data.length<10||oe.data[0]!=="I".charCodeAt(0)||oe.data[1]!=="D".charCodeAt(0)||oe.data[2]!=="3".charCodeAt(0))){j.debug&&console.log("Skipping unrecognized metadata packet");return}if(q.push(oe),ee+=oe.data.byteLength,q.length===1&&(K=un(oe.data.subarray(6,10)),K+=10),!(ee<K)){for(de={data:new Uint8Array(K),frames:[],pts:q[0].pts,dts:q[0].dts},dt=0;dt<K;)de.data.set(q[0].data.subarray(0,K-dt),dt),dt+=q[0].data.byteLength,ee-=q[0].data.byteLength,q.shift();ye=10,de.data[5]&64&&(ye+=4,ye+=un(de.data.subarray(10,14)),K-=un(de.data.subarray(16,20)));do{if(Ae=un(de.data.subarray(ye+4,ye+8)),Ae<1)return console.log("Malformed ID3 frame encountered. Skipping metadata parsing.");if(ht=String.fromCharCode(de.data[ye],de.data[ye+1],de.data[ye+2],de.data[ye+3]),Je={id:ht,data:de.data.subarray(ye+10,ye+Ae+10)},Je.key=Je.id,vs[Je.id]&&(vs[Je.id](Je),Je.owner==="com.apple.streaming.transportStreamTimestamp")){var At=Je.data,Ot=(At[3]&1)<<30|At[4]<<22|At[5]<<14|At[6]<<6|At[7]>>>2;Ot*=4,Ot+=At[7]&3,Je.timeStamp=Ot,de.pts===void 0&&de.dts===void 0&&(de.pts=Je.timeStamp,de.dts=Je.timeStamp),this.trigger("timestamp",Je)}de.frames.push(Je),ye+=10,ye+=Ae}while(ye<K);this.trigger("data",de)}}}},dn.prototype=new n;var cn=dn,ms=jl.TimestampRolloverStream,ni,jn,qi,Ri=188,wa=71;ni=function(){var F=new Uint8Array(Ri),j=0;ni.prototype.init.call(this),this.push=function(K){var q=0,ee=Ri,re;for(j?(re=new Uint8Array(K.byteLength+j),re.set(F.subarray(0,j)),re.set(K,j),j=0):re=K;ee<re.byteLength;){if(re[q]===wa&&re[ee]===wa){this.trigger("data",re.subarray(q,ee)),q+=Ri,ee+=Ri;continue}q++,ee++}q<re.byteLength&&(F.set(re.subarray(q),0),j=re.byteLength-q)},this.flush=function(){j===Ri&&F[0]===wa&&(this.trigger("data",F),j=0),this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){j=0,this.trigger("reset")}},ni.prototype=new n,jn=function(){var F,j,K,q;jn.prototype.init.call(this),q=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,F=function(re,oe){var de=0;oe.payloadUnitStartIndicator&&(de+=re[de]+1),oe.type==="pat"?j(re.subarray(de),oe):K(re.subarray(de),oe)},j=function(re,oe){oe.section_number=re[7],oe.last_section_number=re[8],q.pmtPid=(re[10]&31)<<8|re[11],oe.pmtPid=q.pmtPid},K=function(re,oe){var de,ye,Ae,Je;if(!!(re[5]&1)){for(q.programMapTable={video:null,audio:null,"timed-metadata":{}},de=(re[1]&15)<<8|re[2],ye=3+de-4,Ae=(re[10]&15)<<8|re[11],Je=12+Ae;Je<ye;){var dt=re[Je],ht=(re[Je+1]&31)<<8|re[Je+2];dt===Fr.H264_STREAM_TYPE&&q.programMapTable.video===null?q.programMapTable.video=ht:dt===Fr.ADTS_STREAM_TYPE&&q.programMapTable.audio===null?q.programMapTable.audio=ht:dt===Fr.METADATA_STREAM_TYPE&&(q.programMapTable["timed-metadata"][ht]=dt),Je+=((re[Je+3]&15)<<8|re[Je+4])+5}oe.programMapTable=q.programMapTable}},this.push=function(ee){var re={},oe=4;if(re.payloadUnitStartIndicator=!!(ee[1]&64),re.pid=ee[1]&31,re.pid<<=8,re.pid|=ee[2],(ee[3]&48)>>>4>1&&(oe+=ee[oe]+1),re.pid===0)re.type="pat",F(ee.subarray(oe),re),this.trigger("data",re);else if(re.pid===this.pmtPid)for(re.type="pmt",F(ee.subarray(oe),re),this.trigger("data",re);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([ee,oe,re]):this.processPes_(ee,oe,re)},this.processPes_=function(ee,re,oe){oe.pid===this.programMapTable.video?oe.streamType=Fr.H264_STREAM_TYPE:oe.pid===this.programMapTable.audio?oe.streamType=Fr.ADTS_STREAM_TYPE:oe.streamType=this.programMapTable["timed-metadata"][oe.pid],oe.type="pes",oe.data=ee.subarray(re),this.trigger("data",oe)}},jn.prototype=new n,jn.STREAM_TYPES={h264:27,adts:15},qi=function(){var F=this,j={data:[],size:0},K={data:[],size:0},q={data:[],size:0},ee,re=function(ye,Ae){var Je;Ae.packetLength=6+(ye[4]<<8|ye[5]),Ae.dataAlignmentIndicator=(ye[6]&4)!==0,Je=ye[7],Je&192&&(Ae.pts=(ye[9]&14)<<27|(ye[10]&255)<<20|(ye[11]&254)<<12|(ye[12]&255)<<5|(ye[13]&254)>>>3,Ae.pts*=4,Ae.pts+=(ye[13]&6)>>>1,Ae.dts=Ae.pts,Je&64&&(Ae.dts=(ye[14]&14)<<27|(ye[15]&255)<<20|(ye[16]&254)<<12|(ye[17]&255)<<5|(ye[18]&254)>>>3,Ae.dts*=4,Ae.dts+=(ye[18]&6)>>>1)),Ae.data=ye.subarray(9+ye[8])},oe=function(ye,Ae,Je){var dt=new Uint8Array(ye.size),ht={type:Ae},At=0,Ot=0,We=!1,Or;if(!(!ye.data.length||ye.size<9)){for(ht.trackId=ye.data[0].pid,At=0;At<ye.data.length;At++)Or=ye.data[At],dt.set(Or.data,Ot),Ot+=Or.data.byteLength;re(dt,ht),We=Ae==="video"||ht.packetLength<=ye.size,(Je||We)&&(ye.size=0,ye.data.length=0),We&&F.trigger("data",ht)}};qi.prototype.init.call(this),this.push=function(de){({pat:function(){},pes:function(){var Ae,Je;switch(de.streamType){case Fr.H264_STREAM_TYPE:case Fr.H264_STREAM_TYPE:Ae=j,Je="video";break;case Fr.ADTS_STREAM_TYPE:Ae=K,Je="audio";break;case Fr.METADATA_STREAM_TYPE:Ae=q,Je="timed-metadata";break;default:return}de.payloadUnitStartIndicator&&oe(Ae,Je,!0),Ae.data.push(de),Ae.size+=de.data.byteLength},pmt:function(){var Ae={type:"metadata",tracks:[]};ee=de.programMapTable,ee.video!==null&&Ae.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+ee.video,codec:"avc",type:"video"}),ee.audio!==null&&Ae.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+ee.audio,codec:"adts",type:"audio"}),F.trigger("data",Ae)}})[de.type]()},this.reset=function(){j.size=0,j.data.length=0,K.size=0,K.data.length=0,this.trigger("reset")},this.flushStreams_=function(){oe(j,"video"),oe(K,"audio"),oe(q,"timed-metadata")},this.flush=function(){this.flushStreams_(),this.trigger("done")}},qi.prototype=new n;var ys={PAT_PID:0,MP2T_PACKET_LENGTH:Ri,TransportPacketStream:ni,TransportParseStream:jn,ElementaryStream:qi,TimestampRolloverStream:ms,CaptionStream:Eo.CaptionStream,Cea608Stream:Eo.Cea608Stream,MetadataStream:cn};for(var Hn in Fr)Fr.hasOwnProperty(Hn)&&(ys[Hn]=Fr[Hn]);var ci=ys,Ao=or.ONE_SECOND_IN_TS,Z,ae=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];Z=function(F){var j,K=0;Z.prototype.init.call(this),this.push=function(q){var ee=0,re,oe,de,ye,Ae,Je;if(F||(K=0),q.type==="audio")for(j?(ye=j,j=new Uint8Array(ye.byteLength+q.data.byteLength),j.set(ye),j.set(q.data,ye.byteLength)):j=q.data;ee+5<j.length;){if(j[ee]!==255||(j[ee+1]&246)!==240){ee++;continue}if(oe=(~j[ee+1]&1)*2,re=(j[ee+3]&3)<<11|j[ee+4]<<3|(j[ee+5]&224)>>5,Ae=((j[ee+6]&3)+1)*1024,Je=Ae*Ao/ae[(j[ee+2]&60)>>>2],de=ee+re,j.byteLength<de)return;if(this.trigger("data",{pts:q.pts+K*Je,dts:q.dts+K*Je,sampleCount:Ae,audioobjecttype:(j[ee+2]>>>6&3)+1,channelcount:(j[ee+2]&1)<<2|(j[ee+3]&192)>>>6,samplerate:ae[(j[ee+2]&60)>>>2],samplingfrequencyindex:(j[ee+2]&60)>>>2,samplesize:16,data:j.subarray(ee+7+oe,de)}),K++,j.byteLength===de){j=void 0;return}j=j.subarray(de)}},this.flush=function(){K=0,this.trigger("done")},this.reset=function(){j=void 0,this.trigger("reset")},this.endTimeline=function(){j=void 0,this.trigger("endedtimeline")}},Z.prototype=new n;var te=Z,fe;fe=function(F){var j=F.byteLength,K=0,q=0;this.length=function(){return 8*j},this.bitsAvailable=function(){return 8*j+q},this.loadWord=function(){var ee=F.byteLength-j,re=new Uint8Array(4),oe=Math.min(4,j);if(oe===0)throw new Error("no bytes available");re.set(F.subarray(ee,ee+oe)),K=new DataView(re.buffer).getUint32(0),q=oe*8,j-=oe},this.skipBits=function(ee){var re;q>ee?(K<<=ee,q-=ee):(ee-=q,re=Math.floor(ee/8),ee-=re*8,j-=re,this.loadWord(),K<<=ee,q-=ee)},this.readBits=function(ee){var re=Math.min(q,ee),oe=K>>>32-re;return q-=re,q>0?K<<=re:j>0&&this.loadWord(),re=ee-re,re>0?oe<<re|this.readBits(re):oe},this.skipLeadingZeros=function(){var ee;for(ee=0;ee<q;++ee)if((K&2147483648>>>ee)!==0)return K<<=ee,q-=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 ve=fe,ce,Ee,Ie;Ee=function(){var F=0,j,K;Ee.prototype.init.call(this),this.push=function(q){var ee;K?(ee=new Uint8Array(K.byteLength+q.data.byteLength),ee.set(K),ee.set(q.data,K.byteLength),K=ee):K=q.data;for(var re=K.byteLength;F<re-3;F++)if(K[F+2]===1){j=F+5;break}for(;j<re;)switch(K[j]){case 0:if(K[j-1]!==0){j+=2;break}else if(K[j-2]!==0){j++;break}F+3!==j-2&&this.trigger("data",K.subarray(F+3,j-2));do j++;while(K[j]!==1&&j<re);F=j-2,j+=3;break;case 1:if(K[j-1]!==0||K[j-2]!==0){j+=3;break}this.trigger("data",K.subarray(F+3,j-2)),F=j-2,j+=3;break;default:j+=3;break}K=K.subarray(F),j-=F,F=0},this.reset=function(){K=null,F=0,this.trigger("reset")},this.flush=function(){K&&K.byteLength>3&&this.trigger("data",K.subarray(F+3)),K=null,F=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}},Ee.prototype=new n,Ie={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},ce=function(){var F=new Ee,j,K,q,ee,re,oe,de;ce.prototype.init.call(this),j=this,this.push=function(ye){ye.type==="video"&&(K=ye.trackId,q=ye.pts,ee=ye.dts,F.push(ye))},F.on("data",function(ye){var Ae={trackId:K,pts:q,dts:ee,data:ye};switch(ye[0]&31){case 5:Ae.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:Ae.nalUnitType="sei_rbsp",Ae.escapedRBSP=re(ye.subarray(1));break;case 7:Ae.nalUnitType="seq_parameter_set_rbsp",Ae.escapedRBSP=re(ye.subarray(1)),Ae.config=oe(Ae.escapedRBSP);break;case 8:Ae.nalUnitType="pic_parameter_set_rbsp";break;case 9:Ae.nalUnitType="access_unit_delimiter_rbsp";break}j.trigger("data",Ae)}),F.on("done",function(){j.trigger("done")}),F.on("partialdone",function(){j.trigger("partialdone")}),F.on("reset",function(){j.trigger("reset")}),F.on("endedtimeline",function(){j.trigger("endedtimeline")}),this.flush=function(){F.flush()},this.partialFlush=function(){F.partialFlush()},this.reset=function(){F.reset()},this.endTimeline=function(){F.endTimeline()},de=function(Ae,Je){var dt=8,ht=8,At,Ot;for(At=0;At<Ae;At++)ht!==0&&(Ot=Je.readExpGolomb(),ht=(dt+Ot+256)%256),dt=ht===0?dt:ht},re=function(Ae){for(var Je=Ae.byteLength,dt=[],ht=1,At,Ot;ht<Je-2;)Ae[ht]===0&&Ae[ht+1]===0&&Ae[ht+2]===3?(dt.push(ht+2),ht+=2):ht++;if(dt.length===0)return Ae;At=Je-dt.length,Ot=new Uint8Array(At);var We=0;for(ht=0;ht<At;We++,ht++)We===dt[0]&&(We++,dt.shift()),Ot[ht]=Ae[We];return Ot},oe=function(Ae){var Je=0,dt=0,ht=0,At=0,Ot=1,We,Or,fi,Ca,ql,Co,Yl,Yn,Kl,Ro,Ur,pr,$l,Kn;if(We=new ve(Ae),Or=We.readUnsignedByte(),Ca=We.readUnsignedByte(),fi=We.readUnsignedByte(),We.skipUnsignedExpGolomb(),Ie[Or]&&(ql=We.readUnsignedExpGolomb(),ql===3&&We.skipBits(1),We.skipUnsignedExpGolomb(),We.skipUnsignedExpGolomb(),We.skipBits(1),We.readBoolean()))for(Ur=ql!==3?8:12,Kn=0;Kn<Ur;Kn++)We.readBoolean()&&(Kn<6?de(16,We):de(64,We));if(We.skipUnsignedExpGolomb(),Co=We.readUnsignedExpGolomb(),Co===0)We.readUnsignedExpGolomb();else if(Co===1)for(We.skipBits(1),We.skipExpGolomb(),We.skipExpGolomb(),Yl=We.readUnsignedExpGolomb(),Kn=0;Kn<Yl;Kn++)We.skipExpGolomb();if(We.skipUnsignedExpGolomb(),We.skipBits(1),Yn=We.readUnsignedExpGolomb(),Kl=We.readUnsignedExpGolomb(),Ro=We.readBits(1),Ro===0&&We.skipBits(1),We.skipBits(1),We.readBoolean()&&(Je=We.readUnsignedExpGolomb(),dt=We.readUnsignedExpGolomb(),ht=We.readUnsignedExpGolomb(),At=We.readUnsignedExpGolomb()),We.readBoolean()&&We.readBoolean()){switch($l=We.readUnsignedByte(),$l){case 1:pr=[1,1];break;case 2:pr=[12,11];break;case 3:pr=[10,11];break;case 4:pr=[16,11];break;case 5:pr=[40,33];break;case 6:pr=[24,11];break;case 7:pr=[20,11];break;case 8:pr=[32,11];break;case 9:pr=[80,33];break;case 10:pr=[18,11];break;case 11:pr=[15,11];break;case 12:pr=[64,33];break;case 13:pr=[160,99];break;case 14:pr=[4,3];break;case 15:pr=[3,2];break;case 16:pr=[2,1];break;case 255:{pr=[We.readUnsignedByte()<<8|We.readUnsignedByte(),We.readUnsignedByte()<<8|We.readUnsignedByte()];break}}pr&&(Ot=pr[0]/pr[1])}return{profileIdc:Or,levelIdc:fi,profileCompatibility:Ca,width:Math.ceil(((Yn+1)*16-Je*2-dt*2)*Ot),height:(2-Ro)*(Kl+1)*16-ht*2-At*2,sarRatio:pr}}},ce.prototype=new n;var Ue={H264Stream:ce,NalByteStream:Ee},je=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],Ve=function(F){return F[0]==="I".charCodeAt(0)&&F[1]==="D".charCodeAt(0)&&F[2]==="3".charCodeAt(0)},lt=function(F){return F[0]<<21|F[1]<<14|F[2]<<7|F[3]},wt=function(F,j,K){var q,ee="";for(q=j;q<K;q++)ee+="%"+("00"+F[q].toString(16)).slice(-2);return ee},Gt=function(F,j,K){return unescape(wt(F,j,K))},Vt=function(F,j){var K=F[j+6]<<21|F[j+7]<<14|F[j+8]<<7|F[j+9],q=F[j+5],ee=(q&16)>>4;return ee?K+20:K+10},hr=function(F,j){var K=(F[j+5]&224)>>5,q=F[j+4]<<3,ee=F[j+3]&3<<11;return ee|q|K},lr=function(F,j){return F[j]==="I".charCodeAt(0)&&F[j+1]==="D".charCodeAt(0)&&F[j+2]==="3".charCodeAt(0)?"timed-metadata":F[j]&!0&&(F[j+1]&240)===240?"audio":null},qr=function(F){for(var j=0;j+5<F.length;){if(F[j]!==255||(F[j+1]&246)!==240){j++;continue}return je[(F[j+2]&60)>>>2]}return null},Gn=function(F){var j,K,q,ee;j=10,F[5]&64&&(j+=4,j+=lt(F.subarray(10,14)));do{if(K=lt(F.subarray(j+4,j+8)),K<1)return null;if(ee=String.fromCharCode(F[j],F[j+1],F[j+2],F[j+3]),ee==="PRIV"){q=F.subarray(j+10,j+K+10);for(var re=0;re<q.byteLength;re++)if(q[re]===0){var oe=Gt(q,0,re);if(oe==="com.apple.streaming.transportStreamTimestamp"){var de=q.subarray(re+1),ye=(de[3]&1)<<30|de[4]<<22|de[5]<<14|de[6]<<6|de[7]>>>2;return ye*=4,ye+=de[7]&3,ye}break}}j+=10,j+=K}while(j<F.byteLength);return null},Vn={isLikelyAacData:Ve,parseId3TagSize:Vt,parseAdtsSize:hr,parseType:lr,parseSampleRate:qr,parseAacTimestamp:Gn},Di;Di=function(){var F=new Uint8Array,j=0;Di.prototype.init.call(this),this.setTimestamp=function(K){j=K},this.push=function(K){var q=0,ee=0,re,oe,de,ye;for(F.length?(ye=F.length,F=new Uint8Array(K.byteLength+ye),F.set(F.subarray(0,ye)),F.set(K,ye)):F=K;F.length-ee>=3;){if(F[ee]==="I".charCodeAt(0)&&F[ee+1]==="D".charCodeAt(0)&&F[ee+2]==="3".charCodeAt(0)){if(F.length-ee<10||(q=Vn.parseId3TagSize(F,ee),ee+q>F.length))break;oe={type:"timed-metadata",data:F.subarray(ee,ee+q)},this.trigger("data",oe),ee+=q;continue}else if((F[ee]&255)===255&&(F[ee+1]&240)===240){if(F.length-ee<7||(q=Vn.parseAdtsSize(F,ee),ee+q>F.length))break;de={type:"audio",data:F.subarray(ee,ee+q),pts:j,dts:j},this.trigger("data",de),ee+=q;continue}ee++}re=F.length-ee,re>0?F=F.subarray(ee):F=new Uint8Array},this.reset=function(){F=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){F=new Uint8Array,this.trigger("endedtimeline")}},Di.prototype=new n;var _s=Di,qd=Ue.H264Stream,fn=Vn.isLikelyAacData,Wn=or.ONE_SECOND_IN_TS,Aa=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],Gl=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],bs,ka,ko,qn,Yd=function(F,j){var K;if(F.length!==j.length)return!1;for(K=0;K<F.length;K++)if(F[K]!==j[K])return!1;return!0},Ts=function(F,j,K,q,ee,re){var oe=K-j,de=q-j,ye=ee-K;return{start:{dts:F,pts:F+oe},end:{dts:F+de,pts:F+ye},prependedContentDuration:re,baseMediaDecodeTime:F}};ka=function(F,j){var K=[],q=0,ee=0,re=0,oe=1/0;j=j||{},ka.prototype.init.call(this),this.push=function(de){Vr.collectDtsInfo(F,de),F&&Aa.forEach(function(ye){F[ye]=de[ye]}),K.push(de)},this.setEarliestDts=function(de){ee=de-F.timelineStartInfo.baseMediaDecodeTime},this.setVideoBaseMediaDecodeTime=function(de){oe=de},this.setAudioAppendStart=function(de){re=de},this.flush=function(){var de,ye,Ae,Je,dt;if(K.length===0){this.trigger("done","AudioSegmentStream");return}de=ki.trimAdtsFramesByEarliestDts(K,F,ee),F.baseMediaDecodeTime=Vr.calculateTrackBaseMediaDecodeTime(F,j.keepOriginalTimestamps),ki.prefixWithSilence(F,de,re,oe),F.samples=ki.generateSampleTable(de),Ae=Te.mdat(ki.concatenateFrameData(de)),K=[],ye=Te.moof(q,[F]),Je=new Uint8Array(ye.byteLength+Ae.byteLength),q++,Je.set(ye),Je.set(Ae,ye.byteLength),Vr.clearDtsInfo(F),dt=Math.ceil(Wn*1024/F.samplerate),de.length&&this.trigger("timingInfo",{start:de[0].dts,end:de[0].dts+de.length*dt}),this.trigger("data",{track:F,boxes:Je}),this.trigger("done","AudioSegmentStream")},this.reset=function(){Vr.clearDtsInfo(F),K=[],this.trigger("reset")}},ka.prototype=new n,bs=function(F,j){var K=0,q=[],ee=[],re,oe;j=j||{},bs.prototype.init.call(this),delete F.minPTS,this.gopCache_=[],this.push=function(de){Vr.collectDtsInfo(F,de),de.nalUnitType==="seq_parameter_set_rbsp"&&!re&&(re=de.config,F.sps=[de.data],Gl.forEach(function(ye){F[ye]=re[ye]},this)),de.nalUnitType==="pic_parameter_set_rbsp"&&!oe&&(oe=de.data,F.pps=[de.data]),q.push(de)},this.flush=function(){for(var de,ye,Ae,Je,dt,ht,At=0,Ot,We;q.length&&q[0].nalUnitType!=="access_unit_delimiter_rbsp";)q.shift();if(q.length===0){this.resetStream_(),this.trigger("done","VideoSegmentStream");return}if(de=Be.groupNalsIntoFrames(q),Ae=Be.groupFramesIntoGops(de),Ae[0][0].keyFrame||(ye=this.getGopForFusion_(q[0],F),ye?(At=ye.duration,Ae.unshift(ye),Ae.byteLength+=ye.byteLength,Ae.nalCount+=ye.nalCount,Ae.pts=ye.pts,Ae.dts=ye.dts,Ae.duration+=ye.duration):Ae=Be.extendFirstKeyFrame(Ae)),ee.length){var Or;if(j.alignGopsAtEnd?Or=this.alignGopsAtEnd_(Ae):Or=this.alignGopsAtStart_(Ae),!Or){this.gopCache_.unshift({gop:Ae.pop(),pps:F.pps,sps:F.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),q=[],this.resetStream_(),this.trigger("done","VideoSegmentStream");return}Vr.clearDtsInfo(F),Ae=Or}Vr.collectDtsInfo(F,Ae),F.samples=Be.generateSampleTable(Ae),dt=Te.mdat(Be.concatenateNalData(Ae)),F.baseMediaDecodeTime=Vr.calculateTrackBaseMediaDecodeTime(F,j.keepOriginalTimestamps),this.trigger("processedGopsInfo",Ae.map(function(fi){return{pts:fi.pts,dts:fi.dts,byteLength:fi.byteLength}})),Ot=Ae[0],We=Ae[Ae.length-1],this.trigger("segmentTimingInfo",Ts(F.baseMediaDecodeTime,Ot.dts,Ot.pts,We.dts+We.duration,We.pts+We.duration,At)),this.trigger("timingInfo",{start:Ae[0].dts,end:Ae[Ae.length-1].dts+Ae[Ae.length-1].duration}),this.gopCache_.unshift({gop:Ae.pop(),pps:F.pps,sps:F.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),q=[],this.trigger("baseMediaDecodeTime",F.baseMediaDecodeTime),this.trigger("timelineStartInfo",F.timelineStartInfo),Je=Te.moof(K,[F]),ht=new Uint8Array(Je.byteLength+dt.byteLength),K++,ht.set(Je),ht.set(dt,Je.byteLength),this.trigger("data",{track:F,boxes:ht}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),q=[],this.gopCache_.length=0,ee.length=0,this.trigger("reset")},this.resetStream_=function(){Vr.clearDtsInfo(F),re=void 0,oe=void 0},this.getGopForFusion_=function(de){var ye=45e3,Ae=1e4,Je=1/0,dt,ht,At,Ot,We;for(We=0;We<this.gopCache_.length;We++)Ot=this.gopCache_[We],At=Ot.gop,!(!(F.pps&&Yd(F.pps[0],Ot.pps[0]))||!(F.sps&&Yd(F.sps[0],Ot.sps[0])))&&(At.dts<F.timelineStartInfo.dts||(dt=de.dts-At.dts-At.duration,dt>=-Ae&&dt<=ye&&(!ht||Je>dt)&&(ht=Ot,Je=dt)));return ht?ht.gop:null},this.alignGopsAtStart_=function(de){var ye,Ae,Je,dt,ht,At,Ot,We;for(ht=de.byteLength,At=de.nalCount,Ot=de.duration,ye=Ae=0;ye<ee.length&&Ae<de.length&&(Je=ee[ye],dt=de[Ae],Je.pts!==dt.pts);){if(dt.pts>Je.pts){ye++;continue}Ae++,ht-=dt.byteLength,At-=dt.nalCount,Ot-=dt.duration}return Ae===0?de:Ae===de.length?null:(We=de.slice(Ae),We.byteLength=ht,We.duration=Ot,We.nalCount=At,We.pts=We[0].pts,We.dts=We[0].dts,We)},this.alignGopsAtEnd_=function(de){var ye,Ae,Je,dt,ht,At;for(ye=ee.length-1,Ae=de.length-1,ht=null,At=!1;ye>=0&&Ae>=0;){if(Je=ee[ye],dt=de[Ae],Je.pts===dt.pts){At=!0;break}if(Je.pts>dt.pts){ye--;continue}ye===ee.length-1&&(ht=Ae),Ae--}if(!At&&ht===null)return null;var Ot;if(At?Ot=Ae:Ot=ht,Ot===0)return de;var We=de.slice(Ot),Or=We.reduce(function(fi,Ca){return fi.byteLength+=Ca.byteLength,fi.duration+=Ca.duration,fi.nalCount+=Ca.nalCount,fi},{byteLength:0,duration:0,nalCount:0});return We.byteLength=Or.byteLength,We.duration=Or.duration,We.nalCount=Or.nalCount,We.pts=We[0].pts,We.dts=We[0].dts,We},this.alignGopsWith=function(de){ee=de}},bs.prototype=new n,qn=function(F,j){this.numberOfTracks=0,this.metadataStream=j,F=F||{},typeof F.remux<"u"?this.remuxTracks=!!F.remux:this.remuxTracks=!0,typeof F.keepOriginalTimestamps=="boolean"?this.keepOriginalTimestamps=F.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,qn.prototype.init.call(this),this.push=function(K){if(K.text)return this.pendingCaptions.push(K);if(K.frames)return this.pendingMetadata.push(K);this.pendingTracks.push(K.track),this.pendingBytes+=K.boxes.byteLength,K.track.type==="video"&&(this.videoTrack=K.track,this.pendingBoxes.push(K.boxes)),K.track.type==="audio"&&(this.audioTrack=K.track,this.pendingBoxes.unshift(K.boxes))}},qn.prototype=new n,qn.prototype.flush=function(se){var F=0,j={captions:[],captionStreams:{},metadata:[],info:{}},K,q,ee,re=0,oe;if(this.pendingTracks.length<this.numberOfTracks){if(se!=="VideoSegmentStream"&&se!=="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?(re=this.videoTrack.timelineStartInfo.pts,Gl.forEach(function(de){j.info[de]=this.videoTrack[de]},this)):this.audioTrack&&(re=this.audioTrack.timelineStartInfo.pts,Aa.forEach(function(de){j.info[de]=this.audioTrack[de]},this)),this.videoTrack||this.audioTrack){for(this.pendingTracks.length===1?j.type=this.pendingTracks[0].type:j.type="combined",this.emittedTracks+=this.pendingTracks.length,ee=Te.initSegment(this.pendingTracks),j.initSegment=new Uint8Array(ee.byteLength),j.initSegment.set(ee),j.data=new Uint8Array(this.pendingBytes),oe=0;oe<this.pendingBoxes.length;oe++)j.data.set(this.pendingBoxes[oe],F),F+=this.pendingBoxes[oe].byteLength;for(oe=0;oe<this.pendingCaptions.length;oe++)K=this.pendingCaptions[oe],K.startTime=or.metadataTsToSeconds(K.startPts,re,this.keepOriginalTimestamps),K.endTime=or.metadataTsToSeconds(K.endPts,re,this.keepOriginalTimestamps),j.captionStreams[K.stream]=!0,j.captions.push(K);for(oe=0;oe<this.pendingMetadata.length;oe++)q=this.pendingMetadata[oe],q.cueTime=or.metadataTsToSeconds(q.pts,re,this.keepOriginalTimestamps),j.metadata.push(q);for(j.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",j),oe=0;oe<j.captions.length;oe++)K=j.captions[oe],this.trigger("caption",K);for(oe=0;oe<j.metadata.length;oe++)q=j.metadata[oe],this.trigger("id3Frame",q)}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},qn.prototype.setRemux=function(se){this.remuxTracks=se},ko=function(F){var j=this,K=!0,q,ee;ko.prototype.init.call(this),F=F||{},this.baseMediaDecodeTime=F.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var re={};this.transmuxPipeline_=re,re.type="aac",re.metadataStream=new ci.MetadataStream,re.aacStream=new _s,re.audioTimestampRolloverStream=new ci.TimestampRolloverStream("audio"),re.timedMetadataTimestampRolloverStream=new ci.TimestampRolloverStream("timed-metadata"),re.adtsStream=new te,re.coalesceStream=new qn(F,re.metadataStream),re.headOfPipeline=re.aacStream,re.aacStream.pipe(re.audioTimestampRolloverStream).pipe(re.adtsStream),re.aacStream.pipe(re.timedMetadataTimestampRolloverStream).pipe(re.metadataStream).pipe(re.coalesceStream),re.metadataStream.on("timestamp",function(oe){re.aacStream.setTimestamp(oe.timeStamp)}),re.aacStream.on("data",function(oe){oe.type==="timed-metadata"&&!re.audioSegmentStream&&(ee=ee||{timelineStartInfo:{baseMediaDecodeTime:j.baseMediaDecodeTime},codec:"adts",type:"audio"},re.coalesceStream.numberOfTracks++,re.audioSegmentStream=new ka(ee,F),re.audioSegmentStream.on("timingInfo",j.trigger.bind(j,"audioTimingInfo")),re.adtsStream.pipe(re.audioSegmentStream).pipe(re.coalesceStream)),j.trigger("trackinfo",{hasAudio:!!ee,hasVideo:!!q})}),re.coalesceStream.on("data",this.trigger.bind(this,"data")),re.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setupTsPipeline=function(){var re={};this.transmuxPipeline_=re,re.type="ts",re.metadataStream=new ci.MetadataStream,re.packetStream=new ci.TransportPacketStream,re.parseStream=new ci.TransportParseStream,re.elementaryStream=new ci.ElementaryStream,re.timestampRolloverStream=new ci.TimestampRolloverStream,re.adtsStream=new te,re.h264Stream=new qd,re.captionStream=new ci.CaptionStream,re.coalesceStream=new qn(F,re.metadataStream),re.headOfPipeline=re.packetStream,re.packetStream.pipe(re.parseStream).pipe(re.elementaryStream).pipe(re.timestampRolloverStream),re.timestampRolloverStream.pipe(re.h264Stream),re.timestampRolloverStream.pipe(re.adtsStream),re.timestampRolloverStream.pipe(re.metadataStream).pipe(re.coalesceStream),re.h264Stream.pipe(re.captionStream).pipe(re.coalesceStream),re.elementaryStream.on("data",function(oe){var de;if(oe.type==="metadata"){for(de=oe.tracks.length;de--;)!q&&oe.tracks[de].type==="video"?(q=oe.tracks[de],q.timelineStartInfo.baseMediaDecodeTime=j.baseMediaDecodeTime):!ee&&oe.tracks[de].type==="audio"&&(ee=oe.tracks[de],ee.timelineStartInfo.baseMediaDecodeTime=j.baseMediaDecodeTime);q&&!re.videoSegmentStream&&(re.coalesceStream.numberOfTracks++,re.videoSegmentStream=new bs(q,F),re.videoSegmentStream.on("timelineStartInfo",function(ye){ee&&(ee.timelineStartInfo=ye,re.audioSegmentStream.setEarliestDts(ye.dts))}),re.videoSegmentStream.on("processedGopsInfo",j.trigger.bind(j,"gopInfo")),re.videoSegmentStream.on("segmentTimingInfo",j.trigger.bind(j,"videoSegmentTimingInfo")),re.videoSegmentStream.on("baseMediaDecodeTime",function(ye){ee&&re.audioSegmentStream.setVideoBaseMediaDecodeTime(ye)}),re.videoSegmentStream.on("timingInfo",j.trigger.bind(j,"videoTimingInfo")),re.h264Stream.pipe(re.videoSegmentStream).pipe(re.coalesceStream)),ee&&!re.audioSegmentStream&&(re.coalesceStream.numberOfTracks++,re.audioSegmentStream=new ka(ee,F),re.audioSegmentStream.on("timingInfo",j.trigger.bind(j,"audioTimingInfo")),re.adtsStream.pipe(re.audioSegmentStream).pipe(re.coalesceStream)),j.trigger("trackinfo",{hasAudio:!!ee,hasVideo:!!q})}}),re.coalesceStream.on("data",this.trigger.bind(this,"data")),re.coalesceStream.on("id3Frame",function(oe){oe.dispatchType=re.metadataStream.dispatchType,j.trigger("id3Frame",oe)}),re.coalesceStream.on("caption",this.trigger.bind(this,"caption")),re.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setBaseMediaDecodeTime=function(re){var oe=this.transmuxPipeline_;F.keepOriginalTimestamps||(this.baseMediaDecodeTime=re),ee&&(ee.timelineStartInfo.dts=void 0,ee.timelineStartInfo.pts=void 0,Vr.clearDtsInfo(ee),F.keepOriginalTimestamps||(ee.timelineStartInfo.baseMediaDecodeTime=re),oe.audioTimestampRolloverStream&&oe.audioTimestampRolloverStream.discontinuity()),q&&(oe.videoSegmentStream&&(oe.videoSegmentStream.gopCache_=[]),q.timelineStartInfo.dts=void 0,q.timelineStartInfo.pts=void 0,Vr.clearDtsInfo(q),oe.captionStream.reset(),F.keepOriginalTimestamps||(q.timelineStartInfo.baseMediaDecodeTime=re)),oe.timestampRolloverStream&&oe.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(re){ee&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(re)},this.setRemux=function(re){var oe=this.transmuxPipeline_;F.remux=re,oe&&oe.coalesceStream&&oe.coalesceStream.setRemux(re)},this.alignGopsWith=function(re){q&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(re)},this.push=function(re){if(K){var oe=fn(re);oe&&this.transmuxPipeline_.type!=="aac"?this.setupAacPipeline():!oe&&this.transmuxPipeline_.type!=="ts"&&this.setupTsPipeline(),K=!1}this.transmuxPipeline_.headOfPipeline.push(re)},this.flush=function(){K=!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()}},ko.prototype=new n;var Vl={Transmuxer:ko,VideoSegmentStream:bs,AudioSegmentStream:ka,AUDIO_PROPERTIES:Aa,VIDEO_PROPERTIES:Gl,generateVideoSegmentTimingInfo:Ts},Kd=function(F,j){if(!(F instanceof j))throw new TypeError("Cannot call a class as a function")},Wl=function(){function se(F,j){for(var K=0;K<j.length;K++){var q=j[K];q.enumerable=q.enumerable||!1,q.configurable=!0,"value"in q&&(q.writable=!0),Object.defineProperty(F,q.key,q)}}return function(F,j,K){return j&&se(F.prototype,j),K&&se(F,K),F}}(),Rp=function(F,j){j.on("data",function(K){var q=K.initSegment;K.initSegment={data:q.buffer,byteOffset:q.byteOffset,byteLength:q.byteLength};var ee=K.data;K.data=ee.buffer,F.postMessage({action:"data",segment:K,byteOffset:ee.byteOffset,byteLength:ee.byteLength},[K.data])}),j.captionStream&&j.captionStream.on("data",function(K){F.postMessage({action:"caption",data:K})}),j.on("done",function(K){F.postMessage({action:"done"})}),j.on("gopInfo",function(K){F.postMessage({action:"gopInfo",gopInfo:K})}),j.on("videoSegmentTimingInfo",function(K){F.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:K})})},$d=function(){function se(F,j){Kd(this,se),this.options=j||{},this.self=F,this.init()}return Wl(se,[{key:"init",value:function(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new Vl.Transmuxer(this.options),Rp(this.self,this.transmuxer)}},{key:"push",value:function(j){var K=new Uint8Array(j.data,j.byteOffset,j.byteLength);this.transmuxer.push(K)}},{key:"reset",value:function(){this.init()}},{key:"setTimestampOffset",value:function(j){var K=j.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(K*9e4))}},{key:"setAudioAppendStart",value:function(j){this.transmuxer.setAudioAppendStart(Math.ceil(j.appendStart*9e4))}},{key:"flush",value:function(j){this.transmuxer.flush()}},{key:"resetCaptions",value:function(){this.transmuxer.resetCaptions()}},{key:"alignGopsWith",value:function(j){this.transmuxer.alignGopsWith(j.gopsToAlignWith.slice())}}]),se}(),Dp=function(F){F.onmessage=function(j){if(j.data.action==="init"&&j.data.options){this.messageHandlers=new $d(F,j.data.options);return}this.messageHandlers||(this.messageHandlers=new $d(F)),j.data&&j.data.action&&j.data.action!=="init"&&this.messageHandlers[j.data.action]&&this.messageHandlers[j.data.action](j.data)}},Pp=new Dp(i);return Pp})()}),Bm={videoCodec:"avc1",videoObjectTypeIndicator:".4d400d",audioProfile:"2"},jm=function(r){return r.map(function(i){return i.replace(/avc1\.(\d+)\.(\d+)/i,function(t,n,a){var s=("00"+Number(n).toString(16)).slice(-2),o=("00"+Number(a).toString(16)).slice(-2);return"avc1."+s+"00"+o})})},rl=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},nw=function(r){return r.replace(/avc1\.(\d+)\.(\d+)/i,function(i){return jm([i])[0]})},Rf=function(r,i,t){return r+"/"+i+'; codecs="'+t.filter(function(n){return!!n}).join(", ")+'"'},aw=function(r){return r.segments&&r.segments.length&&r.segments[0].map?"mp4":"mp2t"},sw=function(r){var i=r.attributes||{};return i.CODECS?rl(i.CODECS):Bm},ow=function(r,i){if(!r.mediaGroups.AUDIO||!i)return null;var t=r.mediaGroups.AUDIO[i];if(!t)return null;for(var n in t){var a=t[n];if(a.default&&a.playlists)return rl(a.playlists[0].attributes.CODECS).audioProfile}return null},lw=function(r,i){var t=aw(i),n=sw(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&&!n.audioProfile&&(s||(n.audioProfile=ow(r,a.AUDIO)),n.audioProfile||(W.log.warn("Multiple audio tracks present but no audio codec string is specified. Attempting to use the default audio codec (mp4a.40.2)"),n.audioProfile=Bm.audioProfile));var h={};n.videoCodec&&(h.video=""+n.videoCodec+n.videoObjectTypeIndicator),n.audioProfile&&(h.audio="mp4a.40."+n.audioProfile);var d=Rf("audio",t,[h.audio]),g=Rf("video",t,[h.video]),c=Rf("video",t,[h.video,h.audio]);return o?!s&&h.video?[g,d]:!s&&!h.video?[d,d]:[c,d]:h.video?[c]:[d]},uw=function(r){var i={type:"",parameters:{}},t=r.trim().split(";");return i.type=t.shift().trim(),t.forEach(function(n){var a=n.trim().split("=");if(a.length>1){var s=a[0].replace(/"/g,"").trim(),o=a[1].replace(/"/g,"").trim();i.parameters[s]=o}}),i},Hm=function(r){return/mp4a\.\d+.\d+/i.test(r)},Gm=function(r){return/avc1\.[\da-f]+/i.test(r)},dw=function(r,i,t){if(typeof i>"u"||i===null||!r.length)return[];var n=Math.ceil((i-t+3)*9e4),a=void 0;for(a=0;a<r.length&&!(r[a].pts>n);a++);return r.slice(a)},cw=function(r,i,t){if(!i.length)return r;if(t)return i.slice();var n=i[0].pts,a=0;for(a;a<r.length&&!(r[a].pts>=n);a++);return r.slice(0,a).concat(i)},fw=function(r,i,t,n){for(var a=Math.ceil((i-n)*9e4),s=Math.ceil((t-n)*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},hw=function(r,i,t){var n=null,a=null,s=0,o=[],u=[];if(!r&&!i)return W.createTimeRange();if(!r)return i.buffered;if(!i||t)return r.buffered;if(r.buffered.length===0&&i.buffered.length===0)return W.createTimeRange();for(var l=r.buffered,h=i.buffered,d=l.length;d--;)o.push({time:l.start(d),type:"start"}),o.push({time:l.end(d),type:"end"});for(d=h.length;d--;)o.push({time:h.start(d),type:"start"}),o.push({time:h.end(d),type:"end"});for(o.sort(function(g,c){return g.time-c.time}),d=0;d<o.length;d++)o[d].type==="start"?(s++,s===2&&(n=o[d].time)):o[d].type==="end"&&(s--,s===1&&(a=o[d].time)),n!==null&&a!==null&&(u.push([n,a]),n=null,a=null);return W.createTimeRanges(u)},qs=9e4,pw=function(r,i){var t=r.addSourceBuffer(i),n=Object.create(null);n.updating=!1,n.realBuffer_=t;var a=function(u){typeof t[u]=="function"?n[u]=function(){return t[u].apply(t,arguments)}:typeof n[u]>"u"&&Object.defineProperty(n,u,{get:function(){return t[u]},set:function(h){return t[u]=h}})};for(var s in t)a(s);return n},gw=function(e){yn(r,e);function r(i,t){Si(this,r);var n=zi(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,W.EventTarget));n.timestampOffset_=0,n.pendingBuffers_=[],n.bufferUpdating_=!1,n.mediaSource_=i,n.codecs_=t,n.audioCodec_=null,n.videoCodec_=null,n.audioDisabled_=!1,n.appendAudioInitSegment_=!0,n.gopBuffer_=[],n.timeMapping_=0,n.safeAppend_=W.browser.IE_VERSION>=11;var a={remux:!1,alignGopsAtEnd:n.safeAppend_};return n.codecs_.forEach(function(s){Hm(s)?n.audioCodec_=s:Gm(s)&&(n.videoCodec_=s)}),n.transmuxer_=new iw,n.transmuxer_.postMessage({action:"init",options:a}),n.transmuxer_.onmessage=function(s){if(s.data.action==="data")return n.data_(s);if(s.data.action==="done")return n.done_(s);if(s.data.action==="gopInfo")return n.appendGopInfo_(s);if(s.data.action==="videoSegmentTimingInfo")return n.videoSegmentTimingInfo_(s.data.videoSegmentTimingInfo)},Object.defineProperty(n,"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(n,"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(n,"updating",{get:function(){return!!(this.bufferUpdating_||!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.updating||this.videoBuffer_&&this.videoBuffer_.updating)}}),Object.defineProperty(n,"buffered",{get:function(){return hw(this.videoBuffer_,this.audioBuffer_,this.audioDisabled_)}}),n}return Ii(r,[{key:"data_",value:function(t){var n=t.data.segment;n.data=new Uint8Array(n.data,t.data.byteOffset,t.data.byteLength),n.initSegment=new Uint8Array(n.initSegment.data,n.initSegment.byteOffset,n.initSegment.byteLength),Jx(this,this.mediaSource_,n),this.pendingBuffers_.push(n)}},{key:"done_",value:function(t){if(this.mediaSource_.readyState==="closed"){this.pendingBuffers_.length=0;return}this.processPendingSegments_()}},{key:"videoSegmentTimingInfo_",value:function(t){var n={start:{decode:t.start.dts/qs,presentation:t.start.pts/qs},end:{decode:t.end.dts/qs,presentation:t.end.pts/qs},baseMediaDecodeTime:t.baseMediaDecodeTime/qs};t.prependedContentDuration&&(n.prependedContentDuration=t.prependedContentDuration/qs),this.trigger({type:"videoSegmentTimingInfo",videoSegmentTimingInfo:n})}},{key:"createRealSourceBuffers_",value:function(){var t=this,n=["audio","video"];n.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=pw(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 h=n.every(function(d){return d==="audio"&&t.audioDisabled_?!0:!(a!==d&&t[d+"Buffer_"]&&t[d+"Buffer_"].updating)});if(h)return t.trigger(l)}})})}})}},{key:"appendBuffer",value:function(t){if(this.bufferUpdating_=!0,this.audioBuffer_&&this.audioBuffer_.buffered.length){var n=this.audioBuffer_.buffered;this.transmuxer_.postMessage({action:"setAudioAppendStart",appendStart:n.end(n.length-1)})}this.videoBuffer_&&this.transmuxer_.postMessage({action:"alignGopsWith",gopsToAlignWith:dw(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_=cw(this.gopBuffer_,t.data.gopInfo,this.safeAppend_)}},{key:"remove",value:function(t,n){if(this.videoBuffer_&&(this.videoBuffer_.updating=!0,this.videoBuffer_.remove(t,n),this.gopBuffer_=fw(this.gopBuffer_,t,n,this.timeMapping_)),!this.audioDisabled_&&this.audioBuffer_&&(this.audioBuffer_.updating=!0,this.audioBuffer_.remove(t,n)),Gs(t,n,this.metadataTrack_),this.inbandTextTracks_)for(var a in this.inbandTextTracks_)Gs(t,n,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 n=!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_)&&(n=!0),Zx(this,t.captions,t.metadata),!this.audioDisabled_&&this.audioBuffer_&&this.concatAndAppendSegments_(t.audio,this.audioBuffer_),this.pendingBuffers_.length=0,n&&this.trigger("updateend"),this.bufferUpdating_=!1}},{key:"concatAndAppendSegments_",value:function(t,n){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{n.updating=!0,n.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}(W.EventTarget),Df=function(e){yn(r,e);function r(){Si(this,r);var i=zi(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),t=void 0;i.nativeMediaSource_=new ge.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?W.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 n=i.sourceBuffers[0];n.appendAudioInitSegment_=!0,n.audioDisabled_=!n.audioCodec_,i.activeSourceBuffers_.push(n);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,h){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_=h?s:!s,l.audioDisabled_))return;i.activeSourceBuffers_.push(l)})},i.onPlayerMediachange_=function(){i.sourceBuffers.forEach(function(n){n.appendAudioInitSegment_=!0})},i.onHlsReset_=function(){i.sourceBuffers.forEach(function(n){n.transmuxer_&&n.transmuxer_.postMessage({action:"resetCaptions"})})},i.onHlsSegmentTimeMapping_=function(n){i.sourceBuffers.forEach(function(a){return a.timeMapping_=n.mapping})},["sourceopen","sourceclose","sourceended"].forEach(function(n){this.nativeMediaSource_.addEventListener(n,this.trigger.bind(this))},i),i.on("sourceopen",function(n){var a=$e.querySelector('[src="'+i.url_+'"]');!a||(i.player_=W(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(n){for(var a=Im(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(n){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 Ii(r,[{key:"addSeekableRange_",value:function(t,n){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;(n>this.nativeMediaSource_.duration||isNaN(this.nativeMediaSource_.duration))&&(this.nativeMediaSource_.duration=n)}},{key:"addSourceBuffer",value:function(t){var n=void 0,a=uw(t);if(/^(video|audio)\/mp2t$/i.test(a.type)){var s=[];a.parameters&&a.parameters.codecs&&(s=a.parameters.codecs.split(","),s=jm(s),s=s.filter(function(o){return Hm(o)||Gm(o)})),s.length===0&&(s=["avc1.4d400d","mp4a.40.2"]),n=new gw(this,s),this.sourceBuffers.length!==0&&(this.sourceBuffers[0].createRealSourceBuffers_(),n.createRealSourceBuffers_(),this.sourceBuffers[0].audioDisabled_=!0)}else n=this.nativeMediaSource_.addSourceBuffer(t);return this.sourceBuffers.push(n),n}}]),r}(W.EventTarget),Vm=0;W.mediaSources={};var Wm=function(r,i){var t=W.mediaSources[r];if(t)t.trigger({type:"sourceopen",swfId:i});else throw new Error("Media Source not found (Video.js)")},Pf=function(){return!!ge.MediaSource&&!!ge.MediaSource.isTypeSupported&&ge.MediaSource.isTypeSupported('video/mp4;codecs="avc1.4d400d,mp4a.40.2"')},il=function(){if(this.MediaSource={open:Wm,supportsNativeMediaSources:Pf},Pf())return new Df;throw new Error("Cannot use create a virtual MediaSource for this video")};il.open=Wm,il.supportsNativeMediaSources=Pf;var qm={createObjectURL:function(r){var i="blob:vjs-media-source/",t=void 0;return r instanceof Df?(t=ge.URL.createObjectURL(r.nativeMediaSource_),r.url_=t,t):r instanceof Df?(t=i+Vm,Vm++,W.mediaSources[t]=r,t):(t=ge.URL.createObjectURL(r),r.url_=t,t)}};W.MediaSource=il,W.URL=qm;var vw=W.EventTarget,Ym=W.mergeOptions,Km=function(r,i){for(var t=void 0,n=Ym(r,{duration:i.duration,minimumUpdatePeriod:i.minimumUpdatePeriod}),a=0;a<i.playlists.length;a++){var s=Ef(n,i.playlists[a]);s?n=s:t=!0}return Ou(i,function(o,u,l,h){if(o.playlists&&o.playlists.length){var d=o.playlists[0].uri,g=Ef(n,o.playlists[0]);g&&(n=g,n.mediaGroups[u][l][h].playlists[0]=n.playlists[d],t=!1)}}),t?null:n},Lf=function(r){var i=r.byterange.offset+r.byterange.length-1;return r.uri+"-"+r.byterange.offset+"-"+i},mw=function(r,i){var t=Boolean(!r.map&&!i.map),n=t||Boolean(r.map&&i.map&&r.map.byterange.offset===i.map.byterange.offset&&r.map.byterange.length===i.map.byterange.length);return n&&r.uri===i.uri&&r.byterange.offset===i.byterange.offset&&r.byterange.length===i.byterange.length},$m=function(r,i){var t={};for(var n in r){var a=r[n],s=a.sidx;if(s){var o=Lf(s);if(!i[o])break;var u=i[o].sidxInfo;mw(u,s)&&(t[o]=i[o])}}return t},yw=function(r,i,t,n){var a=ag(r,{manifestUri:i,clientOffset:t}),s=$m(a.playlists,n),o=s;return Ou(a,function(u,l,h,d){if(u.playlists&&u.playlists.length){var g=u.playlists;o=Ym(o,$m(g,n))}}),o},zm=function(r,i,t,n,a){var s={uri:Lu(n.handleManifestRedirects,r.resolvedUri),byterange:r.byterange,playlist:i},o=W.mergeOptions(s,{responseType:"arraybuffer",headers:Af(s)});return t(o,a)},Of=function(e){yn(r,e);function r(i,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=arguments[3];Si(this,r);var s=zi(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),o=n.withCredentials,u=o===void 0?!1:o,l=n.handleManifestRedirects,h=l===void 0?!1:l;if(s.hls_=t,s.withCredentials=u,s.handleManifestRedirects=h,!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_={},zi(s)):(s.setupChildLoader(a,i),s)}return Ii(r,[{key:"setupChildLoader",value:function(t,n){this.masterPlaylistLoader_=t,this.childPlaylist_=n}},{key:"dispose",value:function(){this.stopRequest(),this.loadedPlaylists_={},ge.clearTimeout(this.minimumUpdatePeriodTimeout_),ge.clearTimeout(this.mediaRequest_),ge.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,n,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(n,null);var h=new Uint8Array(l.response),d=fg.parseSidx(h.subarray(8));return s(n,d)}}}},{key:"media",value:function(t){var n=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_=ge.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=Lf(t.sidx);u[l]={sidxInfo:t.sidx},this.request=zm(t.sidx,t,this.hls_.xhr,{handleManifestRedirects:this.handleManifestRedirects},this.sidxRequestFinished_(t,o,a,function(h,d){if(!h||!d)throw new Error("failed to request sidx");u[l].sidx=d,n.haveMetadata({startingState:a,playlist:h.playlists[t.uri]})}))}}},{key:"haveMetadata",value:function(t){var n=t.startingState,a=t.playlist;this.state="HAVE_METADATA",this.loadedPlaylists_[a.uri]=a,this.mediaRequest_=null,this.refreshMedia_(a.uri),n==="HAVE_MASTER"?this.trigger("loadedmetadata"):this.trigger("mediachange")}},{key:"pause",value:function(){this.stopRequest(),ge.clearTimeout(this.mediaUpdateTimeout),ge.clearTimeout(this.minimumUpdatePeriodTimeout_),this.state==="HAVE_NOTHING"&&(this.started=!1)}},{key:"load",value:function(t){var n=this;ge.clearTimeout(this.mediaUpdateTimeout),ge.clearTimeout(this.minimumUpdatePeriodTimeout_);var a=this.media();if(t){var s=a?a.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=ge.setTimeout(function(){return n.load()},s);return}if(!this.started){this.start();return}this.trigger("loadedplaylist")}},{key:"parseMasterXml",value:function(){var t=ag(this.masterXml_,{manifestUri:this.srcUrl,clientOffset:this.clientOffset_,sidxMapping:this.sidxMapping_});t.uri=this.srcUrl;for(var n=0;n<t.playlists.length;n++){var a="placeholder-uri-"+n;t.playlists[n].uri=a,t.playlists[a]=t.playlists[n]}return Ou(t,function(s,o,u,l){if(s.playlists&&s.playlists.length){var h="placeholder-uri-"+o+"-"+u+"-"+l;s.playlists[0].uri=h,t.playlists[h]=s.playlists[0]}}),hm(t),pm(t),t}},{key:"start",value:function(){var t=this;if(this.started=!0,this.masterPlaylistLoader_){this.mediaRequest_=ge.setTimeout(this.haveMaster_.bind(this),0);return}this.request=this.hls_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},function(n,a){if(!!t.request){if(t.request=null,n)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=Lu(t.handleManifestRedirects,t.srcUrl,a),t.syncClientServerClock_(t.onClientServerClockSync_.bind(t))}})}},{key:"syncClientServerClock_",value:function(t){var n=this,a=HT(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:Wa(this.srcUrl,a.value),method:a.method,withCredentials:this.withCredentials},function(s,o){if(!!n.request){if(s)return n.clientOffset_=n.masterLoaded_-Date.now(),t();var u=void 0;a.method==="HEAD"?!o.responseHeaders||!o.responseHeaders.date?u=n.masterLoaded_:u=Date.parse(o.responseHeaders.date):u=Date.parse(o.responseText),n.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_=ge.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(n,a){if(!!t.request){if(t.request=null,n)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_=yw(t.masterXml_,t.srcUrl,t.clientOffset_,t.sidxMapping_);var s=t.parseMasterXml(),o=Km(t.master,s),u=t.media().sidx;if(o)if(u){var l=Lf(u);if(!t.sidxMapping_[l]){var h=t.media();t.request=zm(h.sidx,h,t.hls_.xhr,{handleManifestRedirects:t.handleManifestRedirects},t.sidxRequestFinished_(h,s,t.state,function(d,g){if(!d||!g)throw new Error("failed to request sidx on minimumUpdatePeriod");t.sidxMapping_[l].sidx=g,t.minimumUpdatePeriodTimeout_=ge.setTimeout(function(){t.trigger("minimumUpdatePeriod")},t.master.minimumUpdatePeriod),t.refreshMedia_(t.media().uri)}))}}else t.master=o;t.minimumUpdatePeriodTimeout_=ge.setTimeout(function(){t.trigger("minimumUpdatePeriod")},t.master.minimumUpdatePeriod)}})}},{key:"refreshMedia_",value:function(t){var n=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=Km(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=ge.setTimeout(function(){n.trigger("mediaupdatetimeout")},gm(this.media(),!!o))),this.trigger("loadedplaylist")}}]),r}(vw),nl=function(r){return W.log.debug?W.log.debug.bind(W,"VHS:",r+" >"):function(){}};function Ys(){}var _w=function(){function e(r,i,t,n){Si(this,e),this.callbacks_=[],this.pendingCallback_=null,this.timestampOffset_=0,this.mediaSource=r,this.processedAppend_=!1,this.type_=t,this.mimeType_=i,this.logger_=nl("SourceUpdater["+t+"]["+i+"]"),r.readyState==="closed"?r.addEventListener("sourceopen",this.createSourceBuffer_.bind(this,i,n)):this.createSourceBuffer_(i,n)}return Ii(e,[{key:"createSourceBuffer_",value:function(i,t){var n=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(){n.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 ["+kf(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 n=this;this.processedAppend_=!0,this.queueCallback_(function(){i.videoSegmentTimingInfoCallback&&n.sourceBuffer_.addEventListener("videoSegmentTimingInfo",i.videoSegmentTimingInfoCallback),n.sourceBuffer_.appendBuffer(i.bytes)},function(){i.videoSegmentTimingInfoCallback&&n.sourceBuffer_.removeEventListener("videoSegmentTimingInfo",i.videoSegmentTimingInfoCallback),t()})}},{key:"buffered",value:function(){return this.sourceBuffer_?this.sourceBuffer_.buffered:W.createTimeRanges()}},{key:"remove",value:function(i,t){var n=this,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ys;this.processedAppend_&&this.queueCallback_(function(){n.logger_("remove ["+i+" => "+t+"]"),n.sourceBuffer_.removing=!0,n.sourceBuffer_.remove(i,t)},a)}},{key:"updating",value:function(){return!this.sourceBuffer_||this.sourceBuffer_.updating||!!this.pendingCallback_&&this.pendingCallback_!==Ys}},{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 n(){i.sourceBuffer_&&i.mediaSource.readyState==="open"&&i.sourceBuffer_.abort(),i.sourceBuffer_.removeEventListener("updateend",n)};this.sourceBuffer_.removeEventListener("updateend",this.onUpdateendCallback_),this.sourceBuffer_.removing?this.sourceBuffer_.addEventListener("updateend",t):t()}}]),e}(),ui={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},na={FAILURE:2,TIMEOUT:-101,ABORTED:-102},Xm=function(r){r.forEach(function(i){i.abort()})},bw=function(r){return{bandwidth:r.bandwidth,bytesReceived:r.bytesReceived||0,roundTripTime:r.roundTripTime||0}},Tw=function(r){var i=r.target,t=Date.now()-i.requestTime,n={bandwidth:1/0,bytesReceived:0,roundTripTime:t||0};return n.bytesReceived=r.loaded,n.bandwidth=Math.floor(n.bytesReceived/n.roundTripTime*8*1e3),n},If=function(r,i){return i.timedout?{status:i.status,message:"HLS request timed-out at URL: "+i.uri,code:na.TIMEOUT,xhr:i}:i.aborted?{status:i.status,message:"HLS request aborted at URL: "+i.uri,code:na.ABORTED,xhr:i}:r?{status:i.status,message:"HLS request errored at URL: "+i.uri,code:na.FAILURE,xhr:i}:null},Sw=function(r,i){return function(t,n){var a=n.response,s=If(t,n);if(s)return i(s,r);if(a.byteLength!==16)return i({status:n.status,message:"Invalid HLS key at URL: "+n.uri,code:na.FAILURE,xhr:n},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)}},Ew=function(r,i,t){return function(n,a){var s=a.response,o=If(n,a);return o?t(o,r):s.byteLength===0?t({status:a.status,message:"Empty HLS segment content at URL: "+a.uri,code:na.FAILURE,xhr:a},r):(r.map.bytes=new Uint8Array(a.response),i&&!i.isInitialized()&&i.init(),r.map.timescales=As.timescale(r.map.bytes),r.map.videoTrackIds=As.videoTrackIds(r.map.bytes),t(null,r))}},xw=function(r,i,t){return function(n,a){var s=a.response,o=If(n,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:na.FAILURE,xhr:a},r):(r.stats=bw(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))}},ww=function(r,i,t){var n=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",n);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(Am({source:i.requestId,encrypted:i.encryptedBytes,key:a,iv:i.key.iv}),[i.encryptedBytes.buffer,a.buffer])},Aw=function(r,i,t){var n=0,a=!1;return function(s,o){if(!a){if(s)return a=!0,Xm(r),t(s,o);if(n+=1,n===r.length)return o.endOfAllRequests=Date.now(),o.encryptedBytes?ww(i,o,t):t(null,o)}}},kw=function(r,i){return function(t){return r.stats=W.mergeOptions(r.stats,Tw(t)),!r.stats.firstBytesReceivedAt&&r.stats.bytesReceived&&(r.stats.firstBytesReceivedAt=Date.now()),i(t,r)}},Cw=function(r,i,t,n,a,s,o){var u=[],l=Aw(u,t,o);if(a.key&&!a.key.bytes){var h=W.mergeOptions(i,{uri:a.key.resolvedUri,responseType:"arraybuffer"}),d=Sw(a,l),g=r(h,d);u.push(g)}if(a.map&&!a.map.bytes){var c=W.mergeOptions(i,{uri:a.map.resolvedUri,responseType:"arraybuffer",headers:Af(a.map)}),b=Ew(a,n,l),f=r(c,b);u.push(f)}var m=W.mergeOptions(i,{uri:a.resolvedUri,responseType:"arraybuffer",headers:Af(a)}),y=xw(a,n,l),v=r(m,y);return v.addEventListener("progress",kw(a,s)),u.push(v),function(){return Xm(u)}},Jm=function(r,i){var t=void 0;return!r||(t=ge.getComputedStyle(r),!t)?"":t[i]},al=function(r,i){var t=r.slice();r.sort(function(n,a){var s=i(n,a);return s===0?t.indexOf(n)-t.indexOf(a):s})},Mf=function(r,i){var t=void 0,n=void 0;return r.attributes.BANDWIDTH&&(t=r.attributes.BANDWIDTH),t=t||ge.Number.MAX_VALUE,i.attributes.BANDWIDTH&&(n=i.attributes.BANDWIDTH),n=n||ge.Number.MAX_VALUE,t-n},Rw=function(r,i){var t=void 0,n=void 0;return r.attributes.RESOLUTION&&r.attributes.RESOLUTION.width&&(t=r.attributes.RESOLUTION.width),t=t||ge.Number.MAX_VALUE,i.attributes.RESOLUTION&&i.attributes.RESOLUTION.width&&(n=i.attributes.RESOLUTION.width),n=n||ge.Number.MAX_VALUE,t===n&&r.attributes.BANDWIDTH&&i.attributes.BANDWIDTH?r.attributes.BANDWIDTH-i.attributes.BANDWIDTH:t-n},Dw=function(r,i,t,n,a){var s=r.playlists.map(function(p){var S=void 0,E=void 0,w=void 0;return S=p.attributes.RESOLUTION&&p.attributes.RESOLUTION.width,E=p.attributes.RESOLUTION&&p.attributes.RESOLUTION.height,w=p.attributes.BANDWIDTH,w=w||ge.Number.MAX_VALUE,{bandwidth:w,width:S,height:E,playlist:p}});al(s,function(p,S){return p.bandwidth-S.bandwidth}),s=s.filter(function(p){return!ti.isIncompatible(p.playlist)});var o=s.filter(function(p){return ti.isEnabled(p.playlist)});o.length||(o=s.filter(function(p){return!ti.isDisabled(p.playlist)}));var u=o.filter(function(p){return p.bandwidth*ui.BANDWIDTH_VARIANCE<i}),l=u[u.length-1],h=u.filter(function(p){return p.bandwidth===l.bandwidth})[0];if(a===!1){var d=h||o[0]||s[0];return d?d.playlist:null}var g=u.filter(function(p){return p.width&&p.height});al(g,function(p,S){return p.width-S.width});var c=g.filter(function(p){return p.width===t&&p.height===n});l=c[c.length-1];var b=c.filter(function(p){return p.bandwidth===l.bandwidth})[0],f=void 0,m=void 0,y=void 0;b||(f=g.filter(function(p){return p.width>t||p.height>n}),m=f.filter(function(p){return p.width===f[0].width&&p.height===f[0].height}),l=m[m.length-1],y=m.filter(function(p){return p.bandwidth===l.bandwidth})[0]);var v=y||b||h||o[0]||s[0];return v?v.playlist:null},Pw=function(){return Dw(this.playlists.master,this.systemBandwidth,parseInt(Jm(this.tech_.el(),"width"),10),parseInt(Jm(this.tech_.el(),"height"),10),this.limitRenditionByPlayerDimensions)},Lw=function(r){var i=r.master,t=r.currentTime,n=r.bandwidth,a=r.duration,s=r.segmentDuration,o=r.timeUntilRebuffer,u=r.currentTimeline,l=r.syncController,h=i.playlists.filter(function(f){return!ti.isIncompatible(f)}),d=h.filter(ti.isEnabled);d.length||(d=h.filter(function(f){return!ti.isDisabled(f)}));var g=d.filter(ti.hasAttribute.bind(null,"BANDWIDTH")),c=g.map(function(f){var m=l.getSyncPoint(f,a,u,t),y=m?1:2,v=ti.estimateSegmentRequestTime(s,n,f),p=v*y-o;return{playlist:f,rebufferingImpact:p}}),b=c.filter(function(f){return f.rebufferingImpact<=0});return al(b,function(f,m){return Mf(m.playlist,f.playlist)}),b.length?b[0]:(al(c,function(f,m){return f.rebufferingImpact-m.rebufferingImpact}),c[0]||null)},Ow=function(){var r=this.playlists.master.playlists.filter(ti.isEnabled);al(r,function(t,n){return Mf(t,n)});var i=r.filter(function(t){return rl(t.attributes.CODECS).videoCodec});return i[0]||null},Iw=function(r,i,t){for(var n in t)if(!r[n]){i.trigger({type:"usage",name:"hls-608"});var a=i.textTracks().getTrackById(n);a?r[n]=a:r[n]=i.addRemoteTextTrack({kind:"captions",id:n,label:n},!1).track}},Mw=function(r){var i=r.inbandTextTracks,t=r.captionArray,n=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+=n,l+=n,i[o].addCue(new a(u,l,s.text)))})}},Nw=500,Fw=function(r,i,t){if(!r||!i)return!1;var n=r.segments,a=t===n.length;return r.endList&&i.readyState==="open"&&a},Qm=function(r){return typeof r=="number"&&isFinite(r)},Uw=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},Bw=function(r,i,t){var n=void 0;return r.length&&r.start(0)>0&&r.start(0)<i?n=r.start(0):n=i-30,Math.min(n,i-t)},jw=function(r){var i=r.segment,t=i.start,n=i.end,a=r.playlist,s=a.mediaSequence,o=a.id,u=a.segments,l=u===void 0?[]:u,h=r.mediaIndex,d=r.timeline;return["appending ["+h+"] of ["+s+", "+(s+l.length)+"] from playlist ["+o+"]","["+t+" => "+n+"] in timeline ["+d+"]"].join(" ")},Nf=function(e){yn(r,e);function r(i){Si(this,r);var t=zi(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 lS: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_=nl("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 Ii(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():W.createTimeRanges()}},{key:"initSegment",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=Nu(t),s=this.initSegments_[a];return n&&!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 n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=km(t),s=this.keyCache_[a];this.cacheEncryptionKeys_&&n&&!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 _w(this.mediaSource_,this.mimeType_,this.loaderType_,this.sourceBufferEmitter_),this.resetEverything(),this.monitorBuffer_()}},{key:"playlist",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!!t){var a=this.playlist_,s=this.pendingSegment_;this.playlist_=t,this.xhrOptions_=n,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_&&(ge.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}},{key:"paused",value:function(){return this.checkBufferTimeout_===null}},{key:"mimeType",value:function(t,n){this.mimeType_||(this.mimeType_=t,this.sourceBufferEmitter_=n,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,n,a){if(this.sourceUpdater_&&this.sourceUpdater_.remove(t,n,a),Gs(t,n,this.segmentMetadataTrack_),this.inbandTextTracks_)for(var s in this.inbandTextTracks_)Gs(t,n,this.inbandTextTracks_[s])}},{key:"monitorBuffer_",value:function(){this.checkBufferTimeout_&&ge.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=ge.setTimeout(this.monitorBufferTick_.bind(this),1)}},{key:"monitorBufferTick_",value:function(){this.state==="READY"&&this.fillBuffer_(),this.checkBufferTimeout_&&ge.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=ge.setTimeout(this.monitorBufferTick_.bind(this),Nw)}},{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 n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.playlist_;return Fw(n,this.mediaSource_,t)&&!this.sourceUpdater_.updating()}},{key:"checkBuffer_",value:function(t,n,a,s,o,u){var l=0,h=void 0;t.length&&(l=t.end(t.length-1));var d=Math.max(0,l-o);if(!n.segments.length||d>=this.goalBufferLength_()||!s&&d>=1)return null;if(u===null)return a=this.getSyncSegmentCandidate_(n),this.generateSegmentInfo_(n,a,null,!0);if(a!==null)return n.segments[a],h=l,this.generateSegmentInfo_(n,a+1,h,!1);if(this.fetchAtBuffer_){var g=ti.getMediaInfoForTime(n,l,u.segmentIndex,u.time);a=g.mediaIndex,h=g.startTime}else{var c=ti.getMediaInfoForTime(n,o,u.segmentIndex,u.time);a=c.mediaIndex,h=c.startTime}return this.generateSegmentInfo_(n,a,h,!1)}},{key:"getSyncSegmentCandidate_",value:function(t){var n=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===n.currentTimeline_});return a.length?a[Math.min(a.length-1,1)].segmentIndex:Math.max(t.segments.length-1,0)}},{key:"generateSegmentInfo_",value:function(t,n,a,s){if(n<0||n>=t.segments.length)return null;var o=t.segments[n];return{requestId:"segment-loader-"+Math.random(),uri:o.resolvedUri,mediaIndex:n,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 n=this.currentTime_(),a=t.bandwidth,s=this.pendingSegment_.duration,o=ti.estimateSegmentRequestTime(s,a,this.playlist_,t.bytesReceived),u=Xx(this.buffered_(),n,this.hls_.tech_.playbackRate())-1;if(o<=u)return!1;var l=Lw({master:this.hls_.playlists.master,currentTime:n,bandwidth:a,duration:this.duration_(),segmentDuration:s,timeUntilRebuffer:u,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!!l){var h=o-u,d=h-l.rebufferingImpact,g=.5;return u<=Fu&&(g=1),!l.playlist||l.playlist.uri===this.playlist_.uri||d<g?!1:(this.bandwidth=l.playlist.attributes.BANDWIDTH*ui.BANDWIDTH_VARIANCE+1,this.abort(),this.trigger("earlyabort"),!0)}}},{key:"handleProgress_",value:function(t,n){!this.pendingSegment_||n.requestId!==this.pendingSegment_.requestId||this.abortRequestEarly_(n.stats)||this.trigger("progress")}},{key:"loadSegment_",value:function(t){this.state="WAITING",this.pendingSegment_=t,this.trimBackBuffer_(t),t.abortRequests=Cw(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 n=Bw(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);n>0&&this.remove(0,n)}},{key:"createSimplifiedSegmentObj_",value:function(t){var n=t.segment,a={resolvedUri:n.resolvedUri,byterange:n.byterange,requestId:t.requestId};if(n.key){var s=n.key.iv||new Uint32Array([0,0,0,t.mediaIndex+t.playlist.mediaSequence]);a.key=this.segmentKey(n.key),a.key.iv=s}return n.map&&(a.map=this.initSegment(n.map)),a}},{key:"segmentRequestFinished_",value:function(t,n){if(this.mediaRequests+=1,n.stats&&(this.mediaBytesTransferred+=n.stats.bytesReceived,this.mediaTransferDuration+=n.stats.roundTripTime),!this.pendingSegment_){this.mediaRequestsAborted+=1;return}if(n.requestId===this.pendingSegment_.requestId){if(t){if(this.pendingSegment_=null,this.state="READY",t.code===na.ABORTED){this.mediaRequestsAborted+=1;return}if(this.pause(),t.code===na.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=n.stats.bandwidth,this.roundTrip=n.stats.roundTripTime,n.map&&(n.map=this.initSegment(n.map,!0)),n.key&&this.segmentKey(n.key,!0),this.processSegmentResponse_(n)}}},{key:"processSegmentResponse_",value:function(t){var n=this.pendingSegment_;n.bytes=t.bytes,t.map&&(n.segment.map.bytes=t.map.bytes),n.endOfAllRequests=t.endOfAllRequests,t.fmp4Captions&&(Iw(this.inbandTextTracks_,this.hls_.tech_,t.captionStreams),Mw({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 n=this.pendingSegment_,a=n.segment,s=this.syncController_.probeSegmentInfo(n);typeof this.startingMedia_>"u"&&s&&(s.containsAudio||s.containsVideo)&&(this.startingMedia_={containsAudio:s.containsAudio,containsVideo:s.containsVideo});var o=Uw(this.loaderType_,this.startingMedia_,s);if(o){this.error({message:o,blacklistDuration:1/0}),this.trigger("error");return}if(n.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}if(n.timestampOffset!==null&&n.timestampOffset!==this.sourceUpdater_.timestampOffset()){if(s&&s.segmentTimestampInfo){var u=s.segmentTimestampInfo[0].ptsTime,l=s.segmentTimestampInfo[0].dtsTime;n.timestampOffset-=u-l}this.sourceUpdater_.timestampOffset(n.timestampOffset),this.trigger("timestampoffset")}var h=this.syncController_.mappingForTimeline(n.timeline);if(h!==null&&this.trigger({type:"segmenttimemapping",mapping:h}),this.state="APPENDING",a.map){var d=Nu(a.map);if(!this.activeInitSegmentId_||this.activeInitSegmentId_!==d){var g=this.initSegment(a.map);this.sourceUpdater_.appendBuffer({bytes:g.bytes},function(){t.activeInitSegmentId_=d})}}n.byteLength=n.bytes.byteLength,typeof a.start=="number"&&typeof a.end=="number"?this.mediaSecondsLoaded+=a.end-a.start:this.mediaSecondsLoaded+=a.duration,this.logger_(jw(n)),this.sourceUpdater_.appendBuffer({bytes:n.bytes,videoSegmentTimingInfoCallback:this.handleVideoSegmentTimingInfo_.bind(this,n.requestId)},this.handleUpdateEnd_.bind(this))}},{key:"handleVideoSegmentTimingInfo_",value:function(t,n){if(!(!this.pendingSegment_||t!==this.pendingSegment_.requestId)){var a=this.pendingSegment_.segment;a.videoTimingInfo||(a.videoTimingInfo={}),a.videoTimingInfo.transmuxerPrependedSeconds=n.videoSegmentTimingInfo.prependedContentDuration||0,a.videoTimingInfo.transmuxedPresentationStart=n.videoSegmentTimingInfo.start.presentation,a.videoTimingInfo.transmuxedPresentationEnd=n.videoSegmentTimingInfo.end.presentation,a.videoTimingInfo.baseMediaDecodeTime=n.videoSegmentTimingInfo.baseMediaDecodeTime}}},{key:"handleUpdateEnd_",value:function(){if(!this.pendingSegment_){this.state="READY",this.paused()||this.monitorBuffer_();return}var t=this.pendingSegment_,n=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"),n.end&&this.currentTime_()-n.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 n=this.throughput.rate,a=Date.now()-t.endOfAllRequests+1,s=Math.floor(t.byteLength/a*8*1e3);this.throughput.rate+=(s-n)/++this.throughput.count}},{key:"addSegmentMetadataCue_",value:function(t){if(!!this.segmentMetadataTrack_){var n=t.segment,a=n.start,s=n.end;if(!(!Qm(a)||!Qm(s))){Gs(a,s,this.segmentMetadataTrack_);var o=ge.WebKitDataCue||ge.VTTCue,u={custom:n.custom,dateTimeObject:n.dateTimeObject,dateTimeString:n.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),h=new o(a,s,l);h.value=u,this.segmentMetadataTrack_.addCue(h)}}}}]),r}(W.EventTarget),Zm=function(r){return decodeURIComponent(escape(String.fromCharCode.apply(null,r)))},ey=new Uint8Array(`
80
80
 
81
- `.split("").map(function(e){return e.charCodeAt(0)})),Hw=function(e){yn(r,e);function r(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Si(this,r);var n=zi(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,i,t));return n.mediaSource_=null,n.subtitlesTrack_=null,n}return Ii(r,[{key:"buffered_",value:function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return W.createTimeRanges();var t=this.subtitlesTrack_.cues,n=t[0].startTime,a=t[t.length-1].startTime;return W.createTimeRanges([[n,a]])}},{key:"initSegment",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=Nu(t),s=this.initSegments_[a];if(n&&!s&&t.bytes){var o=ey.byteLength+t.bytes.byteLength,u=new Uint8Array(o);u.set(t.bytes),u.set(ey,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,n){Gs(t,n,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 n=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(n=this.skipEmptySegments_(n),!!n){if(this.syncController_.timestampOffsetForTimeline(n.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_(n)}}},{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 n=this.pendingSegment_,a=n.segment;if(typeof ge.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_(n)}catch(u){return this.error({message:u.message}),this.state="READY",this.pause(),this.trigger("error")}if(this.updateTimeMapping_(n,this.syncController_.timelines[n.timeline],this.playlist_),n.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}n.byteLength=n.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,n.cues.length&&this.remove(n.cues[0].endTime,n.cues[n.cues.length-1].endTime),n.cues.forEach(function(u){t.subtitlesTrack_.addCue(u)}),this.handleUpdateEnd_()}},{key:"parseVTTCues_",value:function(t){var n=void 0,a=!1;typeof ge.TextDecoder=="function"?n=new ge.TextDecoder("utf8"):(n=ge.WebVTT.StringDecoder(),a=!0);var s=new ge.WebVTT.Parser(ge,ge.vttjs,n);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){W.log.warn("Error encountered when parsing cues: "+l.message)},t.segment.map){var o=t.segment.map.bytes;a&&(o=Zm(o)),s.parse(o)}var u=t.bytes;a&&(u=Zm(u)),s.parse(u),s.flush()}},{key:"updateTimeMapping_",value:function(t,n,a){var s=t.segment;if(!!n){if(!t.cues.length){s.empty=!0;return}var o=t.timestampmap,u=o.MPEGTS/9e4-o.LOCAL+n.mapping;if(t.cues.forEach(function(d){d.startTime+=u,d.endTime+=u}),!a.syncInfo){var l=t.cues[0].startTime,h=t.cues[t.cues.length-1].startTime;a.syncInfo={mediaSequence:a.mediaSequence+t.mediaIndex,time:Math.min(l,h-s.duration)}}}}}]),r}(Nf),Gw=function(r,i){for(var t=r.cues,n=0;n<t.length;n++){var a=t[n];if(i>=a.adStartTime&&i<=a.adEndTime)return a}return null},Vw=function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!!r.segments)for(var n=t,a=void 0,s=0;s<r.segments.length;s++){var o=r.segments[s];if(a||(a=Gw(i,n+o.duration/2)),a){if("cueIn"in o){a.endTime=n,a.adEndTime=n,n+=o.duration,a=null;continue}if(n<a.endTime){n+=o.duration;continue}a.endTime+=o.duration}else if("cueOut"in o&&(a=new ge.VTTCue(n,n+o.duration,o.cueOut),a.adStartTime=n,a.adEndTime=n+parseFloat(o.cueOut),i.addCue(a)),"cueOutCont"in o){var u=void 0,l=void 0,h=o.cueOutCont.split("/").map(parseFloat),d=mx(h,2);u=d[0],l=d[1],a=new ge.VTTCue(n,n+o.duration,""),a.adStartTime=n-u,a.adEndTime=a.adStartTime+l,i.addCue(a)}n+=o.duration}},Ww=FS.inspect,ty=[{name:"VOD",run:function(r,i,t,n,a){if(t!==1/0){var s={time:0,segmentIndex:0};return s}return null}},{name:"ProgramDateTime",run:function(r,i,t,n,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 h=s[l];if(h.dateTimeObject){var d=h.dateTimeObject.getTime()/1e3,g=d+r.datetimeToDisplayTime,c=Math.abs(a-g);if(u!==null&&(c===0||u<c))break;u=c,o={time:g,segmentIndex:l}}}return o}},{name:"Segment",run:function(r,i,t,n,a){var s=i.segments||[],o=null,u=null;a=a||0;for(var l=0;l<s.length;l++){var h=s[l];if(h.timeline===n&&typeof h.start<"u"){var d=Math.abs(a-h.start);if(u!==null&&u<d)break;(!o||u===null||u>=d)&&(u=d,o={time:h.start,segmentIndex:l})}}return o}},{name:"Discontinuity",run:function(r,i,t,n,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],h=i.discontinuitySequence+u+1,d=r.discontinuities[h];if(d){var g=Math.abs(a-d.time);if(o!==null&&o<g)break;(!s||o===null||o>=g)&&(o=g,s={time:d.time,segmentIndex:l})}}return s}},{name:"Playlist",run:function(r,i,t,n,a){if(i.syncInfo){var s={time:i.syncInfo.time,segmentIndex:i.syncInfo.mediaSequence-i.mediaSequence};return s}return null}}],qw=function(e){yn(r,e);function r(){Si(this,r);var i=zi(this,(r.__proto__||Object.getPrototypeOf(r)).call(this));return i.inspectCache_=void 0,i.timelines=[],i.discontinuities=[],i.datetimeToDisplayTime=null,i.logger_=nl("SyncController"),i}return Ii(r,[{key:"getSyncPoint",value:function(t,n,a,s){var o=this.runStrategies_(t,n,a,s);return o.length?this.selectSyncPoint_(o,{key:"time",value:s}):null}},{key:"getExpiredTime",value:function(t,n){if(!t||!t.segments)return null;var a=this.runStrategies_(t,n,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+tl(t,s.segmentIndex,0))}},{key:"runStrategies_",value:function(t,n,a,s){for(var o=[],u=0;u<ty.length;u++){var l=ty[u],h=l.run(this,t,n,a,s);h&&(h.strategy=l.name,o.push({strategy:l.name,syncPoint:h}))}return o}},{key:"selectSyncPoint_",value:function(t,n){for(var a=t[0].syncPoint,s=Math.abs(t[0].syncPoint[n.key]-n.value),o=t[0].strategy,u=1;u<t.length;u++){var l=Math.abs(t[u].syncPoint[n.key]-n.value);l<s&&(s=l,a=t[u].syncPoint,o=t[u].strategy)}return this.logger_("syncPoint for ["+n.key+": "+n.value+"] chosen with strategy"+(" ["+o+"]: [time:"+a.time+",")+(" segmentIndex:"+a.segmentIndex+"]")),a}},{key:"saveExpiredSegmentInfo",value:function(t,n){for(var a=n.mediaSequence-t.mediaSequence,s=a-1;s>=0;s--){var o=t.segments[s];if(o&&typeof o.start<"u"){n.syncInfo={mediaSequence:t.mediaSequence+s,time:o.start},this.logger_("playlist refresh sync: [time:"+n.syncInfo.time+","+(" mediaSequence: "+n.syncInfo.mediaSequence+"]")),this.trigger("syncinfoupdate");break}}}},{key:"setDateTimeMapping",value:function(t){if(!this.datetimeToDisplayTime&&t.segments&&t.segments.length&&t.segments[0].dateTimeObject){var n=t.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-n}}},{key:"reset",value:function(){this.inspectCache_=void 0}},{key:"probeSegmentInfo",value:function(t){var n=t.segment,a=t.playlist,s=void 0;return n.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:n.start})),s}},{key:"probeMp4Segment_",value:function(t){var n=t.segment,a=As.timescale(n.map.bytes),s=As.startTime(a,t.bytes);return t.timestampOffset!==null&&(t.timestampOffset-=s),{start:s,end:s+n.duration}}},{key:"probeTsSegment_",value:function(t){var n=Ww(t.bytes,this.inspectCache_),a=void 0,s=void 0,o=void 0;if(!n)return null;n.video&&n.video.length===2?(this.inspectCache_=n.video[1].dts,a=n.video[0].dtsTime,s=n.video[1].dtsTime,o=n.video):n.audio&&n.audio.length===2&&(this.inspectCache_=n.audio[1].dts,a=n.audio[0].dtsTime,s=n.audio[1].dtsTime,o=n.audio);var u={segmentTimestampInfo:o,start:a,end:s,containsVideo:n.video&&n.video.length===2,containsAudio:n.audio&&n.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,n){var a=t.segment,s=this.timelines[t.timeline];if(t.timestampOffset!==null)s={time:t.startOfSegment,mapping:t.startOfSegment-n.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=n.end+s.mapping;else if(s)a.start=n.start+s.mapping,a.end=n.end+s.mapping;else return!1;return!0}},{key:"saveDiscontinuitySyncInfo_",value:function(t){var n=t.playlist,a=t.segment;if(a.discontinuity)this.discontinuities[a.timeline]={time:a.start,accuracy:0};else if(n.discontinuityStarts&&n.discontinuityStarts.length)for(var s=0;s<n.discontinuityStarts.length;s++){var o=n.discontinuityStarts[s],u=n.discontinuitySequence+s+1,l=o-t.mediaIndex,h=Math.abs(l);if(!this.discontinuities[u]||this.discontinuities[u].accuracy>h){var d=void 0;l<0?d=a.start-tl(n,t.mediaIndex,o):d=a.end+tl(n,t.mediaIndex+1,o),this.discontinuities[u]={time:d,accuracy:h}}}}}]),r}(W.EventTarget),Yw=new Mm("./decrypter-worker.worker.js",function(e,r){var i=this;(function(){function t(p){return p.subarray(0,p.byteLength-p[p.byteLength-1])}var n=function(S,E){if(!(S instanceof E))throw new TypeError("Cannot call a class as a function")},a=function(){function p(S,E){for(var w=0;w<E.length;w++){var x=E[w];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(S,x.key,x)}}return function(S,E,w){return E&&p(S.prototype,E),w&&p(S,w),S}}(),s=function(S,E){if(typeof E!="function"&&E!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof E);S.prototype=Object.create(E&&E.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),E&&(Object.setPrototypeOf?Object.setPrototypeOf(S,E):S.__proto__=E)},o=function(S,E){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return E&&(typeof E=="object"||typeof E=="function")?E:S},u=function(){var S=[[[],[],[],[],[]],[[],[],[],[],[]]],E=S[0],w=S[1],x=E[4],T=w[4],A=void 0,k=void 0,C=void 0,R=[],P=[],I=void 0,D=void 0,L=void 0,O=void 0,N=void 0,B=void 0;for(A=0;A<256;A++)P[(R[A]=A<<1^(A>>7)*283)^A]=A;for(k=C=0;!x[k];k^=I||1,C=P[C]||1)for(O=C^C<<1^C<<2^C<<3^C<<4,O=O>>8^O&255^99,x[k]=O,T[O]=k,L=R[D=R[I=R[k]]],B=L*16843009^D*65537^I*257^k*16843008,N=R[O]*257^O*16843008,A=0;A<4;A++)E[A][k]=N=N<<24^N>>>8,w[A][O]=B=B<<24^B>>>8;for(A=0;A<5;A++)E[A]=E[A].slice(0),w[A]=w[A].slice(0);return S},l=null,h=function(){function p(S){n(this,p),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,w=void 0,x=void 0,T=void 0,A=void 0,k=this._tables[0][4],C=this._tables[1],R=S.length,P=1;if(R!==4&&R!==6&&R!==8)throw new Error("Invalid aes key size");for(T=S.slice(0),A=[],this._key=[T,A],E=R;E<4*R+28;E++)x=T[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^P<<24,P=P<<1^(P>>7)*283)),T[E]=T[E-R]^x;for(w=0;E;w++,E--)x=T[w&3?E:E-4],E<=4||w<4?A[w]=x:A[w]=C[0][k[x>>>24]]^C[1][k[x>>16&255]]^C[2][k[x>>8&255]]^C[3][k[x&255]]}return p.prototype.decrypt=function(E,w,x,T,A,k){var C=this._key[1],R=E^C[0],P=T^C[1],I=x^C[2],D=w^C[3],L=void 0,O=void 0,N=void 0,B=C.length/4-2,H=void 0,J=4,ie=this._tables[1],Q=ie[0],ne=ie[1],ue=ie[2],Te=ie[3],Me=ie[4];for(H=0;H<B;H++)L=Q[R>>>24]^ne[P>>16&255]^ue[I>>8&255]^Te[D&255]^C[J],O=Q[P>>>24]^ne[I>>16&255]^ue[D>>8&255]^Te[R&255]^C[J+1],N=Q[I>>>24]^ne[D>>16&255]^ue[R>>8&255]^Te[P&255]^C[J+2],D=Q[D>>>24]^ne[R>>16&255]^ue[P>>8&255]^Te[I&255]^C[J+3],J+=4,R=L,P=O,I=N;for(H=0;H<4;H++)A[(3&-H)+k]=Me[R>>>24]<<24^Me[P>>16&255]<<16^Me[I>>8&255]<<8^Me[D&255]^C[J++],L=R,R=P,P=I,I=D,D=L},p}(),d=function(){function p(){n(this,p),this.listeners={}}return p.prototype.on=function(E,w){this.listeners[E]||(this.listeners[E]=[]),this.listeners[E].push(w)},p.prototype.off=function(E,w){if(!this.listeners[E])return!1;var x=this.listeners[E].indexOf(w);return this.listeners[E].splice(x,1),x>-1},p.prototype.trigger=function(E){var w=this.listeners[E];if(!!w)if(arguments.length===2)for(var x=w.length,T=0;T<x;++T)w[T].call(this,arguments[1]);else for(var A=Array.prototype.slice.call(arguments,1),k=w.length,C=0;C<k;++C)w[C].apply(this,A)},p.prototype.dispose=function(){this.listeners={}},p.prototype.pipe=function(E){this.on("data",function(w){E.push(w)})},p}(),g=function(p){s(S,p);function S(){n(this,S);var E=o(this,p.call(this,d));return E.jobs=[],E.delay=1,E.timeout_=null,E}return S.prototype.processJob_=function(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null},S.prototype.push=function(w){this.jobs.push(w),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))},S}(d),c=function(S){return S<<24|(S&65280)<<8|(S&16711680)>>8|S>>>24},b=function(S,E,w){var x=new Int32Array(S.buffer,S.byteOffset,S.byteLength>>2),T=new h(Array.prototype.slice.call(E)),A=new Uint8Array(S.byteLength),k=new Int32Array(A.buffer),C=void 0,R=void 0,P=void 0,I=void 0,D=void 0,L=void 0,O=void 0,N=void 0,B=void 0;for(C=w[0],R=w[1],P=w[2],I=w[3],B=0;B<x.length;B+=4)D=c(x[B]),L=c(x[B+1]),O=c(x[B+2]),N=c(x[B+3]),T.decrypt(D,L,O,N,k,B),k[B]=c(k[B]^C),k[B+1]=c(k[B+1]^R),k[B+2]=c(k[B+2]^P),k[B+3]=c(k[B+3]^I),C=D,R=L,P=O,I=N;return A},f=function(){function p(S,E,w,x){n(this,p);var T=p.STEP,A=new Int32Array(S.buffer),k=new Uint8Array(S.byteLength),C=0;for(this.asyncStream_=new g,this.asyncStream_.push(this.decryptChunk_(A.subarray(C,C+T),E,w,k)),C=T;C<A.length;C+=T)w=new Uint32Array([c(A[C-4]),c(A[C-3]),c(A[C-2]),c(A[C-1])]),this.asyncStream_.push(this.decryptChunk_(A.subarray(C,C+T),E,w,k));this.asyncStream_.push(function(){x(null,t(k))})}return p.prototype.decryptChunk_=function(E,w,x,T){return function(){var A=b(E,w,x);T.set(A,E.byteOffset)}},a(p,null,[{key:"STEP",get:function(){return 32e3}}]),p}(),m=function(S){var E={};return Object.keys(S).forEach(function(w){var x=S[w];ArrayBuffer.isView(x)?E[w]={bytes:x.buffer,byteOffset:x.byteOffset,byteLength:x.byteLength}:E[w]=x}),E},y=function(S){S.onmessage=function(E){var w=E.data,x=new Uint8Array(w.encrypted.bytes,w.encrypted.byteOffset,w.encrypted.byteLength),T=new Uint32Array(w.key.bytes,w.key.byteOffset,w.key.byteLength/4),A=new Uint32Array(w.iv.bytes,w.iv.byteOffset,w.iv.byteLength/4);new f(x,T,A,function(k,C){S.postMessage(m({source:w.source,decrypted:C}),[C.buffer])})}},v=new y(i);return v})()}),Kw=function(r){var i=r.default?"main":"alternative";return r.characteristics&&r.characteristics.indexOf("public.accessibility.describes-video")>=0&&(i="main-desc"),i},Bu=function(r,i){r.abort(),r.pause(),i&&i.activePlaylistLoader&&(i.activePlaylistLoader.pause(),i.activePlaylistLoader=null)},Ff=function(r,i){i.activePlaylistLoader=r,r.load()},$w=function(r,i){return function(){var t=i.segmentLoaders,n=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),u=s.activeGroup(o),l=s.activePlaylistLoader;if(Bu(n,s),!!u){if(!u.playlistLoader){l&&a.resetEverything();return}n.resyncLoader(),Ff(u.playlistLoader,s)}}},zw=function(r,i){return function(){var t=i.segmentLoaders,n=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),u=s.activeGroup(o),l=s.activePlaylistLoader;if(Bu(n,s),!!u){if(!u.playlistLoader){a.resetEverything();return}if(l===u.playlistLoader){Ff(u.playlistLoader,s);return}n.track&&n.track(o),n.resetEverything(),Ff(u.playlistLoader,s)}}},ju={AUDIO:function(r,i){return function(){var t=i.segmentLoaders[r],n=i.mediaTypes[r],a=i.blacklistCurrentPlaylist;Bu(t,n);var s=n.activeTrack(),o=n.activeGroup(),u=(o.filter(function(d){return d.default})[0]||o[0]).id,l=n.tracks[u];if(s===l){a({message:"Problem encountered loading the default audio track."});return}W.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(var h in n.tracks)n.tracks[h].enabled=n.tracks[h]===l;n.onTrackChanged()}},SUBTITLES:function(r,i){return function(){var t=i.segmentLoaders[r],n=i.mediaTypes[r];W.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),Bu(t,n);var a=n.activeTrack();a&&(a.mode="disabled"),n.onTrackChanged()}}},ry={AUDIO:function(r,i,t){if(!!i){var n=t.tech,a=t.requestOptions,s=t.segmentLoaders[r];i.on("loadedmetadata",function(){var o=i.media();s.playlist(o,a),(!n.paused()||o.endList&&n.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),n.paused()||s.load()}),i.on("error",ju[r](r,t))}},SUBTITLES:function(r,i,t){var n=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()),(!n.paused()||u.endList&&n.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),n.paused()||s.load()}),i.on("error",ju[r](r,t))}},Xw={AUDIO:function(r,i){var t=i.hls,n=i.sourceType,a=i.segmentLoaders[r],s=i.requestOptions,o=i.master.mediaGroups,u=i.mediaTypes[r],l=u.groups,h=u.tracks,d=i.masterPlaylistLoader;(!o[r]||Object.keys(o[r]).length===0)&&(o[r]={main:{default:{default:!0}}});for(var g in o[r]){l[g]||(l[g]=[]);for(var c in o[r][g]){var b=o[r][g][c],f=void 0;if(b.resolvedUri?f=new Iu(b.resolvedUri,t,s):b.playlists&&n==="dash"?f=new Of(b.playlists[0],t,s,d):f=null,b=W.mergeOptions({id:c,playlistLoader:f},b),ry[r](r,b.playlistLoader,i),l[g].push(b),typeof h[c]>"u"){var m=new W.AudioTrack({id:c,kind:Kw(b),enabled:!1,language:b.language,default:b.default,label:c});h[c]=m}}}a.on("error",ju[r](r,i))},SUBTITLES:function(r,i){var t=i.tech,n=i.hls,a=i.sourceType,s=i.segmentLoaders[r],o=i.requestOptions,u=i.master.mediaGroups,l=i.mediaTypes[r],h=l.groups,d=l.tracks,g=i.masterPlaylistLoader;for(var c in u[r]){h[c]||(h[c]=[]);for(var b in u[r][c])if(!u[r][c][b].forced){var f=u[r][c][b],m=void 0;if(a==="hls"?m=new Iu(f.resolvedUri,n,o):a==="dash"&&(m=new Of(f.playlists[0],n,o,g)),f=W.mergeOptions({id:b,playlistLoader:m},f),ry[r](r,f.playlistLoader,i),h[c].push(f),typeof d[b]>"u"){var y=t.addRemoteTextTrack({id:b,kind:"subtitles",default:f.default&&f.autoselect,language:f.language,label:b},!1).track;d[b]=y}}}s.on("error",ju[r](r,i))},"CLOSED-CAPTIONS":function(r,i){var t=i.tech,n=i.master.mediaGroups,a=i.mediaTypes[r],s=a.groups,o=a.tracks;for(var u in n[r]){s[u]||(s[u]=[]);for(var l in n[r][u]){var h=n[r][u][l];if(!!h.instreamId.match(/CC\d/)&&(s[u].push(W.mergeOptions({id:l},h)),typeof o[l]>"u")){var d=t.addRemoteTextTrack({id:h.instreamId,kind:"captions",default:h.default&&h.autoselect,language:h.language,label:l},!1).track;o[l]=d}}}}},Jw=function(r,i){return function(t){var n=i.masterPlaylistLoader,a=i.mediaTypes[r].groups,s=n.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}},Qw={AUDIO:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var n in t)if(t[n].enabled)return t[n];return null}},SUBTITLES:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var n in t)if(t[n].mode==="showing")return t[n];return null}}},Zw=function(r){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(h){Xw[h](h,r)});var i=r.mediaTypes,t=r.masterPlaylistLoader,n=r.tech,a=r.hls;["AUDIO","SUBTITLES"].forEach(function(h){i[h].activeGroup=Jw(h,r),i[h].activeTrack=Qw[h](h,r),i[h].onGroupChanged=$w(h,r),i[h].onTrackChanged=zw(h,r)});var s=i.AUDIO.activeGroup(),o=(s.filter(function(h){return h.default})[0]||s[0]).id;i.AUDIO.tracks[o].enabled=!0,i.AUDIO.onTrackChanged(),t.on("mediachange",function(){["AUDIO","SUBTITLES"].forEach(function(h){return i[h].onGroupChanged()})});var u=function(){i.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"hls-audio-change"})};n.audioTracks().addEventListener("change",u),n.remoteTextTracks().addEventListener("change",i.SUBTITLES.onTrackChanged),a.on("dispose",function(){n.audioTracks().removeEventListener("change",u),n.remoteTextTracks().removeEventListener("change",i.SUBTITLES.onTrackChanged)}),n.clearTracks("audio");for(var l in i.AUDIO.tracks)n.audioTracks().addTrack(i.AUDIO.tracks[l])},eA=function(){var r={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(i){r[i]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Ys,activeTrack:Ys,onGroupChanged:Ys,onTrackChanged:Ys}}),r},tA=60*2,aa=void 0,rA=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],iA=function(r){return this.audioSegmentLoader_[r]+this.mainSegmentLoader_[r]},nA=function(e){yn(r,e);function r(i){Si(this,r);var t=zi(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),n=i.url,a=i.handleManifestRedirects,s=i.withCredentials,o=i.tech,u=i.bandwidth,l=i.externHls,h=i.useCueTags,d=i.blacklistDuration,g=i.enableLowInitialPlaylist,c=i.sourceType,b=i.seekTo,f=i.cacheEncryptionKeys;if(!n)throw new Error("A non-empty playlist URL is required");aa=l,t.withCredentials=s,t.tech_=o,t.hls_=o.hls,t.seekTo_=b,t.sourceType_=c,t.useCueTags_=h,t.blacklistDuration=d,t.enableLowInitialPlaylist=g,t.useCueTags_&&(t.cueTagsTrack_=t.tech_.addTextTrack("metadata","ad-cues"),t.cueTagsTrack_.inBandMetadataTrackDispatchType=""),t.requestOptions_={withCredentials:s,handleManifestRedirects:a,timeout:null},t.mediaTypes_=eA(),t.mediaSource=new W.MediaSource,t.mediaSource.addEventListener("sourceopen",t.handleSourceOpen_.bind(t)),t.seekable_=W.createTimeRanges(),t.hasPlayed_=function(){return!1},t.syncController_=new qw(i),t.segmentMetadataTrack_=o.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,t.decrypter_=new Yw,t.inbandTextTracks_={};var m={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:f};return t.masterPlaylistLoader_=t.sourceType_==="dash"?new Of(n,t.hls_,t.requestOptions_):new Iu(n,t.hls_,t.requestOptions_),t.setupMasterPlaylistLoaderListeners_(),t.mainSegmentLoader_=new Nf(W.mergeOptions(m,{segmentMetadataTrack:t.segmentMetadataTrack_,loaderType:"main"}),i),t.audioSegmentLoader_=new Nf(W.mergeOptions(m,{loaderType:"audio"}),i),t.subtitleSegmentLoader_=new Hw(W.mergeOptions(m,{loaderType:"vtt"}),i),t.setupSegmentLoaderListeners_(),rA.forEach(function(y){t[y+"_"]=iA.bind(t,y)}),t.logger_=nl("MPC"),t.masterPlaylistLoader_.load(),t}return Ii(r,[{key:"setupMasterPlaylistLoaderListeners_",value:function(){var t=this;this.masterPlaylistLoader_.on("loadedmetadata",function(){var n=t.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;wf(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,n.endList&&t.tech_.preload()!=="none"&&(t.mainSegmentLoader_.playlist(n,t.requestOptions_),t.mainSegmentLoader_.load()),Zw({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(),n);try{t.setupSourceBuffers_()}catch(s){return W.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 n=t.masterPlaylistLoader_.media();if(!n){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_(n),t.mainSegmentLoader_.playlist(n,t.requestOptions_),t.updateDuration(),t.tech_.paused()||(t.mainSegmentLoader_.load(),t.audioSegmentLoader_&&t.audioSegmentLoader_.load()),!n.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 n=t.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;wf(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,t.mainSegmentLoader_.playlist(n,t.requestOptions_),t.mainSegmentLoader_.load(),t.tech_.trigger({type:"mediachange",bubbles:!0})}),this.masterPlaylistLoader_.on("playlistunchanged",function(){var n=t.masterPlaylistLoader_.media(),a=t.stuckAtPlaylistEnd_(n);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,n){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 h=a.AUDIO[u][l];h.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"}),aa.Playlist.isAes(n)&&this.tech_.trigger({type:"usage",name:"hls-aes"}),aa.Playlist.isFmp4(n)&&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 n=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()<ui.MAX_BUFFER_LOW_WATER_LINE||n.attributes.BANDWIDTH<a.attributes.BANDWIDTH||o>=u)&&t.masterPlaylistLoader_.media(n),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."},tA)}),this.mainSegmentLoader_.on("reseteverything",function(){t.tech_.trigger("hls-reset")}),this.mainSegmentLoader_.on("segmenttimemapping",function(n){t.tech_.trigger({type:"hls-segment-time-mapping",mapping:n.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,n=this.selectPlaylist();n!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(n),this.mainSegmentLoader_.resetEverything(function(){W.browser.IE_VERSION||W.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,n=this.masterPlaylistLoader_.media();if(!n||this.tech_.paused()||this.hasPlayed_())return!1;if(!n.endList){var a=this.seekable();if(!a.length)return!1;if(W.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(n){return W.log.warn("Failed to create Source Buffers",n),this.mediaSource.endOfStream("decode")}if(this.tech_.autoplay()){var t=this.tech_.play();typeof t<"u"&&typeof t.then=="function"&&t.then(null,function(n){})}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(n){W.log.warn("Failed to call media source endOfStream",n)}}}},{key:"stuckAtPlaylistEnd_",value:function(t){var n=this.seekable();if(!n.length)return!1;var a=this.syncController_.getExpiredTime(t,this.mediaSource.duration);if(a===null)return!1;var s=aa.Playlist.playlistEnd(t,a),o=this.tech_.currentTime(),u=this.tech_.buffered();if(!u.length)return s-o<=_n;var l=u.end(u.length-1);return l-o<=_n&&s-l<=_n}},{key:"blacklistCurrentPlaylist",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments[1],a=void 0,s=void 0;if(a=t.playlist||this.masterPlaylistLoader_.media(),n=n||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(Mu).length===1,u=this.masterPlaylistLoader_.master.playlists;return u.length===1?(W.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&&(W.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()+n*1e3,this.tech_.trigger("blacklistplaylist"),this.tech_.trigger({type:"usage",name:"hls-rendition-blacklisted"}),s=this.selectPlaylist(),W.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 n=Pm(this.tech_.buffered(),t);if(!(this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media())||!this.masterPlaylistLoader_.media().segments)return 0;if(n&&n.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:aa.Playlist.duration(this.masterPlaylistLoader_.media()):0}},{key:"seekable",value:function(){return this.seekable_}},{key:"onSyncInfoUpdate_",value:function(){var t=void 0,n=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=aa.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||(n=aa.Playlist.seekable(a,s),n.length===0))))){var o=void 0,u=void 0;this.seekable_&&this.seekable_.length&&(o=this.seekable_.end(0),u=this.seekable_.start(0)),n?n.start(0)>t.end(0)||t.start(0)>n.end(0)?this.seekable_=t:this.seekable_=W.createTimeRanges([[n.start(0)>t.start(0)?n.start(0):t.start(0),n.end(0)<t.end(0)?n.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 ["+kf(this.seekable_)+"]"),this.tech_.trigger("seekablechanged"))}}}}},{key:"updateDuration",value:function(){var t=this,n=this.mediaSource.duration,a=aa.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){W.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))),n!==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(n){var a=t.mediaTypes_[n].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(),n=void 0;if(!(!t||this.mediaSource.readyState!=="open")){if(n=lw(this.masterPlaylistLoader_.master,t),n.length<1)return this.error="No compatible SourceBuffer configuration for the variant stream:"+t.resolvedUri,this.mediaSource.endOfStream("decode");this.configureLoaderMimeTypes_(n),this.excludeIncompatibleVariants_(t)}}},{key:"configureLoaderMimeTypes_",value:function(t){var n=t.length>1&&t[0].indexOf(",")===-1&&t[0]!==t[1]?new W.EventTarget:null;this.mainSegmentLoader_.mimeType(t[0],n),t[1]&&this.audioSegmentLoader_.mimeType(t[1],n)}},{key:"excludeUnsupportedVariants_",value:function(){this.master().playlists.forEach(function(t){t.attributes.CODECS&&ge.MediaSource&&ge.MediaSource.isTypeSupported&&!ge.MediaSource.isTypeSupported('video/mp4; codecs="'+nw(t.attributes.CODECS)+'"')&&(t.excludeUntil=1/0)})}},{key:"excludeIncompatibleVariants_",value:function(t){var n=2,a=null,s=void 0;t.attributes.CODECS&&(s=rl(t.attributes.CODECS),a=s.videoCodec,n=s.codecCount),this.master().playlists.forEach(function(o){var u={codecCount:2,videoCodec:null};o.attributes.CODECS&&(u=rl(o.attributes.CODECS)),u.codecCount!==n&&(o.excludeUntil=1/0),u.videoCodec!==a&&(o.excludeUntil=1/0)})}},{key:"updateAdCues_",value:function(t){var n=0,a=this.seekable();a.length&&(n=a.start(0)),Vw(t,this.cueTagsTrack_,n)}},{key:"goalBufferLength",value:function(){var t=this.tech_.currentTime(),n=ui.GOAL_BUFFER_LENGTH,a=ui.GOAL_BUFFER_LENGTH_RATE,s=Math.max(n,ui.MAX_GOAL_BUFFER_LENGTH);return Math.min(n+t*a,s)}},{key:"bufferLowWaterLine",value:function(){var t=this.tech_.currentTime(),n=ui.BUFFER_LOW_WATER_LINE,a=ui.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(n,ui.MAX_BUFFER_LOW_WATER_LINE);return Math.min(n+t*a,s)}}]),r}(W.EventTarget),aA=function(r,i,t){return function(n){var a=r.master.playlists[i],s=xf(a),o=Mu(a);return typeof n>"u"?o:(n?delete a.disabled:a.disabled=!0,n!==o&&!s&&(t(),n?r.trigger("renditionenabled"):r.trigger("renditiondisabled")),n)}},sA=function e(r,i,t){Si(this,e);var n=r.masterPlaylistController_,a=r.options_.smoothQualityChange,s=a?"smooth":"fast",o=n[s+"QualityChange_"].bind(n);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=aA(r.playlists,i.uri,o)},oA=function(r){var i=r.playlists;r.representations=function(){return i.master.playlists.filter(function(t){return!xf(t)}).map(function(t,n){return new sA(r,t,t.uri)})}},iy=["seeking","seeked","pause","playing","error"],lA=function(){function e(r){var i=this;Si(this,e),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_=nl("PlaybackWatcher"),this.logger_("initialize");var t=function(){return i.monitorCurrentTime_()},n=function(){return i.techWaiting_()},a=function(){return i.cancelTimer_()},s=function(){return i.fixesBadSeeks_()};this.tech_.on("seekablechanged",s),this.tech_.on("waiting",n),this.tech_.on(iy,a),this.tech_.on("canplay",t),this.dispose=function(){i.logger_("dispose"),i.tech_.off("seekablechanged",s),i.tech_.off("waiting",n),i.tech_.off(iy,a),i.tech_.off("canplay",t),i.checkCurrentTimeTimeout_&&ge.clearTimeout(i.checkCurrentTimeTimeout_),i.cancelTimer_()}}return Ii(e,[{key:"monitorCurrentTime_",value:function(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&ge.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=ge.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+_n>=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(),n=this.tech_.currentTime(),a=this.afterSeekableWindow_(t,n,this.media(),this.allowSeeksWithinUnsafeLiveWindow),s=void 0;if(a){var o=t.end(t.length-1);s=o}if(this.beforeSeekableWindow_(t,n)){var u=t.start(0);s=u+_n}return typeof s<"u"?(this.logger_("Trying to seek outside of seekable at time "+n+" with "+("seekable range "+kf(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(),n=Pm(t,i);if(n.length&&i+3<=n.end(0)){this.cancelTimer_(),this.seekTo(i),this.logger_("Stopped at "+i+" while inside a buffered region "+("["+n.start(0)+" -> "+n.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 n=i.end(i.length-1);return this.logger_("Fell out of live window at time "+t+". Seeking to "+("live point (seekable end) "+n)),this.cancelTimer_(),this.seekTo(n),this.tech_.trigger({type:"usage",name:"hls-live-resync"}),!0}var a=this.tech_.buffered(),s=Lm(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,n){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!i.length)return!1;var s=i.end(i.length-1)+_n,o=!n.endList;return o&&a&&(s=i.end(i.length-1)+n.targetDuration*3),t>s}},{key:"beforeSeekableWindow_",value:function(i,t){return!!(i.length&&i.start(0)>0&&t<i.start(0)-_n)}},{key:"videoUnderflow_",value:function(i,t,n){if(i.length===0){var a=this.gapFromVideoUnderflow_(t,n);if(a)return this.logger_("Encountered a gap in video from "+a.start+" to "+a.end+". "+("Seeking to current time "+n)),!0}return!1}},{key:"skipTheGap_",value:function(i){var t=this.tech_.buffered(),n=this.tech_.currentTime(),a=Lm(t,n);this.cancelTimer_(),!(a.length===0||n!==i)&&(this.logger_("skipTheGap_:","currentTime:",n,"scheduled currentTime:",i,"nextRange start:",a.start(0)),this.seekTo(a.start(0)+Fu),this.tech_.trigger({type:"usage",name:"hls-gap-skip"}))}},{key:"gapFromVideoUnderflow_",value:function(i,t){for(var n=zx(i),a=0;a<n.length;a++){var s=n.start(a),o=n.end(a);if(t-s<4&&t-s>2)return{start:s,end:o}}return null}}]),e}(),uA={errorInterval:30,getSource:function(r){var i=this.tech({IWillNotUseThisInPlugins:!0}),t=i.currentSource_;return r(t)}},dA=function e(r,i){var t=0,n=0,a=W.mergeOptions(uA,i);r.ready(function(){r.trigger({type:"usage",name:"hls-error-reload-initialized"})});var s=function(){n&&r.currentTime(n)},o=function(g){g!=null&&(n=r.duration()!==1/0&&r.currentTime()||0,r.one("loadedmetadata",s),r.src(g),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"){W.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),a.getSource.call(r,o)},l=function d(){r.off("loadedmetadata",s),r.off("error",u),r.off("dispose",d)},h=function(g){l(),e(r,g)};r.on("error",u),r.on("dispose",l),r.reloadSourceOnError=h},ny=function(r){dA(this,r)},cA="1.10.6";W.use("*",function(e){return{setSource:function(i,t){t(null,i)},setCurrentTime:function(i){return e.vhs&&e.currentSource().src===e.vhs.source_.src&&e.vhs.setCurrentTime(i),i},play:function(){e.vhs&&e.currentSource().src===e.vhs.source_.src&&e.vhs.setCurrentTime(e.tech_.currentTime())}}});var ri={PlaylistLoader:Iu,Playlist:ti,Decrypter:WS,AsyncStream:kg,decrypt:Cg,utils:jx,STANDARD_PLAYLIST_SELECTOR:Pw,INITIAL_PLAYLIST_SELECTOR:Ow,comparePlaylistBandwidth:Mf,comparePlaylistResolution:Rw,xhr:wm()};["GOAL_BUFFER_LENGTH","MAX_GOAL_BUFFER_LENGTH","GOAL_BUFFER_LENGTH_RATE","BUFFER_LOW_WATER_LINE","MAX_BUFFER_LOW_WATER_LINE","BUFFER_LOW_WATER_LINE_RATE","BANDWIDTH_VARIANCE"].forEach(function(e){Object.defineProperty(ri,e,{get:function(){return W.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),ui[e]},set:function(i){if(W.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),typeof i!="number"||i<0){W.log.warn("value of Hls."+e+" must be greater than or equal to 0");return}ui[e]=i}})});var ay="videojs-vhs",sy=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},oy=function(r,i){for(var t=i.media(),n=-1,a=0;a<r.length;a++)if(r[a].id===t.uri){n=a;break}r.selectedIndex_=n,r.trigger({selectedIndex:n,type:"change"})},fA=function(r,i){i.representations().forEach(function(t){r.addQualityLevel(t)}),oy(r,i.playlists)};ri.canPlaySource=function(){return W.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var hA=function(r,i,t){if(!r)return r;var n={};for(var a in r)n[a]={audioContentType:'audio/mp4; codecs="'+t.attributes.CODECS+'"',videoContentType:'video/mp4; codecs="'+i.attributes.CODECS+'"'},i.contentProtection&&i.contentProtection[a]&&i.contentProtection[a].pssh&&(n[a].pssh=i.contentProtection[a].pssh),typeof r[a]=="string"&&(n[a].url=r[a]);return W.mergeOptions(r,n)},pA=function(r){if(r.options_.sourceType==="dash"){var i=W.players[r.tech_.options_.playerId];if(i.eme){var t=hA(r.source_.keySystems,r.playlists.media(),r.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader.media());t&&(i.currentSource().keySystems=t,i.eme.initializeMediaKeys&&i.eme.initializeMediaKeys())}}},ly=function(){if(!window.localStorage)return null;var r=window.localStorage.getItem(ay);if(!r)return null;try{return JSON.parse(r)}catch{return null}},gA=function(r){if(!window.localStorage)return!1;var i=ly();i=i?W.mergeOptions(i,r):r;try{window.localStorage.setItem(ay,JSON.stringify(i))}catch{return!1}return i};ri.supportsNativeHls=function(){var e=$e.createElement("video");if(!W.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(e.canPlayType(i))})}(),ri.supportsNativeDash=function(){return W.getTech("Html5").isSupported()?/maybe|probably/i.test($e.createElement("video").canPlayType("application/dash+xml")):!1}(),ri.supportsTypeNatively=function(e){return e==="hls"?ri.supportsNativeHls:e==="dash"?ri.supportsNativeDash:!1},ri.isSupported=function(){return W.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var vA=W.getComponent("Component"),uy=function(e){yn(r,e);function r(i,t,n){Si(this,r);var a=zi(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t,n.hls));if(t.options_&&t.options_.playerId){var s=W(t.options_.playerId);s.hasOwnProperty("hls")||Object.defineProperty(s,"hls",{get:function(){return W.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($e,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],function(o){var u=$e.fullscreenElement||$e.webkitFullscreenElement||$e.mozFullScreenElement||$e.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 Ii(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 n=ly();n&&n.bandwidth&&(this.options_.bandwidth=n.bandwidth,this.tech_.trigger({type:"usage",name:"hls-bandwidth-from-local-storage"})),n&&n.throughput&&(this.options_.throughput=n.throughput,this.tech_.trigger({type:"usage",name:"hls-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=ui.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===ui.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,n){var a=this;!t||(this.setOptions_(),this.options_.url=this.source_.src,this.options_.tech=this.tech_,this.options_.externHls=ri,this.options_.sourceType=sy(n),this.options_.seekTo=function(s){a.tech_.setCurrentTime(s),a.setCurrentTime(s)},this.masterPlaylistController_=new nA(this.options_),this.playbackWatcher_=new lA(W.mergeOptions(this.options_,{seekable:function(){return a.seekable()},media:function(){return a.masterPlaylistController_.media()}})),this.masterPlaylistController_.on("error",function(){var s=W.players[a.tech_.options_.playerId];s.error(a.masterPlaylistController_.error)}),this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):ri.STANDARD_PLAYLIST_SELECTOR.bind(this),this.masterPlaylistController_.selectInitialPlaylist=ri.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(){W.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 Om(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 Om(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&&gA({bandwidth:a.bandwidth,throughput:Math.round(a.throughput)})}),this.masterPlaylistController_.on("selectedinitialmedia",function(){oA(a),pA(a)}),this.on(this.masterPlaylistController_,"progress",function(){this.tech_.trigger("progress")}),this.tech_.ready(function(){return a.setupQualityLevels_()}),this.tech_.el()&&this.tech_.src(W.URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var t=this,n=W.players[this.tech_.options_.playerId];n&&n.qualityLevels&&(this.qualityLevels_=n.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",function(){fA(t.qualityLevels_,t)}),this.playlists.on("mediachange",function(){oy(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,vx(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"dispose",this).call(this)}},{key:"convertToProgramTime",value:function(t,n){return Kx({playlist:this.masterPlaylistController_.media(),time:t,callback:n})}},{key:"seekToProgramTime",value:function(t,n){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:2;return $x({programTime:t,playlist:this.masterPlaylistController_.media(),retryCount:s,pauseAfterSeek:a,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:n})}}]),r}(vA),Uf={name:"videojs-http-streaming",VERSION:cA,canHandleSource:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=W.mergeOptions(W.options,i);return Uf.canPlayType(r.type,t)},handleSource:function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=W.mergeOptions(W.options,t);return i.hls=new uy(r,i,n),i.hls.xhr=wm(),i.hls.src(r.src,r.type),i.hls},canPlayType:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=W.mergeOptions(W.options,i),n=t.hls.overrideNative,a=sy(r),s=a&&(!ri.supportsTypeNatively(a)||n);return s?"maybe":""}};(typeof W.MediaSource>"u"||typeof W.URL>"u")&&(W.MediaSource=il,W.URL=qm),il.supportsNativeMediaSources()&&W.getTech("Html5").registerSourceHandler(Uf,0),W.HlsHandler=uy,W.HlsSourceHandler=Uf,W.Hls=ri,W.use||W.registerComponent("Hls",ri),W.options.hls=W.options.hls||{},W.registerPlugin?W.registerPlugin("reloadSourceOnError",ny):W.plugin("reloadSourceOnError",ny);const mA=Object.freeze(Object.defineProperty({__proto__:null,default:W},Symbol.toStringTag,{value:"Module"})),dy={name:"stream-engine-player",version:"0.0.45",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:{"@fastpix/videojs-monitor":"^1.0.3",angular:"~1.4.8","angular-cookies":"~1.4.8","hls.js":"^0.12.4","include-media":"^2.0.0","infront-logger":"1.1.11",localforage:"^1.10.0","m3u8-parser":"^7.1.0","mixpanel-browser":"2.52.0",moment:"^2.30.1","video.js":"7.6.6","videojs-contrib-ads":"6.6.5","videojs-ima":"1.7.5","videojs-mux":"4.19.0","videojs-sprite-thumbnails":"^1.2.1","videojs-youtube":"^2.6.1"},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"]}};var Nr=[];for(let e=0;e<256;++e)Nr.push((e+256).toString(16).slice(1));function yA(e,r=0){return(Nr[e[r+0]]+Nr[e[r+1]]+Nr[e[r+2]]+Nr[e[r+3]]+"-"+Nr[e[r+4]]+Nr[e[r+5]]+"-"+Nr[e[r+6]]+Nr[e[r+7]]+"-"+Nr[e[r+8]]+Nr[e[r+9]]+"-"+Nr[e[r+10]]+Nr[e[r+11]]+Nr[e[r+12]]+Nr[e[r+13]]+Nr[e[r+14]]+Nr[e[r+15]]).toLowerCase()}var Bf,_A=new Uint8Array(16);function bA(){if(!Bf){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Bf=crypto.getRandomValues.bind(crypto)}return Bf(_A)}var TA=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cy={randomUUID:TA};function SA(e,r,i){var n,a,s;if(cy.randomUUID&&!r&&!e)return cy.randomUUID();e=e||{};let t=(s=(a=e.random)!=null?a:(n=e.rng)==null?void 0:n.call(e))!=null?s:bA();if(t.length<16)throw new Error("Random bytes length must be >= 16");if(t[6]=t[6]&15|64,t[8]=t[8]&63|128,r){if(i=i||0,i<0||i+16>r.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);for(let o=0;o<16;++o)r[i+o]=t[o];return r}return yA(t)}var EA=SA,fy="000000",hy=function(){let e=Math.random().toString(36).replace("0.","").slice(0,6);return fy.slice(e.length)+e},Ks=function(){return EA()},xA=function(){return(fy+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},jf=e=>{if(!e)return["localhost","localhost"];try{let r=new URL(e).hostname,i=r.split("."),t=i.length>=2?i.slice(-2).join("."):r;return[r,t]}catch{}return["localhost","localhost"]},Xi=e=>jf(e)[0],Hf=e=>jf(e)[1],wA=e=>{var r,i;if(e&&e.nodeName)return(r=e.uniqueId)!=null?r:e.uniqueId=hy();try{let t=document.querySelector(e);return t&&!t.uniqueId&&(t.uniqueId=e),(i=t==null?void 0:t.uniqueId)!=null?i:e}catch{}return e},AA=e=>{var t;let r=null;e&&e.nodeName!==void 0?(r=e,e=wA(r)):r=document.querySelector(e);let i=((t=r==null?void 0:r.nodeName)==null?void 0:t.toLowerCase())||"";return[r,e,i]},py=e=>{var i,t;let r=null;if(e&&e.nodeName!==void 0)return(i=e.elementId)!=null||(e.elementId=xA()),e.elementId;try{r=document.querySelector(e)}catch{}return r&&!r.elementId&&(r.elementId=e),(t=r==null?void 0:r.elementId)!=null?t:e};function kA(...e){return e.reduce((r,i)=>{for(let[t,n]of Object.entries(i))n!==void 0&&(r[t]=n);return r},{})}function Hu(e,r,i=1){var t;e[r]=((t=e[r])!=null?t:0)+i}function CA(e,r){let{beaconDomain:i}=r;return`https://${e!=null?e:"collector"}.${i!=null?i:"metrix.ws"}`}function gy(){var r,i;let e=(i=(r=navigator.doNotTrack)!=null?r:window.doNotTrack)!=null?i:navigator.msDoNotTrack;return e==="1"||e==="yes"}var RA=class{constructor(){this.events={}}on(e,r){this.events[e]||(this.events[e]=[]),this.events[e].push(r)}off(e,r){this.events[e]&&(this.events[e]=this.events[e].filter(i=>i!==r))}emit(e,r){this.events[e]&&this.events[e].forEach(i=>{i(r)})}},sa={now:function(){return typeof Date.now=="function"?Date.now():new Date().getTime()}},Gu={isPerformanceAvailable:function(){let e=window.performance;return e&&e.timing!==void 0},getDomContentLoadedEnd:function(){var r;let e=(r=window.performance)==null?void 0:r.timing;return e?e.domContentLoadedEventEnd:null},getNavigationStartTime:function(){var r;let e=(r=window.performance)==null?void 0:r.timing;return e?e.navigationStart:null}};function DA(e){if(!e)return{};let r=Gu.getNavigationStartTime(),{loading:i,trequest:t,tfirst:n,tload:a,total:s}=e,o=i?i.start:t,u=i?i.first:n,l=i?i.end:a;return{bytesLoaded:s,requestStart:Math.round(r+o),responseStart:Math.round(r+u),responseEnd:Math.round(r+l)}}var PA=()=>{var r,i,t;let e=navigator;return(t=(i=(r=e==null?void 0:e.connection)!=null?r:e==null?void 0:e.mozConnection)!=null?i:e==null?void 0:e.webkitConnection)==null?void 0:t.type},LA=()=>{switch(PA()){case"cellular":return"cellular";case"ethernet":return"wired";case"wifi":return"wifi";case void 0:break;default:return"other"}},OA=["x-cdn","content-type","content-length","last-modified","server","x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"];function IA(e){let r={},i=new Set(OA.map(t=>t.toLowerCase()));return!e||typeof e!="string"?{}:(e.trim().split(/[\r\n]+/).forEach(t=>{let[n,...a]=t.split(": "),s=a.join(": ");n&&i.has(n.toLowerCase())&&(r[n]=s)}),r)}var Vu=function(e){if(e&&typeof e.getAllResponseHeaders=="function")return IA(e.getAllResponseHeaders())},MA={convertSecToMs:function(e){return Math.floor(1e3*e)},isolateHostAndDomainName:jf,fetchDomain:Hf,fetchHost:Xi,generateIdToken:hy,buildUUID:Ks,now:sa.now};function NA(e){let r=(window==null?void 0:window.URL)||(window==null?void 0:window.webkitURL),i=window==null?void 0:window.Blob,t=window==null?void 0:window.Worker;if(!r||!i||!t||!e)return null;let n=new i([e]);return new t(r.createObjectURL(n))}var FA=`
81
+ `.split("").map(function(e){return e.charCodeAt(0)})),Hw=function(e){yn(r,e);function r(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Si(this,r);var n=zi(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,i,t));return n.mediaSource_=null,n.subtitlesTrack_=null,n}return Ii(r,[{key:"buffered_",value:function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return W.createTimeRanges();var t=this.subtitlesTrack_.cues,n=t[0].startTime,a=t[t.length-1].startTime;return W.createTimeRanges([[n,a]])}},{key:"initSegment",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=Nu(t),s=this.initSegments_[a];if(n&&!s&&t.bytes){var o=ey.byteLength+t.bytes.byteLength,u=new Uint8Array(o);u.set(t.bytes),u.set(ey,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,n){Gs(t,n,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 n=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(n=this.skipEmptySegments_(n),!!n){if(this.syncController_.timestampOffsetForTimeline(n.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_(n)}}},{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 n=this.pendingSegment_,a=n.segment;if(typeof ge.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_(n)}catch(u){return this.error({message:u.message}),this.state="READY",this.pause(),this.trigger("error")}if(this.updateTimeMapping_(n,this.syncController_.timelines[n.timeline],this.playlist_),n.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}n.byteLength=n.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,n.cues.length&&this.remove(n.cues[0].endTime,n.cues[n.cues.length-1].endTime),n.cues.forEach(function(u){t.subtitlesTrack_.addCue(u)}),this.handleUpdateEnd_()}},{key:"parseVTTCues_",value:function(t){var n=void 0,a=!1;typeof ge.TextDecoder=="function"?n=new ge.TextDecoder("utf8"):(n=ge.WebVTT.StringDecoder(),a=!0);var s=new ge.WebVTT.Parser(ge,ge.vttjs,n);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){W.log.warn("Error encountered when parsing cues: "+l.message)},t.segment.map){var o=t.segment.map.bytes;a&&(o=Zm(o)),s.parse(o)}var u=t.bytes;a&&(u=Zm(u)),s.parse(u),s.flush()}},{key:"updateTimeMapping_",value:function(t,n,a){var s=t.segment;if(!!n){if(!t.cues.length){s.empty=!0;return}var o=t.timestampmap,u=o.MPEGTS/9e4-o.LOCAL+n.mapping;if(t.cues.forEach(function(d){d.startTime+=u,d.endTime+=u}),!a.syncInfo){var l=t.cues[0].startTime,h=t.cues[t.cues.length-1].startTime;a.syncInfo={mediaSequence:a.mediaSequence+t.mediaIndex,time:Math.min(l,h-s.duration)}}}}}]),r}(Nf),Gw=function(r,i){for(var t=r.cues,n=0;n<t.length;n++){var a=t[n];if(i>=a.adStartTime&&i<=a.adEndTime)return a}return null},Vw=function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!!r.segments)for(var n=t,a=void 0,s=0;s<r.segments.length;s++){var o=r.segments[s];if(a||(a=Gw(i,n+o.duration/2)),a){if("cueIn"in o){a.endTime=n,a.adEndTime=n,n+=o.duration,a=null;continue}if(n<a.endTime){n+=o.duration;continue}a.endTime+=o.duration}else if("cueOut"in o&&(a=new ge.VTTCue(n,n+o.duration,o.cueOut),a.adStartTime=n,a.adEndTime=n+parseFloat(o.cueOut),i.addCue(a)),"cueOutCont"in o){var u=void 0,l=void 0,h=o.cueOutCont.split("/").map(parseFloat),d=mx(h,2);u=d[0],l=d[1],a=new ge.VTTCue(n,n+o.duration,""),a.adStartTime=n-u,a.adEndTime=a.adStartTime+l,i.addCue(a)}n+=o.duration}},Ww=FS.inspect,ty=[{name:"VOD",run:function(r,i,t,n,a){if(t!==1/0){var s={time:0,segmentIndex:0};return s}return null}},{name:"ProgramDateTime",run:function(r,i,t,n,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 h=s[l];if(h.dateTimeObject){var d=h.dateTimeObject.getTime()/1e3,g=d+r.datetimeToDisplayTime,c=Math.abs(a-g);if(u!==null&&(c===0||u<c))break;u=c,o={time:g,segmentIndex:l}}}return o}},{name:"Segment",run:function(r,i,t,n,a){var s=i.segments||[],o=null,u=null;a=a||0;for(var l=0;l<s.length;l++){var h=s[l];if(h.timeline===n&&typeof h.start<"u"){var d=Math.abs(a-h.start);if(u!==null&&u<d)break;(!o||u===null||u>=d)&&(u=d,o={time:h.start,segmentIndex:l})}}return o}},{name:"Discontinuity",run:function(r,i,t,n,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],h=i.discontinuitySequence+u+1,d=r.discontinuities[h];if(d){var g=Math.abs(a-d.time);if(o!==null&&o<g)break;(!s||o===null||o>=g)&&(o=g,s={time:d.time,segmentIndex:l})}}return s}},{name:"Playlist",run:function(r,i,t,n,a){if(i.syncInfo){var s={time:i.syncInfo.time,segmentIndex:i.syncInfo.mediaSequence-i.mediaSequence};return s}return null}}],qw=function(e){yn(r,e);function r(){Si(this,r);var i=zi(this,(r.__proto__||Object.getPrototypeOf(r)).call(this));return i.inspectCache_=void 0,i.timelines=[],i.discontinuities=[],i.datetimeToDisplayTime=null,i.logger_=nl("SyncController"),i}return Ii(r,[{key:"getSyncPoint",value:function(t,n,a,s){var o=this.runStrategies_(t,n,a,s);return o.length?this.selectSyncPoint_(o,{key:"time",value:s}):null}},{key:"getExpiredTime",value:function(t,n){if(!t||!t.segments)return null;var a=this.runStrategies_(t,n,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+tl(t,s.segmentIndex,0))}},{key:"runStrategies_",value:function(t,n,a,s){for(var o=[],u=0;u<ty.length;u++){var l=ty[u],h=l.run(this,t,n,a,s);h&&(h.strategy=l.name,o.push({strategy:l.name,syncPoint:h}))}return o}},{key:"selectSyncPoint_",value:function(t,n){for(var a=t[0].syncPoint,s=Math.abs(t[0].syncPoint[n.key]-n.value),o=t[0].strategy,u=1;u<t.length;u++){var l=Math.abs(t[u].syncPoint[n.key]-n.value);l<s&&(s=l,a=t[u].syncPoint,o=t[u].strategy)}return this.logger_("syncPoint for ["+n.key+": "+n.value+"] chosen with strategy"+(" ["+o+"]: [time:"+a.time+",")+(" segmentIndex:"+a.segmentIndex+"]")),a}},{key:"saveExpiredSegmentInfo",value:function(t,n){for(var a=n.mediaSequence-t.mediaSequence,s=a-1;s>=0;s--){var o=t.segments[s];if(o&&typeof o.start<"u"){n.syncInfo={mediaSequence:t.mediaSequence+s,time:o.start},this.logger_("playlist refresh sync: [time:"+n.syncInfo.time+","+(" mediaSequence: "+n.syncInfo.mediaSequence+"]")),this.trigger("syncinfoupdate");break}}}},{key:"setDateTimeMapping",value:function(t){if(!this.datetimeToDisplayTime&&t.segments&&t.segments.length&&t.segments[0].dateTimeObject){var n=t.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-n}}},{key:"reset",value:function(){this.inspectCache_=void 0}},{key:"probeSegmentInfo",value:function(t){var n=t.segment,a=t.playlist,s=void 0;return n.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:n.start})),s}},{key:"probeMp4Segment_",value:function(t){var n=t.segment,a=As.timescale(n.map.bytes),s=As.startTime(a,t.bytes);return t.timestampOffset!==null&&(t.timestampOffset-=s),{start:s,end:s+n.duration}}},{key:"probeTsSegment_",value:function(t){var n=Ww(t.bytes,this.inspectCache_),a=void 0,s=void 0,o=void 0;if(!n)return null;n.video&&n.video.length===2?(this.inspectCache_=n.video[1].dts,a=n.video[0].dtsTime,s=n.video[1].dtsTime,o=n.video):n.audio&&n.audio.length===2&&(this.inspectCache_=n.audio[1].dts,a=n.audio[0].dtsTime,s=n.audio[1].dtsTime,o=n.audio);var u={segmentTimestampInfo:o,start:a,end:s,containsVideo:n.video&&n.video.length===2,containsAudio:n.audio&&n.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,n){var a=t.segment,s=this.timelines[t.timeline];if(t.timestampOffset!==null)s={time:t.startOfSegment,mapping:t.startOfSegment-n.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=n.end+s.mapping;else if(s)a.start=n.start+s.mapping,a.end=n.end+s.mapping;else return!1;return!0}},{key:"saveDiscontinuitySyncInfo_",value:function(t){var n=t.playlist,a=t.segment;if(a.discontinuity)this.discontinuities[a.timeline]={time:a.start,accuracy:0};else if(n.discontinuityStarts&&n.discontinuityStarts.length)for(var s=0;s<n.discontinuityStarts.length;s++){var o=n.discontinuityStarts[s],u=n.discontinuitySequence+s+1,l=o-t.mediaIndex,h=Math.abs(l);if(!this.discontinuities[u]||this.discontinuities[u].accuracy>h){var d=void 0;l<0?d=a.start-tl(n,t.mediaIndex,o):d=a.end+tl(n,t.mediaIndex+1,o),this.discontinuities[u]={time:d,accuracy:h}}}}}]),r}(W.EventTarget),Yw=new Mm("./decrypter-worker.worker.js",function(e,r){var i=this;(function(){function t(p){return p.subarray(0,p.byteLength-p[p.byteLength-1])}var n=function(S,E){if(!(S instanceof E))throw new TypeError("Cannot call a class as a function")},a=function(){function p(S,E){for(var w=0;w<E.length;w++){var x=E[w];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(S,x.key,x)}}return function(S,E,w){return E&&p(S.prototype,E),w&&p(S,w),S}}(),s=function(S,E){if(typeof E!="function"&&E!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof E);S.prototype=Object.create(E&&E.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),E&&(Object.setPrototypeOf?Object.setPrototypeOf(S,E):S.__proto__=E)},o=function(S,E){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return E&&(typeof E=="object"||typeof E=="function")?E:S},u=function(){var S=[[[],[],[],[],[]],[[],[],[],[],[]]],E=S[0],w=S[1],x=E[4],T=w[4],A=void 0,k=void 0,C=void 0,R=[],P=[],I=void 0,D=void 0,L=void 0,O=void 0,N=void 0,B=void 0;for(A=0;A<256;A++)P[(R[A]=A<<1^(A>>7)*283)^A]=A;for(k=C=0;!x[k];k^=I||1,C=P[C]||1)for(O=C^C<<1^C<<2^C<<3^C<<4,O=O>>8^O&255^99,x[k]=O,T[O]=k,L=R[D=R[I=R[k]]],B=L*16843009^D*65537^I*257^k*16843008,N=R[O]*257^O*16843008,A=0;A<4;A++)E[A][k]=N=N<<24^N>>>8,w[A][O]=B=B<<24^B>>>8;for(A=0;A<5;A++)E[A]=E[A].slice(0),w[A]=w[A].slice(0);return S},l=null,h=function(){function p(S){n(this,p),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,w=void 0,x=void 0,T=void 0,A=void 0,k=this._tables[0][4],C=this._tables[1],R=S.length,P=1;if(R!==4&&R!==6&&R!==8)throw new Error("Invalid aes key size");for(T=S.slice(0),A=[],this._key=[T,A],E=R;E<4*R+28;E++)x=T[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^P<<24,P=P<<1^(P>>7)*283)),T[E]=T[E-R]^x;for(w=0;E;w++,E--)x=T[w&3?E:E-4],E<=4||w<4?A[w]=x:A[w]=C[0][k[x>>>24]]^C[1][k[x>>16&255]]^C[2][k[x>>8&255]]^C[3][k[x&255]]}return p.prototype.decrypt=function(E,w,x,T,A,k){var C=this._key[1],R=E^C[0],P=T^C[1],I=x^C[2],D=w^C[3],L=void 0,O=void 0,N=void 0,B=C.length/4-2,H=void 0,J=4,ie=this._tables[1],Q=ie[0],ne=ie[1],ue=ie[2],Te=ie[3],Me=ie[4];for(H=0;H<B;H++)L=Q[R>>>24]^ne[P>>16&255]^ue[I>>8&255]^Te[D&255]^C[J],O=Q[P>>>24]^ne[I>>16&255]^ue[D>>8&255]^Te[R&255]^C[J+1],N=Q[I>>>24]^ne[D>>16&255]^ue[R>>8&255]^Te[P&255]^C[J+2],D=Q[D>>>24]^ne[R>>16&255]^ue[P>>8&255]^Te[I&255]^C[J+3],J+=4,R=L,P=O,I=N;for(H=0;H<4;H++)A[(3&-H)+k]=Me[R>>>24]<<24^Me[P>>16&255]<<16^Me[I>>8&255]<<8^Me[D&255]^C[J++],L=R,R=P,P=I,I=D,D=L},p}(),d=function(){function p(){n(this,p),this.listeners={}}return p.prototype.on=function(E,w){this.listeners[E]||(this.listeners[E]=[]),this.listeners[E].push(w)},p.prototype.off=function(E,w){if(!this.listeners[E])return!1;var x=this.listeners[E].indexOf(w);return this.listeners[E].splice(x,1),x>-1},p.prototype.trigger=function(E){var w=this.listeners[E];if(!!w)if(arguments.length===2)for(var x=w.length,T=0;T<x;++T)w[T].call(this,arguments[1]);else for(var A=Array.prototype.slice.call(arguments,1),k=w.length,C=0;C<k;++C)w[C].apply(this,A)},p.prototype.dispose=function(){this.listeners={}},p.prototype.pipe=function(E){this.on("data",function(w){E.push(w)})},p}(),g=function(p){s(S,p);function S(){n(this,S);var E=o(this,p.call(this,d));return E.jobs=[],E.delay=1,E.timeout_=null,E}return S.prototype.processJob_=function(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null},S.prototype.push=function(w){this.jobs.push(w),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))},S}(d),c=function(S){return S<<24|(S&65280)<<8|(S&16711680)>>8|S>>>24},b=function(S,E,w){var x=new Int32Array(S.buffer,S.byteOffset,S.byteLength>>2),T=new h(Array.prototype.slice.call(E)),A=new Uint8Array(S.byteLength),k=new Int32Array(A.buffer),C=void 0,R=void 0,P=void 0,I=void 0,D=void 0,L=void 0,O=void 0,N=void 0,B=void 0;for(C=w[0],R=w[1],P=w[2],I=w[3],B=0;B<x.length;B+=4)D=c(x[B]),L=c(x[B+1]),O=c(x[B+2]),N=c(x[B+3]),T.decrypt(D,L,O,N,k,B),k[B]=c(k[B]^C),k[B+1]=c(k[B+1]^R),k[B+2]=c(k[B+2]^P),k[B+3]=c(k[B+3]^I),C=D,R=L,P=O,I=N;return A},f=function(){function p(S,E,w,x){n(this,p);var T=p.STEP,A=new Int32Array(S.buffer),k=new Uint8Array(S.byteLength),C=0;for(this.asyncStream_=new g,this.asyncStream_.push(this.decryptChunk_(A.subarray(C,C+T),E,w,k)),C=T;C<A.length;C+=T)w=new Uint32Array([c(A[C-4]),c(A[C-3]),c(A[C-2]),c(A[C-1])]),this.asyncStream_.push(this.decryptChunk_(A.subarray(C,C+T),E,w,k));this.asyncStream_.push(function(){x(null,t(k))})}return p.prototype.decryptChunk_=function(E,w,x,T){return function(){var A=b(E,w,x);T.set(A,E.byteOffset)}},a(p,null,[{key:"STEP",get:function(){return 32e3}}]),p}(),m=function(S){var E={};return Object.keys(S).forEach(function(w){var x=S[w];ArrayBuffer.isView(x)?E[w]={bytes:x.buffer,byteOffset:x.byteOffset,byteLength:x.byteLength}:E[w]=x}),E},y=function(S){S.onmessage=function(E){var w=E.data,x=new Uint8Array(w.encrypted.bytes,w.encrypted.byteOffset,w.encrypted.byteLength),T=new Uint32Array(w.key.bytes,w.key.byteOffset,w.key.byteLength/4),A=new Uint32Array(w.iv.bytes,w.iv.byteOffset,w.iv.byteLength/4);new f(x,T,A,function(k,C){S.postMessage(m({source:w.source,decrypted:C}),[C.buffer])})}},v=new y(i);return v})()}),Kw=function(r){var i=r.default?"main":"alternative";return r.characteristics&&r.characteristics.indexOf("public.accessibility.describes-video")>=0&&(i="main-desc"),i},Bu=function(r,i){r.abort(),r.pause(),i&&i.activePlaylistLoader&&(i.activePlaylistLoader.pause(),i.activePlaylistLoader=null)},Ff=function(r,i){i.activePlaylistLoader=r,r.load()},$w=function(r,i){return function(){var t=i.segmentLoaders,n=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),u=s.activeGroup(o),l=s.activePlaylistLoader;if(Bu(n,s),!!u){if(!u.playlistLoader){l&&a.resetEverything();return}n.resyncLoader(),Ff(u.playlistLoader,s)}}},zw=function(r,i){return function(){var t=i.segmentLoaders,n=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),u=s.activeGroup(o),l=s.activePlaylistLoader;if(Bu(n,s),!!u){if(!u.playlistLoader){a.resetEverything();return}if(l===u.playlistLoader){Ff(u.playlistLoader,s);return}n.track&&n.track(o),n.resetEverything(),Ff(u.playlistLoader,s)}}},ju={AUDIO:function(r,i){return function(){var t=i.segmentLoaders[r],n=i.mediaTypes[r],a=i.blacklistCurrentPlaylist;Bu(t,n);var s=n.activeTrack(),o=n.activeGroup(),u=(o.filter(function(d){return d.default})[0]||o[0]).id,l=n.tracks[u];if(s===l){a({message:"Problem encountered loading the default audio track."});return}W.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(var h in n.tracks)n.tracks[h].enabled=n.tracks[h]===l;n.onTrackChanged()}},SUBTITLES:function(r,i){return function(){var t=i.segmentLoaders[r],n=i.mediaTypes[r];W.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),Bu(t,n);var a=n.activeTrack();a&&(a.mode="disabled"),n.onTrackChanged()}}},ry={AUDIO:function(r,i,t){if(!!i){var n=t.tech,a=t.requestOptions,s=t.segmentLoaders[r];i.on("loadedmetadata",function(){var o=i.media();s.playlist(o,a),(!n.paused()||o.endList&&n.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),n.paused()||s.load()}),i.on("error",ju[r](r,t))}},SUBTITLES:function(r,i,t){var n=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()),(!n.paused()||u.endList&&n.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),n.paused()||s.load()}),i.on("error",ju[r](r,t))}},Xw={AUDIO:function(r,i){var t=i.hls,n=i.sourceType,a=i.segmentLoaders[r],s=i.requestOptions,o=i.master.mediaGroups,u=i.mediaTypes[r],l=u.groups,h=u.tracks,d=i.masterPlaylistLoader;(!o[r]||Object.keys(o[r]).length===0)&&(o[r]={main:{default:{default:!0}}});for(var g in o[r]){l[g]||(l[g]=[]);for(var c in o[r][g]){var b=o[r][g][c],f=void 0;if(b.resolvedUri?f=new Iu(b.resolvedUri,t,s):b.playlists&&n==="dash"?f=new Of(b.playlists[0],t,s,d):f=null,b=W.mergeOptions({id:c,playlistLoader:f},b),ry[r](r,b.playlistLoader,i),l[g].push(b),typeof h[c]>"u"){var m=new W.AudioTrack({id:c,kind:Kw(b),enabled:!1,language:b.language,default:b.default,label:c});h[c]=m}}}a.on("error",ju[r](r,i))},SUBTITLES:function(r,i){var t=i.tech,n=i.hls,a=i.sourceType,s=i.segmentLoaders[r],o=i.requestOptions,u=i.master.mediaGroups,l=i.mediaTypes[r],h=l.groups,d=l.tracks,g=i.masterPlaylistLoader;for(var c in u[r]){h[c]||(h[c]=[]);for(var b in u[r][c])if(!u[r][c][b].forced){var f=u[r][c][b],m=void 0;if(a==="hls"?m=new Iu(f.resolvedUri,n,o):a==="dash"&&(m=new Of(f.playlists[0],n,o,g)),f=W.mergeOptions({id:b,playlistLoader:m},f),ry[r](r,f.playlistLoader,i),h[c].push(f),typeof d[b]>"u"){var y=t.addRemoteTextTrack({id:b,kind:"subtitles",default:f.default&&f.autoselect,language:f.language,label:b},!1).track;d[b]=y}}}s.on("error",ju[r](r,i))},"CLOSED-CAPTIONS":function(r,i){var t=i.tech,n=i.master.mediaGroups,a=i.mediaTypes[r],s=a.groups,o=a.tracks;for(var u in n[r]){s[u]||(s[u]=[]);for(var l in n[r][u]){var h=n[r][u][l];if(!!h.instreamId.match(/CC\d/)&&(s[u].push(W.mergeOptions({id:l},h)),typeof o[l]>"u")){var d=t.addRemoteTextTrack({id:h.instreamId,kind:"captions",default:h.default&&h.autoselect,language:h.language,label:l},!1).track;o[l]=d}}}}},Jw=function(r,i){return function(t){var n=i.masterPlaylistLoader,a=i.mediaTypes[r].groups,s=n.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}},Qw={AUDIO:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var n in t)if(t[n].enabled)return t[n];return null}},SUBTITLES:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var n in t)if(t[n].mode==="showing")return t[n];return null}}},Zw=function(r){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(h){Xw[h](h,r)});var i=r.mediaTypes,t=r.masterPlaylistLoader,n=r.tech,a=r.hls;["AUDIO","SUBTITLES"].forEach(function(h){i[h].activeGroup=Jw(h,r),i[h].activeTrack=Qw[h](h,r),i[h].onGroupChanged=$w(h,r),i[h].onTrackChanged=zw(h,r)});var s=i.AUDIO.activeGroup(),o=(s.filter(function(h){return h.default})[0]||s[0]).id;i.AUDIO.tracks[o].enabled=!0,i.AUDIO.onTrackChanged(),t.on("mediachange",function(){["AUDIO","SUBTITLES"].forEach(function(h){return i[h].onGroupChanged()})});var u=function(){i.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"hls-audio-change"})};n.audioTracks().addEventListener("change",u),n.remoteTextTracks().addEventListener("change",i.SUBTITLES.onTrackChanged),a.on("dispose",function(){n.audioTracks().removeEventListener("change",u),n.remoteTextTracks().removeEventListener("change",i.SUBTITLES.onTrackChanged)}),n.clearTracks("audio");for(var l in i.AUDIO.tracks)n.audioTracks().addTrack(i.AUDIO.tracks[l])},eA=function(){var r={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(i){r[i]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Ys,activeTrack:Ys,onGroupChanged:Ys,onTrackChanged:Ys}}),r},tA=60*2,aa=void 0,rA=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],iA=function(r){return this.audioSegmentLoader_[r]+this.mainSegmentLoader_[r]},nA=function(e){yn(r,e);function r(i){Si(this,r);var t=zi(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),n=i.url,a=i.handleManifestRedirects,s=i.withCredentials,o=i.tech,u=i.bandwidth,l=i.externHls,h=i.useCueTags,d=i.blacklistDuration,g=i.enableLowInitialPlaylist,c=i.sourceType,b=i.seekTo,f=i.cacheEncryptionKeys;if(!n)throw new Error("A non-empty playlist URL is required");aa=l,t.withCredentials=s,t.tech_=o,t.hls_=o.hls,t.seekTo_=b,t.sourceType_=c,t.useCueTags_=h,t.blacklistDuration=d,t.enableLowInitialPlaylist=g,t.useCueTags_&&(t.cueTagsTrack_=t.tech_.addTextTrack("metadata","ad-cues"),t.cueTagsTrack_.inBandMetadataTrackDispatchType=""),t.requestOptions_={withCredentials:s,handleManifestRedirects:a,timeout:null},t.mediaTypes_=eA(),t.mediaSource=new W.MediaSource,t.mediaSource.addEventListener("sourceopen",t.handleSourceOpen_.bind(t)),t.seekable_=W.createTimeRanges(),t.hasPlayed_=function(){return!1},t.syncController_=new qw(i),t.segmentMetadataTrack_=o.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,t.decrypter_=new Yw,t.inbandTextTracks_={};var m={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:f};return t.masterPlaylistLoader_=t.sourceType_==="dash"?new Of(n,t.hls_,t.requestOptions_):new Iu(n,t.hls_,t.requestOptions_),t.setupMasterPlaylistLoaderListeners_(),t.mainSegmentLoader_=new Nf(W.mergeOptions(m,{segmentMetadataTrack:t.segmentMetadataTrack_,loaderType:"main"}),i),t.audioSegmentLoader_=new Nf(W.mergeOptions(m,{loaderType:"audio"}),i),t.subtitleSegmentLoader_=new Hw(W.mergeOptions(m,{loaderType:"vtt"}),i),t.setupSegmentLoaderListeners_(),rA.forEach(function(y){t[y+"_"]=iA.bind(t,y)}),t.logger_=nl("MPC"),t.masterPlaylistLoader_.load(),t}return Ii(r,[{key:"setupMasterPlaylistLoaderListeners_",value:function(){var t=this;this.masterPlaylistLoader_.on("loadedmetadata",function(){var n=t.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;wf(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,n.endList&&t.tech_.preload()!=="none"&&(t.mainSegmentLoader_.playlist(n,t.requestOptions_),t.mainSegmentLoader_.load()),Zw({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(),n);try{t.setupSourceBuffers_()}catch(s){return W.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 n=t.masterPlaylistLoader_.media();if(!n){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_(n),t.mainSegmentLoader_.playlist(n,t.requestOptions_),t.updateDuration(),t.tech_.paused()||(t.mainSegmentLoader_.load(),t.audioSegmentLoader_&&t.audioSegmentLoader_.load()),!n.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 n=t.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;wf(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,t.mainSegmentLoader_.playlist(n,t.requestOptions_),t.mainSegmentLoader_.load(),t.tech_.trigger({type:"mediachange",bubbles:!0})}),this.masterPlaylistLoader_.on("playlistunchanged",function(){var n=t.masterPlaylistLoader_.media(),a=t.stuckAtPlaylistEnd_(n);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,n){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 h=a.AUDIO[u][l];h.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"}),aa.Playlist.isAes(n)&&this.tech_.trigger({type:"usage",name:"hls-aes"}),aa.Playlist.isFmp4(n)&&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 n=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()<ui.MAX_BUFFER_LOW_WATER_LINE||n.attributes.BANDWIDTH<a.attributes.BANDWIDTH||o>=u)&&t.masterPlaylistLoader_.media(n),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."},tA)}),this.mainSegmentLoader_.on("reseteverything",function(){t.tech_.trigger("hls-reset")}),this.mainSegmentLoader_.on("segmenttimemapping",function(n){t.tech_.trigger({type:"hls-segment-time-mapping",mapping:n.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,n=this.selectPlaylist();n!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(n),this.mainSegmentLoader_.resetEverything(function(){W.browser.IE_VERSION||W.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,n=this.masterPlaylistLoader_.media();if(!n||this.tech_.paused()||this.hasPlayed_())return!1;if(!n.endList){var a=this.seekable();if(!a.length)return!1;if(W.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(n){return W.log.warn("Failed to create Source Buffers",n),this.mediaSource.endOfStream("decode")}if(this.tech_.autoplay()){var t=this.tech_.play();typeof t<"u"&&typeof t.then=="function"&&t.then(null,function(n){})}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(n){W.log.warn("Failed to call media source endOfStream",n)}}}},{key:"stuckAtPlaylistEnd_",value:function(t){var n=this.seekable();if(!n.length)return!1;var a=this.syncController_.getExpiredTime(t,this.mediaSource.duration);if(a===null)return!1;var s=aa.Playlist.playlistEnd(t,a),o=this.tech_.currentTime(),u=this.tech_.buffered();if(!u.length)return s-o<=_n;var l=u.end(u.length-1);return l-o<=_n&&s-l<=_n}},{key:"blacklistCurrentPlaylist",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments[1],a=void 0,s=void 0;if(a=t.playlist||this.masterPlaylistLoader_.media(),n=n||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(Mu).length===1,u=this.masterPlaylistLoader_.master.playlists;return u.length===1?(W.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&&(W.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()+n*1e3,this.tech_.trigger("blacklistplaylist"),this.tech_.trigger({type:"usage",name:"hls-rendition-blacklisted"}),s=this.selectPlaylist(),W.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 n=Pm(this.tech_.buffered(),t);if(!(this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media())||!this.masterPlaylistLoader_.media().segments)return 0;if(n&&n.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:aa.Playlist.duration(this.masterPlaylistLoader_.media()):0}},{key:"seekable",value:function(){return this.seekable_}},{key:"onSyncInfoUpdate_",value:function(){var t=void 0,n=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=aa.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||(n=aa.Playlist.seekable(a,s),n.length===0))))){var o=void 0,u=void 0;this.seekable_&&this.seekable_.length&&(o=this.seekable_.end(0),u=this.seekable_.start(0)),n?n.start(0)>t.end(0)||t.start(0)>n.end(0)?this.seekable_=t:this.seekable_=W.createTimeRanges([[n.start(0)>t.start(0)?n.start(0):t.start(0),n.end(0)<t.end(0)?n.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 ["+kf(this.seekable_)+"]"),this.tech_.trigger("seekablechanged"))}}}}},{key:"updateDuration",value:function(){var t=this,n=this.mediaSource.duration,a=aa.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){W.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))),n!==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(n){var a=t.mediaTypes_[n].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(),n=void 0;if(!(!t||this.mediaSource.readyState!=="open")){if(n=lw(this.masterPlaylistLoader_.master,t),n.length<1)return this.error="No compatible SourceBuffer configuration for the variant stream:"+t.resolvedUri,this.mediaSource.endOfStream("decode");this.configureLoaderMimeTypes_(n),this.excludeIncompatibleVariants_(t)}}},{key:"configureLoaderMimeTypes_",value:function(t){var n=t.length>1&&t[0].indexOf(",")===-1&&t[0]!==t[1]?new W.EventTarget:null;this.mainSegmentLoader_.mimeType(t[0],n),t[1]&&this.audioSegmentLoader_.mimeType(t[1],n)}},{key:"excludeUnsupportedVariants_",value:function(){this.master().playlists.forEach(function(t){t.attributes.CODECS&&ge.MediaSource&&ge.MediaSource.isTypeSupported&&!ge.MediaSource.isTypeSupported('video/mp4; codecs="'+nw(t.attributes.CODECS)+'"')&&(t.excludeUntil=1/0)})}},{key:"excludeIncompatibleVariants_",value:function(t){var n=2,a=null,s=void 0;t.attributes.CODECS&&(s=rl(t.attributes.CODECS),a=s.videoCodec,n=s.codecCount),this.master().playlists.forEach(function(o){var u={codecCount:2,videoCodec:null};o.attributes.CODECS&&(u=rl(o.attributes.CODECS)),u.codecCount!==n&&(o.excludeUntil=1/0),u.videoCodec!==a&&(o.excludeUntil=1/0)})}},{key:"updateAdCues_",value:function(t){var n=0,a=this.seekable();a.length&&(n=a.start(0)),Vw(t,this.cueTagsTrack_,n)}},{key:"goalBufferLength",value:function(){var t=this.tech_.currentTime(),n=ui.GOAL_BUFFER_LENGTH,a=ui.GOAL_BUFFER_LENGTH_RATE,s=Math.max(n,ui.MAX_GOAL_BUFFER_LENGTH);return Math.min(n+t*a,s)}},{key:"bufferLowWaterLine",value:function(){var t=this.tech_.currentTime(),n=ui.BUFFER_LOW_WATER_LINE,a=ui.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(n,ui.MAX_BUFFER_LOW_WATER_LINE);return Math.min(n+t*a,s)}}]),r}(W.EventTarget),aA=function(r,i,t){return function(n){var a=r.master.playlists[i],s=xf(a),o=Mu(a);return typeof n>"u"?o:(n?delete a.disabled:a.disabled=!0,n!==o&&!s&&(t(),n?r.trigger("renditionenabled"):r.trigger("renditiondisabled")),n)}},sA=function e(r,i,t){Si(this,e);var n=r.masterPlaylistController_,a=r.options_.smoothQualityChange,s=a?"smooth":"fast",o=n[s+"QualityChange_"].bind(n);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=aA(r.playlists,i.uri,o)},oA=function(r){var i=r.playlists;r.representations=function(){return i.master.playlists.filter(function(t){return!xf(t)}).map(function(t,n){return new sA(r,t,t.uri)})}},iy=["seeking","seeked","pause","playing","error"],lA=function(){function e(r){var i=this;Si(this,e),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_=nl("PlaybackWatcher"),this.logger_("initialize");var t=function(){return i.monitorCurrentTime_()},n=function(){return i.techWaiting_()},a=function(){return i.cancelTimer_()},s=function(){return i.fixesBadSeeks_()};this.tech_.on("seekablechanged",s),this.tech_.on("waiting",n),this.tech_.on(iy,a),this.tech_.on("canplay",t),this.dispose=function(){i.logger_("dispose"),i.tech_.off("seekablechanged",s),i.tech_.off("waiting",n),i.tech_.off(iy,a),i.tech_.off("canplay",t),i.checkCurrentTimeTimeout_&&ge.clearTimeout(i.checkCurrentTimeTimeout_),i.cancelTimer_()}}return Ii(e,[{key:"monitorCurrentTime_",value:function(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&ge.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=ge.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+_n>=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(),n=this.tech_.currentTime(),a=this.afterSeekableWindow_(t,n,this.media(),this.allowSeeksWithinUnsafeLiveWindow),s=void 0;if(a){var o=t.end(t.length-1);s=o}if(this.beforeSeekableWindow_(t,n)){var u=t.start(0);s=u+_n}return typeof s<"u"?(this.logger_("Trying to seek outside of seekable at time "+n+" with "+("seekable range "+kf(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(),n=Pm(t,i);if(n.length&&i+3<=n.end(0)){this.cancelTimer_(),this.seekTo(i),this.logger_("Stopped at "+i+" while inside a buffered region "+("["+n.start(0)+" -> "+n.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 n=i.end(i.length-1);return this.logger_("Fell out of live window at time "+t+". Seeking to "+("live point (seekable end) "+n)),this.cancelTimer_(),this.seekTo(n),this.tech_.trigger({type:"usage",name:"hls-live-resync"}),!0}var a=this.tech_.buffered(),s=Lm(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,n){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!i.length)return!1;var s=i.end(i.length-1)+_n,o=!n.endList;return o&&a&&(s=i.end(i.length-1)+n.targetDuration*3),t>s}},{key:"beforeSeekableWindow_",value:function(i,t){return!!(i.length&&i.start(0)>0&&t<i.start(0)-_n)}},{key:"videoUnderflow_",value:function(i,t,n){if(i.length===0){var a=this.gapFromVideoUnderflow_(t,n);if(a)return this.logger_("Encountered a gap in video from "+a.start+" to "+a.end+". "+("Seeking to current time "+n)),!0}return!1}},{key:"skipTheGap_",value:function(i){var t=this.tech_.buffered(),n=this.tech_.currentTime(),a=Lm(t,n);this.cancelTimer_(),!(a.length===0||n!==i)&&(this.logger_("skipTheGap_:","currentTime:",n,"scheduled currentTime:",i,"nextRange start:",a.start(0)),this.seekTo(a.start(0)+Fu),this.tech_.trigger({type:"usage",name:"hls-gap-skip"}))}},{key:"gapFromVideoUnderflow_",value:function(i,t){for(var n=zx(i),a=0;a<n.length;a++){var s=n.start(a),o=n.end(a);if(t-s<4&&t-s>2)return{start:s,end:o}}return null}}]),e}(),uA={errorInterval:30,getSource:function(r){var i=this.tech({IWillNotUseThisInPlugins:!0}),t=i.currentSource_;return r(t)}},dA=function e(r,i){var t=0,n=0,a=W.mergeOptions(uA,i);r.ready(function(){r.trigger({type:"usage",name:"hls-error-reload-initialized"})});var s=function(){n&&r.currentTime(n)},o=function(g){g!=null&&(n=r.duration()!==1/0&&r.currentTime()||0,r.one("loadedmetadata",s),r.src(g),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"){W.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),a.getSource.call(r,o)},l=function d(){r.off("loadedmetadata",s),r.off("error",u),r.off("dispose",d)},h=function(g){l(),e(r,g)};r.on("error",u),r.on("dispose",l),r.reloadSourceOnError=h},ny=function(r){dA(this,r)},cA="1.10.6";W.use("*",function(e){return{setSource:function(i,t){t(null,i)},setCurrentTime:function(i){return e.vhs&&e.currentSource().src===e.vhs.source_.src&&e.vhs.setCurrentTime(i),i},play:function(){e.vhs&&e.currentSource().src===e.vhs.source_.src&&e.vhs.setCurrentTime(e.tech_.currentTime())}}});var ri={PlaylistLoader:Iu,Playlist:ti,Decrypter:WS,AsyncStream:kg,decrypt:Cg,utils:jx,STANDARD_PLAYLIST_SELECTOR:Pw,INITIAL_PLAYLIST_SELECTOR:Ow,comparePlaylistBandwidth:Mf,comparePlaylistResolution:Rw,xhr:wm()};["GOAL_BUFFER_LENGTH","MAX_GOAL_BUFFER_LENGTH","GOAL_BUFFER_LENGTH_RATE","BUFFER_LOW_WATER_LINE","MAX_BUFFER_LOW_WATER_LINE","BUFFER_LOW_WATER_LINE_RATE","BANDWIDTH_VARIANCE"].forEach(function(e){Object.defineProperty(ri,e,{get:function(){return W.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),ui[e]},set:function(i){if(W.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),typeof i!="number"||i<0){W.log.warn("value of Hls."+e+" must be greater than or equal to 0");return}ui[e]=i}})});var ay="videojs-vhs",sy=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},oy=function(r,i){for(var t=i.media(),n=-1,a=0;a<r.length;a++)if(r[a].id===t.uri){n=a;break}r.selectedIndex_=n,r.trigger({selectedIndex:n,type:"change"})},fA=function(r,i){i.representations().forEach(function(t){r.addQualityLevel(t)}),oy(r,i.playlists)};ri.canPlaySource=function(){return W.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var hA=function(r,i,t){if(!r)return r;var n={};for(var a in r)n[a]={audioContentType:'audio/mp4; codecs="'+t.attributes.CODECS+'"',videoContentType:'video/mp4; codecs="'+i.attributes.CODECS+'"'},i.contentProtection&&i.contentProtection[a]&&i.contentProtection[a].pssh&&(n[a].pssh=i.contentProtection[a].pssh),typeof r[a]=="string"&&(n[a].url=r[a]);return W.mergeOptions(r,n)},pA=function(r){if(r.options_.sourceType==="dash"){var i=W.players[r.tech_.options_.playerId];if(i.eme){var t=hA(r.source_.keySystems,r.playlists.media(),r.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader.media());t&&(i.currentSource().keySystems=t,i.eme.initializeMediaKeys&&i.eme.initializeMediaKeys())}}},ly=function(){if(!window.localStorage)return null;var r=window.localStorage.getItem(ay);if(!r)return null;try{return JSON.parse(r)}catch{return null}},gA=function(r){if(!window.localStorage)return!1;var i=ly();i=i?W.mergeOptions(i,r):r;try{window.localStorage.setItem(ay,JSON.stringify(i))}catch{return!1}return i};ri.supportsNativeHls=function(){var e=$e.createElement("video");if(!W.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(e.canPlayType(i))})}(),ri.supportsNativeDash=function(){return W.getTech("Html5").isSupported()?/maybe|probably/i.test($e.createElement("video").canPlayType("application/dash+xml")):!1}(),ri.supportsTypeNatively=function(e){return e==="hls"?ri.supportsNativeHls:e==="dash"?ri.supportsNativeDash:!1},ri.isSupported=function(){return W.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var vA=W.getComponent("Component"),uy=function(e){yn(r,e);function r(i,t,n){Si(this,r);var a=zi(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t,n.hls));if(t.options_&&t.options_.playerId){var s=W(t.options_.playerId);s.hasOwnProperty("hls")||Object.defineProperty(s,"hls",{get:function(){return W.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($e,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],function(o){var u=$e.fullscreenElement||$e.webkitFullscreenElement||$e.mozFullScreenElement||$e.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 Ii(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 n=ly();n&&n.bandwidth&&(this.options_.bandwidth=n.bandwidth,this.tech_.trigger({type:"usage",name:"hls-bandwidth-from-local-storage"})),n&&n.throughput&&(this.options_.throughput=n.throughput,this.tech_.trigger({type:"usage",name:"hls-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=ui.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===ui.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,n){var a=this;!t||(this.setOptions_(),this.options_.url=this.source_.src,this.options_.tech=this.tech_,this.options_.externHls=ri,this.options_.sourceType=sy(n),this.options_.seekTo=function(s){a.tech_.setCurrentTime(s),a.setCurrentTime(s)},this.masterPlaylistController_=new nA(this.options_),this.playbackWatcher_=new lA(W.mergeOptions(this.options_,{seekable:function(){return a.seekable()},media:function(){return a.masterPlaylistController_.media()}})),this.masterPlaylistController_.on("error",function(){var s=W.players[a.tech_.options_.playerId];s.error(a.masterPlaylistController_.error)}),this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):ri.STANDARD_PLAYLIST_SELECTOR.bind(this),this.masterPlaylistController_.selectInitialPlaylist=ri.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(){W.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 Om(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 Om(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&&gA({bandwidth:a.bandwidth,throughput:Math.round(a.throughput)})}),this.masterPlaylistController_.on("selectedinitialmedia",function(){oA(a),pA(a)}),this.on(this.masterPlaylistController_,"progress",function(){this.tech_.trigger("progress")}),this.tech_.ready(function(){return a.setupQualityLevels_()}),this.tech_.el()&&this.tech_.src(W.URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var t=this,n=W.players[this.tech_.options_.playerId];n&&n.qualityLevels&&(this.qualityLevels_=n.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",function(){fA(t.qualityLevels_,t)}),this.playlists.on("mediachange",function(){oy(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,vx(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"dispose",this).call(this)}},{key:"convertToProgramTime",value:function(t,n){return Kx({playlist:this.masterPlaylistController_.media(),time:t,callback:n})}},{key:"seekToProgramTime",value:function(t,n){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:2;return $x({programTime:t,playlist:this.masterPlaylistController_.media(),retryCount:s,pauseAfterSeek:a,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:n})}}]),r}(vA),Uf={name:"videojs-http-streaming",VERSION:cA,canHandleSource:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=W.mergeOptions(W.options,i);return Uf.canPlayType(r.type,t)},handleSource:function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=W.mergeOptions(W.options,t);return i.hls=new uy(r,i,n),i.hls.xhr=wm(),i.hls.src(r.src,r.type),i.hls},canPlayType:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=W.mergeOptions(W.options,i),n=t.hls.overrideNative,a=sy(r),s=a&&(!ri.supportsTypeNatively(a)||n);return s?"maybe":""}};(typeof W.MediaSource>"u"||typeof W.URL>"u")&&(W.MediaSource=il,W.URL=qm),il.supportsNativeMediaSources()&&W.getTech("Html5").registerSourceHandler(Uf,0),W.HlsHandler=uy,W.HlsSourceHandler=Uf,W.Hls=ri,W.use||W.registerComponent("Hls",ri),W.options.hls=W.options.hls||{},W.registerPlugin?W.registerPlugin("reloadSourceOnError",ny):W.plugin("reloadSourceOnError",ny);const mA=Object.freeze(Object.defineProperty({__proto__:null,default:W},Symbol.toStringTag,{value:"Module"})),dy={name:"stream-engine-player",version:"0.0.46",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:{"@fastpix/videojs-monitor":"^1.0.3",angular:"~1.4.8","angular-cookies":"~1.4.8","hls.js":"^0.12.4","include-media":"^2.0.0","infront-logger":"1.1.11",localforage:"^1.10.0","m3u8-parser":"^7.1.0","mixpanel-browser":"2.52.0",moment:"^2.30.1","video.js":"7.6.6","videojs-contrib-ads":"6.6.5","videojs-ima":"1.7.5","videojs-mux":"4.19.0","videojs-sprite-thumbnails":"^1.2.1","videojs-youtube":"^2.6.1"},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"]}};var Nr=[];for(let e=0;e<256;++e)Nr.push((e+256).toString(16).slice(1));function yA(e,r=0){return(Nr[e[r+0]]+Nr[e[r+1]]+Nr[e[r+2]]+Nr[e[r+3]]+"-"+Nr[e[r+4]]+Nr[e[r+5]]+"-"+Nr[e[r+6]]+Nr[e[r+7]]+"-"+Nr[e[r+8]]+Nr[e[r+9]]+"-"+Nr[e[r+10]]+Nr[e[r+11]]+Nr[e[r+12]]+Nr[e[r+13]]+Nr[e[r+14]]+Nr[e[r+15]]).toLowerCase()}var Bf,_A=new Uint8Array(16);function bA(){if(!Bf){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Bf=crypto.getRandomValues.bind(crypto)}return Bf(_A)}var TA=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cy={randomUUID:TA};function SA(e,r,i){var n,a,s;if(cy.randomUUID&&!r&&!e)return cy.randomUUID();e=e||{};let t=(s=(a=e.random)!=null?a:(n=e.rng)==null?void 0:n.call(e))!=null?s:bA();if(t.length<16)throw new Error("Random bytes length must be >= 16");if(t[6]=t[6]&15|64,t[8]=t[8]&63|128,r){if(i=i||0,i<0||i+16>r.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);for(let o=0;o<16;++o)r[i+o]=t[o];return r}return yA(t)}var EA=SA,fy="000000",hy=function(){let e=Math.random().toString(36).replace("0.","").slice(0,6);return fy.slice(e.length)+e},Ks=function(){return EA()},xA=function(){return(fy+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},jf=e=>{if(!e)return["localhost","localhost"];try{let r=new URL(e).hostname,i=r.split("."),t=i.length>=2?i.slice(-2).join("."):r;return[r,t]}catch{}return["localhost","localhost"]},Xi=e=>jf(e)[0],Hf=e=>jf(e)[1],wA=e=>{var r,i;if(e&&e.nodeName)return(r=e.uniqueId)!=null?r:e.uniqueId=hy();try{let t=document.querySelector(e);return t&&!t.uniqueId&&(t.uniqueId=e),(i=t==null?void 0:t.uniqueId)!=null?i:e}catch{}return e},AA=e=>{var t;let r=null;e&&e.nodeName!==void 0?(r=e,e=wA(r)):r=document.querySelector(e);let i=((t=r==null?void 0:r.nodeName)==null?void 0:t.toLowerCase())||"";return[r,e,i]},py=e=>{var i,t;let r=null;if(e&&e.nodeName!==void 0)return(i=e.elementId)!=null||(e.elementId=xA()),e.elementId;try{r=document.querySelector(e)}catch{}return r&&!r.elementId&&(r.elementId=e),(t=r==null?void 0:r.elementId)!=null?t:e};function kA(...e){return e.reduce((r,i)=>{for(let[t,n]of Object.entries(i))n!==void 0&&(r[t]=n);return r},{})}function Hu(e,r,i=1){var t;e[r]=((t=e[r])!=null?t:0)+i}function CA(e,r){let{beaconDomain:i}=r;return`https://${e!=null?e:"collector"}.${i!=null?i:"metrix.ws"}`}function gy(){var r,i;let e=(i=(r=navigator.doNotTrack)!=null?r:window.doNotTrack)!=null?i:navigator.msDoNotTrack;return e==="1"||e==="yes"}var RA=class{constructor(){this.events={}}on(e,r){this.events[e]||(this.events[e]=[]),this.events[e].push(r)}off(e,r){this.events[e]&&(this.events[e]=this.events[e].filter(i=>i!==r))}emit(e,r){this.events[e]&&this.events[e].forEach(i=>{i(r)})}},sa={now:function(){return typeof Date.now=="function"?Date.now():new Date().getTime()}},Gu={isPerformanceAvailable:function(){let e=window.performance;return e&&e.timing!==void 0},getDomContentLoadedEnd:function(){var r;let e=(r=window.performance)==null?void 0:r.timing;return e?e.domContentLoadedEventEnd:null},getNavigationStartTime:function(){var r;let e=(r=window.performance)==null?void 0:r.timing;return e?e.navigationStart:null}};function DA(e){if(!e)return{};let r=Gu.getNavigationStartTime(),{loading:i,trequest:t,tfirst:n,tload:a,total:s}=e,o=i?i.start:t,u=i?i.first:n,l=i?i.end:a;return{bytesLoaded:s,requestStart:Math.round(r+o),responseStart:Math.round(r+u),responseEnd:Math.round(r+l)}}var PA=()=>{var r,i,t;let e=navigator;return(t=(i=(r=e==null?void 0:e.connection)!=null?r:e==null?void 0:e.mozConnection)!=null?i:e==null?void 0:e.webkitConnection)==null?void 0:t.type},LA=()=>{switch(PA()){case"cellular":return"cellular";case"ethernet":return"wired";case"wifi":return"wifi";case void 0:break;default:return"other"}},OA=["x-cdn","content-type","content-length","last-modified","server","x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"];function IA(e){let r={},i=new Set(OA.map(t=>t.toLowerCase()));return!e||typeof e!="string"?{}:(e.trim().split(/[\r\n]+/).forEach(t=>{let[n,...a]=t.split(": "),s=a.join(": ");n&&i.has(n.toLowerCase())&&(r[n]=s)}),r)}var Vu=function(e){if(e&&typeof e.getAllResponseHeaders=="function")return IA(e.getAllResponseHeaders())},MA={convertSecToMs:function(e){return Math.floor(1e3*e)},isolateHostAndDomainName:jf,fetchDomain:Hf,fetchHost:Xi,generateIdToken:hy,buildUUID:Ks,now:sa.now};function NA(e){let r=(window==null?void 0:window.URL)||(window==null?void 0:window.webkitURL),i=window==null?void 0:window.Blob,t=window==null?void 0:window.Worker;if(!r||!i||!t||!e)return null;let n=new i([e]);return new t(r.createObjectURL(n))}var FA=`
82
82
  let pulseInterval = null;
83
83
  let throbInterval = null
84
84