stream-engine-player 0.0.24 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -85,7 +85,7 @@ See https://github.com/videojs/video.js/issues/2617 for more info.
|
|
|
85
85
|
`;return e},eI=function(r){var i=r.bytes;return jb(i)},tI=function(r){var i="",t=void 0;for(t=0;t<r.length;t++)i+=QR(r,t)+" ";return i},rI=Object.freeze({createTransferableMessage:Bb,initSegmentId:df,segmentKeyId:Ub,hexDump:jb,tagDump:eI,textRanges:tI}),Hb=.25,iI=function(r,i){if(!i.dateTimeObject)return null;var t=i.videoTimingInfo.transmuxerPrependedSeconds,e=i.videoTimingInfo.transmuxedPresentationStart,a=e+t,s=r-a;return new Date(i.dateTimeObject.getTime()+s*1e3)},nI=function(r){return r.transmuxedPresentationEnd-r.transmuxedPresentationStart-r.transmuxerPrependedSeconds},aI=function(r,i){var t=void 0;try{t=new Date(r)}catch{return null}if(!i||!i.segments||i.segments.length===0)return null;var e=i.segments[0];if(t<e.dateTimeObject)return null;for(var a=0;a<i.segments.length-1;a++){e=i.segments[a];var s=i.segments[a+1].dateTimeObject;if(t<s)break}var o=i.segments[i.segments.length-1],u=o.dateTimeObject,l=o.videoTimingInfo?nI(o.videoTimingInfo):o.duration+o.duration*Hb,c=new Date(u.getTime()+l*1e3);return t>c?null:(t>u&&(e=o),{segment:e,estimatedStart:e.videoTimingInfo?e.videoTimingInfo.transmuxedPresentationStart:en.duration(i,i.mediaSequence+i.segments.indexOf(e)),type:e.videoTimingInfo?"accurate":"estimate"})},sI=function(r,i){if(!i||!i.segments||i.segments.length===0)return null;for(var t=0,e=void 0,a=0;a<i.segments.length&&(e=i.segments[a],t=e.videoTimingInfo?e.videoTimingInfo.transmuxedPresentationEnd:t+e.duration,!(r<=t));a++);var s=i.segments[i.segments.length-1];if(s.videoTimingInfo&&s.videoTimingInfo.transmuxedPresentationEnd<r)return null;if(r>t){if(r>t+s.duration*Hb)return null;e=s}return{segment:e,estimatedStart:e.videoTimingInfo?e.videoTimingInfo.transmuxedPresentationStart:t-e.duration,type:e.videoTimingInfo?"accurate":"estimate"}},oI=function(r,i){var t=void 0,e=void 0;try{t=new Date(r),e=new Date(i)}catch{}var a=t.getTime(),s=e.getTime();return(s-a)/1e3},uI=function(r){if(!r.segments||r.segments.length===0)return!1;for(var i=0;i<r.segments.length;i++){var t=r.segments[i];if(!t.dateTimeObject)return!1}return!0},lI=function(r){var i=r.playlist,t=r.time,e=t===void 0?void 0:t,a=r.callback;if(!a)throw new Error("getProgramTime: callback must be provided");if(!i||e===void 0)return a({message:"getProgramTime: playlist and time must be provided"});var s=sI(e,i);if(!s)return a({message:"valid programTime was not found"});if(s.type==="estimate")return a({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:s.estimatedStart});var o={mediaSeconds:e},u=iI(e,s.segment);return u&&(o.programDateTime=u.toISOString()),a(null,o)},dI=function n(r){var i=r.programTime,t=r.playlist,e=r.retryCount,a=e===void 0?2:e,s=r.seekTo,o=r.pauseAfterSeek,u=o===void 0?!0:o,l=r.tech,c=r.callback;if(!c)throw new Error("seekToProgramTime: callback must be provided");if(typeof i>"u"||!t||!s)return c({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!t.endList&&!l.hasStarted_)return c({message:"player must be playing a live stream to start buffering"});if(!uI(t))return c({message:"programDateTime tags must be provided in the manifest "+t.resolvedUri});var d=aI(i,t);if(!d)return c({message:i+" was not found in the stream"});var f=d.segment,h=oI(f.dateTimeObject,i);if(d.type==="estimate"){if(a===0)return c({message:i+" is not buffered yet. Try again"});s(d.estimatedStart+h),l.one("seeked",function(){n({programTime:i,playlist:t,retryCount:a-1,seekTo:s,pauseAfterSeek:u,tech:l,callback:c})});return}var g=f.start+h,p=function(){return c(null,l.currentTime())};l.one("seeked",p),u&&l.pause(),s(g)},cf=1/30,Ja=cf*3,Gb=function(r,i){var t=[],e=void 0;if(r&&r.length)for(e=0;e<r.length;e++)i(r.start(e),r.end(e))&&t.push([r.start(e),r.end(e)]);return oe.createTimeRanges(t)},Vb=function(r,i){return Gb(r,function(t,e){return t-Ja<=i&&e+Ja>=i})},qb=function(r,i){return Gb(r,function(t){return t-cf>=i})},cI=function(r){if(r.length<2)return oe.createTimeRanges();for(var i=[],t=1;t<r.length;t++){var e=r.end(t-1),a=r.start(t);i.push([e,a])}return oe.createTimeRanges(i)},qg=function(r){var i=[];if(!r||!r.length)return"";for(var t=0;t<r.length;t++)i.push(r.start(t)+" => "+r.end(t));return i.join(", ")},fI=function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,e=r.length?r.end(r.length-1):0;return(e-i)/t},$b=function(r){for(var i=[],t=0;t<r.length;t++)i.push({start:r.start(t),end:r.end(t)});return i},hI=function(r,i,t){var e=i.player_;if(t.captions&&t.captions.length){r.inbandTextTracks_||(r.inbandTextTracks_={});for(var a in t.captionStreams)if(!r.inbandTextTracks_[a]){e.tech_.trigger({type:"usage",name:"hls-608"});var s=e.textTracks().getTrackById(a);s?r.inbandTextTracks_[a]=s:r.inbandTextTracks_[a]=e.addRemoteTextTrack({kind:"captions",id:a,label:a},!1).track}}t.metadata&&t.metadata.length&&!r.metadataTrack_&&(r.metadataTrack_=e.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,r.metadataTrack_.inBandMetadataTrackDispatchType=t.metadata.dispatchType)},Nu=function(r,i,t){var e=void 0,a=void 0;if(!!t&&!!t.cues)for(e=t.cues.length;e--;)a=t.cues[e],a.startTime<=i&&a.endTime>=r&&t.removeCue(a)},pI=function(r){Object.defineProperties(r.frame,{id:{get:function(){return oe.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),r.value.key}},value:{get:function(){return oe.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),r.value.data}},privateData:{get:function(){return oe.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),r.value.data}}})},Wb=function(r){var i=void 0;return isNaN(r)||Math.abs(r)===1/0?i=Number.MAX_VALUE:i=r,i},gI=function(r,i,t){var e=Pe.WebKitDataCue||Pe.VTTCue;if(i&&i.forEach(function(d){var f=d.stream;this.inbandTextTracks_[f].addCue(new e(d.startTime+this.timestampOffset,d.endTime+this.timestampOffset,d.text))},r),t){var a=Wb(r.mediaSource_.duration);if(t.forEach(function(d){var f=d.cueTime+this.timestampOffset;typeof f!="number"||Pe.isNaN(f)||f<0||!(f<1/0)||d.frames.forEach(function(h){var g=new e(f,f,h.value||h.url||h.data||"");g.frame=h,g.value=h,pI(g),this.metadataTrack_.addCue(g)},this)},r),r.metadataTrack_&&r.metadataTrack_.cues&&r.metadataTrack_.cues.length){for(var s=r.metadataTrack_.cues,o=[],u=0;u<s.length;u++)s[u]&&o.push(s[u]);var l=o.reduce(function(d,f){var h=d[f.startTime]||[];return h.push(f),d[f.startTime]=h,d},{}),c=Object.keys(l).sort(function(d,f){return Number(d)-Number(f)});c.forEach(function(d,f){var h=l[d],g=Number(c[f+1])||a;h.forEach(function(p){p.endTime=g})})}}},To=typeof window<"u"?window:{},$g=typeof Symbol>"u"?"__target":Symbol(),vI="application/javascript",mI=To.BlobBuilder||To.WebKitBlobBuilder||To.MozBlobBuilder||To.MSBlobBuilder,Bu=To.URL||To.webkitURL||Bu&&Bu.msURL,Uu=To.Worker;function Kb(n,r){return function(t){var e=this;if(r)if(Uu&&!t){var a=r.toString().replace(/^function.+?{/,"").slice(0,-1),s=Yb(a);return this[$g]=new Uu(s),yI(this[$g],s),this[$g]}else{var o={postMessage:function(l){e.onmessage&&setTimeout(function(){e.onmessage({data:l,target:o})})}};r.call(o),this.postMessage=function(u){setTimeout(function(){o.onmessage({data:u,target:e})})},this.isThisThread=!0}else return new Uu(n)}}if(Uu){var ff,zb=Yb("self.onmessage = function () {}"),Xb=new Uint8Array(1);try{ff=new Uu(zb),ff.postMessage(Xb,[Xb.buffer])}catch{Uu=null}finally{Bu.revokeObjectURL(zb),ff&&ff.terminate()}}function Yb(n){try{return Bu.createObjectURL(new Blob([n],{type:vI}))}catch{var r=new mI;return r.append(n),Bu.createObjectURL(r.getBlob(type))}}function yI(n,r){if(!(!n||!r)){var i=n.terminate;n.objURL=r,n.terminate=function(){n.objURL&&Bu.revokeObjectURL(n.objURL),i.call(n)}}}var _I=new Kb("./transmuxer-worker.worker.js",function(n,r){var i=this;(function(){var t=function(){this.init=function(){var H={};this.on=function($,ee){H[$]||(H[$]=[]),H[$]=H[$].concat(ee)},this.off=function($,ee){var Z;return H[$]?(Z=H[$].indexOf(ee),H[$]=H[$].slice(),H[$].splice(Z,1),Z>-1):!1},this.trigger=function($){var ee,Z,le,ce;if(ee=H[$],!!ee)if(arguments.length===2)for(le=ee.length,Z=0;Z<le;++Z)ee[Z].call(this,arguments[1]);else{for(ce=[],Z=arguments.length,Z=1;Z<arguments.length;++Z)ce.push(arguments[Z]);for(le=ee.length,Z=0;Z<le;++Z)ee[Z].apply(this,ce)}},this.dispose=function(){H={}}}};t.prototype.pipe=function(_e){return this.on("data",function(H){_e.push(H)}),this.on("done",function(H){_e.flush(H)}),this.on("partialdone",function(H){_e.partialFlush(H)}),this.on("endedtimeline",function(H){_e.endTimeline(H)}),this.on("reset",function(H){_e.reset(H)}),_e},t.prototype.push=function(_e){this.trigger("data",_e)},t.prototype.flush=function(_e){this.trigger("done",_e)},t.prototype.partialFlush=function(_e){this.trigger("partialdone",_e)},t.prototype.endTimeline=function(_e){this.trigger("endedtimeline",_e)},t.prototype.reset=function(_e){this.trigger("reset",_e)};var e=t,a=Math.pow(2,32)-1,s,o,u,l,c,d,f,h,g,p,v,y,m,T,b,S,A,E,x,C,w,k,D,L,N,P,I,O,U,q,K,X,te,J,fe,ge;(function(){var _e;if(D={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(_e in D)D.hasOwnProperty(_e)&&(D[_e]=[_e.charCodeAt(0),_e.charCodeAt(1),_e.charCodeAt(2),_e.charCodeAt(3)]);L=new Uint8Array(["i".charCodeAt(0),"s".charCodeAt(0),"o".charCodeAt(0),"m".charCodeAt(0)]),P=new Uint8Array(["a".charCodeAt(0),"v".charCodeAt(0),"c".charCodeAt(0),"1".charCodeAt(0)]),N=new Uint8Array([0,0,0,1]),I=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),O=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),U={video:I,audio:O},X=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),K=new Uint8Array([0,0,0,0,0,0,0,0]),te=new Uint8Array([0,0,0,0,0,0,0,0]),J=te,fe=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),ge=te,q=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}})(),s=function(H){var $=[],ee=0,Z,le,ce;for(Z=1;Z<arguments.length;Z++)$.push(arguments[Z]);for(Z=$.length;Z--;)ee+=$[Z].byteLength;for(le=new Uint8Array(ee+8),ce=new DataView(le.buffer,le.byteOffset,le.byteLength),ce.setUint32(0,le.byteLength),le.set(H,4),Z=0,ee=8;Z<$.length;Z++)le.set($[Z],ee),ee+=$[Z].byteLength;return le},o=function(){return s(D.dinf,s(D.dref,X))},u=function(H){return s(D.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,H.audioobjecttype<<3|H.samplingfrequencyindex>>>1,H.samplingfrequencyindex<<7|H.channelcount<<3,6,1,2]))},l=function(){return s(D.ftyp,L,N,L,P)},S=function(H){return s(D.hdlr,U[H])},c=function(H){return s(D.mdat,H)},b=function(H){var $=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,H.duration>>>24&255,H.duration>>>16&255,H.duration>>>8&255,H.duration&255,85,196,0,0]);return H.samplerate&&($[12]=H.samplerate>>>24&255,$[13]=H.samplerate>>>16&255,$[14]=H.samplerate>>>8&255,$[15]=H.samplerate&255),s(D.mdhd,$)},T=function(H){return s(D.mdia,b(H),S(H.type),f(H))},d=function(H){return s(D.mfhd,new Uint8Array([0,0,0,0,(H&4278190080)>>24,(H&16711680)>>16,(H&65280)>>8,H&255]))},f=function(H){return s(D.minf,H.type==="video"?s(D.vmhd,q):s(D.smhd,K),o(),E(H))},h=function(H,$){for(var ee=[],Z=$.length;Z--;)ee[Z]=C($[Z]);return s.apply(null,[D.moof,d(H)].concat(ee))},g=function(H){for(var $=H.length,ee=[];$--;)ee[$]=y(H[$]);return s.apply(null,[D.moov,v(4294967295)].concat(ee).concat(p(H)))},p=function(H){for(var $=H.length,ee=[];$--;)ee[$]=w(H[$]);return s.apply(null,[D.mvex].concat(ee))},v=function(H){var $=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(H&4278190080)>>24,(H&16711680)>>16,(H&65280)>>8,H&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(D.mvhd,$)},A=function(H){var $=H.samples||[],ee=new Uint8Array(4+$.length),Z,le;for(le=0;le<$.length;le++)Z=$[le].flags,ee[le+4]=Z.dependsOn<<4|Z.isDependedOn<<2|Z.hasRedundancy;return s(D.sdtp,ee)},E=function(H){return s(D.stbl,x(H),s(D.stts,ge),s(D.stsc,J),s(D.stsz,fe),s(D.stco,te))},function(){var _e,H;x=function(ee){return s(D.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),ee.type==="video"?_e(ee):H(ee))},_e=function(ee){var Z=ee.sps||[],le=ee.pps||[],ce=[],be=[],Ee,Le;for(Ee=0;Ee<Z.length;Ee++)ce.push((Z[Ee].byteLength&65280)>>>8),ce.push(Z[Ee].byteLength&255),ce=ce.concat(Array.prototype.slice.call(Z[Ee]));for(Ee=0;Ee<le.length;Ee++)be.push((le[Ee].byteLength&65280)>>>8),be.push(le[Ee].byteLength&255),be=be.concat(Array.prototype.slice.call(le[Ee]));if(Le=[D.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,(ee.width&65280)>>8,ee.width&255,(ee.height&65280)>>8,ee.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(D.avcC,new Uint8Array([1,ee.profileIdc,ee.profileCompatibility,ee.levelIdc,255].concat([Z.length],ce,[le.length],be))),s(D.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],ee.sarRatio){var He=ee.sarRatio[0],Tt=ee.sarRatio[1];Le.push(s(D.pasp,new Uint8Array([(He&4278190080)>>24,(He&16711680)>>16,(He&65280)>>8,He&255,(Tt&4278190080)>>24,(Tt&16711680)>>16,(Tt&65280)>>8,Tt&255])))}return s.apply(null,Le)},H=function(ee){return s(D.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(ee.channelcount&65280)>>8,ee.channelcount&255,(ee.samplesize&65280)>>8,ee.samplesize&255,0,0,0,0,(ee.samplerate&65280)>>8,ee.samplerate&255,0,0]),u(ee))}}(),m=function(H){var $=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(H.id&4278190080)>>24,(H.id&16711680)>>16,(H.id&65280)>>8,H.id&255,0,0,0,0,(H.duration&4278190080)>>24,(H.duration&16711680)>>16,(H.duration&65280)>>8,H.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,(H.width&65280)>>8,H.width&255,0,0,(H.height&65280)>>8,H.height&255,0,0]);return s(D.tkhd,$)},C=function(H){var $,ee,Z,le,ce,be,Ee;return $=s(D.tfhd,new Uint8Array([0,0,0,58,(H.id&4278190080)>>24,(H.id&16711680)>>16,(H.id&65280)>>8,H.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),be=Math.floor(H.baseMediaDecodeTime/(a+1)),Ee=Math.floor(H.baseMediaDecodeTime%(a+1)),ee=s(D.tfdt,new Uint8Array([1,0,0,0,be>>>24&255,be>>>16&255,be>>>8&255,be&255,Ee>>>24&255,Ee>>>16&255,Ee>>>8&255,Ee&255])),ce=32+20+8+16+8+8,H.type==="audio"?(Z=k(H,ce),s(D.traf,$,ee,Z)):(le=A(H),Z=k(H,le.length+ce),s(D.traf,$,ee,Z,le))},y=function(H){return H.duration=H.duration||4294967295,s(D.trak,m(H),T(H))},w=function(H){var $=new Uint8Array([0,0,0,0,(H.id&4278190080)>>24,(H.id&16711680)>>16,(H.id&65280)>>8,H.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return H.type!=="video"&&($[$.length-1]=0),s(D.trex,$)},function(){var _e,H,$;$=function(Z,le){var ce=0,be=0,Ee=0,Le=0;return Z.length&&(Z[0].duration!==void 0&&(ce=1),Z[0].size!==void 0&&(be=2),Z[0].flags!==void 0&&(Ee=4),Z[0].compositionTimeOffset!==void 0&&(Le=8)),[0,0,ce|be|Ee|Le,1,(Z.length&4278190080)>>>24,(Z.length&16711680)>>>16,(Z.length&65280)>>>8,Z.length&255,(le&4278190080)>>>24,(le&16711680)>>>16,(le&65280)>>>8,le&255]},H=function(Z,le){var ce,be,Ee,Le;for(be=Z.samples||[],le+=8+12+16*be.length,ce=$(be,le),Le=0;Le<be.length;Le++)Ee=be[Le],ce=ce.concat([(Ee.duration&4278190080)>>>24,(Ee.duration&16711680)>>>16,(Ee.duration&65280)>>>8,Ee.duration&255,(Ee.size&4278190080)>>>24,(Ee.size&16711680)>>>16,(Ee.size&65280)>>>8,Ee.size&255,Ee.flags.isLeading<<2|Ee.flags.dependsOn,Ee.flags.isDependedOn<<6|Ee.flags.hasRedundancy<<4|Ee.flags.paddingValue<<1|Ee.flags.isNonSyncSample,Ee.flags.degradationPriority&240<<8,Ee.flags.degradationPriority&15,(Ee.compositionTimeOffset&4278190080)>>>24,(Ee.compositionTimeOffset&16711680)>>>16,(Ee.compositionTimeOffset&65280)>>>8,Ee.compositionTimeOffset&255]);return s(D.trun,new Uint8Array(ce))},_e=function(Z,le){var ce,be,Ee,Le;for(be=Z.samples||[],le+=8+12+8*be.length,ce=$(be,le),Le=0;Le<be.length;Le++)Ee=be[Le],ce=ce.concat([(Ee.duration&4278190080)>>>24,(Ee.duration&16711680)>>>16,(Ee.duration&65280)>>>8,Ee.duration&255,(Ee.size&4278190080)>>>24,(Ee.size&16711680)>>>16,(Ee.size&65280)>>>8,Ee.size&255]);return s(D.trun,new Uint8Array(ce))},k=function(Z,le){return Z.type==="audio"?_e(Z,le):H(Z,le)}}();var Ie={ftyp:l,mdat:c,moof:h,moov:g,initSegment:function(H){var $=l(),ee=g(H),Z;return Z=new Uint8Array($.byteLength+ee.byteLength),Z.set($),Z.set(ee,$.byteLength),Z}},qe=function(H){var $,ee,Z=[],le=[];for(le.byteLength=0,le.nalCount=0,le.duration=0,Z.byteLength=0,$=0;$<H.length;$++)ee=H[$],ee.nalUnitType==="access_unit_delimiter_rbsp"?(Z.length&&(Z.duration=ee.dts-Z.dts,le.byteLength+=Z.byteLength,le.nalCount+=Z.length,le.duration+=Z.duration,le.push(Z)),Z=[ee],Z.byteLength=ee.data.byteLength,Z.pts=ee.pts,Z.dts=ee.dts):(ee.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"&&(Z.keyFrame=!0),Z.duration=ee.dts-Z.dts,Z.byteLength+=ee.data.byteLength,Z.push(ee));return le.length&&(!Z.duration||Z.duration<=0)&&(Z.duration=le[le.length-1].duration),le.byteLength+=Z.byteLength,le.nalCount+=Z.length,le.duration+=Z.duration,le.push(Z),le},Ne=function(H){var $,ee,Z=[],le=[];for(Z.byteLength=0,Z.nalCount=0,Z.duration=0,Z.pts=H[0].pts,Z.dts=H[0].dts,le.byteLength=0,le.nalCount=0,le.duration=0,le.pts=H[0].pts,le.dts=H[0].dts,$=0;$<H.length;$++)ee=H[$],ee.keyFrame?(Z.length&&(le.push(Z),le.byteLength+=Z.byteLength,le.nalCount+=Z.nalCount,le.duration+=Z.duration),Z=[ee],Z.nalCount=ee.length,Z.byteLength=ee.byteLength,Z.pts=ee.pts,Z.dts=ee.dts,Z.duration=ee.duration):(Z.duration+=ee.duration,Z.nalCount+=ee.length,Z.byteLength+=ee.byteLength,Z.push(ee));return le.length&&Z.duration<=0&&(Z.duration=le[le.length-1].duration),le.byteLength+=Z.byteLength,le.nalCount+=Z.nalCount,le.duration+=Z.duration,le.push(Z),le},Fe=function(H){var $;return!H[0][0].keyFrame&&H.length>1&&($=H.shift(),H.byteLength-=$.byteLength,H.nalCount-=$.nalCount,H[0][0].dts=$.dts,H[0][0].pts=$.pts,H[0][0].duration+=$.duration),H},at=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},xt=function(H,$){var ee=at();return ee.dataOffset=$,ee.compositionTimeOffset=H.pts-H.dts,ee.duration=H.duration,ee.size=4*H.length,ee.size+=H.byteLength,H.keyFrame&&(ee.flags.dependsOn=2,ee.flags.isNonSyncSample=0),ee},Pt=function(H,$){var ee,Z,le,ce,be,Ee=$||0,Le=[];for(ee=0;ee<H.length;ee++)for(ce=H[ee],Z=0;Z<ce.length;Z++)be=ce[Z],le=xt(be,Ee),Ee+=le.size,Le.push(le);return Le},Ht=function(H){var $,ee,Z,le,ce,be,Ee=0,Le=H.byteLength,He=H.nalCount,Tt=Le+4*He,pt=new Uint8Array(Tt),Mt=new DataView(pt.buffer);for($=0;$<H.length;$++)for(le=H[$],ee=0;ee<le.length;ee++)for(ce=le[ee],Z=0;Z<ce.length;Z++)be=ce[Z],Mt.setUint32(Ee,be.data.byteLength),Ee+=4,pt.set(be.data,Ee),Ee+=be.data.byteLength;return pt},Me=function(H,$){var ee,Z=$||0,le=[];return ee=xt(H,Z),le.push(ee),le},Xe=function(H){var $,ee,Z=0,le=H.byteLength,ce=H.length,be=le+4*ce,Ee=new Uint8Array(be),Le=new DataView(Ee.buffer);for($=0;$<H.length;$++)ee=H[$],Le.setUint32(Z,ee.data.byteLength),Z+=4,Ee.set(ee.data,Z),Z+=ee.data.byteLength;return Ee},et={groupNalsIntoFrames:qe,groupFramesIntoGops:Ne,extendFirstKeyFrame:Fe,generateSampleTable:Pt,concatenateNalData:Ht,generateSampleTableForFrame:Me,concatenateNalDataForFrame:Xe},nt=[33,16,5,32,164,27],ct=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],Oe=function(H){for(var $=[];H--;)$.push(0);return $},ft=function(H){return Object.keys(H).reduce(function($,ee){return $[ee]=new Uint8Array(H[ee].reduce(function(Z,le){return Z.concat(le)},[])),$},{})},Dt={96e3:[nt,[227,64],Oe(154),[56]],88200:[nt,[231],Oe(170),[56]],64e3:[nt,[248,192],Oe(240),[56]],48e3:[nt,[255,192],Oe(268),[55,148,128],Oe(54),[112]],44100:[nt,[255,192],Oe(268),[55,163,128],Oe(84),[112]],32e3:[nt,[255,192],Oe(268),[55,234],Oe(226),[112]],24e3:[nt,[255,192],Oe(268),[55,255,128],Oe(268),[111,112],Oe(126),[224]],16e3:[nt,[255,192],Oe(268),[55,255,128],Oe(268),[111,255],Oe(269),[223,108],Oe(195),[1,192]],12e3:[ct,Oe(268),[3,127,248],Oe(268),[6,255,240],Oe(268),[13,255,224],Oe(268),[27,253,128],Oe(259),[56]],11025:[ct,Oe(268),[3,127,248],Oe(268),[6,255,240],Oe(268),[13,255,224],Oe(268),[27,255,192],Oe(268),[55,175,128],Oe(108),[112]],8e3:[ct,Oe(268),[3,121,16],Oe(47),[7]]},Nt=ft(Dt),Ve=9e4,hr,Mr,Yt,jr,Fr,ni,Hr;hr=function(H){return H*Ve},Mr=function(H,$){return H*$},Yt=function(H){return H/Ve},jr=function(H,$){return H/$},Fr=function(H,$){return hr(jr(H,$))},ni=function(H,$){return Mr(Yt(H),$)},Hr=function(H,$,ee){return Yt(ee?H:H-$)};var Ot={ONE_SECOND_IN_TS:Ve,secondsToVideoTs:hr,secondsToAudioTs:Mr,videoTsToSeconds:Yt,audioTsToSeconds:jr,audioTsToVideoTs:Fr,videoTsToAudioTs:ni,metadataTsToSeconds:Hr},Sr=function(H){var $,ee,Z=0;for($=0;$<H.length;$++)ee=H[$],Z+=ee.data.byteLength;return Z},_n=function(H,$,ee,Z){var le,ce=0,be=0,Ee=0,Le=0,He,Tt,pt;if(!!$.length&&(le=Ot.audioTsToVideoTs(H.baseMediaDecodeTime,H.samplerate),ce=Math.ceil(Ot.ONE_SECOND_IN_TS/(H.samplerate/1024)),ee&&Z&&(be=le-Math.max(ee,Z),Ee=Math.floor(be/ce),Le=Ee*ce),!(Ee<1||Le>Ot.ONE_SECOND_IN_TS/2))){for(He=Nt[H.samplerate],He||(He=$[0].data),Tt=0;Tt<Ee;Tt++)pt=$[0],$.splice(0,0,{data:He,dts:pt.dts-ce,pts:pt.pts-ce});H.baseMediaDecodeTime-=Math.floor(Ot.videoTsToAudioTs(Le,H.samplerate))}},ta=function(H,$,ee){return $.minSegmentDts>=ee?H:($.minSegmentDts=1/0,H.filter(function(Z){return Z.dts>=ee?($.minSegmentDts=Math.min($.minSegmentDts,Z.dts),$.minSegmentPts=$.minSegmentDts,!0):!1}))},Xs=function(H){var $,ee,Z=[];for($=0;$<H.length;$++)ee=H[$],Z.push({size:ee.data.byteLength,duration:1024});return Z},Xo=function(H){var $,ee,Z=0,le=new Uint8Array(Sr(H));for($=0;$<H.length;$++)ee=H[$],le.set(ee.data,Z),Z+=ee.data.byteLength;return le},bi={prefixWithSilence:_n,trimAdtsFramesByEarliestDts:ta,generateSampleTable:Xs,concatenateFrameData:Xo},ra=Ot.ONE_SECOND_IN_TS,Ys=function(H,$){typeof $.pts=="number"&&(H.timelineStartInfo.pts===void 0&&(H.timelineStartInfo.pts=$.pts),H.minSegmentPts===void 0?H.minSegmentPts=$.pts:H.minSegmentPts=Math.min(H.minSegmentPts,$.pts),H.maxSegmentPts===void 0?H.maxSegmentPts=$.pts:H.maxSegmentPts=Math.max(H.maxSegmentPts,$.pts)),typeof $.dts=="number"&&(H.timelineStartInfo.dts===void 0&&(H.timelineStartInfo.dts=$.dts),H.minSegmentDts===void 0?H.minSegmentDts=$.dts:H.minSegmentDts=Math.min(H.minSegmentDts,$.dts),H.maxSegmentDts===void 0?H.maxSegmentDts=$.dts:H.maxSegmentDts=Math.max(H.maxSegmentDts,$.dts))},Si=function(H){delete H.minSegmentDts,delete H.maxSegmentDts,delete H.minSegmentPts,delete H.maxSegmentPts},ia=function(H,$){var ee,Z,le=H.minSegmentDts;return $||(le-=H.timelineStartInfo.dts),ee=H.timelineStartInfo.baseMediaDecodeTime,ee+=le,ee=Math.max(0,ee),H.type==="audio"&&(Z=H.samplerate/ra,ee*=Z,ee=Math.floor(ee)),ee},Er={clearDtsInfo:Si,calculateTrackBaseMediaDecodeTime:ia,collectDtsInfo:Ys},Ra=4,Yo=128,Qo=function(H){for(var $=0,ee={payloadType:-1,payloadSize:0},Z=0,le=0;$<H.byteLength&&H[$]!==Yo;){for(;H[$]===255;)Z+=255,$++;for(Z+=H[$++];H[$]===255;)le+=255,$++;if(le+=H[$++],!ee.payload&&Z===Ra){ee.payloadType=Z,ee.payloadSize=le,ee.payload=H.subarray($,$+le);break}$+=le,Z=0,le=0}return ee},Qs=function(H){return H.payload[0]!==181||(H.payload[1]<<8|H.payload[2])!==49||String.fromCharCode(H.payload[3],H.payload[4],H.payload[5],H.payload[6])!=="GA94"||H.payload[7]!==3?null:H.payload.subarray(8,H.payload.length-1)},Jo=function(H,$){var ee=[],Z,le,ce,be;if(!($[0]&64))return ee;for(le=$[0]&31,Z=0;Z<le;Z++)ce=Z*3,be={type:$[ce+2]&3,pts:H},$[ce+2]&4&&(be.ccData=$[ce+3]<<8|$[ce+4],ee.push(be));return ee},Zo=function(H){for(var $=H.byteLength,ee=[],Z=1,le,ce;Z<$-2;)H[Z]===0&&H[Z+1]===0&&H[Z+2]===3?(ee.push(Z+2),Z+=2):Z++;if(ee.length===0)return H;le=$-ee.length,ce=new Uint8Array(le);var be=0;for(Z=0;Z<le;be++,Z++)be===ee[0]&&(be++,ee.shift()),ce[Z]=H[be];return ce},Ii={parseSei:Qo,parseUserData:Qs,parseCaptionPackets:Jo,discardEmulationPreventionBytes:Zo,USER_DATA_REGISTERED_ITU_T_T35:Ra},mr=function _e(){_e.prototype.init.call(this),this.captionPackets_=[],this.ccStreams_=[new Bt(0,0),new Bt(0,1),new Bt(1,0),new Bt(1,1)],this.reset(),this.ccStreams_.forEach(function(H){H.on("data",this.trigger.bind(this,"data")),H.on("partialdone",this.trigger.bind(this,"partialdone")),H.on("done",this.trigger.bind(this,"done"))},this)};mr.prototype=new e,mr.prototype.push=function(_e){var H,$,ee;if(_e.nalUnitType==="sei_rbsp"&&(H=Ii.parseSei(_e.escapedRBSP),H.payloadType===Ii.USER_DATA_REGISTERED_ITU_T_T35&&($=Ii.parseUserData(H),!!$))){if(_e.dts<this.latestDts_){this.ignoreNextEqualDts_=!0;return}else if(_e.dts===this.latestDts_&&this.ignoreNextEqualDts_){this.numSameDts_--,this.numSameDts_||(this.ignoreNextEqualDts_=!1);return}ee=Ii.parseCaptionPackets(_e.pts,$),this.captionPackets_=this.captionPackets_.concat(ee),this.latestDts_!==_e.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=_e.dts}},mr.prototype.flushCCStreams=function(_e){this.ccStreams_.forEach(function(H){return _e==="flush"?H.flush():H.partialFlush()},this)},mr.prototype.flushStream=function(_e){if(!this.captionPackets_.length){this.flushCCStreams(_e);return}this.captionPackets_.forEach(function(H,$){H.presortIndex=$}),this.captionPackets_.sort(function(H,$){return H.pts===$.pts?H.presortIndex-$.presortIndex:H.pts-$.pts}),this.captionPackets_.forEach(function(H){H.type<2&&this.dispatchCea608Packet(H)},this),this.captionPackets_.length=0,this.flushCCStreams(_e)},mr.prototype.flush=function(){return this.flushStream("flush")},mr.prototype.partialFlush=function(){return this.flushStream("partialFlush")},mr.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(_e){_e.reset()})},mr.prototype.dispatchCea608Packet=function(_e){this.setsTextOrXDSActive(_e)?this.activeCea608Channel_[_e.type]=null:this.setsChannel1Active(_e)?this.activeCea608Channel_[_e.type]=0:this.setsChannel2Active(_e)&&(this.activeCea608Channel_[_e.type]=1),this.activeCea608Channel_[_e.type]!==null&&this.ccStreams_[(_e.type<<1)+this.activeCea608Channel_[_e.type]].push(_e)},mr.prototype.setsChannel1Active=function(_e){return(_e.ccData&30720)===4096},mr.prototype.setsChannel2Active=function(_e){return(_e.ccData&30720)===6144},mr.prototype.setsTextOrXDSActive=function(_e){return(_e.ccData&28928)===256||(_e.ccData&30974)===4138||(_e.ccData&30974)===6186};var eu={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},Ia=function(H){return H===null?"":(H=eu[H]||H,String.fromCharCode(H))},Tn=14,Li=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],Ei=function(){for(var H=[],$=Tn+1;$--;)H.push("");return H},Bt=function _e(H,$){_e.prototype.init.call(this),this.field_=H||0,this.dataChannel_=$||0,this.name_="CC"+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(ee){var Z,le,ce,be,Ee;if(Z=ee.ccData&32639,Z===this.lastControlCode_){this.lastControlCode_=null;return}if((Z&61440)===4096?this.lastControlCode_=Z:Z!==this.PADDING_&&(this.lastControlCode_=null),ce=Z>>>8,be=Z&255,Z!==this.PADDING_)if(Z===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(Z===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(ee.pts),this.flushDisplayed(ee.pts),le=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=le,this.startPts_=ee.pts;else if(Z===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(ee.pts);else if(Z===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(ee.pts);else if(Z===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(ee.pts);else if(Z===this.CARRIAGE_RETURN_)this.clearFormatting(ee.pts),this.flushDisplayed(ee.pts),this.shiftRowsUp_(),this.startPts_=ee.pts;else if(Z===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(Z===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(ee.pts),this.displayed_=Ei();else if(Z===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Ei();else if(Z===this.RESUME_DIRECT_CAPTIONING_)this.mode_!=="paintOn"&&(this.flushDisplayed(ee.pts),this.displayed_=Ei()),this.mode_="paintOn",this.startPts_=ee.pts;else if(this.isSpecialCharacter(ce,be))ce=(ce&3)<<8,Ee=Ia(ce|be),this[this.mode_](ee.pts,Ee),this.column_++;else if(this.isExtCharacter(ce,be))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),ce=(ce&3)<<8,Ee=Ia(ce|be),this[this.mode_](ee.pts,Ee),this.column_++;else if(this.isMidRowCode(ce,be))this.clearFormatting(ee.pts),this[this.mode_](ee.pts," "),this.column_++,(be&14)===14&&this.addFormatting(ee.pts,["i"]),(be&1)===1&&this.addFormatting(ee.pts,["u"]);else if(this.isOffsetControlCode(ce,be))this.column_+=be&3;else if(this.isPAC(ce,be)){var Le=Li.indexOf(Z&7968);this.mode_==="rollUp"&&(Le-this.rollUpRows_+1<0&&(Le=this.rollUpRows_-1),this.setRollUp(ee.pts,Le)),Le!==this.row_&&(this.clearFormatting(ee.pts),this.row_=Le),be&1&&this.formatting_.indexOf("u")===-1&&this.addFormatting(ee.pts,["u"]),(Z&16)===16&&(this.column_=((Z&14)>>1)*4),this.isColorPAC(be)&&(be&14)===14&&this.addFormatting(ee.pts,["i"])}else this.isNormalChar(ce)&&(be===0&&(be=null),Ee=Ia(ce),Ee+=Ia(be),this[this.mode_](ee.pts,Ee),this.column_+=Ee.length)}};Bt.prototype=new e,Bt.prototype.flushDisplayed=function(_e){var H=this.displayed_.map(function($){try{return $.trim()}catch{return console.error("Skipping malformed caption."),""}}).join(`
|
|
86
86
|
`).replace(/^\n+|\n+$/g,"");H.length&&this.trigger("data",{startPts:this.startPts_,endPts:_e,text:H,stream:this.name_})},Bt.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=Ei(),this.nonDisplayed_=Ei(),this.lastControlCode_=null,this.column_=0,this.row_=Tn,this.rollUpRows_=2,this.formatting_=[]},Bt.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},Bt.prototype.isSpecialCharacter=function(_e,H){return _e===this.EXT_&&H>=48&&H<=63},Bt.prototype.isExtCharacter=function(_e,H){return(_e===this.EXT_+1||_e===this.EXT_+2)&&H>=32&&H<=63},Bt.prototype.isMidRowCode=function(_e,H){return _e===this.EXT_&&H>=32&&H<=47},Bt.prototype.isOffsetControlCode=function(_e,H){return _e===this.OFFSET_&&H>=33&&H<=35},Bt.prototype.isPAC=function(_e,H){return _e>=this.BASE_&&_e<this.BASE_+8&&H>=64&&H<=127},Bt.prototype.isColorPAC=function(_e){return _e>=64&&_e<=79||_e>=96&&_e<=127},Bt.prototype.isNormalChar=function(_e){return _e>=32&&_e<=127},Bt.prototype.setRollUp=function(_e,H){if(this.mode_!=="rollUp"&&(this.row_=Tn,this.mode_="rollUp",this.flushDisplayed(_e),this.nonDisplayed_=Ei(),this.displayed_=Ei()),H!==void 0&&H!==this.row_)for(var $=0;$<this.rollUpRows_;$++)this.displayed_[H-$]=this.displayed_[this.row_-$],this.displayed_[this.row_-$]="";H===void 0&&(H=this.row_),this.topRow_=H-this.rollUpRows_+1},Bt.prototype.addFormatting=function(_e,H){this.formatting_=this.formatting_.concat(H);var $=H.reduce(function(ee,Z){return ee+"<"+Z+">"},"");this[this.mode_](_e,$)},Bt.prototype.clearFormatting=function(_e){if(!!this.formatting_.length){var H=this.formatting_.reverse().reduce(function($,ee){return $+"</"+ee+">"},"");this.formatting_=[],this[this.mode_](_e,H)}},Bt.prototype.popOn=function(_e,H){var $=this.nonDisplayed_[this.row_];$+=H,this.nonDisplayed_[this.row_]=$},Bt.prototype.rollUp=function(_e,H){var $=this.displayed_[this.row_];$+=H,this.displayed_[this.row_]=$},Bt.prototype.shiftRowsUp_=function(){var _e;for(_e=0;_e<this.topRow_;_e++)this.displayed_[_e]="";for(_e=this.row_+1;_e<Tn+1;_e++)this.displayed_[_e]="";for(_e=this.topRow_;_e<this.row_;_e++)this.displayed_[_e]=this.displayed_[_e+1];this.displayed_[this.row_]=""},Bt.prototype.paintOn=function(_e,H){var $=this.displayed_[this.row_];$+=H,this.displayed_[this.row_]=$};var Js={CaptionStream:mr,Cea608Stream:Bt},qr={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},La=8589934592,tu=4294967296,an="shared",gr=function(H,$){var ee=1;for(H>$&&(ee=-1);Math.abs($-H)>tu;)H+=ee*La;return H},na=function _e(H){var $,ee;_e.prototype.init.call(this),this.type_=H||an,this.push=function(Z){this.type_!==an&&Z.type!==this.type_||(ee===void 0&&(ee=Z.dts),Z.dts=gr(Z.dts,ee),Z.pts=gr(Z.pts,ee),$=Z.dts,this.trigger("data",Z))},this.flush=function(){ee=$,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){ee=void 0,$=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};na.prototype=new e;var Gr={TimestampRolloverStream:na,handleRollover:gr},ys=function(H,$,ee){var Z,le="";for(Z=$;Z<ee;Z++)le+="%"+("00"+H[Z].toString(16)).slice(-2);return le},Oa=function(H,$,ee){return decodeURIComponent(ys(H,$,ee))},Zs=function(H,$,ee){return unescape(ys(H,$,ee))},sn=function(H){return H[0]<<21|H[1]<<14|H[2]<<7|H[3]},Ma={TXXX:function(H){var $;if(H.data[0]===3){for($=1;$<H.data.length;$++)if(H.data[$]===0){H.description=Oa(H.data,1,$),H.value=Oa(H.data,$+1,H.data.length).replace(/\0*$/,"");break}H.data=H.value}},WXXX:function(H){var $;if(H.data[0]===3){for($=1;$<H.data.length;$++)if(H.data[$]===0){H.description=Oa(H.data,1,$),H.url=Oa(H.data,$+1,H.data.length);break}}},PRIV:function(H){var $;for($=0;$<H.data.length;$++)if(H.data[$]===0){H.owner=Zs(H.data,0,$);break}H.privateData=H.data.subarray($+1),H.data=H.privateData}},bn;bn=function(H){var $={debug:!!(H&&H.debug),descriptor:H&&H.descriptor},ee=0,Z=[],le=0,ce;if(bn.prototype.init.call(this),this.dispatchType=qr.METADATA_STREAM_TYPE.toString(16),$.descriptor)for(ce=0;ce<$.descriptor.length;ce++)this.dispatchType+=("00"+$.descriptor[ce].toString(16)).slice(-2);this.push=function(be){var Ee,Le,He,Tt,pt,Mt;if(be.type==="timed-metadata"){if(be.dataAlignmentIndicator&&(le=0,Z.length=0),Z.length===0&&(be.data.length<10||be.data[0]!=="I".charCodeAt(0)||be.data[1]!=="D".charCodeAt(0)||be.data[2]!=="3".charCodeAt(0))){$.debug&&console.log("Skipping unrecognized metadata packet");return}if(Z.push(be),le+=be.data.byteLength,Z.length===1&&(ee=sn(be.data.subarray(6,10)),ee+=10),!(le<ee)){for(Ee={data:new Uint8Array(ee),frames:[],pts:Z[0].pts,dts:Z[0].dts},pt=0;pt<ee;)Ee.data.set(Z[0].data.subarray(0,ee-pt),pt),pt+=Z[0].data.byteLength,le-=Z[0].data.byteLength,Z.shift();Le=10,Ee.data[5]&64&&(Le+=4,Le+=sn(Ee.data.subarray(10,14)),ee-=sn(Ee.data.subarray(16,20)));do{if(He=sn(Ee.data.subarray(Le+4,Le+8)),He<1)return console.log("Malformed ID3 frame encountered. Skipping metadata parsing.");if(Mt=String.fromCharCode(Ee.data[Le],Ee.data[Le+1],Ee.data[Le+2],Ee.data[Le+3]),Tt={id:Mt,data:Ee.data.subarray(Le+10,Le+He+10)},Tt.key=Tt.id,Ma[Tt.id]&&(Ma[Tt.id](Tt),Tt.owner==="com.apple.streaming.transportStreamTimestamp")){var Wt=Tt.data,tr=(Wt[3]&1)<<30|Wt[4]<<22|Wt[5]<<14|Wt[6]<<6|Wt[7]>>>2;tr*=4,tr+=Wt[7]&3,Tt.timeStamp=tr,Ee.pts===void 0&&Ee.dts===void 0&&(Ee.pts=Tt.timeStamp,Ee.dts=Tt.timeStamp),this.trigger("timestamp",Tt)}Ee.frames.push(Tt),Le+=10,Le+=He}while(Le<ee);this.trigger("data",Ee)}}}},bn.prototype=new e;var Sn=bn,Mn=Gr.TimestampRolloverStream,Oi,on,un,xi=188,Fa=71;Oi=function(){var H=new Uint8Array(xi),$=0;Oi.prototype.init.call(this),this.push=function(ee){var Z=0,le=xi,ce;for($?(ce=new Uint8Array(ee.byteLength+$),ce.set(H.subarray(0,$)),ce.set(ee,$),$=0):ce=ee;le<ce.byteLength;){if(ce[Z]===Fa&&ce[le]===Fa){this.trigger("data",ce.subarray(Z,le)),Z+=xi,le+=xi;continue}Z++,le++}Z<ce.byteLength&&(H.set(ce.subarray(Z),0),$=ce.byteLength-Z)},this.flush=function(){$===xi&&H[0]===Fa&&(this.trigger("data",H),$=0),this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){$=0,this.trigger("reset")}},Oi.prototype=new e,on=function(){var H,$,ee,Z;on.prototype.init.call(this),Z=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,H=function(ce,be){var Ee=0;be.payloadUnitStartIndicator&&(Ee+=ce[Ee]+1),be.type==="pat"?$(ce.subarray(Ee),be):ee(ce.subarray(Ee),be)},$=function(ce,be){be.section_number=ce[7],be.last_section_number=ce[8],Z.pmtPid=(ce[10]&31)<<8|ce[11],be.pmtPid=Z.pmtPid},ee=function(ce,be){var Ee,Le,He,Tt;if(!!(ce[5]&1)){for(Z.programMapTable={video:null,audio:null,"timed-metadata":{}},Ee=(ce[1]&15)<<8|ce[2],Le=3+Ee-4,He=(ce[10]&15)<<8|ce[11],Tt=12+He;Tt<Le;){var pt=ce[Tt],Mt=(ce[Tt+1]&31)<<8|ce[Tt+2];pt===qr.H264_STREAM_TYPE&&Z.programMapTable.video===null?Z.programMapTable.video=Mt:pt===qr.ADTS_STREAM_TYPE&&Z.programMapTable.audio===null?Z.programMapTable.audio=Mt:pt===qr.METADATA_STREAM_TYPE&&(Z.programMapTable["timed-metadata"][Mt]=pt),Tt+=((ce[Tt+3]&15)<<8|ce[Tt+4])+5}be.programMapTable=Z.programMapTable}},this.push=function(le){var ce={},be=4;if(ce.payloadUnitStartIndicator=!!(le[1]&64),ce.pid=le[1]&31,ce.pid<<=8,ce.pid|=le[2],(le[3]&48)>>>4>1&&(be+=le[be]+1),ce.pid===0)ce.type="pat",H(le.subarray(be),ce),this.trigger("data",ce);else if(ce.pid===this.pmtPid)for(ce.type="pmt",H(le.subarray(be),ce),this.trigger("data",ce);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([le,be,ce]):this.processPes_(le,be,ce)},this.processPes_=function(le,ce,be){be.pid===this.programMapTable.video?be.streamType=qr.H264_STREAM_TYPE:be.pid===this.programMapTable.audio?be.streamType=qr.ADTS_STREAM_TYPE:be.streamType=this.programMapTable["timed-metadata"][be.pid],be.type="pes",be.data=le.subarray(ce),this.trigger("data",be)}},on.prototype=new e,on.STREAM_TYPES={h264:27,adts:15},un=function(){var H=this,$={data:[],size:0},ee={data:[],size:0},Z={data:[],size:0},le,ce=function(Le,He){var Tt;He.packetLength=6+(Le[4]<<8|Le[5]),He.dataAlignmentIndicator=(Le[6]&4)!==0,Tt=Le[7],Tt&192&&(He.pts=(Le[9]&14)<<27|(Le[10]&255)<<20|(Le[11]&254)<<12|(Le[12]&255)<<5|(Le[13]&254)>>>3,He.pts*=4,He.pts+=(Le[13]&6)>>>1,He.dts=He.pts,Tt&64&&(He.dts=(Le[14]&14)<<27|(Le[15]&255)<<20|(Le[16]&254)<<12|(Le[17]&255)<<5|(Le[18]&254)>>>3,He.dts*=4,He.dts+=(Le[18]&6)>>>1)),He.data=Le.subarray(9+Le[8])},be=function(Le,He,Tt){var pt=new Uint8Array(Le.size),Mt={type:He},Wt=0,tr=0,lt=!1,ti;if(!(!Le.data.length||Le.size<9)){for(Mt.trackId=Le.data[0].pid,Wt=0;Wt<Le.data.length;Wt++)ti=Le.data[Wt],pt.set(ti.data,tr),tr+=ti.data.byteLength;ce(pt,Mt),lt=He==="video"||Mt.packetLength<=Le.size,(Tt||lt)&&(Le.size=0,Le.data.length=0),lt&&H.trigger("data",Mt)}};un.prototype.init.call(this),this.push=function(Ee){({pat:function(){},pes:function(){var He,Tt;switch(Ee.streamType){case qr.H264_STREAM_TYPE:case qr.H264_STREAM_TYPE:He=$,Tt="video";break;case qr.ADTS_STREAM_TYPE:He=ee,Tt="audio";break;case qr.METADATA_STREAM_TYPE:He=Z,Tt="timed-metadata";break;default:return}Ee.payloadUnitStartIndicator&&be(He,Tt,!0),He.data.push(Ee),He.size+=Ee.data.byteLength},pmt:function(){var He={type:"metadata",tracks:[]};le=Ee.programMapTable,le.video!==null&&He.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+le.video,codec:"avc",type:"video"}),le.audio!==null&&He.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+le.audio,codec:"adts",type:"audio"}),H.trigger("data",He)}})[Ee.type]()},this.reset=function(){$.size=0,$.data.length=0,ee.size=0,ee.data.length=0,this.trigger("reset")},this.flushStreams_=function(){be($,"video"),be(ee,"audio"),be(Z,"timed-metadata")},this.flush=function(){this.flushStreams_(),this.trigger("done")}},un.prototype=new e;var _s={PAT_PID:0,MP2T_PACKET_LENGTH:xi,TransportPacketStream:Oi,TransportParseStream:on,ElementaryStream:un,TimestampRolloverStream:Mn,CaptionStream:Js.CaptionStream,Cea608Stream:Js.Cea608Stream,MetadataStream:Sn};for(var ln in qr)qr.hasOwnProperty(ln)&&(_s[ln]=qr[ln]);var ai=_s,aa=Ot.ONE_SECOND_IN_TS,se,ye=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];se=function(H){var $,ee=0;se.prototype.init.call(this),this.push=function(Z){var le=0,ce,be,Ee,Le,He,Tt;if(H||(ee=0),Z.type==="audio")for($?(Le=$,$=new Uint8Array(Le.byteLength+Z.data.byteLength),$.set(Le),$.set(Z.data,Le.byteLength)):$=Z.data;le+5<$.length;){if($[le]!==255||($[le+1]&246)!==240){le++;continue}if(be=(~$[le+1]&1)*2,ce=($[le+3]&3)<<11|$[le+4]<<3|($[le+5]&224)>>5,He=(($[le+6]&3)+1)*1024,Tt=He*aa/ye[($[le+2]&60)>>>2],Ee=le+ce,$.byteLength<Ee)return;if(this.trigger("data",{pts:Z.pts+ee*Tt,dts:Z.dts+ee*Tt,sampleCount:He,audioobjecttype:($[le+2]>>>6&3)+1,channelcount:($[le+2]&1)<<2|($[le+3]&192)>>>6,samplerate:ye[($[le+2]&60)>>>2],samplingfrequencyindex:($[le+2]&60)>>>2,samplesize:16,data:$.subarray(le+7+be,Ee)}),ee++,$.byteLength===Ee){$=void 0;return}$=$.subarray(Ee)}},this.flush=function(){ee=0,this.trigger("done")},this.reset=function(){$=void 0,this.trigger("reset")},this.endTimeline=function(){$=void 0,this.trigger("endedtimeline")}},se.prototype=new e;var de=se,Ae;Ae=function(H){var $=H.byteLength,ee=0,Z=0;this.length=function(){return 8*$},this.bitsAvailable=function(){return 8*$+Z},this.loadWord=function(){var le=H.byteLength-$,ce=new Uint8Array(4),be=Math.min(4,$);if(be===0)throw new Error("no bytes available");ce.set(H.subarray(le,le+be)),ee=new DataView(ce.buffer).getUint32(0),Z=be*8,$-=be},this.skipBits=function(le){var ce;Z>le?(ee<<=le,Z-=le):(le-=Z,ce=Math.floor(le/8),le-=ce*8,$-=ce,this.loadWord(),ee<<=le,Z-=le)},this.readBits=function(le){var ce=Math.min(Z,le),be=ee>>>32-ce;return Z-=ce,Z>0?ee<<=ce:$>0&&this.loadWord(),ce=le-ce,ce>0?be<<ce|this.readBits(ce):be},this.skipLeadingZeros=function(){var le;for(le=0;le<Z;++le)if((ee&2147483648>>>le)!==0)return ee<<=le,Z-=le,le;return this.loadWord(),le+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var le=this.skipLeadingZeros();return this.readBits(le+1)-1},this.readExpGolomb=function(){var le=this.readUnsignedExpGolomb();return 1&le?1+le>>>1:-1*(le>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};var De=Ae,xe,Be,Ye;Be=function(){var H=0,$,ee;Be.prototype.init.call(this),this.push=function(Z){var le;ee?(le=new Uint8Array(ee.byteLength+Z.data.byteLength),le.set(ee),le.set(Z.data,ee.byteLength),ee=le):ee=Z.data;for(var ce=ee.byteLength;H<ce-3;H++)if(ee[H+2]===1){$=H+5;break}for(;$<ce;)switch(ee[$]){case 0:if(ee[$-1]!==0){$+=2;break}else if(ee[$-2]!==0){$++;break}H+3!==$-2&&this.trigger("data",ee.subarray(H+3,$-2));do $++;while(ee[$]!==1&&$<ce);H=$-2,$+=3;break;case 1:if(ee[$-1]!==0||ee[$-2]!==0){$+=3;break}this.trigger("data",ee.subarray(H+3,$-2)),H=$-2,$+=3;break;default:$+=3;break}ee=ee.subarray(H),$-=H,H=0},this.reset=function(){ee=null,H=0,this.trigger("reset")},this.flush=function(){ee&&ee.byteLength>3&&this.trigger("data",ee.subarray(H+3)),ee=null,H=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}},Be.prototype=new e,Ye={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},xe=function(){var H=new Be,$,ee,Z,le,ce,be,Ee;xe.prototype.init.call(this),$=this,this.push=function(Le){Le.type==="video"&&(ee=Le.trackId,Z=Le.pts,le=Le.dts,H.push(Le))},H.on("data",function(Le){var He={trackId:ee,pts:Z,dts:le,data:Le};switch(Le[0]&31){case 5:He.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:He.nalUnitType="sei_rbsp",He.escapedRBSP=ce(Le.subarray(1));break;case 7:He.nalUnitType="seq_parameter_set_rbsp",He.escapedRBSP=ce(Le.subarray(1)),He.config=be(He.escapedRBSP);break;case 8:He.nalUnitType="pic_parameter_set_rbsp";break;case 9:He.nalUnitType="access_unit_delimiter_rbsp";break}$.trigger("data",He)}),H.on("done",function(){$.trigger("done")}),H.on("partialdone",function(){$.trigger("partialdone")}),H.on("reset",function(){$.trigger("reset")}),H.on("endedtimeline",function(){$.trigger("endedtimeline")}),this.flush=function(){H.flush()},this.partialFlush=function(){H.partialFlush()},this.reset=function(){H.reset()},this.endTimeline=function(){H.endTimeline()},Ee=function(He,Tt){var pt=8,Mt=8,Wt,tr;for(Wt=0;Wt<He;Wt++)Mt!==0&&(tr=Tt.readExpGolomb(),Mt=(pt+tr+256)%256),pt=Mt===0?pt:Mt},ce=function(He){for(var Tt=He.byteLength,pt=[],Mt=1,Wt,tr;Mt<Tt-2;)He[Mt]===0&&He[Mt+1]===0&&He[Mt+2]===3?(pt.push(Mt+2),Mt+=2):Mt++;if(pt.length===0)return He;Wt=Tt-pt.length,tr=new Uint8Array(Wt);var lt=0;for(Mt=0;Mt<Wt;lt++,Mt++)lt===pt[0]&&(lt++,pt.shift()),tr[Mt]=He[lt];return tr},be=function(He){var Tt=0,pt=0,Mt=0,Wt=0,tr=1,lt,ti,Mi,ja,ro,io,no,Un,ca,jn,si,Rr,nu,fa;if(lt=new De(He),ti=lt.readUnsignedByte(),ja=lt.readUnsignedByte(),Mi=lt.readUnsignedByte(),lt.skipUnsignedExpGolomb(),Ye[ti]&&(ro=lt.readUnsignedExpGolomb(),ro===3&<.skipBits(1),lt.skipUnsignedExpGolomb(),lt.skipUnsignedExpGolomb(),lt.skipBits(1),lt.readBoolean()))for(si=ro!==3?8:12,fa=0;fa<si;fa++)lt.readBoolean()&&(fa<6?Ee(16,lt):Ee(64,lt));if(lt.skipUnsignedExpGolomb(),io=lt.readUnsignedExpGolomb(),io===0)lt.readUnsignedExpGolomb();else if(io===1)for(lt.skipBits(1),lt.skipExpGolomb(),lt.skipExpGolomb(),no=lt.readUnsignedExpGolomb(),fa=0;fa<no;fa++)lt.skipExpGolomb();if(lt.skipUnsignedExpGolomb(),lt.skipBits(1),Un=lt.readUnsignedExpGolomb(),ca=lt.readUnsignedExpGolomb(),jn=lt.readBits(1),jn===0&<.skipBits(1),lt.skipBits(1),lt.readBoolean()&&(Tt=lt.readUnsignedExpGolomb(),pt=lt.readUnsignedExpGolomb(),Mt=lt.readUnsignedExpGolomb(),Wt=lt.readUnsignedExpGolomb()),lt.readBoolean()&<.readBoolean()){switch(nu=lt.readUnsignedByte(),nu){case 1:Rr=[1,1];break;case 2:Rr=[12,11];break;case 3:Rr=[10,11];break;case 4:Rr=[16,11];break;case 5:Rr=[40,33];break;case 6:Rr=[24,11];break;case 7:Rr=[20,11];break;case 8:Rr=[32,11];break;case 9:Rr=[80,33];break;case 10:Rr=[18,11];break;case 11:Rr=[15,11];break;case 12:Rr=[64,33];break;case 13:Rr=[160,99];break;case 14:Rr=[4,3];break;case 15:Rr=[3,2];break;case 16:Rr=[2,1];break;case 255:{Rr=[lt.readUnsignedByte()<<8|lt.readUnsignedByte(),lt.readUnsignedByte()<<8|lt.readUnsignedByte()];break}}Rr&&(tr=Rr[0]/Rr[1])}return{profileIdc:ti,levelIdc:Mi,profileCompatibility:ja,width:Math.ceil(((Un+1)*16-Tt*2-pt*2)*tr),height:(2-jn)*(ca+1)*16-Mt*2-Wt*2,sarRatio:Rr}}},xe.prototype=new e;var tt={H264Stream:xe,NalByteStream:Be},it=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],dt=function(H){return H[0]==="I".charCodeAt(0)&&H[1]==="D".charCodeAt(0)&&H[2]==="3".charCodeAt(0)},At=function(H){return H[0]<<21|H[1]<<14|H[2]<<7|H[3]},qt=function(H,$,ee){var Z,le="";for(Z=$;Z<ee;Z++)le+="%"+("00"+H[Z].toString(16)).slice(-2);return le},ur=function(H,$,ee){return unescape(qt(H,$,ee))},cr=function(H,$){var ee=H[$+6]<<21|H[$+7]<<14|H[$+8]<<7|H[$+9],Z=H[$+5],le=(Z&16)>>4;return le?ee+20:ee+10},Pr=function(H,$){var ee=(H[$+5]&224)>>5,Z=H[$+4]<<3,le=H[$+3]&3<<11;return le|Z|ee},xr=function(H,$){return H[$]==="I".charCodeAt(0)&&H[$+1]==="D".charCodeAt(0)&&H[$+2]==="3".charCodeAt(0)?"timed-metadata":H[$]&!0&&(H[$+1]&240)===240?"audio":null},vi=function(H){for(var $=0;$+5<H.length;){if(H[$]!==255||(H[$+1]&246)!==240){$++;continue}return it[(H[$+2]&60)>>>2]}return null},sa=function(H){var $,ee,Z,le;$=10,H[5]&64&&($+=4,$+=At(H.subarray(10,14)));do{if(ee=At(H.subarray($+4,$+8)),ee<1)return null;if(le=String.fromCharCode(H[$],H[$+1],H[$+2],H[$+3]),le==="PRIV"){Z=H.subarray($+10,$+ee+10);for(var ce=0;ce<Z.byteLength;ce++)if(Z[ce]===0){var be=ur(Z,0,ce);if(be==="com.apple.streaming.transportStreamTimestamp"){var Ee=Z.subarray(ce+1),Le=(Ee[3]&1)<<30|Ee[4]<<22|Ee[5]<<14|Ee[6]<<6|Ee[7]>>>2;return Le*=4,Le+=Ee[7]&3,Le}break}}$+=10,$+=ee}while($<H.byteLength);return null},Fn={isLikelyAacData:dt,parseId3TagSize:cr,parseAdtsSize:Pr,parseType:xr,parseSampleRate:vi,parseAacTimestamp:sa},dn;dn=function(){var H=new Uint8Array,$=0;dn.prototype.init.call(this),this.setTimestamp=function(ee){$=ee},this.push=function(ee){var Z=0,le=0,ce,be,Ee,Le;for(H.length?(Le=H.length,H=new Uint8Array(ee.byteLength+Le),H.set(H.subarray(0,Le)),H.set(ee,Le)):H=ee;H.length-le>=3;){if(H[le]==="I".charCodeAt(0)&&H[le+1]==="D".charCodeAt(0)&&H[le+2]==="3".charCodeAt(0)){if(H.length-le<10||(Z=Fn.parseId3TagSize(H,le),le+Z>H.length))break;be={type:"timed-metadata",data:H.subarray(le,le+Z)},this.trigger("data",be),le+=Z;continue}else if((H[le]&255)===255&&(H[le+1]&240)===240){if(H.length-le<7||(Z=Fn.parseAdtsSize(H,le),le+Z>H.length))break;Ee={type:"audio",data:H.subarray(le,le+Z),pts:$,dts:$},this.trigger("data",Ee),le+=Z;continue}le++}ce=H.length-le,ce>0?H=H.subarray(le):H=new Uint8Array},this.reset=function(){H=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){H=new Uint8Array,this.trigger("endedtimeline")}},dn.prototype=new e;var Ts=dn,kl=tt.H264Stream,Nn=Fn.isLikelyAacData,oa=Ot.ONE_SECOND_IN_TS,Na=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],Ba=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],Bn,Ua,eo,En,Dl=function(H,$){var ee;if(H.length!==$.length)return!1;for(ee=0;ee<H.length;ee++)if(H[ee]!==$[ee])return!1;return!0},ua=function(H,$,ee,Z,le,ce){var be=ee-$,Ee=Z-$,Le=le-ee;return{start:{dts:H,pts:H+be},end:{dts:H+Ee,pts:H+Le},prependedContentDuration:ce,baseMediaDecodeTime:H}};Ua=function(H,$){var ee=[],Z=0,le=0,ce=0,be=1/0;$=$||{},Ua.prototype.init.call(this),this.push=function(Ee){Er.collectDtsInfo(H,Ee),H&&Na.forEach(function(Le){H[Le]=Ee[Le]}),ee.push(Ee)},this.setEarliestDts=function(Ee){le=Ee-H.timelineStartInfo.baseMediaDecodeTime},this.setVideoBaseMediaDecodeTime=function(Ee){be=Ee},this.setAudioAppendStart=function(Ee){ce=Ee},this.flush=function(){var Ee,Le,He,Tt,pt;if(ee.length===0){this.trigger("done","AudioSegmentStream");return}Ee=bi.trimAdtsFramesByEarliestDts(ee,H,le),H.baseMediaDecodeTime=Er.calculateTrackBaseMediaDecodeTime(H,$.keepOriginalTimestamps),bi.prefixWithSilence(H,Ee,ce,be),H.samples=bi.generateSampleTable(Ee),He=Ie.mdat(bi.concatenateFrameData(Ee)),ee=[],Le=Ie.moof(Z,[H]),Tt=new Uint8Array(Le.byteLength+He.byteLength),Z++,Tt.set(Le),Tt.set(He,Le.byteLength),Er.clearDtsInfo(H),pt=Math.ceil(oa*1024/H.samplerate),Ee.length&&this.trigger("timingInfo",{start:Ee[0].dts,end:Ee[0].dts+Ee.length*pt}),this.trigger("data",{track:H,boxes:Tt}),this.trigger("done","AudioSegmentStream")},this.reset=function(){Er.clearDtsInfo(H),ee=[],this.trigger("reset")}},Ua.prototype=new e,Bn=function(H,$){var ee=0,Z=[],le=[],ce,be;$=$||{},Bn.prototype.init.call(this),delete H.minPTS,this.gopCache_=[],this.push=function(Ee){Er.collectDtsInfo(H,Ee),Ee.nalUnitType==="seq_parameter_set_rbsp"&&!ce&&(ce=Ee.config,H.sps=[Ee.data],Ba.forEach(function(Le){H[Le]=ce[Le]},this)),Ee.nalUnitType==="pic_parameter_set_rbsp"&&!be&&(be=Ee.data,H.pps=[Ee.data]),Z.push(Ee)},this.flush=function(){for(var Ee,Le,He,Tt,pt,Mt,Wt=0,tr,lt;Z.length&&Z[0].nalUnitType!=="access_unit_delimiter_rbsp";)Z.shift();if(Z.length===0){this.resetStream_(),this.trigger("done","VideoSegmentStream");return}if(Ee=et.groupNalsIntoFrames(Z),He=et.groupFramesIntoGops(Ee),He[0][0].keyFrame||(Le=this.getGopForFusion_(Z[0],H),Le?(Wt=Le.duration,He.unshift(Le),He.byteLength+=Le.byteLength,He.nalCount+=Le.nalCount,He.pts=Le.pts,He.dts=Le.dts,He.duration+=Le.duration):He=et.extendFirstKeyFrame(He)),le.length){var ti;if($.alignGopsAtEnd?ti=this.alignGopsAtEnd_(He):ti=this.alignGopsAtStart_(He),!ti){this.gopCache_.unshift({gop:He.pop(),pps:H.pps,sps:H.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),Z=[],this.resetStream_(),this.trigger("done","VideoSegmentStream");return}Er.clearDtsInfo(H),He=ti}Er.collectDtsInfo(H,He),H.samples=et.generateSampleTable(He),pt=Ie.mdat(et.concatenateNalData(He)),H.baseMediaDecodeTime=Er.calculateTrackBaseMediaDecodeTime(H,$.keepOriginalTimestamps),this.trigger("processedGopsInfo",He.map(function(Mi){return{pts:Mi.pts,dts:Mi.dts,byteLength:Mi.byteLength}})),tr=He[0],lt=He[He.length-1],this.trigger("segmentTimingInfo",ua(H.baseMediaDecodeTime,tr.dts,tr.pts,lt.dts+lt.duration,lt.pts+lt.duration,Wt)),this.trigger("timingInfo",{start:He[0].dts,end:He[He.length-1].dts+He[He.length-1].duration}),this.gopCache_.unshift({gop:He.pop(),pps:H.pps,sps:H.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),Z=[],this.trigger("baseMediaDecodeTime",H.baseMediaDecodeTime),this.trigger("timelineStartInfo",H.timelineStartInfo),Tt=Ie.moof(ee,[H]),Mt=new Uint8Array(Tt.byteLength+pt.byteLength),ee++,Mt.set(Tt),Mt.set(pt,Tt.byteLength),this.trigger("data",{track:H,boxes:Mt}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),Z=[],this.gopCache_.length=0,le.length=0,this.trigger("reset")},this.resetStream_=function(){Er.clearDtsInfo(H),ce=void 0,be=void 0},this.getGopForFusion_=function(Ee){var Le=45e3,He=1e4,Tt=1/0,pt,Mt,Wt,tr,lt;for(lt=0;lt<this.gopCache_.length;lt++)tr=this.gopCache_[lt],Wt=tr.gop,!(!(H.pps&&Dl(H.pps[0],tr.pps[0]))||!(H.sps&&Dl(H.sps[0],tr.sps[0])))&&(Wt.dts<H.timelineStartInfo.dts||(pt=Ee.dts-Wt.dts-Wt.duration,pt>=-He&&pt<=Le&&(!Mt||Tt>pt)&&(Mt=tr,Tt=pt)));return Mt?Mt.gop:null},this.alignGopsAtStart_=function(Ee){var Le,He,Tt,pt,Mt,Wt,tr,lt;for(Mt=Ee.byteLength,Wt=Ee.nalCount,tr=Ee.duration,Le=He=0;Le<le.length&&He<Ee.length&&(Tt=le[Le],pt=Ee[He],Tt.pts!==pt.pts);){if(pt.pts>Tt.pts){Le++;continue}He++,Mt-=pt.byteLength,Wt-=pt.nalCount,tr-=pt.duration}return He===0?Ee:He===Ee.length?null:(lt=Ee.slice(He),lt.byteLength=Mt,lt.duration=tr,lt.nalCount=Wt,lt.pts=lt[0].pts,lt.dts=lt[0].dts,lt)},this.alignGopsAtEnd_=function(Ee){var Le,He,Tt,pt,Mt,Wt;for(Le=le.length-1,He=Ee.length-1,Mt=null,Wt=!1;Le>=0&&He>=0;){if(Tt=le[Le],pt=Ee[He],Tt.pts===pt.pts){Wt=!0;break}if(Tt.pts>pt.pts){Le--;continue}Le===le.length-1&&(Mt=He),He--}if(!Wt&&Mt===null)return null;var tr;if(Wt?tr=He:tr=Mt,tr===0)return Ee;var lt=Ee.slice(tr),ti=lt.reduce(function(Mi,ja){return Mi.byteLength+=ja.byteLength,Mi.duration+=ja.duration,Mi.nalCount+=ja.nalCount,Mi},{byteLength:0,duration:0,nalCount:0});return lt.byteLength=ti.byteLength,lt.duration=ti.duration,lt.nalCount=ti.nalCount,lt.pts=lt[0].pts,lt.dts=lt[0].dts,lt},this.alignGopsWith=function(Ee){le=Ee}},Bn.prototype=new e,En=function(H,$){this.numberOfTracks=0,this.metadataStream=$,H=H||{},typeof H.remux<"u"?this.remuxTracks=!!H.remux:this.remuxTracks=!0,typeof H.keepOriginalTimestamps=="boolean"?this.keepOriginalTimestamps=H.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,En.prototype.init.call(this),this.push=function(ee){if(ee.text)return this.pendingCaptions.push(ee);if(ee.frames)return this.pendingMetadata.push(ee);this.pendingTracks.push(ee.track),this.pendingBytes+=ee.boxes.byteLength,ee.track.type==="video"&&(this.videoTrack=ee.track,this.pendingBoxes.push(ee.boxes)),ee.track.type==="audio"&&(this.audioTrack=ee.track,this.pendingBoxes.unshift(ee.boxes))}},En.prototype=new e,En.prototype.flush=function(_e){var H=0,$={captions:[],captionStreams:{},metadata:[],info:{}},ee,Z,le,ce=0,be;if(this.pendingTracks.length<this.numberOfTracks){if(_e!=="VideoSegmentStream"&&_e!=="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?(ce=this.videoTrack.timelineStartInfo.pts,Ba.forEach(function(Ee){$.info[Ee]=this.videoTrack[Ee]},this)):this.audioTrack&&(ce=this.audioTrack.timelineStartInfo.pts,Na.forEach(function(Ee){$.info[Ee]=this.audioTrack[Ee]},this)),this.videoTrack||this.audioTrack){for(this.pendingTracks.length===1?$.type=this.pendingTracks[0].type:$.type="combined",this.emittedTracks+=this.pendingTracks.length,le=Ie.initSegment(this.pendingTracks),$.initSegment=new Uint8Array(le.byteLength),$.initSegment.set(le),$.data=new Uint8Array(this.pendingBytes),be=0;be<this.pendingBoxes.length;be++)$.data.set(this.pendingBoxes[be],H),H+=this.pendingBoxes[be].byteLength;for(be=0;be<this.pendingCaptions.length;be++)ee=this.pendingCaptions[be],ee.startTime=Ot.metadataTsToSeconds(ee.startPts,ce,this.keepOriginalTimestamps),ee.endTime=Ot.metadataTsToSeconds(ee.endPts,ce,this.keepOriginalTimestamps),$.captionStreams[ee.stream]=!0,$.captions.push(ee);for(be=0;be<this.pendingMetadata.length;be++)Z=this.pendingMetadata[be],Z.cueTime=Ot.metadataTsToSeconds(Z.pts,ce,this.keepOriginalTimestamps),$.metadata.push(Z);for($.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",$),be=0;be<$.captions.length;be++)ee=$.captions[be],this.trigger("caption",ee);for(be=0;be<$.metadata.length;be++)Z=$.metadata[be],this.trigger("id3Frame",Z)}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},En.prototype.setRemux=function(_e){this.remuxTracks=_e},eo=function(H){var $=this,ee=!0,Z,le;eo.prototype.init.call(this),H=H||{},this.baseMediaDecodeTime=H.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var ce={};this.transmuxPipeline_=ce,ce.type="aac",ce.metadataStream=new ai.MetadataStream,ce.aacStream=new Ts,ce.audioTimestampRolloverStream=new ai.TimestampRolloverStream("audio"),ce.timedMetadataTimestampRolloverStream=new ai.TimestampRolloverStream("timed-metadata"),ce.adtsStream=new de,ce.coalesceStream=new En(H,ce.metadataStream),ce.headOfPipeline=ce.aacStream,ce.aacStream.pipe(ce.audioTimestampRolloverStream).pipe(ce.adtsStream),ce.aacStream.pipe(ce.timedMetadataTimestampRolloverStream).pipe(ce.metadataStream).pipe(ce.coalesceStream),ce.metadataStream.on("timestamp",function(be){ce.aacStream.setTimestamp(be.timeStamp)}),ce.aacStream.on("data",function(be){be.type==="timed-metadata"&&!ce.audioSegmentStream&&(le=le||{timelineStartInfo:{baseMediaDecodeTime:$.baseMediaDecodeTime},codec:"adts",type:"audio"},ce.coalesceStream.numberOfTracks++,ce.audioSegmentStream=new Ua(le,H),ce.audioSegmentStream.on("timingInfo",$.trigger.bind($,"audioTimingInfo")),ce.adtsStream.pipe(ce.audioSegmentStream).pipe(ce.coalesceStream)),$.trigger("trackinfo",{hasAudio:!!le,hasVideo:!!Z})}),ce.coalesceStream.on("data",this.trigger.bind(this,"data")),ce.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setupTsPipeline=function(){var ce={};this.transmuxPipeline_=ce,ce.type="ts",ce.metadataStream=new ai.MetadataStream,ce.packetStream=new ai.TransportPacketStream,ce.parseStream=new ai.TransportParseStream,ce.elementaryStream=new ai.ElementaryStream,ce.timestampRolloverStream=new ai.TimestampRolloverStream,ce.adtsStream=new de,ce.h264Stream=new kl,ce.captionStream=new ai.CaptionStream,ce.coalesceStream=new En(H,ce.metadataStream),ce.headOfPipeline=ce.packetStream,ce.packetStream.pipe(ce.parseStream).pipe(ce.elementaryStream).pipe(ce.timestampRolloverStream),ce.timestampRolloverStream.pipe(ce.h264Stream),ce.timestampRolloverStream.pipe(ce.adtsStream),ce.timestampRolloverStream.pipe(ce.metadataStream).pipe(ce.coalesceStream),ce.h264Stream.pipe(ce.captionStream).pipe(ce.coalesceStream),ce.elementaryStream.on("data",function(be){var Ee;if(be.type==="metadata"){for(Ee=be.tracks.length;Ee--;)!Z&&be.tracks[Ee].type==="video"?(Z=be.tracks[Ee],Z.timelineStartInfo.baseMediaDecodeTime=$.baseMediaDecodeTime):!le&&be.tracks[Ee].type==="audio"&&(le=be.tracks[Ee],le.timelineStartInfo.baseMediaDecodeTime=$.baseMediaDecodeTime);Z&&!ce.videoSegmentStream&&(ce.coalesceStream.numberOfTracks++,ce.videoSegmentStream=new Bn(Z,H),ce.videoSegmentStream.on("timelineStartInfo",function(Le){le&&(le.timelineStartInfo=Le,ce.audioSegmentStream.setEarliestDts(Le.dts))}),ce.videoSegmentStream.on("processedGopsInfo",$.trigger.bind($,"gopInfo")),ce.videoSegmentStream.on("segmentTimingInfo",$.trigger.bind($,"videoSegmentTimingInfo")),ce.videoSegmentStream.on("baseMediaDecodeTime",function(Le){le&&ce.audioSegmentStream.setVideoBaseMediaDecodeTime(Le)}),ce.videoSegmentStream.on("timingInfo",$.trigger.bind($,"videoTimingInfo")),ce.h264Stream.pipe(ce.videoSegmentStream).pipe(ce.coalesceStream)),le&&!ce.audioSegmentStream&&(ce.coalesceStream.numberOfTracks++,ce.audioSegmentStream=new Ua(le,H),ce.audioSegmentStream.on("timingInfo",$.trigger.bind($,"audioTimingInfo")),ce.adtsStream.pipe(ce.audioSegmentStream).pipe(ce.coalesceStream)),$.trigger("trackinfo",{hasAudio:!!le,hasVideo:!!Z})}}),ce.coalesceStream.on("data",this.trigger.bind(this,"data")),ce.coalesceStream.on("id3Frame",function(be){be.dispatchType=ce.metadataStream.dispatchType,$.trigger("id3Frame",be)}),ce.coalesceStream.on("caption",this.trigger.bind(this,"caption")),ce.coalesceStream.on("done",this.trigger.bind(this,"done"))},this.setBaseMediaDecodeTime=function(ce){var be=this.transmuxPipeline_;H.keepOriginalTimestamps||(this.baseMediaDecodeTime=ce),le&&(le.timelineStartInfo.dts=void 0,le.timelineStartInfo.pts=void 0,Er.clearDtsInfo(le),H.keepOriginalTimestamps||(le.timelineStartInfo.baseMediaDecodeTime=ce),be.audioTimestampRolloverStream&&be.audioTimestampRolloverStream.discontinuity()),Z&&(be.videoSegmentStream&&(be.videoSegmentStream.gopCache_=[]),Z.timelineStartInfo.dts=void 0,Z.timelineStartInfo.pts=void 0,Er.clearDtsInfo(Z),be.captionStream.reset(),H.keepOriginalTimestamps||(Z.timelineStartInfo.baseMediaDecodeTime=ce)),be.timestampRolloverStream&&be.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(ce){le&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(ce)},this.setRemux=function(ce){var be=this.transmuxPipeline_;H.remux=ce,be&&be.coalesceStream&&be.coalesceStream.setRemux(ce)},this.alignGopsWith=function(ce){Z&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(ce)},this.push=function(ce){if(ee){var be=Nn(ce);be&&this.transmuxPipeline_.type!=="aac"?this.setupAacPipeline():!be&&this.transmuxPipeline_.type!=="ts"&&this.setupTsPipeline(),ee=!1}this.transmuxPipeline_.headOfPipeline.push(ce)},this.flush=function(){ee=!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()}},eo.prototype=new e;var ru={Transmuxer:eo,VideoSegmentStream:Bn,AudioSegmentStream:Ua,AUDIO_PROPERTIES:Na,VIDEO_PROPERTIES:Ba,generateVideoSegmentTimingInfo:ua},Pl=function(H,$){if(!(H instanceof $))throw new TypeError("Cannot call a class as a function")},iu=function(){function _e(H,$){for(var ee=0;ee<$.length;ee++){var Z=$[ee];Z.enumerable=Z.enumerable||!1,Z.configurable=!0,"value"in Z&&(Z.writable=!0),Object.defineProperty(H,Z.key,Z)}}return function(H,$,ee){return $&&_e(H.prototype,$),ee&&_e(H,ee),H}}(),bs=function(H,$){$.on("data",function(ee){var Z=ee.initSegment;ee.initSegment={data:Z.buffer,byteOffset:Z.byteOffset,byteLength:Z.byteLength};var le=ee.data;ee.data=le.buffer,H.postMessage({action:"data",segment:ee,byteOffset:le.byteOffset,byteLength:le.byteLength},[ee.data])}),$.captionStream&&$.captionStream.on("data",function(ee){H.postMessage({action:"caption",data:ee})}),$.on("done",function(ee){H.postMessage({action:"done"})}),$.on("gopInfo",function(ee){H.postMessage({action:"gopInfo",gopInfo:ee})}),$.on("videoSegmentTimingInfo",function(ee){H.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:ee})})},la=function(){function _e(H,$){Pl(this,_e),this.options=$||{},this.self=H,this.init()}return iu(_e,[{key:"init",value:function(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new ru.Transmuxer(this.options),bs(this.self,this.transmuxer)}},{key:"push",value:function($){var ee=new Uint8Array($.data,$.byteOffset,$.byteLength);this.transmuxer.push(ee)}},{key:"reset",value:function(){this.init()}},{key:"setTimestampOffset",value:function($){var ee=$.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(ee*9e4))}},{key:"setAudioAppendStart",value:function($){this.transmuxer.setAudioAppendStart(Math.ceil($.appendStart*9e4))}},{key:"flush",value:function($){this.transmuxer.flush()}},{key:"resetCaptions",value:function(){this.transmuxer.resetCaptions()}},{key:"alignGopsWith",value:function($){this.transmuxer.alignGopsWith($.gopsToAlignWith.slice())}}]),_e}(),to=function(H){H.onmessage=function($){if($.data.action==="init"&&$.data.options){this.messageHandlers=new la(H,$.data.options);return}this.messageHandlers||(this.messageHandlers=new la(H)),$.data&&$.data.action&&$.data.action!=="init"&&this.messageHandlers[$.data.action]&&this.messageHandlers[$.data.action]($.data)}},da=new to(i);return da})()}),Qb={videoCodec:"avc1",videoObjectTypeIndicator:".4d400d",audioProfile:"2"},Jb=function(r){return r.map(function(i){return i.replace(/avc1\.(\d+)\.(\d+)/i,function(t,e,a){var s=("00"+Number(e).toString(16)).slice(-2),o=("00"+Number(a).toString(16)).slice(-2);return"avc1."+s+"00"+o})})},md=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",i={codecCount:0},t=void 0;return i.codecCount=r.split(",").length,i.codecCount=i.codecCount||2,t=/(^|\s|,)+(avc[13])([^ ,]*)/i.exec(r),t&&(i.videoCodec=t[2],i.videoObjectTypeIndicator=t[3]),i.audioProfile=/(^|\s|,)+mp4a.[0-9A-Fa-f]+\.([0-9A-Fa-f]+)/i.exec(r),i.audioProfile=i.audioProfile&&i.audioProfile[2],i},TI=function(r){return r.replace(/avc1\.(\d+)\.(\d+)/i,function(i){return Jb([i])[0]})},Wg=function(r,i,t){return r+"/"+i+'; codecs="'+t.filter(function(e){return!!e}).join(", ")+'"'},bI=function(r){return r.segments&&r.segments.length&&r.segments[0].map?"mp4":"mp2t"},SI=function(r){var i=r.attributes||{};return i.CODECS?md(i.CODECS):Qb},EI=function(r,i){if(!r.mediaGroups.AUDIO||!i)return null;var t=r.mediaGroups.AUDIO[i];if(!t)return null;for(var e in t){var a=t[e];if(a.default&&a.playlists)return md(a.playlists[0].attributes.CODECS).audioProfile}return null},xI=function(r,i){var t=bI(i),e=SI(i),a=i.attributes||{},s=!0,o=!1;if(!i)return[];if(r.mediaGroups.AUDIO&&a.AUDIO){var u=r.mediaGroups.AUDIO[a.AUDIO];if(u){o=!0,s=!1;for(var l in u)if(!u[l].uri&&!u[l].playlists){s=!0;break}}}o&&!e.audioProfile&&(s||(e.audioProfile=EI(r,a.AUDIO)),e.audioProfile||(oe.log.warn("Multiple audio tracks present but no audio codec string is specified. Attempting to use the default audio codec (mp4a.40.2)"),e.audioProfile=Qb.audioProfile));var c={};e.videoCodec&&(c.video=""+e.videoCodec+e.videoObjectTypeIndicator),e.audioProfile&&(c.audio="mp4a.40."+e.audioProfile);var d=Wg("audio",t,[c.audio]),f=Wg("video",t,[c.video]),h=Wg("video",t,[c.video,c.audio]);return o?!s&&c.video?[f,d]:!s&&!c.video?[d,d]:[h,d]:c.video?[h]:[d]},AI=function(r){var i={type:"",parameters:{}},t=r.trim().split(";");return i.type=t.shift().trim(),t.forEach(function(e){var a=e.trim().split("=");if(a.length>1){var s=a[0].replace(/"/g,"").trim(),o=a[1].replace(/"/g,"").trim();i.parameters[s]=o}}),i},Zb=function(r){return/mp4a\.\d+.\d+/i.test(r)},eS=function(r){return/avc1\.[\da-f]+/i.test(r)},CI=function(r,i,t){if(typeof i>"u"||i===null||!r.length)return[];var e=Math.ceil((i-t+3)*9e4),a=void 0;for(a=0;a<r.length&&!(r[a].pts>e);a++);return r.slice(a)},wI=function(r,i,t){if(!i.length)return r;if(t)return i.slice();var e=i[0].pts,a=0;for(a;a<r.length&&!(r[a].pts>=e);a++);return r.slice(0,a).concat(i)},kI=function(r,i,t,e){for(var a=Math.ceil((i-e)*9e4),s=Math.ceil((t-e)*9e4),o=r.slice(),u=r.length;u--&&!(r[u].pts<=s););if(u===-1)return o;for(var l=u+1;l--&&!(r[l].pts<=a););return l=Math.max(l,0),o.splice(l,u-l+1),o},DI=function(r,i,t){var e=null,a=null,s=0,o=[],u=[];if(!r&&!i)return oe.createTimeRange();if(!r)return i.buffered;if(!i||t)return r.buffered;if(r.buffered.length===0&&i.buffered.length===0)return oe.createTimeRange();for(var l=r.buffered,c=i.buffered,d=l.length;d--;)o.push({time:l.start(d),type:"start"}),o.push({time:l.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(f,h){return f.time-h.time}),d=0;d<o.length;d++)o[d].type==="start"?(s++,s===2&&(e=o[d].time)):o[d].type==="end"&&(s--,s===1&&(a=o[d].time)),e!==null&&a!==null&&(u.push([e,a]),e=null,a=null);return oe.createTimeRanges(u)},ju=9e4,PI=function(r,i){var t=r.addSourceBuffer(i),e=Object.create(null);e.updating=!1,e.realBuffer_=t;var a=function(u){typeof t[u]=="function"?e[u]=function(){return t[u].apply(t,arguments)}:typeof e[u]>"u"&&Object.defineProperty(e,u,{get:function(){return t[u]},set:function(c){return t[u]=c}})};for(var s in t)a(s);return e},RI=function(n){Qa(r,n);function r(i,t){Rn(this,r);var e=ma(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,oe.EventTarget));e.timestampOffset_=0,e.pendingBuffers_=[],e.bufferUpdating_=!1,e.mediaSource_=i,e.codecs_=t,e.audioCodec_=null,e.videoCodec_=null,e.audioDisabled_=!1,e.appendAudioInitSegment_=!0,e.gopBuffer_=[],e.timeMapping_=0,e.safeAppend_=oe.browser.IE_VERSION>=11;var a={remux:!1,alignGopsAtEnd:e.safeAppend_};return e.codecs_.forEach(function(s){Zb(s)?e.audioCodec_=s:eS(s)&&(e.videoCodec_=s)}),e.transmuxer_=new _I,e.transmuxer_.postMessage({action:"init",options:a}),e.transmuxer_.onmessage=function(s){if(s.data.action==="data")return e.data_(s);if(s.data.action==="done")return e.done_(s);if(s.data.action==="gopInfo")return e.appendGopInfo_(s);if(s.data.action==="videoSegmentTimingInfo")return e.videoSegmentTimingInfo_(s.data.videoSegmentTimingInfo)},Object.defineProperty(e,"timestampOffset",{get:function(){return this.timestampOffset_},set:function(o){typeof o=="number"&&o>=0&&(this.timestampOffset_=o,this.appendAudioInitSegment_=!0,this.gopBuffer_.length=0,this.timeMapping_=0,this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:o}))}}),Object.defineProperty(e,"appendWindowStart",{get:function(){return(this.videoBuffer_||this.audioBuffer_).appendWindowStart},set:function(o){this.videoBuffer_&&(this.videoBuffer_.appendWindowStart=o),this.audioBuffer_&&(this.audioBuffer_.appendWindowStart=o)}}),Object.defineProperty(e,"updating",{get:function(){return!!(this.bufferUpdating_||!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.updating||this.videoBuffer_&&this.videoBuffer_.updating)}}),Object.defineProperty(e,"buffered",{get:function(){return DI(this.videoBuffer_,this.audioBuffer_,this.audioDisabled_)}}),e}return qn(r,[{key:"data_",value:function(t){var e=t.data.segment;e.data=new Uint8Array(e.data,t.data.byteOffset,t.data.byteLength),e.initSegment=new Uint8Array(e.initSegment.data,e.initSegment.byteOffset,e.initSegment.byteLength),hI(this,this.mediaSource_,e),this.pendingBuffers_.push(e)}},{key:"done_",value:function(t){if(this.mediaSource_.readyState==="closed"){this.pendingBuffers_.length=0;return}this.processPendingSegments_()}},{key:"videoSegmentTimingInfo_",value:function(t){var e={start:{decode:t.start.dts/ju,presentation:t.start.pts/ju},end:{decode:t.end.dts/ju,presentation:t.end.pts/ju},baseMediaDecodeTime:t.baseMediaDecodeTime/ju};t.prependedContentDuration&&(e.prependedContentDuration=t.prependedContentDuration/ju),this.trigger({type:"videoSegmentTimingInfo",videoSegmentTimingInfo:e})}},{key:"createRealSourceBuffers_",value:function(){var t=this,e=["audio","video"];e.forEach(function(a){if(!!t[a+"Codec_"]&&!t[a+"Buffer_"]){var s=null;if(t.mediaSource_[a+"Buffer_"])s=t.mediaSource_[a+"Buffer_"],s.updating=!1;else{var o=a+"Codec_",u=a+'/mp4;codecs="'+t[o]+'"';s=PI(t.mediaSource_.nativeMediaSource_,u),t.mediaSource_[a+"Buffer_"]=s}t[a+"Buffer_"]=s,["update","updatestart","updateend"].forEach(function(l){s.addEventListener(l,function(){if(!(a==="audio"&&t.audioDisabled_)){l==="updateend"&&(t[a+"Buffer_"].updating=!1);var c=e.every(function(d){return d==="audio"&&t.audioDisabled_?!0:!(a!==d&&t[d+"Buffer_"]&&t[d+"Buffer_"].updating)});if(c)return t.trigger(l)}})})}})}},{key:"appendBuffer",value:function(t){if(this.bufferUpdating_=!0,this.audioBuffer_&&this.audioBuffer_.buffered.length){var e=this.audioBuffer_.buffered;this.transmuxer_.postMessage({action:"setAudioAppendStart",appendStart:e.end(e.length-1)})}this.videoBuffer_&&this.transmuxer_.postMessage({action:"alignGopsWith",gopsToAlignWith:CI(this.gopBuffer_,this.mediaSource_.player_?this.mediaSource_.player_.currentTime():null,this.timeMapping_)}),this.transmuxer_.postMessage({action:"push",data:t.buffer,byteOffset:t.byteOffset,byteLength:t.byteLength},[t.buffer]),this.transmuxer_.postMessage({action:"flush"})}},{key:"appendGopInfo_",value:function(t){this.gopBuffer_=wI(this.gopBuffer_,t.data.gopInfo,this.safeAppend_)}},{key:"remove",value:function(t,e){if(this.videoBuffer_&&(this.videoBuffer_.updating=!0,this.videoBuffer_.remove(t,e),this.gopBuffer_=kI(this.gopBuffer_,t,e,this.timeMapping_)),!this.audioDisabled_&&this.audioBuffer_&&(this.audioBuffer_.updating=!0,this.audioBuffer_.remove(t,e)),Nu(t,e,this.metadataTrack_),this.inbandTextTracks_)for(var a in this.inbandTextTracks_)Nu(t,e,this.inbandTextTracks_[a])}},{key:"processPendingSegments_",value:function(){var t={video:{segments:[],bytes:0},audio:{segments:[],bytes:0},captions:[],metadata:[]};if(!this.pendingBuffers_.length){this.trigger("updateend"),this.bufferUpdating_=!1;return}t=this.pendingBuffers_.reduce(function(a,s){var o=s.type,u=s.data,l=s.initSegment;return a[o].segments.push(u),a[o].bytes+=u.byteLength,a[o].initSegment=l,s.captions&&(a.captions=a.captions.concat(s.captions)),s.info&&(a[o].info=s.info),s.metadata&&(a.metadata=a.metadata.concat(s.metadata)),a},t),!this.videoBuffer_&&!this.audioBuffer_&&(t.video.bytes===0&&(this.videoCodec_=null),t.audio.bytes===0&&(this.audioCodec_=null),this.createRealSourceBuffers_()),t.audio.info&&this.mediaSource_.trigger({type:"audioinfo",info:t.audio.info}),t.video.info&&this.mediaSource_.trigger({type:"videoinfo",info:t.video.info}),this.appendAudioInitSegment_&&(!this.audioDisabled_&&this.audioBuffer_&&(t.audio.segments.unshift(t.audio.initSegment),t.audio.bytes+=t.audio.initSegment.byteLength),this.appendAudioInitSegment_=!1);var e=!1;this.videoBuffer_&&t.video.bytes?(t.video.segments.unshift(t.video.initSegment),t.video.bytes+=t.video.initSegment.byteLength,this.concatAndAppendSegments_(t.video,this.videoBuffer_)):this.videoBuffer_&&(this.audioDisabled_||!this.audioBuffer_)&&(e=!0),gI(this,t.captions,t.metadata),!this.audioDisabled_&&this.audioBuffer_&&this.concatAndAppendSegments_(t.audio,this.audioBuffer_),this.pendingBuffers_.length=0,e&&this.trigger("updateend"),this.bufferUpdating_=!1}},{key:"concatAndAppendSegments_",value:function(t,e){var a=0,s=void 0;if(t.bytes){s=new Uint8Array(t.bytes),t.segments.forEach(function(o){s.set(o,a),a+=o.byteLength});try{e.updating=!0,e.appendBuffer(s)}catch(o){this.mediaSource_.player_&&this.mediaSource_.player_.error({code:-3,type:"APPEND_BUFFER_ERR",message:o.message,originalError:o})}}}},{key:"abort",value:function(){this.videoBuffer_&&this.videoBuffer_.abort(),!this.audioDisabled_&&this.audioBuffer_&&this.audioBuffer_.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:"reset"}),this.pendingBuffers_.length=0,this.bufferUpdating_=!1}}]),r}(oe.EventTarget),Kg=function(n){Qa(r,n);function r(){Rn(this,r);var i=ma(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),t=void 0;i.nativeMediaSource_=new Pe.MediaSource;for(t in i.nativeMediaSource_)!(t in r.prototype)&&typeof i.nativeMediaSource_[t]=="function"&&(i[t]=i.nativeMediaSource_[t].bind(i.nativeMediaSource_));return i.duration_=NaN,Object.defineProperty(i,"duration",{get:function(){return this.duration_===1/0?this.duration_:this.nativeMediaSource_.duration},set:function(a){if(this.duration_=a,a!==1/0){this.nativeMediaSource_.duration=a;return}}}),Object.defineProperty(i,"seekable",{get:function(){return this.duration_===1/0?oe.createTimeRanges([[0,this.nativeMediaSource_.duration]]):this.nativeMediaSource_.seekable}}),Object.defineProperty(i,"readyState",{get:function(){return this.nativeMediaSource_.readyState}}),Object.defineProperty(i,"activeSourceBuffers",{get:function(){return this.activeSourceBuffers_}}),i.sourceBuffers=[],i.activeSourceBuffers_=[],i.updateActiveSourceBuffers_=function(){if(i.activeSourceBuffers_.length=0,i.sourceBuffers.length===1){var e=i.sourceBuffers[0];e.appendAudioInitSegment_=!0,e.audioDisabled_=!e.audioCodec_,i.activeSourceBuffers_.push(e);return}for(var a=!1,s=!0,o=0;o<i.player_.audioTracks().length;o++){var u=i.player_.audioTracks()[o];if(u.enabled&&u.kind!=="main"){a=!0,s=!1;break}}i.sourceBuffers.forEach(function(l,c){if(l.appendAudioInitSegment_=!0,l.videoCodec_&&l.audioCodec_)l.audioDisabled_=a;else if(l.videoCodec_&&!l.audioCodec_)l.audioDisabled_=!0,s=!1;else if(!l.videoCodec_&&l.audioCodec_&&(l.audioDisabled_=c?s:!s,l.audioDisabled_))return;i.activeSourceBuffers_.push(l)})},i.onPlayerMediachange_=function(){i.sourceBuffers.forEach(function(e){e.appendAudioInitSegment_=!0})},i.onHlsReset_=function(){i.sourceBuffers.forEach(function(e){e.transmuxer_&&e.transmuxer_.postMessage({action:"resetCaptions"})})},i.onHlsSegmentTimeMapping_=function(e){i.sourceBuffers.forEach(function(a){return a.timeMapping_=e.mapping})},["sourceopen","sourceclose","sourceended"].forEach(function(e){this.nativeMediaSource_.addEventListener(e,this.trigger.bind(this))},i),i.on("sourceopen",function(e){var a=vt.querySelector('[src="'+i.url_+'"]');!a||(i.player_=oe(a.parentNode),i.player_&&(i.player_.tech_.on("hls-reset",i.onHlsReset_),i.player_.tech_.on("hls-segment-time-mapping",i.onHlsSegmentTimeMapping_),i.player_.audioTracks&&i.player_.audioTracks()&&(i.player_.audioTracks().on("change",i.updateActiveSourceBuffers_),i.player_.audioTracks().on("addtrack",i.updateActiveSourceBuffers_),i.player_.audioTracks().on("removetrack",i.updateActiveSourceBuffers_)),i.player_.on("mediachange",i.onPlayerMediachange_)))}),i.on("sourceended",function(e){for(var a=Wb(i.duration),s=0;s<i.sourceBuffers.length;s++){var o=i.sourceBuffers[s],u=o.metadataTrack_&&o.metadataTrack_.cues;u&&u.length&&(u[u.length-1].endTime=a)}}),i.on("sourceclose",function(e){this.sourceBuffers.forEach(function(a){a.transmuxer_&&a.transmuxer_.terminate()}),this.sourceBuffers.length=0,this.player_&&(this.player_.audioTracks&&this.player_.audioTracks()&&(this.player_.audioTracks().off("change",this.updateActiveSourceBuffers_),this.player_.audioTracks().off("addtrack",this.updateActiveSourceBuffers_),this.player_.audioTracks().off("removetrack",this.updateActiveSourceBuffers_)),this.player_.el_&&this.player_.off("mediachange",this.onPlayerMediachange_),this.player_.tech_&&this.player_.tech_.el_&&(this.player_.tech_.off("hls-reset",this.onHlsReset_),this.player_.tech_.off("hls-segment-time-mapping",this.onHlsSegmentTimeMapping_)))}),i}return qn(r,[{key:"addSeekableRange_",value:function(t,e){var a=void 0;if(this.duration!==1/0)throw a=new Error("MediaSource.addSeekableRange() can only be invoked when the duration is Infinity"),a.name="InvalidStateError",a.code=11,a;(e>this.nativeMediaSource_.duration||isNaN(this.nativeMediaSource_.duration))&&(this.nativeMediaSource_.duration=e)}},{key:"addSourceBuffer",value:function(t){var e=void 0,a=AI(t);if(/^(video|audio)\/mp2t$/i.test(a.type)){var s=[];a.parameters&&a.parameters.codecs&&(s=a.parameters.codecs.split(","),s=Jb(s),s=s.filter(function(o){return Zb(o)||eS(o)})),s.length===0&&(s=["avc1.4d400d","mp4a.40.2"]),e=new RI(this,s),this.sourceBuffers.length!==0&&(this.sourceBuffers[0].createRealSourceBuffers_(),e.createRealSourceBuffers_(),this.sourceBuffers[0].audioDisabled_=!0)}else e=this.nativeMediaSource_.addSourceBuffer(t);return this.sourceBuffers.push(e),e}}]),r}(oe.EventTarget),tS=0;oe.mediaSources={};var rS=function(r,i){var t=oe.mediaSources[r];if(t)t.trigger({type:"sourceopen",swfId:i});else throw new Error("Media Source not found (Video.js)")},zg=function(){return!!Pe.MediaSource&&!!Pe.MediaSource.isTypeSupported&&Pe.MediaSource.isTypeSupported('video/mp4;codecs="avc1.4d400d,mp4a.40.2"')},yd=function(){if(this.MediaSource={open:rS,supportsNativeMediaSources:zg},zg())return new Kg;throw new Error("Cannot use create a virtual MediaSource for this video")};yd.open=rS,yd.supportsNativeMediaSources=zg;var iS={createObjectURL:function(r){var i="blob:vjs-media-source/",t=void 0;return r instanceof Kg?(t=Pe.URL.createObjectURL(r.nativeMediaSource_),r.url_=t,t):r instanceof Kg?(t=i+tS,tS++,oe.mediaSources[t]=r,t):(t=Pe.URL.createObjectURL(r),r.url_=t,t)}};oe.MediaSource=yd,oe.URL=iS;var II=oe.EventTarget,nS=oe.mergeOptions,aS=function(r,i){for(var t=void 0,e=nS(r,{duration:i.duration,minimumUpdatePeriod:i.minimumUpdatePeriod}),a=0;a<i.playlists.length;a++){var s=jg(e,i.playlists[a]);s?e=s:t=!0}return of(i,function(o,u,l,c){if(o.playlists&&o.playlists.length){var d=o.playlists[0].uri,f=jg(e,o.playlists[0]);f&&(e=f,e.mediaGroups[u][l][c].playlists[0]=e.playlists[d],t=!1)}}),t?null:e},Xg=function(r){var i=r.byterange.offset+r.byterange.length-1;return r.uri+"-"+r.byterange.offset+"-"+i},LI=function(r,i){var t=Boolean(!r.map&&!i.map),e=t||Boolean(r.map&&i.map&&r.map.byterange.offset===i.map.byterange.offset&&r.map.byterange.length===i.map.byterange.length);return e&&r.uri===i.uri&&r.byterange.offset===i.byterange.offset&&r.byterange.length===i.byterange.length},sS=function(r,i){var t={};for(var e in r){var a=r[e],s=a.sidx;if(s){var o=Xg(s);if(!i[o])break;var u=i[o].sidxInfo;LI(u,s)&&(t[o]=i[o])}}return t},OI=function(r,i,t,e){var a=yp(r,{manifestUri:i,clientOffset:t}),s=sS(a.playlists,e),o=s;return of(a,function(u,l,c,d){if(u.playlists&&u.playlists.length){var f=u.playlists;o=nS(o,sS(f,e))}}),o},oS=function(r,i,t,e,a){var s={uri:sf(e.handleManifestRedirects,r.resolvedUri),byterange:r.byterange,playlist:i},o=oe.mergeOptions(s,{responseType:"arraybuffer",headers:Vg(s)});return t(o,a)},Yg=function(n){Qa(r,n);function r(i,t){var e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=arguments[3];Rn(this,r);var s=ma(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),o=e.withCredentials,u=o===void 0?!1:o,l=e.handleManifestRedirects,c=l===void 0?!1:l;if(s.hls_=t,s.withCredentials=u,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_={},ma(s)):(s.setupChildLoader(a,i),s)}return qn(r,[{key:"setupChildLoader",value:function(t,e){this.masterPlaylistLoader_=t,this.childPlaylist_=e}},{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 t=this.request;this.request=null,t.onreadystatechange=null,t.abort()}}},{key:"sidxRequestFinished_",value:function(t,e,a,s){var o=this;return function(u,l){if(!!o.request){if(o.request=null,u)return o.error={status:l.status,message:"DASH playlist request error at URL: "+t.uri,response:l.response,code:2},a&&(o.state=a),o.trigger("error"),s(e,null);var c=new Uint8Array(l.response),d=eD.parseSidx(c.subarray(8));return s(e,d)}}}},{key:"media",value:function(t){var e=this;if(!t)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);var a=this.state;if(typeof t=="string"){if(!this.master.playlists[t])throw new Error("Unknown playlist URI: "+t);t=this.master.playlists[t]}var s=!this.media_||t.uri!==this.media_.uri;if(s&&this.loadedPlaylists_[t.uri]&&this.loadedPlaylists_[t.uri].endList){this.state="HAVE_METADATA",this.media_=t,s&&(this.trigger("mediachanging"),this.trigger("mediachange"));return}if(!!s){if(this.media_&&this.trigger("mediachanging"),!t.sidx){this.mediaRequest_=Pe.setTimeout(this.haveMetadata.bind(this,{startingState:a,playlist:t}),0);return}var o=void 0,u=void 0;this.masterPlaylistLoader_?(o=this.masterPlaylistLoader_.master,u=this.masterPlaylistLoader_.sidxMapping_):(o=this.master,u=this.sidxMapping_);var l=Xg(t.sidx);u[l]={sidxInfo:t.sidx},this.request=oS(t.sidx,t,this.hls_.xhr,{handleManifestRedirects:this.handleManifestRedirects},this.sidxRequestFinished_(t,o,a,function(c,d){if(!c||!d)throw new Error("failed to request sidx");u[l].sidx=d,e.haveMetadata({startingState:a,playlist:c.playlists[t.uri]})}))}}},{key:"haveMetadata",value:function(t){var e=t.startingState,a=t.playlist;this.state="HAVE_METADATA",this.loadedPlaylists_[a.uri]=a,this.mediaRequest_=null,this.refreshMedia_(a.uri),e==="HAVE_MASTER"?this.trigger("loadedmetadata"):this.trigger("mediachange")}},{key:"pause",value:function(){this.stopRequest(),Pe.clearTimeout(this.mediaUpdateTimeout),Pe.clearTimeout(this.minimumUpdatePeriodTimeout_),this.state==="HAVE_NOTHING"&&(this.started=!1)}},{key:"load",value:function(t){var e=this;Pe.clearTimeout(this.mediaUpdateTimeout),Pe.clearTimeout(this.minimumUpdatePeriodTimeout_);var a=this.media();if(t){var s=a?a.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=Pe.setTimeout(function(){return e.load()},s);return}if(!this.started){this.start();return}this.trigger("loadedplaylist")}},{key:"parseMasterXml",value:function(){var t=yp(this.masterXml_,{manifestUri:this.srcUrl,clientOffset:this.clientOffset_,sidxMapping:this.sidxMapping_});t.uri=this.srcUrl;for(var e=0;e<t.playlists.length;e++){var a="placeholder-uri-"+e;t.playlists[e].uri=a,t.playlists[a]=t.playlists[e]}return of(t,function(s,o,u,l){if(s.playlists&&s.playlists.length){var c="placeholder-uri-"+o+"-"+u+"-"+l;s.playlists[0].uri=c,t.playlists[c]=s.playlists[0]}}),Ab(t),Cb(t),t}},{key:"start",value:function(){var t=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(e,a){if(!!t.request){if(t.request=null,e)return t.error={status:a.status,message:"DASH playlist request error at URL: "+t.srcUrl,responseText:a.responseText,code:2},t.state==="HAVE_NOTHING"&&(t.started=!1),t.trigger("error");t.masterXml_=a.responseText,a.responseHeaders&&a.responseHeaders.date?t.masterLoaded_=Date.parse(a.responseHeaders.date):t.masterLoaded_=Date.now(),t.srcUrl=sf(t.handleManifestRedirects,t.srcUrl,a),t.syncClientServerClock_(t.onClientServerClockSync_.bind(t))}})}},{key:"syncClientServerClock_",value:function(t){var e=this,a=d_(this.masterXml_);if(a===null)return this.clientOffset_=this.masterLoaded_-Date.now(),t();if(a.method==="DIRECT")return this.clientOffset_=a.value-Date.now(),t();this.request=this.hls_.xhr({uri:_o(this.srcUrl,a.value),method:a.method,withCredentials:this.withCredentials},function(s,o){if(!!e.request){if(s)return e.clientOffset_=e.masterLoaded_-Date.now(),t();var u=void 0;a.method==="HEAD"?!o.responseHeaders||!o.responseHeaders.date?u=e.masterLoaded_:u=Date.parse(o.responseHeaders.date):u=Date.parse(o.responseText),e.clientOffset_=u-Date.now(),t()}})}},{key:"haveMaster_",value:function(){this.state="HAVE_MASTER",this.mediaRequest_=null,this.masterPlaylistLoader_?this.media_||this.media(this.childPlaylist_):(this.master=this.parseMasterXml(),this.trigger("loadedplaylist"))}},{key:"onClientServerClockSync_",value:function(){var t=this;this.haveMaster_(),!this.hasPendingRequest()&&!this.media_&&this.media(this.master.playlists[0]),this.master&&this.master.minimumUpdatePeriod&&(this.minimumUpdatePeriodTimeout_=Pe.setTimeout(function(){t.trigger("minimumUpdatePeriod")},this.master.minimumUpdatePeriod))}},{key:"refreshXml_",value:function(){var t=this;this.request=this.hls_.xhr({uri:this.srcUrl,withCredentials:this.withCredentials},function(e,a){if(!!t.request){if(t.request=null,e)return t.error={status:a.status,message:"DASH playlist request error at URL: "+t.srcUrl,responseText:a.responseText,code:2},t.state==="HAVE_NOTHING"&&(t.started=!1),t.trigger("error");t.masterXml_=a.responseText,t.sidxMapping_=OI(t.masterXml_,t.srcUrl,t.clientOffset_,t.sidxMapping_);var s=t.parseMasterXml(),o=aS(t.master,s),u=t.media().sidx;if(o)if(u){var l=Xg(u);if(!t.sidxMapping_[l]){var c=t.media();t.request=oS(c.sidx,c,t.hls_.xhr,{handleManifestRedirects:t.handleManifestRedirects},t.sidxRequestFinished_(c,s,t.state,function(d,f){if(!d||!f)throw new Error("failed to request sidx on minimumUpdatePeriod");t.sidxMapping_[l].sidx=f,t.minimumUpdatePeriodTimeout_=Pe.setTimeout(function(){t.trigger("minimumUpdatePeriod")},t.master.minimumUpdatePeriod),t.refreshMedia_(t.media().uri)}))}}else t.master=o;t.minimumUpdatePeriodTimeout_=Pe.setTimeout(function(){t.trigger("minimumUpdatePeriod")},t.master.minimumUpdatePeriod)}})}},{key:"refreshMedia_",value:function(t){var e=this;if(!t)throw new Error("refreshMedia_ must take a media uri");var a=void 0,s=void 0;this.masterPlaylistLoader_?(a=this.masterPlaylistLoader_.master,s=this.masterPlaylistLoader_.parseMasterXml()):(a=this.master,s=this.parseMasterXml());var o=aS(a,s);o?(this.masterPlaylistLoader_?this.masterPlaylistLoader_.master=o:this.master=o,this.media_=o.playlists[t]):(this.media_=s.playlists[t],this.trigger("playlistunchanged")),this.media().endList||(this.mediaUpdateTimeout=Pe.setTimeout(function(){e.trigger("mediaupdatetimeout")},wb(this.media(),!!o))),this.trigger("loadedplaylist")}}]),r}(II),_d=function(r){return oe.log.debug?oe.log.debug.bind(oe,"VHS:",r+" >"):function(){}};function Hu(){}var MI=function(){function n(r,i,t,e){Rn(this,n),this.callbacks_=[],this.pendingCallback_=null,this.timestampOffset_=0,this.mediaSource=r,this.processedAppend_=!1,this.type_=t,this.mimeType_=i,this.logger_=_d("SourceUpdater["+t+"]["+i+"]"),r.readyState==="closed"?r.addEventListener("sourceopen",this.createSourceBuffer_.bind(this,i,e)):this.createSourceBuffer_(i,e)}return qn(n,[{key:"createSourceBuffer_",value:function(i,t){var e=this;if(this.sourceBuffer_=this.mediaSource.addSourceBuffer(i),this.logger_("created SourceBuffer"),t&&(t.trigger("sourcebufferadded"),this.mediaSource.sourceBuffers.length<2)){t.on("sourcebufferadded",function(){e.start_()});return}this.start_()}},{key:"start_",value:function(){var i=this;this.started_=!0,this.onUpdateendCallback_=function(){var t=i.pendingCallback_;i.pendingCallback_=null,i.sourceBuffer_.removing=!1,i.logger_("buffered ["+qg(i.buffered())+"]"),t&&t(),i.runCallback_()},this.sourceBuffer_.addEventListener("updateend",this.onUpdateendCallback_),this.runCallback_()}},{key:"abort",value:function(i){var t=this;this.processedAppend_&&this.queueCallback_(function(){t.sourceBuffer_.abort()},i)}},{key:"appendBuffer",value:function(i,t){var e=this;this.processedAppend_=!0,this.queueCallback_(function(){i.videoSegmentTimingInfoCallback&&e.sourceBuffer_.addEventListener("videoSegmentTimingInfo",i.videoSegmentTimingInfoCallback),e.sourceBuffer_.appendBuffer(i.bytes)},function(){i.videoSegmentTimingInfoCallback&&e.sourceBuffer_.removeEventListener("videoSegmentTimingInfo",i.videoSegmentTimingInfoCallback),t()})}},{key:"buffered",value:function(){return this.sourceBuffer_?this.sourceBuffer_.buffered:oe.createTimeRanges()}},{key:"remove",value:function(i,t){var e=this,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Hu;this.processedAppend_&&this.queueCallback_(function(){e.logger_("remove ["+i+" => "+t+"]"),e.sourceBuffer_.removing=!0,e.sourceBuffer_.remove(i,t)},a)}},{key:"updating",value:function(){return!this.sourceBuffer_||this.sourceBuffer_.updating||!!this.pendingCallback_&&this.pendingCallback_!==Hu}},{key:"timestampOffset",value:function(i){var t=this;return typeof i<"u"&&(this.queueCallback_(function(){t.sourceBuffer_.timestampOffset=i,t.runCallback_()}),this.timestampOffset_=i),this.timestampOffset_}},{key:"queueCallback_",value:function(i,t){this.callbacks_.push([i.bind(this),t]),this.runCallback_()}},{key:"runCallback_",value:function(){var i=void 0;!this.updating()&&this.callbacks_.length&&this.started_&&(i=this.callbacks_.shift(),this.pendingCallback_=i[1],i[0]())}},{key:"dispose",value:function(){var i=this,t=function e(){i.sourceBuffer_&&i.mediaSource.readyState==="open"&&i.sourceBuffer_.abort(),i.sourceBuffer_.removeEventListener("updateend",e)};this.sourceBuffer_.removeEventListener("updateend",this.onUpdateendCallback_),this.sourceBuffer_.removing?this.sourceBuffer_.addEventListener("updateend",t):t()}}]),n}(),pn={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},Os={FAILURE:2,TIMEOUT:-101,ABORTED:-102},uS=function(r){r.forEach(function(i){i.abort()})},FI=function(r){return{bandwidth:r.bandwidth,bytesReceived:r.bytesReceived||0,roundTripTime:r.roundTripTime||0}},NI=function(r){var i=r.target,t=Date.now()-i.requestTime,e={bandwidth:1/0,bytesReceived:0,roundTripTime:t||0};return e.bytesReceived=r.loaded,e.bandwidth=Math.floor(e.bytesReceived/e.roundTripTime*8*1e3),e},Qg=function(r,i){return i.timedout?{status:i.status,message:"HLS request timed-out at URL: "+i.uri,code:Os.TIMEOUT,xhr:i}:i.aborted?{status:i.status,message:"HLS request aborted at URL: "+i.uri,code:Os.ABORTED,xhr:i}:r?{status:i.status,message:"HLS request errored at URL: "+i.uri,code:Os.FAILURE,xhr:i}:null},BI=function(r,i){return function(t,e){var a=e.response,s=Qg(t,e);if(s)return i(s,r);if(a.byteLength!==16)return i({status:e.status,message:"Invalid HLS key at URL: "+e.uri,code:Os.FAILURE,xhr:e},r);var o=new DataView(a);return r.key.bytes=new Uint32Array([o.getUint32(0),o.getUint32(4),o.getUint32(8),o.getUint32(12)]),i(null,r)}},UI=function(r,i,t){return function(e,a){var s=a.response,o=Qg(e,a);return o?t(o,r):s.byteLength===0?t({status:a.status,message:"Empty HLS segment content at URL: "+a.uri,code:Os.FAILURE,xhr:a},r):(r.map.bytes=new Uint8Array(a.response),i&&!i.isInitialized()&&i.init(),r.map.timescales=kc.timescale(r.map.bytes),r.map.videoTrackIds=kc.videoTrackIds(r.map.bytes),t(null,r))}},jI=function(r,i,t){return function(e,a){var s=a.response,o=Qg(e,a),u=void 0;return o?t(o,r):s.byteLength===0?t({status:a.status,message:"Empty HLS segment content at URL: "+a.uri,code:Os.FAILURE,xhr:a},r):(r.stats=FI(a),r.key?r.encryptedBytes=new Uint8Array(a.response):r.bytes=new Uint8Array(a.response),i&&r.map&&r.map.bytes&&(i.isInitialized()||i.init(),u=i.parse(r.bytes,r.map.videoTrackIds,r.map.timescales),u&&u.captions&&(r.captionStreams=u.captionStreams,r.fmp4Captions=u.captions)),t(null,r))}},HI=function(r,i,t){var e=function s(o){if(o.data.source===i.requestId){r.removeEventListener("message",s);var u=o.data.decrypted;return i.bytes=new Uint8Array(u.bytes,u.byteOffset,u.byteLength),t(null,i)}};r.addEventListener("message",e);var a=void 0;i.key.bytes.slice?a=i.key.bytes.slice():a=new Uint32Array(Array.prototype.slice.call(i.key.bytes)),r.postMessage(Bb({source:i.requestId,encrypted:i.encryptedBytes,key:a,iv:i.key.iv}),[i.encryptedBytes.buffer,a.buffer])},GI=function(r,i,t){var e=0,a=!1;return function(s,o){if(!a){if(s)return a=!0,uS(r),t(s,o);if(e+=1,e===r.length)return o.endOfAllRequests=Date.now(),o.encryptedBytes?HI(i,o,t):t(null,o)}}},VI=function(r,i){return function(t){return r.stats=oe.mergeOptions(r.stats,NI(t)),!r.stats.firstBytesReceivedAt&&r.stats.bytesReceived&&(r.stats.firstBytesReceivedAt=Date.now()),i(t,r)}},qI=function(r,i,t,e,a,s,o){var u=[],l=GI(u,t,o);if(a.key&&!a.key.bytes){var c=oe.mergeOptions(i,{uri:a.key.resolvedUri,responseType:"arraybuffer"}),d=BI(a,l),f=r(c,d);u.push(f)}if(a.map&&!a.map.bytes){var h=oe.mergeOptions(i,{uri:a.map.resolvedUri,responseType:"arraybuffer",headers:Vg(a.map)}),g=UI(a,e,l),p=r(h,g);u.push(p)}var v=oe.mergeOptions(i,{uri:a.resolvedUri,responseType:"arraybuffer",headers:Vg(a)}),y=jI(a,e,l),m=r(v,y);return m.addEventListener("progress",VI(a,s)),u.push(m),function(){return uS(u)}},lS=function(r,i){var t=void 0;return!r||(t=Pe.getComputedStyle(r),!t)?"":t[i]},Td=function(r,i){var t=r.slice();r.sort(function(e,a){var s=i(e,a);return s===0?t.indexOf(e)-t.indexOf(a):s})},Jg=function(r,i){var t=void 0,e=void 0;return r.attributes.BANDWIDTH&&(t=r.attributes.BANDWIDTH),t=t||Pe.Number.MAX_VALUE,i.attributes.BANDWIDTH&&(e=i.attributes.BANDWIDTH),e=e||Pe.Number.MAX_VALUE,t-e},$I=function(r,i){var t=void 0,e=void 0;return r.attributes.RESOLUTION&&r.attributes.RESOLUTION.width&&(t=r.attributes.RESOLUTION.width),t=t||Pe.Number.MAX_VALUE,i.attributes.RESOLUTION&&i.attributes.RESOLUTION.width&&(e=i.attributes.RESOLUTION.width),e=e||Pe.Number.MAX_VALUE,t===e&&r.attributes.BANDWIDTH&&i.attributes.BANDWIDTH?r.attributes.BANDWIDTH-i.attributes.BANDWIDTH:t-e},WI=function(r,i,t,e,a){var s=r.playlists.map(function(T){var b=void 0,S=void 0,A=void 0;return b=T.attributes.RESOLUTION&&T.attributes.RESOLUTION.width,S=T.attributes.RESOLUTION&&T.attributes.RESOLUTION.height,A=T.attributes.BANDWIDTH,A=A||Pe.Number.MAX_VALUE,{bandwidth:A,width:b,height:S,playlist:T}});Td(s,function(T,b){return T.bandwidth-b.bandwidth}),s=s.filter(function(T){return!en.isIncompatible(T.playlist)});var o=s.filter(function(T){return en.isEnabled(T.playlist)});o.length||(o=s.filter(function(T){return!en.isDisabled(T.playlist)}));var u=o.filter(function(T){return T.bandwidth*pn.BANDWIDTH_VARIANCE<i}),l=u[u.length-1],c=u.filter(function(T){return T.bandwidth===l.bandwidth})[0];if(a===!1){var d=c||o[0]||s[0];return d?d.playlist:null}var f=u.filter(function(T){return T.width&&T.height});Td(f,function(T,b){return T.width-b.width});var h=f.filter(function(T){return T.width===t&&T.height===e});l=h[h.length-1];var g=h.filter(function(T){return T.bandwidth===l.bandwidth})[0],p=void 0,v=void 0,y=void 0;g||(p=f.filter(function(T){return T.width>t||T.height>e}),v=p.filter(function(T){return T.width===p[0].width&&T.height===p[0].height}),l=v[v.length-1],y=v.filter(function(T){return T.bandwidth===l.bandwidth})[0]);var m=y||g||c||o[0]||s[0];return m?m.playlist:null},KI=function(){return WI(this.playlists.master,this.systemBandwidth,parseInt(lS(this.tech_.el(),"width"),10),parseInt(lS(this.tech_.el(),"height"),10),this.limitRenditionByPlayerDimensions)},zI=function(r){var i=r.master,t=r.currentTime,e=r.bandwidth,a=r.duration,s=r.segmentDuration,o=r.timeUntilRebuffer,u=r.currentTimeline,l=r.syncController,c=i.playlists.filter(function(p){return!en.isIncompatible(p)}),d=c.filter(en.isEnabled);d.length||(d=c.filter(function(p){return!en.isDisabled(p)}));var f=d.filter(en.hasAttribute.bind(null,"BANDWIDTH")),h=f.map(function(p){var v=l.getSyncPoint(p,a,u,t),y=v?1:2,m=en.estimateSegmentRequestTime(s,e,p),T=m*y-o;return{playlist:p,rebufferingImpact:T}}),g=h.filter(function(p){return p.rebufferingImpact<=0});return Td(g,function(p,v){return Jg(v.playlist,p.playlist)}),g.length?g[0]:(Td(h,function(p,v){return p.rebufferingImpact-v.rebufferingImpact}),h[0]||null)},XI=function(){var r=this.playlists.master.playlists.filter(en.isEnabled);Td(r,function(t,e){return Jg(t,e)});var i=r.filter(function(t){return md(t.attributes.CODECS).videoCodec});return i[0]||null},YI=function(r,i,t){for(var e in t)if(!r[e]){i.trigger({type:"usage",name:"hls-608"});var a=i.textTracks().getTrackById(e);a?r[e]=a:r[e]=i.addRemoteTextTrack({kind:"captions",id:e,label:e},!1).track}},QI=function(r){var i=r.inbandTextTracks,t=r.captionArray,e=r.timestampOffset;if(!!t){var a=window.WebKitDataCue||window.VTTCue;t.forEach(function(s){var o=s.stream,u=s.startTime,l=s.endTime;!i[o]||(u+=e,l+=e,i[o].addCue(new a(u,l,s.text)))})}},JI=500,ZI=function(r,i,t){if(!r||!i)return!1;var e=r.segments,a=t===e.length;return r.endList&&i.readyState==="open"&&a},dS=function(r){return typeof r=="number"&&isFinite(r)},eL=function(r,i,t){return r!=="main"||!i||!t?null:!t.containsAudio&&!t.containsVideo?"Neither audio nor video found in segment.":i.containsVideo&&!t.containsVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!i.containsVideo&&t.containsVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null},tL=function(r,i,t){var e=void 0;return r.length&&r.start(0)>0&&r.start(0)<i?e=r.start(0):e=i-30,Math.min(e,i-t)},rL=function(r){var i=r.segment,t=i.start,e=i.end,a=r.playlist,s=a.mediaSequence,o=a.id,u=a.segments,l=u===void 0?[]:u,c=r.mediaIndex,d=r.timeline;return["appending ["+c+"] of ["+s+", "+(s+l.length)+"] from playlist ["+o+"]","["+t+" => "+e+"] in timeline ["+d+"]"].join(" ")},Zg=function(n){Qa(r,n);function r(i){Rn(this,r);var t=ma(this,(r.__proto__||Object.getPrototypeOf(r)).call(this));if(!i)throw new TypeError("Initialization settings are required");if(typeof i.currentTime!="function")throw new TypeError("No currentTime getter specified");if(!i.mediaSource)throw new TypeError("No MediaSource specified");return t.bandwidth=i.bandwidth,t.throughput={rate:0,count:0},t.roundTrip=NaN,t.resetStats_(),t.mediaIndex=null,t.hasPlayed_=i.hasPlayed,t.currentTime_=i.currentTime,t.seekable_=i.seekable,t.seeking_=i.seeking,t.duration_=i.duration,t.mediaSource_=i.mediaSource,t.hls_=i.hls,t.loaderType_=i.loaderType,t.startingMedia_=void 0,t.segmentMetadataTrack_=i.segmentMetadataTrack,t.goalBufferLength_=i.goalBufferLength,t.sourceType_=i.sourceType,t.inbandTextTracks_=i.inbandTextTracks,t.state_="INIT",t.checkBufferTimeout_=null,t.error_=void 0,t.currentTimeline_=-1,t.pendingSegment_=null,t.mimeType_=null,t.sourceUpdater_=null,t.xhrOptions_=null,t.activeInitSegmentId_=null,t.initSegments_={},t.cacheEncryptionKeys_=i.cacheEncryptionKeys,t.keyCache_={},t.loaderType_==="main"?t.captionParser_=new CD:t.captionParser_=null,t.decrypter_=i.decrypter,t.syncController_=i.syncController,t.syncPoint_={segmentIndex:0,time:0},t.syncController_.on("syncinfoupdate",function(){return t.trigger("syncinfoupdate")}),t.mediaSource_.addEventListener("sourceopen",function(){return t.ended_=!1}),t.fetchAtBuffer_=!1,t.logger_=_d("SegmentLoader["+t.loaderType_+"]"),Object.defineProperty(t,"state",{get:function(){return this.state_},set:function(a){a!==this.state_&&(this.logger_(this.state_+" -> "+a),this.state_=a)}}),t}return qn(r,[{key:"resetStats_",value:function(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0}},{key:"dispose",value:function(){this.state="DISPOSED",this.pause(),this.abort_(),this.sourceUpdater_&&this.sourceUpdater_.dispose(),this.resetStats_(),this.captionParser_&&this.captionParser_.reset()}},{key:"abort",value:function(){if(this.state!=="WAITING"){this.pendingSegment_&&(this.pendingSegment_=null);return}this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()}},{key:"abort_",value:function(){this.pendingSegment_&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null}},{key:"error",value:function(t){return typeof t<"u"&&(this.error_=t),this.pendingSegment_=null,this.error_}},{key:"endOfStream",value:function(){this.ended_=!0,this.pause(),this.trigger("ended")}},{key:"buffered_",value:function(){return this.sourceUpdater_?this.sourceUpdater_.buffered():oe.createTimeRanges()}},{key:"initSegment",value:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=df(t),s=this.initSegments_[a];return e&&!s&&t.bytes&&(this.initSegments_[a]=s={resolvedUri:t.resolvedUri,byterange:t.byterange,bytes:t.bytes,timescales:t.timescales,videoTrackIds:t.videoTrackIds}),s||t}},{key:"segmentKey",value:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=Ub(t),s=this.keyCache_[a];this.cacheEncryptionKeys_&&e&&!s&&t.bytes&&(this.keyCache_[a]=s={resolvedUri:t.resolvedUri,bytes:t.bytes});var o={resolvedUri:(s||t).resolvedUri};return s&&(o.bytes=s.bytes),o}},{key:"couldBeginLoading_",value:function(){return this.playlist_&&(this.sourceUpdater_||this.mimeType_&&this.state==="INIT")&&!this.paused()}},{key:"load",value:function(){if(this.monitorBuffer_(),!!this.playlist_){if(this.syncController_.setDateTimeMapping(this.playlist_),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||this.state!=="READY"&&this.state!=="INIT"||(this.state="READY")}}},{key:"init_",value:function(){return this.state="READY",this.sourceUpdater_=new MI(this.mediaSource_,this.mimeType_,this.loaderType_,this.sourceBufferEmitter_),this.resetEverything(),this.monitorBuffer_()}},{key:"playlist",value:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!!t){var a=this.playlist_,s=this.pendingSegment_;this.playlist_=t,this.xhrOptions_=e,this.hasPlayed_()||(t.syncInfo={mediaSequence:t.mediaSequence,time:0});var o=null;if(a&&(a.id?o=a.id:a.uri&&(o=a.uri)),this.logger_("playlist update ["+o+" => "+(t.id||t.uri)+"]"),this.trigger("syncinfoupdate"),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();if(!a||a.uri!==t.uri){this.mediaIndex!==null&&this.resyncLoader();return}var u=t.mediaSequence-a.mediaSequence;this.logger_("live window shift ["+u+"]"),this.mediaIndex!==null&&(this.mediaIndex-=u),s&&(s.mediaIndex-=u,s.mediaIndex>=0&&(s.segment=t.segments[s.mediaIndex])),this.syncController_.saveExpiredSegmentInfo(a,t)}}},{key:"pause",value:function(){this.checkBufferTimeout_&&(Pe.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}},{key:"paused",value:function(){return this.checkBufferTimeout_===null}},{key:"mimeType",value:function(t,e){this.mimeType_||(this.mimeType_=t,this.sourceBufferEmitter_=e,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_())}},{key:"resetEverything",value:function(t){this.ended_=!1,this.resetLoader(),this.remove(0,this.duration_(),t),this.captionParser_&&this.captionParser_.clearAllCaptions(),this.trigger("reseteverything")}},{key:"resetLoader",value:function(){this.fetchAtBuffer_=!1,this.resyncLoader()}},{key:"resyncLoader",value:function(){this.mediaIndex=null,this.syncPoint_=null,this.abort()}},{key:"remove",value:function(t,e,a){if(this.sourceUpdater_&&this.sourceUpdater_.remove(t,e,a),Nu(t,e,this.segmentMetadataTrack_),this.inbandTextTracks_)for(var s in this.inbandTextTracks_)Nu(t,e,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),JI)}},{key:"fillBuffer_",value:function(){if(!this.sourceUpdater_.updating()){this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var t=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(!!t){if(this.isEndOfStream_(t.mediaIndex)){this.endOfStream();return}t.mediaIndex===this.playlist_.segments.length-1&&this.mediaSource_.readyState==="ended"&&!this.seeking_()||(t.timeline!==this.currentTimeline_&&(this.syncController_.reset(),t.timestampOffset=t.startOfSegment,this.captionParser_&&this.captionParser_.clearAllCaptions()),this.loadSegment_(t))}}}},{key:"isEndOfStream_",value:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.playlist_;return ZI(e,this.mediaSource_,t)&&!this.sourceUpdater_.updating()}},{key:"checkBuffer_",value:function(t,e,a,s,o,u){var l=0,c=void 0;t.length&&(l=t.end(t.length-1));var d=Math.max(0,l-o);if(!e.segments.length||d>=this.goalBufferLength_()||!s&&d>=1)return null;if(u===null)return a=this.getSyncSegmentCandidate_(e),this.generateSegmentInfo_(e,a,null,!0);if(a!==null)return e.segments[a],c=l,this.generateSegmentInfo_(e,a+1,c,!1);if(this.fetchAtBuffer_){var f=en.getMediaInfoForTime(e,l,u.segmentIndex,u.time);a=f.mediaIndex,c=f.startTime}else{var h=en.getMediaInfoForTime(e,o,u.segmentIndex,u.time);a=h.mediaIndex,c=h.startTime}return this.generateSegmentInfo_(e,a,c,!1)}},{key:"getSyncSegmentCandidate_",value:function(t){var e=this;if(this.currentTimeline_===-1)return 0;var a=t.segments.map(function(s,o){return{timeline:s.timeline,segmentIndex:o}}).filter(function(s){return s.timeline===e.currentTimeline_});return a.length?a[Math.min(a.length-1,1)].segmentIndex:Math.max(t.segments.length-1,0)}},{key:"generateSegmentInfo_",value:function(t,e,a,s){if(e<0||e>=t.segments.length)return null;var o=t.segments[e];return{requestId:"segment-loader-"+Math.random(),uri:o.resolvedUri,mediaIndex:e,isSyncRequest:s,startOfSegment:a,playlist:t,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:o.timeline,duration:o.duration,segment:o}}},{key:"abortRequestEarly_",value:function(t){if(this.hls_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH||Date.now()-(t.firstBytesReceivedAt||Date.now())<1e3)return!1;var e=this.currentTime_(),a=t.bandwidth,s=this.pendingSegment_.duration,o=en.estimateSegmentRequestTime(s,a,this.playlist_,t.bytesReceived),u=fI(this.buffered_(),e,this.hls_.tech_.playbackRate())-1;if(o<=u)return!1;var l=zI({master:this.hls_.playlists.master,currentTime:e,bandwidth:a,duration:this.duration_(),segmentDuration:s,timeUntilRebuffer:u,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!!l){var c=o-u,d=c-l.rebufferingImpact,f=.5;return u<=cf&&(f=1),!l.playlist||l.playlist.uri===this.playlist_.uri||d<f?!1:(this.bandwidth=l.playlist.attributes.BANDWIDTH*pn.BANDWIDTH_VARIANCE+1,this.abort(),this.trigger("earlyabort"),!0)}}},{key:"handleProgress_",value:function(t,e){!this.pendingSegment_||e.requestId!==this.pendingSegment_.requestId||this.abortRequestEarly_(e.stats)||this.trigger("progress")}},{key:"loadSegment_",value:function(t){this.state="WAITING",this.pendingSegment_=t,this.trimBackBuffer_(t),t.abortRequests=qI(this.hls_.xhr,this.xhrOptions_,this.decrypter_,this.captionParser_,this.createSimplifiedSegmentObj_(t),this.handleProgress_.bind(this),this.segmentRequestFinished_.bind(this))}},{key:"trimBackBuffer_",value:function(t){var e=tL(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);e>0&&this.remove(0,e)}},{key:"createSimplifiedSegmentObj_",value:function(t){var e=t.segment,a={resolvedUri:e.resolvedUri,byterange:e.byterange,requestId:t.requestId};if(e.key){var s=e.key.iv||new Uint32Array([0,0,0,t.mediaIndex+t.playlist.mediaSequence]);a.key=this.segmentKey(e.key),a.key.iv=s}return e.map&&(a.map=this.initSegment(e.map)),a}},{key:"segmentRequestFinished_",value:function(t,e){if(this.mediaRequests+=1,e.stats&&(this.mediaBytesTransferred+=e.stats.bytesReceived,this.mediaTransferDuration+=e.stats.roundTripTime),!this.pendingSegment_){this.mediaRequestsAborted+=1;return}if(e.requestId===this.pendingSegment_.requestId){if(t){if(this.pendingSegment_=null,this.state="READY",t.code===Os.ABORTED){this.mediaRequestsAborted+=1;return}if(this.pause(),t.code===Os.TIMEOUT){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger("bandwidthupdate");return}this.mediaRequestsErrored+=1,this.error(t),this.trigger("error");return}this.bandwidth=e.stats.bandwidth,this.roundTrip=e.stats.roundTripTime,e.map&&(e.map=this.initSegment(e.map,!0)),e.key&&this.segmentKey(e.key,!0),this.processSegmentResponse_(e)}}},{key:"processSegmentResponse_",value:function(t){var e=this.pendingSegment_;e.bytes=t.bytes,t.map&&(e.segment.map.bytes=t.map.bytes),e.endOfAllRequests=t.endOfAllRequests,t.fmp4Captions&&(YI(this.inbandTextTracks_,this.hls_.tech_,t.captionStreams),QI({inbandTextTracks:this.inbandTextTracks_,captionArray:t.fmp4Captions,timestampOffset:0}),this.captionParser_&&this.captionParser_.clearParsedCaptions()),this.handleSegment_()}},{key:"handleSegment_",value:function(){var t=this;if(!this.pendingSegment_){this.state="READY";return}var e=this.pendingSegment_,a=e.segment,s=this.syncController_.probeSegmentInfo(e);typeof this.startingMedia_>"u"&&s&&(s.containsAudio||s.containsVideo)&&(this.startingMedia_={containsAudio:s.containsAudio,containsVideo:s.containsVideo});var o=eL(this.loaderType_,this.startingMedia_,s);if(o){this.error({message:o,blacklistDuration:1/0}),this.trigger("error");return}if(e.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}if(e.timestampOffset!==null&&e.timestampOffset!==this.sourceUpdater_.timestampOffset()){if(s&&s.segmentTimestampInfo){var u=s.segmentTimestampInfo[0].ptsTime,l=s.segmentTimestampInfo[0].dtsTime;e.timestampOffset-=u-l}this.sourceUpdater_.timestampOffset(e.timestampOffset),this.trigger("timestampoffset")}var c=this.syncController_.mappingForTimeline(e.timeline);if(c!==null&&this.trigger({type:"segmenttimemapping",mapping:c}),this.state="APPENDING",a.map){var d=df(a.map);if(!this.activeInitSegmentId_||this.activeInitSegmentId_!==d){var f=this.initSegment(a.map);this.sourceUpdater_.appendBuffer({bytes:f.bytes},function(){t.activeInitSegmentId_=d})}}e.byteLength=e.bytes.byteLength,typeof a.start=="number"&&typeof a.end=="number"?this.mediaSecondsLoaded+=a.end-a.start:this.mediaSecondsLoaded+=a.duration,this.logger_(rL(e)),this.sourceUpdater_.appendBuffer({bytes:e.bytes,videoSegmentTimingInfoCallback:this.handleVideoSegmentTimingInfo_.bind(this,e.requestId)},this.handleUpdateEnd_.bind(this))}},{key:"handleVideoSegmentTimingInfo_",value:function(t,e){if(!(!this.pendingSegment_||t!==this.pendingSegment_.requestId)){var a=this.pendingSegment_.segment;a.videoTimingInfo||(a.videoTimingInfo={}),a.videoTimingInfo.transmuxerPrependedSeconds=e.videoSegmentTimingInfo.prependedContentDuration||0,a.videoTimingInfo.transmuxedPresentationStart=e.videoSegmentTimingInfo.start.presentation,a.videoTimingInfo.transmuxedPresentationEnd=e.videoSegmentTimingInfo.end.presentation,a.videoTimingInfo.baseMediaDecodeTime=e.videoSegmentTimingInfo.baseMediaDecodeTime}}},{key:"handleUpdateEnd_",value:function(){if(!this.pendingSegment_){this.state="READY",this.paused()||this.monitorBuffer_();return}var t=this.pendingSegment_,e=t.segment,a=this.mediaIndex!==null;if(this.pendingSegment_=null,this.recordThroughput_(t),this.addSegmentMetadataCue_(t),this.state="READY",this.mediaIndex=t.mediaIndex,this.fetchAtBuffer_=!0,this.currentTimeline_=t.timeline,this.trigger("syncinfoupdate"),e.end&&this.currentTime_()-e.end>t.playlist.targetDuration*3){this.resetEverything();return}a&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.isEndOfStream_(t.mediaIndex+1,t.playlist)&&this.endOfStream(),this.paused()||this.monitorBuffer_()}},{key:"recordThroughput_",value:function(t){var e=this.throughput.rate,a=Date.now()-t.endOfAllRequests+1,s=Math.floor(t.byteLength/a*8*1e3);this.throughput.rate+=(s-e)/++this.throughput.count}},{key:"addSegmentMetadataCue_",value:function(t){if(!!this.segmentMetadataTrack_){var e=t.segment,a=e.start,s=e.end;if(!(!dS(a)||!dS(s))){Nu(a,s,this.segmentMetadataTrack_);var o=Pe.WebKitDataCue||Pe.VTTCue,u={custom:e.custom,dateTimeObject:e.dateTimeObject,dateTimeString:e.dateTimeString,bandwidth:t.playlist.attributes.BANDWIDTH,resolution:t.playlist.attributes.RESOLUTION,codecs:t.playlist.attributes.CODECS,byteLength:t.byteLength,uri:t.uri,timeline:t.timeline,playlist:t.playlist.uri,start:a,end:s},l=JSON.stringify(u),c=new o(a,s,l);c.value=u,this.segmentMetadataTrack_.addCue(c)}}}}]),r}(oe.EventTarget),cS=function(r){return decodeURIComponent(escape(String.fromCharCode.apply(null,r)))},fS=new Uint8Array(`
|
|
87
87
|
|
|
88
|
-
`.split("").map(function(n){return n.charCodeAt(0)})),iL=function(n){Qa(r,n);function r(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Rn(this,r);var e=ma(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,i,t));return e.mediaSource_=null,e.subtitlesTrack_=null,e}return qn(r,[{key:"buffered_",value:function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return oe.createTimeRanges();var t=this.subtitlesTrack_.cues,e=t[0].startTime,a=t[t.length-1].startTime;return oe.createTimeRanges([[e,a]])}},{key:"initSegment",value:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=df(t),s=this.initSegments_[a];if(e&&!s&&t.bytes){var o=fS.byteLength+t.bytes.byteLength,u=new Uint8Array(o);u.set(t.bytes),u.set(fS,t.bytes.byteLength),this.initSegments_[a]=s={resolvedUri:t.resolvedUri,byterange:t.byterange,bytes:u}}return s||t}},{key:"couldBeginLoading_",value:function(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}},{key:"init_",value:function(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}},{key:"track",value:function(t){return typeof t>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=t,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}},{key:"remove",value:function(t,e){Nu(t,e,this.subtitlesTrack_)}},{key:"fillBuffer_",value:function(){var t=this;this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var e=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(e=this.skipEmptySegments_(e),!!e){if(this.syncController_.timestampOffsetForTimeline(e.timeline)===null){var a=function(){t.state="READY",t.paused()||t.monitorBuffer_()};this.syncController_.one("timestampoffset",a),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(e)}}},{key:"skipEmptySegments_",value:function(t){for(;t&&t.segment.empty;)t=this.generateSegmentInfo_(t.playlist,t.mediaIndex+1,t.startOfSegment+t.duration,t.isSyncRequest);return t}},{key:"handleSegment_",value:function(){var t=this;if(!this.pendingSegment_||!this.subtitlesTrack_){this.state="READY";return}this.state="APPENDING";var e=this.pendingSegment_,a=e.segment;if(typeof Pe.WebVTT!="function"&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var s=void 0,o=function(){t.subtitlesTrack_.tech_.off("vttjsloaded",s),t.error({message:"Error loading vtt.js"}),t.state="READY",t.pause(),t.trigger("error")};s=function(){t.subtitlesTrack_.tech_.off("vttjserror",o),t.handleSegment_()},this.state="WAITING_ON_VTTJS",this.subtitlesTrack_.tech_.one("vttjsloaded",s),this.subtitlesTrack_.tech_.one("vttjserror",o);return}a.requested=!0;try{this.parseVTTCues_(e)}catch(u){return this.error({message:u.message}),this.state="READY",this.pause(),this.trigger("error")}if(this.updateTimeMapping_(e,this.syncController_.timelines[e.timeline],this.playlist_),e.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}e.byteLength=e.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,e.cues.length&&this.remove(e.cues[0].endTime,e.cues[e.cues.length-1].endTime),e.cues.forEach(function(u){t.subtitlesTrack_.addCue(u)}),this.handleUpdateEnd_()}},{key:"parseVTTCues_",value:function(t){var e=void 0,a=!1;typeof Pe.TextDecoder=="function"?e=new Pe.TextDecoder("utf8"):(e=Pe.WebVTT.StringDecoder(),a=!0);var s=new Pe.WebVTT.Parser(Pe,Pe.vttjs,e);if(t.cues=[],t.timestampmap={MPEGTS:0,LOCAL:0},s.oncue=t.cues.push.bind(t.cues),s.ontimestampmap=function(l){return t.timestampmap=l},s.onparsingerror=function(l){oe.log.warn("Error encountered when parsing cues: "+l.message)},t.segment.map){var o=t.segment.map.bytes;a&&(o=cS(o)),s.parse(o)}var u=t.bytes;a&&(u=cS(u)),s.parse(u),s.flush()}},{key:"updateTimeMapping_",value:function(t,e,a){var s=t.segment;if(!!e){if(!t.cues.length){s.empty=!0;return}var o=t.timestampmap,u=o.MPEGTS/9e4-o.LOCAL+e.mapping;if(t.cues.forEach(function(d){d.startTime+=u,d.endTime+=u}),!a.syncInfo){var l=t.cues[0].startTime,c=t.cues[t.cues.length-1].startTime;a.syncInfo={mediaSequence:a.mediaSequence+t.mediaIndex,time:Math.min(l,c-s.duration)}}}}}]),r}(Zg),nL=function(r,i){for(var t=r.cues,e=0;e<t.length;e++){var a=t[e];if(i>=a.adStartTime&&i<=a.adEndTime)return a}return null},aL=function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!!r.segments)for(var e=t,a=void 0,s=0;s<r.segments.length;s++){var o=r.segments[s];if(a||(a=nL(i,e+o.duration/2)),a){if("cueIn"in o){a.endTime=e,a.adEndTime=e,e+=o.duration,a=null;continue}if(e<a.endTime){e+=o.duration;continue}a.endTime+=o.duration}else if("cueOut"in o&&(a=new Pe.VTTCue(e,e+o.duration,o.cueOut),a.adStartTime=e,a.adEndTime=e+parseFloat(o.cueOut),i.addCue(a)),"cueOutCont"in o){var u=void 0,l=void 0,c=o.cueOutCont.split("/").map(parseFloat),d=LR(c,2);u=d[0],l=d[1],a=new Pe.VTTCue(e,e+o.duration,""),a.adStartTime=e-u,a.adEndTime=a.adStartTime+l,i.addCue(a)}e+=o.duration}},sL=ZD.inspect,hS=[{name:"VOD",run:function(r,i,t,e,a){if(t!==1/0){var s={time:0,segmentIndex:0};return s}return null}},{name:"ProgramDateTime",run:function(r,i,t,e,a){if(!r.datetimeToDisplayTime)return null;var s=i.segments||[],o=null,u=null;a=a||0;for(var l=0;l<s.length;l++){var c=s[l];if(c.dateTimeObject){var d=c.dateTimeObject.getTime()/1e3,f=d+r.datetimeToDisplayTime,h=Math.abs(a-f);if(u!==null&&(h===0||u<h))break;u=h,o={time:f,segmentIndex:l}}}return o}},{name:"Segment",run:function(r,i,t,e,a){var s=i.segments||[],o=null,u=null;a=a||0;for(var l=0;l<s.length;l++){var c=s[l];if(c.timeline===e&&typeof c.start<"u"){var d=Math.abs(a-c.start);if(u!==null&&u<d)break;(!o||u===null||u>=d)&&(u=d,o={time:c.start,segmentIndex:l})}}return o}},{name:"Discontinuity",run:function(r,i,t,e,a){var s=null;if(a=a||0,i.discontinuityStarts&&i.discontinuityStarts.length)for(var o=null,u=0;u<i.discontinuityStarts.length;u++){var l=i.discontinuityStarts[u],c=i.discontinuitySequence+u+1,d=r.discontinuities[c];if(d){var f=Math.abs(a-d.time);if(o!==null&&o<f)break;(!s||o===null||o>=f)&&(o=f,s={time:d.time,segmentIndex:l})}}return s}},{name:"Playlist",run:function(r,i,t,e,a){if(i.syncInfo){var s={time:i.syncInfo.time,segmentIndex:i.syncInfo.mediaSequence-i.mediaSequence};return s}return null}}],oL=function(n){Qa(r,n);function r(){Rn(this,r);var i=ma(this,(r.__proto__||Object.getPrototypeOf(r)).call(this));return i.inspectCache_=void 0,i.timelines=[],i.discontinuities=[],i.datetimeToDisplayTime=null,i.logger_=_d("SyncController"),i}return qn(r,[{key:"getSyncPoint",value:function(t,e,a,s){var o=this.runStrategies_(t,e,a,s);return o.length?this.selectSyncPoint_(o,{key:"time",value:s}):null}},{key:"getExpiredTime",value:function(t,e){if(!t||!t.segments)return null;var a=this.runStrategies_(t,e,t.discontinuitySequence,0);if(!a.length)return null;var s=this.selectSyncPoint_(a,{key:"segmentIndex",value:0});return s.segmentIndex>0&&(s.time*=-1),Math.abs(s.time+vd(t,s.segmentIndex,0))}},{key:"runStrategies_",value:function(t,e,a,s){for(var o=[],u=0;u<hS.length;u++){var l=hS[u],c=l.run(this,t,e,a,s);c&&(c.strategy=l.name,o.push({strategy:l.name,syncPoint:c}))}return o}},{key:"selectSyncPoint_",value:function(t,e){for(var a=t[0].syncPoint,s=Math.abs(t[0].syncPoint[e.key]-e.value),o=t[0].strategy,u=1;u<t.length;u++){var l=Math.abs(t[u].syncPoint[e.key]-e.value);l<s&&(s=l,a=t[u].syncPoint,o=t[u].strategy)}return this.logger_("syncPoint for ["+e.key+": "+e.value+"] chosen with strategy"+(" ["+o+"]: [time:"+a.time+",")+(" segmentIndex:"+a.segmentIndex+"]")),a}},{key:"saveExpiredSegmentInfo",value:function(t,e){for(var a=e.mediaSequence-t.mediaSequence,s=a-1;s>=0;s--){var o=t.segments[s];if(o&&typeof o.start<"u"){e.syncInfo={mediaSequence:t.mediaSequence+s,time:o.start},this.logger_("playlist refresh sync: [time:"+e.syncInfo.time+","+(" mediaSequence: "+e.syncInfo.mediaSequence+"]")),this.trigger("syncinfoupdate");break}}}},{key:"setDateTimeMapping",value:function(t){if(!this.datetimeToDisplayTime&&t.segments&&t.segments.length&&t.segments[0].dateTimeObject){var e=t.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-e}}},{key:"reset",value:function(){this.inspectCache_=void 0}},{key:"probeSegmentInfo",value:function(t){var e=t.segment,a=t.playlist,s=void 0;return e.map?s=this.probeMp4Segment_(t):s=this.probeTsSegment_(t),s&&this.calculateSegmentTimeMapping_(t,s)&&(this.saveDiscontinuitySyncInfo_(t),a.syncInfo||(a.syncInfo={mediaSequence:a.mediaSequence+t.mediaIndex,time:e.start})),s}},{key:"probeMp4Segment_",value:function(t){var e=t.segment,a=kc.timescale(e.map.bytes),s=kc.startTime(a,t.bytes);return t.timestampOffset!==null&&(t.timestampOffset-=s),{start:s,end:s+e.duration}}},{key:"probeTsSegment_",value:function(t){var e=sL(t.bytes,this.inspectCache_),a=void 0,s=void 0,o=void 0;if(!e)return null;e.video&&e.video.length===2?(this.inspectCache_=e.video[1].dts,a=e.video[0].dtsTime,s=e.video[1].dtsTime,o=e.video):e.audio&&e.audio.length===2&&(this.inspectCache_=e.audio[1].dts,a=e.audio[0].dtsTime,s=e.audio[1].dtsTime,o=e.audio);var u={segmentTimestampInfo:o,start:a,end:s,containsVideo:e.video&&e.video.length===2,containsAudio:e.audio&&e.audio.length===2};return u}},{key:"timestampOffsetForTimeline",value:function(t){return typeof this.timelines[t]>"u"?null:this.timelines[t].time}},{key:"mappingForTimeline",value:function(t){return typeof this.timelines[t]>"u"?null:this.timelines[t].mapping}},{key:"calculateSegmentTimeMapping_",value:function(t,e){var a=t.segment,s=this.timelines[t.timeline];if(t.timestampOffset!==null)s={time:t.startOfSegment,mapping:t.startOfSegment-e.start},this.timelines[t.timeline]=s,this.trigger("timestampoffset"),this.logger_("time mapping for timeline "+t.timeline+": "+("[time: "+s.time+"] [mapping: "+s.mapping+"]")),a.start=t.startOfSegment,a.end=e.end+s.mapping;else if(s)a.start=e.start+s.mapping,a.end=e.end+s.mapping;else return!1;return!0}},{key:"saveDiscontinuitySyncInfo_",value:function(t){var e=t.playlist,a=t.segment;if(a.discontinuity)this.discontinuities[a.timeline]={time:a.start,accuracy:0};else if(e.discontinuityStarts&&e.discontinuityStarts.length)for(var s=0;s<e.discontinuityStarts.length;s++){var o=e.discontinuityStarts[s],u=e.discontinuitySequence+s+1,l=o-t.mediaIndex,c=Math.abs(l);if(!this.discontinuities[u]||this.discontinuities[u].accuracy>c){var d=void 0;l<0?d=a.start-vd(e,t.mediaIndex,o):d=a.end+vd(e,t.mediaIndex+1,o),this.discontinuities[u]={time:d,accuracy:c}}}}}]),r}(oe.EventTarget),uL=new Kb("./decrypter-worker.worker.js",function(n,r){var i=this;(function(){function t(T){return T.subarray(0,T.byteLength-T[T.byteLength-1])}var e=function(b,S){if(!(b instanceof S))throw new TypeError("Cannot call a class as a function")},a=function(){function T(b,S){for(var A=0;A<S.length;A++){var E=S[A];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(b,E.key,E)}}return function(b,S,A){return S&&T(b.prototype,S),A&&T(b,A),b}}(),s=function(b,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);b.prototype=Object.create(S&&S.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(b,S):b.__proto__=S)},o=function(b,S){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return S&&(typeof S=="object"||typeof S=="function")?S:b},u=function(){var b=[[[],[],[],[],[]],[[],[],[],[],[]]],S=b[0],A=b[1],E=S[4],x=A[4],C=void 0,w=void 0,k=void 0,D=[],L=[],N=void 0,P=void 0,I=void 0,O=void 0,U=void 0,q=void 0;for(C=0;C<256;C++)L[(D[C]=C<<1^(C>>7)*283)^C]=C;for(w=k=0;!E[w];w^=N||1,k=L[k]||1)for(O=k^k<<1^k<<2^k<<3^k<<4,O=O>>8^O&255^99,E[w]=O,x[O]=w,I=D[P=D[N=D[w]]],q=I*16843009^P*65537^N*257^w*16843008,U=D[O]*257^O*16843008,C=0;C<4;C++)S[C][w]=U=U<<24^U>>>8,A[C][O]=q=q<<24^q>>>8;for(C=0;C<5;C++)S[C]=S[C].slice(0),A[C]=A[C].slice(0);return b},l=null,c=function(){function T(b){e(this,T),l||(l=u()),this._tables=[[l[0][0].slice(),l[0][1].slice(),l[0][2].slice(),l[0][3].slice(),l[0][4].slice()],[l[1][0].slice(),l[1][1].slice(),l[1][2].slice(),l[1][3].slice(),l[1][4].slice()]];var S=void 0,A=void 0,E=void 0,x=void 0,C=void 0,w=this._tables[0][4],k=this._tables[1],D=b.length,L=1;if(D!==4&&D!==6&&D!==8)throw new Error("Invalid aes key size");for(x=b.slice(0),C=[],this._key=[x,C],S=D;S<4*D+28;S++)E=x[S-1],(S%D===0||D===8&&S%D===4)&&(E=w[E>>>24]<<24^w[E>>16&255]<<16^w[E>>8&255]<<8^w[E&255],S%D===0&&(E=E<<8^E>>>24^L<<24,L=L<<1^(L>>7)*283)),x[S]=x[S-D]^E;for(A=0;S;A++,S--)E=x[A&3?S:S-4],S<=4||A<4?C[A]=E:C[A]=k[0][w[E>>>24]]^k[1][w[E>>16&255]]^k[2][w[E>>8&255]]^k[3][w[E&255]]}return T.prototype.decrypt=function(S,A,E,x,C,w){var k=this._key[1],D=S^k[0],L=x^k[1],N=E^k[2],P=A^k[3],I=void 0,O=void 0,U=void 0,q=k.length/4-2,K=void 0,X=4,te=this._tables[1],J=te[0],fe=te[1],ge=te[2],Ie=te[3],qe=te[4];for(K=0;K<q;K++)I=J[D>>>24]^fe[L>>16&255]^ge[N>>8&255]^Ie[P&255]^k[X],O=J[L>>>24]^fe[N>>16&255]^ge[P>>8&255]^Ie[D&255]^k[X+1],U=J[N>>>24]^fe[P>>16&255]^ge[D>>8&255]^Ie[L&255]^k[X+2],P=J[P>>>24]^fe[D>>16&255]^ge[L>>8&255]^Ie[N&255]^k[X+3],X+=4,D=I,L=O,N=U;for(K=0;K<4;K++)C[(3&-K)+w]=qe[D>>>24]<<24^qe[L>>16&255]<<16^qe[N>>8&255]<<8^qe[P&255]^k[X++],I=D,D=L,L=N,N=P,P=I},T}(),d=function(){function T(){e(this,T),this.listeners={}}return T.prototype.on=function(S,A){this.listeners[S]||(this.listeners[S]=[]),this.listeners[S].push(A)},T.prototype.off=function(S,A){if(!this.listeners[S])return!1;var E=this.listeners[S].indexOf(A);return this.listeners[S].splice(E,1),E>-1},T.prototype.trigger=function(S){var A=this.listeners[S];if(!!A)if(arguments.length===2)for(var E=A.length,x=0;x<E;++x)A[x].call(this,arguments[1]);else for(var C=Array.prototype.slice.call(arguments,1),w=A.length,k=0;k<w;++k)A[k].apply(this,C)},T.prototype.dispose=function(){this.listeners={}},T.prototype.pipe=function(S){this.on("data",function(A){S.push(A)})},T}(),f=function(T){s(b,T);function b(){e(this,b);var S=o(this,T.call(this,d));return S.jobs=[],S.delay=1,S.timeout_=null,S}return b.prototype.processJob_=function(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null},b.prototype.push=function(A){this.jobs.push(A),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))},b}(d),h=function(b){return b<<24|(b&65280)<<8|(b&16711680)>>8|b>>>24},g=function(b,S,A){var E=new Int32Array(b.buffer,b.byteOffset,b.byteLength>>2),x=new c(Array.prototype.slice.call(S)),C=new Uint8Array(b.byteLength),w=new Int32Array(C.buffer),k=void 0,D=void 0,L=void 0,N=void 0,P=void 0,I=void 0,O=void 0,U=void 0,q=void 0;for(k=A[0],D=A[1],L=A[2],N=A[3],q=0;q<E.length;q+=4)P=h(E[q]),I=h(E[q+1]),O=h(E[q+2]),U=h(E[q+3]),x.decrypt(P,I,O,U,w,q),w[q]=h(w[q]^k),w[q+1]=h(w[q+1]^D),w[q+2]=h(w[q+2]^L),w[q+3]=h(w[q+3]^N),k=P,D=I,L=O,N=U;return C},p=function(){function T(b,S,A,E){e(this,T);var x=T.STEP,C=new Int32Array(b.buffer),w=new Uint8Array(b.byteLength),k=0;for(this.asyncStream_=new f,this.asyncStream_.push(this.decryptChunk_(C.subarray(k,k+x),S,A,w)),k=x;k<C.length;k+=x)A=new Uint32Array([h(C[k-4]),h(C[k-3]),h(C[k-2]),h(C[k-1])]),this.asyncStream_.push(this.decryptChunk_(C.subarray(k,k+x),S,A,w));this.asyncStream_.push(function(){E(null,t(w))})}return T.prototype.decryptChunk_=function(S,A,E,x){return function(){var C=g(S,A,E);x.set(C,S.byteOffset)}},a(T,null,[{key:"STEP",get:function(){return 32e3}}]),T}(),v=function(b){var S={};return Object.keys(b).forEach(function(A){var E=b[A];ArrayBuffer.isView(E)?S[A]={bytes:E.buffer,byteOffset:E.byteOffset,byteLength:E.byteLength}:S[A]=E}),S},y=function(b){b.onmessage=function(S){var A=S.data,E=new Uint8Array(A.encrypted.bytes,A.encrypted.byteOffset,A.encrypted.byteLength),x=new Uint32Array(A.key.bytes,A.key.byteOffset,A.key.byteLength/4),C=new Uint32Array(A.iv.bytes,A.iv.byteOffset,A.iv.byteLength/4);new p(E,x,C,function(w,k){b.postMessage(v({source:A.source,decrypted:k}),[k.buffer])})}},m=new y(i);return m})()}),lL=function(r){var i=r.default?"main":"alternative";return r.characteristics&&r.characteristics.indexOf("public.accessibility.describes-video")>=0&&(i="main-desc"),i},hf=function(r,i){r.abort(),r.pause(),i&&i.activePlaylistLoader&&(i.activePlaylistLoader.pause(),i.activePlaylistLoader=null)},ev=function(r,i){i.activePlaylistLoader=r,r.load()},dL=function(r,i){return function(){var t=i.segmentLoaders,e=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),u=s.activeGroup(o),l=s.activePlaylistLoader;if(hf(e,s),!!u){if(!u.playlistLoader){l&&a.resetEverything();return}e.resyncLoader(),ev(u.playlistLoader,s)}}},cL=function(r,i){return function(){var t=i.segmentLoaders,e=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),u=s.activeGroup(o),l=s.activePlaylistLoader;if(hf(e,s),!!u){if(!u.playlistLoader){a.resetEverything();return}if(l===u.playlistLoader){ev(u.playlistLoader,s);return}e.track&&e.track(o),e.resetEverything(),ev(u.playlistLoader,s)}}},pf={AUDIO:function(r,i){return function(){var t=i.segmentLoaders[r],e=i.mediaTypes[r],a=i.blacklistCurrentPlaylist;hf(t,e);var s=e.activeTrack(),o=e.activeGroup(),u=(o.filter(function(d){return d.default})[0]||o[0]).id,l=e.tracks[u];if(s===l){a({message:"Problem encountered loading the default audio track."});return}oe.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(var c in e.tracks)e.tracks[c].enabled=e.tracks[c]===l;e.onTrackChanged()}},SUBTITLES:function(r,i){return function(){var t=i.segmentLoaders[r],e=i.mediaTypes[r];oe.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),hf(t,e);var a=e.activeTrack();a&&(a.mode="disabled"),e.onTrackChanged()}}},pS={AUDIO:function(r,i,t){if(!!i){var e=t.tech,a=t.requestOptions,s=t.segmentLoaders[r];i.on("loadedmetadata",function(){var o=i.media();s.playlist(o,a),(!e.paused()||o.endList&&e.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),e.paused()||s.load()}),i.on("error",pf[r](r,t))}},SUBTITLES:function(r,i,t){var e=t.tech,a=t.requestOptions,s=t.segmentLoaders[r],o=t.mediaTypes[r];i.on("loadedmetadata",function(){var u=i.media();s.playlist(u,a),s.track(o.activeTrack()),(!e.paused()||u.endList&&e.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),e.paused()||s.load()}),i.on("error",pf[r](r,t))}},fL={AUDIO:function(r,i){var t=i.hls,e=i.sourceType,a=i.segmentLoaders[r],s=i.requestOptions,o=i.master.mediaGroups,u=i.mediaTypes[r],l=u.groups,c=u.tracks,d=i.masterPlaylistLoader;(!o[r]||Object.keys(o[r]).length===0)&&(o[r]={main:{default:{default:!0}}});for(var f in o[r]){l[f]||(l[f]=[]);for(var h in o[r][f]){var g=o[r][f][h],p=void 0;if(g.resolvedUri?p=new uf(g.resolvedUri,t,s):g.playlists&&e==="dash"?p=new Yg(g.playlists[0],t,s,d):p=null,g=oe.mergeOptions({id:h,playlistLoader:p},g),pS[r](r,g.playlistLoader,i),l[f].push(g),typeof c[h]>"u"){var v=new oe.AudioTrack({id:h,kind:lL(g),enabled:!1,language:g.language,default:g.default,label:h});c[h]=v}}}a.on("error",pf[r](r,i))},SUBTITLES:function(r,i){var t=i.tech,e=i.hls,a=i.sourceType,s=i.segmentLoaders[r],o=i.requestOptions,u=i.master.mediaGroups,l=i.mediaTypes[r],c=l.groups,d=l.tracks,f=i.masterPlaylistLoader;for(var h in u[r]){c[h]||(c[h]=[]);for(var g in u[r][h])if(!u[r][h][g].forced){var p=u[r][h][g],v=void 0;if(a==="hls"?v=new uf(p.resolvedUri,e,o):a==="dash"&&(v=new Yg(p.playlists[0],e,o,f)),p=oe.mergeOptions({id:g,playlistLoader:v},p),pS[r](r,p.playlistLoader,i),c[h].push(p),typeof d[g]>"u"){var y=t.addRemoteTextTrack({id:g,kind:"subtitles",default:p.default&&p.autoselect,language:p.language,label:g},!1).track;d[g]=y}}}s.on("error",pf[r](r,i))},"CLOSED-CAPTIONS":function(r,i){var t=i.tech,e=i.master.mediaGroups,a=i.mediaTypes[r],s=a.groups,o=a.tracks;for(var u in e[r]){s[u]||(s[u]=[]);for(var l in e[r][u]){var c=e[r][u][l];if(!!c.instreamId.match(/CC\d/)&&(s[u].push(oe.mergeOptions({id:l},c)),typeof o[l]>"u")){var d=t.addRemoteTextTrack({id:c.instreamId,kind:"captions",default:c.default&&c.autoselect,language:c.language,label:l},!1).track;o[l]=d}}}}},hL=function(r,i){return function(t){var e=i.masterPlaylistLoader,a=i.mediaTypes[r].groups,s=e.media();if(!s)return null;var o=null;return s.attributes[r]&&(o=a[s.attributes[r]]),o=o||a.main,typeof t>"u"?o:t===null?null:o.filter(function(u){return u.id===t.id})[0]||null}},pL={AUDIO:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var e in t)if(t[e].enabled)return t[e];return null}},SUBTITLES:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var e in t)if(t[e].mode==="showing")return t[e];return null}}},gL=function(r){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(c){fL[c](c,r)});var i=r.mediaTypes,t=r.masterPlaylistLoader,e=r.tech,a=r.hls;["AUDIO","SUBTITLES"].forEach(function(c){i[c].activeGroup=hL(c,r),i[c].activeTrack=pL[c](c,r),i[c].onGroupChanged=dL(c,r),i[c].onTrackChanged=cL(c,r)});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(),t.on("mediachange",function(){["AUDIO","SUBTITLES"].forEach(function(c){return i[c].onGroupChanged()})});var u=function(){i.AUDIO.onTrackChanged(),e.trigger({type:"usage",name:"hls-audio-change"})};e.audioTracks().addEventListener("change",u),e.remoteTextTracks().addEventListener("change",i.SUBTITLES.onTrackChanged),a.on("dispose",function(){e.audioTracks().removeEventListener("change",u),e.remoteTextTracks().removeEventListener("change",i.SUBTITLES.onTrackChanged)}),e.clearTracks("audio");for(var l in i.AUDIO.tracks)e.audioTracks().addTrack(i.AUDIO.tracks[l])},vL=function(){var r={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(i){r[i]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Hu,activeTrack:Hu,onGroupChanged:Hu,onTrackChanged:Hu}}),r},mL=60*2,Ms=void 0,yL=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],_L=function(r){return this.audioSegmentLoader_[r]+this.mainSegmentLoader_[r]},TL=function(n){Qa(r,n);function r(i){Rn(this,r);var t=ma(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),e=i.url,a=i.handleManifestRedirects,s=i.withCredentials,o=i.tech,u=i.bandwidth,l=i.externHls,c=i.useCueTags,d=i.blacklistDuration,f=i.enableLowInitialPlaylist,h=i.sourceType,g=i.seekTo,p=i.cacheEncryptionKeys;if(!e)throw new Error("A non-empty playlist URL is required");Ms=l,t.withCredentials=s,t.tech_=o,t.hls_=o.hls,t.seekTo_=g,t.sourceType_=h,t.useCueTags_=c,t.blacklistDuration=d,t.enableLowInitialPlaylist=f,t.useCueTags_&&(t.cueTagsTrack_=t.tech_.addTextTrack("metadata","ad-cues"),t.cueTagsTrack_.inBandMetadataTrackDispatchType=""),t.requestOptions_={withCredentials:s,handleManifestRedirects:a,timeout:null},t.mediaTypes_=vL(),t.mediaSource=new oe.MediaSource,t.mediaSource.addEventListener("sourceopen",t.handleSourceOpen_.bind(t)),t.seekable_=oe.createTimeRanges(),t.hasPlayed_=function(){return!1},t.syncController_=new oL(i),t.segmentMetadataTrack_=o.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,t.decrypter_=new uL,t.inbandTextTracks_={};var v={hls:t.hls_,mediaSource:t.mediaSource,currentTime:t.tech_.currentTime.bind(t.tech_),seekable:function(){return t.seekable()},seeking:function(){return t.tech_.seeking()},duration:function(){return t.mediaSource.duration},hasPlayed:function(){return t.hasPlayed_()},goalBufferLength:function(){return t.goalBufferLength()},bandwidth:u,syncController:t.syncController_,decrypter:t.decrypter_,sourceType:t.sourceType_,inbandTextTracks:t.inbandTextTracks_,cacheEncryptionKeys:p};return t.masterPlaylistLoader_=t.sourceType_==="dash"?new Yg(e,t.hls_,t.requestOptions_):new uf(e,t.hls_,t.requestOptions_),t.setupMasterPlaylistLoaderListeners_(),t.mainSegmentLoader_=new Zg(oe.mergeOptions(v,{segmentMetadataTrack:t.segmentMetadataTrack_,loaderType:"main"}),i),t.audioSegmentLoader_=new Zg(oe.mergeOptions(v,{loaderType:"audio"}),i),t.subtitleSegmentLoader_=new iL(oe.mergeOptions(v,{loaderType:"vtt"}),i),t.setupSegmentLoaderListeners_(),yL.forEach(function(y){t[y+"_"]=_L.bind(t,y)}),t.logger_=_d("MPC"),t.masterPlaylistLoader_.load(),t}return qn(r,[{key:"setupMasterPlaylistLoaderListeners_",value:function(){var t=this;this.masterPlaylistLoader_.on("loadedmetadata",function(){var e=t.masterPlaylistLoader_.media(),a=e.targetDuration*1.5*1e3;Gg(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,e.endList&&t.tech_.preload()!=="none"&&(t.mainSegmentLoader_.playlist(e,t.requestOptions_),t.mainSegmentLoader_.load()),gL({sourceType:t.sourceType_,segmentLoaders:{AUDIO:t.audioSegmentLoader_,SUBTITLES:t.subtitleSegmentLoader_,main:t.mainSegmentLoader_},tech:t.tech_,requestOptions:t.requestOptions_,masterPlaylistLoader:t.masterPlaylistLoader_,hls:t.hls_,master:t.master(),mediaTypes:t.mediaTypes_,blacklistCurrentPlaylist:t.blacklistCurrentPlaylist.bind(t)}),t.triggerPresenceUsage_(t.master(),e);try{t.setupSourceBuffers_()}catch(s){return oe.log.warn("Failed to create SourceBuffers",s),t.mediaSource.endOfStream("decode")}t.setupFirstPlay(),!t.mediaTypes_.AUDIO.activePlaylistLoader||t.mediaTypes_.AUDIO.activePlaylistLoader.media()?t.trigger("selectedinitialmedia"):t.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",function(){t.trigger("selectedinitialmedia")})}),this.masterPlaylistLoader_.on("loadedplaylist",function(){var e=t.masterPlaylistLoader_.media();if(!e){t.excludeUnsupportedVariants_();var a=void 0;t.enableLowInitialPlaylist&&(a=t.selectInitialPlaylist()),a||(a=t.selectPlaylist()),t.initialMedia_=a,t.masterPlaylistLoader_.media(t.initialMedia_);return}if(t.useCueTags_&&t.updateAdCues_(e),t.mainSegmentLoader_.playlist(e,t.requestOptions_),t.updateDuration(),t.tech_.paused()||(t.mainSegmentLoader_.load(),t.audioSegmentLoader_&&t.audioSegmentLoader_.load()),!e.endList){var s=function(){var l=t.seekable();l.length!==0&&t.mediaSource.addSeekableRange_(l.start(0),l.end(0))};if(t.duration()!==1/0){var o=function u(){t.duration()===1/0?s():t.tech_.one("durationchange",u)};t.tech_.one("durationchange",o)}else s()}}),this.masterPlaylistLoader_.on("error",function(){t.blacklistCurrentPlaylist(t.masterPlaylistLoader_.error)}),this.masterPlaylistLoader_.on("mediachanging",function(){t.mainSegmentLoader_.abort(),t.mainSegmentLoader_.pause()}),this.masterPlaylistLoader_.on("mediachange",function(){var e=t.masterPlaylistLoader_.media(),a=e.targetDuration*1.5*1e3;Gg(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,t.mainSegmentLoader_.playlist(e,t.requestOptions_),t.mainSegmentLoader_.load(),t.tech_.trigger({type:"mediachange",bubbles:!0})}),this.masterPlaylistLoader_.on("playlistunchanged",function(){var e=t.masterPlaylistLoader_.media(),a=t.stuckAtPlaylistEnd_(e);a&&(t.blacklistCurrentPlaylist({message:"Playlist no longer updating."}),t.tech_.trigger("playliststuck"))}),this.masterPlaylistLoader_.on("renditiondisabled",function(){t.tech_.trigger({type:"usage",name:"hls-rendition-disabled"})}),this.masterPlaylistLoader_.on("renditionenabled",function(){t.tech_.trigger({type:"usage",name:"hls-rendition-enabled"})})}},{key:"triggerPresenceUsage_",value:function(t,e){var a=t.mediaGroups||{},s=!0,o=Object.keys(a.AUDIO);for(var u in a.AUDIO)for(var l in a.AUDIO[u]){var c=a.AUDIO[u][l];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"}),Ms.Playlist.isAes(e)&&this.tech_.trigger({type:"usage",name:"hls-aes"}),Ms.Playlist.isFmp4(e)&&this.tech_.trigger({type:"usage",name:"hls-fmp4"}),o.length&&Object.keys(a.AUDIO[o[0]]).length>1&&this.tech_.trigger({type:"usage",name:"hls-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"hls-playlist-cue-tags"})}},{key:"setupSegmentLoaderListeners_",value:function(){var t=this;this.mainSegmentLoader_.on("bandwidthupdate",function(){var e=t.selectPlaylist(),a=t.masterPlaylistLoader_.media(),s=t.tech_.buffered(),o=s.length?s.end(s.length-1)-t.tech_.currentTime():0,u=t.bufferLowWaterLine();(!a.endList||t.duration()<pn.MAX_BUFFER_LOW_WATER_LINE||e.attributes.BANDWIDTH<a.attributes.BANDWIDTH||o>=u)&&t.masterPlaylistLoader_.media(e),t.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("progress",function(){t.trigger("progress")}),this.mainSegmentLoader_.on("error",function(){t.blacklistCurrentPlaylist(t.mainSegmentLoader_.error())}),this.mainSegmentLoader_.on("syncinfoupdate",function(){t.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",function(){t.tech_.trigger({type:"usage",name:"hls-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",function(){t.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("ended",function(){t.onEndOfStream()}),this.mainSegmentLoader_.on("earlyabort",function(){t.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},mL)}),this.mainSegmentLoader_.on("reseteverything",function(){t.tech_.trigger("hls-reset")}),this.mainSegmentLoader_.on("segmenttimemapping",function(e){t.tech_.trigger({type:"hls-segment-time-mapping",mapping:e.mapping})}),this.audioSegmentLoader_.on("ended",function(){t.onEndOfStream()})}},{key:"mediaSecondsLoaded_",value:function(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}},{key:"load",value:function(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}},{key:"smoothQualityChange_",value:function(){var t=this.selectPlaylist();t!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(t),this.mainSegmentLoader_.resetLoader())}},{key:"fastQualityChange_",value:function(){var t=this,e=this.selectPlaylist();e!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(e),this.mainSegmentLoader_.resetEverything(function(){oe.browser.IE_VERSION||oe.browser.IS_EDGE?t.tech_.setCurrentTime(t.tech_.currentTime()+.04):t.tech_.setCurrentTime(t.tech_.currentTime())}))}},{key:"play",value:function(){if(!this.setupFirstPlay()){this.tech_.ended()&&this.seekTo_(0),this.hasPlayed_()&&this.load();var t=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<t.start(0))return this.seekTo_(t.end(t.length-1))}}},{key:"setupFirstPlay",value:function(){var t=this,e=this.masterPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_())return!1;if(!e.endList){var a=this.seekable();if(!a.length)return!1;if(oe.browser.IE_VERSION&&this.tech_.readyState()===0)return this.tech_.one("loadedmetadata",function(){t.trigger("firstplay"),t.seekTo_(a.end(0)),t.hasPlayed_=function(){return!0}}),!1;this.trigger("firstplay"),this.seekTo_(a.end(0))}return this.hasPlayed_=function(){return!0},this.load(),!0}},{key:"handleSourceOpen_",value:function(){try{this.setupSourceBuffers_()}catch(e){return oe.log.warn("Failed to create Source Buffers",e),this.mediaSource.endOfStream("decode")}if(this.tech_.autoplay()){var t=this.tech_.play();typeof t<"u"&&typeof t.then=="function"&&t.then(null,function(e){})}this.trigger("sourceopen")}},{key:"onEndOfStream",value:function(){var t=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(!this.mainSegmentLoader_.startingMedia_||this.mainSegmentLoader_.startingMedia_.containsVideo?t=t&&this.audioSegmentLoader_.ended_:t=this.audioSegmentLoader_.ended_),!!t){this.logger_("calling mediaSource.endOfStream()");try{this.mediaSource.endOfStream()}catch(e){oe.log.warn("Failed to call media source endOfStream",e)}}}},{key:"stuckAtPlaylistEnd_",value:function(t){var e=this.seekable();if(!e.length)return!1;var a=this.syncController_.getExpiredTime(t,this.mediaSource.duration);if(a===null)return!1;var s=Ms.Playlist.playlistEnd(t,a),o=this.tech_.currentTime(),u=this.tech_.buffered();if(!u.length)return s-o<=Ja;var l=u.end(u.length-1);return l-o<=Ja&&s-l<=Ja}},{key:"blacklistCurrentPlaylist",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments[1],a=void 0,s=void 0;if(a=t.playlist||this.masterPlaylistLoader_.media(),e=e||t.blacklistDuration||this.blacklistDuration,!a){this.error=t;try{return this.mediaSource.endOfStream("network")}catch{return this.trigger("error")}}var o=this.masterPlaylistLoader_.master.playlists.filter(lf).length===1,u=this.masterPlaylistLoader_.master.playlists;return u.length===1?(oe.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&&(oe.log.warn("Removing all playlists from the blacklist because the last rendition is about to be blacklisted."),u.forEach(function(l){l.excludeUntil!==1/0&&delete l.excludeUntil}),this.tech_.trigger("retryplaylist")),a.excludeUntil=Date.now()+e*1e3,this.tech_.trigger("blacklistplaylist"),this.tech_.trigger({type:"usage",name:"hls-rendition-blacklisted"}),s=this.selectPlaylist(),oe.log.warn("Problem encountered with the current HLS playlist."+(t.message?" "+t.message:"")+" Switching to another playlist."),this.masterPlaylistLoader_.media(s,o))}},{key:"pauseLoading",value:function(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}},{key:"setCurrentTime",value:function(t){var e=Vb(this.tech_.buffered(),t);if(!(this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media())||!this.masterPlaylistLoader_.media().segments)return 0;if(e&&e.length)return t;this.mainSegmentLoader_.resetEverything(),this.mainSegmentLoader_.abort(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.resetEverything(),this.audioSegmentLoader_.abort()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.resetEverything(),this.subtitleSegmentLoader_.abort()),this.load()}},{key:"duration",value:function(){return this.masterPlaylistLoader_?this.mediaSource?this.mediaSource.duration:Ms.Playlist.duration(this.masterPlaylistLoader_.media()):0}},{key:"seekable",value:function(){return this.seekable_}},{key:"onSyncInfoUpdate_",value:function(){var t=void 0,e=void 0;if(!!this.masterPlaylistLoader_){var a=this.masterPlaylistLoader_.media();if(!!a){var s=this.syncController_.getExpiredTime(a,this.mediaSource.duration);if(s!==null&&(t=Ms.Playlist.seekable(a,s),t.length!==0&&!(this.mediaTypes_.AUDIO.activePlaylistLoader&&(a=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),s=this.syncController_.getExpiredTime(a,this.mediaSource.duration),s===null||(e=Ms.Playlist.seekable(a,s),e.length===0))))){var o=void 0,u=void 0;this.seekable_&&this.seekable_.length&&(o=this.seekable_.end(0),u=this.seekable_.start(0)),e?e.start(0)>t.end(0)||t.start(0)>e.end(0)?this.seekable_=t:this.seekable_=oe.createTimeRanges([[e.start(0)>t.start(0)?e.start(0):t.start(0),e.end(0)<t.end(0)?e.end(0):t.end(0)]]):this.seekable_=t,!(this.seekable_&&this.seekable_.length&&this.seekable_.end(0)===o&&this.seekable_.start(0)===u)&&(this.logger_("seekable updated ["+qg(this.seekable_)+"]"),this.tech_.trigger("seekablechanged"))}}}}},{key:"updateDuration",value:function(){var t=this,e=this.mediaSource.duration,a=Ms.Playlist.duration(this.masterPlaylistLoader_.media()),s=this.tech_.buffered(),o=function u(){t.logger_("Setting duration from "+t.mediaSource.duration+" => "+a);try{t.mediaSource.duration=a}catch(l){oe.log.warn("Failed to set media source duration",l)}t.tech_.trigger("durationchange"),t.mediaSource.removeEventListener("sourceopen",u)};s.length>0&&(a=Math.max(a,s.end(s.length-1))),e!==a&&(this.mediaSource.readyState!=="open"?this.mediaSource.addEventListener("sourceopen",o):o())}},{key:"dispose",value:function(){var t=this;this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),["AUDIO","SUBTITLES"].forEach(function(e){var a=t.mediaTypes_[e].groups;for(var s in a)a[s].forEach(function(o){o.playlistLoader&&o.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose()}},{key:"master",value:function(){return this.masterPlaylistLoader_.master}},{key:"media",value:function(){return this.masterPlaylistLoader_.media()||this.initialMedia_}},{key:"setupSourceBuffers_",value:function(){var t=this.masterPlaylistLoader_.media(),e=void 0;if(!(!t||this.mediaSource.readyState!=="open")){if(e=xI(this.masterPlaylistLoader_.master,t),e.length<1)return this.error="No compatible SourceBuffer configuration for the variant stream:"+t.resolvedUri,this.mediaSource.endOfStream("decode");this.configureLoaderMimeTypes_(e),this.excludeIncompatibleVariants_(t)}}},{key:"configureLoaderMimeTypes_",value:function(t){var e=t.length>1&&t[0].indexOf(",")===-1&&t[0]!==t[1]?new oe.EventTarget:null;this.mainSegmentLoader_.mimeType(t[0],e),t[1]&&this.audioSegmentLoader_.mimeType(t[1],e)}},{key:"excludeUnsupportedVariants_",value:function(){this.master().playlists.forEach(function(t){t.attributes.CODECS&&Pe.MediaSource&&Pe.MediaSource.isTypeSupported&&!Pe.MediaSource.isTypeSupported('video/mp4; codecs="'+TI(t.attributes.CODECS)+'"')&&(t.excludeUntil=1/0)})}},{key:"excludeIncompatibleVariants_",value:function(t){var e=2,a=null,s=void 0;t.attributes.CODECS&&(s=md(t.attributes.CODECS),a=s.videoCodec,e=s.codecCount),this.master().playlists.forEach(function(o){var u={codecCount:2,videoCodec:null};o.attributes.CODECS&&(u=md(o.attributes.CODECS)),u.codecCount!==e&&(o.excludeUntil=1/0),u.videoCodec!==a&&(o.excludeUntil=1/0)})}},{key:"updateAdCues_",value:function(t){var e=0,a=this.seekable();a.length&&(e=a.start(0)),aL(t,this.cueTagsTrack_,e)}},{key:"goalBufferLength",value:function(){var t=this.tech_.currentTime(),e=pn.GOAL_BUFFER_LENGTH,a=pn.GOAL_BUFFER_LENGTH_RATE,s=Math.max(e,pn.MAX_GOAL_BUFFER_LENGTH);return Math.min(e+t*a,s)}},{key:"bufferLowWaterLine",value:function(){var t=this.tech_.currentTime(),e=pn.BUFFER_LOW_WATER_LINE,a=pn.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(e,pn.MAX_BUFFER_LOW_WATER_LINE);return Math.min(e+t*a,s)}}]),r}(oe.EventTarget),bL=function(r,i,t){return function(e){var a=r.master.playlists[i],s=Hg(a),o=lf(a);return typeof e>"u"?o:(e?delete a.disabled:a.disabled=!0,e!==o&&!s&&(t(),e?r.trigger("renditionenabled"):r.trigger("renditiondisabled")),e)}},SL=function n(r,i,t){Rn(this,n);var e=r.masterPlaylistController_,a=r.options_.smoothQualityChange,s=a?"smooth":"fast",o=e[s+"QualityChange_"].bind(e);if(i.attributes.RESOLUTION){var u=i.attributes.RESOLUTION;this.width=u.width,this.height=u.height}this.bandwidth=i.attributes.BANDWIDTH,this.id=t,this.enabled=bL(r.playlists,i.uri,o)},EL=function(r){var i=r.playlists;r.representations=function(){return i.master.playlists.filter(function(t){return!Hg(t)}).map(function(t,e){return new SL(r,t,t.uri)})}},gS=["seeking","seeked","pause","playing","error"],xL=function(){function n(r){var i=this;Rn(this,n),this.tech_=r.tech,this.seekable=r.seekable,this.seekTo=r.seekTo,this.allowSeeksWithinUnsafeLiveWindow=r.allowSeeksWithinUnsafeLiveWindow,this.media=r.media,this.consecutiveUpdates=0,this.lastRecordedTime=null,this.timer_=null,this.checkCurrentTimeTimeout_=null,this.logger_=_d("PlaybackWatcher"),this.logger_("initialize");var t=function(){return i.monitorCurrentTime_()},e=function(){return i.techWaiting_()},a=function(){return i.cancelTimer_()},s=function(){return i.fixesBadSeeks_()};this.tech_.on("seekablechanged",s),this.tech_.on("waiting",e),this.tech_.on(gS,a),this.tech_.on("canplay",t),this.dispose=function(){i.logger_("dispose"),i.tech_.off("seekablechanged",s),i.tech_.off("waiting",e),i.tech_.off(gS,a),i.tech_.off("canplay",t),i.checkCurrentTimeTimeout_&&Pe.clearTimeout(i.checkCurrentTimeTimeout_),i.cancelTimer_()}}return qn(n,[{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(),t=this.tech_.buffered();if(this.lastRecordedTime===i&&(!t.length||i+Ja>=t.end(t.length-1)))return this.techWaiting_();this.consecutiveUpdates>=5&&i===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):i===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=i)}}},{key:"cancelTimer_",value:function(){this.consecutiveUpdates=0,this.timer_&&(this.logger_("cancelTimer_"),clearTimeout(this.timer_)),this.timer_=null}},{key:"fixesBadSeeks_",value:function(){var i=this.tech_.seeking();if(!i)return!1;var t=this.seekable(),e=this.tech_.currentTime(),a=this.afterSeekableWindow_(t,e,this.media(),this.allowSeeksWithinUnsafeLiveWindow),s=void 0;if(a){var o=t.end(t.length-1);s=o}if(this.beforeSeekableWindow_(t,e)){var u=t.start(0);s=u+Ja}return typeof s<"u"?(this.logger_("Trying to seek outside of seekable at time "+e+" with "+("seekable range "+qg(t)+". Seeking to ")+(s+".")),this.seekTo(s),!0):!1}},{key:"waiting_",value:function(){if(!this.techWaiting_()){var i=this.tech_.currentTime(),t=this.tech_.buffered(),e=Vb(t,i);if(e.length&&i+3<=e.end(0)){this.cancelTimer_(),this.seekTo(i),this.logger_("Stopped at "+i+" while inside a buffered region "+("["+e.start(0)+" -> "+e.end(0)+"]. Attempting to resume ")+"playback by seeking to the current time."),this.tech_.trigger({type:"usage",name:"hls-unknown-waiting"});return}}}},{key:"techWaiting_",value:function(){var i=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_()||this.tech_.seeking()||this.timer_!==null)return!0;if(this.beforeSeekableWindow_(i,t)){var e=i.end(i.length-1);return this.logger_("Fell out of live window at time "+t+". Seeking to "+("live point (seekable end) "+e)),this.cancelTimer_(),this.seekTo(e),this.tech_.trigger({type:"usage",name:"hls-live-resync"}),!0}var a=this.tech_.buffered(),s=qb(a,t);if(this.videoUnderflow_(s,a,t))return this.cancelTimer_(),this.seekTo(t),this.tech_.trigger({type:"usage",name:"hls-video-underflow"}),!0;if(s.length>0){var o=s.start(0)-t;return this.logger_("Stopped at "+t+", setting timer for "+o+", seeking "+("to "+s.start(0))),this.timer_=setTimeout(this.skipTheGap_.bind(this),o*1e3,t),!0}return!1}},{key:"afterSeekableWindow_",value:function(i,t,e){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!i.length)return!1;var s=i.end(i.length-1)+Ja,o=!e.endList;return o&&a&&(s=i.end(i.length-1)+e.targetDuration*3),t>s}},{key:"beforeSeekableWindow_",value:function(i,t){return!!(i.length&&i.start(0)>0&&t<i.start(0)-Ja)}},{key:"videoUnderflow_",value:function(i,t,e){if(i.length===0){var a=this.gapFromVideoUnderflow_(t,e);if(a)return this.logger_("Encountered a gap in video from "+a.start+" to "+a.end+". "+("Seeking to current time "+e)),!0}return!1}},{key:"skipTheGap_",value:function(i){var t=this.tech_.buffered(),e=this.tech_.currentTime(),a=qb(t,e);this.cancelTimer_(),!(a.length===0||e!==i)&&(this.logger_("skipTheGap_:","currentTime:",e,"scheduled currentTime:",i,"nextRange start:",a.start(0)),this.seekTo(a.start(0)+cf),this.tech_.trigger({type:"usage",name:"hls-gap-skip"}))}},{key:"gapFromVideoUnderflow_",value:function(i,t){for(var e=cI(i),a=0;a<e.length;a++){var s=e.start(a),o=e.end(a);if(t-s<4&&t-s>2)return{start:s,end:o}}return null}}]),n}(),AL={errorInterval:30,getSource:function(r){var i=this.tech({IWillNotUseThisInPlugins:!0}),t=i.currentSource_;return r(t)}},CL=function n(r,i){var t=0,e=0,a=oe.mergeOptions(AL,i);r.ready(function(){r.trigger({type:"usage",name:"hls-error-reload-initialized"})});var s=function(){e&&r.currentTime(e)},o=function(f){f!=null&&(e=r.duration()!==1/0&&r.currentTime()||0,r.one("loadedmetadata",s),r.src(f),r.trigger({type:"usage",name:"hls-error-reload"}),r.play())},u=function(){if(Date.now()-t<a.errorInterval*1e3){r.trigger({type:"usage",name:"hls-error-reload-canceled"});return}if(!a.getSource||typeof a.getSource!="function"){oe.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),a.getSource.call(r,o)},l=function d(){r.off("loadedmetadata",s),r.off("error",u),r.off("dispose",d)},c=function(f){l(),n(r,f)};r.on("error",u),r.on("dispose",l),r.reloadSourceOnError=c},vS=function(r){CL(this,r)},wL="1.10.6";oe.use("*",function(n){return{setSource:function(i,t){t(null,i)},setCurrentTime:function(i){return n.vhs&&n.currentSource().src===n.vhs.source_.src&&n.vhs.setCurrentTime(i),i},play:function(){n.vhs&&n.currentSource().src===n.vhs.source_.src&&n.vhs.setCurrentTime(n.tech_.currentTime())}}});var tn={PlaylistLoader:uf,Playlist:en,Decrypter:sP,AsyncStream:B_,decrypt:U_,utils:rI,STANDARD_PLAYLIST_SELECTOR:KI,INITIAL_PLAYLIST_SELECTOR:XI,comparePlaylistBandwidth:Jg,comparePlaylistResolution:$I,xhr:Nb()};["GOAL_BUFFER_LENGTH","MAX_GOAL_BUFFER_LENGTH","GOAL_BUFFER_LENGTH_RATE","BUFFER_LOW_WATER_LINE","MAX_BUFFER_LOW_WATER_LINE","BUFFER_LOW_WATER_LINE_RATE","BANDWIDTH_VARIANCE"].forEach(function(n){Object.defineProperty(tn,n,{get:function(){return oe.log.warn("using Hls."+n+" is UNSAFE be sure you know what you are doing"),pn[n]},set:function(i){if(oe.log.warn("using Hls."+n+" is UNSAFE be sure you know what you are doing"),typeof i!="number"||i<0){oe.log.warn("value of Hls."+n+" must be greater than or equal to 0");return}pn[n]=i}})});var mS="videojs-vhs",yS=function(r){var i=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;if(i.test(r))return"hls";var t=/^application\/dash\+xml/i;return t.test(r)?"dash":null},_S=function(r,i){for(var t=i.media(),e=-1,a=0;a<r.length;a++)if(r[a].id===t.uri){e=a;break}r.selectedIndex_=e,r.trigger({selectedIndex:e,type:"change"})},kL=function(r,i){i.representations().forEach(function(t){r.addQualityLevel(t)}),_S(r,i.playlists)};tn.canPlaySource=function(){return oe.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var DL=function(r,i,t){if(!r)return r;var e={};for(var a in r)e[a]={audioContentType:'audio/mp4; codecs="'+t.attributes.CODECS+'"',videoContentType:'video/mp4; codecs="'+i.attributes.CODECS+'"'},i.contentProtection&&i.contentProtection[a]&&i.contentProtection[a].pssh&&(e[a].pssh=i.contentProtection[a].pssh),typeof r[a]=="string"&&(e[a].url=r[a]);return oe.mergeOptions(r,e)},PL=function(r){if(r.options_.sourceType==="dash"){var i=oe.players[r.tech_.options_.playerId];if(i.eme){var t=DL(r.source_.keySystems,r.playlists.media(),r.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader.media());t&&(i.currentSource().keySystems=t,i.eme.initializeMediaKeys&&i.eme.initializeMediaKeys())}}},TS=function(){if(!window.localStorage)return null;var r=window.localStorage.getItem(mS);if(!r)return null;try{return JSON.parse(r)}catch{return null}},RL=function(r){if(!window.localStorage)return!1;var i=TS();i=i?oe.mergeOptions(i,r):r;try{window.localStorage.setItem(mS,JSON.stringify(i))}catch{return!1}return i};tn.supportsNativeHls=function(){var n=vt.createElement("video");if(!oe.getTech("Html5").isSupported())return!1;var r=["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"];return r.some(function(i){return/maybe|probably/i.test(n.canPlayType(i))})}(),tn.supportsNativeDash=function(){return oe.getTech("Html5").isSupported()?/maybe|probably/i.test(vt.createElement("video").canPlayType("application/dash+xml")):!1}(),tn.supportsTypeNatively=function(n){return n==="hls"?tn.supportsNativeHls:n==="dash"?tn.supportsNativeDash:!1},tn.isSupported=function(){return oe.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var IL=oe.getComponent("Component"),bS=function(n){Qa(r,n);function r(i,t,e){Rn(this,r);var a=ma(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t,e.hls));if(t.options_&&t.options_.playerId){var s=oe(t.options_.playerId);s.hasOwnProperty("hls")||Object.defineProperty(s,"hls",{get:function(){return oe.log.warn("player.hls is deprecated. Use player.tech().hls instead."),t.trigger({type:"usage",name:"hls-player-access"}),a},configurable:!0}),s.vhs=a,s.dash=a,a.player_=s}if(a.tech_=t,a.source_=i,a.stats={},a.setOptions_(),a.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(a.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native HLS requires emulated tracks. See https://git.io/vMpjB");return a.on(vt,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],function(o){var u=vt.fullscreenElement||vt.webkitFullscreenElement||vt.mozFullScreenElement||vt.msFullscreenElement;u&&u.contains(a.tech_.el())&&a.masterPlaylistController_.smoothQualityChange_()}),a.on(a.tech_,"seeking",function(){this.tech_.currentTime()===0&&this.tech_.player_.loop()&&this.setCurrentTime(0)}),a.on(a.tech_,"error",function(){this.masterPlaylistController_&&this.masterPlaylistController_.pauseLoading()}),a.on(a.tech_,"play",a.play),a}return qn(r,[{key:"setOptions_",value:function(){var t=this;if(this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.handleManifestRedirects=this.options_.handleManifestRedirects||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.smoothQualityChange=this.options_.smoothQualityChange||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,typeof this.options_.blacklistDuration!="number"&&(this.options_.blacklistDuration=5*60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){var e=TS();e&&e.bandwidth&&(this.options_.bandwidth=e.bandwidth,this.tech_.trigger({type:"usage",name:"hls-bandwidth-from-local-storage"})),e&&e.throughput&&(this.options_.throughput=e.throughput,this.tech_.trigger({type:"usage",name:"hls-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=pn.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===pn.INITIAL_BANDWIDTH,["withCredentials","limitRenditionByPlayerDimensions","bandwidth","smoothQualityChange","customTagParsers","customTagMappers","handleManifestRedirects","cacheEncryptionKeys"].forEach(function(a){typeof t.source_[a]<"u"&&(t.options_[a]=t.source_[a])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions}},{key:"src",value:function(t,e){var a=this;!t||(this.setOptions_(),this.options_.url=this.source_.src,this.options_.tech=this.tech_,this.options_.externHls=tn,this.options_.sourceType=yS(e),this.options_.seekTo=function(s){a.tech_.setCurrentTime(s),a.setCurrentTime(s)},this.masterPlaylistController_=new TL(this.options_),this.playbackWatcher_=new xL(oe.mergeOptions(this.options_,{seekable:function(){return a.seekable()},media:function(){return a.masterPlaylistController_.media()}})),this.masterPlaylistController_.on("error",function(){var s=oe.players[a.tech_.options_.playerId];s.error(a.masterPlaylistController_.error)}),this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):tn.STANDARD_PLAYLIST_SELECTOR.bind(this),this.masterPlaylistController_.selectInitialPlaylist=tn.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.masterPlaylistController_.masterPlaylistLoader_,this.mediaSource=this.masterPlaylistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get:function(){return this.masterPlaylistController_.selectPlaylist},set:function(o){this.masterPlaylistController_.selectPlaylist=o.bind(this)}},throughput:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.throughput.rate},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.throughput.rate=o,this.masterPlaylistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.bandwidth},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.bandwidth=o,this.masterPlaylistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get:function(){var o=1/(this.bandwidth||1),u=void 0;this.throughput>0?u=1/this.throughput:u=0;var l=Math.floor(1/(o+u));return l},set:function(){oe.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 $b(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 $b(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&&RL({bandwidth:a.bandwidth,throughput:Math.round(a.throughput)})}),this.masterPlaylistController_.on("selectedinitialmedia",function(){EL(a),PL(a)}),this.on(this.masterPlaylistController_,"progress",function(){this.tech_.trigger("progress")}),this.tech_.ready(function(){return a.setupQualityLevels_()}),this.tech_.el()&&this.tech_.src(oe.URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var t=this,e=oe.players[this.tech_.options_.playerId];e&&e.qualityLevels&&(this.qualityLevels_=e.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",function(){kL(t.qualityLevels_,t)}),this.playlists.on("mediachange",function(){_S(t.qualityLevels_,t.playlists)}))}},{key:"play",value:function(){this.masterPlaylistController_.play()}},{key:"setCurrentTime",value:function(t){this.masterPlaylistController_.setCurrentTime(t)}},{key:"duration",value:function(){return this.masterPlaylistController_.duration()}},{key:"seekable",value:function(){return this.masterPlaylistController_.seekable()}},{key:"dispose",value:function(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.masterPlaylistController_&&this.masterPlaylistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.player_&&(delete this.player_.vhs,delete this.player_.dash,delete this.player_.hls),this.tech_&&this.tech_.hls&&delete this.tech_.hls,IR(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"dispose",this).call(this)}},{key:"convertToProgramTime",value:function(t,e){return lI({playlist:this.masterPlaylistController_.media(),time:t,callback:e})}},{key:"seekToProgramTime",value:function(t,e){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:2;return dI({programTime:t,playlist:this.masterPlaylistController_.media(),retryCount:s,pauseAfterSeek:a,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:e})}}]),r}(IL),tv={name:"videojs-http-streaming",VERSION:wL,canHandleSource:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=oe.mergeOptions(oe.options,i);return tv.canPlayType(r.type,t)},handleSource:function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},e=oe.mergeOptions(oe.options,t);return i.hls=new bS(r,i,e),i.hls.xhr=Nb(),i.hls.src(r.src,r.type),i.hls},canPlayType:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=oe.mergeOptions(oe.options,i),e=t.hls.overrideNative,a=yS(r),s=a&&(!tn.supportsTypeNatively(a)||e);return s?"maybe":""}};(typeof oe.MediaSource>"u"||typeof oe.URL>"u")&&(oe.MediaSource=yd,oe.URL=iS),yd.supportsNativeMediaSources()&&oe.getTech("Html5").registerSourceHandler(tv,0),oe.HlsHandler=bS,oe.HlsSourceHandler=tv,oe.Hls=tn,oe.use||oe.registerComponent("Hls",tn),oe.options.hls=oe.options.hls||{},oe.registerPlugin?oe.registerPlugin("reloadSourceOnError",vS):oe.plugin("reloadSourceOnError",vS);const LL=Object.freeze(Object.defineProperty({__proto__:null,default:oe},Symbol.toStringTag,{value:"Module"})),OL={name:"stream-engine-player",version:"0.0.24",description:"Stream engine player",type:"module",files:["dist","src","index.js","README.md","LICENSE","package.json","vite.config.js"],exports:{".":{import:"./dist/stream-engine-player.mjs",require:"./dist/stream-engine-player.js"},"./style":{import:"./dist/style.css",require:"./dist/style.css"},"./bundle":{import:"./dist/stream-engine-player-bundle.mjs",require:"./dist/stream-engine-player-bundle.js"}},main:"dist/stream-engine-player.js",author:"Dok Umansky",scripts:{dev:"vite serve",build:'concurrently "vite build --mode bundle" "vite build"',serve:"vite preview",start:"npm run dev",prebuild:"rm -rf dist","version:patch":"npm version patch",lint:"./node_modules/.bin/eslint src",format:'prettier "src/**/*.{ts,js,json,scss,css}" --write',watch:'concurrently "vite build --watch" "vite serve"',"build:watch":"vite build --watch"},dependencies:{angular:"~1.4.8","angular-cookies":"~1.4.8","font-awesome":"^4.7.0","hls.js":"^0.12.4","include-media":"^2.0.0",localforage:"^1.10.0","m3u8-parser":"^7.1.0","mixpanel-browser":"2.52.0","video.js":"7.6.6","videojs-youtube":"^2.6.1","videojs-ima":"1.7.5","videojs-contrib-ads":"6.6.5","videojs-mux":"4.19.0","infront-logger":"1.1.11"},devDependencies:{concurrently:"^8.2.1",eslint:"^8.24.0","eslint-config-prettier":"^8.5.0","eslint-plugin-angular":"^4.1.0","eslint-plugin-prettier":"^4.2.1",husky:"^8.0.1",hygen:"^6.2.11","lint-staged":"^13.0.3",prettier:"^2.7.1",sass:"^1.55.0",vite:"^3.2.7"},husky:{hooks:{"pre-commit":"lint-staged"}},"lint-staged":{"*.{ts,js,json,scss,css}":["prettier --write","git add"]}},s5="";/**
|
|
88
|
+
`.split("").map(function(n){return n.charCodeAt(0)})),iL=function(n){Qa(r,n);function r(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Rn(this,r);var e=ma(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,i,t));return e.mediaSource_=null,e.subtitlesTrack_=null,e}return qn(r,[{key:"buffered_",value:function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues.length)return oe.createTimeRanges();var t=this.subtitlesTrack_.cues,e=t[0].startTime,a=t[t.length-1].startTime;return oe.createTimeRanges([[e,a]])}},{key:"initSegment",value:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!t)return null;var a=df(t),s=this.initSegments_[a];if(e&&!s&&t.bytes){var o=fS.byteLength+t.bytes.byteLength,u=new Uint8Array(o);u.set(t.bytes),u.set(fS,t.bytes.byteLength),this.initSegments_[a]=s={resolvedUri:t.resolvedUri,byterange:t.byterange,bytes:u}}return s||t}},{key:"couldBeginLoading_",value:function(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}},{key:"init_",value:function(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}},{key:"track",value:function(t){return typeof t>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=t,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}},{key:"remove",value:function(t,e){Nu(t,e,this.subtitlesTrack_)}},{key:"fillBuffer_",value:function(){var t=this;this.syncPoint_||(this.syncPoint_=this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_()));var e=this.checkBuffer_(this.buffered_(),this.playlist_,this.mediaIndex,this.hasPlayed_(),this.currentTime_(),this.syncPoint_);if(e=this.skipEmptySegments_(e),!!e){if(this.syncController_.timestampOffsetForTimeline(e.timeline)===null){var a=function(){t.state="READY",t.paused()||t.monitorBuffer_()};this.syncController_.one("timestampoffset",a),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(e)}}},{key:"skipEmptySegments_",value:function(t){for(;t&&t.segment.empty;)t=this.generateSegmentInfo_(t.playlist,t.mediaIndex+1,t.startOfSegment+t.duration,t.isSyncRequest);return t}},{key:"handleSegment_",value:function(){var t=this;if(!this.pendingSegment_||!this.subtitlesTrack_){this.state="READY";return}this.state="APPENDING";var e=this.pendingSegment_,a=e.segment;if(typeof Pe.WebVTT!="function"&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var s=void 0,o=function(){t.subtitlesTrack_.tech_.off("vttjsloaded",s),t.error({message:"Error loading vtt.js"}),t.state="READY",t.pause(),t.trigger("error")};s=function(){t.subtitlesTrack_.tech_.off("vttjserror",o),t.handleSegment_()},this.state="WAITING_ON_VTTJS",this.subtitlesTrack_.tech_.one("vttjsloaded",s),this.subtitlesTrack_.tech_.one("vttjserror",o);return}a.requested=!0;try{this.parseVTTCues_(e)}catch(u){return this.error({message:u.message}),this.state="READY",this.pause(),this.trigger("error")}if(this.updateTimeMapping_(e,this.syncController_.timelines[e.timeline],this.playlist_),e.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}e.byteLength=e.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,e.cues.length&&this.remove(e.cues[0].endTime,e.cues[e.cues.length-1].endTime),e.cues.forEach(function(u){t.subtitlesTrack_.addCue(u)}),this.handleUpdateEnd_()}},{key:"parseVTTCues_",value:function(t){var e=void 0,a=!1;typeof Pe.TextDecoder=="function"?e=new Pe.TextDecoder("utf8"):(e=Pe.WebVTT.StringDecoder(),a=!0);var s=new Pe.WebVTT.Parser(Pe,Pe.vttjs,e);if(t.cues=[],t.timestampmap={MPEGTS:0,LOCAL:0},s.oncue=t.cues.push.bind(t.cues),s.ontimestampmap=function(l){return t.timestampmap=l},s.onparsingerror=function(l){oe.log.warn("Error encountered when parsing cues: "+l.message)},t.segment.map){var o=t.segment.map.bytes;a&&(o=cS(o)),s.parse(o)}var u=t.bytes;a&&(u=cS(u)),s.parse(u),s.flush()}},{key:"updateTimeMapping_",value:function(t,e,a){var s=t.segment;if(!!e){if(!t.cues.length){s.empty=!0;return}var o=t.timestampmap,u=o.MPEGTS/9e4-o.LOCAL+e.mapping;if(t.cues.forEach(function(d){d.startTime+=u,d.endTime+=u}),!a.syncInfo){var l=t.cues[0].startTime,c=t.cues[t.cues.length-1].startTime;a.syncInfo={mediaSequence:a.mediaSequence+t.mediaIndex,time:Math.min(l,c-s.duration)}}}}}]),r}(Zg),nL=function(r,i){for(var t=r.cues,e=0;e<t.length;e++){var a=t[e];if(i>=a.adStartTime&&i<=a.adEndTime)return a}return null},aL=function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!!r.segments)for(var e=t,a=void 0,s=0;s<r.segments.length;s++){var o=r.segments[s];if(a||(a=nL(i,e+o.duration/2)),a){if("cueIn"in o){a.endTime=e,a.adEndTime=e,e+=o.duration,a=null;continue}if(e<a.endTime){e+=o.duration;continue}a.endTime+=o.duration}else if("cueOut"in o&&(a=new Pe.VTTCue(e,e+o.duration,o.cueOut),a.adStartTime=e,a.adEndTime=e+parseFloat(o.cueOut),i.addCue(a)),"cueOutCont"in o){var u=void 0,l=void 0,c=o.cueOutCont.split("/").map(parseFloat),d=LR(c,2);u=d[0],l=d[1],a=new Pe.VTTCue(e,e+o.duration,""),a.adStartTime=e-u,a.adEndTime=a.adStartTime+l,i.addCue(a)}e+=o.duration}},sL=ZD.inspect,hS=[{name:"VOD",run:function(r,i,t,e,a){if(t!==1/0){var s={time:0,segmentIndex:0};return s}return null}},{name:"ProgramDateTime",run:function(r,i,t,e,a){if(!r.datetimeToDisplayTime)return null;var s=i.segments||[],o=null,u=null;a=a||0;for(var l=0;l<s.length;l++){var c=s[l];if(c.dateTimeObject){var d=c.dateTimeObject.getTime()/1e3,f=d+r.datetimeToDisplayTime,h=Math.abs(a-f);if(u!==null&&(h===0||u<h))break;u=h,o={time:f,segmentIndex:l}}}return o}},{name:"Segment",run:function(r,i,t,e,a){var s=i.segments||[],o=null,u=null;a=a||0;for(var l=0;l<s.length;l++){var c=s[l];if(c.timeline===e&&typeof c.start<"u"){var d=Math.abs(a-c.start);if(u!==null&&u<d)break;(!o||u===null||u>=d)&&(u=d,o={time:c.start,segmentIndex:l})}}return o}},{name:"Discontinuity",run:function(r,i,t,e,a){var s=null;if(a=a||0,i.discontinuityStarts&&i.discontinuityStarts.length)for(var o=null,u=0;u<i.discontinuityStarts.length;u++){var l=i.discontinuityStarts[u],c=i.discontinuitySequence+u+1,d=r.discontinuities[c];if(d){var f=Math.abs(a-d.time);if(o!==null&&o<f)break;(!s||o===null||o>=f)&&(o=f,s={time:d.time,segmentIndex:l})}}return s}},{name:"Playlist",run:function(r,i,t,e,a){if(i.syncInfo){var s={time:i.syncInfo.time,segmentIndex:i.syncInfo.mediaSequence-i.mediaSequence};return s}return null}}],oL=function(n){Qa(r,n);function r(){Rn(this,r);var i=ma(this,(r.__proto__||Object.getPrototypeOf(r)).call(this));return i.inspectCache_=void 0,i.timelines=[],i.discontinuities=[],i.datetimeToDisplayTime=null,i.logger_=_d("SyncController"),i}return qn(r,[{key:"getSyncPoint",value:function(t,e,a,s){var o=this.runStrategies_(t,e,a,s);return o.length?this.selectSyncPoint_(o,{key:"time",value:s}):null}},{key:"getExpiredTime",value:function(t,e){if(!t||!t.segments)return null;var a=this.runStrategies_(t,e,t.discontinuitySequence,0);if(!a.length)return null;var s=this.selectSyncPoint_(a,{key:"segmentIndex",value:0});return s.segmentIndex>0&&(s.time*=-1),Math.abs(s.time+vd(t,s.segmentIndex,0))}},{key:"runStrategies_",value:function(t,e,a,s){for(var o=[],u=0;u<hS.length;u++){var l=hS[u],c=l.run(this,t,e,a,s);c&&(c.strategy=l.name,o.push({strategy:l.name,syncPoint:c}))}return o}},{key:"selectSyncPoint_",value:function(t,e){for(var a=t[0].syncPoint,s=Math.abs(t[0].syncPoint[e.key]-e.value),o=t[0].strategy,u=1;u<t.length;u++){var l=Math.abs(t[u].syncPoint[e.key]-e.value);l<s&&(s=l,a=t[u].syncPoint,o=t[u].strategy)}return this.logger_("syncPoint for ["+e.key+": "+e.value+"] chosen with strategy"+(" ["+o+"]: [time:"+a.time+",")+(" segmentIndex:"+a.segmentIndex+"]")),a}},{key:"saveExpiredSegmentInfo",value:function(t,e){for(var a=e.mediaSequence-t.mediaSequence,s=a-1;s>=0;s--){var o=t.segments[s];if(o&&typeof o.start<"u"){e.syncInfo={mediaSequence:t.mediaSequence+s,time:o.start},this.logger_("playlist refresh sync: [time:"+e.syncInfo.time+","+(" mediaSequence: "+e.syncInfo.mediaSequence+"]")),this.trigger("syncinfoupdate");break}}}},{key:"setDateTimeMapping",value:function(t){if(!this.datetimeToDisplayTime&&t.segments&&t.segments.length&&t.segments[0].dateTimeObject){var e=t.segments[0].dateTimeObject.getTime()/1e3;this.datetimeToDisplayTime=-e}}},{key:"reset",value:function(){this.inspectCache_=void 0}},{key:"probeSegmentInfo",value:function(t){var e=t.segment,a=t.playlist,s=void 0;return e.map?s=this.probeMp4Segment_(t):s=this.probeTsSegment_(t),s&&this.calculateSegmentTimeMapping_(t,s)&&(this.saveDiscontinuitySyncInfo_(t),a.syncInfo||(a.syncInfo={mediaSequence:a.mediaSequence+t.mediaIndex,time:e.start})),s}},{key:"probeMp4Segment_",value:function(t){var e=t.segment,a=kc.timescale(e.map.bytes),s=kc.startTime(a,t.bytes);return t.timestampOffset!==null&&(t.timestampOffset-=s),{start:s,end:s+e.duration}}},{key:"probeTsSegment_",value:function(t){var e=sL(t.bytes,this.inspectCache_),a=void 0,s=void 0,o=void 0;if(!e)return null;e.video&&e.video.length===2?(this.inspectCache_=e.video[1].dts,a=e.video[0].dtsTime,s=e.video[1].dtsTime,o=e.video):e.audio&&e.audio.length===2&&(this.inspectCache_=e.audio[1].dts,a=e.audio[0].dtsTime,s=e.audio[1].dtsTime,o=e.audio);var u={segmentTimestampInfo:o,start:a,end:s,containsVideo:e.video&&e.video.length===2,containsAudio:e.audio&&e.audio.length===2};return u}},{key:"timestampOffsetForTimeline",value:function(t){return typeof this.timelines[t]>"u"?null:this.timelines[t].time}},{key:"mappingForTimeline",value:function(t){return typeof this.timelines[t]>"u"?null:this.timelines[t].mapping}},{key:"calculateSegmentTimeMapping_",value:function(t,e){var a=t.segment,s=this.timelines[t.timeline];if(t.timestampOffset!==null)s={time:t.startOfSegment,mapping:t.startOfSegment-e.start},this.timelines[t.timeline]=s,this.trigger("timestampoffset"),this.logger_("time mapping for timeline "+t.timeline+": "+("[time: "+s.time+"] [mapping: "+s.mapping+"]")),a.start=t.startOfSegment,a.end=e.end+s.mapping;else if(s)a.start=e.start+s.mapping,a.end=e.end+s.mapping;else return!1;return!0}},{key:"saveDiscontinuitySyncInfo_",value:function(t){var e=t.playlist,a=t.segment;if(a.discontinuity)this.discontinuities[a.timeline]={time:a.start,accuracy:0};else if(e.discontinuityStarts&&e.discontinuityStarts.length)for(var s=0;s<e.discontinuityStarts.length;s++){var o=e.discontinuityStarts[s],u=e.discontinuitySequence+s+1,l=o-t.mediaIndex,c=Math.abs(l);if(!this.discontinuities[u]||this.discontinuities[u].accuracy>c){var d=void 0;l<0?d=a.start-vd(e,t.mediaIndex,o):d=a.end+vd(e,t.mediaIndex+1,o),this.discontinuities[u]={time:d,accuracy:c}}}}}]),r}(oe.EventTarget),uL=new Kb("./decrypter-worker.worker.js",function(n,r){var i=this;(function(){function t(T){return T.subarray(0,T.byteLength-T[T.byteLength-1])}var e=function(b,S){if(!(b instanceof S))throw new TypeError("Cannot call a class as a function")},a=function(){function T(b,S){for(var A=0;A<S.length;A++){var E=S[A];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(b,E.key,E)}}return function(b,S,A){return S&&T(b.prototype,S),A&&T(b,A),b}}(),s=function(b,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof S);b.prototype=Object.create(S&&S.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}}),S&&(Object.setPrototypeOf?Object.setPrototypeOf(b,S):b.__proto__=S)},o=function(b,S){if(!b)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return S&&(typeof S=="object"||typeof S=="function")?S:b},u=function(){var b=[[[],[],[],[],[]],[[],[],[],[],[]]],S=b[0],A=b[1],E=S[4],x=A[4],C=void 0,w=void 0,k=void 0,D=[],L=[],N=void 0,P=void 0,I=void 0,O=void 0,U=void 0,q=void 0;for(C=0;C<256;C++)L[(D[C]=C<<1^(C>>7)*283)^C]=C;for(w=k=0;!E[w];w^=N||1,k=L[k]||1)for(O=k^k<<1^k<<2^k<<3^k<<4,O=O>>8^O&255^99,E[w]=O,x[O]=w,I=D[P=D[N=D[w]]],q=I*16843009^P*65537^N*257^w*16843008,U=D[O]*257^O*16843008,C=0;C<4;C++)S[C][w]=U=U<<24^U>>>8,A[C][O]=q=q<<24^q>>>8;for(C=0;C<5;C++)S[C]=S[C].slice(0),A[C]=A[C].slice(0);return b},l=null,c=function(){function T(b){e(this,T),l||(l=u()),this._tables=[[l[0][0].slice(),l[0][1].slice(),l[0][2].slice(),l[0][3].slice(),l[0][4].slice()],[l[1][0].slice(),l[1][1].slice(),l[1][2].slice(),l[1][3].slice(),l[1][4].slice()]];var S=void 0,A=void 0,E=void 0,x=void 0,C=void 0,w=this._tables[0][4],k=this._tables[1],D=b.length,L=1;if(D!==4&&D!==6&&D!==8)throw new Error("Invalid aes key size");for(x=b.slice(0),C=[],this._key=[x,C],S=D;S<4*D+28;S++)E=x[S-1],(S%D===0||D===8&&S%D===4)&&(E=w[E>>>24]<<24^w[E>>16&255]<<16^w[E>>8&255]<<8^w[E&255],S%D===0&&(E=E<<8^E>>>24^L<<24,L=L<<1^(L>>7)*283)),x[S]=x[S-D]^E;for(A=0;S;A++,S--)E=x[A&3?S:S-4],S<=4||A<4?C[A]=E:C[A]=k[0][w[E>>>24]]^k[1][w[E>>16&255]]^k[2][w[E>>8&255]]^k[3][w[E&255]]}return T.prototype.decrypt=function(S,A,E,x,C,w){var k=this._key[1],D=S^k[0],L=x^k[1],N=E^k[2],P=A^k[3],I=void 0,O=void 0,U=void 0,q=k.length/4-2,K=void 0,X=4,te=this._tables[1],J=te[0],fe=te[1],ge=te[2],Ie=te[3],qe=te[4];for(K=0;K<q;K++)I=J[D>>>24]^fe[L>>16&255]^ge[N>>8&255]^Ie[P&255]^k[X],O=J[L>>>24]^fe[N>>16&255]^ge[P>>8&255]^Ie[D&255]^k[X+1],U=J[N>>>24]^fe[P>>16&255]^ge[D>>8&255]^Ie[L&255]^k[X+2],P=J[P>>>24]^fe[D>>16&255]^ge[L>>8&255]^Ie[N&255]^k[X+3],X+=4,D=I,L=O,N=U;for(K=0;K<4;K++)C[(3&-K)+w]=qe[D>>>24]<<24^qe[L>>16&255]<<16^qe[N>>8&255]<<8^qe[P&255]^k[X++],I=D,D=L,L=N,N=P,P=I},T}(),d=function(){function T(){e(this,T),this.listeners={}}return T.prototype.on=function(S,A){this.listeners[S]||(this.listeners[S]=[]),this.listeners[S].push(A)},T.prototype.off=function(S,A){if(!this.listeners[S])return!1;var E=this.listeners[S].indexOf(A);return this.listeners[S].splice(E,1),E>-1},T.prototype.trigger=function(S){var A=this.listeners[S];if(!!A)if(arguments.length===2)for(var E=A.length,x=0;x<E;++x)A[x].call(this,arguments[1]);else for(var C=Array.prototype.slice.call(arguments,1),w=A.length,k=0;k<w;++k)A[k].apply(this,C)},T.prototype.dispose=function(){this.listeners={}},T.prototype.pipe=function(S){this.on("data",function(A){S.push(A)})},T}(),f=function(T){s(b,T);function b(){e(this,b);var S=o(this,T.call(this,d));return S.jobs=[],S.delay=1,S.timeout_=null,S}return b.prototype.processJob_=function(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null},b.prototype.push=function(A){this.jobs.push(A),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))},b}(d),h=function(b){return b<<24|(b&65280)<<8|(b&16711680)>>8|b>>>24},g=function(b,S,A){var E=new Int32Array(b.buffer,b.byteOffset,b.byteLength>>2),x=new c(Array.prototype.slice.call(S)),C=new Uint8Array(b.byteLength),w=new Int32Array(C.buffer),k=void 0,D=void 0,L=void 0,N=void 0,P=void 0,I=void 0,O=void 0,U=void 0,q=void 0;for(k=A[0],D=A[1],L=A[2],N=A[3],q=0;q<E.length;q+=4)P=h(E[q]),I=h(E[q+1]),O=h(E[q+2]),U=h(E[q+3]),x.decrypt(P,I,O,U,w,q),w[q]=h(w[q]^k),w[q+1]=h(w[q+1]^D),w[q+2]=h(w[q+2]^L),w[q+3]=h(w[q+3]^N),k=P,D=I,L=O,N=U;return C},p=function(){function T(b,S,A,E){e(this,T);var x=T.STEP,C=new Int32Array(b.buffer),w=new Uint8Array(b.byteLength),k=0;for(this.asyncStream_=new f,this.asyncStream_.push(this.decryptChunk_(C.subarray(k,k+x),S,A,w)),k=x;k<C.length;k+=x)A=new Uint32Array([h(C[k-4]),h(C[k-3]),h(C[k-2]),h(C[k-1])]),this.asyncStream_.push(this.decryptChunk_(C.subarray(k,k+x),S,A,w));this.asyncStream_.push(function(){E(null,t(w))})}return T.prototype.decryptChunk_=function(S,A,E,x){return function(){var C=g(S,A,E);x.set(C,S.byteOffset)}},a(T,null,[{key:"STEP",get:function(){return 32e3}}]),T}(),v=function(b){var S={};return Object.keys(b).forEach(function(A){var E=b[A];ArrayBuffer.isView(E)?S[A]={bytes:E.buffer,byteOffset:E.byteOffset,byteLength:E.byteLength}:S[A]=E}),S},y=function(b){b.onmessage=function(S){var A=S.data,E=new Uint8Array(A.encrypted.bytes,A.encrypted.byteOffset,A.encrypted.byteLength),x=new Uint32Array(A.key.bytes,A.key.byteOffset,A.key.byteLength/4),C=new Uint32Array(A.iv.bytes,A.iv.byteOffset,A.iv.byteLength/4);new p(E,x,C,function(w,k){b.postMessage(v({source:A.source,decrypted:k}),[k.buffer])})}},m=new y(i);return m})()}),lL=function(r){var i=r.default?"main":"alternative";return r.characteristics&&r.characteristics.indexOf("public.accessibility.describes-video")>=0&&(i="main-desc"),i},hf=function(r,i){r.abort(),r.pause(),i&&i.activePlaylistLoader&&(i.activePlaylistLoader.pause(),i.activePlaylistLoader=null)},ev=function(r,i){i.activePlaylistLoader=r,r.load()},dL=function(r,i){return function(){var t=i.segmentLoaders,e=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),u=s.activeGroup(o),l=s.activePlaylistLoader;if(hf(e,s),!!u){if(!u.playlistLoader){l&&a.resetEverything();return}e.resyncLoader(),ev(u.playlistLoader,s)}}},cL=function(r,i){return function(){var t=i.segmentLoaders,e=t[r],a=t.main,s=i.mediaTypes[r],o=s.activeTrack(),u=s.activeGroup(o),l=s.activePlaylistLoader;if(hf(e,s),!!u){if(!u.playlistLoader){a.resetEverything();return}if(l===u.playlistLoader){ev(u.playlistLoader,s);return}e.track&&e.track(o),e.resetEverything(),ev(u.playlistLoader,s)}}},pf={AUDIO:function(r,i){return function(){var t=i.segmentLoaders[r],e=i.mediaTypes[r],a=i.blacklistCurrentPlaylist;hf(t,e);var s=e.activeTrack(),o=e.activeGroup(),u=(o.filter(function(d){return d.default})[0]||o[0]).id,l=e.tracks[u];if(s===l){a({message:"Problem encountered loading the default audio track."});return}oe.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(var c in e.tracks)e.tracks[c].enabled=e.tracks[c]===l;e.onTrackChanged()}},SUBTITLES:function(r,i){return function(){var t=i.segmentLoaders[r],e=i.mediaTypes[r];oe.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track."),hf(t,e);var a=e.activeTrack();a&&(a.mode="disabled"),e.onTrackChanged()}}},pS={AUDIO:function(r,i,t){if(!!i){var e=t.tech,a=t.requestOptions,s=t.segmentLoaders[r];i.on("loadedmetadata",function(){var o=i.media();s.playlist(o,a),(!e.paused()||o.endList&&e.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),e.paused()||s.load()}),i.on("error",pf[r](r,t))}},SUBTITLES:function(r,i,t){var e=t.tech,a=t.requestOptions,s=t.segmentLoaders[r],o=t.mediaTypes[r];i.on("loadedmetadata",function(){var u=i.media();s.playlist(u,a),s.track(o.activeTrack()),(!e.paused()||u.endList&&e.preload()!=="none")&&s.load()}),i.on("loadedplaylist",function(){s.playlist(i.media(),a),e.paused()||s.load()}),i.on("error",pf[r](r,t))}},fL={AUDIO:function(r,i){var t=i.hls,e=i.sourceType,a=i.segmentLoaders[r],s=i.requestOptions,o=i.master.mediaGroups,u=i.mediaTypes[r],l=u.groups,c=u.tracks,d=i.masterPlaylistLoader;(!o[r]||Object.keys(o[r]).length===0)&&(o[r]={main:{default:{default:!0}}});for(var f in o[r]){l[f]||(l[f]=[]);for(var h in o[r][f]){var g=o[r][f][h],p=void 0;if(g.resolvedUri?p=new uf(g.resolvedUri,t,s):g.playlists&&e==="dash"?p=new Yg(g.playlists[0],t,s,d):p=null,g=oe.mergeOptions({id:h,playlistLoader:p},g),pS[r](r,g.playlistLoader,i),l[f].push(g),typeof c[h]>"u"){var v=new oe.AudioTrack({id:h,kind:lL(g),enabled:!1,language:g.language,default:g.default,label:h});c[h]=v}}}a.on("error",pf[r](r,i))},SUBTITLES:function(r,i){var t=i.tech,e=i.hls,a=i.sourceType,s=i.segmentLoaders[r],o=i.requestOptions,u=i.master.mediaGroups,l=i.mediaTypes[r],c=l.groups,d=l.tracks,f=i.masterPlaylistLoader;for(var h in u[r]){c[h]||(c[h]=[]);for(var g in u[r][h])if(!u[r][h][g].forced){var p=u[r][h][g],v=void 0;if(a==="hls"?v=new uf(p.resolvedUri,e,o):a==="dash"&&(v=new Yg(p.playlists[0],e,o,f)),p=oe.mergeOptions({id:g,playlistLoader:v},p),pS[r](r,p.playlistLoader,i),c[h].push(p),typeof d[g]>"u"){var y=t.addRemoteTextTrack({id:g,kind:"subtitles",default:p.default&&p.autoselect,language:p.language,label:g},!1).track;d[g]=y}}}s.on("error",pf[r](r,i))},"CLOSED-CAPTIONS":function(r,i){var t=i.tech,e=i.master.mediaGroups,a=i.mediaTypes[r],s=a.groups,o=a.tracks;for(var u in e[r]){s[u]||(s[u]=[]);for(var l in e[r][u]){var c=e[r][u][l];if(!!c.instreamId.match(/CC\d/)&&(s[u].push(oe.mergeOptions({id:l},c)),typeof o[l]>"u")){var d=t.addRemoteTextTrack({id:c.instreamId,kind:"captions",default:c.default&&c.autoselect,language:c.language,label:l},!1).track;o[l]=d}}}}},hL=function(r,i){return function(t){var e=i.masterPlaylistLoader,a=i.mediaTypes[r].groups,s=e.media();if(!s)return null;var o=null;return s.attributes[r]&&(o=a[s.attributes[r]]),o=o||a.main,typeof t>"u"?o:t===null?null:o.filter(function(u){return u.id===t.id})[0]||null}},pL={AUDIO:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var e in t)if(t[e].enabled)return t[e];return null}},SUBTITLES:function(r,i){return function(){var t=i.mediaTypes[r].tracks;for(var e in t)if(t[e].mode==="showing")return t[e];return null}}},gL=function(r){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(c){fL[c](c,r)});var i=r.mediaTypes,t=r.masterPlaylistLoader,e=r.tech,a=r.hls;["AUDIO","SUBTITLES"].forEach(function(c){i[c].activeGroup=hL(c,r),i[c].activeTrack=pL[c](c,r),i[c].onGroupChanged=dL(c,r),i[c].onTrackChanged=cL(c,r)});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(),t.on("mediachange",function(){["AUDIO","SUBTITLES"].forEach(function(c){return i[c].onGroupChanged()})});var u=function(){i.AUDIO.onTrackChanged(),e.trigger({type:"usage",name:"hls-audio-change"})};e.audioTracks().addEventListener("change",u),e.remoteTextTracks().addEventListener("change",i.SUBTITLES.onTrackChanged),a.on("dispose",function(){e.audioTracks().removeEventListener("change",u),e.remoteTextTracks().removeEventListener("change",i.SUBTITLES.onTrackChanged)}),e.clearTracks("audio");for(var l in i.AUDIO.tracks)e.audioTracks().addTrack(i.AUDIO.tracks[l])},vL=function(){var r={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(function(i){r[i]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Hu,activeTrack:Hu,onGroupChanged:Hu,onTrackChanged:Hu}}),r},mL=60*2,Ms=void 0,yL=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred"],_L=function(r){return this.audioSegmentLoader_[r]+this.mainSegmentLoader_[r]},TL=function(n){Qa(r,n);function r(i){Rn(this,r);var t=ma(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),e=i.url,a=i.handleManifestRedirects,s=i.withCredentials,o=i.tech,u=i.bandwidth,l=i.externHls,c=i.useCueTags,d=i.blacklistDuration,f=i.enableLowInitialPlaylist,h=i.sourceType,g=i.seekTo,p=i.cacheEncryptionKeys;if(!e)throw new Error("A non-empty playlist URL is required");Ms=l,t.withCredentials=s,t.tech_=o,t.hls_=o.hls,t.seekTo_=g,t.sourceType_=h,t.useCueTags_=c,t.blacklistDuration=d,t.enableLowInitialPlaylist=f,t.useCueTags_&&(t.cueTagsTrack_=t.tech_.addTextTrack("metadata","ad-cues"),t.cueTagsTrack_.inBandMetadataTrackDispatchType=""),t.requestOptions_={withCredentials:s,handleManifestRedirects:a,timeout:null},t.mediaTypes_=vL(),t.mediaSource=new oe.MediaSource,t.mediaSource.addEventListener("sourceopen",t.handleSourceOpen_.bind(t)),t.seekable_=oe.createTimeRanges(),t.hasPlayed_=function(){return!1},t.syncController_=new oL(i),t.segmentMetadataTrack_=o.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,t.decrypter_=new uL,t.inbandTextTracks_={};var v={hls:t.hls_,mediaSource:t.mediaSource,currentTime:t.tech_.currentTime.bind(t.tech_),seekable:function(){return t.seekable()},seeking:function(){return t.tech_.seeking()},duration:function(){return t.mediaSource.duration},hasPlayed:function(){return t.hasPlayed_()},goalBufferLength:function(){return t.goalBufferLength()},bandwidth:u,syncController:t.syncController_,decrypter:t.decrypter_,sourceType:t.sourceType_,inbandTextTracks:t.inbandTextTracks_,cacheEncryptionKeys:p};return t.masterPlaylistLoader_=t.sourceType_==="dash"?new Yg(e,t.hls_,t.requestOptions_):new uf(e,t.hls_,t.requestOptions_),t.setupMasterPlaylistLoaderListeners_(),t.mainSegmentLoader_=new Zg(oe.mergeOptions(v,{segmentMetadataTrack:t.segmentMetadataTrack_,loaderType:"main"}),i),t.audioSegmentLoader_=new Zg(oe.mergeOptions(v,{loaderType:"audio"}),i),t.subtitleSegmentLoader_=new iL(oe.mergeOptions(v,{loaderType:"vtt"}),i),t.setupSegmentLoaderListeners_(),yL.forEach(function(y){t[y+"_"]=_L.bind(t,y)}),t.logger_=_d("MPC"),t.masterPlaylistLoader_.load(),t}return qn(r,[{key:"setupMasterPlaylistLoaderListeners_",value:function(){var t=this;this.masterPlaylistLoader_.on("loadedmetadata",function(){var e=t.masterPlaylistLoader_.media(),a=e.targetDuration*1.5*1e3;Gg(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,e.endList&&t.tech_.preload()!=="none"&&(t.mainSegmentLoader_.playlist(e,t.requestOptions_),t.mainSegmentLoader_.load()),gL({sourceType:t.sourceType_,segmentLoaders:{AUDIO:t.audioSegmentLoader_,SUBTITLES:t.subtitleSegmentLoader_,main:t.mainSegmentLoader_},tech:t.tech_,requestOptions:t.requestOptions_,masterPlaylistLoader:t.masterPlaylistLoader_,hls:t.hls_,master:t.master(),mediaTypes:t.mediaTypes_,blacklistCurrentPlaylist:t.blacklistCurrentPlaylist.bind(t)}),t.triggerPresenceUsage_(t.master(),e);try{t.setupSourceBuffers_()}catch(s){return oe.log.warn("Failed to create SourceBuffers",s),t.mediaSource.endOfStream("decode")}t.setupFirstPlay(),!t.mediaTypes_.AUDIO.activePlaylistLoader||t.mediaTypes_.AUDIO.activePlaylistLoader.media()?t.trigger("selectedinitialmedia"):t.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",function(){t.trigger("selectedinitialmedia")})}),this.masterPlaylistLoader_.on("loadedplaylist",function(){var e=t.masterPlaylistLoader_.media();if(!e){t.excludeUnsupportedVariants_();var a=void 0;t.enableLowInitialPlaylist&&(a=t.selectInitialPlaylist()),a||(a=t.selectPlaylist()),t.initialMedia_=a,t.masterPlaylistLoader_.media(t.initialMedia_);return}if(t.useCueTags_&&t.updateAdCues_(e),t.mainSegmentLoader_.playlist(e,t.requestOptions_),t.updateDuration(),t.tech_.paused()||(t.mainSegmentLoader_.load(),t.audioSegmentLoader_&&t.audioSegmentLoader_.load()),!e.endList){var s=function(){var l=t.seekable();l.length!==0&&t.mediaSource.addSeekableRange_(l.start(0),l.end(0))};if(t.duration()!==1/0){var o=function u(){t.duration()===1/0?s():t.tech_.one("durationchange",u)};t.tech_.one("durationchange",o)}else s()}}),this.masterPlaylistLoader_.on("error",function(){t.blacklistCurrentPlaylist(t.masterPlaylistLoader_.error)}),this.masterPlaylistLoader_.on("mediachanging",function(){t.mainSegmentLoader_.abort(),t.mainSegmentLoader_.pause()}),this.masterPlaylistLoader_.on("mediachange",function(){var e=t.masterPlaylistLoader_.media(),a=e.targetDuration*1.5*1e3;Gg(t.masterPlaylistLoader_.master,t.masterPlaylistLoader_.media())?t.requestOptions_.timeout=0:t.requestOptions_.timeout=a,t.mainSegmentLoader_.playlist(e,t.requestOptions_),t.mainSegmentLoader_.load(),t.tech_.trigger({type:"mediachange",bubbles:!0})}),this.masterPlaylistLoader_.on("playlistunchanged",function(){var e=t.masterPlaylistLoader_.media(),a=t.stuckAtPlaylistEnd_(e);a&&(t.blacklistCurrentPlaylist({message:"Playlist no longer updating."}),t.tech_.trigger("playliststuck"))}),this.masterPlaylistLoader_.on("renditiondisabled",function(){t.tech_.trigger({type:"usage",name:"hls-rendition-disabled"})}),this.masterPlaylistLoader_.on("renditionenabled",function(){t.tech_.trigger({type:"usage",name:"hls-rendition-enabled"})})}},{key:"triggerPresenceUsage_",value:function(t,e){var a=t.mediaGroups||{},s=!0,o=Object.keys(a.AUDIO);for(var u in a.AUDIO)for(var l in a.AUDIO[u]){var c=a.AUDIO[u][l];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"}),Ms.Playlist.isAes(e)&&this.tech_.trigger({type:"usage",name:"hls-aes"}),Ms.Playlist.isFmp4(e)&&this.tech_.trigger({type:"usage",name:"hls-fmp4"}),o.length&&Object.keys(a.AUDIO[o[0]]).length>1&&this.tech_.trigger({type:"usage",name:"hls-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"hls-playlist-cue-tags"})}},{key:"setupSegmentLoaderListeners_",value:function(){var t=this;this.mainSegmentLoader_.on("bandwidthupdate",function(){var e=t.selectPlaylist(),a=t.masterPlaylistLoader_.media(),s=t.tech_.buffered(),o=s.length?s.end(s.length-1)-t.tech_.currentTime():0,u=t.bufferLowWaterLine();(!a.endList||t.duration()<pn.MAX_BUFFER_LOW_WATER_LINE||e.attributes.BANDWIDTH<a.attributes.BANDWIDTH||o>=u)&&t.masterPlaylistLoader_.media(e),t.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("progress",function(){t.trigger("progress")}),this.mainSegmentLoader_.on("error",function(){t.blacklistCurrentPlaylist(t.mainSegmentLoader_.error())}),this.mainSegmentLoader_.on("syncinfoupdate",function(){t.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",function(){t.tech_.trigger({type:"usage",name:"hls-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",function(){t.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("ended",function(){t.onEndOfStream()}),this.mainSegmentLoader_.on("earlyabort",function(){t.blacklistCurrentPlaylist({message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},mL)}),this.mainSegmentLoader_.on("reseteverything",function(){t.tech_.trigger("hls-reset")}),this.mainSegmentLoader_.on("segmenttimemapping",function(e){t.tech_.trigger({type:"hls-segment-time-mapping",mapping:e.mapping})}),this.audioSegmentLoader_.on("ended",function(){t.onEndOfStream()})}},{key:"mediaSecondsLoaded_",value:function(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}},{key:"load",value:function(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}},{key:"smoothQualityChange_",value:function(){var t=this.selectPlaylist();t!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(t),this.mainSegmentLoader_.resetLoader())}},{key:"fastQualityChange_",value:function(){var t=this,e=this.selectPlaylist();e!==this.masterPlaylistLoader_.media()&&(this.masterPlaylistLoader_.media(e),this.mainSegmentLoader_.resetEverything(function(){oe.browser.IE_VERSION||oe.browser.IS_EDGE?t.tech_.setCurrentTime(t.tech_.currentTime()+.04):t.tech_.setCurrentTime(t.tech_.currentTime())}))}},{key:"play",value:function(){if(!this.setupFirstPlay()){this.tech_.ended()&&this.seekTo_(0),this.hasPlayed_()&&this.load();var t=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<t.start(0))return this.seekTo_(t.end(t.length-1))}}},{key:"setupFirstPlay",value:function(){var t=this,e=this.masterPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_())return!1;if(!e.endList){var a=this.seekable();if(!a.length)return!1;if(oe.browser.IE_VERSION&&this.tech_.readyState()===0)return this.tech_.one("loadedmetadata",function(){t.trigger("firstplay"),t.seekTo_(a.end(0)),t.hasPlayed_=function(){return!0}}),!1;this.trigger("firstplay"),this.seekTo_(a.end(0))}return this.hasPlayed_=function(){return!0},this.load(),!0}},{key:"handleSourceOpen_",value:function(){try{this.setupSourceBuffers_()}catch(e){return oe.log.warn("Failed to create Source Buffers",e),this.mediaSource.endOfStream("decode")}if(this.tech_.autoplay()){var t=this.tech_.play();typeof t<"u"&&typeof t.then=="function"&&t.then(null,function(e){})}this.trigger("sourceopen")}},{key:"onEndOfStream",value:function(){var t=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(!this.mainSegmentLoader_.startingMedia_||this.mainSegmentLoader_.startingMedia_.containsVideo?t=t&&this.audioSegmentLoader_.ended_:t=this.audioSegmentLoader_.ended_),!!t){this.logger_("calling mediaSource.endOfStream()");try{this.mediaSource.endOfStream()}catch(e){oe.log.warn("Failed to call media source endOfStream",e)}}}},{key:"stuckAtPlaylistEnd_",value:function(t){var e=this.seekable();if(!e.length)return!1;var a=this.syncController_.getExpiredTime(t,this.mediaSource.duration);if(a===null)return!1;var s=Ms.Playlist.playlistEnd(t,a),o=this.tech_.currentTime(),u=this.tech_.buffered();if(!u.length)return s-o<=Ja;var l=u.end(u.length-1);return l-o<=Ja&&s-l<=Ja}},{key:"blacklistCurrentPlaylist",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments[1],a=void 0,s=void 0;if(a=t.playlist||this.masterPlaylistLoader_.media(),e=e||t.blacklistDuration||this.blacklistDuration,!a){this.error=t;try{return this.mediaSource.endOfStream("network")}catch{return this.trigger("error")}}var o=this.masterPlaylistLoader_.master.playlists.filter(lf).length===1,u=this.masterPlaylistLoader_.master.playlists;return u.length===1?(oe.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&&(oe.log.warn("Removing all playlists from the blacklist because the last rendition is about to be blacklisted."),u.forEach(function(l){l.excludeUntil!==1/0&&delete l.excludeUntil}),this.tech_.trigger("retryplaylist")),a.excludeUntil=Date.now()+e*1e3,this.tech_.trigger("blacklistplaylist"),this.tech_.trigger({type:"usage",name:"hls-rendition-blacklisted"}),s=this.selectPlaylist(),oe.log.warn("Problem encountered with the current HLS playlist."+(t.message?" "+t.message:"")+" Switching to another playlist."),this.masterPlaylistLoader_.media(s,o))}},{key:"pauseLoading",value:function(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}},{key:"setCurrentTime",value:function(t){var e=Vb(this.tech_.buffered(),t);if(!(this.masterPlaylistLoader_&&this.masterPlaylistLoader_.media())||!this.masterPlaylistLoader_.media().segments)return 0;if(e&&e.length)return t;this.mainSegmentLoader_.resetEverything(),this.mainSegmentLoader_.abort(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.resetEverything(),this.audioSegmentLoader_.abort()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.resetEverything(),this.subtitleSegmentLoader_.abort()),this.load()}},{key:"duration",value:function(){return this.masterPlaylistLoader_?this.mediaSource?this.mediaSource.duration:Ms.Playlist.duration(this.masterPlaylistLoader_.media()):0}},{key:"seekable",value:function(){return this.seekable_}},{key:"onSyncInfoUpdate_",value:function(){var t=void 0,e=void 0;if(!!this.masterPlaylistLoader_){var a=this.masterPlaylistLoader_.media();if(!!a){var s=this.syncController_.getExpiredTime(a,this.mediaSource.duration);if(s!==null&&(t=Ms.Playlist.seekable(a,s),t.length!==0&&!(this.mediaTypes_.AUDIO.activePlaylistLoader&&(a=this.mediaTypes_.AUDIO.activePlaylistLoader.media(),s=this.syncController_.getExpiredTime(a,this.mediaSource.duration),s===null||(e=Ms.Playlist.seekable(a,s),e.length===0))))){var o=void 0,u=void 0;this.seekable_&&this.seekable_.length&&(o=this.seekable_.end(0),u=this.seekable_.start(0)),e?e.start(0)>t.end(0)||t.start(0)>e.end(0)?this.seekable_=t:this.seekable_=oe.createTimeRanges([[e.start(0)>t.start(0)?e.start(0):t.start(0),e.end(0)<t.end(0)?e.end(0):t.end(0)]]):this.seekable_=t,!(this.seekable_&&this.seekable_.length&&this.seekable_.end(0)===o&&this.seekable_.start(0)===u)&&(this.logger_("seekable updated ["+qg(this.seekable_)+"]"),this.tech_.trigger("seekablechanged"))}}}}},{key:"updateDuration",value:function(){var t=this,e=this.mediaSource.duration,a=Ms.Playlist.duration(this.masterPlaylistLoader_.media()),s=this.tech_.buffered(),o=function u(){t.logger_("Setting duration from "+t.mediaSource.duration+" => "+a);try{t.mediaSource.duration=a}catch(l){oe.log.warn("Failed to set media source duration",l)}t.tech_.trigger("durationchange"),t.mediaSource.removeEventListener("sourceopen",u)};s.length>0&&(a=Math.max(a,s.end(s.length-1))),e!==a&&(this.mediaSource.readyState!=="open"?this.mediaSource.addEventListener("sourceopen",o):o())}},{key:"dispose",value:function(){var t=this;this.decrypter_.terminate(),this.masterPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),["AUDIO","SUBTITLES"].forEach(function(e){var a=t.mediaTypes_[e].groups;for(var s in a)a[s].forEach(function(o){o.playlistLoader&&o.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose()}},{key:"master",value:function(){return this.masterPlaylistLoader_.master}},{key:"media",value:function(){return this.masterPlaylistLoader_.media()||this.initialMedia_}},{key:"setupSourceBuffers_",value:function(){var t=this.masterPlaylistLoader_.media(),e=void 0;if(!(!t||this.mediaSource.readyState!=="open")){if(e=xI(this.masterPlaylistLoader_.master,t),e.length<1)return this.error="No compatible SourceBuffer configuration for the variant stream:"+t.resolvedUri,this.mediaSource.endOfStream("decode");this.configureLoaderMimeTypes_(e),this.excludeIncompatibleVariants_(t)}}},{key:"configureLoaderMimeTypes_",value:function(t){var e=t.length>1&&t[0].indexOf(",")===-1&&t[0]!==t[1]?new oe.EventTarget:null;this.mainSegmentLoader_.mimeType(t[0],e),t[1]&&this.audioSegmentLoader_.mimeType(t[1],e)}},{key:"excludeUnsupportedVariants_",value:function(){this.master().playlists.forEach(function(t){t.attributes.CODECS&&Pe.MediaSource&&Pe.MediaSource.isTypeSupported&&!Pe.MediaSource.isTypeSupported('video/mp4; codecs="'+TI(t.attributes.CODECS)+'"')&&(t.excludeUntil=1/0)})}},{key:"excludeIncompatibleVariants_",value:function(t){var e=2,a=null,s=void 0;t.attributes.CODECS&&(s=md(t.attributes.CODECS),a=s.videoCodec,e=s.codecCount),this.master().playlists.forEach(function(o){var u={codecCount:2,videoCodec:null};o.attributes.CODECS&&(u=md(o.attributes.CODECS)),u.codecCount!==e&&(o.excludeUntil=1/0),u.videoCodec!==a&&(o.excludeUntil=1/0)})}},{key:"updateAdCues_",value:function(t){var e=0,a=this.seekable();a.length&&(e=a.start(0)),aL(t,this.cueTagsTrack_,e)}},{key:"goalBufferLength",value:function(){var t=this.tech_.currentTime(),e=pn.GOAL_BUFFER_LENGTH,a=pn.GOAL_BUFFER_LENGTH_RATE,s=Math.max(e,pn.MAX_GOAL_BUFFER_LENGTH);return Math.min(e+t*a,s)}},{key:"bufferLowWaterLine",value:function(){var t=this.tech_.currentTime(),e=pn.BUFFER_LOW_WATER_LINE,a=pn.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(e,pn.MAX_BUFFER_LOW_WATER_LINE);return Math.min(e+t*a,s)}}]),r}(oe.EventTarget),bL=function(r,i,t){return function(e){var a=r.master.playlists[i],s=Hg(a),o=lf(a);return typeof e>"u"?o:(e?delete a.disabled:a.disabled=!0,e!==o&&!s&&(t(),e?r.trigger("renditionenabled"):r.trigger("renditiondisabled")),e)}},SL=function n(r,i,t){Rn(this,n);var e=r.masterPlaylistController_,a=r.options_.smoothQualityChange,s=a?"smooth":"fast",o=e[s+"QualityChange_"].bind(e);if(i.attributes.RESOLUTION){var u=i.attributes.RESOLUTION;this.width=u.width,this.height=u.height}this.bandwidth=i.attributes.BANDWIDTH,this.id=t,this.enabled=bL(r.playlists,i.uri,o)},EL=function(r){var i=r.playlists;r.representations=function(){return i.master.playlists.filter(function(t){return!Hg(t)}).map(function(t,e){return new SL(r,t,t.uri)})}},gS=["seeking","seeked","pause","playing","error"],xL=function(){function n(r){var i=this;Rn(this,n),this.tech_=r.tech,this.seekable=r.seekable,this.seekTo=r.seekTo,this.allowSeeksWithinUnsafeLiveWindow=r.allowSeeksWithinUnsafeLiveWindow,this.media=r.media,this.consecutiveUpdates=0,this.lastRecordedTime=null,this.timer_=null,this.checkCurrentTimeTimeout_=null,this.logger_=_d("PlaybackWatcher"),this.logger_("initialize");var t=function(){return i.monitorCurrentTime_()},e=function(){return i.techWaiting_()},a=function(){return i.cancelTimer_()},s=function(){return i.fixesBadSeeks_()};this.tech_.on("seekablechanged",s),this.tech_.on("waiting",e),this.tech_.on(gS,a),this.tech_.on("canplay",t),this.dispose=function(){i.logger_("dispose"),i.tech_.off("seekablechanged",s),i.tech_.off("waiting",e),i.tech_.off(gS,a),i.tech_.off("canplay",t),i.checkCurrentTimeTimeout_&&Pe.clearTimeout(i.checkCurrentTimeTimeout_),i.cancelTimer_()}}return qn(n,[{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(),t=this.tech_.buffered();if(this.lastRecordedTime===i&&(!t.length||i+Ja>=t.end(t.length-1)))return this.techWaiting_();this.consecutiveUpdates>=5&&i===this.lastRecordedTime?(this.consecutiveUpdates++,this.waiting_()):i===this.lastRecordedTime?this.consecutiveUpdates++:(this.consecutiveUpdates=0,this.lastRecordedTime=i)}}},{key:"cancelTimer_",value:function(){this.consecutiveUpdates=0,this.timer_&&(this.logger_("cancelTimer_"),clearTimeout(this.timer_)),this.timer_=null}},{key:"fixesBadSeeks_",value:function(){var i=this.tech_.seeking();if(!i)return!1;var t=this.seekable(),e=this.tech_.currentTime(),a=this.afterSeekableWindow_(t,e,this.media(),this.allowSeeksWithinUnsafeLiveWindow),s=void 0;if(a){var o=t.end(t.length-1);s=o}if(this.beforeSeekableWindow_(t,e)){var u=t.start(0);s=u+Ja}return typeof s<"u"?(this.logger_("Trying to seek outside of seekable at time "+e+" with "+("seekable range "+qg(t)+". Seeking to ")+(s+".")),this.seekTo(s),!0):!1}},{key:"waiting_",value:function(){if(!this.techWaiting_()){var i=this.tech_.currentTime(),t=this.tech_.buffered(),e=Vb(t,i);if(e.length&&i+3<=e.end(0)){this.cancelTimer_(),this.seekTo(i),this.logger_("Stopped at "+i+" while inside a buffered region "+("["+e.start(0)+" -> "+e.end(0)+"]. Attempting to resume ")+"playback by seeking to the current time."),this.tech_.trigger({type:"usage",name:"hls-unknown-waiting"});return}}}},{key:"techWaiting_",value:function(){var i=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking()&&this.fixesBadSeeks_()||this.tech_.seeking()||this.timer_!==null)return!0;if(this.beforeSeekableWindow_(i,t)){var e=i.end(i.length-1);return this.logger_("Fell out of live window at time "+t+". Seeking to "+("live point (seekable end) "+e)),this.cancelTimer_(),this.seekTo(e),this.tech_.trigger({type:"usage",name:"hls-live-resync"}),!0}var a=this.tech_.buffered(),s=qb(a,t);if(this.videoUnderflow_(s,a,t))return this.cancelTimer_(),this.seekTo(t),this.tech_.trigger({type:"usage",name:"hls-video-underflow"}),!0;if(s.length>0){var o=s.start(0)-t;return this.logger_("Stopped at "+t+", setting timer for "+o+", seeking "+("to "+s.start(0))),this.timer_=setTimeout(this.skipTheGap_.bind(this),o*1e3,t),!0}return!1}},{key:"afterSeekableWindow_",value:function(i,t,e){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!i.length)return!1;var s=i.end(i.length-1)+Ja,o=!e.endList;return o&&a&&(s=i.end(i.length-1)+e.targetDuration*3),t>s}},{key:"beforeSeekableWindow_",value:function(i,t){return!!(i.length&&i.start(0)>0&&t<i.start(0)-Ja)}},{key:"videoUnderflow_",value:function(i,t,e){if(i.length===0){var a=this.gapFromVideoUnderflow_(t,e);if(a)return this.logger_("Encountered a gap in video from "+a.start+" to "+a.end+". "+("Seeking to current time "+e)),!0}return!1}},{key:"skipTheGap_",value:function(i){var t=this.tech_.buffered(),e=this.tech_.currentTime(),a=qb(t,e);this.cancelTimer_(),!(a.length===0||e!==i)&&(this.logger_("skipTheGap_:","currentTime:",e,"scheduled currentTime:",i,"nextRange start:",a.start(0)),this.seekTo(a.start(0)+cf),this.tech_.trigger({type:"usage",name:"hls-gap-skip"}))}},{key:"gapFromVideoUnderflow_",value:function(i,t){for(var e=cI(i),a=0;a<e.length;a++){var s=e.start(a),o=e.end(a);if(t-s<4&&t-s>2)return{start:s,end:o}}return null}}]),n}(),AL={errorInterval:30,getSource:function(r){var i=this.tech({IWillNotUseThisInPlugins:!0}),t=i.currentSource_;return r(t)}},CL=function n(r,i){var t=0,e=0,a=oe.mergeOptions(AL,i);r.ready(function(){r.trigger({type:"usage",name:"hls-error-reload-initialized"})});var s=function(){e&&r.currentTime(e)},o=function(f){f!=null&&(e=r.duration()!==1/0&&r.currentTime()||0,r.one("loadedmetadata",s),r.src(f),r.trigger({type:"usage",name:"hls-error-reload"}),r.play())},u=function(){if(Date.now()-t<a.errorInterval*1e3){r.trigger({type:"usage",name:"hls-error-reload-canceled"});return}if(!a.getSource||typeof a.getSource!="function"){oe.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),a.getSource.call(r,o)},l=function d(){r.off("loadedmetadata",s),r.off("error",u),r.off("dispose",d)},c=function(f){l(),n(r,f)};r.on("error",u),r.on("dispose",l),r.reloadSourceOnError=c},vS=function(r){CL(this,r)},wL="1.10.6";oe.use("*",function(n){return{setSource:function(i,t){t(null,i)},setCurrentTime:function(i){return n.vhs&&n.currentSource().src===n.vhs.source_.src&&n.vhs.setCurrentTime(i),i},play:function(){n.vhs&&n.currentSource().src===n.vhs.source_.src&&n.vhs.setCurrentTime(n.tech_.currentTime())}}});var tn={PlaylistLoader:uf,Playlist:en,Decrypter:sP,AsyncStream:B_,decrypt:U_,utils:rI,STANDARD_PLAYLIST_SELECTOR:KI,INITIAL_PLAYLIST_SELECTOR:XI,comparePlaylistBandwidth:Jg,comparePlaylistResolution:$I,xhr:Nb()};["GOAL_BUFFER_LENGTH","MAX_GOAL_BUFFER_LENGTH","GOAL_BUFFER_LENGTH_RATE","BUFFER_LOW_WATER_LINE","MAX_BUFFER_LOW_WATER_LINE","BUFFER_LOW_WATER_LINE_RATE","BANDWIDTH_VARIANCE"].forEach(function(n){Object.defineProperty(tn,n,{get:function(){return oe.log.warn("using Hls."+n+" is UNSAFE be sure you know what you are doing"),pn[n]},set:function(i){if(oe.log.warn("using Hls."+n+" is UNSAFE be sure you know what you are doing"),typeof i!="number"||i<0){oe.log.warn("value of Hls."+n+" must be greater than or equal to 0");return}pn[n]=i}})});var mS="videojs-vhs",yS=function(r){var i=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;if(i.test(r))return"hls";var t=/^application\/dash\+xml/i;return t.test(r)?"dash":null},_S=function(r,i){for(var t=i.media(),e=-1,a=0;a<r.length;a++)if(r[a].id===t.uri){e=a;break}r.selectedIndex_=e,r.trigger({selectedIndex:e,type:"change"})},kL=function(r,i){i.representations().forEach(function(t){r.addQualityLevel(t)}),_S(r,i.playlists)};tn.canPlaySource=function(){return oe.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var DL=function(r,i,t){if(!r)return r;var e={};for(var a in r)e[a]={audioContentType:'audio/mp4; codecs="'+t.attributes.CODECS+'"',videoContentType:'video/mp4; codecs="'+i.attributes.CODECS+'"'},i.contentProtection&&i.contentProtection[a]&&i.contentProtection[a].pssh&&(e[a].pssh=i.contentProtection[a].pssh),typeof r[a]=="string"&&(e[a].url=r[a]);return oe.mergeOptions(r,e)},PL=function(r){if(r.options_.sourceType==="dash"){var i=oe.players[r.tech_.options_.playerId];if(i.eme){var t=DL(r.source_.keySystems,r.playlists.media(),r.masterPlaylistController_.mediaTypes_.AUDIO.activePlaylistLoader.media());t&&(i.currentSource().keySystems=t,i.eme.initializeMediaKeys&&i.eme.initializeMediaKeys())}}},TS=function(){if(!window.localStorage)return null;var r=window.localStorage.getItem(mS);if(!r)return null;try{return JSON.parse(r)}catch{return null}},RL=function(r){if(!window.localStorage)return!1;var i=TS();i=i?oe.mergeOptions(i,r):r;try{window.localStorage.setItem(mS,JSON.stringify(i))}catch{return!1}return i};tn.supportsNativeHls=function(){var n=vt.createElement("video");if(!oe.getTech("Html5").isSupported())return!1;var r=["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"];return r.some(function(i){return/maybe|probably/i.test(n.canPlayType(i))})}(),tn.supportsNativeDash=function(){return oe.getTech("Html5").isSupported()?/maybe|probably/i.test(vt.createElement("video").canPlayType("application/dash+xml")):!1}(),tn.supportsTypeNatively=function(n){return n==="hls"?tn.supportsNativeHls:n==="dash"?tn.supportsNativeDash:!1},tn.isSupported=function(){return oe.log.warn("HLS is no longer a tech. Please remove it from your player's techOrder.")};var IL=oe.getComponent("Component"),bS=function(n){Qa(r,n);function r(i,t,e){Rn(this,r);var a=ma(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t,e.hls));if(t.options_&&t.options_.playerId){var s=oe(t.options_.playerId);s.hasOwnProperty("hls")||Object.defineProperty(s,"hls",{get:function(){return oe.log.warn("player.hls is deprecated. Use player.tech().hls instead."),t.trigger({type:"usage",name:"hls-player-access"}),a},configurable:!0}),s.vhs=a,s.dash=a,a.player_=s}if(a.tech_=t,a.source_=i,a.stats={},a.setOptions_(),a.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(a.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native HLS requires emulated tracks. See https://git.io/vMpjB");return a.on(vt,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],function(o){var u=vt.fullscreenElement||vt.webkitFullscreenElement||vt.mozFullScreenElement||vt.msFullscreenElement;u&&u.contains(a.tech_.el())&&a.masterPlaylistController_.smoothQualityChange_()}),a.on(a.tech_,"seeking",function(){this.tech_.currentTime()===0&&this.tech_.player_.loop()&&this.setCurrentTime(0)}),a.on(a.tech_,"error",function(){this.masterPlaylistController_&&this.masterPlaylistController_.pauseLoading()}),a.on(a.tech_,"play",a.play),a}return qn(r,[{key:"setOptions_",value:function(){var t=this;if(this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.handleManifestRedirects=this.options_.handleManifestRedirects||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.smoothQualityChange=this.options_.smoothQualityChange||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,typeof this.options_.blacklistDuration!="number"&&(this.options_.blacklistDuration=5*60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){var e=TS();e&&e.bandwidth&&(this.options_.bandwidth=e.bandwidth,this.tech_.trigger({type:"usage",name:"hls-bandwidth-from-local-storage"})),e&&e.throughput&&(this.options_.throughput=e.throughput,this.tech_.trigger({type:"usage",name:"hls-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=pn.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===pn.INITIAL_BANDWIDTH,["withCredentials","limitRenditionByPlayerDimensions","bandwidth","smoothQualityChange","customTagParsers","customTagMappers","handleManifestRedirects","cacheEncryptionKeys"].forEach(function(a){typeof t.source_[a]<"u"&&(t.options_[a]=t.source_[a])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions}},{key:"src",value:function(t,e){var a=this;!t||(this.setOptions_(),this.options_.url=this.source_.src,this.options_.tech=this.tech_,this.options_.externHls=tn,this.options_.sourceType=yS(e),this.options_.seekTo=function(s){a.tech_.setCurrentTime(s),a.setCurrentTime(s)},this.masterPlaylistController_=new TL(this.options_),this.playbackWatcher_=new xL(oe.mergeOptions(this.options_,{seekable:function(){return a.seekable()},media:function(){return a.masterPlaylistController_.media()}})),this.masterPlaylistController_.on("error",function(){var s=oe.players[a.tech_.options_.playerId];s.error(a.masterPlaylistController_.error)}),this.masterPlaylistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):tn.STANDARD_PLAYLIST_SELECTOR.bind(this),this.masterPlaylistController_.selectInitialPlaylist=tn.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.masterPlaylistController_.masterPlaylistLoader_,this.mediaSource=this.masterPlaylistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get:function(){return this.masterPlaylistController_.selectPlaylist},set:function(o){this.masterPlaylistController_.selectPlaylist=o.bind(this)}},throughput:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.throughput.rate},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.throughput.rate=o,this.masterPlaylistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get:function(){return this.masterPlaylistController_.mainSegmentLoader_.bandwidth},set:function(o){this.masterPlaylistController_.mainSegmentLoader_.bandwidth=o,this.masterPlaylistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get:function(){var o=1/(this.bandwidth||1),u=void 0;this.throughput>0?u=1/this.throughput:u=0;var l=Math.floor(1/(o+u));return l},set:function(){oe.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 $b(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 $b(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&&RL({bandwidth:a.bandwidth,throughput:Math.round(a.throughput)})}),this.masterPlaylistController_.on("selectedinitialmedia",function(){EL(a),PL(a)}),this.on(this.masterPlaylistController_,"progress",function(){this.tech_.trigger("progress")}),this.tech_.ready(function(){return a.setupQualityLevels_()}),this.tech_.el()&&this.tech_.src(oe.URL.createObjectURL(this.masterPlaylistController_.mediaSource)))}},{key:"setupQualityLevels_",value:function(){var t=this,e=oe.players[this.tech_.options_.playerId];e&&e.qualityLevels&&(this.qualityLevels_=e.qualityLevels(),this.masterPlaylistController_.on("selectedinitialmedia",function(){kL(t.qualityLevels_,t)}),this.playlists.on("mediachange",function(){_S(t.qualityLevels_,t.playlists)}))}},{key:"play",value:function(){this.masterPlaylistController_.play()}},{key:"setCurrentTime",value:function(t){this.masterPlaylistController_.setCurrentTime(t)}},{key:"duration",value:function(){return this.masterPlaylistController_.duration()}},{key:"seekable",value:function(){return this.masterPlaylistController_.seekable()}},{key:"dispose",value:function(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.masterPlaylistController_&&this.masterPlaylistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.player_&&(delete this.player_.vhs,delete this.player_.dash,delete this.player_.hls),this.tech_&&this.tech_.hls&&delete this.tech_.hls,IR(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"dispose",this).call(this)}},{key:"convertToProgramTime",value:function(t,e){return lI({playlist:this.masterPlaylistController_.media(),time:t,callback:e})}},{key:"seekToProgramTime",value:function(t,e){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:2;return dI({programTime:t,playlist:this.masterPlaylistController_.media(),retryCount:s,pauseAfterSeek:a,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:e})}}]),r}(IL),tv={name:"videojs-http-streaming",VERSION:wL,canHandleSource:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=oe.mergeOptions(oe.options,i);return tv.canPlayType(r.type,t)},handleSource:function(r,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},e=oe.mergeOptions(oe.options,t);return i.hls=new bS(r,i,e),i.hls.xhr=Nb(),i.hls.src(r.src,r.type),i.hls},canPlayType:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=oe.mergeOptions(oe.options,i),e=t.hls.overrideNative,a=yS(r),s=a&&(!tn.supportsTypeNatively(a)||e);return s?"maybe":""}};(typeof oe.MediaSource>"u"||typeof oe.URL>"u")&&(oe.MediaSource=yd,oe.URL=iS),yd.supportsNativeMediaSources()&&oe.getTech("Html5").registerSourceHandler(tv,0),oe.HlsHandler=bS,oe.HlsSourceHandler=tv,oe.Hls=tn,oe.use||oe.registerComponent("Hls",tn),oe.options.hls=oe.options.hls||{},oe.registerPlugin?oe.registerPlugin("reloadSourceOnError",vS):oe.plugin("reloadSourceOnError",vS);const LL=Object.freeze(Object.defineProperty({__proto__:null,default:oe},Symbol.toStringTag,{value:"Module"})),OL={name:"stream-engine-player",version:"0.0.25",description:"Stream engine player",type:"module",files:["dist","src","index.js","README.md","LICENSE","package.json","vite.config.js"],exports:{".":{import:"./dist/stream-engine-player.mjs",require:"./dist/stream-engine-player.js"},"./style":{import:"./dist/style.css",require:"./dist/style.css"},"./bundle":{import:"./dist/stream-engine-player-bundle.mjs",require:"./dist/stream-engine-player-bundle.js"}},main:"dist/stream-engine-player.js",author:"Dok Umansky",scripts:{dev:"vite serve",build:'concurrently "vite build --mode bundle" "vite build"',serve:"vite preview",start:"npm run dev",prebuild:"rm -rf dist","version:patch":"npm version patch",lint:"./node_modules/.bin/eslint src",format:'prettier "src/**/*.{ts,js,json,scss,css}" --write',watch:'concurrently "vite build --watch" "vite serve"',"build:watch":"vite build --watch --minify=false"},dependencies:{angular:"~1.4.8","angular-cookies":"~1.4.8","font-awesome":"^4.7.0","hls.js":"^0.12.4","include-media":"^2.0.0",localforage:"^1.10.0","m3u8-parser":"^7.1.0","mixpanel-browser":"2.52.0","video.js":"7.6.6","videojs-youtube":"^2.6.1","videojs-ima":"1.7.5","videojs-contrib-ads":"6.6.5","videojs-mux":"4.19.0","infront-logger":"1.1.11"},devDependencies:{concurrently:"^8.2.1",eslint:"^8.24.0","eslint-config-prettier":"^8.5.0","eslint-plugin-angular":"^4.1.0","eslint-plugin-prettier":"^4.2.1",husky:"^8.0.1",hygen:"^6.2.11","lint-staged":"^13.0.3",prettier:"^2.7.1",sass:"^1.55.0",vite:"^3.2.7"},husky:{hooks:{"pre-commit":"lint-staged"}},"lint-staged":{"*.{ts,js,json,scss,css}":["prettier --write","git add"]}},s5="";/**
|
|
89
89
|
* @license AngularJS v1.4.14
|
|
90
90
|
* (c) 2010-2015 Google, Inc. http://angularjs.org
|
|
91
91
|
* License: MIT
|