stream-engine-player 0.0.41 → 0.0.42

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.
@@ -85,7 +85,7 @@ See https://github.com/videojs/video.js/issues/2617 for more info.
85
85
  `;return n},hD=function(t){var i=t.bytes;return $y(i)},pD=function(t){var i="",r=void 0;for(r=0;r<t.length;r++)i+=dD(t,r)+" ";return i},gD=Object.freeze({createTransferableMessage:Yy,initSegmentId:Pd,segmentKeyId:Ky,hexDump:$y,tagDump:hD,textRanges:pD}),zy=.25,vD=function(t,i){if(!i.dateTimeObject)return null;var r=i.videoTimingInfo.transmuxerPrependedSeconds,n=i.videoTimingInfo.transmuxedPresentationStart,a=n+r,s=t-a;return new Date(i.dateTimeObject.getTime()+s*1e3)},mD=function(t){return t.transmuxedPresentationEnd-t.transmuxedPresentationStart-t.transmuxerPrependedSeconds},yD=function(t,i){var r=void 0;try{r=new Date(t)}catch{return null}if(!i||!i.segments||i.segments.length===0)return null;var n=i.segments[0];if(r<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(r<s)break}var o=i.segments[i.segments.length-1],l=o.dateTimeObject,u=o.videoTimingInfo?mD(o.videoTimingInfo):o.duration+o.duration*zy,c=new Date(l.getTime()+u*1e3);return r>c?null:(r>l&&(n=o),{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:fi.duration(i,i.mediaSequence+i.segments.indexOf(n)),type:n.videoTimingInfo?"accurate":"estimate"})},_D=function(t,i){if(!i||!i.segments||i.segments.length===0)return null;for(var r=0,n=void 0,a=0;a<i.segments.length&&(n=i.segments[a],r=n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationEnd:r+n.duration,!(t<=r));a++);var s=i.segments[i.segments.length-1];if(s.videoTimingInfo&&s.videoTimingInfo.transmuxedPresentationEnd<t)return null;if(t>r){if(t>r+s.duration*zy)return null;n=s}return{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:r-n.duration,type:n.videoTimingInfo?"accurate":"estimate"}},bD=function(t,i){var r=void 0,n=void 0;try{r=new Date(t),n=new Date(i)}catch{}var a=r.getTime(),s=n.getTime();return(s-a)/1e3},TD=function(t){if(!t.segments||t.segments.length===0)return!1;for(var i=0;i<t.segments.length;i++){var r=t.segments[i];if(!r.dateTimeObject)return!1}return!0},SD=function(t){var i=t.playlist,r=t.time,n=r===void 0?void 0:r,a=t.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=_D(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},l=vD(n,s.segment);return l&&(o.programDateTime=l.toISOString()),a(null,o)},ED=function e(t){var i=t.programTime,r=t.playlist,n=t.retryCount,a=n===void 0?2:n,s=t.seekTo,o=t.pauseAfterSeek,l=o===void 0?!0:o,u=t.tech,c=t.callback;if(!c)throw new Error("seekToProgramTime: callback must be provided");if(typeof i>"u"||!r||!s)return c({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!r.endList&&!u.hasStarted_)return c({message:"player must be playing a live stream to start buffering"});if(!TD(r))return c({message:"programDateTime tags must be provided in the manifest "+r.resolvedUri});var d=yD(i,r);if(!d)return c({message:i+" was not found in the stream"});var h=d.segment,f=bD(h.dateTimeObject,i);if(d.type==="estimate"){if(a===0)return c({message:i+" is not buffered yet. Try again"});s(d.estimatedStart+f),u.one("seeked",function(){e({programTime:i,playlist:r,retryCount:a-1,seekTo:s,pauseAfterSeek:l,tech:u,callback:c})});return}var b=h.start+f,p=function(){return c(null,u.currentTime())};u.one("seeked",p),l&&u.pause(),s(b)},Od=1/30,Ln=Od*3,Xy=function(t,i){var r=[],n=void 0;if(t&&t.length)for(n=0;n<t.length;n++)i(t.start(n),t.end(n))&&r.push([t.start(n),t.end(n)]);return V.createTimeRanges(r)},Jy=function(t,i){return Xy(t,function(r,n){return r-Ln<=i&&n+Ln>=i})},Qy=function(t,i){return Xy(t,function(r){return r-Od>=i})},xD=function(t){if(t.length<2)return V.createTimeRanges();for(var i=[],r=1;r<t.length;r++){var n=t.end(r-1),a=t.start(r);i.push([n,a])}return V.createTimeRanges(i)},Kh=function(t){var i=[];if(!t||!t.length)return"";for(var r=0;r<t.length;r++)i.push(t.start(r)+" => "+t.end(r));return i.join(", ")},wD=function(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,n=t.length?t.end(t.length-1):0;return(n-i)/r},Zy=function(t){for(var i=[],r=0;r<t.length;r++)i.push({start:t.start(r),end:t.end(r)});return i},AD=function(t,i,r){var n=i.player_;if(r.captions&&r.captions.length){t.inbandTextTracks_||(t.inbandTextTracks_={});for(var a in r.captionStreams)if(!t.inbandTextTracks_[a]){n.tech_.trigger({type:"usage",name:"hls-608"});var s=n.textTracks().getTrackById(a);s?t.inbandTextTracks_[a]=s:t.inbandTextTracks_[a]=n.addRemoteTextTrack({kind:"captions",id:a,label:a},!1).track}}r.metadata&&r.metadata.length&&!t.metadataTrack_&&(t.metadataTrack_=n.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,t.metadataTrack_.inBandMetadataTrackDispatchType=r.metadata.dispatchType)},ho=function(t,i,r){var n=void 0,a=void 0;if(!!r&&!!r.cues)for(n=r.cues.length;n--;)a=r.cues[n],a.startTime<=i&&a.endTime>=t&&r.removeCue(a)},DD=function(t){Object.defineProperties(t.frame,{id:{get:function(){return V.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),t.value.key}},value:{get:function(){return V.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),t.value.data}},privateData:{get:function(){return V.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),t.value.data}}})},e_=function(t){var i=void 0;return isNaN(t)||Math.abs(t)===1/0?i=Number.MAX_VALUE:i=t,i},CD=function(t,i,r){var n=pe.WebKitDataCue||pe.VTTCue;if(i&&i.forEach(function(d){var h=d.stream;this.inbandTextTracks_[h].addCue(new n(d.startTime+this.timestampOffset,d.endTime+this.timestampOffset,d.text))},t),r){var a=e_(t.mediaSource_.duration);if(r.forEach(function(d){var h=d.cueTime+this.timestampOffset;typeof h!="number"||pe.isNaN(h)||h<0||!(h<1/0)||d.frames.forEach(function(f){var b=new n(h,h,f.value||f.url||f.data||"");b.frame=f,b.value=f,DD(b),this.metadataTrack_.addCue(b)},this)},t),t.metadataTrack_&&t.metadataTrack_.cues&&t.metadataTrack_.cues.length){for(var s=t.metadataTrack_.cues,o=[],l=0;l<s.length;l++)s[l]&&o.push(s[l]);var u=o.reduce(function(d,h){var f=d[h.startTime]||[];return f.push(h),d[h.startTime]=f,d},{}),c=Object.keys(u).sort(function(d,h){return Number(d)-Number(h)});c.forEach(function(d,h){var f=u[d],b=Number(c[h+1])||a;f.forEach(function(p){p.endTime=b})})}}},as=typeof window<"u"?window:{},$h=typeof Symbol>"u"?"__target":Symbol(),kD="application/javascript",RD=as.BlobBuilder||as.WebKitBlobBuilder||as.MozBlobBuilder||as.MSBlobBuilder,po=as.URL||as.webkitURL||po&&po.msURL,go=as.Worker;function t_(e,t){return function(r){var n=this;if(t)if(go&&!r){var a=t.toString().replace(/^function.+?{/,"").slice(0,-1),s=n_(a);return this[$h]=new go(s),PD(this[$h],s),this[$h]}else{var o={postMessage:function(u){n.onmessage&&setTimeout(function(){n.onmessage({data:u,target:o})})}};t.call(o),this.postMessage=function(l){setTimeout(function(){o.onmessage({data:l,target:n})})},this.isThisThread=!0}else return new go(e)}}if(go){var Ld,r_=n_("self.onmessage = function () {}"),i_=new Uint8Array(1);try{Ld=new go(r_),Ld.postMessage(i_,[i_.buffer])}catch{go=null}finally{po.revokeObjectURL(r_),Ld&&Ld.terminate()}}function n_(e){try{return po.createObjectURL(new Blob([e],{type:kD}))}catch{var t=new RD;return t.append(e),po.createObjectURL(t.getBlob(type))}}function PD(e,t){if(!(!e||!t)){var i=e.terminate;e.objURL=t,e.terminate=function(){e.objURL&&po.revokeObjectURL(e.objURL),i.call(e)}}}var OD=new t_("./transmuxer-worker.worker.js",function(e,t){var i=this;(function(){var r=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 W;return F[j]?(W=F[j].indexOf(K),F[j]=F[j].slice(),F[j].splice(W,1),W>-1):!1},this.trigger=function(j){var K,W,ee,ie;if(K=F[j],!!K)if(arguments.length===2)for(ee=K.length,W=0;W<ee;++W)K[W].call(this,arguments[1]);else{for(ie=[],W=arguments.length,W=1;W<arguments.length;++W)ie.push(arguments[W]);for(ee=K.length,W=0;W<ee;++W)K[W].apply(this,ie)}},this.dispose=function(){F={}}}};r.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},r.prototype.push=function(se){this.trigger("data",se)},r.prototype.flush=function(se){this.trigger("done",se)},r.prototype.partialFlush=function(se){this.trigger("partialdone",se)},r.prototype.endTimeline=function(se){this.trigger("endedtimeline",se)},r.prototype.reset=function(se){this.trigger("reset",se)};var n=r,a=Math.pow(2,32)-1,s,o,l,u,c,d,h,f,b,p,m,y,v,g,S,E,w,T,x,A,D,C,k,O,I,R,P,L,N,B,G,J,re,Q,ne,le;(function(){var se;if(k={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 k)k.hasOwnProperty(se)&&(k[se]=[se.charCodeAt(0),se.charCodeAt(1),se.charCodeAt(2),se.charCodeAt(3)]);O=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]),R=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]),I=new Uint8Array([0,0,0,1]),P=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]),L=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:P,audio:L},J=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),G=new Uint8Array([0,0,0,0,0,0,0,0]),re=new Uint8Array([0,0,0,0,0,0,0,0]),Q=re,ne=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),le=re,B=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}})(),s=function(F){var j=[],K=0,W,ee,ie;for(W=1;W<arguments.length;W++)j.push(arguments[W]);for(W=j.length;W--;)K+=j[W].byteLength;for(ee=new Uint8Array(K+8),ie=new DataView(ee.buffer,ee.byteOffset,ee.byteLength),ie.setUint32(0,ee.byteLength),ee.set(F,4),W=0,K=8;W<j.length;W++)ee.set(j[W],K),K+=j[W].byteLength;return ee},o=function(){return s(k.dinf,s(k.dref,J))},l=function(F){return s(k.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]))},u=function(){return s(k.ftyp,O,I,O,R)},E=function(F){return s(k.hdlr,N[F])},c=function(F){return s(k.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(k.mdhd,j)},g=function(F){return s(k.mdia,S(F),E(F.type),h(F))},d=function(F){return s(k.mfhd,new Uint8Array([0,0,0,0,(F&4278190080)>>24,(F&16711680)>>16,(F&65280)>>8,F&255]))},h=function(F){return s(k.minf,F.type==="video"?s(k.vmhd,B):s(k.smhd,G),o(),T(F))},f=function(F,j){for(var K=[],W=j.length;W--;)K[W]=A(j[W]);return s.apply(null,[k.moof,d(F)].concat(K))},b=function(F){for(var j=F.length,K=[];j--;)K[j]=y(F[j]);return s.apply(null,[k.moov,m(4294967295)].concat(K).concat(p(F)))},p=function(F){for(var j=F.length,K=[];j--;)K[j]=D(F[j]);return s.apply(null,[k.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(k.mvhd,j)},w=function(F){var j=F.samples||[],K=new Uint8Array(4+j.length),W,ee;for(ee=0;ee<j.length;ee++)W=j[ee].flags,K[ee+4]=W.dependsOn<<4|W.isDependedOn<<2|W.hasRedundancy;return s(k.sdtp,K)},T=function(F){return s(k.stbl,x(F),s(k.stts,le),s(k.stsc,Q),s(k.stsz,ne),s(k.stco,re))},function(){var se,F;x=function(K){return s(k.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),K.type==="video"?se(K):F(K))},se=function(K){var W=K.sps||[],ee=K.pps||[],ie=[],oe=[],de,ye;for(de=0;de<W.length;de++)ie.push((W[de].byteLength&65280)>>>8),ie.push(W[de].byteLength&255),ie=ie.concat(Array.prototype.slice.call(W[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=[k.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(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(k.avcC,new Uint8Array([1,K.profileIdc,K.profileCompatibility,K.levelIdc,255].concat([W.length],ie,[ee.length],oe))),s(k.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(k.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(k.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]),l(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(k.tkhd,j)},A=function(F){var j,K,W,ee,ie,oe,de;return j=s(k.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(k.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])),ie=32+20+8+16+8+8,F.type==="audio"?(W=C(F,ie),s(k.traf,j,K,W)):(ee=w(F),W=C(F,ee.length+ie),s(k.traf,j,K,W,ee))},y=function(F){return F.duration=F.duration||4294967295,s(k.trak,v(F),g(F))},D=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(k.trex,j)},function(){var se,F,j;j=function(W,ee){var ie=0,oe=0,de=0,ye=0;return W.length&&(W[0].duration!==void 0&&(ie=1),W[0].size!==void 0&&(oe=2),W[0].flags!==void 0&&(de=4),W[0].compositionTimeOffset!==void 0&&(ye=8)),[0,0,ie|oe|de|ye,1,(W.length&4278190080)>>>24,(W.length&16711680)>>>16,(W.length&65280)>>>8,W.length&255,(ee&4278190080)>>>24,(ee&16711680)>>>16,(ee&65280)>>>8,ee&255]},F=function(W,ee){var ie,oe,de,ye;for(oe=W.samples||[],ee+=8+12+16*oe.length,ie=j(oe,ee),ye=0;ye<oe.length;ye++)de=oe[ye],ie=ie.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(k.trun,new Uint8Array(ie))},se=function(W,ee){var ie,oe,de,ye;for(oe=W.samples||[],ee+=8+12+8*oe.length,ie=j(oe,ee),ye=0;ye<oe.length;ye++)de=oe[ye],ie=ie.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(k.trun,new Uint8Array(ie))},C=function(W,ee){return W.type==="audio"?se(W,ee):F(W,ee)}}();var Te={ftyp:u,mdat:c,moof:f,moov:b,initSegment:function(F){var j=u(),K=b(F),W;return W=new Uint8Array(j.byteLength+K.byteLength),W.set(j),W.set(K,j.byteLength),W}},Ne=function(F){var j,K,W=[],ee=[];for(ee.byteLength=0,ee.nalCount=0,ee.duration=0,W.byteLength=0,j=0;j<F.length;j++)K=F[j],K.nalUnitType==="access_unit_delimiter_rbsp"?(W.length&&(W.duration=K.dts-W.dts,ee.byteLength+=W.byteLength,ee.nalCount+=W.length,ee.duration+=W.duration,ee.push(W)),W=[K],W.byteLength=K.data.byteLength,W.pts=K.pts,W.dts=K.dts):(K.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"&&(W.keyFrame=!0),W.duration=K.dts-W.dts,W.byteLength+=K.data.byteLength,W.push(K));return ee.length&&(!W.duration||W.duration<=0)&&(W.duration=ee[ee.length-1].duration),ee.byteLength+=W.byteLength,ee.nalCount+=W.length,ee.duration+=W.duration,ee.push(W),ee},Se=function(F){var j,K,W=[],ee=[];for(W.byteLength=0,W.nalCount=0,W.duration=0,W.pts=F[0].pts,W.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?(W.length&&(ee.push(W),ee.byteLength+=W.byteLength,ee.nalCount+=W.nalCount,ee.duration+=W.duration),W=[K],W.nalCount=K.length,W.byteLength=K.byteLength,W.pts=K.pts,W.dts=K.dts,W.duration=K.duration):(W.duration+=K.duration,W.nalCount+=K.length,W.byteLength+=K.byteLength,W.push(K));return ee.length&&W.duration<=0&&(W.duration=ee[ee.length-1].duration),ee.byteLength+=W.byteLength,ee.nalCount+=W.nalCount,ee.duration+=W.duration,ee.push(W),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},He=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},rt=function(F,j){var K=He();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,W,ee,ie,oe,de=j||0,ye=[];for(K=0;K<F.length;K++)for(ie=F[K],W=0;W<ie.length;W++)oe=ie[W],ee=rt(oe,de),de+=ee.size,ye.push(ee);return ye},yt=function(F){var j,K,W,ee,ie,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(ie=ee[K],W=0;W<ie.length;W++)oe=ie[W],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,W=j||0,ee=[];return K=rt(F,W),ee.push(K),ee},Le=function(F){var j,K,W=0,ee=F.byteLength,ie=F.length,oe=ee+4*ie,de=new Uint8Array(oe),ye=new DataView(de.buffer);for(j=0;j<F.length;j++)K=F[j],ye.setUint32(W,K.data.byteLength),W+=4,de.set(K.data,W),W+=K.data.byteLength;return de},Be={groupNalsIntoFrames:Ne,groupFramesIntoGops:Se,extendFirstKeyFrame:be,generateSampleTable:ot,concatenateNalData:yt,generateSampleTableForFrame:_e,concatenateNalDataForFrame:Le},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(W,ee){return W.concat(ee)},[])),j},{})},lt={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(lt),Ce=9e4,er,xr,Ut,kr,yr,Xr,wr;er=function(F){return F*Ce},xr=function(F,j){return F*j},Ut=function(F){return F/Ce},kr=function(F,j){return F/j},yr=function(F,j){return er(kr(F,j))},Xr=function(F,j){return xr(Ut(F),j)},wr=function(F,j,K){return Ut(K?F:F-j)};var dr={ONE_SECOND_IN_TS:Ce,secondsToVideoTs:er,secondsToAudioTs:xr,videoTsToSeconds:Ut,audioTsToSeconds:kr,audioTsToVideoTs:yr,videoTsToAudioTs:Xr,metadataTsToSeconds:wr},nr=function(F){var j,K,W=0;for(j=0;j<F.length;j++)K=F[j],W+=K.data.byteLength;return W},Qi=function(F,j,K,W){var ee,ie=0,oe=0,de=0,ye=0,Ae,Je,dt;if(!!j.length&&(ee=dr.audioTsToVideoTs(F.baseMediaDecodeTime,F.samplerate),ie=Math.ceil(dr.ONE_SECOND_IN_TS/(F.samplerate/1024)),K&&W&&(oe=ee-Math.max(K,W),de=Math.floor(oe/ie),ye=de*ie),!(de<1||ye>dr.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-ie,pts:dt.pts-ie});F.baseMediaDecodeTime-=Math.floor(dr.videoTsToAudioTs(ye,F.samplerate))}},Jn=function(F,j,K){return j.minSegmentDts>=K?F:(j.minSegmentDts=1/0,F.filter(function(W){return W.dts>=K?(j.minSegmentDts=Math.min(j.minSegmentDts,W.dts),j.minSegmentPts=j.minSegmentDts,!0):!1}))},qo=function(F){var j,K,W=[];for(j=0;j<F.length;j++)K=F[j],W.push({size:K.data.byteLength,duration:1024});return W},fl=function(F){var j,K,W=0,ee=new Uint8Array(nr(F));for(j=0;j<F.length;j++)K=F[j],ee.set(K.data,W),W+=K.data.byteLength;return ee},Ii={prefixWithSilence:Qi,trimAdtsFramesByEarliestDts:Jn,generateSampleTable:qo,concatenateFrameData:fl},Qn=dr.ONE_SECOND_IN_TS,Vo=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))},oi=function(F){delete F.minSegmentDts,delete F.maxSegmentDts,delete F.minSegmentPts,delete F.maxSegmentPts},Zn=function(F,j){var K,W,ee=F.minSegmentDts;return j||(ee-=F.timelineStartInfo.dts),K=F.timelineStartInfo.baseMediaDecodeTime,K+=ee,K=Math.max(0,K),F.type==="audio"&&(W=F.samplerate/Qn,K*=W,K=Math.floor(K)),K},Jr={clearDtsInfo:oi,calculateTrackBaseMediaDecodeTime:Zn,collectDtsInfo:Vo},Cs=4,hl=128,pl=function(F){for(var j=0,K={payloadType:-1,payloadSize:0},W=0,ee=0;j<F.byteLength&&F[j]!==hl;){for(;F[j]===255;)W+=255,j++;for(W+=F[j++];F[j]===255;)ee+=255,j++;if(ee+=F[j++],!K.payload&&W===Cs){K.payloadType=W,K.payloadSize=ee,K.payload=F.subarray(j,j+ee);break}j+=ee,W=0,ee=0}return K},Wo=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)},gl=function(F,j){var K=[],W,ee,ie,oe;if(!(j[0]&64))return K;for(ee=j[0]&31,W=0;W<ee;W++)ie=W*3,oe={type:j[ie+2]&3,pts:F},j[ie+2]&4&&(oe.ccData=j[ie+3]<<8|j[ie+4],K.push(oe));return K},vl=function(F){for(var j=F.byteLength,K=[],W=1,ee,ie;W<j-2;)F[W]===0&&F[W+1]===0&&F[W+2]===3?(K.push(W+2),W+=2):W++;if(K.length===0)return F;ee=j-K.length,ie=new Uint8Array(ee);var oe=0;for(W=0;W<ee;oe++,W++)oe===K[0]&&(oe++,K.shift()),ie[W]=F[oe];return ie},mn={parseSei:pl,parseUserData:Wo,parseCaptionPackets:gl,discardEmulationPreventionBytes:vl,USER_DATA_REGISTERED_ITU_T_T35:Cs},Qr=function se(){se.prototype.init.call(this),this.captionPackets_=[],this.ccStreams_=[new ar(0,0),new ar(0,1),new ar(1,0),new ar(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)};Qr.prototype=new n,Qr.prototype.push=function(se){var F,j,K;if(se.nalUnitType==="sei_rbsp"&&(F=mn.parseSei(se.escapedRBSP),F.payloadType===mn.USER_DATA_REGISTERED_ITU_T_T35&&(j=mn.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=mn.parseCaptionPackets(se.pts,j),this.captionPackets_=this.captionPackets_.concat(K),this.latestDts_!==se.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=se.dts}},Qr.prototype.flushCCStreams=function(se){this.ccStreams_.forEach(function(F){return se==="flush"?F.flush():F.partialFlush()},this)},Qr.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)},Qr.prototype.flush=function(){return this.flushStream("flush")},Qr.prototype.partialFlush=function(){return this.flushStream("partialFlush")},Qr.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(se){se.reset()})},Qr.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)},Qr.prototype.setsChannel1Active=function(se){return(se.ccData&30720)===4096},Qr.prototype.setsChannel2Active=function(se){return(se.ccData&30720)===6144},Qr.prototype.setsTextOrXDSActive=function(se){return(se.ccData&28928)===256||(se.ccData&30974)===4138||(se.ccData&30974)===6186};var ml={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},Na=function(F){return F===null?"":(F=ml[F]||F,String.fromCharCode(F))},Fa=14,Yo=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],Mi=function(){for(var F=[],j=Fa+1;j--;)F.push("");return F},ar=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 W,ee,ie,oe,de;if(W=K.ccData&32639,W===this.lastControlCode_){this.lastControlCode_=null;return}if((W&61440)===4096?this.lastControlCode_=W:W!==this.PADDING_&&(this.lastControlCode_=null),ie=W>>>8,oe=W&255,W!==this.PADDING_)if(W===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(W===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(W===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(K.pts);else if(W===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(K.pts);else if(W===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(K.pts);else if(W===this.CARRIAGE_RETURN_)this.clearFormatting(K.pts),this.flushDisplayed(K.pts),this.shiftRowsUp_(),this.startPts_=K.pts;else if(W===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(W===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(K.pts),this.displayed_=Mi();else if(W===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Mi();else if(W===this.RESUME_DIRECT_CAPTIONING_)this.mode_!=="paintOn"&&(this.flushDisplayed(K.pts),this.displayed_=Mi()),this.mode_="paintOn",this.startPts_=K.pts;else if(this.isSpecialCharacter(ie,oe))ie=(ie&3)<<8,de=Na(ie|oe),this[this.mode_](K.pts,de),this.column_++;else if(this.isExtCharacter(ie,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),ie=(ie&3)<<8,de=Na(ie|oe),this[this.mode_](K.pts,de),this.column_++;else if(this.isMidRowCode(ie,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(ie,oe))this.column_+=oe&3;else if(this.isPAC(ie,oe)){var ye=Yo.indexOf(W&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"]),(W&16)===16&&(this.column_=((W&14)>>1)*4),this.isColorPAC(oe)&&(oe&14)===14&&this.addFormatting(K.pts,["i"])}else this.isNormalChar(ie)&&(oe===0&&(oe=null),de=Na(ie),de+=Na(oe),this[this.mode_](K.pts,de),this.column_+=de.length)}};ar.prototype=new n,ar.prototype.flushDisplayed=function(se){var F=this.displayed_.map(function(j){try{return j.trim()}catch{return console.error("Skipping malformed caption."),""}}).join(`
86
86
  `).replace(/^\n+|\n+$/g,"");F.length&&this.trigger("data",{startPts:this.startPts_,endPts:se,text:F,stream:this.name_})},ar.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=Mi(),this.nonDisplayed_=Mi(),this.lastControlCode_=null,this.column_=0,this.row_=Fa,this.rollUpRows_=2,this.formatting_=[]},ar.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},ar.prototype.isSpecialCharacter=function(se,F){return se===this.EXT_&&F>=48&&F<=63},ar.prototype.isExtCharacter=function(se,F){return(se===this.EXT_+1||se===this.EXT_+2)&&F>=32&&F<=63},ar.prototype.isMidRowCode=function(se,F){return se===this.EXT_&&F>=32&&F<=47},ar.prototype.isOffsetControlCode=function(se,F){return se===this.OFFSET_&&F>=33&&F<=35},ar.prototype.isPAC=function(se,F){return se>=this.BASE_&&se<this.BASE_+8&&F>=64&&F<=127},ar.prototype.isColorPAC=function(se){return se>=64&&se<=79||se>=96&&se<=127},ar.prototype.isNormalChar=function(se){return se>=32&&se<=127},ar.prototype.setRollUp=function(se,F){if(this.mode_!=="rollUp"&&(this.row_=Fa,this.mode_="rollUp",this.flushDisplayed(se),this.nonDisplayed_=Mi(),this.displayed_=Mi()),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},ar.prototype.addFormatting=function(se,F){this.formatting_=this.formatting_.concat(F);var j=F.reduce(function(K,W){return K+"<"+W+">"},"");this[this.mode_](se,j)},ar.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)}},ar.prototype.popOn=function(se,F){var j=this.nonDisplayed_[this.row_];j+=F,this.nonDisplayed_[this.row_]=j},ar.prototype.rollUp=function(se,F){var j=this.displayed_[this.row_];j+=F,this.displayed_[this.row_]=j},ar.prototype.shiftRowsUp_=function(){var se;for(se=0;se<this.topRow_;se++)this.displayed_[se]="";for(se=this.row_+1;se<Fa+1;se++)this.displayed_[se]="";for(se=this.topRow_;se<this.row_;se++)this.displayed_[se]=this.displayed_[se+1];this.displayed_[this.row_]=""},ar.prototype.paintOn=function(se,F){var j=this.displayed_[this.row_];j+=F,this.displayed_[this.row_]=j};var Ko={CaptionStream:Qr,Cea608Stream:ar},Hr={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},yl=8589934592,_l=4294967296,$o="shared",Ua=function(F,j){var K=1;for(F>j&&(K=-1);Math.abs(j-F)>_l;)F+=K*yl;return F},zo=function se(F){var j,K;se.prototype.init.call(this),this.type_=F||$o,this.push=function(W){this.type_!==$o&&W.type!==this.type_||(K===void 0&&(K=W.dts),W.dts=Ua(W.dts,K),W.pts=Ua(W.pts,K),j=W.dts,this.trigger("data",W))},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")}};zo.prototype=new n;var bl={TimestampRolloverStream:zo,handleRollover:Ua},ks=function(F,j,K){var W,ee="";for(W=j;W<K;W++)ee+="%"+("00"+F[W].toString(16)).slice(-2);return ee},Ba=function(F,j,K){return decodeURIComponent(ks(F,j,K))},Tl=function(F,j,K){return unescape(ks(F,j,K))},yn=function(F){return F[0]<<21|F[1]<<14|F[2]<<7|F[3]},Rs={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=Ba(F.data,1,j),F.value=Ba(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=Ba(F.data,1,j),F.url=Ba(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=Tl(F.data,0,j);break}F.privateData=F.data.subarray(j+1),F.data=F.privateData}},_n;_n=function(F){var j={debug:!!(F&&F.debug),descriptor:F&&F.descriptor},K=0,W=[],ee=0,ie;if(_n.prototype.init.call(this),this.dispatchType=Hr.METADATA_STREAM_TYPE.toString(16),j.descriptor)for(ie=0;ie<j.descriptor.length;ie++)this.dispatchType+=("00"+j.descriptor[ie].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,W.length=0),W.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(W.push(oe),ee+=oe.data.byteLength,W.length===1&&(K=yn(oe.data.subarray(6,10)),K+=10),!(ee<K)){for(de={data:new Uint8Array(K),frames:[],pts:W[0].pts,dts:W[0].dts},dt=0;dt<K;)de.data.set(W[0].data.subarray(0,K-dt),dt),dt+=W[0].data.byteLength,ee-=W[0].data.byteLength,W.shift();ye=10,de.data[5]&64&&(ye+=4,ye+=yn(de.data.subarray(10,14)),K-=yn(de.data.subarray(16,20)));do{if(Ae=yn(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,Rs[Je.id]&&(Rs[Je.id](Je),Je.owner==="com.apple.streaming.transportStreamTimestamp")){var At=Je.data,Lt=(At[3]&1)<<30|At[4]<<22|At[5]<<14|At[6]<<6|At[7]>>>2;Lt*=4,Lt+=At[7]&3,Je.timeStamp=Lt,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)}}}},_n.prototype=new n;var bn=_n,Ps=bl.TimestampRolloverStream,gi,ea,Zi,Ni=188,ja=71;gi=function(){var F=new Uint8Array(Ni),j=0;gi.prototype.init.call(this),this.push=function(K){var W=0,ee=Ni,ie;for(j?(ie=new Uint8Array(K.byteLength+j),ie.set(F.subarray(0,j)),ie.set(K,j),j=0):ie=K;ee<ie.byteLength;){if(ie[W]===ja&&ie[ee]===ja){this.trigger("data",ie.subarray(W,ee)),W+=Ni,ee+=Ni;continue}W++,ee++}W<ie.byteLength&&(F.set(ie.subarray(W),0),j=ie.byteLength-W)},this.flush=function(){j===Ni&&F[0]===ja&&(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")}},gi.prototype=new n,ea=function(){var F,j,K,W;ea.prototype.init.call(this),W=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,F=function(ie,oe){var de=0;oe.payloadUnitStartIndicator&&(de+=ie[de]+1),oe.type==="pat"?j(ie.subarray(de),oe):K(ie.subarray(de),oe)},j=function(ie,oe){oe.section_number=ie[7],oe.last_section_number=ie[8],W.pmtPid=(ie[10]&31)<<8|ie[11],oe.pmtPid=W.pmtPid},K=function(ie,oe){var de,ye,Ae,Je;if(!!(ie[5]&1)){for(W.programMapTable={video:null,audio:null,"timed-metadata":{}},de=(ie[1]&15)<<8|ie[2],ye=3+de-4,Ae=(ie[10]&15)<<8|ie[11],Je=12+Ae;Je<ye;){var dt=ie[Je],ht=(ie[Je+1]&31)<<8|ie[Je+2];dt===Hr.H264_STREAM_TYPE&&W.programMapTable.video===null?W.programMapTable.video=ht:dt===Hr.ADTS_STREAM_TYPE&&W.programMapTable.audio===null?W.programMapTable.audio=ht:dt===Hr.METADATA_STREAM_TYPE&&(W.programMapTable["timed-metadata"][ht]=dt),Je+=((ie[Je+3]&15)<<8|ie[Je+4])+5}oe.programMapTable=W.programMapTable}},this.push=function(ee){var ie={},oe=4;if(ie.payloadUnitStartIndicator=!!(ee[1]&64),ie.pid=ee[1]&31,ie.pid<<=8,ie.pid|=ee[2],(ee[3]&48)>>>4>1&&(oe+=ee[oe]+1),ie.pid===0)ie.type="pat",F(ee.subarray(oe),ie),this.trigger("data",ie);else if(ie.pid===this.pmtPid)for(ie.type="pmt",F(ee.subarray(oe),ie),this.trigger("data",ie);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([ee,oe,ie]):this.processPes_(ee,oe,ie)},this.processPes_=function(ee,ie,oe){oe.pid===this.programMapTable.video?oe.streamType=Hr.H264_STREAM_TYPE:oe.pid===this.programMapTable.audio?oe.streamType=Hr.ADTS_STREAM_TYPE:oe.streamType=this.programMapTable["timed-metadata"][oe.pid],oe.type="pes",oe.data=ee.subarray(ie),this.trigger("data",oe)}},ea.prototype=new n,ea.STREAM_TYPES={h264:27,adts:15},Zi=function(){var F=this,j={data:[],size:0},K={data:[],size:0},W={data:[],size:0},ee,ie=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,Lt=0,Ve=!1,Ur;if(!(!ye.data.length||ye.size<9)){for(ht.trackId=ye.data[0].pid,At=0;At<ye.data.length;At++)Ur=ye.data[At],dt.set(Ur.data,Lt),Lt+=Ur.data.byteLength;ie(dt,ht),Ve=Ae==="video"||ht.packetLength<=ye.size,(Je||Ve)&&(ye.size=0,ye.data.length=0),Ve&&F.trigger("data",ht)}};Zi.prototype.init.call(this),this.push=function(de){({pat:function(){},pes:function(){var Ae,Je;switch(de.streamType){case Hr.H264_STREAM_TYPE:case Hr.H264_STREAM_TYPE:Ae=j,Je="video";break;case Hr.ADTS_STREAM_TYPE:Ae=K,Je="audio";break;case Hr.METADATA_STREAM_TYPE:Ae=W,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(W,"timed-metadata")},this.flush=function(){this.flushStreams_(),this.trigger("done")}},Zi.prototype=new n;var Os={PAT_PID:0,MP2T_PACKET_LENGTH:Ni,TransportPacketStream:gi,TransportParseStream:ea,ElementaryStream:Zi,TimestampRolloverStream:Ps,CaptionStream:Ko.CaptionStream,Cea608Stream:Ko.Cea608Stream,MetadataStream:bn};for(var ta in Hr)Hr.hasOwnProperty(ta)&&(Os[ta]=Hr[ta]);var bi=Os,Xo=dr.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(W){var ee=0,ie,oe,de,ye,Ae,Je;if(F||(K=0),W.type==="audio")for(j?(ye=j,j=new Uint8Array(ye.byteLength+W.data.byteLength),j.set(ye),j.set(W.data,ye.byteLength)):j=W.data;ee+5<j.length;){if(j[ee]!==255||(j[ee+1]&246)!==240){ee++;continue}if(oe=(~j[ee+1]&1)*2,ie=(j[ee+3]&3)<<11|j[ee+4]<<3|(j[ee+5]&224)>>5,Ae=((j[ee+6]&3)+1)*1024,Je=Ae*Xo/ae[(j[ee+2]&60)>>>2],de=ee+ie,j.byteLength<de)return;if(this.trigger("data",{pts:W.pts+K*Je,dts:W.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,W=0;this.length=function(){return 8*j},this.bitsAvailable=function(){return 8*j+W},this.loadWord=function(){var ee=F.byteLength-j,ie=new Uint8Array(4),oe=Math.min(4,j);if(oe===0)throw new Error("no bytes available");ie.set(F.subarray(ee,ee+oe)),K=new DataView(ie.buffer).getUint32(0),W=oe*8,j-=oe},this.skipBits=function(ee){var ie;W>ee?(K<<=ee,W-=ee):(ee-=W,ie=Math.floor(ee/8),ee-=ie*8,j-=ie,this.loadWord(),K<<=ee,W-=ee)},this.readBits=function(ee){var ie=Math.min(W,ee),oe=K>>>32-ie;return W-=ie,W>0?K<<=ie:j>0&&this.loadWord(),ie=ee-ie,ie>0?oe<<ie|this.readBits(ie):oe},this.skipLeadingZeros=function(){var ee;for(ee=0;ee<W;++ee)if((K&2147483648>>>ee)!==0)return K<<=ee,W-=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(W){var ee;K?(ee=new Uint8Array(K.byteLength+W.data.byteLength),ee.set(K),ee.set(W.data,K.byteLength),K=ee):K=W.data;for(var ie=K.byteLength;F<ie-3;F++)if(K[F+2]===1){j=F+5;break}for(;j<ie;)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<ie);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,W,ee,ie,oe,de;ce.prototype.init.call(this),j=this,this.push=function(ye){ye.type==="video"&&(K=ye.trackId,W=ye.pts,ee=ye.dts,F.push(ye))},F.on("data",function(ye){var Ae={trackId:K,pts:W,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=ie(ye.subarray(1));break;case 7:Ae.nalUnitType="seq_parameter_set_rbsp",Ae.escapedRBSP=ie(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,Lt;for(At=0;At<Ae;At++)ht!==0&&(Lt=Je.readExpGolomb(),ht=(dt+Lt+256)%256),dt=ht===0?dt:ht},ie=function(Ae){for(var Je=Ae.byteLength,dt=[],ht=1,At,Lt;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,Lt=new Uint8Array(At);var Ve=0;for(ht=0;ht<At;Ve++,ht++)Ve===dt[0]&&(Ve++,dt.shift()),Lt[ht]=Ae[Ve];return Lt},oe=function(Ae){var Je=0,dt=0,ht=0,At=0,Lt=1,Ve,Ur,Ti,qa,wl,Qo,Al,sa,Dl,Zo,qr,mr,Cl,oa;if(Ve=new ve(Ae),Ur=Ve.readUnsignedByte(),qa=Ve.readUnsignedByte(),Ti=Ve.readUnsignedByte(),Ve.skipUnsignedExpGolomb(),Ie[Ur]&&(wl=Ve.readUnsignedExpGolomb(),wl===3&&Ve.skipBits(1),Ve.skipUnsignedExpGolomb(),Ve.skipUnsignedExpGolomb(),Ve.skipBits(1),Ve.readBoolean()))for(qr=wl!==3?8:12,oa=0;oa<qr;oa++)Ve.readBoolean()&&(oa<6?de(16,Ve):de(64,Ve));if(Ve.skipUnsignedExpGolomb(),Qo=Ve.readUnsignedExpGolomb(),Qo===0)Ve.readUnsignedExpGolomb();else if(Qo===1)for(Ve.skipBits(1),Ve.skipExpGolomb(),Ve.skipExpGolomb(),Al=Ve.readUnsignedExpGolomb(),oa=0;oa<Al;oa++)Ve.skipExpGolomb();if(Ve.skipUnsignedExpGolomb(),Ve.skipBits(1),sa=Ve.readUnsignedExpGolomb(),Dl=Ve.readUnsignedExpGolomb(),Zo=Ve.readBits(1),Zo===0&&Ve.skipBits(1),Ve.skipBits(1),Ve.readBoolean()&&(Je=Ve.readUnsignedExpGolomb(),dt=Ve.readUnsignedExpGolomb(),ht=Ve.readUnsignedExpGolomb(),At=Ve.readUnsignedExpGolomb()),Ve.readBoolean()&&Ve.readBoolean()){switch(Cl=Ve.readUnsignedByte(),Cl){case 1:mr=[1,1];break;case 2:mr=[12,11];break;case 3:mr=[10,11];break;case 4:mr=[16,11];break;case 5:mr=[40,33];break;case 6:mr=[24,11];break;case 7:mr=[20,11];break;case 8:mr=[32,11];break;case 9:mr=[80,33];break;case 10:mr=[18,11];break;case 11:mr=[15,11];break;case 12:mr=[64,33];break;case 13:mr=[160,99];break;case 14:mr=[4,3];break;case 15:mr=[3,2];break;case 16:mr=[2,1];break;case 255:{mr=[Ve.readUnsignedByte()<<8|Ve.readUnsignedByte(),Ve.readUnsignedByte()<<8|Ve.readUnsignedByte()];break}}mr&&(Lt=mr[0]/mr[1])}return{profileIdc:Ur,levelIdc:Ti,profileCompatibility:qa,width:Math.ceil(((sa+1)*16-Je*2-dt*2)*Lt),height:(2-Zo)*(Dl+1)*16-ht*2-At*2,sarRatio:mr}}},ce.prototype=new n;var Ue={H264Stream:ce,NalByteStream:Ee},je=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],qe=function(F){return F[0]==="I".charCodeAt(0)&&F[1]==="D".charCodeAt(0)&&F[2]==="3".charCodeAt(0)},ut=function(F){return F[0]<<21|F[1]<<14|F[2]<<7|F[3]},wt=function(F,j,K){var W,ee="";for(W=j;W<K;W++)ee+="%"+("00"+F[W].toString(16)).slice(-2);return ee},Ht=function(F,j,K){return unescape(wt(F,j,K))},qt=function(F,j){var K=F[j+6]<<21|F[j+7]<<14|F[j+8]<<7|F[j+9],W=F[j+5],ee=(W&16)>>4;return ee?K+20:K+10},vr=function(F,j){var K=(F[j+5]&224)>>5,W=F[j+4]<<3,ee=F[j+3]&3<<11;return ee|W|K},cr=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},Zr=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},ra=function(F){var j,K,W,ee;j=10,F[5]&64&&(j+=4,j+=ut(F.subarray(10,14)));do{if(K=ut(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"){W=F.subarray(j+10,j+K+10);for(var ie=0;ie<W.byteLength;ie++)if(W[ie]===0){var oe=Ht(W,0,ie);if(oe==="com.apple.streaming.transportStreamTimestamp"){var de=W.subarray(ie+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},ia={isLikelyAacData:qe,parseId3TagSize:qt,parseAdtsSize:vr,parseType:cr,parseSampleRate:Zr,parseAacTimestamp:ra},Fi;Fi=function(){var F=new Uint8Array,j=0;Fi.prototype.init.call(this),this.setTimestamp=function(K){j=K},this.push=function(K){var W=0,ee=0,ie,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||(W=ia.parseId3TagSize(F,ee),ee+W>F.length))break;oe={type:"timed-metadata",data:F.subarray(ee,ee+W)},this.trigger("data",oe),ee+=W;continue}else if((F[ee]&255)===255&&(F[ee+1]&240)===240){if(F.length-ee<7||(W=ia.parseAdtsSize(F,ee),ee+W>F.length))break;de={type:"audio",data:F.subarray(ee,ee+W),pts:j,dts:j},this.trigger("data",de),ee+=W;continue}ee++}ie=F.length-ee,ie>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")}},Fi.prototype=new n;var Ls=Fi,Bc=Ue.H264Stream,Tn=ia.isLikelyAacData,na=dr.ONE_SECOND_IN_TS,Ga=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],Sl=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],Is,Ha,Jo,aa,jc=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},Ms=function(F,j,K,W,ee,ie){var oe=K-j,de=W-j,ye=ee-K;return{start:{dts:F,pts:F+oe},end:{dts:F+de,pts:F+ye},prependedContentDuration:ie,baseMediaDecodeTime:F}};Ha=function(F,j){var K=[],W=0,ee=0,ie=0,oe=1/0;j=j||{},Ha.prototype.init.call(this),this.push=function(de){Jr.collectDtsInfo(F,de),F&&Ga.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){ie=de},this.flush=function(){var de,ye,Ae,Je,dt;if(K.length===0){this.trigger("done","AudioSegmentStream");return}de=Ii.trimAdtsFramesByEarliestDts(K,F,ee),F.baseMediaDecodeTime=Jr.calculateTrackBaseMediaDecodeTime(F,j.keepOriginalTimestamps),Ii.prefixWithSilence(F,de,ie,oe),F.samples=Ii.generateSampleTable(de),Ae=Te.mdat(Ii.concatenateFrameData(de)),K=[],ye=Te.moof(W,[F]),Je=new Uint8Array(ye.byteLength+Ae.byteLength),W++,Je.set(ye),Je.set(Ae,ye.byteLength),Jr.clearDtsInfo(F),dt=Math.ceil(na*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(){Jr.clearDtsInfo(F),K=[],this.trigger("reset")}},Ha.prototype=new n,Is=function(F,j){var K=0,W=[],ee=[],ie,oe;j=j||{},Is.prototype.init.call(this),delete F.minPTS,this.gopCache_=[],this.push=function(de){Jr.collectDtsInfo(F,de),de.nalUnitType==="seq_parameter_set_rbsp"&&!ie&&(ie=de.config,F.sps=[de.data],Sl.forEach(function(ye){F[ye]=ie[ye]},this)),de.nalUnitType==="pic_parameter_set_rbsp"&&!oe&&(oe=de.data,F.pps=[de.data]),W.push(de)},this.flush=function(){for(var de,ye,Ae,Je,dt,ht,At=0,Lt,Ve;W.length&&W[0].nalUnitType!=="access_unit_delimiter_rbsp";)W.shift();if(W.length===0){this.resetStream_(),this.trigger("done","VideoSegmentStream");return}if(de=Be.groupNalsIntoFrames(W),Ae=Be.groupFramesIntoGops(de),Ae[0][0].keyFrame||(ye=this.getGopForFusion_(W[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 Ur;if(j.alignGopsAtEnd?Ur=this.alignGopsAtEnd_(Ae):Ur=this.alignGopsAtStart_(Ae),!Ur){this.gopCache_.unshift({gop:Ae.pop(),pps:F.pps,sps:F.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),W=[],this.resetStream_(),this.trigger("done","VideoSegmentStream");return}Jr.clearDtsInfo(F),Ae=Ur}Jr.collectDtsInfo(F,Ae),F.samples=Be.generateSampleTable(Ae),dt=Te.mdat(Be.concatenateNalData(Ae)),F.baseMediaDecodeTime=Jr.calculateTrackBaseMediaDecodeTime(F,j.keepOriginalTimestamps),this.trigger("processedGopsInfo",Ae.map(function(Ti){return{pts:Ti.pts,dts:Ti.dts,byteLength:Ti.byteLength}})),Lt=Ae[0],Ve=Ae[Ae.length-1],this.trigger("segmentTimingInfo",Ms(F.baseMediaDecodeTime,Lt.dts,Lt.pts,Ve.dts+Ve.duration,Ve.pts+Ve.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),W=[],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_(),W=[],this.gopCache_.length=0,ee.length=0,this.trigger("reset")},this.resetStream_=function(){Jr.clearDtsInfo(F),ie=void 0,oe=void 0},this.getGopForFusion_=function(de){var ye=45e3,Ae=1e4,Je=1/0,dt,ht,At,Lt,Ve;for(Ve=0;Ve<this.gopCache_.length;Ve++)Lt=this.gopCache_[Ve],At=Lt.gop,!(!(F.pps&&jc(F.pps[0],Lt.pps[0]))||!(F.sps&&jc(F.sps[0],Lt.sps[0])))&&(At.dts<F.timelineStartInfo.dts||(dt=de.dts-At.dts-At.duration,dt>=-Ae&&dt<=ye&&(!ht||Je>dt)&&(ht=Lt,Je=dt)));return ht?ht.gop:null},this.alignGopsAtStart_=function(de){var ye,Ae,Je,dt,ht,At,Lt,Ve;for(ht=de.byteLength,At=de.nalCount,Lt=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,Lt-=dt.duration}return Ae===0?de:Ae===de.length?null:(Ve=de.slice(Ae),Ve.byteLength=ht,Ve.duration=Lt,Ve.nalCount=At,Ve.pts=Ve[0].pts,Ve.dts=Ve[0].dts,Ve)},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 Lt;if(At?Lt=Ae:Lt=ht,Lt===0)return de;var Ve=de.slice(Lt),Ur=Ve.reduce(function(Ti,qa){return Ti.byteLength+=qa.byteLength,Ti.duration+=qa.duration,Ti.nalCount+=qa.nalCount,Ti},{byteLength:0,duration:0,nalCount:0});return Ve.byteLength=Ur.byteLength,Ve.duration=Ur.duration,Ve.nalCount=Ur.nalCount,Ve.pts=Ve[0].pts,Ve.dts=Ve[0].dts,Ve},this.alignGopsWith=function(de){ee=de}},Is.prototype=new n,aa=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,aa.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))}},aa.prototype=new n,aa.prototype.flush=function(se){var F=0,j={captions:[],captionStreams:{},metadata:[],info:{}},K,W,ee,ie=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?(ie=this.videoTrack.timelineStartInfo.pts,Sl.forEach(function(de){j.info[de]=this.videoTrack[de]},this)):this.audioTrack&&(ie=this.audioTrack.timelineStartInfo.pts,Ga.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=dr.metadataTsToSeconds(K.startPts,ie,this.keepOriginalTimestamps),K.endTime=dr.metadataTsToSeconds(K.endPts,ie,this.keepOriginalTimestamps),j.captionStreams[K.stream]=!0,j.captions.push(K);for(oe=0;oe<this.pendingMetadata.length;oe++)W=this.pendingMetadata[oe],W.cueTime=dr.metadataTsToSeconds(W.pts,ie,this.keepOriginalTimestamps),j.metadata.push(W);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++)W=j.metadata[oe],this.trigger("id3Frame",W)}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},aa.prototype.setRemux=function(se){this.remuxTracks=se},Jo=function(F){var j=this,K=!0,W,ee;Jo.prototype.init.call(this),F=F||{},this.baseMediaDecodeTime=F.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var ie={};this.transmuxPipeline_=ie,ie.type="aac",ie.metadataStream=new bi.MetadataStream,ie.aacStream=new Ls,ie.audioTimestampRolloverStream=new bi.TimestampRolloverStream("audio"),ie.timedMetadataTimestampRolloverStream=new bi.TimestampRolloverStream("timed-metadata"),ie.adtsStream=new te,ie.coalesceStream=new aa(F,ie.metadataStream),ie.headOfPipeline=ie.aacStream,ie.aacStream.pipe(ie.audioTimestampRolloverStream).pipe(ie.adtsStream),ie.aacStream.pipe(ie.timedMetadataTimestampRolloverStream).pipe(ie.metadataStream).pipe(ie.coalesceStream),ie.metadataStream.on("timestamp",function(oe){ie.aacStream.setTimestamp(oe.timeStamp)}),ie.aacStream.on("data",function(oe){oe.type==="timed-metadata"&&!ie.audioSegmentStream&&(ee=ee||{timelineStartInfo:{baseMediaDecodeTime:j.baseMediaDecodeTime},codec:"adts",type:"audio"},ie.coalesceStream.numberOfTracks++,ie.audioSegmentStream=new Ha(ee,F),ie.audioSegmentStream.on("timingInfo",j.trigger.bind(j,"audioTimingInfo")),ie.adtsStream.pipe(ie.audioSegmentStream).pipe(ie.coalesceStream)),j.trigger("trackinfo",{hasAudio:!!ee,hasVideo:!!W})}),ie.coalesceStream.on("data",this.trigger.bind(this,"data")),ie.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setupTsPipeline=function(){var ie={};this.transmuxPipeline_=ie,ie.type="ts",ie.metadataStream=new bi.MetadataStream,ie.packetStream=new bi.TransportPacketStream,ie.parseStream=new bi.TransportParseStream,ie.elementaryStream=new bi.ElementaryStream,ie.timestampRolloverStream=new bi.TimestampRolloverStream,ie.adtsStream=new te,ie.h264Stream=new Bc,ie.captionStream=new bi.CaptionStream,ie.coalesceStream=new aa(F,ie.metadataStream),ie.headOfPipeline=ie.packetStream,ie.packetStream.pipe(ie.parseStream).pipe(ie.elementaryStream).pipe(ie.timestampRolloverStream),ie.timestampRolloverStream.pipe(ie.h264Stream),ie.timestampRolloverStream.pipe(ie.adtsStream),ie.timestampRolloverStream.pipe(ie.metadataStream).pipe(ie.coalesceStream),ie.h264Stream.pipe(ie.captionStream).pipe(ie.coalesceStream),ie.elementaryStream.on("data",function(oe){var de;if(oe.type==="metadata"){for(de=oe.tracks.length;de--;)!W&&oe.tracks[de].type==="video"?(W=oe.tracks[de],W.timelineStartInfo.baseMediaDecodeTime=j.baseMediaDecodeTime):!ee&&oe.tracks[de].type==="audio"&&(ee=oe.tracks[de],ee.timelineStartInfo.baseMediaDecodeTime=j.baseMediaDecodeTime);W&&!ie.videoSegmentStream&&(ie.coalesceStream.numberOfTracks++,ie.videoSegmentStream=new Is(W,F),ie.videoSegmentStream.on("timelineStartInfo",function(ye){ee&&(ee.timelineStartInfo=ye,ie.audioSegmentStream.setEarliestDts(ye.dts))}),ie.videoSegmentStream.on("processedGopsInfo",j.trigger.bind(j,"gopInfo")),ie.videoSegmentStream.on("segmentTimingInfo",j.trigger.bind(j,"videoSegmentTimingInfo")),ie.videoSegmentStream.on("baseMediaDecodeTime",function(ye){ee&&ie.audioSegmentStream.setVideoBaseMediaDecodeTime(ye)}),ie.videoSegmentStream.on("timingInfo",j.trigger.bind(j,"videoTimingInfo")),ie.h264Stream.pipe(ie.videoSegmentStream).pipe(ie.coalesceStream)),ee&&!ie.audioSegmentStream&&(ie.coalesceStream.numberOfTracks++,ie.audioSegmentStream=new Ha(ee,F),ie.audioSegmentStream.on("timingInfo",j.trigger.bind(j,"audioTimingInfo")),ie.adtsStream.pipe(ie.audioSegmentStream).pipe(ie.coalesceStream)),j.trigger("trackinfo",{hasAudio:!!ee,hasVideo:!!W})}}),ie.coalesceStream.on("data",this.trigger.bind(this,"data")),ie.coalesceStream.on("id3Frame",function(oe){oe.dispatchType=ie.metadataStream.dispatchType,j.trigger("id3Frame",oe)}),ie.coalesceStream.on("caption",this.trigger.bind(this,"caption")),ie.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setBaseMediaDecodeTime=function(ie){var oe=this.transmuxPipeline_;F.keepOriginalTimestamps||(this.baseMediaDecodeTime=ie),ee&&(ee.timelineStartInfo.dts=void 0,ee.timelineStartInfo.pts=void 0,Jr.clearDtsInfo(ee),F.keepOriginalTimestamps||(ee.timelineStartInfo.baseMediaDecodeTime=ie),oe.audioTimestampRolloverStream&&oe.audioTimestampRolloverStream.discontinuity()),W&&(oe.videoSegmentStream&&(oe.videoSegmentStream.gopCache_=[]),W.timelineStartInfo.dts=void 0,W.timelineStartInfo.pts=void 0,Jr.clearDtsInfo(W),oe.captionStream.reset(),F.keepOriginalTimestamps||(W.timelineStartInfo.baseMediaDecodeTime=ie)),oe.timestampRolloverStream&&oe.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(ie){ee&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(ie)},this.setRemux=function(ie){var oe=this.transmuxPipeline_;F.remux=ie,oe&&oe.coalesceStream&&oe.coalesceStream.setRemux(ie)},this.alignGopsWith=function(ie){W&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(ie)},this.push=function(ie){if(K){var oe=Tn(ie);oe&&this.transmuxPipeline_.type!=="aac"?this.setupAacPipeline():!oe&&this.transmuxPipeline_.type!=="ts"&&this.setupTsPipeline(),K=!1}this.transmuxPipeline_.headOfPipeline.push(ie)},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()}},Jo.prototype=new n;var El={Transmuxer:Jo,VideoSegmentStream:Is,AudioSegmentStream:Ha,AUDIO_PROPERTIES:Ga,VIDEO_PROPERTIES:Sl,generateVideoSegmentTimingInfo:Ms},Gc=function(F,j){if(!(F instanceof j))throw new TypeError("Cannot call a class as a function")},xl=function(){function se(F,j){for(var K=0;K<j.length;K++){var W=j[K];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(F,W.key,W)}}return function(F,j,K){return j&&se(F.prototype,j),K&&se(F,K),F}}(),zg=function(F,j){j.on("data",function(K){var W=K.initSegment;K.initSegment={data:W.buffer,byteOffset:W.byteOffset,byteLength:W.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})})},Hc=function(){function se(F,j){Gc(this,se),this.options=j||{},this.self=F,this.init()}return xl(se,[{key:"init",value:function(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new El.Transmuxer(this.options),zg(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}(),Xg=function(F){F.onmessage=function(j){if(j.data.action==="init"&&j.data.options){this.messageHandlers=new Hc(F,j.data.options);return}this.messageHandlers||(this.messageHandlers=new Hc(F)),j.data&&j.data.action&&j.data.action!=="init"&&this.messageHandlers[j.data.action]&&this.messageHandlers[j.data.action](j.data)}},Jg=new Xg(i);return Jg})()}),a_={videoCodec:"avc1",videoObjectTypeIndicator:".4d400d",audioProfile:"2"},s_=function(t){return t.map(function(i){return i.replace(/avc1\.(\d+)\.(\d+)/i,function(r,n,a){var s=("00"+Number(n).toString(16)).slice(-2),o=("00"+Number(a).toString(16)).slice(-2);return"avc1."+s+"00"+o})})},Nu=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",i={codecCount:0},r=void 0;return i.codecCount=t.split(",").length,i.codecCount=i.codecCount||2,r=/(^|\s|,)+(avc[13])([^ ,]*)/i.exec(t),r&&(i.videoCodec=r[2],i.videoObjectTypeIndicator=r[3]),i.audioProfile=/(^|\s|,)+mp4a.[0-9A-Fa-f]+\.([0-9A-Fa-f]+)/i.exec(t),i.audioProfile=i.audioProfile&&i.audioProfile[2],i},LD=function(t){return t.replace(/avc1\.(\d+)\.(\d+)/i,function(i){return s_([i])[0]})},zh=function(t,i,r){return t+"/"+i+'; codecs="'+r.filter(function(n){return!!n}).join(", ")+'"'},ID=function(t){return t.segments&&t.segments.length&&t.segments[0].map?"mp4":"mp2t"},MD=function(t){var i=t.attributes||{};return i.CODECS?Nu(i.CODECS):a_},ND=function(t,i){if(!t.mediaGroups.AUDIO||!i)return null;var r=t.mediaGroups.AUDIO[i];if(!r)return null;for(var n in r){var a=r[n];if(a.default&&a.playlists)return Nu(a.playlists[0].attributes.CODECS).audioProfile}return null},FD=function(t,i){var r=ID(i),n=MD(i),a=i.attributes||{},s=!0,o=!1;if(!i)return[];if(t.mediaGroups.AUDIO&&a.AUDIO){var l=t.mediaGroups.AUDIO[a.AUDIO];if(l){o=!0,s=!1;for(var u in l)if(!l[u].uri&&!l[u].playlists){s=!0;break}}}o&&!n.audioProfile&&(s||(n.audioProfile=ND(t,a.AUDIO)),n.audioProfile||(V.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=a_.audioProfile));var c={};n.videoCodec&&(c.video=""+n.videoCodec+n.videoObjectTypeIndicator),n.audioProfile&&(c.audio="mp4a.40."+n.audioProfile);var d=zh("audio",r,[c.audio]),h=zh("video",r,[c.video]),f=zh("video",r,[c.video,c.audio]);return o?!s&&c.video?[h,d]:!s&&!c.video?[d,d]:[f,d]:c.video?[f]:[d]},UD=function(t){var i={type:"",parameters:{}},r=t.trim().split(";");return i.type=r.shift().trim(),r.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},o_=function(t){return/mp4a\.\d+.\d+/i.test(t)},u_=function(t){return/avc1\.[\da-f]+/i.test(t)},BD=function(t,i,r){if(typeof i>"u"||i===null||!t.length)return[];var n=Math.ceil((i-r+3)*9e4),a=void 0;for(a=0;a<t.length&&!(t[a].pts>n);a++);return t.slice(a)},jD=function(t,i,r){if(!i.length)return t;if(r)return i.slice();var n=i[0].pts,a=0;for(a;a<t.length&&!(t[a].pts>=n);a++);return t.slice(0,a).concat(i)},GD=function(t,i,r,n){for(var a=Math.ceil((i-n)*9e4),s=Math.ceil((r-n)*9e4),o=t.slice(),l=t.length;l--&&!(t[l].pts<=s););if(l===-1)return o;for(var u=l+1;u--&&!(t[u].pts<=a););return u=Math.max(u,0),o.splice(u,l-u+1),o},HD=function(t,i,r){var n=null,a=null,s=0,o=[],l=[];if(!t&&!i)return V.createTimeRange();if(!t)return i.buffered;if(!i||r)return t.buffered;if(t.buffered.length===0&&i.buffered.length===0)return V.createTimeRange();for(var u=t.buffered,c=i.buffered,d=u.length;d--;)o.push({time:u.start(d),type:"start"}),o.push({time:u.end(d),type:"end"});for(d=c.length;d--;)o.push({time:c.start(d),type:"start"}),o.push({time:c.end(d),type:"end"});for(o.sort(function(h,f){return h.time-f.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&&(l.push([n,a]),n=null,a=null);return V.createTimeRanges(l)},vo=9e4,qD=function(t,i){var r=t.addSourceBuffer(i),n=Object.create(null);n.updating=!1,n.realBuffer_=r;var a=function(l){typeof r[l]=="function"?n[l]=function(){return r[l].apply(r,arguments)}:typeof n[l]>"u"&&Object.defineProperty(n,l,{get:function(){return r[l]},set:function(c){return r[l]=c}})};for(var s in r)a(s);return n},VD=function(e){On(t,e);function t(i,r){ki(this,t);var n=an(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,V.EventTarget));n.timestampOffset_=0,n.pendingBuffers_=[],n.bufferUpdating_=!1,n.mediaSource_=i,n.codecs_=r,n.audioCodec_=null,n.videoCodec_=null,n.audioDisabled_=!1,n.appendAudioInitSegment_=!0,n.gopBuffer_=[],n.timeMapping_=0,n.safeAppend_=V.browser.IE_VERSION>=11;var a={remux:!1,alignGopsAtEnd:n.safeAppend_};return n.codecs_.forEach(function(s){o_(s)?n.audioCodec_=s:u_(s)&&(n.videoCodec_=s)}),n.transmuxer_=new OD,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 HD(this.videoBuffer_,this.audioBuffer_,this.audioDisabled_)}}),n}return Hi(t,[{key:"data_",value:function(r){var n=r.data.segment;n.data=new Uint8Array(n.data,r.data.byteOffset,r.data.byteLength),n.initSegment=new Uint8Array(n.initSegment.data,n.initSegment.byteOffset,n.initSegment.byteLength),AD(this,this.mediaSource_,n),this.pendingBuffers_.push(n)}},{key:"done_",value:function(r){if(this.mediaSource_.readyState==="closed"){this.pendingBuffers_.length=0;return}this.processPendingSegments_()}},{key:"videoSegmentTimingInfo_",value:function(r){var n={start:{decode:r.start.dts/vo,presentation:r.start.pts/vo},end:{decode:r.end.dts/vo,presentation:r.end.pts/vo},baseMediaDecodeTime:r.baseMediaDecodeTime/vo};r.prependedContentDuration&&(n.prependedContentDuration=r.prependedContentDuration/vo),this.trigger({type:"videoSegmentTimingInfo",videoSegmentTimingInfo:n})}},{key:"createRealSourceBuffers_",value:function(){var r=this,n=["audio","video"];n.forEach(function(a){if(!!r[a+"Codec_"]&&!r[a+"Buffer_"]){var s=null;if(r.mediaSource_[a+"Buffer_"])s=r.mediaSource_[a+"Buffer_"],s.updating=!1;else{var o=a+"Codec_",l=a+'/mp4;codecs="'+r[o]+'"';s=qD(r.mediaSource_.nativeMediaSource_,l),r.mediaSource_[a+"Buffer_"]=s}r[a+"Buffer_"]=s,["update","updatestart","updateend"].forEach(function(u){s.addEventListener(u,function(){if(!(a==="audio"&&r.audioDisabled_)){u==="updateend"&&(r[a+"Buffer_"].updating=!1);var c=n.every(function(d){return d==="audio"&&r.audioDisabled_?!0:!(a!==d&&r[d+"Buffer_"]&&r[d+"Buffer_"].updating)});if(c)return r.trigger(u)}})})}})}},{key:"appendBuffer",value:function(r){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:BD(this.gopBuffer_,this.mediaSource_.player_?this.mediaSource_.player_.currentTime():null,this.timeMapping_)}),this.transmuxer_.postMessage({action:"push",data:r.buffer,byteOffset:r.byteOffset,byteLength:r.byteLength},[r.buffer]),this.transmuxer_.postMessage({action:"flush"})}},{key:"appendGopInfo_",value:function(r){this.gopBuffer_=jD(this.gopBuffer_,r.data.gopInfo,this.safeAppend_)}},{key:"remove",value:function(r,n){if(this.videoBuffer_&&(this.videoBuffer_.updating=!0,this.videoBuffer_.remove(r,n),this.gopBuffer_=GD(this.gopBuffer_,r,n,this.timeMapping_)),!this.audioDisabled_&&this.audioBuffer_&&(this.audioBuffer_.updating=!0,this.audioBuffer_.remove(r,n)),ho(r,n,this.metadataTrack_),this.inbandTextTracks_)for(var a in this.inbandTextTracks_)ho(r,n,this.inbandTextTracks_[a])}},{key:"processPendingSegments_",value:function(){var r={video:{segments:[],bytes:0},audio:{segments:[],bytes:0},captions:[],metadata:[]};if(!this.pendingBuffers_.length){this.trigger("updateend"),this.bufferUpdating_=!1;return}r=this.pendingBuffers_.reduce(function(a,s){var o=s.type,l=s.data,u=s.initSegment;return a[o].segments.push(l),a[o].bytes+=l.byteLength,a[o].initSegment=u,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},r),!this.videoBuffer_&&!this.audioBuffer_&&(r.video.bytes===0&&(this.videoCodec_=null),r.audio.bytes===0&&(this.audioCodec_=null),this.createRealSourceBuffers_()),r.audio.info&&this.mediaSource_.trigger({type:"audioinfo",info:r.audio.info}),r.video.info&&this.mediaSource_.trigger({type:"videoinfo",info:r.video.info}),this.appendAudioInitSegment_&&(!this.audioDisabled_&&this.audioBuffer_&&(r.audio.segments.unshift(r.audio.initSegment),r.audio.bytes+=r.audio.initSegment.byteLength),this.appendAudioInitSegment_=!1);var n=!1;this.videoBuffer_&&r.video.bytes?(r.video.segments.unshift(r.video.initSegment),r.video.bytes+=r.video.initSegment.byteLength,this.concatAndAppendSegments_(r.video,this.videoBuffer_)):this.videoBuffer_&&(this.audioDisabled_||!this.audioBuffer_)&&(n=!0),CD(this,r.captions,r.metadata),!this.audioDisabled_&&this.audioBuffer_&&this.concatAndAppendSegments_(r.audio,this.audioBuffer_),this.pendingBuffers_.length=0,n&&this.trigger("updateend"),this.bufferUpdating_=!1}},{key:"concatAndAppendSegments_",value:function(r,n){var a=0,s=void 0;if(r.bytes){s=new Uint8Array(r.bytes),r.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}}]),t}(V.EventTarget),Xh=function(e){On(t,e);function t(){ki(this,t);var i=an(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),r=void 0;i.nativeMediaSource_=new pe.MediaSource;for(r in i.nativeMediaSource_)!(r in t.prototype)&&typeof i.nativeMediaSource_[r]=="function"&&(i[r]=i.nativeMediaSource_[r].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?V.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 l=i.player_.audioTracks()[o];if(l.enabled&&l.kind!=="main"){a=!0,s=!1;break}}i.sourceBuffers.forEach(function(u,c){if(u.appendAudioInitSegment_=!0,u.videoCodec_&&u.audioCodec_)u.audioDisabled_=a;else if(u.videoCodec_&&!u.audioCodec_)u.audioDisabled_=!0,s=!1;else if(!u.videoCodec_&&u.audioCodec_&&(u.audioDisabled_=c?s:!s,u.audioDisabled_))return;i.activeSourceBuffers_.push(u)})},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_=V(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=e_(i.duration),s=0;s<i.sourceBuffers.length;s++){var o=i.sourceBuffers[s],l=o.metadataTrack_&&o.metadataTrack_.cues;l&&l.length&&(l[l.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 Hi(t,[{key:"addSeekableRange_",value:function(r,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(r){var n=void 0,a=UD(r);if(/^(video|audio)\/mp2t$/i.test(a.type)){var s=[];a.parameters&&a.parameters.codecs&&(s=a.parameters.codecs.split(","),s=s_(s),s=s.filter(function(o){return o_(o)||u_(o)})),s.length===0&&(s=["avc1.4d400d","mp4a.40.2"]),n=new VD(this,s),this.sourceBuffers.length!==0&&(this.sourceBuffers[0].createRealSourceBuffers_(),n.createRealSourceBuffers_(),this.sourceBuffers[0].audioDisabled_=!0)}else n=this.nativeMediaSource_.addSourceBuffer(r);return this.sourceBuffers.push(n),n}}]),t}(V.EventTarget),l_=0;V.mediaSources={};var d_=function(t,i){var r=V.mediaSources[t];if(r)r.trigger({type:"sourceopen",swfId:i});else throw new Error("Media Source not found (Video.js)")},Jh=function(){return!!pe.MediaSource&&!!pe.MediaSource.isTypeSupported&&pe.MediaSource.isTypeSupported('video/mp4;codecs="avc1.4d400d,mp4a.40.2"')},Fu=function(){if(this.MediaSource={open:d_,supportsNativeMediaSources:Jh},Jh())return new Xh;throw new Error("Cannot use create a virtual MediaSource for this video")};Fu.open=d_,Fu.supportsNativeMediaSources=Jh;var c_={createObjectURL:function(t){var i="blob:vjs-media-source/",r=void 0;return t instanceof Xh?(r=pe.URL.createObjectURL(t.nativeMediaSource_),t.url_=r,r):t instanceof Xh?(r=i+l_,l_++,V.mediaSources[r]=t,r):(r=pe.URL.createObjectURL(t),t.url_=r,r)}};V.MediaSource=Fu,V.URL=c_;var WD=V.EventTarget,f_=V.mergeOptions,h_=function(t,i){for(var r=void 0,n=f_(t,{duration:i.duration,minimumUpdatePeriod:i.minimumUpdatePeriod}),a=0;a<i.playlists.length;a++){var s=qh(n,i.playlists[a]);s?n=s:r=!0}return Cd(i,function(o,l,u,c){if(o.playlists&&o.playlists.length){var d=o.playlists[0].uri,h=qh(n,o.playlists[0]);h&&(n=h,n.mediaGroups[l][u][c].playlists[0]=n.playlists[d],r=!1)}}),r?null:n},Qh=function(t){var i=t.byterange.offset+t.byterange.length-1;return t.uri+"-"+t.byterange.offset+"-"+i},YD=function(t,i){var r=Boolean(!t.map&&!i.map),n=r||Boolean(t.map&&i.map&&t.map.byterange.offset===i.map.byterange.offset&&t.map.byterange.length===i.map.byterange.length);return n&&t.uri===i.uri&&t.byterange.offset===i.byterange.offset&&t.byterange.length===i.byterange.length},p_=function(t,i){var r={};for(var n in t){var a=t[n],s=a.sidx;if(s){var o=Qh(s);if(!i[o])break;var l=i[o].sidxInfo;YD(l,s)&&(r[o]=i[o])}}return r},KD=function(t,i,r,n){var a=ym(t,{manifestUri:i,clientOffset:r}),s=p_(a.playlists,n),o=s;return Cd(a,function(l,u,c,d){if(l.playlists&&l.playlists.length){var h=l.playlists;o=f_(o,p_(h,n))}}),o},g_=function(t,i,r,n,a){var s={uri:Dd(n.handleManifestRedirects,t.resolvedUri),byterange:t.byterange,playlist:i},o=V.mergeOptions(s,{responseType:"arraybuffer",headers:Yh(s)});return r(o,a)},Zh=function(e){On(t,e);function t(i,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=arguments[3];ki(this,t);var s=an(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),o=n.withCredentials,l=o===void 0?!1:o,u=n.handleManifestRedirects,c=u===void 0?!1:u;if(s.hls_=r,s.withCredentials=l,s.handleManifestRedirects=c,!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_={},an(s)):(s.setupChildLoader(a,i),s)}return Hi(t,[{key:"setupChildLoader",value:function(r,n){this.masterPlaylistLoader_=r,this.childPlaylist_=n}},{key:"dispose",value:function(){this.stopRequest(),this.loadedPlaylists_={},pe.clearTimeout(this.minimumUpdatePeriodTimeout_),pe.clearTimeout(this.mediaRequest_),pe.clearTimeout(this.mediaUpdateTimeout)}},{key:"hasPendingRequest",value:function(){return this.request||this.mediaRequest_}},{key:"stopRequest",value:function(){if(this.request){var r=this.request;this.request=null,r.onreadystatechange=null,r.abort()}}},{key:"sidxRequestFinished_",value:function(r,n,a,s){var o=this;return function(l,u){if(!!o.request){if(o.request=null,l)return o.error={status:u.status,message:"DASH playlist request error at URL: "+r.uri,response:u.response,code:2},a&&(o.state=a),o.trigger("error"),s(n,null);var c=new Uint8Array(u.response),d=fw.parseSidx(c.subarray(8));return s(n,d)}}}},{key:"media",value:function(r){var n=this;if(!r)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);var a=this.state;if(typeof r=="string"){if(!this.master.playlists[r])throw new Error("Unknown playlist URI: "+r);r=this.master.playlists[r]}var s=!this.media_||r.uri!==this.media_.uri;if(s&&this.loadedPlaylists_[r.uri]&&this.loadedPlaylists_[r.uri].endList){this.state="HAVE_METADATA",this.media_=r,s&&(this.trigger("mediachanging"),this.trigger("mediachange"));return}if(!!s){if(this.media_&&this.trigger("mediachanging"),!r.sidx){this.mediaRequest_=pe.setTimeout(this.haveMetadata.bind(this,{startingState:a,playlist:r}),0);return}var o=void 0,l=void 0;this.masterPlaylistLoader_?(o=this.masterPlaylistLoader_.master,l=this.masterPlaylistLoader_.sidxMapping_):(o=this.master,l=this.sidxMapping_);var u=Qh(r.sidx);l[u]={sidxInfo:r.sidx},this.request=g_(r.sidx,r,this.hls_.xhr,{handleManifestRedirects:this.handleManifestRedirects},this.sidxRequestFinished_(r,o,a,function(c,d){if(!c||!d)throw new Error("failed to request sidx");l[u].sidx=d,n.haveMetadata({startingState:a,playlist:c.playlists[r.uri]})}))}}},{key:"haveMetadata",value:function(r){var n=r.startingState,a=r.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(),pe.clearTimeout(this.mediaUpdateTimeout),pe.clearTimeout(this.minimumUpdatePeriodTimeout_),this.state==="HAVE_NOTHING"&&(this.started=!1)}},{key:"load",value:function(r){var n=this;pe.clearTimeout(this.mediaUpdateTimeout),pe.clearTimeout(this.minimumUpdatePeriodTimeout_);var a=this.media();if(r){var s=a?a.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=pe.setTimeout(function(){return n.load()},s);return}if(!this.started){this.start();return}this.trigger("loadedplaylist")}},{key:"parseMasterXml",value:function(){var r=ym(this.masterXml_,{manifestUri:this.srcUrl,clientOffset:this.clientOffset_,sidxMapping:this.sidxMapping_});r.uri=this.srcUrl;for(var n=0;n<r.playlists.length;n++){var a="placeholder-uri-"+n;r.playlists[n].uri=a,r.playlists[a]=r.playlists[n]}return Cd(r,function(s,o,l,u){if(s.playlists&&s.playlists.length){var c="placeholder-uri-"+o+"-"+l+"-"+u;s.playlists[0].uri=c,r.playlists[c]=s.playlists[0]}}),Ly(r),Iy(r),r}},{key:"start",value:function(){var r=this;if(this.started=!0,this.masterPlaylistLoader_){this.mediaRequest_=pe.setTimeout(this.haveMaster_.bind(this),0);return}this.request=this.hls_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},function(n,a){if(!!r.request){if(r.request=null,n)return r.error={status:a.status,message:"DASH playlist request error at URL: "+r.srcUrl,responseText:a.responseText,code:2},r.state==="HAVE_NOTHING"&&(r.started=!1),r.trigger("error");r.masterXml_=a.responseText,a.responseHeaders&&a.responseHeaders.date?r.masterLoaded_=Date.parse(a.responseHeaders.date):r.masterLoaded_=Date.now(),r.srcUrl=Dd(r.handleManifestRedirects,r.srcUrl,a),r.syncClientServerClock_(r.onClientServerClockSync_.bind(r))}})}},{key:"syncClientServerClock_",value:function(r){var n=this,a=$x(this.masterXml_);if(a===null)return this.clientOffset_=this.masterLoaded_-Date.now(),r();if(a.method==="DIRECT")return this.clientOffset_=a.value-Date.now(),r();this.request=this.hls_.xhr({uri:ns(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(),r();var l=void 0;a.method==="HEAD"?!o.responseHeaders||!o.responseHeaders.date?l=n.masterLoaded_:l=Date.parse(o.responseHeaders.date):l=Date.parse(o.responseText),n.clientOffset_=l-Date.now(),r()}})}},{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 r=this;this.haveMaster_(),!this.hasPendingRequest()&&!this.media_&&this.media(this.master.playlists[0]),this.master&&this.master.minimumUpdatePeriod&&(this.minimumUpdatePeriodTimeout_=pe.setTimeout(function(){r.trigger("minimumUpdatePeriod")},this.master.minimumUpdatePeriod))}},{key:"refreshXml_",value:function(){var r=this;this.request=this.hls_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},function(n,a){if(!!r.request){if(r.request=null,n)return r.error={status:a.status,message:"DASH playlist request error at URL: "+r.srcUrl,responseText:a.responseText,code:2},r.state==="HAVE_NOTHING"&&(r.started=!1),r.trigger("error");r.masterXml_=a.responseText,r.sidxMapping_=KD(r.masterXml_,r.srcUrl,r.clientOffset_,r.sidxMapping_);var s=r.parseMasterXml(),o=h_(r.master,s),l=r.media().sidx;if(o)if(l){var u=Qh(l);if(!r.sidxMapping_[u]){var c=r.media();r.request=g_(c.sidx,c,r.hls_.xhr,{handleManifestRedirects:r.handleManifestRedirects},r.sidxRequestFinished_(c,s,r.state,function(d,h){if(!d||!h)throw new Error("failed to request sidx on minimumUpdatePeriod");r.sidxMapping_[u].sidx=h,r.minimumUpdatePeriodTimeout_=pe.setTimeout(function(){r.trigger("minimumUpdatePeriod")},r.master.minimumUpdatePeriod),r.refreshMedia_(r.media().uri)}))}}else r.master=o;r.minimumUpdatePeriodTimeout_=pe.setTimeout(function(){r.trigger("minimumUpdatePeriod")},r.master.minimumUpdatePeriod)}})}},{key:"refreshMedia_",value:function(r){var n=this;if(!r)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=h_(a,s);o?(this.masterPlaylistLoader_?this.masterPlaylistLoader_.master=o:this.master=o,this.media_=o.playlists[r]):(this.media_=s.playlists[r],this.trigger("playlistunchanged")),this.media().endList||(this.mediaUpdateTimeout=pe.setTimeout(function(){n.trigger("mediaupdatetimeout")},My(this.media(),!!o))),this.trigger("loadedplaylist")}}]),t}(WD),Uu=function(t){return V.log.debug?V.log.debug.bind(V,"VHS:",t+" >"):function(){}};function mo(){}var $D=function(){function e(t,i,r,n){ki(this,e),this.callbacks_=[],this.pendingCallback_=null,this.timestampOffset_=0,this.mediaSource=t,this.processedAppend_=!1,this.type_=r,this.mimeType_=i,this.logger_=Uu("SourceUpdater["+r+"]["+i+"]"),t.readyState==="closed"?t.addEventListener("sourceopen",this.createSourceBuffer_.bind(this,i,n)):this.createSourceBuffer_(i,n)}return Hi(e,[{key:"createSourceBuffer_",value:function(i,r){var n=this;if(this.sourceBuffer_=this.mediaSource.addSourceBuffer(i),this.logger_("created SourceBuffer"),r&&(r.trigger("sourcebufferadded"),this.mediaSource.sourceBuffers.length<2)){r.on("sourcebufferadded",function(){n.start_()});return}this.start_()}},{key:"start_",value:function(){var i=this;this.started_=!0,this.onUpdateendCallback_=function(){var r=i.pendingCallback_;i.pendingCallback_=null,i.sourceBuffer_.removing=!1,i.logger_("buffered ["+Kh(i.buffered())+"]"),r&&r(),i.runCallback_()},this.sourceBuffer_.addEventListener("updateend",this.onUpdateendCallback_),this.runCallback_()}},{key:"abort",value:function(i){var r=this;this.processedAppend_&&this.queueCallback_(function(){r.sourceBuffer_.abort()},i)}},{key:"appendBuffer",value:function(i,r){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),r()})}},{key:"buffered",value:function(){return this.sourceBuffer_?this.sourceBuffer_.buffered:V.createTimeRanges()}},{key:"remove",value:function(i,r){var n=this,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:mo;this.processedAppend_&&this.queueCallback_(function(){n.logger_("remove ["+i+" => "+r+"]"),n.sourceBuffer_.removing=!0,n.sourceBuffer_.remove(i,r)},a)}},{key:"updating",value:function(){return!this.sourceBuffer_||this.sourceBuffer_.updating||!!this.pendingCallback_&&this.pendingCallback_!==mo}},{key:"timestampOffset",value:function(i){var r=this;return typeof i<"u"&&(this.queueCallback_(function(){r.sourceBuffer_.timestampOffset=i,r.runCallback_()}),this.timestampOffset_=i),this.timestampOffset_}},{key:"queueCallback_",value:function(i,r){this.callbacks_.push([i.bind(this),r]),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,r=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",r):r()}}]),e}(),yi={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},_a={FAILURE:2,TIMEOUT:-101,ABORTED:-102},v_=function(t){t.forEach(function(i){i.abort()})},zD=function(t){return{bandwidth:t.bandwidth,bytesReceived:t.bytesReceived||0,roundTripTime:t.roundTripTime||0}},XD=function(t){var i=t.target,r=Date.now()-i.requestTime,n={bandwidth:1/0,bytesReceived:0,roundTripTime:r||0};return n.bytesReceived=t.loaded,n.bandwidth=Math.floor(n.bytesReceived/n.roundTripTime*8*1e3),n},ep=function(t,i){return i.timedout?{status:i.status,message:"HLS request timed-out at URL: "+i.uri,code:_a.TIMEOUT,xhr:i}:i.aborted?{status:i.status,message:"HLS request aborted at URL: "+i.uri,code:_a.ABORTED,xhr:i}:t?{status:i.status,message:"HLS request errored at URL: "+i.uri,code:_a.FAILURE,xhr:i}:null},JD=function(t,i){return function(r,n){var a=n.response,s=ep(r,n);if(s)return i(s,t);if(a.byteLength!==16)return i({status:n.status,message:"Invalid HLS key at URL: "+n.uri,code:_a.FAILURE,xhr:n},t);var o=new DataView(a);return t.key.bytes=new Uint32Array([o.getUint32(0),o.getUint32(4),o.getUint32(8),o.getUint32(12)]),i(null,t)}},QD=function(t,i,r){return function(n,a){var s=a.response,o=ep(n,a);return o?r(o,t):s.byteLength===0?r({status:a.status,message:"Empty HLS segment content at URL: "+a.uri,code:_a.FAILURE,xhr:a},t):(t.map.bytes=new Uint8Array(a.response),i&&!i.isInitialized()&&i.init(),t.map.timescales=Xl.timescale(t.map.bytes),t.map.videoTrackIds=Xl.videoTrackIds(t.map.bytes),r(null,t))}},ZD=function(t,i,r){return function(n,a){var s=a.response,o=ep(n,a),l=void 0;return o?r(o,t):s.byteLength===0?r({status:a.status,message:"Empty HLS segment content at URL: "+a.uri,code:_a.FAILURE,xhr:a},t):(t.stats=zD(a),t.key?t.encryptedBytes=new Uint8Array(a.response):t.bytes=new Uint8Array(a.response),i&&t.map&&t.map.bytes&&(i.isInitialized()||i.init(),l=i.parse(t.bytes,t.map.videoTrackIds,t.map.timescales),l&&l.captions&&(t.captionStreams=l.captionStreams,t.fmp4Captions=l.captions)),r(null,t))}},eC=function(t,i,r){var n=function s(o){if(o.data.source===i.requestId){t.removeEventListener("message",s);var l=o.data.decrypted;return i.bytes=new Uint8Array(l.bytes,l.byteOffset,l.byteLength),r(null,i)}};t.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)),t.postMessage(Yy({source:i.requestId,encrypted:i.encryptedBytes,key:a,iv:i.key.iv}),[i.encryptedBytes.buffer,a.buffer])},tC=function(t,i,r){var n=0,a=!1;return function(s,o){if(!a){if(s)return a=!0,v_(t),r(s,o);if(n+=1,n===t.length)return o.endOfAllRequests=Date.now(),o.encryptedBytes?eC(i,o,r):r(null,o)}}},rC=function(t,i){return function(r){return t.stats=V.mergeOptions(t.stats,XD(r)),!t.stats.firstBytesReceivedAt&&t.stats.bytesReceived&&(t.stats.firstBytesReceivedAt=Date.now()),i(r,t)}},iC=function(t,i,r,n,a,s,o){var l=[],u=tC(l,r,o);if(a.key&&!a.key.bytes){var c=V.mergeOptions(i,{uri:a.key.resolvedUri,responseType:"arraybuffer"}),d=JD(a,u),h=t(c,d);l.push(h)}if(a.map&&!a.map.bytes){var f=V.mergeOptions(i,{uri:a.map.resolvedUri,responseType:"arraybuffer",headers:Yh(a.map)}),b=QD(a,n,u),p=t(f,b);l.push(p)}var m=V.mergeOptions(i,{uri:a.resolvedUri,responseType:"arraybuffer",headers:Yh(a)}),y=ZD(a,n,u),v=t(m,y);return v.addEventListener("progress",rC(a,s)),l.push(v),function(){return v_(l)}},m_=function(t,i){var r=void 0;return!t||(r=pe.getComputedStyle(t),!r)?"":r[i]},Bu=function(t,i){var r=t.slice();t.sort(function(n,a){var s=i(n,a);return s===0?r.indexOf(n)-r.indexOf(a):s})},tp=function(t,i){var r=void 0,n=void 0;return t.attributes.BANDWIDTH&&(r=t.attributes.BANDWIDTH),r=r||pe.Number.MAX_VALUE,i.attributes.BANDWIDTH&&(n=i.attributes.BANDWIDTH),n=n||pe.Number.MAX_VALUE,r-n},nC=function(t,i){var r=void 0,n=void 0;return t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width&&(r=t.attributes.RESOLUTION.width),r=r||pe.Number.MAX_VALUE,i.attributes.RESOLUTION&&i.attributes.RESOLUTION.width&&(n=i.attributes.RESOLUTION.width),n=n||pe.Number.MAX_VALUE,r===n&&t.attributes.BANDWIDTH&&i.attributes.BANDWIDTH?t.attributes.BANDWIDTH-i.attributes.BANDWIDTH:r-n},aC=function(t,i,r,n,a){var s=t.playlists.map(function(g){var S=void 0,E=void 0,w=void 0;return S=g.attributes.RESOLUTION&&g.attributes.RESOLUTION.width,E=g.attributes.RESOLUTION&&g.attributes.RESOLUTION.height,w=g.attributes.BANDWIDTH,w=w||pe.Number.MAX_VALUE,{bandwidth:w,width:S,height:E,playlist:g}});Bu(s,function(g,S){return g.bandwidth-S.bandwidth}),s=s.filter(function(g){return!fi.isIncompatible(g.playlist)});var o=s.filter(function(g){return fi.isEnabled(g.playlist)});o.length||(o=s.filter(function(g){return!fi.isDisabled(g.playlist)}));var l=o.filter(function(g){return g.bandwidth*yi.BANDWIDTH_VARIANCE<i}),u=l[l.length-1],c=l.filter(function(g){return g.bandwidth===u.bandwidth})[0];if(a===!1){var d=c||o[0]||s[0];return d?d.playlist:null}var h=l.filter(function(g){return g.width&&g.height});Bu(h,function(g,S){return g.width-S.width});var f=h.filter(function(g){return g.width===r&&g.height===n});u=f[f.length-1];var b=f.filter(function(g){return g.bandwidth===u.bandwidth})[0],p=void 0,m=void 0,y=void 0;b||(p=h.filter(function(g){return g.width>r||g.height>n}),m=p.filter(function(g){return g.width===p[0].width&&g.height===p[0].height}),u=m[m.length-1],y=m.filter(function(g){return g.bandwidth===u.bandwidth})[0]);var v=y||b||c||o[0]||s[0];return v?v.playlist:null},sC=function(){return aC(this.playlists.master,this.systemBandwidth,parseInt(m_(this.tech_.el(),"width"),10),parseInt(m_(this.tech_.el(),"height"),10),this.limitRenditionByPlayerDimensions)},oC=function(t){var i=t.master,r=t.currentTime,n=t.bandwidth,a=t.duration,s=t.segmentDuration,o=t.timeUntilRebuffer,l=t.currentTimeline,u=t.syncController,c=i.playlists.filter(function(p){return!fi.isIncompatible(p)}),d=c.filter(fi.isEnabled);d.length||(d=c.filter(function(p){return!fi.isDisabled(p)}));var h=d.filter(fi.hasAttribute.bind(null,"BANDWIDTH")),f=h.map(function(p){var m=u.getSyncPoint(p,a,l,r),y=m?1:2,v=fi.estimateSegmentRequestTime(s,n,p),g=v*y-o;return{playlist:p,rebufferingImpact:g}}),b=f.filter(function(p){return p.rebufferingImpact<=0});return Bu(b,function(p,m){return tp(m.playlist,p.playlist)}),b.length?b[0]:(Bu(f,function(p,m){return p.rebufferingImpact-m.rebufferingImpact}),f[0]||null)},uC=function(){var t=this.playlists.master.playlists.filter(fi.isEnabled);Bu(t,function(r,n){return tp(r,n)});var i=t.filter(function(r){return Nu(r.attributes.CODECS).videoCodec});return i[0]||null},lC=function(t,i,r){for(var n in r)if(!t[n]){i.trigger({type:"usage",name:"hls-608"});var a=i.textTracks().getTrackById(n);a?t[n]=a:t[n]=i.addRemoteTextTrack({kind:"captions",id:n,label:n},!1).track}},dC=function(t){var i=t.inbandTextTracks,r=t.captionArray,n=t.timestampOffset;if(!!r){var a=window.WebKitDataCue||window.VTTCue;r.forEach(function(s){var o=s.stream,l=s.startTime,u=s.endTime;!i[o]||(l+=n,u+=n,i[o].addCue(new a(l,u,s.text)))})}},cC=500,fC=function(t,i,r){if(!t||!i)return!1;var n=t.segments,a=r===n.length;return t.endList&&i.readyState==="open"&&a},y_=function(t){return typeof t=="number"&&isFinite(t)},hC=function(t,i,r){return t!=="main"||!i||!r?null:!r.containsAudio&&!r.containsVideo?"Neither audio nor video found in segment.":i.containsVideo&&!r.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&&r.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},pC=function(t,i,r){var n=void 0;return t.length&&t.start(0)>0&&t.start(0)<i?n=t.start(0):n=i-30,Math.min(n,i-r)},gC=function(t){var i=t.segment,r=i.start,n=i.end,a=t.playlist,s=a.mediaSequence,o=a.id,l=a.segments,u=l===void 0?[]:l,c=t.mediaIndex,d=t.timeline;return["appending ["+c+"] of ["+s+", "+(s+u.length)+"] from playlist ["+o+"]","["+r+" => "+n+"] in timeline ["+d+"]"].join(" ")},rp=function(e){On(t,e);function t(i){ki(this,t);var r=an(this,(t.__proto__||Object.getPrototypeOf(t)).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 r.bandwidth=i.bandwidth,r.throughput={rate:0,count:0},r.roundTrip=NaN,r.resetStats_(),r.mediaIndex=null,r.hasPlayed_=i.hasPlayed,r.currentTime_=i.currentTime,r.seekable_=i.seekable,r.seeking_=i.seeking,r.duration_=i.duration,r.mediaSource_=i.mediaSource,r.hls_=i.hls,r.loaderType_=i.loaderType,r.startingMedia_=void 0,r.segmentMetadataTrack_=i.segmentMetadataTrack,r.goalBufferLength_=i.goalBufferLength,r.sourceType_=i.sourceType,r.inbandTextTracks_=i.inbandTextTracks,r.state_="INIT",r.checkBufferTimeout_=null,r.error_=void 0,r.currentTimeline_=-1,r.pendingSegment_=null,r.mimeType_=null,r.sourceUpdater_=null,r.xhrOptions_=null,r.activeInitSegmentId_=null,r.initSegments_={},r.cacheEncryptionKeys_=i.cacheEncryptionKeys,r.keyCache_={},r.loaderType_==="main"?r.captionParser_=new Uw:r.captionParser_=null,r.decrypter_=i.decrypter,r.syncController_=i.syncController,r.syncPoint_={segmentIndex:0,time:0},r.syncController_.on("syncinfoupdate",function(){return r.trigger("syncinfoupdate")}),r.mediaSource_.addEventListener("sourceopen",function(){return r.ended_=!1}),r.fetchAtBuffer_=!1,r.logger_=Uu("SegmentLoader["+r.loaderType_+"]"),Object.defineProperty(r,"state",{get:function(){return this.state_},set:function(a){a!==this.state_&&(this.logger_(this.state_+" -> "+a),this.state_=a)}}),r}return Hi(t,[{key:"resetStats_",value:function(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0}},{key:"dispose",value:function(){this.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(r){return typeof r<"u"&&(this.error_=r),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():V.createTimeRanges()}},{key:"initSegment",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!r)return null;var a=Pd(r),s=this.initSegments_[a];return n&&!s&&r.bytes&&(this.initSegments_[a]=s={resolvedUri:r.resolvedUri,byterange:r.byterange,bytes:r.bytes,timescales:r.timescales,videoTrackIds:r.videoTrackIds}),s||r}},{key:"segmentKey",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!r)return null;var a=Ky(r),s=this.keyCache_[a];this.cacheEncryptionKeys_&&n&&!s&&r.bytes&&(this.keyCache_[a]=s={resolvedUri:r.resolvedUri,bytes:r.bytes});var o={resolvedUri:(s||r).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 $D(this.mediaSource_,this.mimeType_,this.loaderType_,this.sourceBufferEmitter_),this.resetEverything(),this.monitorBuffer_()}},{key:"playlist",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!!r){var a=this.playlist_,s=this.pendingSegment_;this.playlist_=r,this.xhrOptions_=n,this.hasPlayed_()||(r.syncInfo={mediaSequence:r.mediaSequence,time:0});var o=null;if(a&&(a.id?o=a.id:a.uri&&(o=a.uri)),this.logger_("playlist update ["+o+" => "+(r.id||r.uri)+"]"),this.trigger("syncinfoupdate"),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();if(!a||a.uri!==r.uri){this.mediaIndex!==null&&this.resyncLoader();return}var l=r.mediaSequence-a.mediaSequence;this.logger_("live window shift ["+l+"]"),this.mediaIndex!==null&&(this.mediaIndex-=l),s&&(s.mediaIndex-=l,s.mediaIndex>=0&&(s.segment=r.segments[s.mediaIndex])),this.syncController_.saveExpiredSegmentInfo(a,r)}}},{key:"pause",value:function(){this.checkBufferTimeout_&&(pe.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}},{key:"paused",value:function(){return this.checkBufferTimeout_===null}},{key:"mimeType",value:function(r,n){this.mimeType_||(this.mimeType_=r,this.sourceBufferEmitter_=n,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_())}},{key:"resetEverything",value:function(r){this.ended_=!1,this.resetLoader(),this.remove(0,this.duration_(),r),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(r,n,a){if(this.sourceUpdater_&&this.sourceUpdater_.remove(r,n,a),ho(r,n,this.segmentMetadataTrack_),this.inbandTextTracks_)for(var s in this.inbandTextTracks_)ho(r,n,this.inbandTextTracks_[s])}},{key:"monitorBuffer_",value:function(){this.checkBufferTimeout_&&pe.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=pe.setTimeout(this.monitorBufferTick_.bind(this),1)}},{key:"monitorBufferTick_",value:function(){this.state==="READY"&&this.fillBuffer_(),this.checkBufferTimeout_&&pe.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=pe.setTimeout(this.monitorBufferTick_.bind(this),cC)}},{key:"fillBuffer_",value:function(){if(!this.sourceUpdater_.updating()){this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var r=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(!!r){if(this.isEndOfStream_(r.mediaIndex)){this.endOfStream();return}r.mediaIndex===this.playlist_.segments.length-1&&this.mediaSource_.readyState==="ended"&&!this.seeking_()||(r.timeline!==this.currentTimeline_&&(this.syncController_.reset(),r.timestampOffset=r.startOfSegment,this.captionParser_&&this.captionParser_.clearAllCaptions()),this.loadSegment_(r))}}}},{key:"isEndOfStream_",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.playlist_;return fC(n,this.mediaSource_,r)&&!this.sourceUpdater_.updating()}},{key:"checkBuffer_",value:function(r,n,a,s,o,l){var u=0,c=void 0;r.length&&(u=r.end(r.length-1));var d=Math.max(0,u-o);if(!n.segments.length||d>=this.goalBufferLength_()||!s&&d>=1)return null;if(l===null)return a=this.getSyncSegmentCandidate_(n),this.generateSegmentInfo_(n,a,null,!0);if(a!==null)return n.segments[a],c=u,this.generateSegmentInfo_(n,a+1,c,!1);if(this.fetchAtBuffer_){var h=fi.getMediaInfoForTime(n,u,l.segmentIndex,l.time);a=h.mediaIndex,c=h.startTime}else{var f=fi.getMediaInfoForTime(n,o,l.segmentIndex,l.time);a=f.mediaIndex,c=f.startTime}return this.generateSegmentInfo_(n,a,c,!1)}},{key:"getSyncSegmentCandidate_",value:function(r){var n=this;if(this.currentTimeline_===-1)return 0;var a=r.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(r.segments.length-1,0)}},{key:"generateSegmentInfo_",value:function(r,n,a,s){if(n<0||n>=r.segments.length)return null;var o=r.segments[n];return{requestId:"segment-loader-"+Math.random(),uri:o.resolvedUri,mediaIndex:n,isSyncRequest:s,startOfSegment:a,playlist:r,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:o.timeline,duration:o.duration,segment:o}}},{key:"abortRequestEarly_",value:function(r){if(this.hls_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH||Date.now()-(r.firstBytesReceivedAt||Date.now())<1e3)return!1;var n=this.currentTime_(),a=r.bandwidth,s=this.pendingSegment_.duration,o=fi.estimateSegmentRequestTime(s,a,this.playlist_,r.bytesReceived),l=wD(this.buffered_(),n,this.hls_.tech_.playbackRate())-1;if(o<=l)return!1;var u=oC({master:this.hls_.playlists.master,currentTime:n,bandwidth:a,duration:this.duration_(),segmentDuration:s,timeUntilRebuffer:l,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!!u){var c=o-l,d=c-u.rebufferingImpact,h=.5;return l<=Od&&(h=1),!u.playlist||u.playlist.uri===this.playlist_.uri||d<h?!1:(this.bandwidth=u.playlist.attributes.BANDWIDTH*yi.BANDWIDTH_VARIANCE+1,this.abort(),this.trigger("earlyabort"),!0)}}},{key:"handleProgress_",value:function(r,n){!this.pendingSegment_||n.requestId!==this.pendingSegment_.requestId||this.abortRequestEarly_(n.stats)||this.trigger("progress")}},{key:"loadSegment_",value:function(r){this.state="WAITING",this.pendingSegment_=r,this.trimBackBuffer_(r),r.abortRequests=iC(this.hls_.xhr,this.xhrOptions_,this.decrypter_,this.captionParser_,this.createSimplifiedSegmentObj_(r),this.handleProgress_.bind(this),this.segmentRequestFinished_.bind(this))}},{key:"trimBackBuffer_",value:function(r){var n=pC(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);n>0&&this.remove(0,n)}},{key:"createSimplifiedSegmentObj_",value:function(r){var n=r.segment,a={resolvedUri:n.resolvedUri,byterange:n.byterange,requestId:r.requestId};if(n.key){var s=n.key.iv||new Uint32Array([0,0,0,r.mediaIndex+r.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(r,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(r){if(this.pendingSegment_=null,this.state="READY",r.code===_a.ABORTED){this.mediaRequestsAborted+=1;return}if(this.pause(),r.code===_a.TIMEOUT){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger("bandwidthupdate");return}this.mediaRequestsErrored+=1,this.error(r),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(r){var n=this.pendingSegment_;n.bytes=r.bytes,r.map&&(n.segment.map.bytes=r.map.bytes),n.endOfAllRequests=r.endOfAllRequests,r.fmp4Captions&&(lC(this.inbandTextTracks_,this.hls_.tech_,r.captionStreams),dC({inbandTextTracks:this.inbandTextTracks_,captionArray:r.fmp4Captions,timestampOffset:0}),this.captionParser_&&this.captionParser_.clearParsedCaptions()),this.handleSegment_()}},{key:"handleSegment_",value:function(){var r=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=hC(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 l=s.segmentTimestampInfo[0].ptsTime,u=s.segmentTimestampInfo[0].dtsTime;n.timestampOffset-=l-u}this.sourceUpdater_.timestampOffset(n.timestampOffset),this.trigger("timestampoffset")}var c=this.syncController_.mappingForTimeline(n.timeline);if(c!==null&&this.trigger({type:"segmenttimemapping",mapping:c}),this.state="APPENDING",a.map){var d=Pd(a.map);if(!this.activeInitSegmentId_||this.activeInitSegmentId_!==d){var h=this.initSegment(a.map);this.sourceUpdater_.appendBuffer({bytes:h.bytes},function(){r.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_(gC(n)),this.sourceUpdater_.appendBuffer({bytes:n.bytes,videoSegmentTimingInfoCallback:this.handleVideoSegmentTimingInfo_.bind(this,n.requestId)},this.handleUpdateEnd_.bind(this))}},{key:"handleVideoSegmentTimingInfo_",value:function(r,n){if(!(!this.pendingSegment_||r!==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 r=this.pendingSegment_,n=r.segment,a=this.mediaIndex!==null;if(this.pendingSegment_=null,this.recordThroughput_(r),this.addSegmentMetadataCue_(r),this.state="READY",this.mediaIndex=r.mediaIndex,this.fetchAtBuffer_=!0,this.currentTimeline_=r.timeline,this.trigger("syncinfoupdate"),n.end&&this.currentTime_()-n.end>r.playlist.targetDuration*3){this.resetEverything();return}a&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.isEndOfStream_(r.mediaIndex+1,r.playlist)&&this.endOfStream(),this.paused()||this.monitorBuffer_()}},{key:"recordThroughput_",value:function(r){var n=this.throughput.rate,a=Date.now()-r.endOfAllRequests+1,s=Math.floor(r.byteLength/a*8*1e3);this.throughput.rate+=(s-n)/++this.throughput.count}},{key:"addSegmentMetadataCue_",value:function(r){if(!!this.segmentMetadataTrack_){var n=r.segment,a=n.start,s=n.end;if(!(!y_(a)||!y_(s))){ho(a,s,this.segmentMetadataTrack_);var o=pe.WebKitDataCue||pe.VTTCue,l={custom:n.custom,dateTimeObject:n.dateTimeObject,dateTimeString:n.dateTimeString,bandwidth:r.playlist.attributes.BANDWIDTH,resolution:r.playlist.attributes.RESOLUTION,codecs:r.playlist.attributes.CODECS,byteLength:r.byteLength,uri:r.uri,timeline:r.timeline,playlist:r.playlist.uri,start:a,end:s},u=JSON.stringify(l),c=new o(a,s,u);c.value=l,this.segmentMetadataTrack_.addCue(c)}}}}]),t}(V.EventTarget),__=function(t){return decodeURIComponent(escape(String.fromCharCode.apply(null,t)))},b_=new Uint8Array(`
87
87
 
88
- `.split("").map(function(e){return e.charCodeAt(0)})),vC=function(e){On(t,e);function t(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};ki(this,t);var n=an(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,i,r));return n.mediaSource_=null,n.subtitlesTrack_=null,n}return Hi(t,[{key:"buffered_",value:function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return V.createTimeRanges();var r=this.subtitlesTrack_.cues,n=r[0].startTime,a=r[r.length-1].startTime;return V.createTimeRanges([[n,a]])}},{key:"initSegment",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!r)return null;var a=Pd(r),s=this.initSegments_[a];if(n&&!s&&r.bytes){var o=b_.byteLength+r.bytes.byteLength,l=new Uint8Array(o);l.set(r.bytes),l.set(b_,r.bytes.byteLength),this.initSegments_[a]=s={resolvedUri:r.resolvedUri,byterange:r.byterange,bytes:l}}return s||r}},{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(r){return typeof r>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=r,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}},{key:"remove",value:function(r,n){ho(r,n,this.subtitlesTrack_)}},{key:"fillBuffer_",value:function(){var r=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(){r.state="READY",r.paused()||r.monitorBuffer_()};this.syncController_.one("timestampoffset",a),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(n)}}},{key:"skipEmptySegments_",value:function(r){for(;r&&r.segment.empty;)r=this.generateSegmentInfo_(r.playlist,r.mediaIndex+1,r.startOfSegment+r.duration,r.isSyncRequest);return r}},{key:"handleSegment_",value:function(){var r=this;if(!this.pendingSegment_||!this.subtitlesTrack_){this.state="READY";return}this.state="APPENDING";var n=this.pendingSegment_,a=n.segment;if(typeof pe.WebVTT!="function"&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var s=void 0,o=function(){r.subtitlesTrack_.tech_.off("vttjsloaded",s),r.error({message:"Error loading vtt.js"}),r.state="READY",r.pause(),r.trigger("error")};s=function(){r.subtitlesTrack_.tech_.off("vttjserror",o),r.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(l){return this.error({message:l.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(l){r.subtitlesTrack_.addCue(l)}),this.handleUpdateEnd_()}},{key:"parseVTTCues_",value:function(r){var n=void 0,a=!1;typeof pe.TextDecoder=="function"?n=new pe.TextDecoder("utf8"):(n=pe.WebVTT.StringDecoder(),a=!0);var s=new pe.WebVTT.Parser(pe,pe.vttjs,n);if(r.cues=[],r.timestampmap={MPEGTS:0,LOCAL:0},s.oncue=r.cues.push.bind(r.cues),s.ontimestampmap=function(u){return r.timestampmap=u},s.onparsingerror=function(u){V.log.warn("Error encountered when parsing cues: "+u.message)},r.segment.map){var o=r.segment.map.bytes;a&&(o=__(o)),s.parse(o)}var l=r.bytes;a&&(l=__(l)),s.parse(l),s.flush()}},{key:"updateTimeMapping_",value:function(r,n,a){var s=r.segment;if(!!n){if(!r.cues.length){s.empty=!0;return}var o=r.timestampmap,l=o.MPEGTS/9e4-o.LOCAL+n.mapping;if(r.cues.forEach(function(d){d.startTime+=l,d.endTime+=l}),!a.syncInfo){var u=r.cues[0].startTime,c=r.cues[r.cues.length-1].startTime;a.syncInfo={mediaSequence:a.mediaSequence+r.mediaIndex,time:Math.min(u,c-s.duration)}}}}}]),t}(rp),mC=function(t,i){for(var r=t.cues,n=0;n<r.length;n++){var a=r[n];if(i>=a.adStartTime&&i<=a.adEndTime)return a}return null},yC=function(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!!t.segments)for(var n=r,a=void 0,s=0;s<t.segments.length;s++){var o=t.segments[s];if(a||(a=mC(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 pe.VTTCue(n,n+o.duration,o.cueOut),a.adStartTime=n,a.adEndTime=n+parseFloat(o.cueOut),i.addCue(a)),"cueOutCont"in o){var l=void 0,u=void 0,c=o.cueOutCont.split("/").map(parseFloat),d=Y1(c,2);l=d[0],u=d[1],a=new pe.VTTCue(n,n+o.duration,""),a.adStartTime=n-l,a.adEndTime=a.adStartTime+u,i.addCue(a)}n+=o.duration}},_C=fA.inspect,T_=[{name:"VOD",run:function(t,i,r,n,a){if(r!==1/0){var s={time:0,segmentIndex:0};return s}return null}},{name:"ProgramDateTime",run:function(t,i,r,n,a){if(!t.datetimeToDisplayTime)return null;var s=i.segments||[],o=null,l=null;a=a||0;for(var u=0;u<s.length;u++){var c=s[u];if(c.dateTimeObject){var d=c.dateTimeObject.getTime()/1e3,h=d+t.datetimeToDisplayTime,f=Math.abs(a-h);if(l!==null&&(f===0||l<f))break;l=f,o={time:h,segmentIndex:u}}}return o}},{name:"Segment",run:function(t,i,r,n,a){var s=i.segments||[],o=null,l=null;a=a||0;for(var u=0;u<s.length;u++){var c=s[u];if(c.timeline===n&&typeof c.start<"u"){var d=Math.abs(a-c.start);if(l!==null&&l<d)break;(!o||l===null||l>=d)&&(l=d,o={time:c.start,segmentIndex:u})}}return o}},{name:"Discontinuity",run:function(t,i,r,n,a){var s=null;if(a=a||0,i.discontinuityStarts&&i.discontinuityStarts.length)for(var o=null,l=0;l<i.discontinuityStarts.length;l++){var u=i.discontinuityStarts[l],c=i.discontinuitySequence+l+1,d=t.discontinuities[c];if(d){var h=Math.abs(a-d.time);if(o!==null&&o<h)break;(!s||o===null||o>=h)&&(o=h,s={time:d.time,segmentIndex:u})}}return s}},{name:"Playlist",run:function(t,i,r,n,a){if(i.syncInfo){var s={time:i.syncInfo.time,segmentIndex:i.syncInfo.mediaSequence-i.mediaSequence};return s}return null}}],bC=function(e){On(t,e);function t(){ki(this,t);var i=an(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return i.inspectCache_=void 0,i.timelines=[],i.discontinuities=[],i.datetimeToDisplayTime=null,i.logger_=Uu("SyncController"),i}return Hi(t,[{key:"getSyncPoint",value:function(r,n,a,s){var o=this.runStrategies_(r,n,a,s);return o.length?this.selectSyncPoint_(o,{key:"time",value:s}):null}},{key:"getExpiredTime",value:function(r,n){if(!r||!r.segments)return null;var a=this.runStrategies_(r,n,r.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+Mu(r,s.segmentIndex,0))}},{key:"runStrategies_",value:function(r,n,a,s){for(var o=[],l=0;l<T_.length;l++){var u=T_[l],c=u.run(this,r,n,a,s);c&&(c.strategy=u.name,o.push({strategy:u.name,syncPoint:c}))}return o}},{key:"selectSyncPoint_",value:function(r,n){for(var a=r[0].syncPoint,s=Math.abs(r[0].syncPoint[n.key]-n.value),o=r[0].strategy,l=1;l<r.length;l++){var u=Math.abs(r[l].syncPoint[n.key]-n.value);u<s&&(s=u,a=r[l].syncPoint,o=r[l].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(r,n){for(var a=n.mediaSequence-r.mediaSequence,s=a-1;s>=0;s--){var o=r.segments[s];if(o&&typeof o.start<"u"){n.syncInfo={mediaSequence:r.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(r){if(!this.datetimeToDisplayTime&&r.segments&&r.segments.length&&r.segments[0].dateTimeObject){var n=r.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-n}}},{key:"reset",value:function(){this.inspectCache_=void 0}},{key:"probeSegmentInfo",value:function(r){var n=r.segment,a=r.playlist,s=void 0;return n.map?s=this.probeMp4Segment_(r):s=this.probeTsSegment_(r),s&&this.calculateSegmentTimeMapping_(r,s)&&(this.saveDiscontinuitySyncInfo_(r),a.syncInfo||(a.syncInfo={mediaSequence:a.mediaSequence+r.mediaIndex,time:n.start})),s}},{key:"probeMp4Segment_",value:function(r){var n=r.segment,a=Xl.timescale(n.map.bytes),s=Xl.startTime(a,r.bytes);return r.timestampOffset!==null&&(r.timestampOffset-=s),{start:s,end:s+n.duration}}},{key:"probeTsSegment_",value:function(r){var n=_C(r.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 l={segmentTimestampInfo:o,start:a,end:s,containsVideo:n.video&&n.video.length===2,containsAudio:n.audio&&n.audio.length===2};return l}},{key:"timestampOffsetForTimeline",value:function(r){return typeof this.timelines[r]>"u"?null:this.timelines[r].time}},{key:"mappingForTimeline",value:function(r){return typeof this.timelines[r]>"u"?null:this.timelines[r].mapping}},{key:"calculateSegmentTimeMapping_",value:function(r,n){var a=r.segment,s=this.timelines[r.timeline];if(r.timestampOffset!==null)s={time:r.startOfSegment,mapping:r.startOfSegment-n.start},this.timelines[r.timeline]=s,this.trigger("timestampoffset"),this.logger_("time mapping for timeline "+r.timeline+": "+("[time: "+s.time+"] [mapping: "+s.mapping+"]")),a.start=r.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(r){var n=r.playlist,a=r.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],l=n.discontinuitySequence+s+1,u=o-r.mediaIndex,c=Math.abs(u);if(!this.discontinuities[l]||this.discontinuities[l].accuracy>c){var d=void 0;u<0?d=a.start-Mu(n,r.mediaIndex,o):d=a.end+Mu(n,r.mediaIndex+1,o),this.discontinuities[l]={time:d,accuracy:c}}}}}]),t}(V.EventTarget),TC=new t_("./decrypter-worker.worker.js",function(e,t){var i=this;(function(){function r(g){return g.subarray(0,g.byteLength-g[g.byteLength-1])}var n=function(S,E){if(!(S instanceof E))throw new TypeError("Cannot call a class as a function")},a=function(){function g(S,E){for(var w=0;w<E.length;w++){var T=E[w];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(S,T.key,T)}}return function(S,E,w){return E&&g(S.prototype,E),w&&g(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},l=function(){var S=[[[],[],[],[],[]],[[],[],[],[],[]]],E=S[0],w=S[1],T=E[4],x=w[4],A=void 0,D=void 0,C=void 0,k=[],O=[],I=void 0,R=void 0,P=void 0,L=void 0,N=void 0,B=void 0;for(A=0;A<256;A++)O[(k[A]=A<<1^(A>>7)*283)^A]=A;for(D=C=0;!T[D];D^=I||1,C=O[C]||1)for(L=C^C<<1^C<<2^C<<3^C<<4,L=L>>8^L&255^99,T[D]=L,x[L]=D,P=k[R=k[I=k[D]]],B=P*16843009^R*65537^I*257^D*16843008,N=k[L]*257^L*16843008,A=0;A<4;A++)E[A][D]=N=N<<24^N>>>8,w[A][L]=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},u=null,c=function(){function g(S){n(this,g),u||(u=l()),this._tables=[[u[0][0].slice(),u[0][1].slice(),u[0][2].slice(),u[0][3].slice(),u[0][4].slice()],[u[1][0].slice(),u[1][1].slice(),u[1][2].slice(),u[1][3].slice(),u[1][4].slice()]];var E=void 0,w=void 0,T=void 0,x=void 0,A=void 0,D=this._tables[0][4],C=this._tables[1],k=S.length,O=1;if(k!==4&&k!==6&&k!==8)throw new Error("Invalid aes key size");for(x=S.slice(0),A=[],this._key=[x,A],E=k;E<4*k+28;E++)T=x[E-1],(E%k===0||k===8&&E%k===4)&&(T=D[T>>>24]<<24^D[T>>16&255]<<16^D[T>>8&255]<<8^D[T&255],E%k===0&&(T=T<<8^T>>>24^O<<24,O=O<<1^(O>>7)*283)),x[E]=x[E-k]^T;for(w=0;E;w++,E--)T=x[w&3?E:E-4],E<=4||w<4?A[w]=T:A[w]=C[0][D[T>>>24]]^C[1][D[T>>16&255]]^C[2][D[T>>8&255]]^C[3][D[T&255]]}return g.prototype.decrypt=function(E,w,T,x,A,D){var C=this._key[1],k=E^C[0],O=x^C[1],I=T^C[2],R=w^C[3],P=void 0,L=void 0,N=void 0,B=C.length/4-2,G=void 0,J=4,re=this._tables[1],Q=re[0],ne=re[1],le=re[2],Te=re[3],Ne=re[4];for(G=0;G<B;G++)P=Q[k>>>24]^ne[O>>16&255]^le[I>>8&255]^Te[R&255]^C[J],L=Q[O>>>24]^ne[I>>16&255]^le[R>>8&255]^Te[k&255]^C[J+1],N=Q[I>>>24]^ne[R>>16&255]^le[k>>8&255]^Te[O&255]^C[J+2],R=Q[R>>>24]^ne[k>>16&255]^le[O>>8&255]^Te[I&255]^C[J+3],J+=4,k=P,O=L,I=N;for(G=0;G<4;G++)A[(3&-G)+D]=Ne[k>>>24]<<24^Ne[O>>16&255]<<16^Ne[I>>8&255]<<8^Ne[R&255]^C[J++],P=k,k=O,O=I,I=R,R=P},g}(),d=function(){function g(){n(this,g),this.listeners={}}return g.prototype.on=function(E,w){this.listeners[E]||(this.listeners[E]=[]),this.listeners[E].push(w)},g.prototype.off=function(E,w){if(!this.listeners[E])return!1;var T=this.listeners[E].indexOf(w);return this.listeners[E].splice(T,1),T>-1},g.prototype.trigger=function(E){var w=this.listeners[E];if(!!w)if(arguments.length===2)for(var T=w.length,x=0;x<T;++x)w[x].call(this,arguments[1]);else for(var A=Array.prototype.slice.call(arguments,1),D=w.length,C=0;C<D;++C)w[C].apply(this,A)},g.prototype.dispose=function(){this.listeners={}},g.prototype.pipe=function(E){this.on("data",function(w){E.push(w)})},g}(),h=function(g){s(S,g);function S(){n(this,S);var E=o(this,g.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),f=function(S){return S<<24|(S&65280)<<8|(S&16711680)>>8|S>>>24},b=function(S,E,w){var T=new Int32Array(S.buffer,S.byteOffset,S.byteLength>>2),x=new c(Array.prototype.slice.call(E)),A=new Uint8Array(S.byteLength),D=new Int32Array(A.buffer),C=void 0,k=void 0,O=void 0,I=void 0,R=void 0,P=void 0,L=void 0,N=void 0,B=void 0;for(C=w[0],k=w[1],O=w[2],I=w[3],B=0;B<T.length;B+=4)R=f(T[B]),P=f(T[B+1]),L=f(T[B+2]),N=f(T[B+3]),x.decrypt(R,P,L,N,D,B),D[B]=f(D[B]^C),D[B+1]=f(D[B+1]^k),D[B+2]=f(D[B+2]^O),D[B+3]=f(D[B+3]^I),C=R,k=P,O=L,I=N;return A},p=function(){function g(S,E,w,T){n(this,g);var x=g.STEP,A=new Int32Array(S.buffer),D=new Uint8Array(S.byteLength),C=0;for(this.asyncStream_=new h,this.asyncStream_.push(this.decryptChunk_(A.subarray(C,C+x),E,w,D)),C=x;C<A.length;C+=x)w=new Uint32Array([f(A[C-4]),f(A[C-3]),f(A[C-2]),f(A[C-1])]),this.asyncStream_.push(this.decryptChunk_(A.subarray(C,C+x),E,w,D));this.asyncStream_.push(function(){T(null,r(D))})}return g.prototype.decryptChunk_=function(E,w,T,x){return function(){var A=b(E,w,T);x.set(A,E.byteOffset)}},a(g,null,[{key:"STEP",get:function(){return 32e3}}]),g}(),m=function(S){var E={};return Object.keys(S).forEach(function(w){var T=S[w];ArrayBuffer.isView(T)?E[w]={bytes:T.buffer,byteOffset:T.byteOffset,byteLength:T.byteLength}:E[w]=T}),E},y=function(S){S.onmessage=function(E){var w=E.data,T=new Uint8Array(w.encrypted.bytes,w.encrypted.byteOffset,w.encrypted.byteLength),x=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 p(T,x,A,function(D,C){S.postMessage(m({source:w.source,decrypted:C}),[C.buffer])})}},v=new y(i);return v})()}),SC=function(t){var i=t.default?"main":"alternative";return t.characteristics&&t.characteristics.indexOf("public.accessibility.describes-video")>=0&&(i="main-desc"),i},Id=function(t,i){t.abort(),t.pause(),i&&i.activePlaylistLoader&&(i.activePlaylistLoader.pause(),i.activePlaylistLoader=null)},ip=function(t,i){i.activePlaylistLoader=t,t.load()},EC=function(t,i){return function(){var r=i.segmentLoaders,n=r[t],a=r.main,s=i.mediaTypes[t],o=s.activeTrack(),l=s.activeGroup(o),u=s.activePlaylistLoader;if(Id(n,s),!!l){if(!l.playlistLoader){u&&a.resetEverything();return}n.resyncLoader(),ip(l.playlistLoader,s)}}},xC=function(t,i){return function(){var r=i.segmentLoaders,n=r[t],a=r.main,s=i.mediaTypes[t],o=s.activeTrack(),l=s.activeGroup(o),u=s.activePlaylistLoader;if(Id(n,s),!!l){if(!l.playlistLoader){a.resetEverything();return}if(u===l.playlistLoader){ip(l.playlistLoader,s);return}n.track&&n.track(o),n.resetEverything(),ip(l.playlistLoader,s)}}},Md={AUDIO:function(t,i){return function(){var r=i.segmentLoaders[t],n=i.mediaTypes[t],a=i.blacklistCurrentPlaylist;Id(r,n);var s=n.activeTrack(),o=n.activeGroup(),l=(o.filter(function(d){return d.default})[0]||o[0]).id,u=n.tracks[l];if(s===u){a({message:"Problem encountered loading the default audio track."});return}V.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(var c in n.tracks)n.tracks[c].enabled=n.tracks[c]===u;n.onTrackChanged()}},SUBTITLES:function(t,i){return function(){var r=i.segmentLoaders[t],n=i.mediaTypes[t];V.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),Id(r,n);var a=n.activeTrack();a&&(a.mode="disabled"),n.onTrackChanged()}}},S_={AUDIO:function(t,i,r){if(!!i){var n=r.tech,a=r.requestOptions,s=r.segmentLoaders[t];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",Md[t](t,r))}},SUBTITLES:function(t,i,r){var n=r.tech,a=r.requestOptions,s=r.segmentLoaders[t],o=r.mediaTypes[t];i.on("loadedmetadata",function(){var l=i.media();s.playlist(l,a),s.track(o.activeTrack()),(!n.paused()||l.endList&&n.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),n.paused()||s.load()}),i.on("error",Md[t](t,r))}},wC={AUDIO:function(t,i){var r=i.hls,n=i.sourceType,a=i.segmentLoaders[t],s=i.requestOptions,o=i.master.mediaGroups,l=i.mediaTypes[t],u=l.groups,c=l.tracks,d=i.masterPlaylistLoader;(!o[t]||Object.keys(o[t]).length===0)&&(o[t]={main:{default:{default:!0}}});for(var h in o[t]){u[h]||(u[h]=[]);for(var f in o[t][h]){var b=o[t][h][f],p=void 0;if(b.resolvedUri?p=new kd(b.resolvedUri,r,s):b.playlists&&n==="dash"?p=new Zh(b.playlists[0],r,s,d):p=null,b=V.mergeOptions({id:f,playlistLoader:p},b),S_[t](t,b.playlistLoader,i),u[h].push(b),typeof c[f]>"u"){var m=new V.AudioTrack({id:f,kind:SC(b),enabled:!1,language:b.language,default:b.default,label:f});c[f]=m}}}a.on("error",Md[t](t,i))},SUBTITLES:function(t,i){var r=i.tech,n=i.hls,a=i.sourceType,s=i.segmentLoaders[t],o=i.requestOptions,l=i.master.mediaGroups,u=i.mediaTypes[t],c=u.groups,d=u.tracks,h=i.masterPlaylistLoader;for(var f in l[t]){c[f]||(c[f]=[]);for(var b in l[t][f])if(!l[t][f][b].forced){var p=l[t][f][b],m=void 0;if(a==="hls"?m=new kd(p.resolvedUri,n,o):a==="dash"&&(m=new Zh(p.playlists[0],n,o,h)),p=V.mergeOptions({id:b,playlistLoader:m},p),S_[t](t,p.playlistLoader,i),c[f].push(p),typeof d[b]>"u"){var y=r.addRemoteTextTrack({id:b,kind:"subtitles",default:p.default&&p.autoselect,language:p.language,label:b},!1).track;d[b]=y}}}s.on("error",Md[t](t,i))},"CLOSED-CAPTIONS":function(t,i){var r=i.tech,n=i.master.mediaGroups,a=i.mediaTypes[t],s=a.groups,o=a.tracks;for(var l in n[t]){s[l]||(s[l]=[]);for(var u in n[t][l]){var c=n[t][l][u];if(!!c.instreamId.match(/CC\d/)&&(s[l].push(V.mergeOptions({id:u},c)),typeof o[u]>"u")){var d=r.addRemoteTextTrack({id:c.instreamId,kind:"captions",default:c.default&&c.autoselect,language:c.language,label:u},!1).track;o[u]=d}}}}},AC=function(t,i){return function(r){var n=i.masterPlaylistLoader,a=i.mediaTypes[t].groups,s=n.media();if(!s)return null;var o=null;return s.attributes[t]&&(o=a[s.attributes[t]]),o=o||a.main,typeof r>"u"?o:r===null?null:o.filter(function(l){return l.id===r.id})[0]||null}},DC={AUDIO:function(t,i){return function(){var r=i.mediaTypes[t].tracks;for(var n in r)if(r[n].enabled)return r[n];return null}},SUBTITLES:function(t,i){return function(){var r=i.mediaTypes[t].tracks;for(var n in r)if(r[n].mode==="showing")return r[n];return null}}},CC=function(t){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(c){wC[c](c,t)});var i=t.mediaTypes,r=t.masterPlaylistLoader,n=t.tech,a=t.hls;["AUDIO","SUBTITLES"].forEach(function(c){i[c].activeGroup=AC(c,t),i[c].activeTrack=DC[c](c,t),i[c].onGroupChanged=EC(c,t),i[c].onTrackChanged=xC(c,t)});var s=i.AUDIO.activeGroup(),o=(s.filter(function(c){return c.default})[0]||s[0]).id;i.AUDIO.tracks[o].enabled=!0,i.AUDIO.onTrackChanged(),r.on("mediachange",function(){["AUDIO","SUBTITLES"].forEach(function(c){return i[c].onGroupChanged()})});var l=function(){i.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"hls-audio-change"})};n.audioTracks().addEventListener("change",l),n.remoteTextTracks().addEventListener("change",i.SUBTITLES.onTrackChanged),a.on("dispose",function(){n.audioTracks().removeEventListener("change",l),n.remoteTextTracks().removeEventListener("change",i.SUBTITLES.onTrackChanged)}),n.clearTracks("audio");for(var u in i.AUDIO.tracks)n.audioTracks().addTrack(i.AUDIO.tracks[u])},kC=function(){var t={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(i){t[i]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:mo,activeTrack:mo,onGroupChanged:mo,onTrackChanged:mo}}),t},RC=60*2,ba=void 0,PC=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],OC=function(t){return this.audioSegmentLoader_[t]+this.mainSegmentLoader_[t]},LC=function(e){On(t,e);function t(i){ki(this,t);var r=an(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),n=i.url,a=i.handleManifestRedirects,s=i.withCredentials,o=i.tech,l=i.bandwidth,u=i.externHls,c=i.useCueTags,d=i.blacklistDuration,h=i.enableLowInitialPlaylist,f=i.sourceType,b=i.seekTo,p=i.cacheEncryptionKeys;if(!n)throw new Error("A non-empty playlist URL is required");ba=u,r.withCredentials=s,r.tech_=o,r.hls_=o.hls,r.seekTo_=b,r.sourceType_=f,r.useCueTags_=c,r.blacklistDuration=d,r.enableLowInitialPlaylist=h,r.useCueTags_&&(r.cueTagsTrack_=r.tech_.addTextTrack("metadata","ad-cues"),r.cueTagsTrack_.inBandMetadataTrackDispatchType=""),r.requestOptions_={withCredentials:s,handleManifestRedirects:a,timeout:null},r.mediaTypes_=kC(),r.mediaSource=new V.MediaSource,r.mediaSource.addEventListener("sourceopen",r.handleSourceOpen_.bind(r)),r.seekable_=V.createTimeRanges(),r.hasPlayed_=function(){return!1},r.syncController_=new bC(i),r.segmentMetadataTrack_=o.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,r.decrypter_=new TC,r.inbandTextTracks_={};var m={hls:r.hls_,mediaSource:r.mediaSource,currentTime:r.tech_.currentTime.bind(r.tech_),seekable:function(){return r.seekable()},seeking:function(){return r.tech_.seeking()},duration:function(){return r.mediaSource.duration},hasPlayed:function(){return r.hasPlayed_()},goalBufferLength:function(){return r.goalBufferLength()},bandwidth:l,syncController:r.syncController_,decrypter:r.decrypter_,sourceType:r.sourceType_,inbandTextTracks:r.inbandTextTracks_,cacheEncryptionKeys:p};return r.masterPlaylistLoader_=r.sourceType_==="dash"?new Zh(n,r.hls_,r.requestOptions_):new kd(n,r.hls_,r.requestOptions_),r.setupMasterPlaylistLoaderListeners_(),r.mainSegmentLoader_=new rp(V.mergeOptions(m,{segmentMetadataTrack:r.segmentMetadataTrack_,loaderType:"main"}),i),r.audioSegmentLoader_=new rp(V.mergeOptions(m,{loaderType:"audio"}),i),r.subtitleSegmentLoader_=new vC(V.mergeOptions(m,{loaderType:"vtt"}),i),r.setupSegmentLoaderListeners_(),PC.forEach(function(y){r[y+"_"]=OC.bind(r,y)}),r.logger_=Uu("MPC"),r.masterPlaylistLoader_.load(),r}return Hi(t,[{key:"setupMasterPlaylistLoaderListeners_",value:function(){var r=this;this.masterPlaylistLoader_.on("loadedmetadata",function(){var n=r.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;Wh(r.masterPlaylistLoader_.master,r.masterPlaylistLoader_.media())?r.requestOptions_.timeout=0:r.requestOptions_.timeout=a,n.endList&&r.tech_.preload()!=="none"&&(r.mainSegmentLoader_.playlist(n,r.requestOptions_),r.mainSegmentLoader_.load()),CC({sourceType:r.sourceType_,segmentLoaders:{AUDIO:r.audioSegmentLoader_,SUBTITLES:r.subtitleSegmentLoader_,main:r.mainSegmentLoader_},tech:r.tech_,requestOptions:r.requestOptions_,masterPlaylistLoader:r.masterPlaylistLoader_,hls:r.hls_,master:r.master(),mediaTypes:r.mediaTypes_,blacklistCurrentPlaylist:r.blacklistCurrentPlaylist.bind(r)}),r.triggerPresenceUsage_(r.master(),n);try{r.setupSourceBuffers_()}catch(s){return V.log.warn("Failed to create SourceBuffers",s),r.mediaSource.endOfStream("decode")}r.setupFirstPlay(),!r.mediaTypes_.AUDIO.activePlaylistLoader||r.mediaTypes_.AUDIO.activePlaylistLoader.media()?r.trigger("selectedinitialmedia"):r.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",function(){r.trigger("selectedinitialmedia")})}),this.masterPlaylistLoader_.on("loadedplaylist",function(){var n=r.masterPlaylistLoader_.media();if(!n){r.excludeUnsupportedVariants_();var a=void 0;r.enableLowInitialPlaylist&&(a=r.selectInitialPlaylist()),a||(a=r.selectPlaylist()),r.initialMedia_=a,r.masterPlaylistLoader_.media(r.initialMedia_);return}if(r.useCueTags_&&r.updateAdCues_(n),r.mainSegmentLoader_.playlist(n,r.requestOptions_),r.updateDuration(),r.tech_.paused()||(r.mainSegmentLoader_.load(),r.audioSegmentLoader_&&r.audioSegmentLoader_.load()),!n.endList){var s=function(){var u=r.seekable();u.length!==0&&r.mediaSource.addSeekableRange_(u.start(0),u.end(0))};if(r.duration()!==1/0){var o=function l(){r.duration()===1/0?s():r.tech_.one("durationchange",l)};r.tech_.one("durationchange",o)}else s()}}),this.masterPlaylistLoader_.on("error",function(){r.blacklistCurrentPlaylist(r.masterPlaylistLoader_.error)}),this.masterPlaylistLoader_.on("mediachanging",function(){r.mainSegmentLoader_.abort(),r.mainSegmentLoader_.pause()}),this.masterPlaylistLoader_.on("mediachange",function(){var n=r.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;Wh(r.masterPlaylistLoader_.master,r.masterPlaylistLoader_.media())?r.requestOptions_.timeout=0:r.requestOptions_.timeout=a,r.mainSegmentLoader_.playlist(n,r.requestOptions_),r.mainSegmentLoader_.load(),r.tech_.trigger({type:"mediachange",bubbles:!0})}),this.masterPlaylistLoader_.on("playlistunchanged",function(){var n=r.masterPlaylistLoader_.media(),a=r.stuckAtPlaylistEnd_(n);a&&(r.blacklistCurrentPlaylist({message:"Playlist no longer updating."}),r.tech_.trigger("playliststuck"))}),this.masterPlaylistLoader_.on("renditiondisabled",function(){r.tech_.trigger({type:"usage",name:"hls-rendition-disabled"})}),this.masterPlaylistLoader_.on("renditionenabled",function(){r.tech_.trigger({type:"usage",name:"hls-rendition-enabled"})})}},{key:"triggerPresenceUsage_",value:function(r,n){var a=r.mediaGroups||{},s=!0,o=Object.keys(a.AUDIO);for(var l in a.AUDIO)for(var u in a.AUDIO[l]){var c=a.AUDIO[l][u];c.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"}),ba.Playlist.isAes(n)&&this.tech_.trigger({type:"usage",name:"hls-aes"}),ba.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 r=this;this.mainSegmentLoader_.on("bandwidthupdate",function(){var n=r.selectPlaylist(),a=r.masterPlaylistLoader_.media(),s=r.tech_.buffered(),o=s.length?s.end(s.length-1)-r.tech_.currentTime():0,l=r.bufferLowWaterLine();(!a.endList||r.duration()<yi.MAX_BUFFER_LOW_WATER_LINE||n.attributes.BANDWIDTH<a.attributes.BANDWIDTH||o>=l)&&r.masterPlaylistLoader_.media(n),r.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("progress",function(){r.trigger("progress")}),this.mainSegmentLoader_.on("error",function(){r.blacklistCurrentPlaylist(r.mainSegmentLoader_.error())}),this.mainSegmentLoader_.on("syncinfoupdate",function(){r.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",function(){r.tech_.trigger({type:"usage",name:"hls-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",function(){r.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("ended",function(){r.onEndOfStream()}),this.mainSegmentLoader_.on("earlyabort",function(){r.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},RC)}),this.mainSegmentLoader_.on("reseteverything",function(){r.tech_.trigger("hls-reset")}),this.mainSegmentLoader_.on("segmenttimemapping",function(n){r.tech_.trigger({type:"hls-segment-time-mapping",mapping:n.mapping})}),this.audioSegmentLoader_.on("ended",function(){r.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 r=this.selectPlaylist();r!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(r),this.mainSegmentLoader_.resetLoader())}},{key:"fastQualityChange_",value:function(){var r=this,n=this.selectPlaylist();n!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(n),this.mainSegmentLoader_.resetEverything(function(){V.browser.IE_VERSION||V.browser.IS_EDGE?r.tech_.setCurrentTime(r.tech_.currentTime()+.04):r.tech_.setCurrentTime(r.tech_.currentTime())}))}},{key:"play",value:function(){if(!this.setupFirstPlay()){this.tech_.ended()&&this.seekTo_(0),this.hasPlayed_()&&this.load();var r=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<r.start(0))return this.seekTo_(r.end(r.length-1))}}},{key:"setupFirstPlay",value:function(){var r=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(V.browser.IE_VERSION&&this.tech_.readyState()===0)return this.tech_.one("loadedmetadata",function(){r.trigger("firstplay"),r.seekTo_(a.end(0)),r.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 V.log.warn("Failed to create Source Buffers",n),this.mediaSource.endOfStream("decode")}if(this.tech_.autoplay()){var r=this.tech_.play();typeof r<"u"&&typeof r.then=="function"&&r.then(null,function(n){})}this.trigger("sourceopen")}},{key:"onEndOfStream",value:function(){var r=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(!this.mainSegmentLoader_.startingMedia_||this.mainSegmentLoader_.startingMedia_.containsVideo?r=r&&this.audioSegmentLoader_.ended_:r=this.audioSegmentLoader_.ended_),!!r){this.logger_("calling mediaSource.endOfStream()");try{this.mediaSource.endOfStream()}catch(n){V.log.warn("Failed to call media source endOfStream",n)}}}},{key:"stuckAtPlaylistEnd_",value:function(r){var n=this.seekable();if(!n.length)return!1;var a=this.syncController_.getExpiredTime(r,this.mediaSource.duration);if(a===null)return!1;var s=ba.Playlist.playlistEnd(r,a),o=this.tech_.currentTime(),l=this.tech_.buffered();if(!l.length)return s-o<=Ln;var u=l.end(l.length-1);return u-o<=Ln&&s-u<=Ln}},{key:"blacklistCurrentPlaylist",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments[1],a=void 0,s=void 0;if(a=r.playlist||this.masterPlaylistLoader_.media(),n=n||r.blacklistDuration||this.blacklistDuration,!a){this.error=r;try{return this.mediaSource.endOfStream("network")}catch{return this.trigger("error")}}var o=this.masterPlaylistLoader_.master.playlists.filter(Rd).length===1,l=this.masterPlaylistLoader_.master.playlists;return l.length===1?(V.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&&(V.log.warn("Removing all playlists from the blacklist because the last rendition is about to be blacklisted."),l.forEach(function(u){u.excludeUntil!==1/0&&delete u.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(),V.log.warn("Problem encountered with the current HLS playlist."+(r.message?" "+r.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(r){var n=Jy(this.tech_.buffered(),r);if(!(this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media())||!this.masterPlaylistLoader_.media().segments)return 0;if(n&&n.length)return r;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:ba.Playlist.duration(this.masterPlaylistLoader_.media()):0}},{key:"seekable",value:function(){return this.seekable_}},{key:"onSyncInfoUpdate_",value:function(){var r=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&&(r=ba.Playlist.seekable(a,s),r.length!==0&&!(this.mediaTypes_.AUDIO.activePlaylistLoader&&(a=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),s=this.syncController_.getExpiredTime(a,this.mediaSource.duration),s===null||(n=ba.Playlist.seekable(a,s),n.length===0))))){var o=void 0,l=void 0;this.seekable_&&this.seekable_.length&&(o=this.seekable_.end(0),l=this.seekable_.start(0)),n?n.start(0)>r.end(0)||r.start(0)>n.end(0)?this.seekable_=r:this.seekable_=V.createTimeRanges([[n.start(0)>r.start(0)?n.start(0):r.start(0),n.end(0)<r.end(0)?n.end(0):r.end(0)]]):this.seekable_=r,!(this.seekable_&&this.seekable_.length&&this.seekable_.end(0)===o&&this.seekable_.start(0)===l)&&(this.logger_("seekable updated ["+Kh(this.seekable_)+"]"),this.tech_.trigger("seekablechanged"))}}}}},{key:"updateDuration",value:function(){var r=this,n=this.mediaSource.duration,a=ba.Playlist.duration(this.masterPlaylistLoader_.media()),s=this.tech_.buffered(),o=function l(){r.logger_("Setting duration from "+r.mediaSource.duration+" => "+a);try{r.mediaSource.duration=a}catch(u){V.log.warn("Failed to set media source duration",u)}r.tech_.trigger("durationchange"),r.mediaSource.removeEventListener("sourceopen",l)};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 r=this;this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),["AUDIO","SUBTITLES"].forEach(function(n){var a=r.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 r=this.masterPlaylistLoader_.media(),n=void 0;if(!(!r||this.mediaSource.readyState!=="open")){if(n=FD(this.masterPlaylistLoader_.master,r),n.length<1)return this.error="No compatible SourceBuffer configuration for the variant stream:"+r.resolvedUri,this.mediaSource.endOfStream("decode");this.configureLoaderMimeTypes_(n),this.excludeIncompatibleVariants_(r)}}},{key:"configureLoaderMimeTypes_",value:function(r){var n=r.length>1&&r[0].indexOf(",")===-1&&r[0]!==r[1]?new V.EventTarget:null;this.mainSegmentLoader_.mimeType(r[0],n),r[1]&&this.audioSegmentLoader_.mimeType(r[1],n)}},{key:"excludeUnsupportedVariants_",value:function(){this.master().playlists.forEach(function(r){r.attributes.CODECS&&pe.MediaSource&&pe.MediaSource.isTypeSupported&&!pe.MediaSource.isTypeSupported('video/mp4; codecs="'+LD(r.attributes.CODECS)+'"')&&(r.excludeUntil=1/0)})}},{key:"excludeIncompatibleVariants_",value:function(r){var n=2,a=null,s=void 0;r.attributes.CODECS&&(s=Nu(r.attributes.CODECS),a=s.videoCodec,n=s.codecCount),this.master().playlists.forEach(function(o){var l={codecCount:2,videoCodec:null};o.attributes.CODECS&&(l=Nu(o.attributes.CODECS)),l.codecCount!==n&&(o.excludeUntil=1/0),l.videoCodec!==a&&(o.excludeUntil=1/0)})}},{key:"updateAdCues_",value:function(r){var n=0,a=this.seekable();a.length&&(n=a.start(0)),yC(r,this.cueTagsTrack_,n)}},{key:"goalBufferLength",value:function(){var r=this.tech_.currentTime(),n=yi.GOAL_BUFFER_LENGTH,a=yi.GOAL_BUFFER_LENGTH_RATE,s=Math.max(n,yi.MAX_GOAL_BUFFER_LENGTH);return Math.min(n+r*a,s)}},{key:"bufferLowWaterLine",value:function(){var r=this.tech_.currentTime(),n=yi.BUFFER_LOW_WATER_LINE,a=yi.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(n,yi.MAX_BUFFER_LOW_WATER_LINE);return Math.min(n+r*a,s)}}]),t}(V.EventTarget),IC=function(t,i,r){return function(n){var a=t.master.playlists[i],s=Vh(a),o=Rd(a);return typeof n>"u"?o:(n?delete a.disabled:a.disabled=!0,n!==o&&!s&&(r(),n?t.trigger("renditionenabled"):t.trigger("renditiondisabled")),n)}},MC=function e(t,i,r){ki(this,e);var n=t.masterPlaylistController_,a=t.options_.smoothQualityChange,s=a?"smooth":"fast",o=n[s+"QualityChange_"].bind(n);if(i.attributes.RESOLUTION){var l=i.attributes.RESOLUTION;this.width=l.width,this.height=l.height}this.bandwidth=i.attributes.BANDWIDTH,this.id=r,this.enabled=IC(t.playlists,i.uri,o)},NC=function(t){var i=t.playlists;t.representations=function(){return i.master.playlists.filter(function(r){return!Vh(r)}).map(function(r,n){return new MC(t,r,r.uri)})}},E_=["seeking","seeked","pause","playing","error"],FC=function(){function e(t){var i=this;ki(this,e),this.tech_=t.tech,this.seekable=t.seekable,this.seekTo=t.seekTo,this.allowSeeksWithinUnsafeLiveWindow=t.allowSeeksWithinUnsafeLiveWindow,this.media=t.media,this.consecutiveUpdates=0,this.lastRecordedTime=null,this.timer_=null,this.checkCurrentTimeTimeout_=null,this.logger_=Uu("PlaybackWatcher"),this.logger_("initialize");var r=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(E_,a),this.tech_.on("canplay",r),this.dispose=function(){i.logger_("dispose"),i.tech_.off("seekablechanged",s),i.tech_.off("waiting",n),i.tech_.off(E_,a),i.tech_.off("canplay",r),i.checkCurrentTimeTimeout_&&pe.clearTimeout(i.checkCurrentTimeTimeout_),i.cancelTimer_()}}return Hi(e,[{key:"monitorCurrentTime_",value:function(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&pe.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=pe.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(),r=this.tech_.buffered();if(this.lastRecordedTime===i&&(!r.length||i+Ln>=r.end(r.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 r=this.seekable(),n=this.tech_.currentTime(),a=this.afterSeekableWindow_(r,n,this.media(),this.allowSeeksWithinUnsafeLiveWindow),s=void 0;if(a){var o=r.end(r.length-1);s=o}if(this.beforeSeekableWindow_(r,n)){var l=r.start(0);s=l+Ln}return typeof s<"u"?(this.logger_("Trying to seek outside of seekable at time "+n+" with "+("seekable range "+Kh(r)+". Seeking to ")+(s+".")),this.seekTo(s),!0):!1}},{key:"waiting_",value:function(){if(!this.techWaiting_()){var i=this.tech_.currentTime(),r=this.tech_.buffered(),n=Jy(r,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(),r=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_()||this.tech_.seeking()||this.timer_!==null)return!0;if(this.beforeSeekableWindow_(i,r)){var n=i.end(i.length-1);return this.logger_("Fell out of live window at time "+r+". 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=Qy(a,r);if(this.videoUnderflow_(s,a,r))return this.cancelTimer_(),this.seekTo(r),this.tech_.trigger({type:"usage",name:"hls-video-underflow"}),!0;if(s.length>0){var o=s.start(0)-r;return this.logger_("Stopped at "+r+", setting timer for "+o+", seeking "+("to "+s.start(0))),this.timer_=setTimeout(this.skipTheGap_.bind(this),o*1e3,r),!0}return!1}},{key:"afterSeekableWindow_",value:function(i,r,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)+Ln,o=!n.endList;return o&&a&&(s=i.end(i.length-1)+n.targetDuration*3),r>s}},{key:"beforeSeekableWindow_",value:function(i,r){return!!(i.length&&i.start(0)>0&&r<i.start(0)-Ln)}},{key:"videoUnderflow_",value:function(i,r,n){if(i.length===0){var a=this.gapFromVideoUnderflow_(r,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 r=this.tech_.buffered(),n=this.tech_.currentTime(),a=Qy(r,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)+Od),this.tech_.trigger({type:"usage",name:"hls-gap-skip"}))}},{key:"gapFromVideoUnderflow_",value:function(i,r){for(var n=xD(i),a=0;a<n.length;a++){var s=n.start(a),o=n.end(a);if(r-s<4&&r-s>2)return{start:s,end:o}}return null}}]),e}(),UC={errorInterval:30,getSource:function(t){var i=this.tech({IWillNotUseThisInPlugins:!0}),r=i.currentSource_;return t(r)}},BC=function e(t,i){var r=0,n=0,a=V.mergeOptions(UC,i);t.ready(function(){t.trigger({type:"usage",name:"hls-error-reload-initialized"})});var s=function(){n&&t.currentTime(n)},o=function(h){h!=null&&(n=t.duration()!==1/0&&t.currentTime()||0,t.one("loadedmetadata",s),t.src(h),t.trigger({type:"usage",name:"hls-error-reload"}),t.play())},l=function(){if(Date.now()-r<a.errorInterval*1e3){t.trigger({type:"usage",name:"hls-error-reload-canceled"});return}if(!a.getSource||typeof a.getSource!="function"){V.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return r=Date.now(),a.getSource.call(t,o)},u=function d(){t.off("loadedmetadata",s),t.off("error",l),t.off("dispose",d)},c=function(h){u(),e(t,h)};t.on("error",l),t.on("dispose",u),t.reloadSourceOnError=c},x_=function(t){BC(this,t)},jC="1.10.6";V.use("*",function(e){return{setSource:function(i,r){r(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 hi={PlaylistLoader:kd,Playlist:fi,Decrypter:_A,AsyncStream:Km,decrypt:$m,utils:gD,STANDARD_PLAYLIST_SELECTOR:sC,INITIAL_PLAYLIST_SELECTOR:uC,comparePlaylistBandwidth:tp,comparePlaylistResolution:nC,xhr:Wy()};["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(hi,e,{get:function(){return V.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),yi[e]},set:function(i){if(V.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),typeof i!="number"||i<0){V.log.warn("value of Hls."+e+" must be greater than or equal to 0");return}yi[e]=i}})});var w_="videojs-vhs",A_=function(t){var i=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;if(i.test(t))return"hls";var r=/^application\/dash\+xml/i;return r.test(t)?"dash":null},D_=function(t,i){for(var r=i.media(),n=-1,a=0;a<t.length;a++)if(t[a].id===r.uri){n=a;break}t.selectedIndex_=n,t.trigger({selectedIndex:n,type:"change"})},GC=function(t,i){i.representations().forEach(function(r){t.addQualityLevel(r)}),D_(t,i.playlists)};hi.canPlaySource=function(){return V.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var HC=function(t,i,r){if(!t)return t;var n={};for(var a in t)n[a]={audioContentType:'audio/mp4; codecs="'+r.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 t[a]=="string"&&(n[a].url=t[a]);return V.mergeOptions(t,n)},qC=function(t){if(t.options_.sourceType==="dash"){var i=V.players[t.tech_.options_.playerId];if(i.eme){var r=HC(t.source_.keySystems,t.playlists.media(),t.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader.media());r&&(i.currentSource().keySystems=r,i.eme.initializeMediaKeys&&i.eme.initializeMediaKeys())}}},C_=function(){if(!window.localStorage)return null;var t=window.localStorage.getItem(w_);if(!t)return null;try{return JSON.parse(t)}catch{return null}},VC=function(t){if(!window.localStorage)return!1;var i=C_();i=i?V.mergeOptions(i,t):t;try{window.localStorage.setItem(w_,JSON.stringify(i))}catch{return!1}return i};hi.supportsNativeHls=function(){var e=$e.createElement("video");if(!V.getTech("Html5").isSupported())return!1;var t=["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"];return t.some(function(i){return/maybe|probably/i.test(e.canPlayType(i))})}(),hi.supportsNativeDash=function(){return V.getTech("Html5").isSupported()?/maybe|probably/i.test($e.createElement("video").canPlayType("application/dash+xml")):!1}(),hi.supportsTypeNatively=function(e){return e==="hls"?hi.supportsNativeHls:e==="dash"?hi.supportsNativeDash:!1},hi.isSupported=function(){return V.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var WC=V.getComponent("Component"),k_=function(e){On(t,e);function t(i,r,n){ki(this,t);var a=an(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,r,n.hls));if(r.options_&&r.options_.playerId){var s=V(r.options_.playerId);s.hasOwnProperty("hls")||Object.defineProperty(s,"hls",{get:function(){return V.log.warn("player.hls is deprecated. Use player.tech().hls instead."),r.trigger({type:"usage",name:"hls-player-access"}),a},configurable:!0}),s.vhs=a,s.dash=a,a.player_=s}if(a.tech_=r,a.source_=i,a.stats={},a.setOptions_(),a.options_.overrideNative&&r.overrideNativeAudioTracks&&r.overrideNativeVideoTracks)r.overrideNativeAudioTracks(!0),r.overrideNativeVideoTracks(!0);else if(a.options_.overrideNative&&(r.featuresNativeVideoTracks||r.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 l=$e.fullscreenElement||$e.webkitFullscreenElement||$e.mozFullScreenElement||$e.msFullscreenElement;l&&l.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 Hi(t,[{key:"setOptions_",value:function(){var r=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=C_();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=yi.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===yi.INITIAL_BANDWIDTH,["withCredentials","limitRenditionByPlayerDimensions","bandwidth","smoothQualityChange","customTagParsers","customTagMappers","handleManifestRedirects","cacheEncryptionKeys"].forEach(function(a){typeof r.source_[a]<"u"&&(r.options_[a]=r.source_[a])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions}},{key:"src",value:function(r,n){var a=this;!r||(this.setOptions_(),this.options_.url=this.source_.src,this.options_.tech=this.tech_,this.options_.externHls=hi,this.options_.sourceType=A_(n),this.options_.seekTo=function(s){a.tech_.setCurrentTime(s),a.setCurrentTime(s)},this.masterPlaylistController_=new LC(this.options_),this.playbackWatcher_=new FC(V.mergeOptions(this.options_,{seekable:function(){return a.seekable()},media:function(){return a.masterPlaylistController_.media()}})),this.masterPlaylistController_.on("error",function(){var s=V.players[a.tech_.options_.playerId];s.error(a.masterPlaylistController_.error)}),this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):hi.STANDARD_PLAYLIST_SELECTOR.bind(this),this.masterPlaylistController_.selectInitialPlaylist=hi.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),l=void 0;this.throughput>0?l=1/this.throughput:l=0;var u=Math.floor(1/(o+l));return u},set:function(){V.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 Zy(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 Zy(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&&VC({bandwidth:a.bandwidth,throughput:Math.round(a.throughput)})}),this.masterPlaylistController_.on("selectedinitialmedia",function(){NC(a),qC(a)}),this.on(this.masterPlaylistController_,"progress",function(){this.tech_.trigger("progress")}),this.tech_.ready(function(){return a.setupQualityLevels_()}),this.tech_.el()&&this.tech_.src(V.URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var r=this,n=V.players[this.tech_.options_.playerId];n&&n.qualityLevels&&(this.qualityLevels_=n.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",function(){GC(r.qualityLevels_,r)}),this.playlists.on("mediachange",function(){D_(r.qualityLevels_,r.playlists)}))}},{key:"play",value:function(){this.masterPlaylistController_.play()}},{key:"setCurrentTime",value:function(r){this.masterPlaylistController_.setCurrentTime(r)}},{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,W1(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"dispose",this).call(this)}},{key:"convertToProgramTime",value:function(r,n){return SD({playlist:this.masterPlaylistController_.media(),time:r,callback:n})}},{key:"seekToProgramTime",value:function(r,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 ED({programTime:r,playlist:this.masterPlaylistController_.media(),retryCount:s,pauseAfterSeek:a,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:n})}}]),t}(WC),np={name:"videojs-http-streaming",VERSION:jC,canHandleSource:function(t){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=V.mergeOptions(V.options,i);return np.canPlayType(t.type,r)},handleSource:function(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=V.mergeOptions(V.options,r);return i.hls=new k_(t,i,n),i.hls.xhr=Wy(),i.hls.src(t.src,t.type),i.hls},canPlayType:function(t){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=V.mergeOptions(V.options,i),n=r.hls.overrideNative,a=A_(t),s=a&&(!hi.supportsTypeNatively(a)||n);return s?"maybe":""}};(typeof V.MediaSource>"u"||typeof V.URL>"u")&&(V.MediaSource=Fu,V.URL=c_),Fu.supportsNativeMediaSources()&&V.getTech("Html5").registerSourceHandler(np,0),V.HlsHandler=k_,V.HlsSourceHandler=np,V.Hls=hi,V.use||V.registerComponent("Hls",hi),V.options.hls=V.options.hls||{},V.registerPlugin?V.registerPlugin("reloadSourceOnError",x_):V.plugin("reloadSourceOnError",x_);const YC=Object.freeze(Object.defineProperty({__proto__:null,default:V},Symbol.toStringTag,{value:"Module"})),R_={name:"stream-engine-player",version:"0.0.41",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 Gr=[];for(let e=0;e<256;++e)Gr.push((e+256).toString(16).slice(1));function KC(e,t=0){return(Gr[e[t+0]]+Gr[e[t+1]]+Gr[e[t+2]]+Gr[e[t+3]]+"-"+Gr[e[t+4]]+Gr[e[t+5]]+"-"+Gr[e[t+6]]+Gr[e[t+7]]+"-"+Gr[e[t+8]]+Gr[e[t+9]]+"-"+Gr[e[t+10]]+Gr[e[t+11]]+Gr[e[t+12]]+Gr[e[t+13]]+Gr[e[t+14]]+Gr[e[t+15]]).toLowerCase()}var ap,$C=new Uint8Array(16);function zC(){if(!ap){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ap=crypto.getRandomValues.bind(crypto)}return ap($C)}var XC=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),P_={randomUUID:XC};function JC(e,t,i){var n,a,s;if(P_.randomUUID&&!t&&!e)return P_.randomUUID();e=e||{};let r=(s=(a=e.random)!=null?a:(n=e.rng)==null?void 0:n.call(e))!=null?s:zC();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(i=i||0,i<0||i+16>t.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);for(let o=0;o<16;++o)t[i+o]=r[o];return t}return KC(r)}var QC=JC,O_="000000",L_=function(){let e=Math.random().toString(36).replace("0.","").slice(0,6);return O_.slice(e.length)+e},yo=function(){return QC()},ZC=function(){return(O_+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},sp=e=>{if(!e)return["localhost","localhost"];try{let t=new URL(e).hostname,i=t.split("."),r=i.length>=2?i.slice(-2).join("."):t;return[t,r]}catch{}return["localhost","localhost"]},sn=e=>sp(e)[0],op=e=>sp(e)[1],ek=e=>{var t,i;if(e&&e.nodeName)return(t=e.uniqueId)!=null?t:e.uniqueId=L_();try{let r=document.querySelector(e);return r&&!r.uniqueId&&(r.uniqueId=e),(i=r==null?void 0:r.uniqueId)!=null?i:e}catch{}return e},tk=e=>{var r;let t=null;e&&e.nodeName!==void 0?(t=e,e=ek(t)):t=document.querySelector(e);let i=((r=t==null?void 0:t.nodeName)==null?void 0:r.toLowerCase())||"";return[t,e,i]},I_=e=>{var i,r;let t=null;if(e&&e.nodeName!==void 0)return(i=e.elementId)!=null||(e.elementId=ZC()),e.elementId;try{t=document.querySelector(e)}catch{}return t&&!t.elementId&&(t.elementId=e),(r=t==null?void 0:t.elementId)!=null?r:e};function rk(...e){return e.reduce((t,i)=>{for(let[r,n]of Object.entries(i))n!==void 0&&(t[r]=n);return t},{})}function Nd(e,t,i=1){var r;e[t]=((r=e[t])!=null?r:0)+i}function ik(e,t){let{beaconDomain:i}=t;return`https://${e!=null?e:"collector"}.${i!=null?i:"metrix.ws"}`}function M_(){var t,i;let e=(i=(t=navigator.doNotTrack)!=null?t:window.doNotTrack)!=null?i:navigator.msDoNotTrack;return e==="1"||e==="yes"}var nk=class{constructor(){this.events={}}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}off(e,t){this.events[e]&&(this.events[e]=this.events[e].filter(i=>i!==t))}emit(e,t){this.events[e]&&this.events[e].forEach(i=>{i(t)})}},Ta={now:function(){return typeof Date.now=="function"?Date.now():new Date().getTime()}},Fd={isPerformanceAvailable:function(){let e=window.performance;return e&&e.timing!==void 0},getDomContentLoadedEnd:function(){var t;let e=(t=window.performance)==null?void 0:t.timing;return e?e.domContentLoadedEventEnd:null},getNavigationStartTime:function(){var t;let e=(t=window.performance)==null?void 0:t.timing;return e?e.navigationStart:null}};function ak(e){if(!e)return{};let t=Fd.getNavigationStartTime(),{loading:i,trequest:r,tfirst:n,tload:a,total:s}=e,o=i?i.start:r,l=i?i.first:n,u=i?i.end:a;return{bytesLoaded:s,requestStart:Math.round(t+o),responseStart:Math.round(t+l),responseEnd:Math.round(t+u)}}var sk=()=>{var t,i,r;let e=navigator;return(r=(i=(t=e==null?void 0:e.connection)!=null?t:e==null?void 0:e.mozConnection)!=null?i:e==null?void 0:e.webkitConnection)==null?void 0:r.type},ok=()=>{switch(sk()){case"cellular":return"cellular";case"ethernet":return"wired";case"wifi":return"wifi";case void 0:break;default:return"other"}},uk=["x-cdn","content-type","content-length","last-modified","server","x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"];function lk(e){let t={},i=new Set(uk.map(r=>r.toLowerCase()));return!e||typeof e!="string"?{}:(e.trim().split(/[\r\n]+/).forEach(r=>{let[n,...a]=r.split(": "),s=a.join(": ");n&&i.has(n.toLowerCase())&&(t[n]=s)}),t)}var Ud=function(e){if(e&&typeof e.getAllResponseHeaders=="function")return lk(e.getAllResponseHeaders())},dk={convertSecToMs:function(e){return Math.floor(1e3*e)},isolateHostAndDomainName:sp,fetchDomain:op,fetchHost:sn,generateIdToken:L_,buildUUID:yo,now:Ta.now};function ck(e){let t=(window==null?void 0:window.URL)||(window==null?void 0:window.webkitURL),i=window==null?void 0:window.Blob,r=window==null?void 0:window.Worker;if(!t||!i||!r||!e)return null;let n=new i([e]);return new r(t.createObjectURL(n))}var fk=`
88
+ `.split("").map(function(e){return e.charCodeAt(0)})),vC=function(e){On(t,e);function t(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};ki(this,t);var n=an(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,i,r));return n.mediaSource_=null,n.subtitlesTrack_=null,n}return Hi(t,[{key:"buffered_",value:function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return V.createTimeRanges();var r=this.subtitlesTrack_.cues,n=r[0].startTime,a=r[r.length-1].startTime;return V.createTimeRanges([[n,a]])}},{key:"initSegment",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!r)return null;var a=Pd(r),s=this.initSegments_[a];if(n&&!s&&r.bytes){var o=b_.byteLength+r.bytes.byteLength,l=new Uint8Array(o);l.set(r.bytes),l.set(b_,r.bytes.byteLength),this.initSegments_[a]=s={resolvedUri:r.resolvedUri,byterange:r.byterange,bytes:l}}return s||r}},{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(r){return typeof r>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=r,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}},{key:"remove",value:function(r,n){ho(r,n,this.subtitlesTrack_)}},{key:"fillBuffer_",value:function(){var r=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(){r.state="READY",r.paused()||r.monitorBuffer_()};this.syncController_.one("timestampoffset",a),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(n)}}},{key:"skipEmptySegments_",value:function(r){for(;r&&r.segment.empty;)r=this.generateSegmentInfo_(r.playlist,r.mediaIndex+1,r.startOfSegment+r.duration,r.isSyncRequest);return r}},{key:"handleSegment_",value:function(){var r=this;if(!this.pendingSegment_||!this.subtitlesTrack_){this.state="READY";return}this.state="APPENDING";var n=this.pendingSegment_,a=n.segment;if(typeof pe.WebVTT!="function"&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var s=void 0,o=function(){r.subtitlesTrack_.tech_.off("vttjsloaded",s),r.error({message:"Error loading vtt.js"}),r.state="READY",r.pause(),r.trigger("error")};s=function(){r.subtitlesTrack_.tech_.off("vttjserror",o),r.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(l){return this.error({message:l.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(l){r.subtitlesTrack_.addCue(l)}),this.handleUpdateEnd_()}},{key:"parseVTTCues_",value:function(r){var n=void 0,a=!1;typeof pe.TextDecoder=="function"?n=new pe.TextDecoder("utf8"):(n=pe.WebVTT.StringDecoder(),a=!0);var s=new pe.WebVTT.Parser(pe,pe.vttjs,n);if(r.cues=[],r.timestampmap={MPEGTS:0,LOCAL:0},s.oncue=r.cues.push.bind(r.cues),s.ontimestampmap=function(u){return r.timestampmap=u},s.onparsingerror=function(u){V.log.warn("Error encountered when parsing cues: "+u.message)},r.segment.map){var o=r.segment.map.bytes;a&&(o=__(o)),s.parse(o)}var l=r.bytes;a&&(l=__(l)),s.parse(l),s.flush()}},{key:"updateTimeMapping_",value:function(r,n,a){var s=r.segment;if(!!n){if(!r.cues.length){s.empty=!0;return}var o=r.timestampmap,l=o.MPEGTS/9e4-o.LOCAL+n.mapping;if(r.cues.forEach(function(d){d.startTime+=l,d.endTime+=l}),!a.syncInfo){var u=r.cues[0].startTime,c=r.cues[r.cues.length-1].startTime;a.syncInfo={mediaSequence:a.mediaSequence+r.mediaIndex,time:Math.min(u,c-s.duration)}}}}}]),t}(rp),mC=function(t,i){for(var r=t.cues,n=0;n<r.length;n++){var a=r[n];if(i>=a.adStartTime&&i<=a.adEndTime)return a}return null},yC=function(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!!t.segments)for(var n=r,a=void 0,s=0;s<t.segments.length;s++){var o=t.segments[s];if(a||(a=mC(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 pe.VTTCue(n,n+o.duration,o.cueOut),a.adStartTime=n,a.adEndTime=n+parseFloat(o.cueOut),i.addCue(a)),"cueOutCont"in o){var l=void 0,u=void 0,c=o.cueOutCont.split("/").map(parseFloat),d=Y1(c,2);l=d[0],u=d[1],a=new pe.VTTCue(n,n+o.duration,""),a.adStartTime=n-l,a.adEndTime=a.adStartTime+u,i.addCue(a)}n+=o.duration}},_C=fA.inspect,T_=[{name:"VOD",run:function(t,i,r,n,a){if(r!==1/0){var s={time:0,segmentIndex:0};return s}return null}},{name:"ProgramDateTime",run:function(t,i,r,n,a){if(!t.datetimeToDisplayTime)return null;var s=i.segments||[],o=null,l=null;a=a||0;for(var u=0;u<s.length;u++){var c=s[u];if(c.dateTimeObject){var d=c.dateTimeObject.getTime()/1e3,h=d+t.datetimeToDisplayTime,f=Math.abs(a-h);if(l!==null&&(f===0||l<f))break;l=f,o={time:h,segmentIndex:u}}}return o}},{name:"Segment",run:function(t,i,r,n,a){var s=i.segments||[],o=null,l=null;a=a||0;for(var u=0;u<s.length;u++){var c=s[u];if(c.timeline===n&&typeof c.start<"u"){var d=Math.abs(a-c.start);if(l!==null&&l<d)break;(!o||l===null||l>=d)&&(l=d,o={time:c.start,segmentIndex:u})}}return o}},{name:"Discontinuity",run:function(t,i,r,n,a){var s=null;if(a=a||0,i.discontinuityStarts&&i.discontinuityStarts.length)for(var o=null,l=0;l<i.discontinuityStarts.length;l++){var u=i.discontinuityStarts[l],c=i.discontinuitySequence+l+1,d=t.discontinuities[c];if(d){var h=Math.abs(a-d.time);if(o!==null&&o<h)break;(!s||o===null||o>=h)&&(o=h,s={time:d.time,segmentIndex:u})}}return s}},{name:"Playlist",run:function(t,i,r,n,a){if(i.syncInfo){var s={time:i.syncInfo.time,segmentIndex:i.syncInfo.mediaSequence-i.mediaSequence};return s}return null}}],bC=function(e){On(t,e);function t(){ki(this,t);var i=an(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return i.inspectCache_=void 0,i.timelines=[],i.discontinuities=[],i.datetimeToDisplayTime=null,i.logger_=Uu("SyncController"),i}return Hi(t,[{key:"getSyncPoint",value:function(r,n,a,s){var o=this.runStrategies_(r,n,a,s);return o.length?this.selectSyncPoint_(o,{key:"time",value:s}):null}},{key:"getExpiredTime",value:function(r,n){if(!r||!r.segments)return null;var a=this.runStrategies_(r,n,r.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+Mu(r,s.segmentIndex,0))}},{key:"runStrategies_",value:function(r,n,a,s){for(var o=[],l=0;l<T_.length;l++){var u=T_[l],c=u.run(this,r,n,a,s);c&&(c.strategy=u.name,o.push({strategy:u.name,syncPoint:c}))}return o}},{key:"selectSyncPoint_",value:function(r,n){for(var a=r[0].syncPoint,s=Math.abs(r[0].syncPoint[n.key]-n.value),o=r[0].strategy,l=1;l<r.length;l++){var u=Math.abs(r[l].syncPoint[n.key]-n.value);u<s&&(s=u,a=r[l].syncPoint,o=r[l].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(r,n){for(var a=n.mediaSequence-r.mediaSequence,s=a-1;s>=0;s--){var o=r.segments[s];if(o&&typeof o.start<"u"){n.syncInfo={mediaSequence:r.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(r){if(!this.datetimeToDisplayTime&&r.segments&&r.segments.length&&r.segments[0].dateTimeObject){var n=r.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-n}}},{key:"reset",value:function(){this.inspectCache_=void 0}},{key:"probeSegmentInfo",value:function(r){var n=r.segment,a=r.playlist,s=void 0;return n.map?s=this.probeMp4Segment_(r):s=this.probeTsSegment_(r),s&&this.calculateSegmentTimeMapping_(r,s)&&(this.saveDiscontinuitySyncInfo_(r),a.syncInfo||(a.syncInfo={mediaSequence:a.mediaSequence+r.mediaIndex,time:n.start})),s}},{key:"probeMp4Segment_",value:function(r){var n=r.segment,a=Xl.timescale(n.map.bytes),s=Xl.startTime(a,r.bytes);return r.timestampOffset!==null&&(r.timestampOffset-=s),{start:s,end:s+n.duration}}},{key:"probeTsSegment_",value:function(r){var n=_C(r.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 l={segmentTimestampInfo:o,start:a,end:s,containsVideo:n.video&&n.video.length===2,containsAudio:n.audio&&n.audio.length===2};return l}},{key:"timestampOffsetForTimeline",value:function(r){return typeof this.timelines[r]>"u"?null:this.timelines[r].time}},{key:"mappingForTimeline",value:function(r){return typeof this.timelines[r]>"u"?null:this.timelines[r].mapping}},{key:"calculateSegmentTimeMapping_",value:function(r,n){var a=r.segment,s=this.timelines[r.timeline];if(r.timestampOffset!==null)s={time:r.startOfSegment,mapping:r.startOfSegment-n.start},this.timelines[r.timeline]=s,this.trigger("timestampoffset"),this.logger_("time mapping for timeline "+r.timeline+": "+("[time: "+s.time+"] [mapping: "+s.mapping+"]")),a.start=r.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(r){var n=r.playlist,a=r.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],l=n.discontinuitySequence+s+1,u=o-r.mediaIndex,c=Math.abs(u);if(!this.discontinuities[l]||this.discontinuities[l].accuracy>c){var d=void 0;u<0?d=a.start-Mu(n,r.mediaIndex,o):d=a.end+Mu(n,r.mediaIndex+1,o),this.discontinuities[l]={time:d,accuracy:c}}}}}]),t}(V.EventTarget),TC=new t_("./decrypter-worker.worker.js",function(e,t){var i=this;(function(){function r(g){return g.subarray(0,g.byteLength-g[g.byteLength-1])}var n=function(S,E){if(!(S instanceof E))throw new TypeError("Cannot call a class as a function")},a=function(){function g(S,E){for(var w=0;w<E.length;w++){var T=E[w];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(S,T.key,T)}}return function(S,E,w){return E&&g(S.prototype,E),w&&g(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},l=function(){var S=[[[],[],[],[],[]],[[],[],[],[],[]]],E=S[0],w=S[1],T=E[4],x=w[4],A=void 0,D=void 0,C=void 0,k=[],O=[],I=void 0,R=void 0,P=void 0,L=void 0,N=void 0,B=void 0;for(A=0;A<256;A++)O[(k[A]=A<<1^(A>>7)*283)^A]=A;for(D=C=0;!T[D];D^=I||1,C=O[C]||1)for(L=C^C<<1^C<<2^C<<3^C<<4,L=L>>8^L&255^99,T[D]=L,x[L]=D,P=k[R=k[I=k[D]]],B=P*16843009^R*65537^I*257^D*16843008,N=k[L]*257^L*16843008,A=0;A<4;A++)E[A][D]=N=N<<24^N>>>8,w[A][L]=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},u=null,c=function(){function g(S){n(this,g),u||(u=l()),this._tables=[[u[0][0].slice(),u[0][1].slice(),u[0][2].slice(),u[0][3].slice(),u[0][4].slice()],[u[1][0].slice(),u[1][1].slice(),u[1][2].slice(),u[1][3].slice(),u[1][4].slice()]];var E=void 0,w=void 0,T=void 0,x=void 0,A=void 0,D=this._tables[0][4],C=this._tables[1],k=S.length,O=1;if(k!==4&&k!==6&&k!==8)throw new Error("Invalid aes key size");for(x=S.slice(0),A=[],this._key=[x,A],E=k;E<4*k+28;E++)T=x[E-1],(E%k===0||k===8&&E%k===4)&&(T=D[T>>>24]<<24^D[T>>16&255]<<16^D[T>>8&255]<<8^D[T&255],E%k===0&&(T=T<<8^T>>>24^O<<24,O=O<<1^(O>>7)*283)),x[E]=x[E-k]^T;for(w=0;E;w++,E--)T=x[w&3?E:E-4],E<=4||w<4?A[w]=T:A[w]=C[0][D[T>>>24]]^C[1][D[T>>16&255]]^C[2][D[T>>8&255]]^C[3][D[T&255]]}return g.prototype.decrypt=function(E,w,T,x,A,D){var C=this._key[1],k=E^C[0],O=x^C[1],I=T^C[2],R=w^C[3],P=void 0,L=void 0,N=void 0,B=C.length/4-2,G=void 0,J=4,re=this._tables[1],Q=re[0],ne=re[1],le=re[2],Te=re[3],Ne=re[4];for(G=0;G<B;G++)P=Q[k>>>24]^ne[O>>16&255]^le[I>>8&255]^Te[R&255]^C[J],L=Q[O>>>24]^ne[I>>16&255]^le[R>>8&255]^Te[k&255]^C[J+1],N=Q[I>>>24]^ne[R>>16&255]^le[k>>8&255]^Te[O&255]^C[J+2],R=Q[R>>>24]^ne[k>>16&255]^le[O>>8&255]^Te[I&255]^C[J+3],J+=4,k=P,O=L,I=N;for(G=0;G<4;G++)A[(3&-G)+D]=Ne[k>>>24]<<24^Ne[O>>16&255]<<16^Ne[I>>8&255]<<8^Ne[R&255]^C[J++],P=k,k=O,O=I,I=R,R=P},g}(),d=function(){function g(){n(this,g),this.listeners={}}return g.prototype.on=function(E,w){this.listeners[E]||(this.listeners[E]=[]),this.listeners[E].push(w)},g.prototype.off=function(E,w){if(!this.listeners[E])return!1;var T=this.listeners[E].indexOf(w);return this.listeners[E].splice(T,1),T>-1},g.prototype.trigger=function(E){var w=this.listeners[E];if(!!w)if(arguments.length===2)for(var T=w.length,x=0;x<T;++x)w[x].call(this,arguments[1]);else for(var A=Array.prototype.slice.call(arguments,1),D=w.length,C=0;C<D;++C)w[C].apply(this,A)},g.prototype.dispose=function(){this.listeners={}},g.prototype.pipe=function(E){this.on("data",function(w){E.push(w)})},g}(),h=function(g){s(S,g);function S(){n(this,S);var E=o(this,g.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),f=function(S){return S<<24|(S&65280)<<8|(S&16711680)>>8|S>>>24},b=function(S,E,w){var T=new Int32Array(S.buffer,S.byteOffset,S.byteLength>>2),x=new c(Array.prototype.slice.call(E)),A=new Uint8Array(S.byteLength),D=new Int32Array(A.buffer),C=void 0,k=void 0,O=void 0,I=void 0,R=void 0,P=void 0,L=void 0,N=void 0,B=void 0;for(C=w[0],k=w[1],O=w[2],I=w[3],B=0;B<T.length;B+=4)R=f(T[B]),P=f(T[B+1]),L=f(T[B+2]),N=f(T[B+3]),x.decrypt(R,P,L,N,D,B),D[B]=f(D[B]^C),D[B+1]=f(D[B+1]^k),D[B+2]=f(D[B+2]^O),D[B+3]=f(D[B+3]^I),C=R,k=P,O=L,I=N;return A},p=function(){function g(S,E,w,T){n(this,g);var x=g.STEP,A=new Int32Array(S.buffer),D=new Uint8Array(S.byteLength),C=0;for(this.asyncStream_=new h,this.asyncStream_.push(this.decryptChunk_(A.subarray(C,C+x),E,w,D)),C=x;C<A.length;C+=x)w=new Uint32Array([f(A[C-4]),f(A[C-3]),f(A[C-2]),f(A[C-1])]),this.asyncStream_.push(this.decryptChunk_(A.subarray(C,C+x),E,w,D));this.asyncStream_.push(function(){T(null,r(D))})}return g.prototype.decryptChunk_=function(E,w,T,x){return function(){var A=b(E,w,T);x.set(A,E.byteOffset)}},a(g,null,[{key:"STEP",get:function(){return 32e3}}]),g}(),m=function(S){var E={};return Object.keys(S).forEach(function(w){var T=S[w];ArrayBuffer.isView(T)?E[w]={bytes:T.buffer,byteOffset:T.byteOffset,byteLength:T.byteLength}:E[w]=T}),E},y=function(S){S.onmessage=function(E){var w=E.data,T=new Uint8Array(w.encrypted.bytes,w.encrypted.byteOffset,w.encrypted.byteLength),x=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 p(T,x,A,function(D,C){S.postMessage(m({source:w.source,decrypted:C}),[C.buffer])})}},v=new y(i);return v})()}),SC=function(t){var i=t.default?"main":"alternative";return t.characteristics&&t.characteristics.indexOf("public.accessibility.describes-video")>=0&&(i="main-desc"),i},Id=function(t,i){t.abort(),t.pause(),i&&i.activePlaylistLoader&&(i.activePlaylistLoader.pause(),i.activePlaylistLoader=null)},ip=function(t,i){i.activePlaylistLoader=t,t.load()},EC=function(t,i){return function(){var r=i.segmentLoaders,n=r[t],a=r.main,s=i.mediaTypes[t],o=s.activeTrack(),l=s.activeGroup(o),u=s.activePlaylistLoader;if(Id(n,s),!!l){if(!l.playlistLoader){u&&a.resetEverything();return}n.resyncLoader(),ip(l.playlistLoader,s)}}},xC=function(t,i){return function(){var r=i.segmentLoaders,n=r[t],a=r.main,s=i.mediaTypes[t],o=s.activeTrack(),l=s.activeGroup(o),u=s.activePlaylistLoader;if(Id(n,s),!!l){if(!l.playlistLoader){a.resetEverything();return}if(u===l.playlistLoader){ip(l.playlistLoader,s);return}n.track&&n.track(o),n.resetEverything(),ip(l.playlistLoader,s)}}},Md={AUDIO:function(t,i){return function(){var r=i.segmentLoaders[t],n=i.mediaTypes[t],a=i.blacklistCurrentPlaylist;Id(r,n);var s=n.activeTrack(),o=n.activeGroup(),l=(o.filter(function(d){return d.default})[0]||o[0]).id,u=n.tracks[l];if(s===u){a({message:"Problem encountered loading the default audio track."});return}V.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(var c in n.tracks)n.tracks[c].enabled=n.tracks[c]===u;n.onTrackChanged()}},SUBTITLES:function(t,i){return function(){var r=i.segmentLoaders[t],n=i.mediaTypes[t];V.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),Id(r,n);var a=n.activeTrack();a&&(a.mode="disabled"),n.onTrackChanged()}}},S_={AUDIO:function(t,i,r){if(!!i){var n=r.tech,a=r.requestOptions,s=r.segmentLoaders[t];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",Md[t](t,r))}},SUBTITLES:function(t,i,r){var n=r.tech,a=r.requestOptions,s=r.segmentLoaders[t],o=r.mediaTypes[t];i.on("loadedmetadata",function(){var l=i.media();s.playlist(l,a),s.track(o.activeTrack()),(!n.paused()||l.endList&&n.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),n.paused()||s.load()}),i.on("error",Md[t](t,r))}},wC={AUDIO:function(t,i){var r=i.hls,n=i.sourceType,a=i.segmentLoaders[t],s=i.requestOptions,o=i.master.mediaGroups,l=i.mediaTypes[t],u=l.groups,c=l.tracks,d=i.masterPlaylistLoader;(!o[t]||Object.keys(o[t]).length===0)&&(o[t]={main:{default:{default:!0}}});for(var h in o[t]){u[h]||(u[h]=[]);for(var f in o[t][h]){var b=o[t][h][f],p=void 0;if(b.resolvedUri?p=new kd(b.resolvedUri,r,s):b.playlists&&n==="dash"?p=new Zh(b.playlists[0],r,s,d):p=null,b=V.mergeOptions({id:f,playlistLoader:p},b),S_[t](t,b.playlistLoader,i),u[h].push(b),typeof c[f]>"u"){var m=new V.AudioTrack({id:f,kind:SC(b),enabled:!1,language:b.language,default:b.default,label:f});c[f]=m}}}a.on("error",Md[t](t,i))},SUBTITLES:function(t,i){var r=i.tech,n=i.hls,a=i.sourceType,s=i.segmentLoaders[t],o=i.requestOptions,l=i.master.mediaGroups,u=i.mediaTypes[t],c=u.groups,d=u.tracks,h=i.masterPlaylistLoader;for(var f in l[t]){c[f]||(c[f]=[]);for(var b in l[t][f])if(!l[t][f][b].forced){var p=l[t][f][b],m=void 0;if(a==="hls"?m=new kd(p.resolvedUri,n,o):a==="dash"&&(m=new Zh(p.playlists[0],n,o,h)),p=V.mergeOptions({id:b,playlistLoader:m},p),S_[t](t,p.playlistLoader,i),c[f].push(p),typeof d[b]>"u"){var y=r.addRemoteTextTrack({id:b,kind:"subtitles",default:p.default&&p.autoselect,language:p.language,label:b},!1).track;d[b]=y}}}s.on("error",Md[t](t,i))},"CLOSED-CAPTIONS":function(t,i){var r=i.tech,n=i.master.mediaGroups,a=i.mediaTypes[t],s=a.groups,o=a.tracks;for(var l in n[t]){s[l]||(s[l]=[]);for(var u in n[t][l]){var c=n[t][l][u];if(!!c.instreamId.match(/CC\d/)&&(s[l].push(V.mergeOptions({id:u},c)),typeof o[u]>"u")){var d=r.addRemoteTextTrack({id:c.instreamId,kind:"captions",default:c.default&&c.autoselect,language:c.language,label:u},!1).track;o[u]=d}}}}},AC=function(t,i){return function(r){var n=i.masterPlaylistLoader,a=i.mediaTypes[t].groups,s=n.media();if(!s)return null;var o=null;return s.attributes[t]&&(o=a[s.attributes[t]]),o=o||a.main,typeof r>"u"?o:r===null?null:o.filter(function(l){return l.id===r.id})[0]||null}},DC={AUDIO:function(t,i){return function(){var r=i.mediaTypes[t].tracks;for(var n in r)if(r[n].enabled)return r[n];return null}},SUBTITLES:function(t,i){return function(){var r=i.mediaTypes[t].tracks;for(var n in r)if(r[n].mode==="showing")return r[n];return null}}},CC=function(t){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(c){wC[c](c,t)});var i=t.mediaTypes,r=t.masterPlaylistLoader,n=t.tech,a=t.hls;["AUDIO","SUBTITLES"].forEach(function(c){i[c].activeGroup=AC(c,t),i[c].activeTrack=DC[c](c,t),i[c].onGroupChanged=EC(c,t),i[c].onTrackChanged=xC(c,t)});var s=i.AUDIO.activeGroup(),o=(s.filter(function(c){return c.default})[0]||s[0]).id;i.AUDIO.tracks[o].enabled=!0,i.AUDIO.onTrackChanged(),r.on("mediachange",function(){["AUDIO","SUBTITLES"].forEach(function(c){return i[c].onGroupChanged()})});var l=function(){i.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"hls-audio-change"})};n.audioTracks().addEventListener("change",l),n.remoteTextTracks().addEventListener("change",i.SUBTITLES.onTrackChanged),a.on("dispose",function(){n.audioTracks().removeEventListener("change",l),n.remoteTextTracks().removeEventListener("change",i.SUBTITLES.onTrackChanged)}),n.clearTracks("audio");for(var u in i.AUDIO.tracks)n.audioTracks().addTrack(i.AUDIO.tracks[u])},kC=function(){var t={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(i){t[i]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:mo,activeTrack:mo,onGroupChanged:mo,onTrackChanged:mo}}),t},RC=60*2,ba=void 0,PC=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],OC=function(t){return this.audioSegmentLoader_[t]+this.mainSegmentLoader_[t]},LC=function(e){On(t,e);function t(i){ki(this,t);var r=an(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),n=i.url,a=i.handleManifestRedirects,s=i.withCredentials,o=i.tech,l=i.bandwidth,u=i.externHls,c=i.useCueTags,d=i.blacklistDuration,h=i.enableLowInitialPlaylist,f=i.sourceType,b=i.seekTo,p=i.cacheEncryptionKeys;if(!n)throw new Error("A non-empty playlist URL is required");ba=u,r.withCredentials=s,r.tech_=o,r.hls_=o.hls,r.seekTo_=b,r.sourceType_=f,r.useCueTags_=c,r.blacklistDuration=d,r.enableLowInitialPlaylist=h,r.useCueTags_&&(r.cueTagsTrack_=r.tech_.addTextTrack("metadata","ad-cues"),r.cueTagsTrack_.inBandMetadataTrackDispatchType=""),r.requestOptions_={withCredentials:s,handleManifestRedirects:a,timeout:null},r.mediaTypes_=kC(),r.mediaSource=new V.MediaSource,r.mediaSource.addEventListener("sourceopen",r.handleSourceOpen_.bind(r)),r.seekable_=V.createTimeRanges(),r.hasPlayed_=function(){return!1},r.syncController_=new bC(i),r.segmentMetadataTrack_=o.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,r.decrypter_=new TC,r.inbandTextTracks_={};var m={hls:r.hls_,mediaSource:r.mediaSource,currentTime:r.tech_.currentTime.bind(r.tech_),seekable:function(){return r.seekable()},seeking:function(){return r.tech_.seeking()},duration:function(){return r.mediaSource.duration},hasPlayed:function(){return r.hasPlayed_()},goalBufferLength:function(){return r.goalBufferLength()},bandwidth:l,syncController:r.syncController_,decrypter:r.decrypter_,sourceType:r.sourceType_,inbandTextTracks:r.inbandTextTracks_,cacheEncryptionKeys:p};return r.masterPlaylistLoader_=r.sourceType_==="dash"?new Zh(n,r.hls_,r.requestOptions_):new kd(n,r.hls_,r.requestOptions_),r.setupMasterPlaylistLoaderListeners_(),r.mainSegmentLoader_=new rp(V.mergeOptions(m,{segmentMetadataTrack:r.segmentMetadataTrack_,loaderType:"main"}),i),r.audioSegmentLoader_=new rp(V.mergeOptions(m,{loaderType:"audio"}),i),r.subtitleSegmentLoader_=new vC(V.mergeOptions(m,{loaderType:"vtt"}),i),r.setupSegmentLoaderListeners_(),PC.forEach(function(y){r[y+"_"]=OC.bind(r,y)}),r.logger_=Uu("MPC"),r.masterPlaylistLoader_.load(),r}return Hi(t,[{key:"setupMasterPlaylistLoaderListeners_",value:function(){var r=this;this.masterPlaylistLoader_.on("loadedmetadata",function(){var n=r.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;Wh(r.masterPlaylistLoader_.master,r.masterPlaylistLoader_.media())?r.requestOptions_.timeout=0:r.requestOptions_.timeout=a,n.endList&&r.tech_.preload()!=="none"&&(r.mainSegmentLoader_.playlist(n,r.requestOptions_),r.mainSegmentLoader_.load()),CC({sourceType:r.sourceType_,segmentLoaders:{AUDIO:r.audioSegmentLoader_,SUBTITLES:r.subtitleSegmentLoader_,main:r.mainSegmentLoader_},tech:r.tech_,requestOptions:r.requestOptions_,masterPlaylistLoader:r.masterPlaylistLoader_,hls:r.hls_,master:r.master(),mediaTypes:r.mediaTypes_,blacklistCurrentPlaylist:r.blacklistCurrentPlaylist.bind(r)}),r.triggerPresenceUsage_(r.master(),n);try{r.setupSourceBuffers_()}catch(s){return V.log.warn("Failed to create SourceBuffers",s),r.mediaSource.endOfStream("decode")}r.setupFirstPlay(),!r.mediaTypes_.AUDIO.activePlaylistLoader||r.mediaTypes_.AUDIO.activePlaylistLoader.media()?r.trigger("selectedinitialmedia"):r.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",function(){r.trigger("selectedinitialmedia")})}),this.masterPlaylistLoader_.on("loadedplaylist",function(){var n=r.masterPlaylistLoader_.media();if(!n){r.excludeUnsupportedVariants_();var a=void 0;r.enableLowInitialPlaylist&&(a=r.selectInitialPlaylist()),a||(a=r.selectPlaylist()),r.initialMedia_=a,r.masterPlaylistLoader_.media(r.initialMedia_);return}if(r.useCueTags_&&r.updateAdCues_(n),r.mainSegmentLoader_.playlist(n,r.requestOptions_),r.updateDuration(),r.tech_.paused()||(r.mainSegmentLoader_.load(),r.audioSegmentLoader_&&r.audioSegmentLoader_.load()),!n.endList){var s=function(){var u=r.seekable();u.length!==0&&r.mediaSource.addSeekableRange_(u.start(0),u.end(0))};if(r.duration()!==1/0){var o=function l(){r.duration()===1/0?s():r.tech_.one("durationchange",l)};r.tech_.one("durationchange",o)}else s()}}),this.masterPlaylistLoader_.on("error",function(){r.blacklistCurrentPlaylist(r.masterPlaylistLoader_.error)}),this.masterPlaylistLoader_.on("mediachanging",function(){r.mainSegmentLoader_.abort(),r.mainSegmentLoader_.pause()}),this.masterPlaylistLoader_.on("mediachange",function(){var n=r.masterPlaylistLoader_.media(),a=n.targetDuration*1.5*1e3;Wh(r.masterPlaylistLoader_.master,r.masterPlaylistLoader_.media())?r.requestOptions_.timeout=0:r.requestOptions_.timeout=a,r.mainSegmentLoader_.playlist(n,r.requestOptions_),r.mainSegmentLoader_.load(),r.tech_.trigger({type:"mediachange",bubbles:!0})}),this.masterPlaylistLoader_.on("playlistunchanged",function(){var n=r.masterPlaylistLoader_.media(),a=r.stuckAtPlaylistEnd_(n);a&&(r.blacklistCurrentPlaylist({message:"Playlist no longer updating."}),r.tech_.trigger("playliststuck"))}),this.masterPlaylistLoader_.on("renditiondisabled",function(){r.tech_.trigger({type:"usage",name:"hls-rendition-disabled"})}),this.masterPlaylistLoader_.on("renditionenabled",function(){r.tech_.trigger({type:"usage",name:"hls-rendition-enabled"})})}},{key:"triggerPresenceUsage_",value:function(r,n){var a=r.mediaGroups||{},s=!0,o=Object.keys(a.AUDIO);for(var l in a.AUDIO)for(var u in a.AUDIO[l]){var c=a.AUDIO[l][u];c.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"}),ba.Playlist.isAes(n)&&this.tech_.trigger({type:"usage",name:"hls-aes"}),ba.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 r=this;this.mainSegmentLoader_.on("bandwidthupdate",function(){var n=r.selectPlaylist(),a=r.masterPlaylistLoader_.media(),s=r.tech_.buffered(),o=s.length?s.end(s.length-1)-r.tech_.currentTime():0,l=r.bufferLowWaterLine();(!a.endList||r.duration()<yi.MAX_BUFFER_LOW_WATER_LINE||n.attributes.BANDWIDTH<a.attributes.BANDWIDTH||o>=l)&&r.masterPlaylistLoader_.media(n),r.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("progress",function(){r.trigger("progress")}),this.mainSegmentLoader_.on("error",function(){r.blacklistCurrentPlaylist(r.mainSegmentLoader_.error())}),this.mainSegmentLoader_.on("syncinfoupdate",function(){r.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",function(){r.tech_.trigger({type:"usage",name:"hls-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",function(){r.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("ended",function(){r.onEndOfStream()}),this.mainSegmentLoader_.on("earlyabort",function(){r.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},RC)}),this.mainSegmentLoader_.on("reseteverything",function(){r.tech_.trigger("hls-reset")}),this.mainSegmentLoader_.on("segmenttimemapping",function(n){r.tech_.trigger({type:"hls-segment-time-mapping",mapping:n.mapping})}),this.audioSegmentLoader_.on("ended",function(){r.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 r=this.selectPlaylist();r!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(r),this.mainSegmentLoader_.resetLoader())}},{key:"fastQualityChange_",value:function(){var r=this,n=this.selectPlaylist();n!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(n),this.mainSegmentLoader_.resetEverything(function(){V.browser.IE_VERSION||V.browser.IS_EDGE?r.tech_.setCurrentTime(r.tech_.currentTime()+.04):r.tech_.setCurrentTime(r.tech_.currentTime())}))}},{key:"play",value:function(){if(!this.setupFirstPlay()){this.tech_.ended()&&this.seekTo_(0),this.hasPlayed_()&&this.load();var r=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<r.start(0))return this.seekTo_(r.end(r.length-1))}}},{key:"setupFirstPlay",value:function(){var r=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(V.browser.IE_VERSION&&this.tech_.readyState()===0)return this.tech_.one("loadedmetadata",function(){r.trigger("firstplay"),r.seekTo_(a.end(0)),r.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 V.log.warn("Failed to create Source Buffers",n),this.mediaSource.endOfStream("decode")}if(this.tech_.autoplay()){var r=this.tech_.play();typeof r<"u"&&typeof r.then=="function"&&r.then(null,function(n){})}this.trigger("sourceopen")}},{key:"onEndOfStream",value:function(){var r=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(!this.mainSegmentLoader_.startingMedia_||this.mainSegmentLoader_.startingMedia_.containsVideo?r=r&&this.audioSegmentLoader_.ended_:r=this.audioSegmentLoader_.ended_),!!r){this.logger_("calling mediaSource.endOfStream()");try{this.mediaSource.endOfStream()}catch(n){V.log.warn("Failed to call media source endOfStream",n)}}}},{key:"stuckAtPlaylistEnd_",value:function(r){var n=this.seekable();if(!n.length)return!1;var a=this.syncController_.getExpiredTime(r,this.mediaSource.duration);if(a===null)return!1;var s=ba.Playlist.playlistEnd(r,a),o=this.tech_.currentTime(),l=this.tech_.buffered();if(!l.length)return s-o<=Ln;var u=l.end(l.length-1);return u-o<=Ln&&s-u<=Ln}},{key:"blacklistCurrentPlaylist",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments[1],a=void 0,s=void 0;if(a=r.playlist||this.masterPlaylistLoader_.media(),n=n||r.blacklistDuration||this.blacklistDuration,!a){this.error=r;try{return this.mediaSource.endOfStream("network")}catch{return this.trigger("error")}}var o=this.masterPlaylistLoader_.master.playlists.filter(Rd).length===1,l=this.masterPlaylistLoader_.master.playlists;return l.length===1?(V.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&&(V.log.warn("Removing all playlists from the blacklist because the last rendition is about to be blacklisted."),l.forEach(function(u){u.excludeUntil!==1/0&&delete u.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(),V.log.warn("Problem encountered with the current HLS playlist."+(r.message?" "+r.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(r){var n=Jy(this.tech_.buffered(),r);if(!(this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media())||!this.masterPlaylistLoader_.media().segments)return 0;if(n&&n.length)return r;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:ba.Playlist.duration(this.masterPlaylistLoader_.media()):0}},{key:"seekable",value:function(){return this.seekable_}},{key:"onSyncInfoUpdate_",value:function(){var r=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&&(r=ba.Playlist.seekable(a,s),r.length!==0&&!(this.mediaTypes_.AUDIO.activePlaylistLoader&&(a=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),s=this.syncController_.getExpiredTime(a,this.mediaSource.duration),s===null||(n=ba.Playlist.seekable(a,s),n.length===0))))){var o=void 0,l=void 0;this.seekable_&&this.seekable_.length&&(o=this.seekable_.end(0),l=this.seekable_.start(0)),n?n.start(0)>r.end(0)||r.start(0)>n.end(0)?this.seekable_=r:this.seekable_=V.createTimeRanges([[n.start(0)>r.start(0)?n.start(0):r.start(0),n.end(0)<r.end(0)?n.end(0):r.end(0)]]):this.seekable_=r,!(this.seekable_&&this.seekable_.length&&this.seekable_.end(0)===o&&this.seekable_.start(0)===l)&&(this.logger_("seekable updated ["+Kh(this.seekable_)+"]"),this.tech_.trigger("seekablechanged"))}}}}},{key:"updateDuration",value:function(){var r=this,n=this.mediaSource.duration,a=ba.Playlist.duration(this.masterPlaylistLoader_.media()),s=this.tech_.buffered(),o=function l(){r.logger_("Setting duration from "+r.mediaSource.duration+" => "+a);try{r.mediaSource.duration=a}catch(u){V.log.warn("Failed to set media source duration",u)}r.tech_.trigger("durationchange"),r.mediaSource.removeEventListener("sourceopen",l)};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 r=this;this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),["AUDIO","SUBTITLES"].forEach(function(n){var a=r.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 r=this.masterPlaylistLoader_.media(),n=void 0;if(!(!r||this.mediaSource.readyState!=="open")){if(n=FD(this.masterPlaylistLoader_.master,r),n.length<1)return this.error="No compatible SourceBuffer configuration for the variant stream:"+r.resolvedUri,this.mediaSource.endOfStream("decode");this.configureLoaderMimeTypes_(n),this.excludeIncompatibleVariants_(r)}}},{key:"configureLoaderMimeTypes_",value:function(r){var n=r.length>1&&r[0].indexOf(",")===-1&&r[0]!==r[1]?new V.EventTarget:null;this.mainSegmentLoader_.mimeType(r[0],n),r[1]&&this.audioSegmentLoader_.mimeType(r[1],n)}},{key:"excludeUnsupportedVariants_",value:function(){this.master().playlists.forEach(function(r){r.attributes.CODECS&&pe.MediaSource&&pe.MediaSource.isTypeSupported&&!pe.MediaSource.isTypeSupported('video/mp4; codecs="'+LD(r.attributes.CODECS)+'"')&&(r.excludeUntil=1/0)})}},{key:"excludeIncompatibleVariants_",value:function(r){var n=2,a=null,s=void 0;r.attributes.CODECS&&(s=Nu(r.attributes.CODECS),a=s.videoCodec,n=s.codecCount),this.master().playlists.forEach(function(o){var l={codecCount:2,videoCodec:null};o.attributes.CODECS&&(l=Nu(o.attributes.CODECS)),l.codecCount!==n&&(o.excludeUntil=1/0),l.videoCodec!==a&&(o.excludeUntil=1/0)})}},{key:"updateAdCues_",value:function(r){var n=0,a=this.seekable();a.length&&(n=a.start(0)),yC(r,this.cueTagsTrack_,n)}},{key:"goalBufferLength",value:function(){var r=this.tech_.currentTime(),n=yi.GOAL_BUFFER_LENGTH,a=yi.GOAL_BUFFER_LENGTH_RATE,s=Math.max(n,yi.MAX_GOAL_BUFFER_LENGTH);return Math.min(n+r*a,s)}},{key:"bufferLowWaterLine",value:function(){var r=this.tech_.currentTime(),n=yi.BUFFER_LOW_WATER_LINE,a=yi.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(n,yi.MAX_BUFFER_LOW_WATER_LINE);return Math.min(n+r*a,s)}}]),t}(V.EventTarget),IC=function(t,i,r){return function(n){var a=t.master.playlists[i],s=Vh(a),o=Rd(a);return typeof n>"u"?o:(n?delete a.disabled:a.disabled=!0,n!==o&&!s&&(r(),n?t.trigger("renditionenabled"):t.trigger("renditiondisabled")),n)}},MC=function e(t,i,r){ki(this,e);var n=t.masterPlaylistController_,a=t.options_.smoothQualityChange,s=a?"smooth":"fast",o=n[s+"QualityChange_"].bind(n);if(i.attributes.RESOLUTION){var l=i.attributes.RESOLUTION;this.width=l.width,this.height=l.height}this.bandwidth=i.attributes.BANDWIDTH,this.id=r,this.enabled=IC(t.playlists,i.uri,o)},NC=function(t){var i=t.playlists;t.representations=function(){return i.master.playlists.filter(function(r){return!Vh(r)}).map(function(r,n){return new MC(t,r,r.uri)})}},E_=["seeking","seeked","pause","playing","error"],FC=function(){function e(t){var i=this;ki(this,e),this.tech_=t.tech,this.seekable=t.seekable,this.seekTo=t.seekTo,this.allowSeeksWithinUnsafeLiveWindow=t.allowSeeksWithinUnsafeLiveWindow,this.media=t.media,this.consecutiveUpdates=0,this.lastRecordedTime=null,this.timer_=null,this.checkCurrentTimeTimeout_=null,this.logger_=Uu("PlaybackWatcher"),this.logger_("initialize");var r=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(E_,a),this.tech_.on("canplay",r),this.dispose=function(){i.logger_("dispose"),i.tech_.off("seekablechanged",s),i.tech_.off("waiting",n),i.tech_.off(E_,a),i.tech_.off("canplay",r),i.checkCurrentTimeTimeout_&&pe.clearTimeout(i.checkCurrentTimeTimeout_),i.cancelTimer_()}}return Hi(e,[{key:"monitorCurrentTime_",value:function(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&pe.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=pe.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(),r=this.tech_.buffered();if(this.lastRecordedTime===i&&(!r.length||i+Ln>=r.end(r.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 r=this.seekable(),n=this.tech_.currentTime(),a=this.afterSeekableWindow_(r,n,this.media(),this.allowSeeksWithinUnsafeLiveWindow),s=void 0;if(a){var o=r.end(r.length-1);s=o}if(this.beforeSeekableWindow_(r,n)){var l=r.start(0);s=l+Ln}return typeof s<"u"?(this.logger_("Trying to seek outside of seekable at time "+n+" with "+("seekable range "+Kh(r)+". Seeking to ")+(s+".")),this.seekTo(s),!0):!1}},{key:"waiting_",value:function(){if(!this.techWaiting_()){var i=this.tech_.currentTime(),r=this.tech_.buffered(),n=Jy(r,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(),r=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_()||this.tech_.seeking()||this.timer_!==null)return!0;if(this.beforeSeekableWindow_(i,r)){var n=i.end(i.length-1);return this.logger_("Fell out of live window at time "+r+". 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=Qy(a,r);if(this.videoUnderflow_(s,a,r))return this.cancelTimer_(),this.seekTo(r),this.tech_.trigger({type:"usage",name:"hls-video-underflow"}),!0;if(s.length>0){var o=s.start(0)-r;return this.logger_("Stopped at "+r+", setting timer for "+o+", seeking "+("to "+s.start(0))),this.timer_=setTimeout(this.skipTheGap_.bind(this),o*1e3,r),!0}return!1}},{key:"afterSeekableWindow_",value:function(i,r,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)+Ln,o=!n.endList;return o&&a&&(s=i.end(i.length-1)+n.targetDuration*3),r>s}},{key:"beforeSeekableWindow_",value:function(i,r){return!!(i.length&&i.start(0)>0&&r<i.start(0)-Ln)}},{key:"videoUnderflow_",value:function(i,r,n){if(i.length===0){var a=this.gapFromVideoUnderflow_(r,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 r=this.tech_.buffered(),n=this.tech_.currentTime(),a=Qy(r,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)+Od),this.tech_.trigger({type:"usage",name:"hls-gap-skip"}))}},{key:"gapFromVideoUnderflow_",value:function(i,r){for(var n=xD(i),a=0;a<n.length;a++){var s=n.start(a),o=n.end(a);if(r-s<4&&r-s>2)return{start:s,end:o}}return null}}]),e}(),UC={errorInterval:30,getSource:function(t){var i=this.tech({IWillNotUseThisInPlugins:!0}),r=i.currentSource_;return t(r)}},BC=function e(t,i){var r=0,n=0,a=V.mergeOptions(UC,i);t.ready(function(){t.trigger({type:"usage",name:"hls-error-reload-initialized"})});var s=function(){n&&t.currentTime(n)},o=function(h){h!=null&&(n=t.duration()!==1/0&&t.currentTime()||0,t.one("loadedmetadata",s),t.src(h),t.trigger({type:"usage",name:"hls-error-reload"}),t.play())},l=function(){if(Date.now()-r<a.errorInterval*1e3){t.trigger({type:"usage",name:"hls-error-reload-canceled"});return}if(!a.getSource||typeof a.getSource!="function"){V.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return r=Date.now(),a.getSource.call(t,o)},u=function d(){t.off("loadedmetadata",s),t.off("error",l),t.off("dispose",d)},c=function(h){u(),e(t,h)};t.on("error",l),t.on("dispose",u),t.reloadSourceOnError=c},x_=function(t){BC(this,t)},jC="1.10.6";V.use("*",function(e){return{setSource:function(i,r){r(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 hi={PlaylistLoader:kd,Playlist:fi,Decrypter:_A,AsyncStream:Km,decrypt:$m,utils:gD,STANDARD_PLAYLIST_SELECTOR:sC,INITIAL_PLAYLIST_SELECTOR:uC,comparePlaylistBandwidth:tp,comparePlaylistResolution:nC,xhr:Wy()};["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(hi,e,{get:function(){return V.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),yi[e]},set:function(i){if(V.log.warn("using Hls."+e+" is UNSAFE be sure you know what you are doing"),typeof i!="number"||i<0){V.log.warn("value of Hls."+e+" must be greater than or equal to 0");return}yi[e]=i}})});var w_="videojs-vhs",A_=function(t){var i=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;if(i.test(t))return"hls";var r=/^application\/dash\+xml/i;return r.test(t)?"dash":null},D_=function(t,i){for(var r=i.media(),n=-1,a=0;a<t.length;a++)if(t[a].id===r.uri){n=a;break}t.selectedIndex_=n,t.trigger({selectedIndex:n,type:"change"})},GC=function(t,i){i.representations().forEach(function(r){t.addQualityLevel(r)}),D_(t,i.playlists)};hi.canPlaySource=function(){return V.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var HC=function(t,i,r){if(!t)return t;var n={};for(var a in t)n[a]={audioContentType:'audio/mp4; codecs="'+r.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 t[a]=="string"&&(n[a].url=t[a]);return V.mergeOptions(t,n)},qC=function(t){if(t.options_.sourceType==="dash"){var i=V.players[t.tech_.options_.playerId];if(i.eme){var r=HC(t.source_.keySystems,t.playlists.media(),t.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader.media());r&&(i.currentSource().keySystems=r,i.eme.initializeMediaKeys&&i.eme.initializeMediaKeys())}}},C_=function(){if(!window.localStorage)return null;var t=window.localStorage.getItem(w_);if(!t)return null;try{return JSON.parse(t)}catch{return null}},VC=function(t){if(!window.localStorage)return!1;var i=C_();i=i?V.mergeOptions(i,t):t;try{window.localStorage.setItem(w_,JSON.stringify(i))}catch{return!1}return i};hi.supportsNativeHls=function(){var e=$e.createElement("video");if(!V.getTech("Html5").isSupported())return!1;var t=["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"];return t.some(function(i){return/maybe|probably/i.test(e.canPlayType(i))})}(),hi.supportsNativeDash=function(){return V.getTech("Html5").isSupported()?/maybe|probably/i.test($e.createElement("video").canPlayType("application/dash+xml")):!1}(),hi.supportsTypeNatively=function(e){return e==="hls"?hi.supportsNativeHls:e==="dash"?hi.supportsNativeDash:!1},hi.isSupported=function(){return V.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var WC=V.getComponent("Component"),k_=function(e){On(t,e);function t(i,r,n){ki(this,t);var a=an(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,r,n.hls));if(r.options_&&r.options_.playerId){var s=V(r.options_.playerId);s.hasOwnProperty("hls")||Object.defineProperty(s,"hls",{get:function(){return V.log.warn("player.hls is deprecated. Use player.tech().hls instead."),r.trigger({type:"usage",name:"hls-player-access"}),a},configurable:!0}),s.vhs=a,s.dash=a,a.player_=s}if(a.tech_=r,a.source_=i,a.stats={},a.setOptions_(),a.options_.overrideNative&&r.overrideNativeAudioTracks&&r.overrideNativeVideoTracks)r.overrideNativeAudioTracks(!0),r.overrideNativeVideoTracks(!0);else if(a.options_.overrideNative&&(r.featuresNativeVideoTracks||r.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 l=$e.fullscreenElement||$e.webkitFullscreenElement||$e.mozFullScreenElement||$e.msFullscreenElement;l&&l.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 Hi(t,[{key:"setOptions_",value:function(){var r=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=C_();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=yi.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===yi.INITIAL_BANDWIDTH,["withCredentials","limitRenditionByPlayerDimensions","bandwidth","smoothQualityChange","customTagParsers","customTagMappers","handleManifestRedirects","cacheEncryptionKeys"].forEach(function(a){typeof r.source_[a]<"u"&&(r.options_[a]=r.source_[a])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions}},{key:"src",value:function(r,n){var a=this;!r||(this.setOptions_(),this.options_.url=this.source_.src,this.options_.tech=this.tech_,this.options_.externHls=hi,this.options_.sourceType=A_(n),this.options_.seekTo=function(s){a.tech_.setCurrentTime(s),a.setCurrentTime(s)},this.masterPlaylistController_=new LC(this.options_),this.playbackWatcher_=new FC(V.mergeOptions(this.options_,{seekable:function(){return a.seekable()},media:function(){return a.masterPlaylistController_.media()}})),this.masterPlaylistController_.on("error",function(){var s=V.players[a.tech_.options_.playerId];s.error(a.masterPlaylistController_.error)}),this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):hi.STANDARD_PLAYLIST_SELECTOR.bind(this),this.masterPlaylistController_.selectInitialPlaylist=hi.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),l=void 0;this.throughput>0?l=1/this.throughput:l=0;var u=Math.floor(1/(o+l));return u},set:function(){V.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 Zy(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 Zy(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&&VC({bandwidth:a.bandwidth,throughput:Math.round(a.throughput)})}),this.masterPlaylistController_.on("selectedinitialmedia",function(){NC(a),qC(a)}),this.on(this.masterPlaylistController_,"progress",function(){this.tech_.trigger("progress")}),this.tech_.ready(function(){return a.setupQualityLevels_()}),this.tech_.el()&&this.tech_.src(V.URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var r=this,n=V.players[this.tech_.options_.playerId];n&&n.qualityLevels&&(this.qualityLevels_=n.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",function(){GC(r.qualityLevels_,r)}),this.playlists.on("mediachange",function(){D_(r.qualityLevels_,r.playlists)}))}},{key:"play",value:function(){this.masterPlaylistController_.play()}},{key:"setCurrentTime",value:function(r){this.masterPlaylistController_.setCurrentTime(r)}},{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,W1(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"dispose",this).call(this)}},{key:"convertToProgramTime",value:function(r,n){return SD({playlist:this.masterPlaylistController_.media(),time:r,callback:n})}},{key:"seekToProgramTime",value:function(r,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 ED({programTime:r,playlist:this.masterPlaylistController_.media(),retryCount:s,pauseAfterSeek:a,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:n})}}]),t}(WC),np={name:"videojs-http-streaming",VERSION:jC,canHandleSource:function(t){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=V.mergeOptions(V.options,i);return np.canPlayType(t.type,r)},handleSource:function(t,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=V.mergeOptions(V.options,r);return i.hls=new k_(t,i,n),i.hls.xhr=Wy(),i.hls.src(t.src,t.type),i.hls},canPlayType:function(t){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=V.mergeOptions(V.options,i),n=r.hls.overrideNative,a=A_(t),s=a&&(!hi.supportsTypeNatively(a)||n);return s?"maybe":""}};(typeof V.MediaSource>"u"||typeof V.URL>"u")&&(V.MediaSource=Fu,V.URL=c_),Fu.supportsNativeMediaSources()&&V.getTech("Html5").registerSourceHandler(np,0),V.HlsHandler=k_,V.HlsSourceHandler=np,V.Hls=hi,V.use||V.registerComponent("Hls",hi),V.options.hls=V.options.hls||{},V.registerPlugin?V.registerPlugin("reloadSourceOnError",x_):V.plugin("reloadSourceOnError",x_);const YC=Object.freeze(Object.defineProperty({__proto__:null,default:V},Symbol.toStringTag,{value:"Module"})),R_={name:"stream-engine-player",version:"0.0.42",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 Gr=[];for(let e=0;e<256;++e)Gr.push((e+256).toString(16).slice(1));function KC(e,t=0){return(Gr[e[t+0]]+Gr[e[t+1]]+Gr[e[t+2]]+Gr[e[t+3]]+"-"+Gr[e[t+4]]+Gr[e[t+5]]+"-"+Gr[e[t+6]]+Gr[e[t+7]]+"-"+Gr[e[t+8]]+Gr[e[t+9]]+"-"+Gr[e[t+10]]+Gr[e[t+11]]+Gr[e[t+12]]+Gr[e[t+13]]+Gr[e[t+14]]+Gr[e[t+15]]).toLowerCase()}var ap,$C=new Uint8Array(16);function zC(){if(!ap){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ap=crypto.getRandomValues.bind(crypto)}return ap($C)}var XC=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),P_={randomUUID:XC};function JC(e,t,i){var n,a,s;if(P_.randomUUID&&!t&&!e)return P_.randomUUID();e=e||{};let r=(s=(a=e.random)!=null?a:(n=e.rng)==null?void 0:n.call(e))!=null?s:zC();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(i=i||0,i<0||i+16>t.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);for(let o=0;o<16;++o)t[i+o]=r[o];return t}return KC(r)}var QC=JC,O_="000000",L_=function(){let e=Math.random().toString(36).replace("0.","").slice(0,6);return O_.slice(e.length)+e},yo=function(){return QC()},ZC=function(){return(O_+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},sp=e=>{if(!e)return["localhost","localhost"];try{let t=new URL(e).hostname,i=t.split("."),r=i.length>=2?i.slice(-2).join("."):t;return[t,r]}catch{}return["localhost","localhost"]},sn=e=>sp(e)[0],op=e=>sp(e)[1],ek=e=>{var t,i;if(e&&e.nodeName)return(t=e.uniqueId)!=null?t:e.uniqueId=L_();try{let r=document.querySelector(e);return r&&!r.uniqueId&&(r.uniqueId=e),(i=r==null?void 0:r.uniqueId)!=null?i:e}catch{}return e},tk=e=>{var r;let t=null;e&&e.nodeName!==void 0?(t=e,e=ek(t)):t=document.querySelector(e);let i=((r=t==null?void 0:t.nodeName)==null?void 0:r.toLowerCase())||"";return[t,e,i]},I_=e=>{var i,r;let t=null;if(e&&e.nodeName!==void 0)return(i=e.elementId)!=null||(e.elementId=ZC()),e.elementId;try{t=document.querySelector(e)}catch{}return t&&!t.elementId&&(t.elementId=e),(r=t==null?void 0:t.elementId)!=null?r:e};function rk(...e){return e.reduce((t,i)=>{for(let[r,n]of Object.entries(i))n!==void 0&&(t[r]=n);return t},{})}function Nd(e,t,i=1){var r;e[t]=((r=e[t])!=null?r:0)+i}function ik(e,t){let{beaconDomain:i}=t;return`https://${e!=null?e:"collector"}.${i!=null?i:"metrix.ws"}`}function M_(){var t,i;let e=(i=(t=navigator.doNotTrack)!=null?t:window.doNotTrack)!=null?i:navigator.msDoNotTrack;return e==="1"||e==="yes"}var nk=class{constructor(){this.events={}}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}off(e,t){this.events[e]&&(this.events[e]=this.events[e].filter(i=>i!==t))}emit(e,t){this.events[e]&&this.events[e].forEach(i=>{i(t)})}},Ta={now:function(){return typeof Date.now=="function"?Date.now():new Date().getTime()}},Fd={isPerformanceAvailable:function(){let e=window.performance;return e&&e.timing!==void 0},getDomContentLoadedEnd:function(){var t;let e=(t=window.performance)==null?void 0:t.timing;return e?e.domContentLoadedEventEnd:null},getNavigationStartTime:function(){var t;let e=(t=window.performance)==null?void 0:t.timing;return e?e.navigationStart:null}};function ak(e){if(!e)return{};let t=Fd.getNavigationStartTime(),{loading:i,trequest:r,tfirst:n,tload:a,total:s}=e,o=i?i.start:r,l=i?i.first:n,u=i?i.end:a;return{bytesLoaded:s,requestStart:Math.round(t+o),responseStart:Math.round(t+l),responseEnd:Math.round(t+u)}}var sk=()=>{var t,i,r;let e=navigator;return(r=(i=(t=e==null?void 0:e.connection)!=null?t:e==null?void 0:e.mozConnection)!=null?i:e==null?void 0:e.webkitConnection)==null?void 0:r.type},ok=()=>{switch(sk()){case"cellular":return"cellular";case"ethernet":return"wired";case"wifi":return"wifi";case void 0:break;default:return"other"}},uk=["x-cdn","content-type","content-length","last-modified","server","x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"];function lk(e){let t={},i=new Set(uk.map(r=>r.toLowerCase()));return!e||typeof e!="string"?{}:(e.trim().split(/[\r\n]+/).forEach(r=>{let[n,...a]=r.split(": "),s=a.join(": ");n&&i.has(n.toLowerCase())&&(t[n]=s)}),t)}var Ud=function(e){if(e&&typeof e.getAllResponseHeaders=="function")return lk(e.getAllResponseHeaders())},dk={convertSecToMs:function(e){return Math.floor(1e3*e)},isolateHostAndDomainName:sp,fetchDomain:op,fetchHost:sn,generateIdToken:L_,buildUUID:yo,now:Ta.now};function ck(e){let t=(window==null?void 0:window.URL)||(window==null?void 0:window.webkitURL),i=window==null?void 0:window.Blob,r=window==null?void 0:window.Worker;if(!t||!i||!r||!e)return null;let n=new i([e]);return new r(t.createObjectURL(n))}var fk=`
89
89
  let pulseInterval = null;
90
90
  let throbInterval = null
91
91